query_id
stringlengths
32
32
query
stringlengths
7
29.6k
positive_passages
listlengths
1
1
negative_passages
listlengths
88
101
9e4c5fe110ed98b1fdbd4408bec62c62
gets the youtube thumbnail
[ { "docid": "dd4ea03d4e9b61cc7b88144570e67923", "score": "0.6952558", "text": "function getYoutubeThumbnail(){\n // var portfolio = {{ site.data.portfolio | jsonify }};\n // console.log(portfolio);\n }", "title": "" } ]
[ { "docid": "f531f4280411a82b1b50c204cc037b99", "score": "0.7627644", "text": "function setYoutubeThumbnail(){\n }", "title": "" }, { "docid": "d094c7ba0440d92f337340490f704317", "score": "0.75822365", "text": "function get_url_thumb_youtube(embed_src) {\n const thumb = '/maxresdefault.webp';\n const base_uri_img = 'https://i.ytimg.com/vi_webp/';\n const uri = url.parse(embed_src);\n if (uri.hostname === 'www.youtube.com' && uri.pathname.includes('/embed/')) {\n const path = uri.pathname.replace('/embed/','') + thumb;\n return url.resolve(base_uri_img, path);\n }\n return undefined;\n }", "title": "" }, { "docid": "3974d47125201f628fd11b020420b965", "score": "0.73327124", "text": "function youtubeVideoThumbnail(key) {\n return `https://img.youtube.com/vi/${key}/maxresdefault.jpg`\n}", "title": "" }, { "docid": "80723fd6122ef07377a670ae9bad8cb8", "score": "0.69192624", "text": "function update_thumbnail() {\n let url = document.getElementById('url-field').value;\n let video_id = youtube_url_parser(url);\n let picture_url = 'img/noinput.svg';\n if(video_id !== false) {\n picture_url = 'https://img.youtube.com/vi/' + video_id + '/0.jpg';\n }\n document.getElementById('video-thumbnail').src = picture_url;\n}", "title": "" }, { "docid": "cccb4202d2293b40b79de3e4619e7e53", "score": "0.6880093", "text": "function loadYouTubeThumbnails() {\r\n // frames without video are automatically ignored:\r\n $.each(settings.path, function (i, frameId) {\r\n youTube.loadThumbnailUrl(frameId, function (url) {\r\n drawYouTubeThumbnail(frameId, url);\r\n });\r\n });\r\n }", "title": "" }, { "docid": "d61566a2049f4bbf8e06a38680fa1e9b", "score": "0.67819065", "text": "getThumbnailUrl() {\n if (this.noThumbnail === '1') {\n return this.getUrl();\n }\n\n return this.getResizedImageUrl('t');\n }", "title": "" }, { "docid": "97f575acffed0d225d84eea7a675eb95", "score": "0.6699561", "text": "function buildThumbs() {\n\t\t$.getJSON(URL, function(data) {\n\n\t\t\t$('#video-section').html('');\n\n\t\t\tvar myData = data.items;\n\n\t\t\tfor (var x in myData) {\n\t\t\t\tvar idLink = myData[x].id.videoId;\n\t\t\t\tvar thumbLink = myData[x].snippet.thumbnails.medium.url;\n\t\t\t\tvar title = myData[x].snippet.title;\n\n\t\t\t\tif(title.length > 35) {\n\t\t\t\t\ttitle = title.substring(0,35)+\"...\"; \n\t\t\t\t}\n\n\t\t\t\tvar ytURL = 'https://www.youtube.com/watch?v=';\n\t\t\t\t$('#video-section').append('<li><p>' + title + '<br /><a target=\"_blank\" href=' + ytURL + idLink + '><img src=\"' + thumbLink + '\"></a></p></li>');\n\t\t\t\t//.append('<li><p>' + title + '</p><a target=\"_blank\" href=' + ytURL + idLink + '><img src=\"' + thumbLink + '\"></a></li.block>');\n\t\t\t\t//console.log(myData[x].snippet.thumbnails.medium.url);\n\t\t\t}\n\t\t});\n\n\t}", "title": "" }, { "docid": "dae87e69defc433a5042905f9a2da25c", "score": "0.66518116", "text": "function labnolThumb(id) {\n\t\t\t\tvar thumb = '<img src=\"https://img.youtube.com/vi/ID/maxresdefault.jpg\">',\n\t\t\t\t\tplay = '<div class=\"play\"></div>';\n\t\t\t\treturn thumb.replace(\"ID\", id) + play;\n\t\t\t}", "title": "" }, { "docid": "0f628757a1d6548724952ec26f534192", "score": "0.64957297", "text": "async function getThumbnail() {\n context = canvas.getContext(\"2d\");\n ratio = video.videoWidth / video.videoHeight;\n w = video.videoWidth - 100;\n h = parseInt(w / ratio, 10);\n canvas.width = w * 0.5;\n canvas.height = h * 0.5;\n context.fillRect(0, 0, w * 0.5, h * 0.5);\n context.drawImage(video, 0, 0, w * 0.5, h * 0.5);\n canvas.toBlob((blob) => {\n const storageRef = ref(storage, \"thumbnails/\" + fName);\n\n uploadBytes(storageRef, blob).then((snapshot) => {\n getDownloadURL(snapshot.ref).then((thumbURL) => {\n thumbnailUrl = thumbURL;\n });\n });\n });\n return thumU;\n }", "title": "" }, { "docid": "d2db85484181a5be0df4847f1ea54bd0", "score": "0.6464614", "text": "function YTIDToImg(YTID){\n var img = document.createElement('img');\n img.src = 'http://img.youtube.com/vi/'+YTID+'/sddefault.jpg';\n return img;\n}", "title": "" }, { "docid": "9c8b5d0c8b46c0571ae0b0696315a11f", "score": "0.63753444", "text": "function getYoutubeMedia() {\n const youtubeMedia = document.querySelectorAll(\"[is-youtube='true']\")[0];\n return youtubeMedia;\n}", "title": "" }, { "docid": "52fec80c1f867c9cf02566aeed048945", "score": "0.6289707", "text": "function xImageViewLoadVideoThumbnail(this_, video) {\n const imageView = getImageView(this_);\n if (imageView === null)\n return;\n if (video !== null) {\n imageView.src = \"\";\n Video_ext_1.xVideoThumbnail(video).subscribe((x) => {\n xImageViewLoadImage(imageView, x);\n });\n }\n}", "title": "" }, { "docid": "3f907b3c9494c828c40eae7afb063c7c", "score": "0.62624156", "text": "async function getNewThumb(vimeoDataURL) {\n return axios\n .get(vimeoDataURL, {})\n .then(res => {\n // console.log(`statusCode: ${res.status}`)\n return res.data[0].thumbnail_large;\n })\n .catch(error => {\n // console.error(error)\n return null;\n })\n}", "title": "" }, { "docid": "48fda017f10965b3b2f19aa1b68bb7f5", "score": "0.61294526", "text": "function pullYoutube(videoID) {\n\n fetch('https://www.googleapis.com/youtube/v3/videos?id=' + videoID + '&key=AIzaSyCD-KLjB1ggkVaDarraIp9NgwndXJqBRDo&fields=items(id,snippet(channelId,title,categoryId,description,thumbnails),statistics,contentDetails,player)&part=snippet,statistics,contentDetails,player')\n\n .then(function (response) {\n return response.json();\n })\n .then(function (data) {\n console.log(data);\n console.log(data.items[0].player.embedHtml);\n var video = (data.items[0].player.embedHtml);\n var container = document.getElementById('youtube');\n container.innerHTML = video;\n })\n\n .catch(error => {\n console.log(error);\n });\n}", "title": "" }, { "docid": "9cdf12bee18231627f2dfad7381cc047", "score": "0.6101235", "text": "get ThumbnailUrl() {\n return this.thumbnailUrl;\n }", "title": "" }, { "docid": "c3e59252fb3cc7d6e8880e6a72f93d4c", "score": "0.60943276", "text": "function getData() {\n $.getJSON(url, params, function(data){\n videos = data.items.length;\n for (var i = 0; i <= videos; i++) {\n thumb = data.items[i].snippet.thumbnails.medium.url;\n ID = data.items[i].id.videoId;\n $('#search-results').append(\"<a href='https://www.youtube.com/watch?v=\" + ID + \"'>\" + \"<img src='\" + thumb + \"'>\" + \"</a>\");\n }\n });\n }", "title": "" }, { "docid": "6ec3321c6c90151a77c10ddb2a580a01", "score": "0.6093055", "text": "function createThumbnail(vidInfo) {\n var thumbnail= YTIDToImg(vidInfo.YTID);\n\n thumbnail.onclick= function(){\n playNewVideo(vidInfo.YTID);\n removeThumbnail(vidInfo.thumbnailID);\n //Changes title of header to match that of curr video playing\n document.getElementById(\"videoTitle\").innerHTML=vidInfo.vidTitle;};\n thumbnail.classList.add(\"thumbnail\");\n\n return thumbnail;\n}", "title": "" }, { "docid": "c3ceb152d84f35717ea01ab45062b8fe", "score": "0.60630566", "text": "function onYouTubeIframeAPIReady() {\n if (debug) console.log('onYouTubeIframeAPIReady');\n\n if (Boolean(document.querySelectorAll(\"[data-js=photoswipe-item]\"))) {\n mswpScanPage();\n }\n\n video_n_thumb_player = new YT.Player('video-n-thumb__video-container', {\n events: {\n 'onReady': function () {\n document.querySelectorAll(\"[data-js=video-n-thumb__thumb]\").forEach(thumb => {\n thumb.addEventListener(\"click\", e => {\n let video_n_thumb = thumb.closest(\"[data-js=video-n-thumb]\");\n let video_id = video_n_thumb.getAttribute(\"data-video-id\");\n // let video_container = video_n_thumb.querySelector(\"[data-js=video-n-thumb__video-container]\");\n\n // video_container.innerHTML = '<iframe width=\"100%\" height=\"100%\" src=\"https://www.youtube.com/embed/' + video_id + '?&autoplay=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>';\n video_n_thumb_player.loadVideoById(video_id);\n thumb.style.display = \"none\";\n })\n });\n }\n }\n });\n\n\n}", "title": "" }, { "docid": "e7195ab9ffcbe027cbd407a3b578dd5d", "score": "0.6062599", "text": "function showVideo(item) {\n\tvar videoID = item.id.videoId;\n\tvar videoThumb = item.snippet.thumbnails.medium.url;\n\tvar getTitle = item.snippet.title;\n\t// console.log(videoID);\n\t// console.log(videoThumb);\n\t// console.log(getTitle);\n\treturn '<a href=https://youtube.com/watch?v=' + videoID + '>' + getTitle + '<br><img src=\"' + videoThumb + '\"></a><br>';\n}", "title": "" }, { "docid": "4c29268c8a5326cdcf67b21af8fbde22", "score": "0.60574424", "text": "function getYouTube(src) {\n if (!src) {\n return '';\n } else if (!src.includes(\"youtube.com/embed/\")) {\n src = src.replace(\"www.youtube.com/watch?v=\", \"www.youtube.com/embed/\");\n }\n return '<iframe src=\"' + src + '\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>';\n}", "title": "" }, { "docid": "f987d507315a66c610c7904756de8993", "score": "0.597004", "text": "function createDisplayThumbnail(videoSnippet) {\n var titleEl = $('<h3>');\n titleEl.addClass('video-title');\n $(titleEl).html(videoSnippet.title);\n var thumbnailUrl = videoSnippet.thumbnails.medium.url;\n\n var div = $('<div>');\n div.addClass('video-content');\n div.css('backgroundImage', 'url(\"' + thumbnailUrl + '\")');\n div.append(titleEl);\n $('#video-container').append(div);\n}", "title": "" }, { "docid": "551fd6a1faf760d5195853c6ab53edcf", "score": "0.5949311", "text": "function youtube_parser(url){\n var regExp = /^.*((youtu.be\\/)|(v\\/)|(\\/u\\/\\w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*/;\n var match = url.match(regExp);\n if (match&&match[7].length==11){\n return match[7];\n }else{\n $(\"#infodiv\").show();\n $(\"#errordiv\").show();\n return 0;\n }\n}", "title": "" }, { "docid": "402fcc4aae4410ec188346d69a1b5a3d", "score": "0.5932116", "text": "_getImageThumbnail(image) {\n if (image) {\n if (image.thumbnail) {\n return image.thumbnail;\n }\n return image;\n }\n return \"\";\n }", "title": "" }, { "docid": "ed6627adbcb0003f381e29f238ca2378", "score": "0.5927952", "text": "get videoHub_1stVideoThumbImage() {return browser.element(\"//android.widget.ScrollView/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup[1]\");}", "title": "" }, { "docid": "e6b9266ee6bcbab89896f72dccfc79bc", "score": "0.58987015", "text": "function initializeYouTube() {\r\n var youTubeSettings = $.extend({}, settings.youTube, {\r\n containerNode: createYouTubeContainerNode(),\r\n path: settings.path\r\n });\r\n\r\n youTube = presvg.youTube(youTubeSettings);\r\n\r\n loadYouTubeThumbnails();\r\n }", "title": "" }, { "docid": "7652c63ca7fb77c68a80d203c337bbe2", "score": "0.58985", "text": "getLargeVideo() {\n return largeVideo;\n }", "title": "" }, { "docid": "6e4b160c102c6a6e27139f2cc8be7f5b", "score": "0.58917236", "text": "function get_thumbnail_path(site, protocol) {\n\treturn get_selected_dir() + '/site_screenshots/' + site + '-' \n\t\t+ protocol + '_thumb.png';\n}", "title": "" }, { "docid": "b71f52e57b062775531c81b1982e00f9", "score": "0.58717155", "text": "function getYoutubeVideoId(url){\n\t\tvar a = $('<a>', { href:url } )[0];\n\t\tvar urlPathName = a.pathname;\n\t\tvar splits = urlPathName.split('/');\n\t\treturn splits[2];\n\t}", "title": "" }, { "docid": "8a87d515e4fa39cf8ec511646963f0cb", "score": "0.58273476", "text": "function YouTubeEmbed() {\n return _super.call(this, _BaseWebpart__WEBPACK_IMPORTED_MODULE_0__[\"WebpartType\"].YouTube, _BaseWebpart__WEBPACK_IMPORTED_MODULE_0__[\"WebpartType\"].YouTube.toString()) || this;\n }", "title": "" }, { "docid": "2dc55a0498488ac4e3bf52291f5fcbd3", "score": "0.5819596", "text": "function parseYoutubeURL(content) {\n\tvar regEx = /^.*((youtu.be\\/)|(v\\/)|(\\/u\\/\\w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*/;\n\tvar match = content.match(regEx);\n\t//the youtube id will be in match[7]. can verify with console.log\n\t//console.log(match);\n\n\treturn match;\n}", "title": "" }, { "docid": "59c1335ed641bab2375ca64bd6411e2f", "score": "0.5784098", "text": "function getYoutubeUrl(url) {\n if (url == null || url === \"\") return url;\n var regExp = /^.*(youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=|\\&v=)([^#\\&\\?]{11,11}).*/;\n var match = url.match(regExp);\n if (match)\n if (match.length >= 2) {\n url = \"https://www.youtube.com/embed/\" + match[2];\n }\n return url;\n }", "title": "" }, { "docid": "6195f321fb6ca0c5ec79494730f68945", "score": "0.5767117", "text": "function getYouTube(response2){\n\t\n\tvar id = localStorage.getItem(\"gameID\");\n\tvar queryYouTube = `https://api.rawg.io/api/games/${id}/youtube`;\n\t\n\t\n\t$.ajax({\n\t\turl: queryYouTube,\n\t\tmethod: \"GET\"\n\t}).then(function(response2){\n\t\tconsole.log(response2);\n\n\t\tvar externalID = response2.results[0].external_id;\n\t\tif (externalID !== null)\n\t\t$(\"#game-title\").attr(\"href\", \"https://www.youtube.com/watch?v=\" + externalID).addClass(\"uniqueURL\");\n\t});\n}", "title": "" }, { "docid": "bad3c424cc6a9d9e3aaf21233aca9536", "score": "0.5753619", "text": "function showVideo(title, videoId, thumbnails) {\n return `\n <div class=\"card\" style=\"width: 70rem;\">\n <img class=\"card-img-top\" style=\"width: 35rem;\" src=\"${thumbnails.medium.url}\" alt=\"Card image cap\">\n <div class=\"card-body\">\n <p class=\"card-text\"><font size=\"4.5\">${title}<\\p>\n <button type=\"button\" class=\"btn btn-secondary\"><a href=\"http://www.youtube.com/embed/${videoId}\">LINK</a></button>\n\n </div>\n </div>`; \n}", "title": "" }, { "docid": "ce7627a40ced08b561bdeea2c2e974db", "score": "0.57498384", "text": "function generateThumbnail() {\n var c = document.createElement(\"canvas\");\n var ctx = c.getContext(\"2d\");\n c.width = 160;\n c.height = 90;\n ctx.drawImage(video, 0, 0, 160, 90);\n thumbsList.push(c); // store this frame in our list\n if (thumbsList.length === 1) {\n displayThumbs(); // start animating as soon as we got a frame\n }\n}", "title": "" }, { "docid": "b5f17452dd1e0d56b4f69117f9c7f948", "score": "0.5744943", "text": "function getYouTubeEmbedUrl(youTubeLink) {\n var embedUrl = 'https://www.youtube.com/embed/';\n console.log(youTubeLink);\n var youTubeLinkParts = youTubeLink.split('/');\n var id = youTubeLinkParts[youTubeLinkParts.length - 1];\n embedUrl += id;\n console.log(embedUrl);\n return $sce.trustAsResourceUrl(embedUrl);\n\n }", "title": "" }, { "docid": "f6cfbb7cdec63aae3aa3bbef83b0d1f6", "score": "0.5742281", "text": "function youtube_parser(url) {\n var regExp = /^.*((youtu.be\\/)|(v\\/)|(\\/u\\/\\w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*/;\n var match = url.match(regExp);\n if (match && match[7].length == 11) {\n return match[7];\n } else {\n return url;\n }\n}", "title": "" }, { "docid": "6f5d8eefeb5b532a3e9d485c5f6d6ae7", "score": "0.5736822", "text": "function youtube_parser(url) {\r\n\t\t\tvar regExp = /^.*((youtu.be\\/)|(v\\/)|(\\/u\\/\\w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*/;\r\n\t\t\tvar match = url.match(regExp);\r\n\t\t\tif (match && match[7].length == 11) {\r\n\t\t\t\treturn match[7];\r\n\t\t\t} else {\r\n\t\t\t\tconsole.error('PrettyEmbed.js Error: Bad URL.');\r\n\t\t\t}\r\n\t\t}", "title": "" }, { "docid": "9faf166a5f692346391354d8a98a77e5", "score": "0.5725171", "text": "function getYoutubeID(url) {\n var id = url.match(\"[\\\\?&]v=([^&#]*)\");\n id = id[1];\n return id;\n}", "title": "" }, { "docid": "edcef4c8d67f116ddf0991c9d1c74499", "score": "0.57190907", "text": "function thumbnail(session) {\n if(!img_out)\n img_out = PUBNUB.$('video-thumbnail');\n\n img_out.innerHTML = '';\n img_out.appendChild(session.image);\n img_out.appendChild(phone.snap().image);\n }", "title": "" }, { "docid": "5a6e23aabd2af41f2d28950e4d2457c1", "score": "0.5711064", "text": "function onYouTubeIframeAPIReady() {\n var backgroundNodes = document.getElementsByClassName('slide-background');\n var length = backgroundNodes.length;\n var i = 0\n var backgroundNode;\n var backgroundImage;\n var youtubeMatch;\n var nodeId;\n for (; i < length; i++) {\n backgroundNode = backgroundNodes[i];\n\n backgroundImageUrl = backgroundNode.getAttribute('data-background-hash');\n youtubeMatch = backgroundImageUrl && backgroundImageUrl.match(\n /\\/\\/img\\.youtube\\.com\\/vi\\/([0-9a-zA-Z\\-\\_]+)\\/maxresdefault.jpg/\n );\n\n if (youtubeMatch) {\n // assing an ID to the background div so youtube's api can handle it\n backgroundNode.id = nodeId = 'youtubeBackground' + i;\n\n // Disable jscs camelCase code validation for this block\n // jscs:disable requireCamelCaseOrUpperCaseIdentifiers\n player = new YT.Player(nodeId, {\n videoId: youtubeMatch[1],\n\n playerVars: {\n controls: 0,\n disablekb: 0,\n modestbranding: 1,\n showinfo: 0,\n enablejsapi: 1,\n origin: window.location.origin,\n\n // Don't show related videos\n rel: 0,\n\n // Disable video annotations\n iv_load_policy: 3\n\n },\n\n events: {\n onReady: tweakPlayer,\n onStateChange: loopVideo\n }\n });\n\n // jscs:enable requireCamelCaseOrUpperCaseIdentifiers\n }\n }\n}", "title": "" }, { "docid": "7e87cfd4db77aca14059e81f625b0e9f", "score": "0.5709605", "text": "function letsJQuery() {\r\n\r\n$(document).ready(function() {\r\n function escapehtml(str) {\r\n str = str.replace(\"&\",'&amp;');\r\n str = str.replace('<','&lt;');\r\n str = str.replace('>','&gt;');\r\n str = str.replace('\"','&quot;');\r\n str = str.replace(\"'\",'&#039;');\r\n return str\r\n }\r\n $('.thumbnail').hide(); // Hide reddit.com thumbnails\r\n $('a').each(function(){\r\n var link = $(this).attr('href');\r\n var text= $(this).html();\r\n \r\n // The size of thumbnails\r\n if (/comments/.test(window.location)) { width = \"500\"; }\r\n else { width = \"500\"; }\r\n \r\n // Ignore Not Safe For Work posts\r\n if (!(/thumbs/.test(link)) && !(/NSFW/i.test(text))) {\r\n \r\n // Direct image links\r\n if (/\\.(jpe?g|gif|png)$/i.test(link)) {\r\n $(\"<br /><img src='\"+escapehtml(link)+\"' style='margin-top:5px; margin-bottom:5px; border:1px black solid; display:inline; vertical-align:top; max-width:\"+width+\"px;' alt='' />\").appendTo(this);\r\n }\r\n // Youtube\r\n if (/youtube\\.com\\/watch\\?v\\=/i.test(link)) {\r\n t = link.match(/youtube\\.com\\/watch\\?v\\=([^&]+)/i);\r\n video_id = t[1];\r\n $('<br /><object width=\"480\" height=\"385\"><param name=\"movie\" value=\"http://www.youtube.com/v/'+escapehtml(video_id)+'&hl=fi_FI&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube´.com/v/'+escapehtml(video_id)+'&hl=fi_FI&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"480\" height=\"385\"></embed></object>').appendTo(this);\r\n }\r\n \r\n // For Imgur.com links that are not direct\r\n if (/imgur\\.com\\/([a-zA-Z0-9]+)$/.test(link)) {\r\n link = link + '.png';\r\n $(\"<br /><img src='\"+link+\"' style='margin-top:5px; margin-bottom:5px; border:1px black solid; display:inline; vertical-align:top; max-width:\"+width+\"px;' alt='' />\").appendTo(this); \r\n }\r\n }\r\n });\r\n});\r\n }", "title": "" }, { "docid": "29ad8a50bd2472a3b10fb81e67bcbd42", "score": "0.5698108", "text": "function getThumbnailPath(type, thumbPath) {\n if((type !== 'avatar' && type !== 'inset' && type !== 'profile-main') || thumbPath === undefined) {\n console.log('getThumbnailPath : bad param');\n return;\n }\n var path = 'http://render-eu.worldofwarcraft.com/character/';\n var result = thumbPath.replace('avatar', type);\n return path + result;\n }", "title": "" }, { "docid": "84f73a1e5de606e57500c5acf537503b", "score": "0.569643", "text": "function render(item) {\n let href = 'https://www.youtube.com/watch?v=' + item.id.videoId;\n let title = item.snippet.title;\n let image = item.snippet.thumbnails.medium.url;\n return `<div class=\"imageContainer resultsBackground\">\n<h3><a href= ${href} class='links'>${title}</a></h3>\n<div class = \"product-image\" style=\"background-image: url(${image})\" alt=${title}></div>\n</div>`;\n}", "title": "" }, { "docid": "2b5d4401677b20ae10616cf5e8802a7b", "score": "0.5694854", "text": "function printYoutube(dataYoutube) {\n const youtubeVideoId = dataYoutube.items[0].id.videoId;\n const youtubeVideoUrl = \"https://www.youtube.com/embed/\" + youtubeVideoId;\n const youtubeiframe = $(\"<iframe>\")\n .attr(\"src\", youtubeVideoUrl)\n .attr(\"frameborder\", \"0\")\n .attr(\n \"allow\",\n \"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\"\n );\n\n imageRow.append(youtubeiframe);\n }", "title": "" }, { "docid": "9cd60f52195e66f1e012cd87d0afd012", "score": "0.56788206", "text": "static get tag() {\n return \"a11y-media-youtube-utility\";\n }", "title": "" }, { "docid": "4f633d36754a024d661d48ee06879d6e", "score": "0.56676596", "text": "function getThumbnail(values, options) {\n var url = options.base_url + \"/files/\" + values.fileid + \"/thumbnail.png?min_height=256&min_width=256\";\n\n var header = {\n url: url,\n headers: {\n 'Authorization': 'Bearer ' + options.token.access_token\n },\n method: \"GET\",\n followAllRedirect: false\n };\n\n var bufs = [];\n var req = request(header)\n .on('data', function(d) {\n bufs.push(d);\n })\n .on('end', function() {\n\n var buf = Buffer.concat(bufs);\n\n if (this.response.statusCode == 200) {\n if (this.redirects.length == 0 || use_box_generic_thumbnails) {\n values.response_stream.writeHead(200, {\n 'Content-Length': buf.length,\n 'Content-Type': 'image/png',\n 'content-disposition': 'attachment;filename=\"tbm.png\";'\n });\n\n values.response_stream.write(buf);\n values.response_stream.end();\n } else {\n /* FUTURE FUNCTIONALITY : allow overriding of images for BOX */\n\n /*\n var contenttype = images[this.response.headers['content-type']];\n \n if(typeof contenttype == \"undefined\" || contenttype == null) {\n // load default image from box\n values.response_stream.writeHead(200, {\n 'Content-Length': buf.length,\n 'Content-Type' : 'image/png',\n 'content-disposition' : 'attachment;filename=\"tbm.png\";'});\n \n values.response_stream.write(buf);\n values.response_stream.end(); \n } else {\n // load this image\n fs.readFile(require('path').join(__dirname, \"/images/default.png\"), function(err, buf) {\n \n values.response_stream.writeHead(200, {\n 'Content-Length': buf.length,\n 'Content-Type' : 'image/png',\n 'content-disposition' : 'attachment;filename=\"tbm.png\";'}\n );\n \n values.response_stream.write(buf);\n values.response_stream.end(); \n });\n }\n */\n }\n } else if (this.response.statusCode == 202) {\n //thumbnail being generated\n\n var retry = (parseInt(this.response.headers['retry-after']) * 1000) + 500;\n\n setTimeout(getThumbnail(values, options), retry);\n\n } else {\n //thumbnail can't be generated\n\n get_image_from_file(require('path').join(__dirname, \"/images/default.png\"), function(buf) {\n values.response_stream.writeHead(200, {\n 'Content-Length': buf.length,\n 'Content-Type': 'image/png',\n 'content-disposition': 'attachment;filename=\"tbm.png\";'\n });\n\n values.response_stream.write(buf);\n values.response_stream.end();\n });\n }\n });\n\n}", "title": "" }, { "docid": "e275b8438a4006f923d57dcbed4e8e08", "score": "0.56474507", "text": "function renderThumbnailHtml(item) {\n console.log('renderThumbnailHtml');\n\n // variables for title and thumbnailUrl\n const title = item.title;\n let thumbnailUrl = \"\";\n let customThumbnail = 'http://via.placeholder.com/640x480';\n\n // using thumbnail sizes with height of either 360 or 480\n // builds an array of thumbnails per item with those sizes\n const selectedThumbnailSizes = item.thumbnails.filter(function (thumbnail) {\n return thumbnail.height === 360 || thumbnail.height === 480;\n });\n\n // use the first item in the array for the size (will always be either 360 or 480)\n // if there aren't any thumbnails available use my placeholder\n // else use the url of the image supplied\n if (selectedThumbnailSizes.length === 0) {\n thumbnailUrl = 'http://via.placeholder.com/640x480';\n } else {\n thumbnailUrl = selectedThumbnailSizes[0].url;\n }\n\n return `\n <div class=\"row\">\n <div class=\"col-xs-12 col-md-8 col-md-offset-2\">\n <div class=\"video\">\n <div class=\"thumbnail\">\n <img class=\"parallax\" src=\"${thumbnailUrl}\" alt=\"${title}\" />\n </div>\n <div class=\"title\">\n ${title}\n </div>\n </div>\n </div>\n </div>\n `;\n}", "title": "" }, { "docid": "0702b7c58aa8105f5ef51c947d711d6d", "score": "0.5646693", "text": "function renderThumbnailHtml(item) {\n console.log('renderThumbnailHtml');\n\n // variables for title and thumbnailUrl\n const title = item.title;\n let thumbnailUrl = \"\";\n let customThumbnail = 'http://via.placeholder.com/640x480';\n\n // using thumbnail sizes with height of either 360 or 480\n // builds an array of thumbnails per item with those sizes\n const selectedThumbnailSizes = item.thumbnails.filter(function(thumbnail) {\n return thumbnail.height === 360 || thumbnail.height === 480;\n });\n\n // use the first item in the array for the size (will always be either 360 or 480)\n // if there aren't any thumbnails available use my placeholder\n // else use the url of the image supplied\n if(selectedThumbnailSizes.length === 0) {\n thumbnailUrl = 'http://via.placeholder.com/640x480';\n } else {\n thumbnailUrl = selectedThumbnailSizes[0].url;\n }\n\n return `\n <div class=\"row\">\n <div class=\"col-xs-12 col-md-8 col-md-offset-2\">\n <div class=\"video\">\n <div class=\"thumbnail\">\n <img class=\"parallax\" src=\"${thumbnailUrl}\" alt=\"${title}\" />\n </div>\n <div class=\"title\">\n ${title}\n </div>\n </div>\n </div>\n </div>\n `;\n}", "title": "" }, { "docid": "f12877a9212e0fb9700dd03059c26719", "score": "0.5646422", "text": "function youtubeGetVideoList()\n{\n try{\n var videoFormats = {\n 5: { itag: 5, resolution: 224, format: \"FLV\"},\n 6: { itag: 6, resolution: 270, format: \"FLV\"},\n 13: { itag: 13, resolution: 144, format: \"3GP\"},\n 17: { itag: 17, resolution: 144, format: \"3GP\"},\n 18: { itag: 18, resolution: 360, format: \"MP4\"},\n 22: { itag: 22, resolution: 720, format: \"MP4\"},\n 34: { itag: 34, resolution: 360, format: \"FLV\"},\n 35: { itag: 35, resolution: 480, format: \"FLV\"},\n 36: { itag: 36, resolution: 240, format: \"3GP\"},\n 37: { itag: 37, resolution: 1080, format: \"MP4\"},\n 38: { itag: 38, resolution: 2304, format: \"MP4\"},\n 43: { itag: 43, resolution: 360, format: \"WebM\"},\n 44: { itag: 44, resolution: 480, format: \"WebM\"},\n 45: { itag: 45, resolution: 720, format: \"WebM\"},\n 46: { itag: 46, resolution: 1080, format: \"WebM\"},\n 82: { itag: 82, resolution: 360, format: \"MP4\"},\n 83: { itag: 83, resolution: 240, format: \"MP4\"},\n 84: { itag: 84, resolution: 720, format: \"MP4\"},\n 85: { itag: 85, resolution: 520, format: \"MP4\"},\n 100:{ itag: 100, resolution: 360, format: \"WebM\"},\n 101:{ itag: 101, resolution: 480, format: \"WebM\"},\n 102:{ itag: 102, resolution: 720, format: \"WebM\"}\n };\n\n var videoList = new Array();\n var encodedStream = ytplayer.config.args.url_encoded_fmt_stream_map;\n var streamInfo = encodedStream.split(',');\n\n for(i in streamInfo)\n {\n streamData = streamInfo[i].split('&');\n var youtubeURL = '';\n var youtubeSIG = '';\n var youtubeITAG = 0;\n\n for(y in streamData)\n {\n if(streamData[y].indexOf('itag=') == 0)\n {\n itagData = streamData[y].split('=');\n youtubeITAG = itagData[1];\n }\n if(streamData[y].indexOf('url=') == 0)\n {\n urlData = streamData[y].split('=');\n youtubeURL = unescape(urlData[1]);\n }\n if(streamData[y].indexOf('s=') == 0)\n {\n sigData = streamData[y].split('=');\n youtubeSIG = unescape(sigData[1]);\n }\n }\n\n if(youtubeURL != '' && youtubeITAG != 0)\n {\n if(youtubeURL.indexOf('signature') > 0)\n {\n var video = {formatObject: videoFormats[youtubeITAG], url: youtubeURL};\n videoList.push(video);\n }\n else\n {\n var video = {formatObject: videoFormats[youtubeITAG], url: youtubeURL+'&signature='+youtubeRetrieveSignature(youtubeSIG)};\n videoList.push(video);\n }\n }\n }\n return videoList;\n }\n catch(e){\n var videoList = new Array();\n console.log(e);\n return videoList;\n }\n}", "title": "" }, { "docid": "78e8c1de61c42ed9a22b3376748dd859", "score": "0.5643882", "text": "function youtubeData(value) {\n\tvar date = moment().add(-2, 'days').format(\"YYYY-MM-DDTHH:mm:ssZ\");\n\n\t$.ajax({\n\t\ttype: 'GET',\n\t\turl: 'https://www.googleapis.com/youtube/v3/search',\n\t\tdata: {\n\t\t\tkey: 'AIzaSyBVy0EAkJ0kLC1HlyZ81wXGvNy9HpQwTqE',\n\t\t\tq: value,\n\t\t\tpublishedAfter: date,\n\t\t\tpart: 'snippet',\n\t\t\trelevanceLanguage: 'en',\n\t\t\tregionCode: 'US',\n\t\t\ttype: 'video',\n\t\t\tvideoCategoryId: '20',\n\t\t\tmaxResults: 6\n\t\t},\n\t\tsuccess: function(data) {\n\t\t\t$(\"#secondPanel\").text(\"Recent Videos\");\n\t\t\t$(\"#secondContentRow\").html(\"\");\n\t\t\tfor (var i = 0; i < data.items.length; i++) {\n\t\t\t\t$(\"#secondContentRow\").append(\"<div class='col-sm-4 previewGridYT'><a href='https://www.youtube.com/watch?v=\" + data.items[i].id.videoId + \"' target='_blank'><img src='\" + data.items[i].snippet.thumbnails.medium.url + \"' class='previewYT'><div class='streamInfo'><p>\" + data.items[i].snippet.title + \"</p></div></a></div>\")\t\t\t};\n\n\t\t\t}\n\t\t})\n}", "title": "" }, { "docid": "b23b63aa908af407a58ae9fe0c3637c5", "score": "0.56434906", "text": "function YouTubeGetID(url){\n var ID = '';\n url = url.replace(/(>|<)/gi,'').split(/(vi\\/|v=|\\/v\\/|youtu\\.be\\/|\\/embed\\/)/);\n if(url[2] !== undefined) {\n ID = url[2].split(/[^0-9a-z_\\-]/i);\n ID = ID[0];\n }\n else {\n ID = url;\n }\n return ID;\n }", "title": "" }, { "docid": "b23b63aa908af407a58ae9fe0c3637c5", "score": "0.56434906", "text": "function YouTubeGetID(url){\n var ID = '';\n url = url.replace(/(>|<)/gi,'').split(/(vi\\/|v=|\\/v\\/|youtu\\.be\\/|\\/embed\\/)/);\n if(url[2] !== undefined) {\n ID = url[2].split(/[^0-9a-z_\\-]/i);\n ID = ID[0];\n }\n else {\n ID = url;\n }\n return ID;\n }", "title": "" }, { "docid": "b23b63aa908af407a58ae9fe0c3637c5", "score": "0.56434906", "text": "function YouTubeGetID(url){\n var ID = '';\n url = url.replace(/(>|<)/gi,'').split(/(vi\\/|v=|\\/v\\/|youtu\\.be\\/|\\/embed\\/)/);\n if(url[2] !== undefined) {\n ID = url[2].split(/[^0-9a-z_\\-]/i);\n ID = ID[0];\n }\n else {\n ID = url;\n }\n return ID;\n }", "title": "" }, { "docid": "fd99f07546a00bf2b126dba1ec8da571", "score": "0.5638864", "text": "function getPlaylistUrlLive(link, response) {\n try {\n let token = JSON.parse(response).data.streamPlaybackAccessToken.value;\n let channel = JSON.parse(token).channel;\n let signature = JSON.parse(response).data.streamPlaybackAccessToken.signature;\n let urlPlaylist = \"https://usher.ttvnw.net/api/channel/hls/\" + channel + \".m3u8?sig=\" + signature + \"&token=\" + token;\n\n let data = link.data();\n data.hoverZoomSrc = [urlPlaylist];\n\n callback(link, name);\n hoverZoom.displayPicFromElement(link);\n\n // get M3U8 file\n /*$.ajax({\n type: \"GET\",\n dataType: \"text\",\n url: urlPlaylist\n });*/\n } catch { return; }\n }", "title": "" }, { "docid": "b5b1e9a3704e5ab95ad91647ac7f9d46", "score": "0.56225485", "text": "function getYoutubeVideoId(url) {\n var videoId = \"\";\n var regex = /[?&]v=([^&#]*)/;\n var match = regex.exec(url);\n if (match) {\n videoId = match[1];\n }\n return videoId;\n}", "title": "" }, { "docid": "c6f907dbcff04c8f666596408649b238", "score": "0.56213677", "text": "get url() {\n return 'https://www.googleapis.com/youtube/v3/search';\n }", "title": "" }, { "docid": "6bdad93f328acd728779354a36d1394f", "score": "0.56171477", "text": "function loadSimpleYTPlayer() {\n\tusersReadyToPlay = 1; \n\t$(\"#infodiv\").hide(); $(\"#errordiv\").hide();\n\tswfobject.removeSWF(\"simpleytPlayer\");\n\tvar youtubeUrl = $(\"#youtubeurl\").val();\n\tvideoID = youtube_parser(youtubeUrl);\n\tif(videoID!=0 && videoID!=null){\n\t\t$(\"#youtubeUrlDiv\").slideToggle(\"fast\");\n\t\t$(\"#moderatorPopupWindow\").append('<div id=\"simplevideoDiv\"/>');\n\t\tvar params = { allowScriptAccess: \"always\" };\n\t\tvar atts = { id: \"simpleytPlayer\" };\n\t\tswfobject.embedSWF(\"http://www.youtube.com/v/\" + videoID + \"?listType=search&version=3&enablejsapi=1&playerapiid=player1\", \n \"simplevideoDiv\", \"480\", \"295\", \"9\", null, null, params, atts);\n\t}\n}", "title": "" }, { "docid": "55fd6cd57c2197ca24d8a10edd8f6d09", "score": "0.56129223", "text": "function getYoutubeLink(key) {\n var video = \"https://www.youtube.com/embed/\" + key;\n displayTrailer(video);\n}", "title": "" }, { "docid": "743775eef0329666ebf8b7fe1a3574cd", "score": "0.5608395", "text": "function processYoutubeVimeo(img, url)\n{\n let matches = url.match(/(http:|https:|)\\/\\/(player.|www.|m.)?(vimeo\\.com|youtu(be\\.com|\\.be|be\\.googleapis\\.com))\\/(video\\/|embed\\/|watch\\?v=|v\\/)?([A-Za-z0-9._%-]*)(\\&\\S+)?/);\n if (matches && matches.length > 6)\n {\n let vID = matches[6];\n if (matches[3].indexOf('youtu') > -1)\n {\n //video\n if (url.indexOf('/watch?v=') > -1) {\n setImgSrc(img, 'https://img.youtube.com/vi/' + vID + '/maxresdefault.jpg', url);\n return true;\n }\n\n //playlist\n if (url.indexOf('playlist?list=') > -1) {\n getRequest(url, (err, data) => {\n let thumb = trimStart(data, '\"thumbnail\":{\"thumbnails\":[{\"url\":\"');\n setImgSrc(img, trimEnd(thumb), url);\n });\n return true;\n }\n\n //channel\n if (url.indexOf('channel/')) {\n getRequest(url, (err, data) => {\n let thumb = trimStart(data, '\"avatar\":{\"thumbnails\":[{\"url\":\"');\n setImgSrc(img, trimEnd(thumb), url);\n });\n return true;\n }\n setImgSrc(img, 'https://s.ytimg.com/yts/img/favicon-vfl8qSV2F.ico', url);\n return true;\n }\n else if (matches[3].indexOf('vimeo') > -1) {\n getRequest('https://vimeo.com/api/v2/video/' + vID + '.json',\n (err, data) => {\n let parsedData = JSON.parse(data);\n let thumbSRClarge = parsedData[0].thumbnail_large;\n\n // split url of large thumbnail at 640\n let thumbSplit = thumbSRClarge.split(/\\d{3}(?=.jpg)/);\n // add 1280x720 to parts and get bigger thumbnail\n thumb = thumbSplit[0] + '1280x720' + thumbSplit[1];\n setImgSrc(img, thumb, url);\n });\n }\n return true;\n }\n\n //youtube favicon\n if (url.indexOf('youtube.com') > -1) {\n setImgSrc(img, 'https://s.ytimg.com/yts/img/favicon-vfl8qSV2F.ico', url);\n return true;\n }\n return false;\n}", "title": "" }, { "docid": "b8d6624e58050eb437498bd3ba4d9d32", "score": "0.55925524", "text": "static getImageUrlFromQuality(data, quality) {\n switch(quality) {\n case ViewConstants.imageQuality.Low:\n return data.thumbnail;\n case ViewConstants.imageQuality.High:\n // ex http://imager.mnhn.fr/imager2/w400/2012/11/20/6/P00048663.jpg\n return data.thumbnail.replace('v25', 'w400');\n case ViewConstants.imageQuality.Original:\n return data.url;\n default:\n return data.thumbnail;\n }\n }", "title": "" }, { "docid": "7faccf2656ec860f8b2ff90c503cfab4", "score": "0.5592007", "text": "function getVideoIdFromYouTube() {\n\t// AJAX happens hereeeeeeee\n\t$.ajax(`https://www.googleapis.com/youtube/v3/search?part=snippet&q=${query}&key=AIzaSyDYh2b125tU8IsCWUwuFVayxcs59k_i2ng&maxResults=1`,\n\t\tfunction(jsonResponse){\n\t\taddVideoToDOM(jsonResponse.items[0].id.videoId);\n\t\tconsole.log(jsonResponse)\n\t});\n}", "title": "" }, { "docid": "8074b12cb4baf85fcf978152e634dbab", "score": "0.55896485", "text": "function getIMG(tt_number, title) {\n var movie;\n var xhr = new XMLHttpRequest();\n xhr.onreadystatechange = function () {\n if (this.readyState === 4 && this.status === 200) {\n movie = JSON.parse(this.responseText);\n var posterPath = movie.poster_path;\n var ulrString = 'https://image.tmdb.org/t/p/w500' + posterPath;\n localStorage.setItem('' + title + '', ulrString);\n }\n };\n xhr.open(\"GET\", \"https://api.themoviedb.org/3/movie/\" + tt_number + \"?api_key=af1b95e9f890b9b6840cf6f08d0e6710&language=en-US\", true);\n xhr.send();\n}", "title": "" }, { "docid": "e7ef4168cf672d927f0b5f5c014d92bf", "score": "0.55891037", "text": "function getVidInfo(YTID) {\n try {\n var URL = 'https://www.googleapis.com/youtube/v3/videos?id=' + YTID + '&key=AIzaSyCNe2YcTQ6A96ni2C_7bxyoucT8mN0pQ9Q&part=snippet,contentDetails,statistics,status';\n var jsonVidInfo = JSON.parse(GetURL(URL));\n return {\n title: jsonVidInfo.items[0].snippet.title,\n duration: jsonVidInfo.items[0].contentDetails.duration\n };\n }\n catch(err) {\n //Best error handling practice\n }\n\n}", "title": "" }, { "docid": "b3e9b3088ed3b7310b06a17da2ddb1ec", "score": "0.55868375", "text": "function getYTID() {\n var YTURL = document.YoutubeID.YTURL.value;\n document.YoutubeID.reset();\n var YTID=extractYTID(YTURL);\n populatePlaylist(YTID);\n}", "title": "" }, { "docid": "773d7200988a0708f6b51cbf1ea73194", "score": "0.5586141", "text": "function getVideoObj(id,callback){\r\n\tvar request = new HttpClient();\r\n\trequest.get((\"https://www.googleapis.com/youtube/v3/videos?id=\" +\r\n\tid +\r\n\t\"&key=\" + youtubeKey +\r\n\t\"&part=snippet\"), function(response){\r\n\t\tcallback(response);\r\n\t})\r\n}", "title": "" }, { "docid": "7bddb7f2efcc6cdec0e72991dbbb94eb", "score": "0.55819064", "text": "function getYouTubeIDFromURL(url)\n {\n if (url.indexOf('www.youtube.com/')==-1) {\n var regExp = /^.*((youtu.be\\/)|(v\\/)|(\\/u\\/\\w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*/;\n var match = url.match(regExp);\n if (match&&match[7].length==11){\n console.log(match[7])\n return match[7];\n }else{\n alert(\"Url incorrecta\");\n }\n }\n else {\n console.log(url.match(/\\?v=([^&]*)/)[1])\n return url.match(/\\?v=([^&]*)/)[1];\n\n }\n }", "title": "" }, { "docid": "14f32331f745b44759a772ee8b5ffe58", "score": "0.5569185", "text": "function VideoThumbnail(){\n\n\tvar slider = Ulo.get(\"thumbnail_selector\", \"button.slider\"),\n\n\tsettings = { vertical: false, marginOffset: 13, offsetX: -4 };\n\n\n\tif(slider === null){\n\n\t\tthis.select = this.update = function(){}\n\n\t} else{\n\n\t\twindow.Draggable.call(this, slider, settings, null);\n\n\t\tthis.register();\n\n\t\tthis.update();\n\n\t}\n\n}", "title": "" }, { "docid": "c4e186f016b9c0039ff9eaf2eb6cce9c", "score": "0.55611885", "text": "async function getTrailer() {\n var trailerApi = 'https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=';\n var trailerApiKey= ' trailer&key=AIzaSyAVo5crd8w8kPuBz_Sq_ebY9N9JoogNUOM'\n var trailerUrl = trailerApi + flixTitleVal + trailerApiKey;\n var response = await fetch(trailerUrl);\n var data = await response.json();\n var trailer = data.items[0].id.videoId;\n var youtubeUrl = \"https://www.youtube.com/embed/\" + trailer;\n document.getElementById(\"trailer\").setAttribute('src',youtubeUrl);\n}", "title": "" }, { "docid": "762d7329bdb6aca32365b454e6eee7cd", "score": "0.5541143", "text": "function n(e,i,n){const o=e.thumbnail&&e.thumbnail.url;return o?U(o,{responseType:\"image\"}).then((t=>{const e=h(t.data,n);return n&&n.node?(n.node.appendChild(e),n.node):e})):e.fetchSymbol().then((t=>t?i(t,n):null))}", "title": "" }, { "docid": "70720da08dac53cc4178a6a176a291a5", "score": "0.5536088", "text": "function getYoutubeStream(youtube_id) {\n\n var doc = new XMLHttpRequest();\n\n doc.onreadystatechange = function() {\n if (doc.readyState == XMLHttpRequest.DONE) {\n\n var videoInfo = doc.responseText;\n\n var videoInfoSplit = videoInfo.split(\"&\");\n var streams;\n for (var i = 0; i < videoInfo.length; i++) {\n var paramPair = videoInfoSplit[i].split(\"=\");\n if (paramPair[0] === \"url_encoded_fmt_stream_map\") {\n streams = decodeURIComponent(paramPair[1]);\n break;\n }\n }\n\n if (!streams) {\n var msg = \"YouTube videoInfo parsing: url_encoded_fmt_stream_map not found\";\n console.debug(msg);\n return;\n }\n var streamsSplit = streams.split(\"&\");\n\n // some lines contain two value pairs separated by comma\n var newSplit = [];\n for (var i = 0; i < streamsSplit.length; i++) {\n var secondSplit = streamsSplit[i].split(\",\");\n newSplit.push.apply(newSplit, secondSplit);\n }\n streamsSplit = newSplit;\n\n var url, sig, itag;\n var found = false;\n for (var i = 0; i < streamsSplit.length; i++) {\n var paramPair = streamsSplit[i].split(\"=\");\n if (paramPair[0] === \"url\") {\n url = decodeURIComponent(paramPair[1]);\n } else if (paramPair[0] === \"sig\") {\n sig = paramPair[1]; // do not decode, as we would have to encode it later (although decoding/encoding has currently no effect for the signature)\n } else if (paramPair[0] === \"itag\") {\n itag = paramPair[1];\n }\n if ((i + 1) % 6 === 0 && itag === \"18\") { // 6 parameters per video; itag 18 is \"MP4 360p\", see http://userscripts.org/scripts/review/25105\n found = true;\n url += \"&signature=\" + sig;\n break;\n }\n }\n\n if (found) {\n console.debug(\"video direct URL found: \" + url);\n return url;\n\n } else {\n var msg = \"Couldn't find video in MP4 360p\";\n console.debug(msg);\n return;\n }\n\n }\n\n\n\n }\n\n doc.open(\"GET\", \"http://www.youtube.com/get_video_info?video_id=\" + youtube_id);\n doc.send();\n}", "title": "" }, { "docid": "44239d9be8dbcf61002f0255db743fe4", "score": "0.5529162", "text": "function playYoutubeVideo(response) {\n // extract Json data and populate URL to play the video\n // Insert your code here\n }", "title": "" }, { "docid": "d79cd6b61c543f5b76c583bb8aa57bb9", "score": "0.55194443", "text": "function embedVideo (container) {\n\n var video_url = $(container).data(\"url\");\n\n\n function get_video_thumb(url, callback) {\n var id = get_video_id(url);\n if (id['type'] == 'y') {\n return processYouTube(id);\n } else if (id['type'] == 'v') {\n\n $.ajax({\n url: 'http://vimeo.com/api/v2/video/' + id['id'] + '.json',\n dataType: 'jsonp',\n success: function (data) {\n callback({type: 'v', id: id['id'], url: data[0].thumbnail_large});\n }\n });\n }\n\n function processYouTube(id) {\n if (!id) {\n throw new Error('Unsupported YouTube URL');\n }\n\n callback({\n type: 'y',\n id: id['id'],\n url: 'http://i2.ytimg.com/vi/' + id['id'] + '/hqdefault.jpg'\n });\n }\n }\n\n function get_video_id(url) {\n var id;\n var a;\n if (url.indexOf('youtube.com') > -1) {\n if (url.indexOf('v=') > -1) {\n id = url.split('v=')[1].split('&')[0];\n }\n else if (url.indexOf('embed') > -1) {\n id = url.split('embed/')[1].split('?')[0];\n }\n ;\n return processYouTube(id);\n }\n else if (url.indexOf('youtu.be') > -1) {\n id = url.split('/')[1];\n return processYouTube(id);\n }\n else if (url.indexOf('vimeo.com') > -1) {\n if (url.match(/https?:\\/\\/(www\\.)?vimeo.com\\/(\\d+)($|\\/)/)) {\n id = url.split('/')[3];\n }\n else if (url.match(/^vimeo.com\\/channels\\/[\\d\\w]+#[0-9]+/)) {\n id = url.split('#')[1];\n }\n else if (url.match(/vimeo.com\\/groups\\/[\\d\\w]+\\/videos\\/[0-9]+/)) {\n id = url.split('/')[4];\n }\n else if (url.match(/player.vimeo.com\\/video\\/[0-9]+/)) {\n id = url.split('/')[2];\n }\n else {\n throw new Error('Unsupported Vimeo URL');\n }\n\n }\n else {\n throw new Error('Unrecognised URL');\n }\n a = {type: 'v', id: id};\n return a;\n function processYouTube(id) {\n if (!id) {\n throw new Error('Unsupported YouTube URL');\n }\n a = {type: 'y', id: id};\n return (a); // default.jpg OR hqdefault.jpg\n }\n }\n\n function callback(video) {\n\n $(container + ' .video-overlay').css({\"background-image\": \"url('\" + video.url + \"')\"});\n\n var frame;\n\n if (video.type == 'v') {\n frame = '<iframe src=\"https://player.vimeo.com/video/' + video.id + '?autoplay=1&color=3aafd6&portrait=0\" width=\"500\" height=\"281\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>';\n } else {\n frame = '<iframe src=\"https://www.youtube.com/embed/' + video.id + '?autoplay=1&color=white&rel=0\" frameborder=\"0\" allowfullscreen width=\"560\" height=\"315\" showinfo=\"0\"></iframe>';\n }\n\n $(container).click(function () {\n $(container).fadeOut('fast', 'linear', function () {\n $(this).html(frame);\n $(this).fadeIn('fast');\n });\n })\n\n }\n\n get_video_thumb(video_url, callback);\n}", "title": "" }, { "docid": "19e9362aeebfc67b0aa4554d898415f9", "score": "0.5510078", "text": "function loadExampleVideoMarkup() {\n var vidID = $('body #example').data('url');\n var id = vidID.split('watch?v=')[1];\n\n var tempHTML = '<li class=\"yt-shelf-grid-item yt-uix-shelfslider-item\">'\n + '<div class=\"yt-lockup yt-lockup-grid yt-lockup-video clearfix\">'\n + '<div class=\"yt-lockup-dismissable\">'\n + '<div class=\"yt-lockup-thumbnail contains-addto\">'\n + '<a aria-hidden=\"true\" href=\"/watch?v=' + id + '\" class=\" yt-uix-sessionlink spf-link\">'\n + '<div class=\"yt-thumb video-thumb\"><span class=\"yt-thumb-simple\">'\n + '<img data-ytimg=\"1\" alt=\"\" src=\"http://img.youtube.com/vi/' + id + '/mqdefault.jpg\" width=\"300\" height=\"168.5\" style=\"display: inline;\">'\n + '</span>'\n + '</div>'\n + '</a>'\n + '</div>'\n + '</div>'\n + '</div>'\n + '</li>';\n\n $('body #example').prepend(tempHTML);\n }", "title": "" }, { "docid": "d0647e3d62cdd64eca148fdf01e92568", "score": "0.5500865", "text": "static thumb(item) {\n const { thumb, title, views } = item;\n\n return `\n <li class=\"thumb\">\n <img\n srcset=\"\n ${thumb.small} 75w,\n ${thumb.large} 150w\"\n sizes=\"\n (max-width: 32.1rem) 75px,\n 150px\"\n src=\"${thumb.large}\"\n alt=\"${title}\"\n />\n <div>${views}</div>\n </li>\n `;\n }", "title": "" }, { "docid": "d0647e3d62cdd64eca148fdf01e92568", "score": "0.5500865", "text": "static thumb(item) {\n const { thumb, title, views } = item;\n\n return `\n <li class=\"thumb\">\n <img\n srcset=\"\n ${thumb.small} 75w,\n ${thumb.large} 150w\"\n sizes=\"\n (max-width: 32.1rem) 75px,\n 150px\"\n src=\"${thumb.large}\"\n alt=\"${title}\"\n />\n <div>${views}</div>\n </li>\n `;\n }", "title": "" }, { "docid": "5ecf7bc6db62999fdfbe8dfe889b58d9", "score": "0.54985464", "text": "function getTrailer() {\r\n\tconst MovieId = sessionStorage.getItem('movieId');\r\n\tconst trailerUrl = \"https://api.themoviedb.org/3/movie/\" + MovieId + \"/videos?api_key=\" + api_key;\r\n\tfetch(trailerUrl)\r\n\t\t.then((res) => res.json())\r\n\t\t.then((data) => {\r\n\t\t\tconst output =`\r\n\t\t\t\t<iframe class = \"trailer\" src = \"https://www.youtube.com/embed/${data.results[0].key}\" allowfullscreen></iframe>\r\n\t\t\t`;\r\n\t\t\t$(\".video\").html(output);\r\n\t\t})\r\n\t\t.catch((error) => {\r\n\t\t\tconsole.log('Error ', error);\r\n\t\t});\r\n}", "title": "" }, { "docid": "2cd41c0c06c29bdcd5389fe84f2c4f25", "score": "0.5489971", "text": "function displayYoutube() {\n showYTPlayer();\n if(player != null) {\n loadYTVideo();\n }\n else {\n displayYouTubePlayer();\n }\n}", "title": "" }, { "docid": "b67a3087a0de8a34609a4451db4dedbb", "score": "0.5487522", "text": "getContentOfVideo() {\r\n return (h(\"div\", { class: `content-video ${this.orientation}` },\r\n h(\"img\", { class: \"content-background-img\", src: this.srcPoster, alt: dxp.i18n.t('ContentItem:videoPosterImageText') }),\r\n h(\"a\", { class: `play-icon ${this.playIconBottomLeft ? 'bottom-left' : 'center'}`, \"aria-label\": dxp.i18n.t('ContentItem:videoPlayBtnText'), onClick: ev => this.toggleVideo(true, ev), href: \"\" },\r\n h(\"img\", { alt: dxp.i18n.t('ContentItem:videoPlayBtnText'), src: `${process.env.DXP_COMPONENT_ASSET_PATH}/images/icons/play-icon-${this.iconType}.png` }))));\r\n }", "title": "" }, { "docid": "3e2c6b65b6ed5eae445ccd22fb55a991", "score": "0.54819524", "text": "async function getVideo(url) {\n try {\n // Quality values can be found here: https://github.com/fent/node-ytdl-core/blob/HEAD/typings/index.d.ts#L15\n return await ytdl(url, { quality: 'lowestvideo' }) // 'highestvideo' or 'lowestvideo' as examples\n } catch (err) {\n console.log(err)\n }\n}", "title": "" }, { "docid": "9f852337727ea9fe7f1620ed739f3195", "score": "0.54698104", "text": "function onYouTubeIframeAPIReady() {\n $('.mediaModule .youTubePlayerHolder').each(function(event) { \n $this = $(this);\n var videoIDString = $this.parents().find('li:first-child').attr(\"data-video-id\");\n var iframeID = $this.attr('id');\n //alert(iframeID);\n var posterImage = $this.next();\n var thisPlayer = $this;\n //players[iframeID] = new YT.Player(iframeID, {\n players[iframeID] = new YT.Player(iframeID, {\n videoId: videoIDString,\n height: '171',\n width: '304',\n playerVars: {\n controls: 1,\n rel: 0,\n showinfo: 0,\n modestbranding: 1,\n theme: \"light\",\n wmode: \"opaque\" \n },\n events: {\n 'onStateChange': onPlayerStateChange\n }\n });\n });\n \n // Listen for a video row being clicked. \n $('.mediaPoster').click(function() {\n $this = $(this);\n var ytVideoID = $this.attr('data-video-id');\n if ( $(window).width() < 944 ) {\n //go straight to youtube\n window.location = 'http://www.youtube.com/watch?v='+ytVideoID;\n } else {\n // Get the id of the video holder, change the video id and play.\n var ytPlayerEleID = $this.prev().attr('id');\n var posterHeight = $this.height();\n $this.hide();\n //$this.prev().css('position','static').show();\n //$(this).parent().fitVids();\n players[ytPlayerEleID].loadVideoById(ytVideoID);\n }\n });\n\n // Listen for a video row being clicked. \n $('.videoRow').click(function() {\n // Get the yt video id from this li.\n var $this = $(this);\n var ytVideoID = $this.attr('data-video-id');\n var ytVideoPoster = $this.attr('data-video-poster');\n if ( $(window).width() < 944 || ($.browser.msie && parseInt($.browser.version, 10) == 7) ) {\n //go straight to youtube\n window.location = 'http://www.youtube.com/watch?v='+ytVideoID;\n } else {\n var posterImageTemp = $this.parent().parent().find('.mediaPoster');\n // Switch the poster image.\n posterImageTemp.attr(\"src\", ytVideoPoster);\n // Hide the poster image (if exists)\n posterImageTemp.hide();\n // Get the iframe id to set the player.videoid and also set the iframe to position static.\n //$this.parents('.mediaPlayer').find('.youTubePlayerHolder').show().css('position','static');\n var videoFrameID = $this.parents('.mediaPlayer').find('iframe').attr(\"id\");\n // Mark this row as active (mark others as none active first). \n $('.videoRow').removeClass('active');\n $(this).addClass('active');\n // Change the video of the player.\n players[videoFrameID].loadVideoById(ytVideoID);\n }\n });\n}", "title": "" }, { "docid": "0aee21edcbcb1514c1380aded2a540a7", "score": "0.54688495", "text": "function create_thumbnail(message) {\n var talk = get_conversation(message.number);\n talk.image.src = message.packet.thumbnail;\n\n // Call only once\n if (!talk.thumb) return;\n if (!talk.imgset) talk.thumb(talk);\n talk.imgset = true;\n }", "title": "" }, { "docid": "7204967d61324207d6a41da2a7b78cf5", "score": "0.546613", "text": "_renderThumbnail($$) {\n let node = this.props.node;\n // TODO: Make this work with tables as well\n let contentNode = node.find('graphic');\n let el = $$('div').addClass('se-thumbnail');\n if (contentNode) {\n el.append(\n $$(this.getComponent(contentNode.type), {\n node: contentNode,\n disabled: this.props.disabled\n })\n );\n } else {\n el.append('No thumb');\n }\n return el\n }", "title": "" }, { "docid": "b60ee604915da5bc7a64d7d47591e5be", "score": "0.5465916", "text": "function getYouTubeId(a){var b=a.match(/^.*((youtu.be\\/)|(v\\/)|(\\/u\\/\\w\\/)|(embed\\/)|(watch\\?))\\??v?=?([^#\\&\\?]*).*/);if(b&&b[7].length==11){return b[7]}else{return undefined}}", "title": "" }, { "docid": "da769e3aeea672d67b5786b4fed29af5", "score": "0.5465021", "text": "function loadThumbs(postId){\n var postId = window.location.pathname.split(\"/\").pop();\n \n return getThumbsByPostId(postId).then(function(data){\n var container=document.getElementById(\"thumb-container\");\n container.innerHTML = \"\";\n data.forEach(function(thumbnail){\n var thumb = thumbnail.val(); \n var myImg = new Image(150, 150);\n myImg.src = thumb.downloadUrl;\n myImg.setAttribute('data-img-id', thumbnail.key);\n myImg.classList.add(\"work-thumbnail\");\n container.appendChild(myImg);\n });\n });\n}", "title": "" }, { "docid": "1720a4a384547a5c0fc0df41ae365250", "score": "0.5464091", "text": "function getThumbnailSize(width, height, maxSize) {\n\tif (width >= height) {\n\t\treturn {\n\t\t\twidth: maxSize,\n\t\t\theight: maxSize * height / width\n\t\t}\n\t} else {\n\t\treturn {\n\t\t\twidth: maxSize * width / height,\n\t\t\theight: maxSize\n\t\t}\n\t}\n}", "title": "" }, { "docid": "bcef1e8cde81e930ca2bc2ec598974c1", "score": "0.5444034", "text": "function youtubeConvert(url) {\n var regExp = /[&?]list=([^&]+)/i;\n var match = url.match(regExp);\n if (match) {\n return match[1];\n }\n else {\n\n }\n }", "title": "" }, { "docid": "3c8a14f48afe2754e60685b4c543ed30", "score": "0.54384744", "text": "function getImgSrc(path, width) {\n return location.protocol + '//image.tmdb.org/t/p/' + width + path\n}", "title": "" }, { "docid": "4408f258a08b2cb20407f9f0db45f374", "score": "0.5430881", "text": "function get_auto_subtitle_xml_url() {\n try {\n // get JSON\n var json = '';\n if (typeof youtube_playerResponse_1c7 !== \"undefined\" && youtube_playerResponse_1c7 !== null && youtube_playerResponse_1c7 !== '') {\n json = youtube_playerResponse_1c7;\n } else {\n var raw_string = ytplayer.config.args.player_response;\n json = JSON.parse(raw_string);\n }\n\n // get data from JSON\n var captionTracks = json.captions.playerCaptionsTracklistRenderer.captionTracks;\n for (var index in captionTracks) {\n var caption = captionTracks[index];\n if (typeof caption.kind === 'string' && caption.kind == 'asr') {\n return captionTracks[index].baseUrl;\n }\n // ASR – A caption track generated using automatic speech recognition.\n // https://developers.google.com/youtube/v3/docs/captions\n }\n } catch (error) {\n return false;\n }\n}", "title": "" }, { "docid": "35474d2477b4593507b701aa44ab9bf7", "score": "0.54268974", "text": "function spotToYoutube(link){\n\t//TODO\n}", "title": "" }, { "docid": "aeac57985f82439a4588a0bb85e52319", "score": "0.54252684", "text": "function videoPlayerFetch(plant) {\n var videoUrl = \"https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=5&type=video&q=how%20to%20plant%20\" + plant + \"&key=AIzaSyCMPORVZJdaOUUus5_Ai-OfTRhBIcmYyAs\"\n fetch(videoUrl)\n .then(function(response) {\n if (response.ok) {\n return response.json()\n } else {\n $('.videoSection').text('No YouTube videos were found for this particular entry, please try another!')\n }\n })\n .then(function(data) {\n videoPlayerHandler(data)\n })\n .catch(function(error) {\n $('.videoSection').text(`An error has occurred loading videos... ${error}`);\n })\n\n}", "title": "" }, { "docid": "53832cb6cbd88c8264b855dc3775b19d", "score": "0.54188704", "text": "function changeSrc() {\n video_src = \"https://www.youtube.com/embed/\" + url[2];\n document.getElementById(\"video-src\").src = video_src;\n }", "title": "" }, { "docid": "7dfeabd16f5e4256007f7a9af892a842", "score": "0.5409069", "text": "function custom_video_html_generate(video_id, video_url, video_cover, video_mime_type) {\n if (video_mime_type == 'youtube') {\n return '<video id=\"' + video_id + '\" class=\"video-js vjs-default-skin video-1810-video-dimensions\" controls preload=\"auto\" poster=\"' + video_cover + '\" data-setup=\\'{\"techOrder\": [\"youtube\"], \"fluid\": true, \"aspectRatio\": \"16:9\"}\\'> <source src=\"' + video_url + '\" type=\"video/youtube\"></source><p class=\"vjs-no-js\">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href=\"http://videojs.com/html5-video-support/\" target=\"_blank\"> supports HTML5 video</a></p></video>';\n }\n else{\n video_mime_type = video_mime_type.replace(/video\\/quicktime/, 'video/mp4');\n \n return '<video id=\"' + video_id + '\" class=\"video-js vjs-default-skin video-1810-video-dimensions\" controls preload=\"auto\" poster=\"' + video_cover + '\" data-setup=\\'{\"fluid\": true, \"aspectRatio\": \"16:9\"}\\'> <source src=\"' + video_url + '\" type=\"'+ video_mime_type + '\"></source><p class=\"vjs-no-js\">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href=\"http://videojs.com/html5-video-support/\" target=\"_blank\"> supports HTML5 video</a></p></video>';\n }\n}", "title": "" }, { "docid": "91b82eee808b727c13c61cafb9025d23", "score": "0.5406982", "text": "constructor() {\n super();\n this.state = {\n slideDuration: 450,\n slideInterval: 2000,\n showVideo: {},\n };\n this.onSlide = this.onSlide.bind(this);\n this.images = [\n {\n thumbnail: `${PREFIX_URL}4v.jpg`,\n original: `${PREFIX_URL}4v.jpg`,\n embedUrl:\n 'https://www.youtube.com/embed/4pSzhZ76GdM?autoplay=1&showinfo=0',\n renderItem: this.renderVideo.bind(this),\n },\n {\n original: `${PREFIX_URL}image_set_default.jpg`,\n thumbnail: `${PREFIX_URL}image_set_thumb.jpg`,\n imageSet: [\n {\n srcSet: `${PREFIX_URL}image_set_cropped.jpg`,\n media: '(max-width: 1280px)',\n },\n {\n srcSet: `${PREFIX_URL}image_set_default.jpg`,\n media: '(min-width: 1280px)',\n },\n ],\n },\n {\n original: `${PREFIX_URL}1.jpg`,\n thumbnail: `${PREFIX_URL}1t.jpg`,\n originalClass: 'featured-slide',\n thumbnailClass: 'featured-thumb',\n },\n ];\n }", "title": "" }, { "docid": "ce6dab441dcd45898415fb9f4998a29e", "score": "0.53970134", "text": "function getAndShowVideo(name){\r\n\t$.ajax({\r\n\t\turl: \"https://www.googleapis.com/youtube/v3/search\",\r\n\t\tdata: {\r\n\t\t\tkey: \"AIzaSyBa3BsHMug2jQg83fp_DMpbnDMSbk6sUhk\",\r\n\t\t\tpart: \"snippet\",\r\n\t\t\tq: name + \" official\",\r\n\t\t\ttype: \"video\",\r\n\t\t\tvideoEmbeddable: true\r\n\t\t},\r\n\t\tsuccess: function(response){\r\n\t\t\tconsole.log(response);\r\n\t\t\t$(\"#wrapper\").html('<iframe id=\"ytplayer\" type=\"text/html\" width=\"640\" height=\"390\" src=\"http://www.youtube.com/embed/'+response.items[0].id.videoId+'?autoplay=1&origin=http://example.com\" frameborder=\"0\"/>'\r\n\t\t\t);\r\n\t\t}\r\n\t});\r\n}", "title": "" }, { "docid": "cb66e3582cc3505c9cd2a1c5c739b61d", "score": "0.53949654", "text": "function applyImdbThumbnail(div, getLargeVersion, id) {\n\t// Send ajax GET request to php script with the imdb url\n\t$.ajax({\n\t\turl: \"/helper_scripts/pull_site.php?url=https://www.imdb.com/title/\" + id + \"/\",\n\t\ttype: 'GET',\n\t\tsuccess: function(response) {\n\t\t\t// cut the resulting text to extract the image URL\n\t\t\tvar img = response.replace(response.substring(0, response.indexOf(\"src=\\\"\")+5), \"\");\n\t\t\timg = img.substring(0, img.indexOf(\"\\\" />\"));\n\n\t\t\t// Check if the current page is the homepage, if it is, change the image URL to pull a large sized image\n\t\t\tif (getLargeVersion) {\n\t\t\t\timg = img.replace(\"182,268\", \"675,1000\");\n\t\t\t\timg = img.replace(img.substring(img.indexOf(\"_U\")+1, img.indexOf(\"CR\")), \"SY1000_\");\n\t\t\t}\n\n\t\t\t// Update the background of the div with the pulled image\n\t\t\t$(div).css(\"background\", \"url(\" + img + \")\");\n\n\t\t\t// Call the removeShine function passing the div that the image was applied to\n\t\t\tremoveShine(div);\n\t\t}\n\t});\n}", "title": "" }, { "docid": "a34ca322254d2cfe11cd0761d92c5b02", "score": "0.5387599", "text": "get thumbLabel() { return this._thumbLabel; }", "title": "" }, { "docid": "cab4fe5a7630292ace1936f3ad331874", "score": "0.53875554", "text": "function _GetPlayerHtml(YouTubeVideoId) {\r\n // if YouTubeVideoId is null or empty, we provide an empty div with same dimension of the Player\r\n // This will fix a bug of IE (IE will load the swf forever if object movie is empty and/or embbed src is empty\r\n if (!YouTubeVideoId) {\r\n return '<div style=\"width:' + options.PlayerWidth + 'px;height:' + options.PlayerHeight + 'px\">';\r\n }\r\n\r\n var AutoPlay = \"\";\r\n var ShowRelated = \"&rel=0\";\r\n var fullScreen = \"\";\r\n if (options.AutoPlay) AutoPlay = \"&autoplay=1\";\r\n if (options.ShowRelated) ShowRelated = \"&rel=1\";\r\n if (options.AllowFullScreen) fullScreen = \"&fs=1\";\r\n\r\n var html = '';\r\n\r\n html += '<object height=\"' + options.PlayerHeight + '\" width=\"' + options.PlayerWidth + '\">';\r\n html += '<param name=\"movie\" value=\"http://www.YouTube.com/v/' + YouTubeVideoId + AutoPlay + ShowRelated + fullScreen + '\"> </param>';\r\n html += '<param name=\"wmode\" value=\"transparent\"> </param>';\r\n if (options.AllowFullScreen) {\r\n html += '<param name=\"allowfullscreen\" value=\"true\"> </param>';\r\n }\r\n html += '<embed src=\"http://www.YouTube.com/v/' + YouTubeVideoId + AutoPlay + ShowRelated + fullScreen + '\"';\r\n if (options.AllowFullScreen) {\r\n html += ' allowfullscreen=\"true\" ';\r\n }\r\n html += 'type=\"application/x-shockwave-flash\" wmode=\"transparent\" height=\"' + options.PlayerHeight + '\" width=\"' + options.PlayerWidth + '\"></embed>';\r\n html += '</object>';\r\n\r\n return html;\r\n }", "title": "" }, { "docid": "60a4f110627bba4e66401c8bfb884d7e", "score": "0.5383606", "text": "function getVideo(movie) {\n\tidArr = [];\n\tlet request = gapi.client.youtube.search.list({\n\t\tpart: 'snippet',\n\t\ttype: 'video',\n\t\tq: encodeURIComponent(movie).replace(/%20/g, '+'),\n\t\tmaxResults: 20,\n\t\torder: 'relevance'\n\t});\n\n\trequest.execute(function (result) {\n\t\tif (result) {\n\t\t\tfor (var i = 0; i < result.items.length; i++) {\n\t\t\t\tidArr.push(result.items[i].id.videoId);\n\t\t\t}\n\t\t\tvidId = idArr[0];\n\t\t\tlet url = `https://www.youtube.com/embed/${idArr[0]}`;\n\t\t\t$('#trailer').attr('src', url);\n\t\t}\n\t});\n}", "title": "" }, { "docid": "691b2885067ebc0798bb61f7a6f856cb", "score": "0.5381761", "text": "function getYouTubeVideos() {\n\t//Make sure that the ytplayer variable is there and properly initialized\n\tif (!(ytplayer && ytplayer.config && ytplayer.config.args && ytplayer.config.args.url_encoded_fmt_stream_map)) {\n\t\treturn null;\n\t}\n\t//grab the videos out of the ytplayer variable\n\tvar YTPlayerVideos = ytplayer.config.args.url_encoded_fmt_stream_map.split(',');\n\tvar videos = [];\n var video, index;\n\t//parse out the information for each video and put it into the videos variable\n\tfor (index in YTPlayerVideos) {\n\t\tvideo = parseVideoURIIntoObject(YTPlayerVideos[index]);\n if (video) {\n videos.push(video);\n }\n\t}\n if(videos.length < 1){\n return false;\n }\n\t//If we don't have adaptive formats available then just return videos we have so far.\n\tif (!(ytplayer && ytplayer.config && ytplayer.config.args && ytplayer.config.args.adaptive_fmts)) {\n\t\treturn [videos];\n\t}\n\tvar regularAndAdaptiveVideos = [videos];\n\tYTPlayerVideos = ytplayer.config.args.adaptive_fmts.split(',');\n\tvideos = [];\n\t//parse out the information for each video and put it into the videos variable\n\tfor (index in YTPlayerVideos) {\n video = parseVideoURIIntoObject(YTPlayerVideos[index]);\n if (video) {\n videos.push(video);\n }\n\t}\n if(videos.length < 1){\n return regularAndAdaptiveVideos[0];\n }\n\tregularAndAdaptiveVideos.push(videos);\n\treturn regularAndAdaptiveVideos;\n}", "title": "" }, { "docid": "94d796fb1dc5e5122da72dd30d1fa5e5", "score": "0.53796554", "text": "function convertYoutubeLink(url) {\n var videoID = url.split(\"v=\")[1]; // Get ID and variables\n if(videoID == null)\n videoID = url.split(\"e/\")[1]; // If there is no v= in the link, just separate with a slash\n\n var endPoint = videoID.indexOf(\"&\"); // Find start of variables (time to start video, end video, etc.)\n if(endPoint != -1) { // If there are any vars\n videoID = videoID.substring(0, endPoint); // Get 12 digit video ID and leave out vars\n }\n url = \"https://www.youtube.com/embed/\" + videoID;// Youtube by default has links that do not work in an iframe, we have to convert them using /embed/\n return url;\n}", "title": "" } ]
ae98dce9393633569da4b27c68a61888
isFloat (STRING s [, BOOLEAN emptyOK]) True if string s is an unsigned floating point (real) number. Also returns true for unsigned integers. If you wish to distinguish between integers and floating point numbers, first call isInteger, like If (!isInteger (s, true)) && isFloat (s, true)) Does not accept exponential notation.
[ { "docid": "1261438943e476186709735faa460110", "score": "0.80718416", "text": "function isFloat (s)\r\n{ var i;\r\n var seenDecimalPoint = false;\r\n var decimalPointDelimiter = \".\";\r\n if (isEmpty(s)) \r\n if (isFloat.arguments.length == 1) return defaultEmptyOK;\r\n else return (isFloat.arguments[1] == true);\r\n if (s == decimalPointDelimiter) return false;\r\n\r\n // Search through string's characters one by one\r\n // until we find a non-numeric character.\r\n // When we do, return false; if we don't, return true.\r\n\r\n for (i = 0; i < s.length; i++)\r\n { \r\n var c = s.charAt(i);\t// Check that current character is number.\r\n if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;\r\n else if (!isDigit(c)) return false;\r\n }\r\n return true;\t\t// All characters are numbers.\r\n}", "title": "" } ]
[ { "docid": "28da86898fa3d3942672aac5678c8cae", "score": "0.82353866", "text": "function PublicFunction_isFloat(sValue){\r\n if (sValue== null) return false;\r\n var vsValue= this.trim(sValue+ \"\");\r\n var vsResult= \"\";\r\n vsResult= vsValue.replace(this.RE_FLOAT01, \"\");\r\n if (vsResult.length== 0) return true;\r\n vsResult= vsValue.replace(this.RE_FLOAT02, \"\");\r\n if (vsResult.length== 0) return true;\r\n vsResult= vsValue.replace(this.RE_FLOAT03, \"\");\r\n if (vsResult.length== 0) return true;\r\n return false;\r\n}", "title": "" }, { "docid": "e6fd441a4f41d1ca924cc294e27a21f1", "score": "0.8069302", "text": "function isSignedFloat (s)\r\n\r\n{ if (isEmpty(s))\r\n if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;\r\n else return (isSignedFloat.arguments[1] == true);\r\n\r\n else {\r\n var startPos = 0;\r\n var secondArg = defaultEmptyOK;\r\n\r\n if (isSignedFloat.arguments.length > 1)\r\n secondArg = isSignedFloat.arguments[1];\r\n\r\n // skip leading + or -\r\n if ( (s.charAt(0) == \"-\") || (s.charAt(0) == \"+\") ) {\r\n if(s.length==1){ // The sign only is invalid\r\n return false;\r\n }\r\n startPos = 1;\r\n }\r\n return (isFloat(s.substring(startPos, s.length), secondArg))\r\n }\r\n}", "title": "" }, { "docid": "cde665ca3547560abb537525062940af", "score": "0.8067872", "text": "function isFloat (s)\r\n\r\n{ var i;\r\n var seenDecimalPoint = false;\r\n\r\n if (isEmpty(s))\r\n if (isFloat.arguments.length == 1) return defaultEmptyOK;\r\n else return (isFloat.arguments[1] == true);\r\n\r\n if (s == decimalPointDelimiter) return false;\r\n\r\n // Search through string's characters one by one\r\n // until we find a non-numeric character.\r\n // When we do, return false; if we don't, return true.\r\n\r\n for (i = 0; i < s.length; i++)\r\n {\r\n // Check that current character is number.\r\n var c = s.charAt(i);\r\n\r\n if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;\r\n else if (!isDigit(c)) return false;\r\n }\r\n\r\n // All characters are numbers.\r\n return true;\r\n}", "title": "" }, { "docid": "cde665ca3547560abb537525062940af", "score": "0.8067872", "text": "function isFloat (s)\r\n\r\n{ var i;\r\n var seenDecimalPoint = false;\r\n\r\n if (isEmpty(s))\r\n if (isFloat.arguments.length == 1) return defaultEmptyOK;\r\n else return (isFloat.arguments[1] == true);\r\n\r\n if (s == decimalPointDelimiter) return false;\r\n\r\n // Search through string's characters one by one\r\n // until we find a non-numeric character.\r\n // When we do, return false; if we don't, return true.\r\n\r\n for (i = 0; i < s.length; i++)\r\n {\r\n // Check that current character is number.\r\n var c = s.charAt(i);\r\n\r\n if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;\r\n else if (!isDigit(c)) return false;\r\n }\r\n\r\n // All characters are numbers.\r\n return true;\r\n}", "title": "" }, { "docid": "5b8af6d3cfecc24f69b44d74159c9d59", "score": "0.79672045", "text": "function isSignedFloat (s) { \r\n\tif (isEmpty(s)) {\r\n if (isSignedFloat.arguments.length == 1) {\r\n\t\t\treturn defaultEmptyOK;\r\n\t\t} else {\r\n\t\t\treturn (isSignedFloat.arguments[1] == true);\r\n\t\t}\r\n } else {\r\n var startPos = 0;\r\n var secondArg = defaultEmptyOK;\r\n if (isSignedFloat.arguments.length > 1) {\r\n secondArg = isSignedFloat.arguments[1];\r\n\t\t}\r\n // skip leading + or -\r\n if ( (s.charAt(0) == \"-\") || (s.charAt(0) == \"+\") ) {\r\n\t\t\tstartPos = 1;\r\n\t\t}\r\n return (isFloat(s.substring(startPos, s.length), secondArg))\r\n }\r\n}", "title": "" }, { "docid": "238ab2447b316e3ecc14bdf56db56450", "score": "0.7921052", "text": "function IsFloat(s){\n var ch = \"\";\n var justFloat = \"0123456789.\";\n \n for (var i = 0; i < s.length; i++)\n {\n ch = s.substr(i, 1);\n \n if (justFloat.indexOf(ch) == -1)\n return false;\n }\n return true;\n}", "title": "" }, { "docid": "3009da24f61cbae46528305802c45e63", "score": "0.7704614", "text": "function isFloat(str){\n\n\tlet out = true;\n\tif (str.search(/[^\\.\\d]/) != -1 || (str.indexOf(\".\") != str.lastIndexOf(\".\"))){\n\n\t\tout = false;\n\t};\n\treturn out\n}", "title": "" }, { "docid": "292e1d33a637659e8bc618d00c03a5c8", "score": "0.7697655", "text": "function isFloat(value) {\n if (notEmpty(value)) {\n if (typeof value !== 'string')\n value = value.toString();\n return regexpr_1.float.test(value);\n }\n return false;\n}", "title": "" }, { "docid": "2d85e7d6420999d9ab151a6bb4b6aa99", "score": "0.7677001", "text": "function isFloat(n){ //fonction pour n'avoir que des chiffres.\n return n != \"\" && !isNaN(n) && n !==0;\n}//fin de la fonction", "title": "" }, { "docid": "f0b972e62dc74740b8a10afac376b8e5", "score": "0.7655484", "text": "function isFloat(valueOfStr){\r\n\tvar patrn1 = /^([+|-]?\\d+)(\\.\\d+)?$/;\r\n\ttry{\r\n\t\t//alert(\"isFloat(\"+valueOfStr+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "1d38cd0f55f7d3742c0a4730449672da", "score": "0.7553502", "text": "function isFloat(str){\n \n if (str=='') {\n return true;\n }\n var reg = /^-?\\d+(\\.\\d{1,2})?$/;\n return reg.test(str);\n}", "title": "" }, { "docid": "2d8410eb0c227c196c473ef03a2a03e1", "score": "0.74234545", "text": "function isFloat(n){\n\t return parseFloat(n.match(/^-?\\d*(\\.\\d+)?$/))>0;\n\t}", "title": "" }, { "docid": "f45b14a332f7b1f9094e9f8d7bd6945d", "score": "0.7200579", "text": "function h$isFloat (n) {\n return n===+n && n!==(n|0);\n}", "title": "" }, { "docid": "f45b14a332f7b1f9094e9f8d7bd6945d", "score": "0.7200579", "text": "function h$isFloat (n) {\n return n===+n && n!==(n|0);\n}", "title": "" }, { "docid": "f45b14a332f7b1f9094e9f8d7bd6945d", "score": "0.7200579", "text": "function h$isFloat (n) {\n return n===+n && n!==(n|0);\n}", "title": "" }, { "docid": "f45b14a332f7b1f9094e9f8d7bd6945d", "score": "0.7200579", "text": "function h$isFloat (n) {\n return n===+n && n!==(n|0);\n}", "title": "" }, { "docid": "f45b14a332f7b1f9094e9f8d7bd6945d", "score": "0.7200579", "text": "function h$isFloat (n) {\n return n===+n && n!==(n|0);\n}", "title": "" }, { "docid": "9cdd8d861cffe7d8cd90569b962cf65c", "score": "0.7049468", "text": "function isFloat(val) {\n var floatRegex = /^-?\\d+(?:[.,]\\d*?)?$/;\n if (!floatRegex.test(val))\n return false;\n\n val = parseFloat(val);\n if (isNaN(val))\n return false;\n return true;\n}", "title": "" }, { "docid": "00dafd98956612f5d5aa9346557e9a43", "score": "0.7002296", "text": "function floatOfString(s) {\n // Check whether we're dealing with nan, since it's the error case for Number.parseFloat\n if (s === 'nan') {\n return NaN;\n } else {\n let num = Number.parseFloat(s);\n if (Number.isNaN(num)) {\n return null;\n } else {\n return num\n }\n }\n}", "title": "" }, { "docid": "636479bb58907a83991d0591238488bb", "score": "0.6927041", "text": "function isFloat(n) {\n return n === +n && n !== (n|0);\n}", "title": "" }, { "docid": "275de6df0f5510be45769fb160ec6fbf", "score": "0.69153905", "text": "function isFloat(n) {\n return n === +n && n !== (n | 0);\n}", "title": "" }, { "docid": "4dae929483884dbf5495b1edee0d09a7", "score": "0.6884498", "text": "ParseFloat(s){\r\n\t\tif(s == '' || s == 'undefined' || s == null){\r\n\t\t\treturn 0.0;\r\n\t\t}\r\n\t\t\r\n\t\tvar chr, ss = '', i, l = s.length;\r\n\t\ts = s.toString();\r\n\t\tfor(i = 0; i < l; i += 1){\r\n\t\t\tchr = s.charAt(i);\r\n\t\t\tif(((chr >= '0') && (chr <= '9')) || chr == '.' || chr == '-') {\r\n\t\t\t\tss += chr;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn parseFloat(ss);\r\n\t}", "title": "" }, { "docid": "486c7bd77e51c4224067fb9e7f03b594", "score": "0.6873529", "text": "function parseFloat_(s) {\n return validFloatRepr.test (s) ? Just (parseFloat (s)) : Nothing;\n }", "title": "" }, { "docid": "6f592792bb52824bcd9a12c85f75d215", "score": "0.6779612", "text": "function safeParseFloat (str) {\n var flo = parseFloat(str);\n if( isNaN(flo) === true ) {\n throw errors[103];\n }\n return flo;\n}", "title": "" }, { "docid": "2bf42ac9c02f6a8dc3fd4a4fa0dfff56", "score": "0.6777058", "text": "function is_float(object)\n{\n return object != undefined && object.toFixed != undefined && parseInt(object) != object;\n}", "title": "" }, { "docid": "60e985eee8963bc16e91f8513b7d4047", "score": "0.67669016", "text": "function isFloatNum(value) {\r\n if (typeof(value) !== \"string\") value = String(value);\r\n\r\n if (value.includes(\".\")) return true;\r\n return false;\r\n}", "title": "" }, { "docid": "b9c18c12a90fddf8d0f191c5ab5e4b71", "score": "0.675983", "text": "function isFloat(n) {\n\t\t\t\treturn n === +n && n !== (n | 0);\n\t\t\t}", "title": "" }, { "docid": "5a2e138f48a12471cee9fcabf2bd40cb", "score": "0.6660681", "text": "function isFloat(val) {\n return (isNumber(val) &&\n Number(val) === val && val % 1 !== 0);\n}", "title": "" }, { "docid": "e4aaab1c82b757a901c3505dde05e860", "score": "0.6631634", "text": "function isFloatNum(num) {\n\t// console.log(num);\n\treturn num.toString().includes(\".\");\n}", "title": "" }, { "docid": "bb96064c10e2725238a1fea5f32393c0", "score": "0.65826166", "text": "function isPlusFloat(valueOfStr){\r\n\tvar patrn1 = /^(\\d+)(\\.\\d+)?$/;\r\n\ttry{\r\n\t\t//alert(\"isPlusFloat(\"+valueOfStr+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "ef1c698db0889c58d23ffb9139f10f72", "score": "0.6484704", "text": "function parseFloat(str) {\n var float = 0, sign, order, mantiss, exp,\n int, checkexp = 0, multi = 1;\n if (/^0x/.exec(str)) {\n int = parseInt(str, 16);\n } else {\n for (var i = str.length - 1; i >= 0; i -= 1) {\n if (str.charCodeAt(i) > 255) {\n console.log('Wrong string parametr');\n return false;\n }\n int += str.charCodeAt(i) * multi;\n multi *= 256;\n }\n }\n sign = (int >>> 31) ? -1 : 1;\n exp = (int >>> 23 & 0xff) - 127;\n checkexp = exp;\n mantissa = ((int & 0x7fffff) + 0x800000).toString(2);\n for (i = 0; i < mantissa.length; i += 1) {\n float += parseInt(mantissa[i]) ? Math.pow(2, exp) : 0;\n exp--;\n }\n if (checkexp < 0) {\n return int;\n } else {\n return (float * sign).toFixed(2);\n }\n}", "title": "" }, { "docid": "09ef38bda82449fc3457303ccc78e184", "score": "0.6484526", "text": "function isFloat(n){\n return Number(n) === n && n % 1 !== 0\n}", "title": "" }, { "docid": "4a8b220d0b92b8993d34135df744daa4", "score": "0.6469321", "text": "function StringToFloat(str){\n if (str.length==0){\n return 0;\n }\n try {\n return parseFloat(desformatnum (str));\n }\n catch(e){\n }\n return 0;\n}", "title": "" }, { "docid": "36a0b7efb747a2dec3f151fdf6055085", "score": "0.64666146", "text": "function isNegativeFloat(valueOfStr){\r\n\tvar patrn1 = /^(-\\d+)(\\.\\d+)?$/;\r\n\ttry{\r\n\t\t//alert(\"isNegativeFloat(\"+valueOfStr+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "5b6ac5511ff6ab2f626b30568cc26742", "score": "0.62534034", "text": "isFloat(val) {\n return !isNaN(Number(val)) && Number(val) % 1 !== 0;\n }", "title": "" }, { "docid": "9e9ddc6ec9518ba712dcbef1d4a155cc", "score": "0.6210045", "text": "function isRealNumber(strInput) {\n\treturn (strInput == parseFloat(strInput));\n}", "title": "" }, { "docid": "95d1ddaf0af7005b077ccf5c273aa0b8", "score": "0.6200775", "text": "function testFloat(valueOFinput, plusORnegative, decimal){\r\n\tvalueOFinput = valueOFinput.replace(/(^\\s*)|(\\s*$)/g, \"\");\r\n\tplusORnegative = plusORnegative.replace(/(^\\s*)|(\\s*$)/g, \"\");\r\n\tdecimal = decimal.replace(/(^\\s*)|(\\s*$)/g, \"\");\r\n\t\r\n\tif(valueOFinput==null || valueOFinput==\"\"){\r\n\t\talert(\"Illegimate number input!\");\r\n\t\treturn false;\r\n\t}\r\n\tif(plusORnegative==null && plusORnegative!=\"+\" && plusORnegative!=\"-\" && plusORnegative!=\"\"){\r\n\t\talert(\"Illegimate sign input!\");\r\n\t\treturn false;\r\n\t}\r\n\tvar dec = parseInt(decimal);\r\n\tif(typeof(dec)==\"undefine\" || dec == null){\r\n\t\talert(\"Illegimate decimal number input!\");\r\n\t\treturn false;\r\n\t}else if(dec < 0){\r\n\t\talert(\"negative decimal number input! Make it positive number\");\r\n\t}\r\n\t\r\n\tvar rg = \"\";\r\n\t\r\n\tif(plusORnegative==\"+\"){\r\n\t\trg += '^([+|]?';\r\n\t}else if(plusORnegative==\"-\"){\r\n\t\trg += '^([-]';\r\n\t}else{\r\n\t\trg += '^([+|-|]?';\r\n\t}\r\n\t\r\n\tvar pp = new RegExp(rg + '[0-9]{1,9})+(.[0-9]{0,'+dec+'})?$');\r\n\t//alert(pp);\r\n\t\t\r\n if(!pp.exec(valueOFinput)){\r\n\t\talert(\"Illegimate value input with \"+dec+\" decimal!\");\r\n\t\treturn false;\r\n\t}else{\r\n\t\talert(\"Legimate value input with \"+dec+\" decimal!\");\r\n\t\treturn true;\r\n\t}\r\n}", "title": "" }, { "docid": "575f707876f0319fef0b696308c1902a", "score": "0.6173948", "text": "function IsFloat(e) {\n\ttecla = (document.all) ? e.keyCode : e.which;\n\tif(tecla==0){\n\t\treturn true;\n\t}else{\n\t\tif (tecla==8) return true;\n\t\tpatron = /[\\d\\.]/;\n\t\tte = String.fromCharCode(tecla);\n\t\treturn patron.test(te);\n\t}\n}", "title": "" }, { "docid": "d4c83a2874fb8958c4990e0598384337", "score": "0.61692667", "text": "readFloat() {\n const helper = new misc_functions_1.ReturnHelper();\n const start = this.cursor;\n const readToTest = this.readWhileRegexp(StringReader.charAllowedNumber);\n\n if (readToTest.length === 0) {\n return helper.fail(EXCEPTIONS.EXPECTED_FLOAT.create(start, this.string.length));\n } // The Java readInt throws upon multiple `.`s, but Javascript's doesn't\n\n\n if ((readToTest.match(/\\./g) || []).length > 1) {\n return helper.fail(EXCEPTIONS.INVALID_FLOAT.create(start, this.cursor, this.string.substring(start, this.cursor)));\n }\n\n try {\n return helper.succeed(parseFloat(readToTest));\n } catch (error) {\n return helper.fail(EXCEPTIONS.INVALID_FLOAT.create(start, this.cursor, readToTest));\n }\n }", "title": "" }, { "docid": "b6bde7b91ace364e571eb35ff95f376d", "score": "0.60812956", "text": "function parseF(s) {\n // if (typeof(parseInt(s)) === \"number\"){\n // return parseFloat(s)\n \n // }else{\n // return null\n // }\n \n if ( isNaN(parseFloat(s) )) {\n return null\n } else{\n return parseFloat(s)\n }\n \n \n }", "title": "" }, { "docid": "cd87011e53422b5d2f7bd2d2f45e0e7d", "score": "0.6067832", "text": "function CheckForFloat(i)\n{\n if(i.value.length>0)\n {\n i.value = i.value.replace(/[^\\d\\.]+/g, '');\n }\n}", "title": "" }, { "docid": "974287dadb90b0ebc4c434c237f46d62", "score": "0.60643554", "text": "function validFloat(k) {\n var regex = /^[0-9]*\\.?[0-9]*$/;\n return k.match(regex);\n}", "title": "" }, { "docid": "4e6b07b454fce00111e4a5f709278b71", "score": "0.60375345", "text": "function isFloatD4(valueOfStr){\r\n\tvar patrn1 = /^([+|-]?[0-9])+(.[0-9]{0,4})?$/;\r\n\ttry{\r\n\t\t//alert(\"isFloatD4(\"+valueOfStr+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "51be18a407407537d6d2e63b90888788", "score": "0.5996183", "text": "function checkNumericFloat(name, value){\n\tvar conversion = parseFloat(value);\n\t\n\tif (isNaN(conversion) == true){\n\t\terrMessages += \"<li>\" + name + \" - Value must be a number with decimals.</li>\";\n\t\treturn false;\n\t}\n\telse{\n\t\treturn true;\n\t}\n}", "title": "" }, { "docid": "27f3b9d4d1fd66246cf5052ac9da8f81", "score": "0.59853876", "text": "function checkIfFloat(value) {\n return Number(value) === value && value % 1 !== 0;\n }", "title": "" }, { "docid": "ca553bf65c9d02e2c84c0e2809f596c2", "score": "0.5965398", "text": "function forceParseFloat(stValue)\n{\n var flValue = parseFloat(stValue);\n \n if (isNaN(flValue))\n {\n return 0.00;\n }\n \n return flValue;\n}", "title": "" }, { "docid": "22c1ded582b504679e55c02106849b04", "score": "0.59576297", "text": "function isFloatTD4(valueOfStr, eLength){\r\n\tvar patrn1 = /^([+|-]?[0-9])+(.[0-9]{0,4})?$/;\r\n\ttry{\r\n\t\t//alert(\"isFloatTD4(\"+valueOfStr+\",\"+eLength+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\t\t\r\n\t\t\tvar tlen = valueOfStr.length;\r\n\t\t\tvar dot = valueOfStr.indexOf('.');\r\n\t\t\tvar plus = valueOfStr.indexOf('+');\r\n\t\t\tvar neg = valueOfStr.indexOf('-');\r\n\t\t\tvar rlen = tlen;\r\n\t\t\tif(dot != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\tif(plus != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\tif(neg != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\t\t\r\n\t\t\tif(rlen==parseInt(eLength))\t\t\t\t\r\n\t\t\t\treturn true;\r\n\t\t\telse \r\n\t\t\t\treturn false;\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "78c0dc9f46c2dc2dded566d604369c05", "score": "0.5928863", "text": "function parseFloat_(a){return\"string\"==typeof a?parseFloat(a):a}", "title": "" }, { "docid": "d53748008d03f082b2e42b61e74b0088", "score": "0.59204334", "text": "function isFloatingPoint(n) {\n return n >= 0x8000000000000000 ||\n (Math.abs(n) < 0x4000000000000\n && Math.floor(n) !== n);\n}", "title": "" }, { "docid": "b56c018fa2658959628e394808b90e81", "score": "0.58785325", "text": "function convertToFloat(str) {\n return parseFloat(str);\n}", "title": "" }, { "docid": "1027ecccf5bbba6262f6ea49fa0188dc", "score": "0.5842348", "text": "function parseFloatMaybe(string) {\n var parsed = parseFloat(string);\n return !isNaN(parsed) ? parsed : string;\n}", "title": "" }, { "docid": "b63297285334ad93a4bb9351c7561d6a", "score": "0.5808735", "text": "isNumber(number) {\n const float = parseFloat(number)\n return !isNaN(float) && float + '' == number + ''\n }", "title": "" }, { "docid": "fd84cf65ef7e7d66ee1da1e3e3d08bce", "score": "0.5806726", "text": "function isNumeric(s) {\n return !isNaN(s - parseFloat(s));\n }", "title": "" }, { "docid": "58dc88d90342d93a4acf00831993a7ea", "score": "0.57927984", "text": "function CheckFloatDataType(field, rules, i, options) {\n ///Assign a Reguler experassion in a variable\n var regex = /([\\d\\w]+?:\\/\\/)?([\\w\\d\\.\\-]+)(\\.\\w+)(:\\d{1,5})?(\\/\\S*)?/;\n //Match Reguler expression with user input data\n if (!regex.test(field.val())) {\n ///Show Message if Invalid Information\n return \"Please Enter Numbers Only.\"\n }\n}", "title": "" }, { "docid": "7033827170e6cbfebd63ca472f0a1b4a", "score": "0.57592434", "text": "function getFloat(str) {\n return parseFloat(str.replace(/[^0-9\\.\\-]/g, ''));\n}", "title": "" }, { "docid": "06ff1888a8a55e6ad2a4c210fd390f67", "score": "0.5748844", "text": "function toFloat(val, def) {\n if (is_1.isFloat(val))\n return val;\n if (!is_1.isValue(val))\n return toDefault(null, def);\n var parsed = function_1.tryWrap(parseFloat, val)(def);\n if (is_1.isFloat(parsed) || is_1.isNumber(parsed))\n return parsed;\n if (toBoolean(val))\n return 1;\n return 0;\n}", "title": "" }, { "docid": "9804b1730c3f5c9731ec923a1a41fc2d", "score": "0.574053", "text": "function sc_string2real(s) {\n return parseFloat(s);\n}", "title": "" }, { "docid": "5bb053ec28a7ceb1528a4db3626f83bb", "score": "0.5691778", "text": "function binaryToFloat(str){\n return parseFloat(parseInt(str, 2));\n}", "title": "" }, { "docid": "75d5bbddd97ef99b9d88eff94498b95b", "score": "0.5685065", "text": "function enforceFloat() {\r\n var valid = /^\\-?\\d+\\.\\d*$|^\\-?[\\d]*$/;\r\n var number = /\\-\\d+\\.\\d*|\\-[\\d]*|[\\d]+\\.[\\d]*|[\\d]+/;\r\n if (!valid.test(this.value)) {\r\n var n = this.value.match(number);\r\n this.value = n ? n[0] : '';\r\n }\r\n}", "title": "" }, { "docid": "4a74d9ea138c1a4e6507b1a78b5fe4ca", "score": "0.5665269", "text": "function isFinite(val){\n\t var is = false;\n\t if (typeof val === 'string' && val !== '') {\n\t is = GLOBAL.isFinite( parseFloat(val) );\n\t } else if (isNumber(val)){\n\t // need to use isNumber because of Number constructor\n\t is = GLOBAL.isFinite( val );\n\t }\n\t return is;\n\t }", "title": "" }, { "docid": "3fec52c9a9ec7604e6a4b24a194f7b1c", "score": "0.56376475", "text": "function isNumeric(string, rejectThousandSep )\n{\n string = string.trim();\n if ( rejectThousandSep !== null && rejectThousandSep )\n {\n var hasThousands = ( string.search( new RegExp( THOUSANDS_SEP ) ) !== -1 ) ;\n if (hasThousands)\n {\n return false;\n }\n }\n string = string.replace(new RegExp(THOUSANDS_SEP, 'g'), '');\n if ( string.search( new RegExp(EFLOAT_REGEXP) ) === 0 )\n {\n var floatValue = parseFloat(string);\n return !isNaN(floatValue);\n }\n return false;\n}", "title": "" }, { "docid": "6d2271ef0e8b687b0a36ce9576301760", "score": "0.55851287", "text": "function isFinite(value) {\n return window.isFinite(value) && !window.isNaN(parseFloat(value));\n}", "title": "" }, { "docid": "483f9de751257a9809fb56b504092b42", "score": "0.5573058", "text": "function isNum(str) {\n return !isNaN(str.toString());\n}", "title": "" }, { "docid": "f76df6ed1dda52958b2ba6d19c5bcc70", "score": "0.55691826", "text": "function fn_CheckFloatNumber ( theElement , theElementName )\n\t{\n\t\t/*\n\t\tif ( theElement == undefined )\n\t\t{\n\t\t\talert ( \"要求检查的项目(\" + theElementName\t+ \")并不是一个有效的JavaScript对象\" ) ;\n\t\t\treturn false;\n\t\t}\n\t\t*/\n\t\tif( isNaN( parseFloat ( theElement.value ) ) )\n\t\t{\n\t\t\talert( \"\\\"\" + theElementName + \"\\\"\" + \"不是一个有效的数字!\" ) ;\n\t\t\ttheElement.focus();\n\t\t\treturn false ;\n\t\t}\n\t\treturn true;\n\t}", "title": "" }, { "docid": "43ffc53b38a730372fcbe036bf63629c", "score": "0.5554539", "text": "function nummy(x) { return !isNaN(parseFloat(x)) && isFinite(x) }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "2f6c14a91a247f8f5b1a42fe0c8c9821", "score": "0.5552453", "text": "function isFinite$1(obj) {\n return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));\n }", "title": "" }, { "docid": "da8b20efd61aad127d6887634b95eedc", "score": "0.5522403", "text": "function isNegativeFloatTD4(valueOfStr){\r\n\tvar patrn1 = /^(-[0-9])+(.[0-9]{0,4})?$/;\r\n\ttry{\r\n\t\t//alert(\"isNegativeFloatTD4(\"+valueOfStr+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\tvar tlen = valueOfStr.length;\r\n\t\t\tvar dot = valueOfStr.indexOf('.');\r\n\t\t\tvar plus = valueOfStr.indexOf('+');\r\n\t\t\tvar neg = valueOfStr.indexOf('-');\r\n\t\t\tvar rlen = tlen;\r\n\t\t\tif(dot != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\tif(plus != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\tif(neg != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\t\t\r\n\t\t\tif(rlen==parseInt(eLength))\t\t\t\t\r\n\t\t\t\treturn true;\r\n\t\t\telse \r\n\t\t\t\treturn false;\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "132670dd5229949afb19d0d547ddee9b", "score": "0.5504537", "text": "function numToFloat(num)\n{\n\tif(num == \"\")\n\t\tnum = \"0.0\";\n\t\t\n\tif(isNaN(num))\n\t{\n\t\tdebug(num+\"Ϊ֣...\");\n\t\treturn \"\";\t\n\t}\n\tvar rule = \"^(-?\\\\d+)(\\\\.\\\\d+)$\";\n\tvar result = num.match(rule);\n\tif(null == result){\n\t\tnum += \".0\"\n\t}\n\treturn num;\n}", "title": "" }, { "docid": "0d987f0a32f125b1dc80288f6808d1e9", "score": "0.54979813", "text": "function float(v) {\n\treturn v ? parseFloat(v.toString().replace(/[^\\d.-]/g, '')) || 0 : 0;\n}", "title": "" }, { "docid": "11159a34d360c901fde9b3a42a5bc5f7", "score": "0.5470513", "text": "function convertToFloat(stringAmount) {\r\n var parseStringAmount = parseFloat(\"stringAmount\");\r\n return parseFloat;\r\n\r\n}", "title": "" }, { "docid": "6643bdd655fcf48b26ee9f494523c3f0", "score": "0.54446685", "text": "function isNum(n) {\n return (!isNaN(parseFloat(n)) && isFinite(n));\n}", "title": "" }, { "docid": "0530ebf79c79601fec9c9b6370fa3bd5", "score": "0.54236263", "text": "function isPlusFloatD4(valueOfStr){\r\n\tvar patrn1 = /^([+|]?[0-9])+(.[0-9]{0,4})?$/;\r\n\ttry{\r\n\t\t//alert(\"isPlusFloatD4(\"+valueOfStr+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "209be7465f302a87ade0725ee38ade6d", "score": "0.538366", "text": "function isFloatValue(e,obj)\n {\n\t\tif ([e.keyCode||e.which]==8) //this is to allow backspace\n\t\t\treturn true;\n\t\tif ([e.keyCode||e.which]==46) {\n\t var val = obj.value;\n\t if(val.indexOf(\".\") > -1)\n\t {\n\t e.returnValue = false;\n\t return false;\n\t }\n\t return true;\n\t }\n\t\t\n\t var charCode = (e.which) ? e.which : event.keyCode\n if (charCode > 31 && (charCode < 48 || charCode > 57)){\n return false;\n }\n return true;\n }", "title": "" }, { "docid": "8b749e7f9eabae1193e03e176dc019e7", "score": "0.5367595", "text": "function parseXSDFloat(value) {\n const numb = Number(value);\n if (isNaN(numb)) {\n if (value === 'NaN') {\n return NaN;\n }\n if (value === 'INF') {\n return Infinity;\n }\n if (value === '-INF') {\n return -Infinity;\n }\n return undefined;\n }\n return numb;\n}", "title": "" }, { "docid": "01b0ae64ed071204c8382726250e4297", "score": "0.53557193", "text": "function stringToNumber(string) {\n if(isNaN(string))\n return false;\n return parseFloat(string);\n}", "title": "" }, { "docid": "e84629357bcedcddc8577fcfa3d1bb70", "score": "0.53554326", "text": "function isNegativeFloatD4(valueOfStr){\r\n\tvar patrn1 = /^(-[0-9])+(.[0-9]{0,4})?$/;\r\n\ttry{\r\n\t\t//alert(\"isNegativeFloatD4(\"+valueOfStr+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "411c3b18be972e04a033f3c11b59250b", "score": "0.5348958", "text": "function isNumeric(x) { return !isNaN(parseFloat(x)) && isFinite(x); }", "title": "" }, { "docid": "b9bdf22225ca7e2546fe3900e786e942", "score": "0.5285574", "text": "function fixFloat(fld)\n{\n if (!fld.value.length||fld.disabled)\n return true; // blank fields are the domain of requireValue\n\n val = parseFloat(fld.value);\n if(isNaN(val))\n {\n fld.value= '0';\n return false;\n }\n\n return true;\n}", "title": "" }, { "docid": "b5a3cd38f7c2cacc5c80e31761d6f8d8", "score": "0.52830845", "text": "function isFiniteNumber(value) {\n return typeof value === 'number' && isFinite(value);\n}", "title": "" }, { "docid": "75b7ded771934a79b988aba823934f55", "score": "0.5270197", "text": "function numberIsFinite(value){\n return typeof value === \"number\" && isFinite(value);\n }", "title": "" }, { "docid": "a205f63cb45a89704e0450fbfa519a0a", "score": "0.5251669", "text": "function isPlusFloatTD4(valueOfStr, eLength){\r\n\tvar patrn1 = /^([+|]?[0-9])+(.[0-9]{0,4})?$/;\r\n\ttry{\r\n\t\t//alert(\"isPlusFloatTD4(\"+valueOfStr+\",\"+eLength+\").patrn=\"+patrn1.exec(valueOfStr));\r\n\t\tif (patrn1.exec(valueOfStr)){\r\n\t\t\tvar tlen = valueOfStr.length;\r\n\t\t\tvar dot = valueOfStr.indexOf('.');\r\n\t\t\tvar plus = valueOfStr.indexOf('+');\r\n\t\t\tvar neg = valueOfStr.indexOf('-');\r\n\t\t\tvar rlen = tlen;\r\n\t\t\tif(dot != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\tif(plus != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\tif(neg != -1)\r\n\t\t\t\trlen = rlen - 1;\r\n\t\t\t\t\r\n\t\t\tif(rlen==parseInt(eLength))\t\t\t\t\r\n\t\t\t\treturn true;\r\n\t\t\telse \r\n\t\t\t\treturn false;\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}catch(e){\r\n\t\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "0cc4535eeb89b152bccf142d659c869f", "score": "0.5234461", "text": "function floatEq(a, b) {\n return a == round(b);\n }", "title": "" }, { "docid": "65945e71d6c818d2ad178a499cbc336b", "score": "0.52342516", "text": "function finiteNumberString() {\n var finiteNumberDelegate = number_1.finiteNumber();\n return operator_1.pipe(floatingPointFormatString(), function (name, str) {\n return finiteNumberDelegate(\"parseFloat(\" + name + \")\", parseFloat(str)).toString();\n });\n}", "title": "" }, { "docid": "00a84e7e4a4fe84c413160f4d5b95817", "score": "0.5224454", "text": "function isSignedInteger (s)\r\n\r\n{ if (isEmpty(s))\r\n if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;\r\n else return (isSignedInteger.arguments[1] == true);\r\n\r\n else {\r\n var startPos = 0;\r\n var secondArg = defaultEmptyOK;\r\n\r\n if (isSignedInteger.arguments.length > 1)\r\n secondArg = isSignedInteger.arguments[1];\r\n\r\n // skip leading + or -\r\n if ( (s.charAt(0) == \"-\") || (s.charAt(0) == \"+\") ){\r\n if(s.length==1){ // The sign only is invalid\r\n return false;\r\n }\r\n startPos = 1;\r\n }\r\n return (isInteger(s.substring(startPos, s.length), secondArg))\r\n }\r\n}", "title": "" }, { "docid": "056eb2c1b1c731453cd8f63b686c1d66", "score": "0.5215926", "text": "function _isNumeric(pString) {\n\tvar oRegExp = /^[-+]?[0-9]+(?:[.,]?[0-9]+)?$/;\n\treturn (oRegExp.test(pString)); \n}", "title": "" }, { "docid": "b31ea377930c04058a2f9b6f2c396102", "score": "0.5215292", "text": "function isNumber(number) {\n return !isNaN(parseFloat(number)) && isFinite(number);\n}", "title": "" }, { "docid": "ca6f0b7ebecf2402f982ad7420995592", "score": "0.52026993", "text": "function isNumeric(string) {\n\treturn isNumeric1(string, false);\n}", "title": "" }, { "docid": "5510653cc65d72d33b884078d2fe7c56", "score": "0.5202654", "text": "function check_number(nb) {\n return nb.nb$float !== undefined;\n }", "title": "" }, { "docid": "fef06869671cc7c82fb18d080cf7ecf1", "score": "0.52007884", "text": "function isNumeric(num){\n return !isNaN(parseFloat(num)) && isFinite(num);\n}", "title": "" }, { "docid": "287f8af9577bbdc67bf0d8561399abb4", "score": "0.51871514", "text": "function floatEqual (f1, f2) {\n return (Math.abs(f1 - f2) < 0.000001);\n }", "title": "" }, { "docid": "287f8af9577bbdc67bf0d8561399abb4", "score": "0.51871514", "text": "function floatEqual (f1, f2) {\n return (Math.abs(f1 - f2) < 0.000001);\n }", "title": "" }, { "docid": "287f8af9577bbdc67bf0d8561399abb4", "score": "0.51871514", "text": "function floatEqual (f1, f2) {\n return (Math.abs(f1 - f2) < 0.000001);\n }", "title": "" } ]
1e7f9f6db21bc5df7fa5bfa5538f69d6
When the component mounts, perform our network request
[ { "docid": "0c4766580be66fc5f90f9b4b3d893f11", "score": "0.0", "text": "componentDidMount() {\n Client.search(this.props.params.ticketId)\n .then((data) => {\n this.setState({\n data: data\n });\n })\n .catch((error) => {\n alert('An error ocurred while trying to fetch the ticket from Zendesk');\n throw error;\n });\n }", "title": "" } ]
[ { "docid": "fedfb0760b6d5187cea620a5a9d9157e", "score": "0.75777423", "text": "componentDidMount(){\n this.makeRemoteRequest();\n }", "title": "" }, { "docid": "5f101fb54254adbdb131da56f666091f", "score": "0.7313789", "text": "componentDidMount() {\n this.fetchRemoteData()\n }", "title": "" }, { "docid": "4502db5701d30123caf948a8cc478d0a", "score": "0.7266117", "text": "componentDidMount() {\n this.getServerData(this.props.url);\n }", "title": "" }, { "docid": "82d079889f270547f873576b82f9b173", "score": "0.7249485", "text": "componentDidMount() {\n this.getRequest();\n }", "title": "" }, { "docid": "9ff97a85322cd807ae87527544847f23", "score": "0.72209823", "text": "componentDidMount() {\n this._isMounted = true;\n this.fetch_data();\n }", "title": "" }, { "docid": "01af755bc3bd78bad6016d88fef1ddc6", "score": "0.7212651", "text": "componentWillMount(){\n\n //Perform API request, obtaining \"events\"\n this.retrieveData();\n\n }", "title": "" }, { "docid": "c00aaf101bf0973fe5aad45aa7f3ee4b", "score": "0.7181099", "text": "componentWillMount(){\n this.connectionReqHandler();\n }", "title": "" }, { "docid": "f2de0ed1fb27ae3649a9455385071ed0", "score": "0.71584094", "text": "componentDidMount() {\n this.fetchInIt();\n }", "title": "" }, { "docid": "d563854b0c1581a2ae85480d834b8434", "score": "0.71480036", "text": "componentDidMount() {\r\n this.fetchEndpointData();\r\n }", "title": "" }, { "docid": "f6864739ac6f96d70e2bfd2bb2c48f49", "score": "0.7120245", "text": "componentDidMount() {\n\t\tthis.fetchData();\n\t}", "title": "" }, { "docid": "da8c5b9d6783b1950f994c02e325076f", "score": "0.6985621", "text": "componentDidMount() {\n this.fetchSmurfs();\n }", "title": "" }, { "docid": "669e7631d61bec0771f8cac16fcffaf5", "score": "0.69754785", "text": "componentDidMount() {\n this.fetchData()\n }", "title": "" }, { "docid": "17b67293c20962972db09d30f16ef0e8", "score": "0.6957449", "text": "componentDidMount() {\n this.fetchData()\n }", "title": "" }, { "docid": "078aa79e404fca1a7d95941667eec0e7", "score": "0.6952867", "text": "componentDidMount() {\n this.fetchData();\n }", "title": "" }, { "docid": "078aa79e404fca1a7d95941667eec0e7", "score": "0.6952867", "text": "componentDidMount() {\n this.fetchData();\n }", "title": "" }, { "docid": "078aa79e404fca1a7d95941667eec0e7", "score": "0.6952867", "text": "componentDidMount() {\n this.fetchData();\n }", "title": "" }, { "docid": "078aa79e404fca1a7d95941667eec0e7", "score": "0.6952867", "text": "componentDidMount() {\n this.fetchData();\n }", "title": "" }, { "docid": "078aa79e404fca1a7d95941667eec0e7", "score": "0.6952867", "text": "componentDidMount() {\n this.fetchData();\n }", "title": "" }, { "docid": "d7ed49c1f6461bb4761ad3f6158e1714", "score": "0.69477737", "text": "componentDidMount() { // start fetching after the component is rendered in the DOM\n\t\tthis.getJson();\n\t}", "title": "" }, { "docid": "f207a2cd6142c49a36527e7517fb3695", "score": "0.6925036", "text": "componentDidMount() {\n\t\t//Attempt a fetch, wait for the promis and check the reponse\n\t\tfetch('/public')\n\t\t\t.then(response => {\n\t\t\t\t//if response, then do stuff\n\t\t\t\tif (response.ok) return response.json();\n\t\t\t\tthrow new Error('Network response was not ok.');\n\t\t\t})\n\t\t\t.then(response => this.setState({ message: response.message }))\n\t\t\t.catch(error => this.setState({ message: error.message }));\n\t}", "title": "" }, { "docid": "aa5e999717fdb70d8ad74411bb942b93", "score": "0.6924475", "text": "componentDidMount() {\n this.onFetchData();\n }", "title": "" }, { "docid": "d9297d4f1aaddb08c8b2ba30f07ed9d0", "score": "0.6917117", "text": "componentDidMount(){\n this.fetchData()\n }", "title": "" }, { "docid": "f4b9d9a39112b5095d548393bc974567", "score": "0.69107664", "text": "componentWillMount() {\n\t\tthis.componentsDataGetRequest(data => this.props.onDataLoaded(data));\n\t}", "title": "" }, { "docid": "43e669ee5f4df7397e7716e590659f00", "score": "0.68704146", "text": "componentWillMount () {\n this._fetchData()\n }", "title": "" }, { "docid": "566be97ff2d65a87cb373d79c35d4bd3", "score": "0.68690825", "text": "componentDidMount() {\n\t\tthis.setQueryInfo();\n\t\tthis.createChannel();\n\t}", "title": "" }, { "docid": "566be97ff2d65a87cb373d79c35d4bd3", "score": "0.68690825", "text": "componentDidMount() {\n\t\tthis.setQueryInfo();\n\t\tthis.createChannel();\n\t}", "title": "" }, { "docid": "408a9f7a1387da3931a740dd30c72775", "score": "0.68520814", "text": "componentWillMount() { \n //autoutils.debug(\"AutoMain componentWillMount\");\n //this.loadDataFromServer();\n }", "title": "" }, { "docid": "870235ba04f3b6a6c2cd21e26020505d", "score": "0.6849183", "text": "componentDidMount() {\n this.listenSSE();\n\n this.getImages();\n }", "title": "" }, { "docid": "dea2cb2ca375f795d69c1f74e91421ed", "score": "0.6848949", "text": "componentDidMount() {\n // if loaded flag is already true we don't need to query the API again\n if (!this.props.loaded) {\n this.props.handleLoad();\n }\n }", "title": "" }, { "docid": "4e1360159f7e530d3dd4de7f46979a25", "score": "0.6844152", "text": "componentDidMount() {\n this.sendGetRequest(this.pageuri);\n }", "title": "" }, { "docid": "3246340b97899d7b4d8747ba961c0bd5", "score": "0.6835153", "text": "componentWillMount() {\n this.fetchDataFromAPI(); \n }", "title": "" }, { "docid": "a31860bfd084a669a3e424284672a236", "score": "0.68085194", "text": "componentDidMount() {\n\t\tthis.getData();\n\t}", "title": "" }, { "docid": "68b931507865f25f4276560bac1cbefb", "score": "0.67986935", "text": "componentDidMount() {\n setTimeout(() => { this.setState({ renderHeader: true }) }, 0);\n setTimeout(() => { this.setState({ renderList: true }) }, 0);\n\n InteractionManager.runAfterInteractions(() => {\n this.makeRemoteRequest();\n });\n }", "title": "" }, { "docid": "3ba0f29a7fde8cb72b4071c160187d94", "score": "0.6772807", "text": "async componentWillMount(){\n this.getData()\n }", "title": "" }, { "docid": "f9efc5f3fec95c9749121c4e85d78ebd", "score": "0.6759052", "text": "async componentWillMount() {\r\n await this.loadWeb3()\r\n await this.loadBlockchainData()\r\n }", "title": "" }, { "docid": "074584b24e59f4dc9fd7e49b9932f558", "score": "0.6742539", "text": "componentDidMount(){\n\n this.fetchMarket()\n \n }", "title": "" }, { "docid": "2424366e7c20082bbddfe0d8636a38e3", "score": "0.6739278", "text": "componentDidMount() {\n // function to get images from the server\n this.getGalleryFromServer();\n }", "title": "" }, { "docid": "74f700fbca2f46fb8c2ba88d9efbe44b", "score": "0.6735468", "text": "componentDidMount() {\n this.retrieveData()\n }", "title": "" }, { "docid": "4d70754e50f44306794afd9cb61ab013", "score": "0.67328554", "text": "componentWillMount(){\n this.getData();\n }", "title": "" }, { "docid": "2efff2647cf424f1fb8c415d0085bbbd", "score": "0.67291516", "text": "componentDidMount() {\n this._processData();\n }", "title": "" }, { "docid": "df4353169d01bd1343d71cd92848d6ba", "score": "0.6723116", "text": "componentDidMount(){\n\n //run loadData function in component did mount\n this.loadData()\n\n }", "title": "" }, { "docid": "3f9ab8eef8e2723b7399df38eb2ca5f6", "score": "0.6700867", "text": "componentDidMount()\n {\n this.getData();\n }", "title": "" }, { "docid": "e25260d17ea872febf501218371905f0", "score": "0.6695792", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "e25260d17ea872febf501218371905f0", "score": "0.6695792", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "e25260d17ea872febf501218371905f0", "score": "0.6695792", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "119fa48891ff29a0a8b2f968eda2c8ab", "score": "0.66871476", "text": "componentDidMount() {\n this.fetcher(this.state.baseUrl);\n }", "title": "" }, { "docid": "062f9442f02e979f8a1b4d5596e5d551", "score": "0.6683514", "text": "UNSAFE_componentWillMount() {\n this.doFetching(this.props);\n }", "title": "" }, { "docid": "7bb7a1e3b6dd0f5b9d0a019291c9383d", "score": "0.6671827", "text": "componentDidMount(){\n \t// Set loader to true\n \tthis.setState({loader:true})\n \t// Fetch data\n \tthis.fetchData()\t\n }", "title": "" }, { "docid": "03545cf75f3a34acbd5742ab80bbe3a1", "score": "0.6670605", "text": "componentDidMount() {\n\t\tconsole.log(\"[*] Component Review Mounted\");\t\n\t\tconsole.log(\"[>] Calling API\");\n\t\tthis.getWebsiteDataApi();\n\t}", "title": "" }, { "docid": "052572ac87ab0001c2acbea6d3b746a0", "score": "0.66690975", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "052572ac87ab0001c2acbea6d3b746a0", "score": "0.66690975", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "052572ac87ab0001c2acbea6d3b746a0", "score": "0.66690975", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "052572ac87ab0001c2acbea6d3b746a0", "score": "0.66690975", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "052572ac87ab0001c2acbea6d3b746a0", "score": "0.66690975", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "052572ac87ab0001c2acbea6d3b746a0", "score": "0.66690975", "text": "componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "ba8d7bef2ad396fad0c8a0269f0218bf", "score": "0.6667225", "text": "componentDidMount(){\n this.getData();\n }", "title": "" }, { "docid": "fc3deb800ffcf8720ce31cfff913d747", "score": "0.6644944", "text": "componentDidMount() {\n this.getSourceData();\n }", "title": "" }, { "docid": "09e93213eda2ce0dfa39bd9da0a60a43", "score": "0.66406137", "text": "componentDidMount(){\n this.getData();\n \n }", "title": "" }, { "docid": "a953d827fb8fa8f7f374da6f7bf9ce39", "score": "0.6633436", "text": "componentWillMount() {\n\t\tthis.fetchJSON(this.state.url);\n\t}", "title": "" }, { "docid": "2fecff15d4b7feeccbe86bdf2ee30353", "score": "0.6625939", "text": "componentDidMount() {\n this.getloadData();\n }", "title": "" }, { "docid": "3eaa1439f1c3af018f6854a389737e58", "score": "0.6623884", "text": "componentDidMount() {\n // this.props.fetchAccounts();\n // this.props.fetchNetwork();\n // this.initPoll();\n // this.initNetworkPoll();\n }", "title": "" }, { "docid": "2c9d7dc16830cfa45d259a767db16b77", "score": "0.66219467", "text": "componentDidMount() {\n this.getData()\n }", "title": "" }, { "docid": "2c9d7dc16830cfa45d259a767db16b77", "score": "0.66219467", "text": "componentDidMount() {\n this.getData()\n }", "title": "" }, { "docid": "8dbe238d36936a8e866da39766fd3d05", "score": "0.6618027", "text": "componentDidMount() {\n // this.fetchBusiness();\n }", "title": "" }, { "docid": "72cdd713295dbb8c57082c25ac4d66ff", "score": "0.6597551", "text": "componentDidMount() {\n this.fetchServices();\n}", "title": "" }, { "docid": "96d2bb300d478b319027502229b1ea8d", "score": "0.65915346", "text": "componentWillMount() {\n\t\tthis.fetchRequestedItems()\n\t}", "title": "" }, { "docid": "b6fd61da47256cdf4862c54a2c012450", "score": "0.65913314", "text": "async componentDidMount() {\n try {\n const store = await notefulServer.fetchData();\n console.log('Got Data: ', store);\n this.setState({ ...store, loaded: true });\n } catch (e) {\n console.log(e);\n this.setState({ isError: true });\n }\n }", "title": "" }, { "docid": "4cebd1d8fb3bb753aa6f1eeda9fc08b7", "score": "0.6590331", "text": "componentDidMount() {\n this.loadShoppingListsFromServer();\n }", "title": "" }, { "docid": "4c5fc71c056a3fccbb5e858386a1fceb", "score": "0.6586933", "text": "componentDidMount() {\r\n // this.peticionGet();\r\n // this.authListener();\r\n this.loadData();\r\n }", "title": "" }, { "docid": "466ccce8fe6a6e39a09f7d1278493838", "score": "0.6571482", "text": "componentDidMount() {\n this.getData();\n this.updateInfo();\n }", "title": "" }, { "docid": "c4762d9218110226ba17083d569a994a", "score": "0.65700316", "text": "componentDidMount()\n {\n this.fetchUserData();\n }", "title": "" }, { "docid": "20e6e429a836cf9980c128c94a438f0e", "score": "0.6564751", "text": "componentDidMount() {\n this.loadData().done()\n }", "title": "" }, { "docid": "20e6e429a836cf9980c128c94a438f0e", "score": "0.6564751", "text": "componentDidMount() {\n this.loadData().done()\n }", "title": "" }, { "docid": "ab8d1af7d3903094242904a7b04ae15f", "score": "0.65634173", "text": "componentDidMount() {\n const request = new Request('http://127.0.0.1:8080/que');\n fetch(request)\n .then(response => response.json())\n .then(data => this.setState({data: data}));\n }", "title": "" }, { "docid": "204a615d95cfbb8f2f96a804c24b162c", "score": "0.6557294", "text": "async componentDidMount() {\n this.getData();\n }", "title": "" }, { "docid": "e663ed06329b06db72df70c5e1ec5e04", "score": "0.6556818", "text": "componentDidMount() {\n this.loadData(); \n }", "title": "" }, { "docid": "bd7827d2f92b42a3c632b56db4e725f5", "score": "0.6550886", "text": "componentDidMount() {\r\n this.fetchData(null)\r\n }", "title": "" }, { "docid": "e941c11daf29ed6ad8232458b098ff70", "score": "0.65358675", "text": "componentDidMount(){\n this.fetchItems()\n }", "title": "" }, { "docid": "0143d16d832f69607ab403c7b7a678f2", "score": "0.6532721", "text": "componentDidMount() {\n\t\t\n this.getURL();\n\n }", "title": "" }, { "docid": "d6d6cd7f26cfe083bbfcfc36e5e7ec44", "score": "0.6528332", "text": "componentDidMount(){\n this.loadData()\n }", "title": "" }, { "docid": "8dfc4b9f7592339e1d4b86fffb823124", "score": "0.65271556", "text": "componentDidMount() {\r\n\r\n this.fetchDashboard();\r\n\r\n}", "title": "" }, { "docid": "f8c51a25a7fcc563c7e6aaf41f38846f", "score": "0.65254056", "text": "componentDidMount() {\n this.getData()\n }", "title": "" }, { "docid": "0fc305d475bf50b5cd5ef6febfe8094f", "score": "0.652522", "text": "componentDidMount() {\n this.loadData();\n }", "title": "" }, { "docid": "0fc305d475bf50b5cd5ef6febfe8094f", "score": "0.652522", "text": "componentDidMount() {\n this.loadData();\n }", "title": "" }, { "docid": "5e83217f2c3eb4edcbbff89496827c71", "score": "0.6521443", "text": "componentDidMount (){\n this.postMaker();\n this.queryURL();\n }", "title": "" }, { "docid": "03a20a9d4d0cb6e911d411a67da19b5f", "score": "0.652088", "text": "async componentDidMount() {\n try {\n const data = await fetch('/query');\n const json = await data.json();\n this.setState({ items: json,\n loading: false });\n } catch (e) {\n console.log(\"Failed to fetch message\", e);\n }\n }", "title": "" }, { "docid": "4962d3bbde9c8315a7979dda2d1dc659", "score": "0.6516147", "text": "componentDidMount() {\n // this.setState({access: ipcRenderer.sendSync('fetch-access')})\n getSuppliers().then(response => {\n this.setState({\n data: response,\n results: response.results,\n loading: false\n });\n })\n //console.log(ipcRenderer.sendSync('fetch-access'));\n //get access key\n // ipcRenderer.send('fetch-refresh');\n // ipcRenderer.on('supplierUpdate', (event, arg) => this.handler(arg));\n // ipcRenderer.send('fetch-access', 'supplierUpdate');\n // console.log(\"Supplier Component mounted!\");\n }", "title": "" }, { "docid": "2ec429e6eb3f010cd1f4f3984f0238a5", "score": "0.6505052", "text": "componentWillMount() {\n this.loadBlockchainData();\n }", "title": "" }, { "docid": "018ff7c5ffe141ede4f868c1d0703ae3", "score": "0.650445", "text": "componentDidMount() {\n this.loadData();\n }", "title": "" }, { "docid": "167c50059a2a310a6f911cab6109f4fb", "score": "0.6503488", "text": "beforeMount() {\n this.callData();\n }", "title": "" }, { "docid": "99fbf691b7e0b0424c27392ec39174b9", "score": "0.64996135", "text": "componentDidMount() {\n this.getDataAPI();\n }", "title": "" }, { "docid": "51e81dd805e9e7d4d140b72f047bd14a", "score": "0.64992875", "text": "async componentWillMount() {\n await this.loadData();\n }", "title": "" }, { "docid": "41a11fdbc6854698d2414be646e71691", "score": "0.6491069", "text": "async componentDidMount() {\n // check if there is connection\n await NetInfo.isConnected.addEventListener('change', this.handleConnectionChange);\n await NetInfo.isConnected.fetch().done((isConnected) => {\n \tthis.props.dispatch(setNetInfo(isConnected));\n });\n // verify signature in the server\n await this.props.dispatch(signinWithToken());\n // initialize socket.io\n await this.globalSocketInit();\n \t// add the correspondig functions to the pushService class -> in this way we can retrieve the result of the class process\n await PushService.setCallbacks(this.handleOnPushRegister, this.handleOnPushNotification);\n }", "title": "" }, { "docid": "fad26e2c40a4f013e9500b23eeb1dd04", "score": "0.6490923", "text": "componentDidMount() {\n this.getWidgetsFromBackend()\n this.getDocTypes()\n this.getAttributeTypes()\n this.getAttributeValues()\n this.getLogs()\n }", "title": "" }, { "docid": "8f0a859eb8946d6fbca8255304f49d52", "score": "0.6488445", "text": "async componentWillMount() {\n await this.loadWeb3();\n await this.loadBlockchainData();\n await this.showAdmin();\n }", "title": "" }, { "docid": "e59071146d6722eb63d73cf9c5d2f1fa", "score": "0.64845294", "text": "componentDidMount() {\n this.handleUpdateClick(); //agregamos la llamada al evento (al servidor) \n }", "title": "" }, { "docid": "c134edcff63a77bdc3bbf8de9c4bdbc0", "score": "0.64834833", "text": "componentDidMount() {\n // this.checkAuth to call command at the correct time\n this.checkAuth();\n this.loadFriends();\n this.loadSent();\n this.loadRecieved();\n }", "title": "" }, { "docid": "0774b709ce310c564bd1d4d556ab5ee4", "score": "0.6482301", "text": "componentDidMount(){\n this._onComLoad();\n}", "title": "" }, { "docid": "b000114f107b47d293a2fc5c3f1d3552", "score": "0.64814556", "text": "componentDidMount() {\n let now_playing = this.nowPlayingUrl()\n this.startFetch(now_playing)\n console.log('MOUNTED', now_playing)\n }", "title": "" }, { "docid": "1f7c129d4a1d3f138791c805f07717cf", "score": "0.6480582", "text": "componentWillMount() {\n this.getContacts();\n this.makeRemoteRequest();\n // this.getMember();\n }", "title": "" }, { "docid": "0332690f3b42ef817bdbf4fc8d5116e3", "score": "0.6477629", "text": "componentDidMount() {\n // Good place to do Ajax Calls (I think this is like getting info from APIs?).\n // And then you can use this.setState() here.\n console.log(\"App- Mounted\");\n }", "title": "" } ]
8f067741c81897e0a5b0f300c7fdf089
Return true if data was signed by a sender. Precondition: this method should be called after "finish decryption".
[ { "docid": "0c239230794a9c442c031ca05f6c19cd", "score": "0.7621699", "text": "isDataSigned() {\n precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);\n\n let proxyResult;\n proxyResult = Module._vscf_recipient_cipher_is_data_signed(this.ctxPtr);\n\n const booleanResult = !!proxyResult;\n return booleanResult;\n }", "title": "" } ]
[ { "docid": "badca2bcddbf6f160841880439260f03", "score": "0.75917625", "text": "verifySignature() {\n try {\n // Main signature verification is done in `getSenderPublicKey()`\n const publicKey = this.getSenderPublicKey();\n return ethereumjs_util_1.unpadBuffer(publicKey).length !== 0;\n }\n catch (e) {\n return false;\n }\n }", "title": "" }, { "docid": "51c6ba9b8d0c443252b8644a27878ee2", "score": "0.6709541", "text": "hasValidSignature() {\n if (this.sig === undefined) {\n return false;\n } else if (!utils.addressMatchesKey(this.from, this.pubKey)) {\n return false;\n } else {\n return utils.verifySignature(this.pubKey, this.id, this.sig);\n }\n }", "title": "" }, { "docid": "13c25d766de3bdd47695b70b48135ffc", "score": "0.60806936", "text": "isDelegateMessage() {\n let res = super.isDelegateMessage();\n //in real app: check balance or another info by public key of data, in our example:\n if (this.getKey() == '0x2')\n return true;\n return res;\n }", "title": "" }, { "docid": "44f48ed7be220d5c350d7cd662ee98c9", "score": "0.6008018", "text": "isSender(message) {\n if (message.sender === firebase__WEBPACK_IMPORTED_MODULE_14__[\"default\"].auth().currentUser.uid) {\n return true;\n }\n else {\n return false;\n }\n }", "title": "" }, { "docid": "d2fe0106981e547435e47fb61d1bce9a", "score": "0.592732", "text": "async verify (signature, data) {\n return util.verify(signature, data, this._signPubId)\n }", "title": "" }, { "docid": "8f029a94024952c448ecd9dfaed0c827", "score": "0.58317405", "text": "function is_encrypted(data)\n {\n return data.hasOwnProperty(\"version\"); // Only encrypted exports are tagged with version.\n }", "title": "" }, { "docid": "792b9fd3e89800b347e54de23bc2742e", "score": "0.57837224", "text": "function verifySig (data, key, signature) {\n const verifier = crypto.createVerify('RSA-SHA256');\n verifier.write(data);\n verifier.end();\n\n try {\n return verifier.verify(key, signature, 'base64');\n } catch (e) {\n console.log(\"Verification of signature failed:\", e);\n return false;\n }\n}", "title": "" }, { "docid": "298342a0fe9e853f44be0f339c6f7b4e", "score": "0.5769198", "text": "isEncoded() {\n if (this._y && this._y.length > 0) {\n return false;\n } else if (this._compressed && this._compressed.length > 0) {\n return true;\n } else {\n return false;\n }\n }", "title": "" }, { "docid": "a92f26892258f83fbe9f0517bb0c6bf7", "score": "0.57598907", "text": "function isValidSignature(data, signature, signerAddress) {\n assert_1.assert.isHexString('data', data);\n assert_1.assert.doesConformToSchema('signature', signature, json_schemas_1.schemas.ecSignatureSchema);\n assert_1.assert.isETHAddressHex('signerAddress', signerAddress);\n var normalizedSignerAddress = signerAddress.toLowerCase();\n var dataBuff = ethUtil.toBuffer(data);\n var msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);\n try {\n var pubKey = ethUtil.ecrecover(msgHashBuff, signature.v, ethUtil.toBuffer(signature.r), ethUtil.toBuffer(signature.s));\n var retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));\n return retrievedAddress === signerAddress;\n }\n catch (err) {\n return false;\n }\n}", "title": "" }, { "docid": "67e74434ff33bd9536f4ae166cd5d94a", "score": "0.56651294", "text": "function checkSig (address, signature, message, network) {\n return(bitcoinjs.Message.verify(address, signature, message, network));\n }", "title": "" }, { "docid": "782b347f8f309b459de1f1de221d4c01", "score": "0.5663408", "text": "function check_signature(msg, sig, addr_of_signatory) {\n const addr = web3.eth.accounts.recover(msg, sig);\n return addr == addr_of_signatory;\n}", "title": "" }, { "docid": "a55a1a7b4e5a9992d12e79a49d3c3433", "score": "0.56392765", "text": "verifySignerInfo(signerInfo, publicKey) {\n precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);\n precondition.ensureClass('signerInfo', signerInfo, modules.SignerInfo);\n precondition.ensureImplementInterface('publicKey', publicKey, 'Foundation.PublicKey', modules.FoundationInterfaceTag.PUBLIC_KEY, modules.FoundationInterface);\n\n let proxyResult;\n proxyResult = Module._vscf_recipient_cipher_verify_signer_info(this.ctxPtr, signerInfo.ctxPtr, publicKey.ctxPtr);\n\n const booleanResult = !!proxyResult;\n return booleanResult;\n }", "title": "" }, { "docid": "037cf436b020c8ede7a0698861aa890d", "score": "0.56161547", "text": "tranfser_complete() {\n return this.packets_received() === this.total_packets;\n }", "title": "" }, { "docid": "81c4526a8bb2525365aebaba33c66f53", "score": "0.5608093", "text": "isSelfSigned() {\n return this.subject.equals(this.issuer);\n }", "title": "" }, { "docid": "be05b21e2aa35c52a37979a93dbddd7e", "score": "0.5576781", "text": "get isValidSigned() {\n return this.isValid & this.isSigned & this.sigVerified & this.hashVerified;\n }", "title": "" }, { "docid": "24f7715824203659b637a57e843ee28f", "score": "0.55254376", "text": "function signed(event) {\n const signature = event.headers[\"x-webhook-signature\"];\n if (!signature) {\n console.log(\"Missing x-webhook-signature\");\n return false;\n }\n\n const { iss, sha256 } = jwt.verify(signature, process.env.JWS_SECRET);\n const hash = crypto\n .createHash(\"sha256\")\n .update(event.body)\n .digest(\"hex\");\n\n return iss === \"netlify\" && sha256 === hash;\n}", "title": "" }, { "docid": "d485ca0a1b08368b65e1dba6cc8cd971", "score": "0.5488286", "text": "function verify({from, to, amount, timestamp, signature}, pub) {\n let keyPairTemp = ec.keyFromPublic(pub, 'hex');\n let bufferMsg = Buffer.from(`${timestamp} - ${amount} - ${from} - ${to}`);\n return keyPairTemp.verify(bufferMsg, signature);\n}", "title": "" }, { "docid": "e8fc5463ca54ed2f8cb81aa8c0f54b91", "score": "0.5482951", "text": "function Verify_SignedData( signedData, option, directoryServer )\n{\n\tvar\tverified_msg;\n\tvar\terrCode;\n\t\n\tif( IsNetscape() )\n\t{\n\t\talert(\"Not supported function\");\n\t\treturn \"\";\n\t}\n\telse\n\t{\n\t\tverified_msg = document.XecureWeb.VerifySignedData( signedData, option, directoryServer );\n\t}\n\n\t// VerifySignedData는 인증서 검증시 오류가 발생하더라도 원문 추출이 성공하면 원문을 리턴하기 때문에\n\t// 반드시 LastErrCode를 확인해야 한다.\n\terrCode = document.XecureWeb.LastErrCode();\n\tif( errCode != 0 )\n\t\tXecureWebError();\n\t\n\treturn verified_msg;\t\n}", "title": "" }, { "docid": "6d5dce87ef57db5ec3b1efae0b27de02", "score": "0.5455239", "text": "verify () {\n if (this.signature.length > 0)\n this.valid = Return(() => Crypt.sign.verify(str(this.#exportPost()), this.owner.split('').reverse().join(''), this.signature), false)\n }", "title": "" }, { "docid": "7c342d109ce1df5aa7e1ec6042ad4dee", "score": "0.54329735", "text": "_validateSignedTxData(signedTxData) {\n return signedTxData\n }", "title": "" }, { "docid": "13bbfb1e86cad7805c41da42d2c8624d", "score": "0.5319609", "text": "function isPublicConversation() {\n let peerKey = $('#peer_public_key').val().replace(/\\s/g, \"\");\n return peerKey.startsWith(\"_\");\n }", "title": "" }, { "docid": "a3cc046cbc964e8710772616d61bf34a", "score": "0.5287509", "text": "async signMessage(data) {\n const { wallet } = this.props\n if (data.from !== wallet.activeAccount.address.toLowerCase()) {\n console.error('Account mismatch')\n return null\n }\n const signedMessage = await this.web3.eth.accounts.sign(\n data.data,\n wallet.activeAccount.privateKey\n )\n DeviceEventEmitter.emit('messageSigned', {\n data,\n signedMessage\n })\n }", "title": "" }, { "docid": "a3cc046cbc964e8710772616d61bf34a", "score": "0.5287509", "text": "async signMessage(data) {\n const { wallet } = this.props\n if (data.from !== wallet.activeAccount.address.toLowerCase()) {\n console.error('Account mismatch')\n return null\n }\n const signedMessage = await this.web3.eth.accounts.sign(\n data.data,\n wallet.activeAccount.privateKey\n )\n DeviceEventEmitter.emit('messageSigned', {\n data,\n signedMessage\n })\n }", "title": "" }, { "docid": "056317165d920f3d7982df9885f5522b", "score": "0.5278079", "text": "function checkSignature(str) {\n var i;\n for (i = 0; i < str.length; i += 1) {\n if (dv.getUint8(dv_offset + i) !== str.charCodeAt(i)) {\n return false;\n }\n }\n skip(str.length);\n return true;\n }", "title": "" }, { "docid": "75d6c0e2e9c7f064eb7315d67ecbca06", "score": "0.5262475", "text": "isSignTransactionSupported() { return true }", "title": "" }, { "docid": "6cc00c4a69770dabb70acb9cd054fc03", "score": "0.52556145", "text": "canDoRsaEncryption() {\n\t\treturn this.accountencryption.canDoRsaEncryption();\n\t}", "title": "" }, { "docid": "5abc971c0a1622f8e7a42a60990d1e82", "score": "0.52473104", "text": "function verify (address, signature, message, network) {\n\t if (!Buffer.isBuffer(signature)) {\n\t signature = new Buffer(signature, 'base64')\n\t }\n\n\t network = network || networks.bitcoin\n\n\t var hash = magicHash(message, network)\n\t var parsed = ECSignature.parseCompact(signature)\n\t var e = BigInteger.fromBuffer(hash)\n\t var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)\n\n\t var pubKey = new ECPubKey(Q, parsed.compressed)\n\t return pubKey.getAddress(network).toString() === address.toString()\n\t}", "title": "" }, { "docid": "e3dfe3ce28683d6f609717a53f7f817c", "score": "0.5231686", "text": "verify(message, signature) {\n // Verify signature\n return this.key.verify(codifyMessage(message), signature)\n }", "title": "" }, { "docid": "b03855cf4d49094aec76c87b6d0b9d78", "score": "0.52087116", "text": "function isSigned() {\n let r = true;\n if (localStorage.getItem(\"user\") == null) {\n return false;\n }\n user = JSON.parse(localStorage.getItem(\"user\")); // if user present then parse JSON\n return r;\n}", "title": "" }, { "docid": "0aa8de15ef323b8b0b2a6e772245bf79", "score": "0.5201674", "text": "verifyPayload(message, addressOrPublicKey, signature) {\n const messageBytes = ethers_1.ethers.utils.toUtf8Bytes(message);\n const messageDigest = ethers_1.ethers.utils.keccak256(messageBytes);\n let res = false;\n try {\n const address = (addressOrPublicKey.length > 42) ? ethers_1.ethers.utils.computeAddress(addressOrPublicKey) : addressOrPublicKey;\n res = ethers_1.ethers.utils.recoverAddress(messageDigest, signature) === address;\n }\n catch (_a) {\n // Leave result false when error\n }\n return res;\n }", "title": "" }, { "docid": "31c5c2b35e2257bf9a8cc75e548a36f6", "score": "0.51927084", "text": "function verifyKey(body, signature, timestamp, clientPublicKey) {\n try {\n const timestampData = valueToUint8Array(timestamp);\n const bodyData = valueToUint8Array(body);\n const message = concatUint8Arrays(timestampData, bodyData);\n const signatureData = valueToUint8Array(signature, 'hex');\n const publicKeyData = valueToUint8Array(clientPublicKey, 'hex');\n return tweetnacl_1.default.sign.detached.verify(message, signatureData, publicKeyData);\n }\n catch (ex) {\n console.error('[discord-interactions]: Invalid verifyKey parameters', ex);\n return false;\n }\n}", "title": "" }, { "docid": "517fbd0c2bdb010faff296a6e6da6acc", "score": "0.5174173", "text": "function verifySignature(signature, data, publicKey, digestAlgorithm, callback) {\n\n crypto.subtle.importKey(\n \"spki\",\n new Uint8Array(cutil.hexToArray(publicKey)),\n {\n name: \"RSASSA-PKCS1-v1_5\",\n hash: {name: getNameForOID(digestAlgorithm)}\n },\n false,\n [\"verify\"]\n )\n .then(function(publicKey){\n\n crypto.subtle.verify(\n {\n name: \"RSASSA-PKCS1-v1_5\"\n },\n publicKey,\n new Uint8Array(cutil.hexToArray(signature)),\n new Uint8Array(cutil.hexToArray(data))\n )\n .then(function(isvalid){\n callback(isvalid);\n })\n .catch(function(err){\n error.show(err);\n throw(err);\n });\n\n })\n .catch(function(err){\n error.show(err);\n throw(err);\n });\n}", "title": "" }, { "docid": "34fe9ca651e78cf9f0f518d370dc8b30", "score": "0.5169816", "text": "verify (sig, pubKey, nIn, subScript) {\n let hashBuf = this.sighash(sig.nHashType, nIn, subScript)\n return Ecdsa.verify(hashBuf, sig, pubKey, 'little')\n }", "title": "" }, { "docid": "df0b663e9ae6e6f5dc932262ca8178c8", "score": "0.5164753", "text": "function isTokenSentToServer() {\n if (window.localStorage.getItem('sentToServer') == 1) {\n return true;\n }\n return false;\n }", "title": "" }, { "docid": "9305539aa11f6950c2e8121f2837a266", "score": "0.5163311", "text": "isPeerCanSendData(peer) {\n //one of validator list\n //this peer have cursor\n if (app.dataManager.getHeight() == -1)\n return true;//genesis\n return this.isDelegateMode() ? this.getConfig('delegates').indexOf(peer.getId()) != -1 : app.roundManager.isActiveValidator(peer.getId());\n }", "title": "" }, { "docid": "6843bb3c20d787302cdb23182ccf61a5", "score": "0.51632434", "text": "isDataMatch(data, peer) {\n //check data for consensus\n if (app.dataManager.getHeight() == -1 && data.getId() == app.config.genesis.id)\n return true;\n if (this.isDelegateMode()) {\n return this.getConfig('delegates').indexOf(data.getKey()) != -1\n } else {\n return app.roundManager.isActiveValidator(data.getKey());\n }\n }", "title": "" }, { "docid": "3975d89f71457ddb6df45296e63e8c51", "score": "0.5147425", "text": "paymentAccepted () {\n return this.paymentAuthorization ? true : false\n }", "title": "" }, { "docid": "f3ed04a974f8f4b425bd4b42baed2d6f", "score": "0.5146134", "text": "returnData(data) {\n EnigmailLog.DEBUG(\n \"mimeDecrypt.jsm: returnData: \" + data.length + \" bytes\\n\"\n );\n\n let proto = null;\n let ct = this.extractContentType(data);\n if (ct && ct.search(/multipart\\/signed/i) >= 0) {\n proto = EnigmailMime.getProtocol(ct);\n }\n\n if (\n proto &&\n proto.search(/application\\/(pgp|pkcs7|x-pkcs7)-signature/i) >= 0\n ) {\n try {\n EnigmailLog.DEBUG(\n \"mimeDecrypt.jsm: returnData: using direct verification\\n\"\n );\n this.mimeSvc.contentType = ct;\n if (\"mimePart\" in this.mimeSvc) {\n this.mimeSvc.mimePart = this.mimeSvc.mimePart + \".1\";\n }\n let veri = EnigmailVerify.newVerifier(proto);\n veri.onStartRequest(this.mimeSvc, this.uri);\n veri.onTextData(data);\n veri.onStopRequest(null, 0);\n } catch (ex) {\n console.debug(ex);\n EnigmailLog.ERROR(\n \"mimeDecrypt.jsm: returnData(): mimeSvc.onDataAvailable failed:\\n\" +\n ex.toString()\n );\n }\n } else {\n try {\n this.mimeSvc.outputDecryptedData(data, data.length);\n } catch (ex) {\n console.debug(ex);\n EnigmailLog.ERROR(\n \"mimeDecrypt.jsm: returnData(): cannot send decrypted data to MIME processing:\\n\" +\n ex.toString()\n );\n }\n }\n }", "title": "" }, { "docid": "f0e5db4d1b4e581e31ddf380690ef4bf", "score": "0.51451415", "text": "isValid (callback) {\n // TODO Needs better checking\n if (this.privKey &&\n this.privKey.public &&\n this.privKey.public.bytes &&\n Buffer.isBuffer(this.pubKey.bytes) &&\n this.privKey.public.bytes.equals(this.pubKey.bytes)) {\n callback()\n } else {\n callback(new Error('Keys not match'))\n }\n }", "title": "" }, { "docid": "f0e5db4d1b4e581e31ddf380690ef4bf", "score": "0.51451415", "text": "isValid (callback) {\n // TODO Needs better checking\n if (this.privKey &&\n this.privKey.public &&\n this.privKey.public.bytes &&\n Buffer.isBuffer(this.pubKey.bytes) &&\n this.privKey.public.bytes.equals(this.pubKey.bytes)) {\n callback()\n } else {\n callback(new Error('Keys not match'))\n }\n }", "title": "" }, { "docid": "7081c5653bc1cc3551062cbc40217b49", "score": "0.51366615", "text": "get isValidSignedTimestamped() {\n return this.isValid & this.isSigned & this.sigVerified &\n this.hashVerified & this.hasTS & this.tsVerified;\n }", "title": "" }, { "docid": "45ce23a800728e35d027e19637528035", "score": "0.5117025", "text": "function verify(address, signature, message, network) {\n if (!Buffer.isBuffer(signature)) {\n signature = new Buffer(signature, 'base64')\n }\n\n network = network || networks.bitcoin\n\n var hash = magicHash(message, network)\n var parsed = ECSignature.parseCompact(signature)\n var e = BigInteger.fromBuffer(hash)\n var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)\n\n var pubKey = new ECPubKey(Q, parsed.compressed)\n return pubKey.getAddress(network).toString() === address.toString()\n}", "title": "" }, { "docid": "aa72b4e032691b4dddb14917aceb1992", "score": "0.5112331", "text": "async function parseAndVerifyPayload(data) {\n let payload\n const li = data.lastIndexOf('}')\n const msg = data.substring(0, li + 1)\n const sig = data.substring(li + 1)\n try {\n payload = JSON.parse(msg)\n if (payload && payload.sender && payload.sender.pub_key) {\n let v\n if (sig.length === 96 && payload.sender.pub_key) {\n v = await signer.verifyAscii(msg, sig, payload.sender.pub_key)\n }\n if (v && v.valid) {\n return payload\n }\n }\n } catch (e) {\n console.log(e)\n return null\n }\n}", "title": "" }, { "docid": "3a83c58b7c1f987df218531720b8d088", "score": "0.5111067", "text": "function verify (address, signature, message, network) {\n if (!Buffer.isBuffer(signature)) {\n signature = new Buffer(signature, 'base64')\n }\n\n network = network || networks.bitcoin\n\n var hash = magicHash(message, network)\n var parsed = ECSignature.parseCompact(signature)\n var e = BigInteger.fromBuffer(hash)\n var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)\n\n var pubKey = new ECPubKey(Q, parsed.compressed)\n return pubKey.getAddress(network).toString() === address.toString()\n}", "title": "" }, { "docid": "632db90eebf6085457321e32c2209951", "score": "0.5105997", "text": "isValida(){\n //Verifica se Eh null pois na Classe BlockChain, a recompensa tem o enderecoDe Null pq eh algo gerado do sistema.\n if(this.enderecoDe === null) return true;\n\n //Checa se existe uma assinatura\n if(!this.assinatura || this.assinatura.length === 0){\n throw new Error('Transacao sem Assinatura');\n }\n // o EnderecoDe eh uma chave publica logo precisamos verificar se eh correta\n const chavePublica = ec.keyFromPublic(this.enderecoDe, 'hex');\n //Retorna se eh verdadeiro ou falso pelo verificador verify se o hash foi assinado pela assinatura\n return chavePublica.verify(this.calcularHash(), this.assinatura);\n }", "title": "" }, { "docid": "e4286d53f30e68da5b28979dc1448c73", "score": "0.50981015", "text": "getMessageToVerifySignature() {\n return this.getMessageToSign();\n }", "title": "" }, { "docid": "e4286d53f30e68da5b28979dc1448c73", "score": "0.50981015", "text": "getMessageToVerifySignature() {\n return this.getMessageToSign();\n }", "title": "" }, { "docid": "875fcb0de5443fce1866bd6ceef017e2", "score": "0.5070124", "text": "async validate_message(msg)\n\t{\n\t\tlet peer = this.peers[msg.key];\n\t\tlet status = {\n\t\t\tvalid: false,\n\t\t\tpeer: null,\n\t\t\tseq: false,\n\t\t\tsig: false,\n\t\t};\n\n\t\t// if we do not have a corresponding key for this peer,\n\t\t// then we can't check the sequence number of signature, so\n\t\t// we are done here.\n\t\tif (!peer)\n\t\t{\n\t\t\tconsole.log(\"UNKNOWN PEER:\", msg);\n\t\t\treturn status;\n\t\t}\n\n\t\t// the key claims to be from a known peer\n\t\t// we can't trust the server to fill in a peer,\n\t\t// so we use the hash of the public key.\n\t\tstatus.peer = peer;\n\n\t\tlet signed_msg = JSON.stringify({\n\t\t\tmsg: msg.msg,\n\t\t\tseq: msg.seq,\n\t\t\tkey: msg.key,\n\t\t});\n\t\t//console.log(\"signed=\", signed_msg);\n\n\t\t// check sequence number first, since otherwise there is a\n\t\t// possibility that the verifications will complete out of order.\n\t\t// trust on first use for sequence number,\n\t\t// otherwise require an exact match for the expected value\n\t\t// TODO: update seq after verification, since otherwise\n\t\t// an attacker could send a spoofed message with a bad sequence number\n\t\t// and ruin the rest of the messages\n\t\tif (peer.seq < 0 || msg.seq == peer.seq + 1)\n\t\t{\n\t\t\tstatus.seq = true;\n\t\t\tpeer.seq = msg.seq; // bad bad bad\n\t\t} else {\n\t\t\tconsole.log(\"SEQ MISMATCH\", peer.name, \"expected=\" + (peer.seq + 1), \"seq=\" + msg.seq, msg);\n\t\t\tstatus.seq = false;\n\t\t}\n\n\t\treturn window.crypto.subtle.verify(\n\t\t\tthis.key_param,\n\t\t\tpeer.key,\n\t\t\thex2array(msg.sig),\n\t\t\tgetEncoding(signed_msg)\n\t\t).then((valid) => {\n\t\t\t// store the \n\t\t\tstatus.sig = valid;\n\n\t\t\tif (valid && status.seq)\n\t\t\t{\n\t\t\t\t// seq, sig, and key all match\n\t\t\t\tstatus.valid = true;\n\t\t\t\t//peer.seq = msg.seq; // expected seq was already updated\n\t\t\t} else {\n\t\t\t\t// something didn't match\n\t\t\t\tpeer.cheats++;\n\t\t\t}\n\n\t\t\treturn status;\n\t\t});\n\t}", "title": "" }, { "docid": "7e48df4936109a3ac04168fd873ba406", "score": "0.5068999", "text": "hasKeyRecipient(recipientId) {\n precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);\n precondition.ensureByteArray('recipientId', recipientId);\n\n // Copy bytes from JS memory to the WASM memory.\n const recipientIdSize = recipientId.length * recipientId.BYTES_PER_ELEMENT;\n const recipientIdPtr = Module._malloc(recipientIdSize);\n Module.HEAP8.set(recipientId, recipientIdPtr);\n\n // Create C structure vsc_data_t.\n const recipientIdCtxSize = Module._vsc_data_ctx_size();\n const recipientIdCtxPtr = Module._malloc(recipientIdCtxSize);\n\n // Point created vsc_data_t object to the copied bytes.\n Module._vsc_data(recipientIdCtxPtr, recipientIdPtr, recipientIdSize);\n\n let proxyResult;\n\n try {\n proxyResult = Module._vscf_recipient_cipher_has_key_recipient(this.ctxPtr, recipientIdCtxPtr);\n\n const booleanResult = !!proxyResult;\n return booleanResult;\n } finally {\n Module._free(recipientIdPtr);\n Module._free(recipientIdCtxPtr);\n }\n }", "title": "" }, { "docid": "2082242db9bc2522fb25d3b8a74b24fb", "score": "0.50178576", "text": "function isTradeValid() {\n\t\tconst userItemValue = getItemsPrice(itemsToExchange);\n\t\tconst ownerItemValue = getItemsPrice(itemsToReceive);\n\n\t\tconst priceDifference = userItemValue - ownerItemValue;\n\n\t\treturn priceDifference >= 0 ? true : false;\n\t}", "title": "" }, { "docid": "a6e440bc6e568f758ca6bc8fa5fdf1d5", "score": "0.49923104", "text": "verify(data, signature, hashAlgorithm) {\n const verifier = PublicKey._verifiers[this.oid];\n if (verifier != null) {\n const sum = crypto_1.createHash(hashAlgorithm).update(data).digest();\n return verifier.call(this, sum, signature);\n }\n const verify = crypto_1.createVerify(hashAlgorithm);\n verify.update(data);\n return verify.verify(this.toPEM(), signature);\n }", "title": "" }, { "docid": "4414cfa5a9bbe45a9beed5302858f6fe", "score": "0.4989758", "text": "function isMultisigInput (script, allowIncomplete) {\n\t if (script.chunks.length < 2) return false\n\t if (script.chunks[0] !== ops.OP_0) return false\n\n\t if (allowIncomplete) {\n\t return script.chunks.slice(1).every(function (chunk) {\n\t return chunk === ops.OP_0 || isCanonicalSignature(chunk)\n\t })\n\t }\n\n\t return script.chunks.slice(1).every(isCanonicalSignature)\n\t}", "title": "" }, { "docid": "c97f65bfeb3fd73b0b4665f0c174d063", "score": "0.49816322", "text": "function isSignedAndValid(doc) {\n return Promise.try(() => {\n const signatures = _.get(doc, 'signatures');\n if (signatures == null || !_.isArray(signatures) || signatures.length == 0) {\n throw new Error('Not signed.');\n }\n if (_.get(config, 'debug.verifySignatures') === false) {\n return true;\n }\n //console.log(JSON.stringify(doc, null, 2));\n //Remove _id, _rev, and _meta from the doc when signing/verifying\n return verify(_.omit(doc, ['_id', '_rev', '_meta']));\n })\n}", "title": "" }, { "docid": "284b5537f886c2d08401abaccb3f8b4c", "score": "0.49469855", "text": "function isReceiver( func ) { return func.hasOwnProperty( \"receive\" ); }", "title": "" }, { "docid": "7ef15e4bcb190f8f8807b81d6bc075b7", "score": "0.49300653", "text": "function isMultisigInput (script, allowIncomplete) {\n if (script.chunks.length < 2) return false\n if (script.chunks[0] !== ops.OP_0) return false\n\n if (allowIncomplete) {\n return script.chunks.slice(1).every(function (chunk) {\n return chunk === ops.OP_0 || isCanonicalSignature(chunk)\n })\n }\n\n return script.chunks.slice(1).every(isCanonicalSignature)\n}", "title": "" }, { "docid": "fbe15def49cacb6e1274f6cada5bb33c", "score": "0.49296835", "text": "function passesSecretKeyVerification(secretKey) {\n if (!signature && !secretKey) {\n return true;\n }\n if (!secretKey) {\n return false;\n }\n\n var hmacDigest = crypto.createHmac(\"sha1\", secretKey).update(JSON.stringify(body)).digest(\"hex\");\n\n return hmacDigest === signature;\n }", "title": "" }, { "docid": "a44e3bbbac9abbfced339adce66a7c21", "score": "0.4907234", "text": "validPublicKey()\n {\n //is the string the correct length?\n if(this.publicKey.length >= 8 && this.publicKey.length =< 25)\n {\n return true;\n }\n else\n {\n return false;\n }\n }", "title": "" }, { "docid": "53b577c93446c3ae804764bad354214a", "score": "0.48860264", "text": "isUnsigned(entry) {\n if (Lang.isNull(entry)) return false;\n\n if (entry.entryInfo.sourceClinicalNote) {\n let clinicalNote = this.getEntryFromReference(entry.entryInfo.sourceClinicalNote);\n if (!clinicalNote) return true;\n return !clinicalNote.signed;\n }\n return false;\n }", "title": "" }, { "docid": "6c49104595f13127adf750b14b4a567e", "score": "0.48840812", "text": "get isConnected() {\n return !!(this._receiver.isConnected && this._sender.isConnected);\n }", "title": "" }, { "docid": "b19cd835c4fd346b43a1f7613b73f015", "score": "0.4861911", "text": "function checkCallerKeys(metadata, call, current, stream1){\n var sql = `SELECT COUNT(*) from user_keys WHERE phone_no = `+metadata.caller+`\n AND id_key = \"`+metadata.callerIdKey+`\" AND contact_key = \"`+metadata.callerContactKey+`\";`;\n\n connection.query(sql, function (err, result) {\n if (err) throw err;\n\n if (result[0]['COUNT(*)'] != 1){\n //FALSE KEYS\n console.error(\"FALSE KEYS\");\n let outgoing;\n conns.forEach(peerConn => {\n if (peerConn.id == call.peer){\n outgoing = peerConn.conn;\n }\n });\n if (outgoing != null){\n outgoing.send('false_key');\n }\n }\n else {\n console.log(\"Caller's provided keys: VERIFIED\");\n if (metadata.callerContactKey == metadata.targetContactKey){\n console.log('Caller honestly not have target contact key, will route to voicemail.')\n checkIfFirstContact(metadata, call, current, stream1, false)\n }\n else{\n checkTargetKey(metadata, call, current, stream1);\n }\n }\n });\n}", "title": "" }, { "docid": "8a17deb6b5176747776c5e4d635c3f0b", "score": "0.48610863", "text": "isContract() {\n\t\tvar code = this.code;\n\t\t\n\t\tif (code)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}", "title": "" }, { "docid": "887f5dc2205b3fef88215e90aeb149a8", "score": "0.48530734", "text": "function checkIfVendorBurn(event){\n // if using transfer with data:\n // (utils.hexToString(event.data) == BURN_MESSAGE && VENDOR_ACCOUNTS.includes(event.from) && event.to == BURN_ACCOUNT)\n return (event.to == BURN_ACCOUNT && (event.from in vendors))\n}", "title": "" }, { "docid": "b074774f5118fe68ae9fadaccfd3e7f4", "score": "0.4849445", "text": "verifyPublic(message, signature, publicKey) {\n // Import public key\n const key = ecContext.keyFromPublic(publicKey, 'hex')\n\n // Verify signature\n // 7~10ms on my machine\n return key.verify(codifyMessage(message), signature)\n }", "title": "" }, { "docid": "712c0b3c6e9e69972976c847e65acd48", "score": "0.4847473", "text": "getSenderPublicKey() {\n var _a;\n if (!this.isSigned()) {\n throw new Error('Cannot call this method if transaction is not signed');\n }\n const msgHash = this.getMessageToVerifySignature();\n // EIP-2: All transaction signatures whose s-value is greater than secp256k1n/2 are considered invalid.\n // Reasoning: https://ethereum.stackexchange.com/a/55728\n if (this.common.gteHardfork('homestead') && ((_a = this.s) === null || _a === void 0 ? void 0 : _a.gt(types_1.N_DIV_2))) {\n throw new Error('Invalid Signature: s-values greater than secp256k1n/2 are considered invalid');\n }\n const { yParity, r, s } = this;\n try {\n return ethereumjs_util_1.ecrecover(msgHash, yParity.addn(27), // Recover the 27 which was stripped from ecsign\n ethereumjs_util_1.bnToRlp(r), ethereumjs_util_1.bnToRlp(s));\n }\n catch (e) {\n throw new Error('Invalid Signature');\n }\n }", "title": "" }, { "docid": "f953ed654234a68e3ec51f469d7f7adc", "score": "0.48468158", "text": "isReceiving() {\n return this._activeSiblings.size > 0;\n }", "title": "" }, { "docid": "69b5eb2be6766c155c898c033c3b7dca", "score": "0.48418283", "text": "async function verifySAMLSignature(saml, key_data) {\n const root = saml.$root;\n const rootSignature = root.Signature;\n\n if (!rootSignature) {\n throw Error(`SAML message is unsigned`);\n }\n\n const assertion = root.Assertion;\n const assertionSignature = assertion ? assertion.Signature : null;\n\n if (assertionSignature) {\n if (!await digestSAML(assertionSignature)) {\n return false;\n }\n\n if (!await signatureSAML(assertionSignature, key_data)) {\n return false;\n }\n }\n\n if (rootSignature) {\n if (!await digestSAML(rootSignature)) {\n return false;\n }\n\n if (!await signatureSAML(rootSignature, key_data)) {\n return false;\n }\n }\n\n return true;\n}", "title": "" }, { "docid": "c5762bd69a7a89ee6ee81b1ab97bf9e0", "score": "0.4837656", "text": "getSenderPublicKey() {\n return this.senderPublicKey;\n }", "title": "" }, { "docid": "3d75f8156862de65ed1ca9a6b1f4143b", "score": "0.4837359", "text": "isContract() {\n return !this.codeHash.equals(constants_1.KECCAK256_NULL);\n }", "title": "" }, { "docid": "3d75f8156862de65ed1ca9a6b1f4143b", "score": "0.4837359", "text": "isContract() {\n return !this.codeHash.equals(constants_1.KECCAK256_NULL);\n }", "title": "" }, { "docid": "d3dc2cacda0e1233d637b44d74249d1a", "score": "0.4825119", "text": "function checkCert(data){\n\n getIsSenderInTheWhiteList(data).then(function(){\n const contract = createContract();\n contract.getCertByHash(data.certHash, {from: data.sender}, function(err, certInfo) {\n if(certInfo[4].c[0] != certInfo[5].c[0] && certInfo[6]) {\n console.log(\"checking\")\n setCheckExpiration(data);\n }\n showAndInsert(data,certInfo);\n\n });\n }).catch(function(err){\n processCheckCertErrorResponse(err);\n });\n}", "title": "" }, { "docid": "d7126d52b2e9f8fb3340378ecd3144d2", "score": "0.48243368", "text": "send (data) {\n if (this.state != 1) return -1; //Don't do that if the peer is not connected yet\n data.signature = keySign(signatureStringifyer(data)); //Calculate signature\n this.socket.send(JSON.stringify(data)); //Send message\n }", "title": "" }, { "docid": "fd98c6ea972a8aca103e19f507b7e720", "score": "0.48154962", "text": "validateHeader() {\n let sum = this._pktBytes[0] + this._pktBytes[1] + this._pktBytes[2] + this._pktBytes[3];\n sum &= 0xFF;\n sum = ThreeWireHeader.twosComplement(sum);\n return sum === 0;\n }", "title": "" }, { "docid": "daaad77e52ce767d20bf1c2130d41348", "score": "0.47980034", "text": "getDataToSign()\n\t{\n\t\treturn this.data.input;\n\t}", "title": "" }, { "docid": "eef1717e97e3914e93e4ac2182737c03", "score": "0.47929022", "text": "function verifySignature(signature, callback_url, post_body) {\n payload = callback_url + \"|\" + post_body\n\n var publicKey = fs.readFileSync('../spectre_public.pem');\n var verifier = crypto.createVerify('sha256');\n verifier.update(payload);\n\n return verifier.verify(publicKey, signature,'base64');\n}", "title": "" }, { "docid": "9d389642be3b1daf1fef299590233306", "score": "0.47895238", "text": "function isBusSender( subject ) { return subject === \"bus.sender\"; }", "title": "" }, { "docid": "4b9d0ad9037e058de587f0a2f44f19de", "score": "0.47886857", "text": "getSenderPublicKey() {\n var _a;\n if (!this.isSigned()) {\n throw new Error('Cannot call this method if transaction is not signed');\n }\n const msgHash = this.getMessageToVerifySignature();\n // EIP-2: All transaction signatures whose s-value is greater than secp256k1n/2 are considered invalid.\n // Reasoning: https://ethereum.stackexchange.com/a/55728\n if (this.common.gteHardfork('homestead') && ((_a = this.s) === null || _a === void 0 ? void 0 : _a.gt(types_1.N_DIV_2))) {\n throw new Error('Invalid Signature: s-values greater than secp256k1n/2 are considered invalid');\n }\n const { v, r, s } = this;\n try {\n return ethereumjs_util_1.ecrecover(msgHash, v.addn(27), // Recover the 27 which was stripped from ecsign\n ethereumjs_util_1.bnToRlp(r), ethereumjs_util_1.bnToRlp(s));\n }\n catch (e) {\n throw new Error('Invalid Signature');\n }\n }", "title": "" }, { "docid": "3ee25138204c6dbab5880e9170c311c5", "score": "0.47885284", "text": "isKeyValid(donationAsBytes){\n if (!donationAsBytes || donationAsBytes.length === 0) {\n return false;\n }\n\n return true;\n }", "title": "" }, { "docid": "db411d58f03442574b180a2a81dda75e", "score": "0.47869256", "text": "function checkTransaction(ua, request) {\n var tr;\n\n switch(request.method) {\n case JsSIP_C.INVITE:\n tr = ua.transactions.ist[request.via_branch];\n if(tr) {\n switch(tr.state) {\n case C.STATUS_PROCEEDING:\n tr.transport.send(tr.last_response);\n break;\n\n // RFC 6026 7.1 Invite retransmission\n //received while in C.STATUS_ACCEPTED state. Absorb it.\n case C.STATUS_ACCEPTED:\n break;\n }\n return true;\n }\n break;\n case JsSIP_C.ACK:\n tr = ua.transactions.ist[request.via_branch];\n\n // RFC 6026 7.1\n if(tr) {\n if(tr.state === C.STATUS_ACCEPTED) {\n return false;\n } else if(tr.state === C.STATUS_COMPLETED) {\n tr.state = C.STATUS_CONFIRMED;\n tr.I = setTimeout(function() {tr.timer_I();}, Timers.TIMER_I);\n return true;\n }\n }\n // ACK to 2XX Response.\n else {\n return false;\n }\n break;\n case JsSIP_C.CANCEL:\n tr = ua.transactions.ist[request.via_branch];\n if(tr) {\n request.reply_sl(200);\n if(tr.state === C.STATUS_PROCEEDING) {\n return false;\n } else {\n return true;\n }\n } else {\n request.reply_sl(481);\n return true;\n }\n break;\n default:\n\n // Non-INVITE Server Transaction RFC 3261 17.2.2\n tr = ua.transactions.nist[request.via_branch];\n if(tr) {\n switch(tr.state) {\n case C.STATUS_TRYING:\n break;\n case C.STATUS_PROCEEDING:\n case C.STATUS_COMPLETED:\n tr.transport.send(tr.last_response);\n break;\n }\n return true;\n }\n break;\n }\n}", "title": "" }, { "docid": "d3e48c74beac9c180656c5fefe92d873", "score": "0.47846913", "text": "function verifyKeyPair(keyPair, { script }) {\n return !!(\n script.chunks.length === 2 &&\n script.chunks[0].buf &&\n Buffer.compare(script.chunks[0].buf, keyPair.pubKey.toBuffer()) === 0\n )\n}", "title": "" }, { "docid": "6999e8e4f629970d96b67c3acbcd6827", "score": "0.47623688", "text": "validPublicKey(){\n if(this.publickey.length >= 8 && this.publickey.length <=25 ){\n return true;\n }\n else{\n return false;\n }\n }", "title": "" }, { "docid": "4ba7186110c05d83e2341cbcc42e44eb", "score": "0.4762119", "text": "_verifySignature (verifyObj) {\n try {\n // Expand the input object.\n const { slpAddress, signature, entry } = verifyObj\n\n // Convert to BCH address.\n const scrubbedAddr = this.bchjs.SLP.Address.toCashAddress(slpAddress)\n\n const isValid = this.bchjs.BitcoinCash.verifyMessage(\n scrubbedAddr,\n signature,\n entry\n )\n\n return isValid\n } catch (err) {\n console.error('Error in bch.js/_verifySignature()')\n throw err\n }\n }", "title": "" }, { "docid": "4acc30c901a7037545ea1c1a74169a82", "score": "0.47595382", "text": "function checkTargetKey(metadata, call, current, stream1){\n var sql = `SELECT COUNT(*) from user_keys WHERE phone_no = `+metadata.target+`\n AND contact_key = \"`+metadata.targetContactKey+`\";`;\n\n connection.query(sql, function (err, result) {\n if (err) throw err;\n\n if (result[0]['COUNT(*)'] != 1){\n //FALSE KEYS\n console.error(\"FALSE KEYS\");\n let outgoing;\n conns.forEach(peerConn => {\n if (peerConn.id == call.peer){\n outgoing = peerConn.conn;\n }\n });\n if (outgoing != null){\n outgoing.send('false_key');\n }\n }\n else {\n console.log(\"Caller's provided target contact key: VERIFIED\");\n checkIfFirstContact(metadata, call, current, stream1, true);\n }\n });\n}", "title": "" }, { "docid": "d2724e28bca61fb78538286f70ca4245", "score": "0.47513792", "text": "function sendSigned(txData, cb) {\n console.log(\"sending transaction\");\n console.log(txData);\n web3.eth.sendTransaction(txData, cb)\n}", "title": "" }, { "docid": "fd9b62b7f1bc5dc6600bbd0ec0d682be", "score": "0.47386268", "text": "isSignedIn() {\n return !!this._authData.accountId;\n }", "title": "" }, { "docid": "6fed97f81e995e7e82c93ae4ab86365a", "score": "0.4735855", "text": "async function _verify (pubKey, sig, msg) {\n if (typeof sig === 'object') {\n throw new Error('signature should be base64 string. ' +\n 'Did you mean verifyObj(public, signed_obj)?')\n }\n\n // default_ecc_curve = 'p-256'\n return verify(msg, sig, pubKey)\n }", "title": "" }, { "docid": "f3b4295c4da9473a4da7ff840aa434b1", "score": "0.47317302", "text": "async function verify(sig, message, key) {\n if (typeof message === 'string') {\n message = new Uint8Array(Buffer.from(message))\n }\n return await bls.verify(bls.PointG2.fromSignature(bigIntToBuffer(sig)), message, bls.PointG1.fromCompressedHex(bigIntToBuffer(key)))\n}", "title": "" }, { "docid": "1feb052d3dc898101a5b0214d8b83057", "score": "0.47250125", "text": "sign(data) {\n // data must be hashed before passing to the sign() method.\n return this.keyPair.sign(cryptoHash(data));\n }", "title": "" }, { "docid": "1797f5fec7e49e70b735b08131805d81", "score": "0.47205067", "text": "function verify(bufMac, bufM) {\n return bufMac.equals(authenticate(bufM));\n}", "title": "" }, { "docid": "340c445d065c262c9ce17d7e864bbccc", "score": "0.47120616", "text": "function verify(req, res, buf) {\n\t\tif (!req.headers['x-hub-signature']) return;\n\t\tvar signature = req.headers['x-hub-signature'], \n\t\t\thmac = crypto.createHmac('sha1', secret);\n\t\tif (hmac.update(chunk).digest('hex') !== hmac.digest('hex'))\n\t\t\tthrow new Error();\n\t}", "title": "" }, { "docid": "660f939b7c5facd3de4f084ce2562c34", "score": "0.47038805", "text": "startSignedEncryption(dataSize) {\n precondition.ensureNotNull('this.ctxPtr', this.ctxPtr);\n precondition.ensureNumber('dataSize', dataSize);\n const proxyResult = Module._vscf_recipient_cipher_start_signed_encryption(this.ctxPtr, dataSize);\n modules.FoundationError.handleStatusCode(proxyResult);\n }", "title": "" }, { "docid": "90e0d8843685ab38528b93c4ff7537f4", "score": "0.4700273", "text": "function sign_activation(event) {\n\n try {\n var sneaking = event.getPlayer().isSneaking();\n var action = event.getAction().toString();\n var clicked = event.getClickedBlock().getType().toString();\n\n if (sneaking && action === 'RIGHT_CLICK_BLOCK') {\n\n if (clicked === 'WALL_SIGN') {\n //if (hasItems(event, 'REDSTONE', 1))\n //echo(event.getPlayer(), 'NODE ACTIVATED!');\n //MQTTNode.prototype.create(event.getClickedBlock().state, true);\n }\n else if (clicked === 'SIGN') {\n\n var sign = event.getClickedBlock().state;\n\n //TODO: Chceck, if the sign is not activated yet\n var avalible = true;\n\n if (avalible) {\n\n var signCords = [sign.getX(), sign.getY(), sign.getZ()];\n var blockCords = [sign.getX(), sign.getY() - 1, sign.getZ()];\n var world = sign.getWorld();\n var topic = getTopic(sign, event.getPlayer());\n var payload = getPayload(sign);\n\n if (sign.getLine(0) === 'SEM' || sign.getLine(0) === 'RECV') {\n MQTTNode.prototype.createReceiver(blockCords, signCords, world, topic);\n echo(event.getPlayer(), 'Receiver ACTIVATED!');\n }\n else if (sign.getLine(0) === 'TAM' || sign.getLine(0) === 'TRAN') {\n MQTTNode.prototype.createSender(blockCords, signCords, world, topic, payload);\n echo(event.getPlayer(), 'Transmitter ACTIVATED!');\n }\n else {\n echo(event.getPlayer(), 'Need Help? Yout need to type SEM/RECV | TAM/TRAN ;)'); // Write SEM/RECV | TAM/TRAN\n }\n\n }\n else {\n echo(event.getPlayer(), 'Receiver is already active.');\n }\n\n }\n }\n }\n catch (err) {\n console.log('Invalid activation - ' + err);\n }\n}", "title": "" }, { "docid": "8e28d688778db86e6244338193c01c44", "score": "0.46804655", "text": "verifyData(algorithm, data, signature, options = {}) {\n return tracingClient.withSpan(\"CryptographyClient.verifyData\", options, async (updatedOptions) => {\n this.ensureValid(await this.fetchKey(updatedOptions), KnownKeyOperations.Verify);\n const provider = await this.getProvider(\"verifyData\", algorithm, updatedOptions);\n try {\n return provider.verifyData(algorithm, data, signature, updatedOptions);\n }\n catch (err) {\n if (this.remoteProvider) {\n return this.remoteProvider.verifyData(algorithm, data, signature, updatedOptions);\n }\n throw err;\n }\n });\n }", "title": "" }, { "docid": "575dc48735c02f649dd8e8e5eaee8302", "score": "0.46666348", "text": "function DoVerify(){\n\t\tvar message_hash = $('#hash_file_verify').val();\n\t\tvar signverified = $('#signatured_string').val();\n\t\tvar pubkey_verify = $('#pubkey_verify').val();\n\n\t\tvar rsa_verify = KEYUTIL.getKey(pubkey_verify);\t\t\n\t\tvar isValid = rsa_verify.verifyWithMessageHash(message_hash,signverified);\n\n\t\tif(isValid)\n\t\t{\n\t\t\t$('#message_value_verify').text(\"Kết quả: Xác thực thành công ==> Tài liệu đúng\");\n\t\t\t$('#message_value_verify').addClass(\"message_value_verify_right\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$('#message_value_verify').text(\"Kết quả: Xác thực không thành công ==> Tài liệu đã bị giả mạo\");\n\t\t\t$('#message_value_verify').addClass(\"message_value_verify_wrong\");\n\t\t}\n\t}", "title": "" }, { "docid": "501ce637e016a67401020e33c489c9d4", "score": "0.46617916", "text": "getMessageToVerifySignature() {\n const withEIP155 = this._signedTxImplementsEIP155();\n const message = this._getMessageToSign(withEIP155);\n return ethereumjs_util_1.rlphash(message);\n }", "title": "" }, { "docid": "4af8eb01ce21779b039692c066176fbd", "score": "0.4660377", "text": "function isSameTagCheck(type,mac,recv){\n\tvar time = moment(recv).format('mm');\n\n\t//Get number of tag\n\tvar tmp = mData.substring(4,6);\n\tvar mTag = parseInt(tmp,16)*100;//流水號:百位\n mTag = mTag + parseInt(time,10);//分鐘:10位及個位\n\tvar key = mac.concat(type);\n\tvar tag = type_tag_map[key];\n\n\tif(tag === undefined){\n\t\ttag = 0;\n\t}\n\n\t/* Fix 時間進位問題\n\t\texample : time 由59分進到00分時絕對值差為59\n\t*/\n\tif (Math.abs(tag - mTag)<2 || Math.abs(tag - mTag)==59){\n\t\tconsole.log('mTag=' +mTag+'(key:' +key + '):tag='+tag+' #### drop');\n\t\treturn true;\n\t}else{\n\t\ttype_tag_map[key] = mTag;\n\t\tconsole.log('**** mTag=' +mTag+'(key:' +key + '):tag='+tag +'=>'+mTag+' @@@@ save' );\n\t\treturn false;\n\t}\n}", "title": "" }, { "docid": "f0078e94b966597269cd99f5c73b3cbd", "score": "0.46279216", "text": "function do_unSignCrypt(r, s, SenderPublicKey, RecieverPrivateKey, cipher)\n{\n\t\n\t var c = getSECCurveByName(\"secp160r1\");\n\t var PublicKey = decodepublickeyhex(SenderPublicKey);\n\t var Privatekey = new BigInteger(RecieverPrivateKey,16);\n\t var G = c.getG();\n\t var n = c.getN();\n\t\n\t sx = new BigInteger();\n\t rx = new BigInteger();\n\t Gs = new BigInteger();\n\t rPA = new BigInteger();\n\t QPoint = new BigInteger();\n\t Qx = new BigInteger();\n\n\t rx= r.multiply(Privatekey);\n\t sx= s.multiply(Privatekey);\n\t Gs = G.multiply(sx);\n\t rPA = PublicKey.multiply(rx);\n\t QPoint = Gs.add(rPA);\n\t \n\t \n var Qx= QPoint.getX().toBigInteger().toString();\n var Hash = CryptoJS.SHA256(Qx.toString());\n var QxHash=new Array();\n QxHash =Hash.toString(CryptoJS.enc.Latin1);\n\t \n var QxLen = QxHash.length / 2;\n var mu = [QxLen];\n\t var v = [QxLen];\n\t \n\t for (var i = 0; i < QxLen; i++) {\n\t\t\t mu[i] = QxHash[i];\n\t\t\t v[i] = QxHash[mu.length + i];\n\t\t}\n\n\t var muHMAC = BigInteger.ZERO;\n\t var key = new BigInteger(mu);\n \t var plain = CryptoJS.AES.decrypt(cipher, v.toString(), { key: key }); \n \t var plaintext= plain.toString(CryptoJS.enc.Latin1);\n \t\n\t var rhash=CryptoJS.HmacSHA256(plaintext, key.toString());\t\n\t var rhs= new BigInteger(rhash.toString(), 10);\n\t muHMAC = rhs.mod(n);\n\t \n\t var sucess = false;\n\t sucess=(muHMAC.equals(r));\n\t return sucess;\n\t\n\t}", "title": "" }, { "docid": "7a63a53ba1ead52846fbf2e0f2a8e02c", "score": "0.46157578", "text": "handleHandshake(ev) {\n var res = this._crypto.input(ev.data)\n\n if (res && 'string' === typeof(res))\n this._sockjs.send(res)\n else if(res)\n console.log('handleHandshake got non-ciphertext payload back from crypto')\n }", "title": "" }, { "docid": "11c44916ba2b469c7db6c976dfaa42be", "score": "0.46114746", "text": "function verify(req, res, next) {\n const headers = req.headers\n const wistiaSignature = headers['x-wistia-signature']\n // console.log(\"Wistia Signature: \", wistiaSignature)\n\n const requestBody = req.body\n const computedHash = getHash(requestBody)\n // console.log(\"The computed hash is: \", computedHash)\n\n if (wistiaSignature === computedHash) {\n console.log(\"Signature Looks Good!\")\n next();\n } else {\n res.sendStatus(200);\n console.log('Valid Signature Not Present!');\n }\n}", "title": "" }, { "docid": "488cee2819ca91fea154a141234a1fd1", "score": "0.46104574", "text": "function checkSecurity(){\t\t\t\n// Check the security tokens\nif (messageIn.type!=INIT && (messageIn.tokenParent!=securityTokenParent || messageIn.tokenChild!=securityTokenChild)){\n\tlog( \"Security token error: Invalid security token received. The message will be discarded.\" );\n\thandleSecurityError(smash.SecurityErrors.INVALID_TOKEN);\n\treturn false;\n}\t\t\n// Attacks should never pass the security check. Code below is to debug the implementation.\n//if(oah_ifr_debug){\n//\tif (messageIn.type!=INIT && messageIn.type!=ACK && messageIn.type!=PART && messageIn.type!=END){\n//\t\tif(oah_ifr_debug)debug(\"Syntax error: Message Type. The message will be discarded.\");\n//\t\treturn false;\n//\t}\n//\tif (!(messageIn.msn>=0 && messageIn.msn<=99)){\n//\t\tif(oah_ifr_debug)debug(\"Syntax error: Message Sequence Number. The message will be discarded.\");\n//\t\treturn false;\n//\t}\n//\tif (!(messageIn.ack==0 || messageIn.ack==1)){\n//\t\tif(oah_ifr_debug)debug(\"Syntax error: ACK. The message will be discarded.\");\n//\t\treturn false;\n//\t}\n//\tif (!(messageIn.ackMsn>=0 && messageIn.ackMsn<=99)){\n//\t\tif(oah_ifr_debug)debug(\"Syntax error: ACK Message Sequence Number. The message will be discarded.\");\n//\t\treturn false;\n//\t}\n//}\nreturn true;\n}", "title": "" }, { "docid": "df65f6522e61273bc6a85b58f7c1c9b0", "score": "0.4608854", "text": "getSenderPublicKey() {\n var _a;\n const msgHash = this.getMessageToVerifySignature();\n // EIP-2: All transaction signatures whose s-value is greater than secp256k1n/2 are considered invalid.\n // Reasoning: https://ethereum.stackexchange.com/a/55728\n if (this.common.gteHardfork('homestead') && ((_a = this.s) === null || _a === void 0 ? void 0 : _a.gt(types_1.N_DIV_2))) {\n throw new Error('Invalid Signature: s-values greater than secp256k1n/2 are considered invalid');\n }\n const { v, r, s } = this;\n try {\n return ethereumjs_util_1.ecrecover(msgHash, v, ethereumjs_util_1.bnToRlp(r), ethereumjs_util_1.bnToRlp(s), this._signedTxImplementsEIP155() ? this.common.chainIdBN() : undefined);\n }\n catch (e) {\n throw new Error('Invalid Signature');\n }\n }", "title": "" } ]
fc7f737d931ea81d5eb9e5a3dd0d49d3
forces numeric input to fit interval even when it's typed
[ { "docid": "3d9b33230fa3b48f857dee650ce771b1", "score": "0.55309623", "text": "function fitMinMaxInputInterval(){\n if(base<min_base_level){\n base = min_base_level;\n document.getElementById(\"base\").value = min_base_level;\n }else if(base>max_base_level){\n base = max_base_level;\n document.getElementById(\"base\").value = max_base_level;\n }\n if(job<1){\n job = 1;\n document.getElementById(\"job\").value = 1;\n }else if(job>max_stat_points){\n job = max_job_level;\n document.getElementById(\"job\").value = max_job_level;\n }\n\n if(str<1){\n str = 1;\n document.getElementById(\"str\").value = 1;\n }else if(str>max_stat_points){\n str = max_stat_points;\n document.getElementById(\"str\").value = max_stat_points;\n }\n if(agi<1){\n agi = 1;\n document.getElementById(\"agi\").value = 1;\n }else if(str>max_stat_points){\n agi = max_stat_points;\n document.getElementById(\"agi\").value = max_stat_points;\n }\n if(vit<1){\n vit = 1;\n document.getElementById(\"vit\").value = 1;\n }else if(vit>max_stat_points){\n vit = max_stat_points;\n document.getElementById(\"vit\").value = max_stat_points;\n }\n if(int<1){\n int = 1;\n document.getElementById(\"int\").value = 1;\n }else if(int>max_stat_points){\n int = max_stat_points;\n document.getElementById(\"int\").value = max_stat_points;\n }\n if(dex<1){\n dex = 1;\n document.getElementById(\"dex\").value = 1;\n }else if(dex>max_stat_points){\n dex = max_stat_points;\n document.getElementById(\"dex\").value = max_stat_points;\n }\n if(luk<1){\n luk = 1;\n document.getElementById(\"luk\").value = 1;\n }else if(luk>max_stat_points){\n luk = max_stat_points;\n document.getElementById(\"luk\").value = max_stat_points;\n }\n}", "title": "" } ]
[ { "docid": "a4efa3cd89a55cef7cbcc75c24cb9f09", "score": "0.6350595", "text": "function verifyNumber(input, min, max, sigFigs)\n{\n var n = parseFloat(input.value);\n if (isNaN(n) || n < min || n > max) {\n alert(\"Please enter a value between \" + min.toFixed(sigFigs) + \" and \" + max.toFixed(sigFigs));\n input.select();\n input.focus();\n } else\n input.value = n.toFixed(sigFigs);\n divePlan();\n return;\n}", "title": "" }, { "docid": "9c92ab7b53626319c624f4ad875054a4", "score": "0.632086", "text": "function forceNumeric(input) {\n\tinput.keypress(function(e) {\n\t\treturn /\\d|\\./.test(String.fromCharCode(e.keyCode));\n\t});\n}", "title": "" }, { "docid": "3583eb89c06d5414119ae5fc24371482", "score": "0.6193015", "text": "function restrictNumber(e) {\n var newValue = this.value.replace();\n this.value = newValue;\n}", "title": "" }, { "docid": "dc7986cacaeae0055f41892e5ccdbd92", "score": "0.61731243", "text": "function isInputInValidRange(id, event){\n var value = document.getElementById(id).value;\n if(value == \"\"){\n return;\n }\n if(value < -9_999_99 || value > 9_999_999){\n console.log(\"INPUT WAS TO SMALL OR TOO BIG\"); // todo - REMOVE\n event.preventDefault();\n var length = value.length;\n document.getElementById(id).value = value.slice(0, length - 1);\n }\n}", "title": "" }, { "docid": "480604e2011b696e16c5406523f38beb", "score": "0.6122998", "text": "function validarNumerico(event){\n if(event.which < 48 || event.which > 57)\n {\n event.preventDefault();\n } \n }", "title": "" }, { "docid": "fc6f54b3c515b24afb776bb1756a0156", "score": "0.61215097", "text": "function restrictInputToBounds(inputElement, min, max) {\n var value = inputElement.val();\n\n if (isNaN(value)) {\n value = min;\n } \n\n value = Math.max(min, value);\n value = Math.min(max, value);\n\n inputElement.val(value);\n}", "title": "" }, { "docid": "e4eaa87c3468ed4a0820025796dac1f5", "score": "0.6104643", "text": "function oceanwp_autocorrect_range_input_number( input_number, timeout ) {\n\n\t\t\tvar range_input \t= input_number,\n\t\t\t\trange \t\t\t= range_input.parent().find( 'input[type=\"range\"]' ),\n\t\t\t\tvalue \t\t\t= parseFloat( range_input.val() ),\n\t\t\t\treset \t\t\t= parseFloat( range.attr( 'data-reset_value' ) ),\n\t\t\t\tstep \t\t\t= parseFloat( range_input.attr( 'step' ) ),\n\t\t\t\tmin \t\t\t= parseFloat( range_input.attr( 'min') ),\n\t\t\t\tmax \t\t\t= parseFloat( range_input.attr( 'max') );\n\n\t\t\tclearTimeout( oceanwp_range_input_number_timeout );\n\n\t\t\toceanwp_range_input_number_timeout = setTimeout( function() {\n\n\t\t\t\tif ( isNaN( value ) ) {\n\t\t\t\t\trange_input.val( reset );\n\t\t\t\t\trange.val( reset ).trigger( 'change' );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( step >= 1 && value % 1 !== 0 ) {\n\t\t\t\t\tvalue = Math.round( value );\n\t\t\t\t\trange_input.val( value );\n\t\t\t\t\trange.val( value );\n\t\t\t\t}\n\n\t\t\t\tif ( value > max ) {\n\t\t\t\t\trange_input.val( max );\n\t\t\t\t\trange.val( max ).trigger( 'change' );\n\t\t\t\t}\n\n\t\t\t\tif ( value < min ) {\n\t\t\t\t\trange_input.val( min );\n\t\t\t\t\trange.val( min ).trigger( 'change' );\n\t\t\t\t}\n\n\t\t\t}, timeout );\n\n\t\t\trange.val( value ).trigger( 'change' );\n\n\t\t}", "title": "" }, { "docid": "cbf9d20577cccc4243303f879920fff2", "score": "0.5955263", "text": "function NumericalOnly( evt, field ) {\r\n\r\n\tif( evt.ctrlKey || evt.altKey )\r\n\t\treturn true;\r\n\r\n\tvar charCode = ( evt.which || evt.which == 0 ) ? evt.which : evt.keyCode;\r\n\tswitch( charCode ) {\r\n\t\t//Enter\r\n\t\tcase 13:\r\n\t\t\tApplyTimeSpanFormat( field );\r\n\t\t//Backspace\r\n\t\tcase 8:\r\n\t\t// Keys that don't produce a character\r\n\t\tcase 0:\r\n\t\t\treturn true;\r\n\t\tdefault:\r\n\t\t\t// Max of maxValueLength digits, numbers only.\r\n\t\t\t// If some of the field is selected, let them replace the contents even if it's full\r\n\t\t\treturn ( $( field ).getSelection().text != \"\" || field.value.length < maxValueLength ) && ( 48 <= charCode && charCode <= 57 );\r\n\t}\r\n}", "title": "" }, { "docid": "d27baa26c0093d31255acde5e4da7bd7", "score": "0.58892053", "text": "function allowOnlyNumeric(input) {\n input.on('keypress', function(event) {\n return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13) ? null : event.charCode >= 48 && event.charCode <= 57;\n });\n}", "title": "" }, { "docid": "f68537c76a876e392df7fa6a854f9a61", "score": "0.58856225", "text": "function forceNumeric(){\n\t//allows numeric values and decimal points(01234567890.)\n\tif ( ((event.keyCode > 47) && (event.keyCode < 58)) || (event.keyCode == 46)) \n\t event.returnValue = true;\n\telse\n\t event.returnValue = false;\n}", "title": "" }, { "docid": "692eff4a77967d3bb827a7e128ca49fe", "score": "0.5884111", "text": "function allowOnlyNumericInput() {\n let input = this.value;\n let checkString = \"$%.,1234567890\";\n\n if(input) {\n for(i=0; i<input.length; i++) {\n if(!checkString.includes(input.charAt(i))) {\n input = input.replace(input.charAt(i),'');\n this.value = input;\n }\n\n updateInput();\n }\n }\n}", "title": "" }, { "docid": "4fa2372d72805e81aa40a06ae943bb7a", "score": "0.58830905", "text": "function checkRangeValidity(key) {\n var value = parseFloat($scope.prefValues[key]);\n var defaultValue = valueParams[key].default;\n console.log([\"checking range\", key, value, defaultValue]);\n if (isNaN(value)) {\n value = defaultValue;\n } else if (value < valueParams[key].min) {\n value = defaultValue;\n } else if (value > valueParams[key].max) {\n value = defaultValue;\n }\n console.log([\"checked range\", key, value, defaultValue]);\n // Else, the value is in the range, fine!\n $scope.prefValues[key] = value;\n }", "title": "" }, { "docid": "1024c38d98650a52ba6f34590c412932", "score": "0.58615124", "text": "function getInputNumValue(isFloat, element, event, min, max) {\n\t\telement = jqElt(element);\n\t\tvar value = utils.getInputTextValue(element, event);\n\t\tif(value === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tvalue = isFloat ? parseFloat(value) : parseInt(value, 10);\n\t\tif(isNaN(value) || (min !== undefined && value < min) || (max !== undefined && value > max)) {\n\t\t\tinputError(element, event);\n\t\t\treturn undefined;\n\t\t}\n\t\treturn value;\n\t}", "title": "" }, { "docid": "f77a32b724f87888d0b80e6d199a4a0c", "score": "0.5828646", "text": "function enforceMinMax(element) {\n if (element.value != \"\") {\n if (parseInt(element.value) < parseInt(element.min)) {\n element.value = element.min;\n }\n if (parseInt(element.value) > parseInt(element.max)) {\n element.value = element.max;\n element.click();\n }\n }\n}", "title": "" }, { "docid": "7d92c5177190acf6eb7848f82a277911", "score": "0.57825166", "text": "function allowOnlyFloatNumber(evt)\n {\n // Get the ASCII value of the key that the user entered\n \n var charCode = (evt.which) ? evt.which : evt.keyCode\n\n //if ((charCode >= 48 && charCode <= 57 ) || (charCode == 8)|| (charCode == 45) || (charCode == 46) || (charCode == 0)|| (charCode == 9))\n\n if ((charCode >= 48 && charCode <= 57) || (charCode == 8) || (charCode == 46) || (charCode == 0) || (charCode == 9))\n // If it was, then allow the entry to continue\n return true;\n else\n // If it was not, then dispose the key and continue with entry\n return false; \n }", "title": "" }, { "docid": "4ca73e8ba153f4f822cfa3a6dcfaa47a", "score": "0.57716984", "text": "function validInt(event) {\r\n $(this).val($(this).val().replace(/[^\\d].+/, \"\"));\r\n if ((event.which < 48 || event.which > 57)) {\r\n event.preventDefault();\r\n }\r\n}", "title": "" }, { "docid": "22b30b4d2e9a1b8285e759e675de7cb9", "score": "0.57639444", "text": "function updateInput(input){\n if (isNaN(input.value)){\n input.value=\"\";\n console_area.value+=\"Please introduce a number\\n\";\n }\n else{\n setValue(input);\n }\n}", "title": "" }, { "docid": "3bcdeb036fc906d91dfebadd539f2262", "score": "0.57497233", "text": "function promptRangeValue(input, msg) {\n //The input element of the label\n var val = parseFloat(input.value, 10);\n var min = input.min;\n var max = input.max;\n\n var answer = prompt(msg, val);\n if (answer !== null) {\n val = parseFloat(answer, 10);\n\n //Set the value if it is valid\n if (isFinite(val) && val <= max && min <= val) {\n return val;\n } else {\n alert('Invalid value');\n }\n }\n }", "title": "" }, { "docid": "da5d13bf7652a80c23a64b467ac1b2a0", "score": "0.5742196", "text": "function numericField_Blur(inputBox, settings) {\nvar fieldValueNumeric = parseFloat($(inputBox).val());\nvar $inputBox = $(inputBox);\nif(isNaN(fieldValueNumeric)) {\n$inputBox.val(\"\");\nreturn;\n}\nif(isNumeric(settings.min) && fieldValueNumeric < settings.min)\n$inputBox.val(\"\");\nif(isNumeric(settings.max) && fieldValueNumeric > settings.max)\n$inputBox.val(\"\");\n}", "title": "" }, { "docid": "5beb56263862a937d654c127cc684bf3", "score": "0.57253283", "text": "function ai_is_numeric(input){\n return !isNaN(input);\n }", "title": "" }, { "docid": "c1f98675e2a114c20e8f628a79745bac", "score": "0.57015777", "text": "function annualValidation(inputText) {\n console.log('1: ' + inputText);\n console.log('1.5: ' + inputText.replace(',', ''));\n // remove comma, convert to integer\n var inputInt = parseInt(inputText.replace(',', ''));\n\n console.log('2: ' + inputInt);\n\n if (isNaN(inputInt)) {\n console.log('3: is NaN!');\n // if invalid input entered, just default to min\n return annualMin;\n } \n else {\n console.log('4: Not NaN, ' + Math.max(Math.min(inputInt, annualMax), annualMin));\n // return integer entered, or force into range\n return Math.max(Math.min(inputInt, annualMax), annualMin);\n }\n }", "title": "" }, { "docid": "82cc0c03ca8649413c37847f15fba75a", "score": "0.56906956", "text": "function updateInput(ev) {\n let numericInput = ev.target.value;\n if (numericInput.length > 4) {\n numericInput = numericInput = numericInput[numericInput.length - 1];;\n }\n setCurrentInput(numericInput);\n }", "title": "" }, { "docid": "0bda36d8e6e69fa4dec82150f09d01a9", "score": "0.56884265", "text": "attemptNewValue(newValue) {\n const upperbound = this.props.upperBound || 25;\n const lowerbound = this.props.lowerBound || 0;\n if (newValue <= upperbound && newValue >= lowerbound) {\n this.props.setValue(newValue);\n }\n }", "title": "" }, { "docid": "20008218cb30e212ff6f4e5fc624aed0", "score": "0.5688154", "text": "function isInputNumber(evt){\n \n var ch = String.fromCharCode(evt.which);\n \n if(!(/[0-9]/.test(ch))){\n evt.preventDefault();\n } \n}", "title": "" }, { "docid": "b7fdb16020dc777ea681a6750bb5b880", "score": "0.56716055", "text": "isValidInput (input)\n {\n if (!input && input !== 0) return false;\n\n var int = Number (input); // NOTE: Can't use parseInt, because \"3 X\" is valid.\n if (!int && int !== 0) return false;\n\n return (int >= __addMinValue__ && int <= __addMaxValue__);\n }", "title": "" }, { "docid": "cc672f8f52a0665d547a5983c5742c36", "score": "0.565821", "text": "function floatonly(e)\n{\n\treturn keyRestrict(e,'1234567890.');\n}", "title": "" }, { "docid": "cd87011e53422b5d2f7bd2d2f45e0e7d", "score": "0.5653346", "text": "function CheckForFloat(i)\n{\n if(i.value.length>0)\n {\n i.value = i.value.replace(/[^\\d\\.]+/g, '');\n }\n}", "title": "" }, { "docid": "5819834944f018886f4e3c2c0d1f4d68", "score": "0.5645429", "text": "isValidInput (input)\n {\n if (!input && input !== 0) return false;\n\n var int = Number (input); // NOTE: Can't use parseInt, because \"3 X\" is valid.\n if (!int && int !== 0) return false;\n\n return (int >= __addMinParam__ && int <= __addMaxParam__);\n }", "title": "" }, { "docid": "5819834944f018886f4e3c2c0d1f4d68", "score": "0.5645429", "text": "isValidInput (input)\n {\n if (!input && input !== 0) return false;\n\n var int = Number (input); // NOTE: Can't use parseInt, because \"3 X\" is valid.\n if (!int && int !== 0) return false;\n\n return (int >= __addMinParam__ && int <= __addMaxParam__);\n }", "title": "" }, { "docid": "b5501ff04221c457f16e955b43b3dbc0", "score": "0.5634108", "text": "handleNumber(input) {\n\t\tcalc.input = input;\n\t\tif (typeof input !== 'string') {\n\t\t\tinput = $(this).text();\n\t\t\tcalc.input = input;\n\t\t}\n\t\tif (\n\t\t\tcalc.isLastInputNum(calc.inputArray) ||\n\t\t\tcalc.inputArray[calc.inputArray.length - 1] === '.'\n\t\t) {\n\t\t\tcalc.concatLastInput(calc.inputArray, calc.input);\n\t\t} else {\n\t\t\tcalc.inputArray.push(calc.input);\n\t\t}\n\t\tcalc.display();\n\t}", "title": "" }, { "docid": "aef8e14e081e3bb168ac652c40fa6fcb", "score": "0.56340116", "text": "function numericOnly() {\n var oldval = this.value,\n newval = this.value.replace(/\\D/g, '');\n\n if (oldval !== newval) {\n this.value = newval;\n }\n }", "title": "" }, { "docid": "04e0aa754530cf2abaa21d6fe51ab08a", "score": "0.56283784", "text": "function Vka(a){if(Lb(a)||isNaN(a))throw Zn(\"Forbidden numeric value: \"+a).g;}", "title": "" }, { "docid": "d47a8c9aa785c35159393e039755a65e", "score": "0.56076777", "text": "onlyNumber(event) {\n return event.keyCode >= 48 && event.keyCode <= 57;\n }", "title": "" }, { "docid": "f5d3ffc270548d92c1c490f619e67415", "score": "0.56067103", "text": "function checkBounds_(val, boundInclusive, valStr) {\n if (typeof val === 'number') {\n if (val < 0 || val > boundInclusive)\n throw new Error(Errors.INDEX_OUT_OF_BOUNDS.toString(valStr, val, boundInclusive));\n } else if (val)\n throw new Error(Errors.ILLEGAL_ARGUMENT.toString('Make sure' + valStr + ' is a number.'));\n else\n throw new Error(Errors.ILLEGAL_ARGUMENT.toString('Make sure ' + valStr + ' is provided.'));\n }", "title": "" }, { "docid": "37e9a8d65f62d6015f9de5818feff5ec", "score": "0.5584073", "text": "normalizeInputParameters() {\n if (this._max) this.handlePrecision(this._max);\n if (this._min) this.handlePrecision(this._min);\n if (this._step) this.handlePrecision(this._step);\n\n this._previousValue = this.value;\n }", "title": "" }, { "docid": "a7c0ad1287c6404c6e349b29feba88b4", "score": "0.5579545", "text": "function numericField_Blur(inputBox, settings) {\n\t\tvar fieldValueNumeric = parseFloat($(inputBox).val());\n\t\tvar $inputBox = $(inputBox);\n\n\t\tif(isNaN(fieldValueNumeric)) {\n\t\t\t$inputBox.val(\"\");\n\t\t\treturn;\n\t\t}\n\n\t\tif(isNumeric(settings.min) && fieldValueNumeric < settings.min)\n\t\t\t$inputBox.val(\"\");\n\n\t\tif(isNumeric(settings.max) && fieldValueNumeric > settings.max)\n\t\t\t$inputBox.val(\"\");\n\t}", "title": "" }, { "docid": "0e257378a9b8a26e9b134a87a1acfffc", "score": "0.55395985", "text": "function valueChanged(event){\n var input = event.target\n if (input.value <= 0){\n input.value = 1\n }\n if (input.value >= 3){\n input.value = 3\n }\n}", "title": "" }, { "docid": "95fd8b1f333075aaec40492cb910e801", "score": "0.55290973", "text": "function limitControl(input) {\n if ((input.val() > 100)||(input.val() < 0)) {\n input.val(1);\n alert(\"Please input a number between 0 and 100.\"); \n}\n}", "title": "" }, { "docid": "b4a7c1dd494ba8284c36cfcfcfc8d6f4", "score": "0.5525651", "text": "function checkInput(newNum) {\n if (+newNum > 0 && +newNum <= 100) {\n return Math.round(+newNum);\n } else if (newNum === null) {\n return +prevNum;\n } else {\n alert(\"Please Enter a number between 1 and 100.\");\n return +prevNum;\n }\n}", "title": "" }, { "docid": "aa87eaadbd4c59f869692d30d827623d", "score": "0.5515691", "text": "function range($log) {\n return {\n require: \"ngModel\",\n restrict: \"A\",\n scope: {\n rMin: '=',\n rMax: '='\n },\n link: function postLink(scope, elm, attrs, ctrl) {\n\n ctrl.$validators.range = function(modelValue, viewValue) {\n var value = modelValue || viewValue;\n if (ctrl.$isEmpty(value)) return true;\n var min = scope.rMin > parseInt(value);\n var max = scope.rMax < parseInt(value);\n return !(min || max);\n };\n }\n };\n }", "title": "" }, { "docid": "bb3a29c2b78f5bf92e5ea22bcc944936", "score": "0.5515399", "text": "function update_mytunes_range_input() {\n\n var range = document.getElementById('mytunes-range');\n console.log( Math.round(range.value / 10) )\n var mytunes_status = document.getElementById('mytunes-status-display');\n mytunes_status.value = Math.round(range.value / 10); // dont set right away, incase use is just updating other content\n\n range.oninput = function() {\n mytunes_status.value = Math.round(this.value / 10);\n }\n }", "title": "" }, { "docid": "ae238dacdcba68207008b58c59dfb866", "score": "0.5511175", "text": "function onlyAllowNumericInput(e) {\n var modifiers = (e.altkey || e.shiftKey || e.ctrlKey || e.metaKey);\n\n if((!modifiers && e.keyCode >= 48 && e.keyCode <= 57) || allowedCodes.indexOf(e.keyCode) > -1) {\n return true;\n }\n e.preventDefault();\n return false;\n }", "title": "" }, { "docid": "1853bc6dce54ff20b6053b6cfe79e929", "score": "0.5509174", "text": "function allowNumericInputOnly( event ) {\n return (/[0123456789]/.test( String.fromCharCode( event.which ) ) );\n }", "title": "" }, { "docid": "fd786a8565fe74d5adca94a466155bb7", "score": "0.54973996", "text": "function CorrectIntegerInInput(objInput, minValue, maxValue, defaultValue){\n\n var iNewValue = TryParseInt(objInput.val(), defaultValue);\n\n if(iNewValue < minValue)\n objInput.val(minValue);\n else if(iNewValue > maxValue)\n objInput.val(maxValue);\n else\n objInput.val(iNewValue);\n}", "title": "" }, { "docid": "6fa1c6027c25266f3120d1f0b5b2b770", "score": "0.54871595", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n }", "title": "" }, { "docid": "776a1ed139b3127820cfeb706d12cbcb", "score": "0.54689324", "text": "function checkNumberWithinRange({ number }) {\n checkIfEmptyString(number);\n\n if(!checkIfNumber(number)) {\n throw new Error(\"Please enter a number\");\n }\n\n //use absolutes Math.abs(100-inputs)\n\n}", "title": "" }, { "docid": "14ac00afc93219d48244700aa8b1ad88", "score": "0.54648656", "text": "function is_numeric(input){\r\n return isNaN(input);\r\n}", "title": "" }, { "docid": "93ed4087df024f79119b54833eed0fe3", "score": "0.546012", "text": "function on_textInput_changed()\n\t{\n\t\t// set the scale_factor based on the text, then close the dialog.\n\t\tif ( isNaN(this.text) ) {\n\t\t\talert(this.text + \"is not a number. Please enter a number.\");\n\t\t} else {\n\t\t\tscale_factor = this.text;\n\t\t}\n\t}", "title": "" }, { "docid": "2130ce717738b76f7c24d269a402be46", "score": "0.5453103", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n}", "title": "" }, { "docid": "2130ce717738b76f7c24d269a402be46", "score": "0.5453103", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n}", "title": "" }, { "docid": "2130ce717738b76f7c24d269a402be46", "score": "0.5453103", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n}", "title": "" }, { "docid": "2130ce717738b76f7c24d269a402be46", "score": "0.5453103", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n}", "title": "" }, { "docid": "2130ce717738b76f7c24d269a402be46", "score": "0.5453103", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n}", "title": "" }, { "docid": "2130ce717738b76f7c24d269a402be46", "score": "0.5453103", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n}", "title": "" }, { "docid": "5594bd47d2f8233a22be789d21208b42", "score": "0.54514897", "text": "constructor(readCB,writeCB) {\n this.writeCB = writeCB;\n this.readCB = readCB;\n var span = document.createElement(\"span\");\n var input = document.createElement(\"input\");\n input.setAttribute('type', 'range');\n input.setAttribute('min', -1.1);\n input.setAttribute('max', 1.1);\n input.setAttribute('step', 0.05);\n input.value = 0;\n span.appendChild(input);\n var input2 = document.createElement(\"input\");\n input2.setAttribute('type', 'text');\n input2.style.width = \"3em\";\n span.appendChild(input2);\n var update = function() {\n var v = parseFloat(input.value);\n input2.value = v;\n if (writeCB) {\n writeCB(v);\n }\n }\n input.addEventListener(\"input\", update);\n input.addEventListener(\"change\", update);\n input2.addEventListener(\"keypress\", function(e) {\n if (!e) e = window.event;\n var keyCode = e.keyCode || e.which;\n if (keyCode == '13'){\n if (! isNaN(input2.value)) {\n input.value = input2.value;\n update();\n } \n }\n });\n input2.value = 0.0;\n this.input = input;\n this.textinput = input2;\n this.dom = span;\n }", "title": "" }, { "docid": "0f01af21645a7de2eac324ef9dc71f03", "score": "0.54471785", "text": "function fitRange(num, min, max) {\r\n // Check if not number\r\n if (isNaN(num)) {\r\n return min;\r\n }\r\n\r\n // Otherwise fit within range\r\n num = (num > max ? max : num);\r\n num = (num < min ? min : num);\r\n return num;\r\n}", "title": "" }, { "docid": "c17513040fd2567f3c1aaa43cbe0b7e5", "score": "0.5446833", "text": "function getMinRangeInput(){\n\t\tif(minRangeInput){\n\t\t\tminRangeInput.onkeyup = function(e) {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\ttimeout = setTimeout(function () { \n\t\t\t\t\tconsole.log(minRangeInput.value);\t \n\t\t\t\t\tminValue = parseInt(minRangeInput.value);\t\n\t\t\t\t}, 600);\t\n\t\t\t}\n\t }\n\t}", "title": "" }, { "docid": "7e706146febc67c79d3f20bf1204cc9f", "score": "0.5445592", "text": "function validQuantity(input) {\n return parseInt(input) > 0 && input.toString().indexOf(\".\") === -1;\n }", "title": "" }, { "docid": "f6935ddcdd130339946b87eb2bccf5d6", "score": "0.54365295", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "a23cf018e1866843b8682217ec90193e", "score": "0.5432859", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n }", "title": "" }, { "docid": "6adb8330d195fb8eedf0f3e520863bf6", "score": "0.54280365", "text": "function Numeral(input, number) {\r\n this._input = input;\r\n \r\n this._value = number;\r\n }", "title": "" }, { "docid": "3b4236a5cbb8211066480dd3178323dd", "score": "0.5425106", "text": "function range(event, from, to) {\n result = allowChars('0-9');\n if (result)\n return (event.currentTarget.value >= from && event.currentTarget.value <= to);\n else\n return result;\n}", "title": "" }, { "docid": "3002331273f491c48f5bf76754a3d715", "score": "0.54236716", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n }", "title": "" }, { "docid": "75eb9aaac8fd7deb8fa391a824bd7f66", "score": "0.5419201", "text": "function SomenteNumeros(input)\r\n\t{\r\n\tif ((event.keyCode<48)||(event.keyCode>57))\r\n\t\tevent.returnValue = false;\r\n\t}", "title": "" }, { "docid": "b198554c70bced9863355f2008ae1ae9", "score": "0.54168797", "text": "function isValidNumber(input) {\r\n return typeof input === \"number\" && isFinite(input);\r\n }", "title": "" }, { "docid": "58f7314e7887eeb596ea5a60c43037dd", "score": "0.54146105", "text": "function changeRange(){ // \n\tif(bs!=1){\n\t\trange=parseFloat(ran.value); // Read input from page input numbers\n\t\trange2=parseFloat(ran2.value);\n\t}\n}", "title": "" }, { "docid": "8c7ab21314bd835042351baf7ff5fbb1", "score": "0.541443", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n }", "title": "" }, { "docid": "f733e06c5fdedcbe8f961a23b0e14d74", "score": "0.5405544", "text": "function allowOnlyAmount(input) {\n input.on('input', function() {\n $(this).val($(this).val().replace(/[^0-9.]/g, '').replace(/(\\..*?)\\..*/g, '$1'));\n });\n}", "title": "" }, { "docid": "e1a02cc136bd3f62ed2d15ed7298fe71", "score": "0.5405128", "text": "function quantityChanged(event) {\r\n var input = event.target\r\n if (isNaN(input.value) || input.value <= 0) {\r\n input.value = 1 \r\n }\r\n}", "title": "" }, { "docid": "af9de59e993dbc2f86dcdf18a52b0276", "score": "0.5403584", "text": "function validCell(val) {//input value is passed through from board\n if (val.value==='0') {\n \tval.value='';\n }\n if (isNaN(val.value)===true || val.value<0 || val.value>9) {//checks if it is not a number isNAN, then chks if less than 1 or greater than 9 \n alert('INVALID INPUT \\nPlease choose a number between 1-9\\nYou entered: '+ val.value);//alert the user of invalid entry and their entered value\n val.value='';//sets value to blank\n }\t\n}", "title": "" }, { "docid": "d2b4d346f77141ce32a2425fad1cad69", "score": "0.54034567", "text": "function checkRange(input) {\n //checks integer range values for min/max order\n if (input < 0) {\n return true;\n }\n //converts every input into a String\n let stringTest = input.toString();\n // Take their input and split it at the '-' (hyphen mark)\n // numbers variable will then look like this\n // numbers = ['value1', 'value2']\n let numbers = stringTest.split(\"-\");\n //removes empty strings in array (caused by edge case of negative min to max range ex: \"-100-300\")\n let filterednumbers = numbers.filter((item) => item);\n // parseFloat parses argument and returns floating point number, then point numbers are compared using the < (less than) mathematical symbol\n // Because we are using the < in the return, this will only return a true or false based off the values.\n return parseFloat(filterednumbers[0]) < parseFloat(filterednumbers[1]);\n}", "title": "" }, { "docid": "6c94ca71061e0837d52c8449db932390", "score": "0.540207", "text": "function allowOnlyNumericInInputBox(controlid) {\r\n $('#' + controlid).keydown(function (e) {\r\n // Allow: backspace, delete, tab, escape, enter and .\r\n if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||\r\n // Allow: Ctrl+A\r\n (e.keyCode == 65 && e.ctrlKey === true) ||\r\n // Allow: home, end, left, right\r\n (e.keyCode >= 35 && e.keyCode <= 39)) {\r\n // let it happen, don't do anything\r\n return;\r\n }\r\n // Ensure that it is a number and stop the keypress\r\n if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {\r\n e.preventDefault();\r\n }\r\n });\r\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" }, { "docid": "b94c8fb8ec4ddbb8af179b19f45851bc", "score": "0.53999186", "text": "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n}", "title": "" } ]
c73ab9593c3334a460da7040f62cfe37
prefixed with underscored because delete is a reserved word in javascript
[ { "docid": "b3aa7cb3df15be5ace4debd2927c9bea", "score": "0.0", "text": "async function _delete(url) {\n\tconst requestOptions = {\n\t\tmethod: \"DELETE\",\n\t\theaders: authHeader(url),\n\t};\n\treturn await fetch(url, requestOptions)\n\t\t.then((response) => response.json())\n\t\t.catch((error) => console.error(error));\n}", "title": "" } ]
[ { "docid": "0c9988d10186ad0fe40ec371e5a3ab84", "score": "0.7236311", "text": "function DELETE(){\n\n}", "title": "" }, { "docid": "f0a48937f34fcf41ad3588bd6740cc3f", "score": "0.7019411", "text": "static get DELETE_LOWER() { return 3; }", "title": "" }, { "docid": "f0a48937f34fcf41ad3588bd6740cc3f", "score": "0.7019411", "text": "static get DELETE_LOWER() { return 3; }", "title": "" }, { "docid": "ed4b58b9e540f4b093594beb64f16f4d", "score": "0.6898352", "text": "function _delete(id) {\n\n}", "title": "" }, { "docid": "cbaa9c11b49242d2564af5bc8ef333e2", "score": "0.67977756", "text": "function caml_js_delete(o,f) { delete o[f]; return 0}", "title": "" }, { "docid": "cab7a4a981b9ff258a857f8c6f008bb0", "score": "0.67370963", "text": "delete() {\n\n\n }", "title": "" }, { "docid": "b712f44a99f439d3d72e775e91730a33", "score": "0.6731984", "text": "function keyDeleter() {\n var compiled;\n if (this.body.length !== 2) {\n throw new Error('The setKey function must take 2 arguments. Line ' + this.pos + '.');\n }\n compiled = this.body[0].compile();\n if (compiled === '_HN_global') {\n throw new Error('Nice try. No touching global variables. Line ' + this.pos + '.');\n }\n return '(delete ' + compiled + '[' + this.body[1].compile() + ']' + ')';\n}", "title": "" }, { "docid": "88093a55fd0abada741abd644faca262", "score": "0.66626227", "text": "delete(){return Hs(this.kt.delete());}", "title": "" }, { "docid": "72d76fb12d126a1d7e2f8271ca6b9e29", "score": "0.6606109", "text": "delete() {\n \n }", "title": "" }, { "docid": "0c015c8e9ea1cd1accd9b8ebaae00b7b", "score": "0.64862335", "text": "function delete_literal() {\n return (delete 4);\n}", "title": "" }, { "docid": "93d7875f6e59dea33fd642d7b2a91196", "score": "0.63254064", "text": "delete(...args) {\n return this._call('delete', 1, ...args);\n }", "title": "" }, { "docid": "83d6eb917690d316f1f37874d257f16b", "score": "0.63148683", "text": "function HandleDelete () {\n}", "title": "" }, { "docid": "44504beb0e7da3fb8a44415e271a799d", "score": "0.630716", "text": "function xd(e,t){e&&e[t]&&0===Ua(e[t]).length&&delete e[t]}", "title": "" }, { "docid": "83ad07357570d24f655283516f2041cf", "score": "0.62305135", "text": "function Ar(e){delete Nr[e]}", "title": "" }, { "docid": "6b281e1970203b88a11339d5fde6715d", "score": "0.6185257", "text": "static DeleteKey() {}", "title": "" }, { "docid": "4a1e20bab3dff3f0f4bf865811a57b84", "score": "0.6169254", "text": "delete() {\n return Js(this.kt.delete());\n }", "title": "" }, { "docid": "e0b2758e9a0703658f5624ad35621e17", "score": "0.61294794", "text": "delete() {\n throw new Error('Implement me!');\n }", "title": "" }, { "docid": "190ff9a1bfc02abb2f439c63a5915d2b", "score": "0.61215377", "text": "async delete()\n {\n\n }", "title": "" }, { "docid": "f1a9ae40b06b75b9e0885809e92eec9a", "score": "0.60934985", "text": "delete(id) {\n\n }", "title": "" }, { "docid": "054229570f29b5034a9c1da1362c0cd8", "score": "0.6057655", "text": "function User_Delete_Type_de_documents_Type_de_documents0(Compo_Maitre)\n{\n var Table=\"typedocument\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "247dda8c1daf511f4338ac174193b4bc", "score": "0.6053972", "text": "function deleteable(t) {\r\n return function () {\r\n return Object(_operations__WEBPACK_IMPORTED_MODULE_5__[\"spPostDelete\"])(_telemetry__WEBPACK_IMPORTED_MODULE_6__[\"tag\"].configure(this, t + \".delete\"));\r\n };\r\n}", "title": "" }, { "docid": "07c96cda85c6158e772a20ada9141cec", "score": "0.60482275", "text": "function fa(e){delete da[e]}", "title": "" }, { "docid": "fae088220d497d6d431e400cd5a9fb6f", "score": "0.60084575", "text": "delete() {\n this.currentOperation = this.currentOperation.toString().slice(0,-1)\n\n}", "title": "" }, { "docid": "51c544bdeebfbf0dc2f41d788db3e70c", "score": "0.6005283", "text": "function normalizeOperationName(operation) {\n return (operation == 'del') ? 'delete' : operation;\n}", "title": "" }, { "docid": "19c5cf00d100b220753dc0f1a566f43a", "score": "0.59785336", "text": "async delete(WhatToDelete){\n \n }", "title": "" }, { "docid": "9c6719fb6dcfa9e3856e4931018ce621", "score": "0.5960427", "text": "function User_Delete_Documents_Documents0(Compo_Maitre)\n{\n var Table=\"document\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "7ab531493e05804b5e39164cbc48ee70", "score": "0.59432435", "text": "deleteItem(key) {\n\n }", "title": "" }, { "docid": "af8478329f615aafe31ec281f253c1c7", "score": "0.59208935", "text": "function Yi(e){delete qi[e]}", "title": "" }, { "docid": "7f01b40d0fe982d2b27874591fd35254", "score": "0.5913324", "text": "function Uo(e){delete qo[e]}", "title": "" }, { "docid": "8cd63c9bb6d7912591e8493144f8b58f", "score": "0.5905979", "text": "function sfDelete(ast, env){\n assertArity(ast.length >= 2 && ast.length < 4, ast);\n let ret = smNode(ast);\n ret.add([\"delete \", txExpr(ast[1], env)]);\n if(ast.length > 2)\n ret.add([\"[\", txExpr(ast[2], env), \"]\"]);\n return ret;\n }", "title": "" }, { "docid": "4f6fe624e3f034b4812c1c7f9b009f74", "score": "0.58823323", "text": "_delete(table) {\n this.query += 'DELETE FROM ??';\n this.params.push(table);\n return this;\n }", "title": "" }, { "docid": "07e63d01dbaa48dfc2b6214675c0390f", "score": "0.5838058", "text": "function Yi(e){delete Xi[e]}", "title": "" }, { "docid": "3e5f94424c50abe7a11549c8ea268c9e", "score": "0.58140606", "text": "function delete_parameter(p) {\n return (delete p);\n}", "title": "" }, { "docid": "000a325f41cd4a71a4e238b058c4ce6c", "score": "0.5801471", "text": "function keyCommandPlainDelete(editorState){var afterRemoval=removeTextWithStrategy(editorState,function(strategyState){var selection=strategyState.getSelection(),content=strategyState.getCurrentContent(),key=selection.getAnchorKey(),offset=selection.getAnchorOffset(),charAhead=content.getBlockForKey(key).getText()[offset];return moveSelectionForward(strategyState,charAhead?UnicodeUtils.getUTF16Length(charAhead,0):1);},\"forward\");if(afterRemoval===editorState.getCurrentContent())return editorState;var selection=editorState.getSelection();return EditorState.push(editorState,afterRemoval.set(\"selectionBefore\",selection),selection.isCollapsed()?\"delete-character\":\"remove-range\");}", "title": "" }, { "docid": "a78d3eb443a40acf787152f5728397c6", "score": "0.57944363", "text": "delete(){\n this.currentOperand = this.currentOperand.toString().slice(0, -1)\n\n }", "title": "" }, { "docid": "e96f7bb939a34301cde15192a71542e1", "score": "0.5784315", "text": "function deleteEntity(name){// delete is a reserved keyword\nreturn this._path().addParams({name:name}).makeBuilder();}", "title": "" }, { "docid": "8fc9391a8aad1fcc7a5ddf0daf422375", "score": "0.5782576", "text": "canDelete() {}", "title": "" }, { "docid": "695ac19ad770805c4b745008c0f2bd20", "score": "0.577828", "text": "te(t){delete this.Jt[t];}", "title": "" }, { "docid": "d4d835d465b433b837605ad6a0384dd1", "score": "0.57743067", "text": "delete(args){\n args.scope = 'META'\n return remove(args)\n }", "title": "" }, { "docid": "bc35d157704e914912b8d3bca44deac4", "score": "0.57694894", "text": "deleteRecord() {}", "title": "" }, { "docid": "0f29fdec0e5c5f1c5660fd71e9f15421", "score": "0.5768704", "text": "function f2 () {\n \"use \\\nstrict\";\n // This should be fine since the directives above are not valid.\n delete y;\n}", "title": "" }, { "docid": "3f210b95f47bcf089f422abdb1daa455", "score": "0.5764634", "text": "function delDel(str) {\n if ((str.length >= 4) && (str.substring(1, 4).localeCompare(\"del\") == 0)) {\n return str.slice(0, 1) + str.slice(4);\n\n } else {\n return str;\n }\n\n}", "title": "" }, { "docid": "8bf473a9e682bb47cb6ecd9820312f2b", "score": "0.5758665", "text": "function f1 () {\n \"use\\x20strict\";\n // This should be fine since the directives above are not valid.\n delete y;\n}", "title": "" }, { "docid": "ca2167ce8a1b878326e2a07d647f25b6", "score": "0.57487357", "text": "function DELETE(key, strict) {\n return %DeleteProperty(%ToObject(this), %ToString(key), strict);\n}", "title": "" }, { "docid": "49ea9af1bc844f5249157e422346c4cf", "score": "0.5737274", "text": "function User_Delete_Articles_Articles0(Compo_Maitre)\n{\n var Table=\"article\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "985f3a3017fae2516446990baa7edf42", "score": "0.5737123", "text": "function delete_variable() {\n return (delete x);\n}", "title": "" }, { "docid": "a41eb3c4ae6994ed70119335542f4f5e", "score": "0.57343376", "text": "function deleteItemFromParse(key){\n\n}", "title": "" }, { "docid": "a3c5569a47867c27161960ed128ca053", "score": "0.5733231", "text": "function deleteCheque(ChequePrefix){\n\tvar chequeDIVName = ChequePrefix + 'DIV';\n\tvar divObj = document.getElementById(chequeDIVName);\n\tvar chequeActionName = ChequePrefix + '_Action';\n\tvar actionObj = document.getElementById(chequeActionName);\n\tactionObj.value = 'delete';\n\tdivObj.style.display=\"none\";\t\n}", "title": "" }, { "docid": "6836a8ca0df2c99b006f2a3833411179", "score": "0.5695853", "text": "function BtnDelete() {\n transacionAjax_D_elete(\"D_elete\");\n}", "title": "" }, { "docid": "d0feabeff1b07b97a79e80609e55a8fd", "score": "0.56916016", "text": "function quitarEspacios(id){\n return id.replace(/\\s/g, \"_\")\n}", "title": "" }, { "docid": "9f47086b8ed16ea1079d0c52ce38a750", "score": "0.5690822", "text": "function keyDeleter(obj) {\n delete obj.foo;\n delete obj.bar;\n return obj; \n}", "title": "" }, { "docid": "95b29d1c23edf16526dabe8a8be6fe63", "score": "0.5690401", "text": "function User_Delete_Type_de_couche_Type_de_couches0(Compo_Maitre)\n{\n var Table=\"typecouche\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "56178892bc32239ea8234fc7016eede7", "score": "0.5680157", "text": "deleteProperty(o, name) {\n return false;\n }", "title": "" }, { "docid": "85af36ede8d19dd06b3cf3b0bc4d66b8", "score": "0.5669711", "text": "static get deleteProperty() {\n return this.prototype.deleteProperty;\n }", "title": "" }, { "docid": "3b9407b9ed0547f5d30d74a67cc20b96", "score": "0.56686705", "text": "function Sr(e){delete Mr[e]}", "title": "" }, { "docid": "a874b5de92b6dc47b02a86d4611724e1", "score": "0.5663612", "text": "_deleteKey(objName, key = '') {\n let obj = get(this, objName);\n if (obj.hasOwnProperty(key)) {\n delete obj[key];\n }\n let c = this;\n c.notifyPropertyChange(`${objName}.${key}`);\n c.notifyPropertyChange(objName);\n }", "title": "" }, { "docid": "3047bff2bf604a5f31cd195da69b901a", "score": "0.566339", "text": "function stripDelete(a) {\n \t for (var _i = 0, _Object$keys = keys$3(a); _i < _Object$keys.length; _i++) {\n \t var prop = _Object$keys[_i];\n\n \t if (a[prop] === DELETE) {\n \t delete a[prop];\n \t } else if (_typeof_1(a[prop]) === \"object\" && a[prop] !== null) {\n \t stripDelete(a[prop]);\n \t }\n \t }\n \t}", "title": "" }, { "docid": "9b1d95753806ca9ab241d02d7c3005b5", "score": "0.56629086", "text": "delete( key ){\n\t\tif( ! this.__data ) return null\n\n\t\tlet _data = this.__data\n\n\t\tdelete this[ key ]\n\t\t// delete this[ ''+key ]\n\n\t\t// this.delete( key )\n\t\tif( this.__data.data && typeof this.__data.data === 'function') this.__data.data.delete( key )\n\n\t\treturn _data.delete( key )\n\t}", "title": "" }, { "docid": "fbf0490491b9628e6a16b3aa788106e7", "score": "0.5655313", "text": "function User_Delete_Composition_Compositions0(Compo_Maitre)\n{\n var Table=\"composition\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "bf7ed950c1b484e8c2209d3e7476fe03", "score": "0.56538594", "text": "function Delete (token) {\n this.token = token;\n}", "title": "" }, { "docid": "47be12c31ab3528b5665e0e75f360b01", "score": "0.56522745", "text": "function Ui(t){delete $i[t]}", "title": "" }, { "docid": "44da8ef39376e770ebb0f54d983c8839", "score": "0.56486493", "text": "get_delete_url(){\n return \"base/\" + this.nameSpace + \"/table/\" + this.state.tableName + \"/\";\n }", "title": "" }, { "docid": "2137a4670c21191c1b95140814df24d0", "score": "0.56467986", "text": "function User_Delete_Achat_Achat0(Compo_Maitre)\n{\n var Table=\"achat\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "85d2e49bc17c71455d11fae6d4d98d8c", "score": "0.5640512", "text": "function User_Delete_Modele_Modeles0(Compo_Maitre)\n{\n var Table=\"modele\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "efbacba51466a01a6980516779365c2d", "score": "0.5639911", "text": "function del (keysString, isPrintOutput) {\n _storeFunctions (\"delete\", keysString, \"\", isPrintOutput);\n return;\n}", "title": "" }, { "docid": "2bbeef85f0828eecb127376bdcac1328", "score": "0.56382054", "text": "function Ko(t){delete qo[t]}", "title": "" }, { "docid": "28d04eba111029e7aae4888118dd967e", "score": "0.5627105", "text": "function deleteQuoteLocalStorage() {\n console.log('delete')\n}", "title": "" }, { "docid": "9e9dd9e097a77171d342e4b8f1f4d21c", "score": "0.5622457", "text": "function processDelete(event,target){\n\t\n}", "title": "" }, { "docid": "c5b47296563826ad6dd11b26a95df28c", "score": "0.56160265", "text": "function User_Delete_Ventes_Ventes0(Compo_Maitre)\n{\n var Table=\"vente\";\n var CleMaitre = Compo_Maitre.getCleVal();\n var NomCleMaitre = DePrefixerChamp(Compo_Maitre.getCle());\n var Req=\"delete from \"+Table+\" where \"+NomCleMaitre+\" = \"+CleMaitre;\n\n if (pgsql_update(Req)==0)\n\talert(\"Echec lors de la supression\");\nreturn CleMaitre;\n\n}", "title": "" }, { "docid": "0a6c7101e2fdef10bf0052ae22590f0d", "score": "0.5612284", "text": "function deleteVariableDeclarationOrPrefixWithUnderscore(identifier, varDecl) {\n switch (varDecl.parent.parent.kind) {\n case 214 /* ForStatement */:\n var forStatement = varDecl.parent.parent;\n var forInitializer = forStatement.initializer;\n return [forInitializer.declarations.length === 1 ? deleteNode(forInitializer) : deleteNodeInList(varDecl)];\n case 216 /* ForOfStatement */:\n var forOfStatement = varDecl.parent.parent;\n ts.Debug.assert(forOfStatement.initializer.kind === 227 /* VariableDeclarationList */);\n var forOfInitializer = forOfStatement.initializer;\n return [\n replaceNode(forOfInitializer.declarations[0], ts.createObjectLiteral()),\n prefixIdentifierWithUnderscore(identifier)\n ];\n case 215 /* ForInStatement */:\n // There is no valid fix in the case of:\n // for .. in\n return [prefixIdentifierWithUnderscore(identifier)];\n default:\n var variableStatement = varDecl.parent.parent;\n if (variableStatement.declarationList.declarations.length === 1) {\n return [deleteNode(variableStatement)];\n }\n else {\n return [deleteNodeInList(varDecl)];\n }\n }\n }", "title": "" }, { "docid": "68daee319a0a169d6dc108254985ec24", "score": "0.56113523", "text": "static delete(t){return x(\"SimpleDb\",\"Removing database:\",t),Hs(window.indexedDB.deleteDatabase(t)).toPromise();}", "title": "" }, { "docid": "64061804d8d872ebe9e33f4e684b4c95", "score": "0.5610934", "text": "function cIsReservedIdentifier(token){if(!token||2>token.length)return!1;if(\"_\"!=token[0])return!1;return\"_\"==token[1]||token[1]!==token[1].toLowerCase()}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.56088954", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" } ]
7779e23f9eef65f1fed3f786bd7d7c69
Draw the needed elements
[ { "docid": "2e9bf358423be100f9aa49900813c359", "score": "0.0", "text": "function draw() {\n\n // fix some styles\n self.css(\"text-decoration\", \"none\");\n self.width(self.outerWidth());\n self.height(self.outerHeight());\n\n // wrapper styles\n wrapper.css(\"position\", \"relative\");\n // wrapper.css(\"width\", self.outerWidth());\n // relative div needs an z-index (related to IE z-index bug)\n if($.browser.msie)\n \twrapper.css(\"z-index\", zindex);\n\n // overlay div to block events of source select element\n overlay.css({\n \"position\": \"absolute\",\n \"top\": 0,\n \"left\": 0,\n \"width\": self.outerWidth(),\n \"height\": self.outerHeight(),\n \"background-color\": \"#FFFFFF\",\n \"opacity\": \"0.01\",\n \"display\": \"none\"\n });\n\n // overlay text field for searching capability\n input.attr(\"type\", \"text\");\n // input.hide();\n input.height(self.outerHeight());\n\n // default styles for text field\n input.css({\n \"position\": \"absolute\",\n \"top\": 0,\n \"left\": 0,\n \"margin\": \"0px\",\n \"padding\": \"0px\",\n \"outline-style\": \"none\",\n \"border-style\": \"solid\",\n \"border-bottom-style\": \"none\",\n \"border-color\": \"transparent\",\n \"background-color\": \"transparent\"\n// \"background-color\": \"red\"\n });\n\n // copy selected styles to text field\n \t\tvar sty = new Array();\n \t\tsty.push(\"border-left-width\");\n \t\tsty.push(\"border-top-width\");\n \t\t//sty.push(\"font-family\");\n \t\tsty.push(\"font-size\");\n \t\tsty.push(\"font-stretch\");\n \t\tsty.push(\"font-variant\");\n \t\tsty.push(\"font-weight\");\n \t\tsty.push(\"color\");\n \t\tsty.push(\"text-align\");\n \t\tsty.push(\"text-indent\");\n \t\tsty.push(\"text-shadow\");\n \t\tsty.push(\"text-transform\");\n \t\tsty.push(\"padding-left\");\n \t\tsty.push(\"padding-top\");\n \t\tfor(var i=0; i < sty.length;i++)\n \t\t\tinput.css(sty[i], self.css(sty[i]));\n\n \t\t// adjust search text field\n \t\t// IE7\n \t\tif($.browser.msie && parseInt(jQuery.browser.version) < 8) {\n \t\t\tinput.css(\"padding\", \"0px\");\n \t\t\tinput.css(\"padding-left\", \"3px\");\n \t\t\tinput.css(\"border-left-width\", \"2px\");\n \t\t\tinput.css(\"border-top-width\", \"3px\");\n \t\t}\n \t\t// chrome\n \t\telse if($.browser.chrome) {\n \t\t\tinput.height(self.innerHeight());\n \t\t\tinput.css(\"text-transform\", \"none\");\n \t\t\tinput.css(\"padding-left\", parseFloatPx(input.css(\"padding-left\"))+3);\n \t\t\tinput.css(\"padding-top\", 2);\n \t\t}\n \t\t// safari\n \t\telse if($.browser.safari) {\n \t\t\tinput.height(self.innerHeight());\n \t\t\tinput.css(\"padding-top\", 2);\n \t\t\tinput.css(\"padding-left\", 3);\n \t\t\tinput.css(\"text-transform\", \"none\");\n \t\t}\n \t\t// opera\n \t\telse if($.browser.opera) {\n \t\t\tinput.height(self.innerHeight());\n \t\t\tvar pl = parseFloatPx(self.css(\"padding-left\"));\n \t\t\tinput.css(\"padding-left\", pl == 1 ? pl+1 : pl);\n \t\t\tinput.css(\"padding-top\", 0);\n \t\t}\n \t\telse if($.browser.mozilla) {\n \t\t\tinput.css(\"padding-top\", \"0px\");\n \t\t\tinput.css(\"border-top\", \"0px\");\n \t\t\tinput.css(\"padding-left\", parseFloatPx(self.css(\"padding-left\"))+3);\n \t\t}\n \t\t// all other browsers\n \t\telse {\n \t\t\tinput.css(\"padding-left\", parseFloatPx(self.css(\"padding-left\"))+3);\n \t\t\tinput.css(\"padding-top\", parseFloatPx(self.css(\"padding-top\"))+1);\n \t\t}\n\n \t\t// adjust width of search field\n \t\tvar offset = parseFloatPx(self.css(\"padding-left\")) + parseFloatPx(self.css(\"padding-right\")) +\n \t\tparseFloatPx(self.css(\"border-left-width\")) + parseFloatPx(self.css(\"border-left-width\")) + 23;\n input.width(self.outerWidth() - offset);\n\n \t\t// store css width of source select object then set width\n \t\t// to auto to obtain the maximum width depends on the longest entry.\n \t\t// this is nessesary to set the width of the selector, because min-width\n \t\t// do not work in all browser.\n var w = self.css(\"width\");\n var ow = self.outerWidth();\n self.css(\"width\", \"auto\");\n ow = ow > self.outerWidth() ? ow : self.outerWidth();\n self.css(\"width\", w);\n\n // entries selector replacement\n selector.hide();\n selectorHelper.size(self.get(0).length);\n selector.css({\n \"position\": \"absolute\",\n \"top\": self.outerHeight(),\n \"left\": 0,\n \"width\": ow,\n \"border\": \"1px solid #333\",\n \"font-weight\": \"normal\",\n \"padding\": 0,\n \"background-color\": self.css(\"background-color\"),\n \"text-transform\": self.css(\"text-transform\")\n });\n\n // z-index handling\n var zIndex = /^\\d+$/.test(self.css(\"z-index\")) ? self.css(\"z-index\") : 1;\n // if z-index option is defined, use it instead of select element z-index\n if (settings.zIndex && /^\\d+$/.test(settings.zIndex))\n \tzIndex = settings.zIndex;\n overlay.css(\"z-index\", (zIndex).toString(10));\n input.css(\"z-index\", (zIndex+1).toString(10));\n selector.css(\"z-index\", (zIndex+2).toString(10));\n\n // append to container\n self.wrap(wrapper);\n self.after(overlay);\n self.after(input);\n self.after(selector);\n }", "title": "" } ]
[ { "docid": "bd47788b362edbf7e1215099f38a9e31", "score": "0.7005588", "text": "draw() {\n this.clear();\n for (const aes of this.aesthetics) {\n if (aes.isEnabled())\n this.drawTriangles(aes);\n this.drawBorders(aes);\n }\n }", "title": "" }, { "docid": "f843a79d4a86f26d3d456e3bf5b6e871", "score": "0.6863977", "text": "function renderElements() {\n\tfor ( var i = 0; i < elements.length; i++ ) {\n\t\tdrawElement( elements[i] );\n\t}\n}", "title": "" }, { "docid": "87a5f233a4cc754dbff9392037266711", "score": "0.6741917", "text": "function draw() {\n updateButtons();\n\n makeGrid();\n\n borderR.position(canvas.position().x + width, size * 10);\n currentSelection.position(canvas.position().x + width, height / 4);\n info.position(canvas.position().x + width, height / 2.5);\n\n currentSelection.html(currentType + '<br>' + currentTile + '<br>' + currentTier);\n info.html('Pylons can be connected<br>if within a 4 block square<br>radius of each other.');\n\n elements.forEach(e => { e.show() });\n if (showBorders)\n drawBorders();\n\n let gridX = Math.floor(mouseX / size);\n let gridY = Math.floor(mouseY / size);\n\n if (checkPos(gridX, gridY)) {\n drawPreview(gridX, gridY, currentTile, currentType, currentTier);\n }\n}", "title": "" }, { "docid": "125c3d367edc555ab8f3c05cdf62563a", "score": "0.67350227", "text": "draw() {\n this.layout(this.width, this.height);\n }", "title": "" }, { "docid": "f14a5ca53a9591717bfe0affe9f1baed", "score": "0.6703253", "text": "draw() {\n // Create and structure elements.\n const els = this.elements;\n els.container = createDiv('fbv-item-container');\n els.rowContainer = createDiv('fbv-item-row-container');\n els.container.appendChild(els.rowContainer);\n els.row = createDiv('fbv-item-row');\n els.rowContainer.appendChild(els.row);\n els.iconContainer = createDiv('fbv-item-icon');\n els.row.appendChild(els.iconContainer);\n this.drawIcon();\n els.main = createDiv('fbv-item-main');\n els.row.appendChild(els.main);\n this.drawMainItem();\n els.children = createDiv('fbv-item-children');\n els.container.appendChild(els.children); // Set padding left according to the depth of the item.\n\n const depth = this.pathTokens.length - 1;\n els.row.style.paddingLeft = `${depth * INDENT_SIZE}rem`; // Set visibility of the children.\n\n if (!this.options.expand) {\n els.children.style.display = 'none';\n } // Bind listeners to elements.\n\n\n if (!this.isEdit()) {\n els.row.addEventListener('click', e => this.handleClickRow(e));\n }\n\n this.target.appendChild(els.container);\n }", "title": "" }, { "docid": "4e73539d964fefeb5c38cd91baee3df6", "score": "0.6691279", "text": "render() {\n this._create_elements()\n this._render_elements()\n }", "title": "" }, { "docid": "8a201b2181d655cf2a763918ca77953a", "score": "0.66802114", "text": "function draw(){\n background(51);\n objArr.forEach(element => {\n element.render()\n });\n}", "title": "" }, { "docid": "31e7324d3002a77ef516ce6c90725ae1", "score": "0.665945", "text": "draw() {\n super.draw();\n this.div\n this.describe(this.height, this.width);\n }", "title": "" }, { "docid": "05673ae9728aa6712f9346104e9c0b15", "score": "0.6653474", "text": "draw() {\n this.elements.html(null);\n\n for (var x = 0; x < this.interCount; x++) {\n for (var y = 0; y < this.interCount; y++) {\n //var cellWidth = Math.ceil(this.totalWidth / (this.interCount - 1));\n var width = (this.interCount > 13) ? 22 : 33;\n var minus = (this.interCount > 13) ? 10 : 15;\n\n var posX = (x * width) - minus;\n\n if (this.interCount > 13) {\n var posY = (y * width) - minus;\n } else {\n var posY = (y * width) - minus + y;\n }\n \n var player = this.intersections[x][y];\n\n switch (player) {\n case 0: player = null; break;\n case 1: player = \"black\"; break;\n case 2: player = \"white\"; break;\n }\n\n this.elements.append(`<div data-x=\"${x}\" data-y=\"${y}\" style=\"top: ${posY}px; left: ${posX}px;\" class=\"${player}\"></div>`);\n }\n }\n }", "title": "" }, { "docid": "e3f59c0d35c989283a73d105167fe1be", "score": "0.6620653", "text": "function draw()\n\t{\t\t\n\t\tdrawNode.draw(ctx);\n\t\tfor( var i = 0; i < drawNode.children.length; i++ )\n\t\t{\n\t\t\tdrawNode.children[i].draw(ctx);\n\t\t}\n\t\treturn;\n\t}", "title": "" }, { "docid": "5c4e58c6de8399506799416dbe5f51ff", "score": "0.66075647", "text": "draw() {\n\t\t\t// erase the canvas\n\t\t\tthis.destroy_board();\n\t\t\t// redraw the contents\n\t\t\tthis.init_grid(); // grid, if show_grid is set\n\t\t\tthis.init_tray(); // tray, if pento_with_tray is set\n\t\t\tthis.draw_shapes(); // shapes present in pento_shapes\n\t\t}", "title": "" }, { "docid": "251c93dcb8e932831cc80c77fd9f2b6d", "score": "0.66057307", "text": "function initDraw() {\r\n brushLabel.text(\"Width: \");\r\n brushLabel1.text(\"7px\");\r\n brushLabel.append(brushLabel1);\r\n brushSliderPoint.css(\"left\", \"0px\");\r\n drawLabel.css({ 'color': 'black' });\r\n eraseLabel.css({ 'color': 'gray' });\r\n drawMode = 'draw';\r\n drawModeLabel1.text(\"Draw\");\r\n //eraserLabel.text(\"Eraser: \");\r\n //eraserLabel1.text(\"7px\");\r\n //eraserLabel.append(eraserLabel1);\r\n //eraserSliderPoint.css(\"left\", \"0px\");\r\n opacityLabel.text(\"Opacity: \");\r\n opacityLabel1.text(\"100%\");\r\n opacityLabel.append(opacityLabel1);\r\n opacitySliderPoint.css(\"left\", (0.87 * opacitySlider.width()) + \"px\");\r\n hideAll(drawArray);\r\n }", "title": "" }, { "docid": "42371bcb9d1f829ec4574f754f37afd3", "score": "0.65359706", "text": "draw(){\n\t\tpush();\n\t\ttranslate(this.x, this.y);\n\t\trectMode(CORNER);\n\t\tfill(this.color);\n\t\trect(0, 0, this.w, this.h);\n\t\tpop();\n\t}", "title": "" }, { "docid": "c6888530ec9d6349b71ec8b00b196820", "score": "0.6523923", "text": "static draw() {\n for (let e of this.elements){\n if(e.visible)\n e.draw();\n }\n // After everything draw the popUps\n for (let e of this.elements){\n if(e.popUpDraw)\n e.popUp();\n }\n }", "title": "" }, { "docid": "9be379dfc8ac544df69938b488bf1f54", "score": "0.65196764", "text": "draw() {\n \n }", "title": "" }, { "docid": "48e30f57c290ea51c448f9125798285f", "score": "0.65175116", "text": "function drawLayout() {\r\n\r\n\t\tctx.strokeStyle = \"black\";\r\n\t\tctx.lineWidth = 1;\r\n\t\tctx.strokeRect(0, 0, w, h);\r\n\t\tctx.strokeStyle = \"white\";\r\n\t\tctx.lineWidth = 4;\r\n\t\tctx.beginPath();\r\n\t\tctx.moveTo(w/2, h);\r\n\t\tctx.lineTo(w/2, h-100);\r\n\t\tctx.stroke();\r\n\r\n\t}", "title": "" }, { "docid": "4cb79f1cc2037e3ff7dc778d9f692727", "score": "0.648996", "text": "draw() {\n this.drawRect();\n this.writeInfo();\n this.drawUmbilic();\n }", "title": "" }, { "docid": "91b8519c528b958128017bad331fb795", "score": "0.6461494", "text": "draw() {\n // Create elements.\n const els = this.elements;\n els.container = createDiv(`fbv-container t-${this.options.theme}`);\n els.header = createDiv('fbv-header');\n els.container.appendChild(els.header);\n els.bodyContainer = createDiv('fbv-body-container');\n els.container.appendChild(els.bodyContainer);\n els.body = createDiv('fbv-body');\n els.bodyContainer.appendChild(els.body); // Bind children.\n\n const {\n on,\n dispatch,\n options,\n handleChange,\n handleEditModeChange,\n handleEdit\n } = this;\n this.fileTreeView = new FileTreeView(els.body, {\n on,\n dispatch,\n options,\n handleChange,\n handleEdit\n });\n this.toolbarView = new ToolbarView(els.header, {\n handleEditModeChange\n }); // Render.\n\n this.target.appendChild(els.container);\n }", "title": "" }, { "docid": "e73396a5a182e7b59fe03c5412319420", "score": "0.64558834", "text": "function drawCanvas() {\n\t\tdrawing(context, drawer, colours, solver, purificator, extraIndications);\n\t\tsolver.callStateForItem(spanState);\n\t}", "title": "" }, { "docid": "08849798dce442b62a0b8e7d93592c91", "score": "0.6452038", "text": "function draw(){\n\n\tvar numElements = 50\n\nvar step= width/numElements\ntextSize(10)\ntextAlign(CENTER,CENTER)\nvar colorstep = 255/numElements\n//console.log(step)\n\n//var x =0\n//var step =10\n\n// var x is the starting value\n\nfor (var x = 0 ;x < numElements; x++){\n\tfor (var y = 0 ; y< numElements; y++){\n\nnoStroke(255)\nstrokeWeight(3)\nfill(x*colorstep,mouseX,y*colorstep)\nrect(x*step,y*step,step,step)\nfill(0)\n\n\n}\n}\n}", "title": "" }, { "docid": "7cb982b81a9c0747158d545a48afcd0e", "score": "0.64420575", "text": "function draw() {\n if (self.currentShapes == 'circles') {\n drawCircles();\n } else if (self.currentShapes == 'triangles') {\n drawTriangles();\n } else {\n drawRectangles();\n }\n }", "title": "" }, { "docid": "72bf11178116c5cc54edab9f1e6f1e08", "score": "0.6440497", "text": "function render() {\n // below: if statement for distinguishing btw hover and click (bonus for later)\n // if (clicked) {\n //\n // } else {\n // ctx.clearRect(0, 0, w, h);\n // }\n\n ctx.beginPath();\n\n for (let x = 0; x < columns; x++) {\n ctx.moveTo(x * tileWidth, 0);\n ctx.lineTo(x * tileWidth, h);\n }\n for (let y = 0; y < rows; y++) {\n ctx.moveTo(0, y * tileHeight);\n ctx.lineTo(w, y * tileHeight);\n }\n ctx.stroke();\n }", "title": "" }, { "docid": "8161ad364e60bf37034eb8b0c83cfe94", "score": "0.64330715", "text": "function draw() {\n background(100)\n\n drawTopics(topics)\n drawLegend(docs, colors)\n navigation(array)\n}", "title": "" }, { "docid": "2354cbd951a382af2bca02eaf9785c28", "score": "0.64132446", "text": "drawNodesRectanglesAndLines() {\r\n this.clearCanvas();\r\n this.determinePaths();\r\n this.drawAllNodes();\r\n //this.drawEntryNodeStar();\r\n this.drawNodeRect(\"red\", this.curNode);\r\n this.drawNodeRect(\"green\", this.secondNode);\r\n\r\n }", "title": "" }, { "docid": "20b2e9630332f3b8180251053e6f136d", "score": "0.6395834", "text": "draw() {\n for (const n of this.nodes) {\n n.draw();\n }\n for (const e of this.edges){\n e.draw();\n }\n\n }", "title": "" }, { "docid": "282b63cf379117e7295bef8d4caf6cca", "score": "0.63920206", "text": "draw() {\n super.draw();\n this.div.style.borderBottomWidth = `${this.height}px`;\n this.div.style.borderRightWidth = `${this.height}px`;\n this.describe(); \n }", "title": "" }, { "docid": "13f19828f86770c9e01873edd819fa90", "score": "0.6390095", "text": "function draw() {\r\n if (canvasValid == false) {\r\n clear(ctx);\r\n\r\n // Add stuff you want drawn in the background all the time here\r\n if (image != null) {\r\n ctx.drawImage(image, 0, 0);\r\n }\r\n\r\n // draw all motor.zuordnungen()\r\n var l = motor.zuordnungen().length;\r\n for (var i = 0; i < l; i++) {\r\n drawshape(ctx, motor.zuordnungen()[i]);\r\n ctx.font = textFont;\r\n ctx.fillStyle = textColor;\r\n ctx.fillText(motor.zuordnungen()[i].baugruppe() + motor.zuordnungen()[i].einzelteil(), motor.zuordnungen()[i].x(), motor.zuordnungen()[i].y()-2);\r\n }\r\n\r\n // draw selection\r\n // right now this is just a stroke along the edge of the selected box\r\n if (motor.selectedZuordnung() != null) {\r\n ctx.strokeStyle = mySelColor;\r\n ctx.lineWidth = mySelWidth;\r\n ctx.strokeRect(motor.selectedZuordnung().x(), \r\n motor.selectedZuordnung().y(), \r\n motor.selectedZuordnung().width(), \r\n motor.selectedZuordnung().height());\r\n }\r\n\r\n // Add stuff you want drawn on top all the time here\r\n\r\n\r\n canvasValid = true;\r\n }\r\n}", "title": "" }, { "docid": "fdee602ca00ceb49bbb915dc55dee61d", "score": "0.6385981", "text": "draw() {\n // Draw in the currently toggled Links\n this.links.forEach((link) => {\n if (\n (link.top && link.category === this.config.topLinkCategory) ||\n (!link.top && link.category === this.config.bottomLinkCategory)\n ) {\n link.show();\n }\n\n if (\n (link.top && this.config.showTopMainLabel) ||\n (!link.top && this.config.showBottomMainLabel)\n ) {\n link.showMainLabel();\n } else {\n link.hideMainLabel();\n }\n\n if (\n (link.top && this.config.showTopArgLabels) ||\n (!link.top && this.config.showBottomArgLabels)\n ) {\n link.showArgLabels();\n } else {\n link.hideArgLabels();\n }\n });\n\n // Now that Links are visible, make sure that all Rows have enough space\n this.rowManager.resizeAll();\n\n // And change the Row resize cursor if compact mode is on\n this.rowManager.rows.forEach((row) => {\n this.config.compactRows\n ? row.draggable.addClass(\"row-drag-compact\")\n : row.draggable.removeClass(\"row-drag-compact\");\n });\n\n // Change token colours based on the current taxonomy, if loaded\n this.taxonomyManager.colour(this.words);\n }", "title": "" }, { "docid": "768a9ba12b0c9490530f54a82b43235c", "score": "0.63756436", "text": "function draw() {\n\tif(!myStart || !myEnd){\n\t\tmissingPointLabel.show();\n\t\tprintButton.style('background-color','red');\n\t\tprintButton.style('color','white');\n\t}else{\n\t\tmissingPointLabel.hide();\n\t\tprintButton.style('background-color','white');\n\t\tprintButton.style('color','black');\n\t}\n\tbackground(220);\n\tif(mouseDown){\n\t\tswitch(currentTool){\n\t\t\tcase toolEnum.Line:\n\t\t\tcurrentObj.moveP2(mouseX,mouseY);\n\t\t\tdrawHelpLines();\n\t\t\tbreak;\n\t\t\tcase toolEnum.Rect:\n\t\t\tcurrentObj.moveP2(mouseX,mouseY);\n\t\t\tdrawHelpLines();\n\t\t\tbreak;\n\t\t\tcase toolEnum.Cirk:\n\t\t\tcurrentObj.setR(dist(currentObj.x,currentObj.y,mouseX,mouseY));\n\t\t\tbreak;\n\t\t\tcase toolEnum.Start:\n\t\t\tmyStart.setR(dist(myStart.x,myStart.y,mouseX,mouseY));\n\t\t\tbreak;\n\t\t\tcase toolEnum.End:\n\t\t\tmyEnd.setR(dist(myEnd.x,myEnd.y,mouseX,mouseY));\n\t\t\tbreak;\n\t\t\tcase toolEnum.Move:\n\t\t\tif(currentObj && currentObj.grabbed){\n\t\t\t\tcurrentObj.grab(mouseX,mouseY);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(netCheckBox.checked()){\n\t\tdrawNet();\n\t}\n\tdrawObjects();\n\tif(myStart != null){\n\t\tmyStart.draw();\n\t}\n\tif(myEnd != null){\n\t\tmyEnd.draw();\n\t}\n\tif(currentTool == toolEnum.Test){\n\t\tdrawTest();\n\t}\n}", "title": "" }, { "docid": "a3d51f921fc2f04e5bfe61f9f2dbe031", "score": "0.6370579", "text": "draw() {\n // Draw all the previous paths saved to the history array\n if(this.drawHistory) {\n this.drawPreviousEdges();\n }\n\n // Draw bounds\n if(this.showBounds && this.bounds != undefined && this.bounds instanceof Bounds) {\n this.drawBounds();\n }\n\n // Set shape fill \n if(this.fillMode && this.isClosed) {\n this.p5.fill(this.currentFillColor.h, this.currentFillColor.s, this.currentFillColor.b, this.currentFillColor.a);\n } else {\n this.p5.noFill();\n }\n\n // Set stroke color\n this.p5.stroke(this.currentStrokeColor.h, this.currentStrokeColor.s, this.currentStrokeColor.b, this.currentStrokeColor.a);\n\n // Draw current edges\n this.drawCurrentEdges();\n\n // Draw all nodes\n if(this.drawNodes) {\n this.drawCurrentNodes();\n }\n }", "title": "" }, { "docid": "f3641f4457335f48124a75502c6b9e1b", "score": "0.636963", "text": "function simplePanel() {\n\n this.Handle = \"simplePanel\";\n\n this.draw = function (context) {\n var ele = new definitionObject();\n var b = new initDraw(context);\n b.upline_pos = [{x:ele.upLine.getPosition()[0].x, y:ele.upLine.getPosition()[0].y}, {x:ele.upLine.getPosition()[1].x + b.widthDifference, y:ele.upLine.getPosition()[1].y},]\n b.downline_pos = [{x:ele.downLine.getPosition()[0].x, y:ele.downLine.getPosition()[0].y}, {x:ele.downLine.getPosition()[1].x+ b.widthDifference, y:ele.downLine.getPosition()[1].y},]\n b.leftline_pos = [{x:ele.leftLine.getPosition()[0].x, y:ele.leftLine.getPosition()[0].y}, {x:ele.leftLine.getPosition()[1].x, y:ele.leftLine.getPosition()[1].y},]\n b.rightline_pos = [{x:ele.rightLine.getPosition()[0].x+ b.widthDifference, y:ele.rightLine.getPosition()[0].y},{x:ele.rightLine.getPosition()[1].x+ b.widthDifference, y:ele.rightLine.getPosition()[1].y},]\n \n b.upArrowline_pos = [{x:b.upline_pos[0].x, y:165}, {x:b.upline_pos[1].x, y:165},]\n b.ulArrowP_pos = [{x:b.upline_pos[0].x, y:175},{x:b.upline_pos[0].x, y:155}]\n b.urArrowP_pos = [{x:b.upline_pos[1].x, y:175},{x:b.upline_pos[1].x, y:155}]\n b.ulTip_pos = {x:b.upline_pos[0].x, y:165};\n b.urTip_pos = {x:b.upline_pos[1].x, y:165};\n\n b.downArrowline_pos = [{x:b.downline_pos[0].x, y:935}, {x:b.downline_pos[1].x, y:935},]\n b.dlArrowP_pos = [{x:b.downline_pos[0].x, y:945},{x:b.downline_pos[0].x, y:925}] \n b.drArrowP_pos = [{x:b.downline_pos[1].x, y:945},{x:b.downline_pos[1].x, y:925}]\n b.dlTip_pos = {x:b.downline_pos[0].x, y:935};\n b.drTip_pos = {x:b.downline_pos[1].x, y:935};\n\n b.rArrowline_pos = [{x:b.rightline_pos[0].x+77, y:b.rightline_pos[0].y}, {x:b.rightline_pos[1].x+77, y:b.rightline_pos[1].y},]\n b.rgupArrowP_pos = [{x:b.rightline_pos[0].x-10+77, y:b.rightline_pos[0].y}, {x:b.rightline_pos[1].x+10+77, y:b.rightline_pos[0].y}]\n b.rgdownArrowP_pos = [{x:b.rightline_pos[1].x-10+77, y:b.rightline_pos[1].y},{x:b.rightline_pos[1].x+10+77, y:b.rightline_pos[1].y}]\n b.rgupTip_pos = {x:b.rightline_pos[0].x+77, y:b.rightline_pos[0].y};\n b.rgdownTip_pos ={x:b.rightline_pos[1].x+77, y:b.rightline_pos[1].y};\n\n\n b.lArrowline_pos = [{x:52, y:b.leftline_pos[0].y}, {x:52, y:b.leftline_pos[1].y},]\n b.lfupArrowP_pos = [{x:40 , y:b.leftline_pos[0].y}, {x:65, y:b.leftline_pos[0].y}]\n b.lfdownArrowP_pos = [{x:40, y:b.leftline_pos[1].y},{x:65, y:b.leftline_pos[1].y}]\n b.lfupTip_pos = {x:52, y:b.leftline_pos[0].y};\n b.lfdownTip_pos ={x:52, y:b.leftline_pos[1].y};\n \n \n b.upletter = {x:ele.upmainGroup.getPosition().x+b.widthDifference/2,y:ele.upmainGroup.getPosition().y}\n b.downletter.x = ele.upmainGroup.getPosition().x+b.widthDifference/2;\n b.rightletter.x = ele.rightmainGroup.getPosition().x + b.widthDifference\n\n\n b.ruRectmove = {x:ele.ruRect.getPosition().x + b.widthDifference, y:ele.ruRect.getPosition().y};\n b.rbRectmove = {x:ele.rbRect.getPosition().x + b.widthDifference, y:ele.rbRect.getPosition().y};\n b.luRectmove = {x:ele.luRect.getPosition().x, y:ele.luRect.getPosition().y};\n b.lbRectmove = {x:ele.lbRect.getPosition().x, y:ele.lbRect.getPosition().y};\n\n b.BULine = [{x:ele.BULine.getPosition()[0].x,y:ele.BULine.getPosition()[0].y},{x:ele.BULine.getPosition()[1].x+b.widthDifference,y:ele.BULine.getPosition()[1].y}]\n\n b.BLLine = [{x:ele.BLLine.getPosition()[0].x,y:ele.BLLine.getPosition()[0].y},{x:ele.BLLine.getPosition()[1].x,y:ele.BLLine.getPosition()[1].y}]\n \n b.BRLine = [{x:ele.BRLine.getPosition()[0].x+b.widthDifference,y:45},{x:ele.BRLine.getPosition()[1].x+b.widthDifference,y:75}]\n \n b.BDLine = [{x:ele.BDLine.getPosition()[0].x,y:ele.BDLine.getPosition()[0].y},{x:ele.BDLine.getPosition()[1].x+b.widthDifference,y:ele.BDLine.getPosition()[1].y}]\n \n \n b.draw();\n };\n\n this.convertToPNG = function () {\n var d = new Date();\n function download(\n filename, // string\n blob // Blob\n ) {\n if (window.navigator.msSaveOrOpenBlob) {\n window.navigator.msSaveBlob(blob, filename);\n } else {\n const elem = window.document.createElement('a');\n elem.href = window.URL.createObjectURL(blob);\n elem.download = filename;\n document.body.appendChild(elem);\n elem.click();\n document.body.removeChild(elem);\n }\n }\n \n var svg = document.querySelector('svg');\n var data = (new XMLSerializer()).serializeToString(svg);\n var canvas = document.createElement('canvas');\n \n canvg(canvas, data, {\n renderCallback: function () {\n canvas.toBlob(function (blob) {\n download(`${d.getDate()}day-${d.getHours()}hour/${d.getMinutes()}min.png`, blob);\n });\n }\n });\n return \"\";\n };\n\n this.cleanUp = function () {\n };\n\n this.reset = function () {\n\n };\n }", "title": "" }, { "docid": "423e37b1b2c4b8f1b76f59557c6213d8", "score": "0.63370305", "text": "function drawAll() {\n\tsetMaxCodeArea();\n\tdrawSeparateLineBlocks();\n\tdrawConnectors();\n\tmodifyStyles();\n}", "title": "" }, { "docid": "bb305915fd837a8b59eeab998cf738b1", "score": "0.63330644", "text": "renderUI () {\n let indexMin = this.currentIndexMin;\n let indexMax = this.currentIndexMax;\n\n this.ctx.clearRect(0, 0, this.ctxWidth, this.bigCtxHeight + this.smallCtxHeight + this.canvasIndent + 30);\n this.ctx.save();\n this.ctx.lineWidth = 2;\n var data = this.renderGraphList(this.visibleNames, this.x, this.y, this.ctxWidth, this.bigCtxHeight, indexMin, indexMax, 4, this.currentMultiplierBig);\n data.targetIndexMin = this.targetIndexMin;\n data.targetIndexMax = this.targetIndexMax;\n data.currentMultiplier = this.currentMultiplierBig;\n data.targetMultiplier = this.targetMultiplierBig;\n this.inscriptionRender.setData(data);\n this.inscriptionRender.repaint();\n this.ctx.restore();\n\n this.renderGraphList(this.visibleNames, this.x, this.smallY, this.ctxWidth, this.smallCtxHeight, 0, this.xAxis.length - 1, 2);\n }", "title": "" }, { "docid": "208b4c8785990e9fb743efc458951853", "score": "0.6324265", "text": "drawAll() {\n this.drawGrid();\n this.drawRaster();\n this.drawRaster(\"temp\");\n this.drawCursor();\n this.drawSelect();\n }", "title": "" }, { "docid": "96020fd89fe8f658ba3ea714f5722704", "score": "0.63199043", "text": "draw() {\n new Clearer(this.fields[0], this.fields[this.fields.length - 1]).clearArea();\n for (i = 0; i < this.fields.length; i++)\n this.stones[i].draw(this.fields[i]);\n this.drawResult(null);\n this.drawMenu();\n }", "title": "" }, { "docid": "ca14d527102060f5a0e651631ba04ab4", "score": "0.6274823", "text": "function draw() {\n \tbackground(0);\n \tfor (var i = 0; i < ways.length; i++) {\n ways[i].show();\n }\n for (var i = 0; i < nodes.length; i++) {\n \tnodes[i].show();\n }\n \texamplep.update();\n}", "title": "" }, { "docid": "f2c71d854531dc98c0643e01e5c2c02e", "score": "0.627066", "text": "draw() {\n super.draw();\n this.describe(this.height, this.width);\n }", "title": "" }, { "docid": "f2c71d854531dc98c0643e01e5c2c02e", "score": "0.627066", "text": "draw() {\n super.draw();\n this.describe(this.height, this.width);\n }", "title": "" }, { "docid": "bfe0291846aef467bfb5b81dafab0bfa", "score": "0.6255783", "text": "function draw(){\n var context = this;\n\n var blocks = this.children;\n\n for(var i = 0, block; block = blocks[i++];){\n block.draw();\n }\n\n context.element.style.width = context.calculateWidth() + 'px';\n }", "title": "" }, { "docid": "7cb6a4df20b5e577f574c906e615fefd", "score": "0.6254377", "text": "function draw() {\n\ttextSize(FONT['size']);\n\ttextFont(FONT['typeface']);\n\ttextAlign(CENTER,CENTER);\n\tfill(darkGray);\n\tnoStroke();\n\tfor (var i=0;i<remaining['p1'].length; i++) {\n\t\trect(counters['palette'][i][0]-12,counters['palette'][i][1]-12,20,18);\n\t};\n\tfill(white);\n\tfor (var k=0;k<allTokenTypes.length; k++) {\n\t\tvar j = allTokenTypes[k];\n\t\ttext(parseInt(remaining['p1'][j]), counters['palette'][k][0], counters['palette'][k][1]);\n\t};\n\tupdate(mouseX,mouseY);\n\t//testing\n}", "title": "" }, { "docid": "95dc7152e2e250baf62b69485082505b", "score": "0.6251508", "text": "function drawElements(elements){\n\tfor(item in items){\n\t\tdrawRandomItem(item);\n\t}\n}", "title": "" }, { "docid": "a19e6a7ac52d3ecb512d8f19e25798ff", "score": "0.6250289", "text": "function DrawChessProbabilites() {\n var hudRoot;\n\n\tfor(panel=$.GetContextPanel();panel!=null;panel=panel.GetParent()){\n hudRoot = panel;\n }\n \n\t\n var probability_panel = '<Panel id=\"level_stats_panel\" style=\"width: 290px; height: 149px; position:256px 934px 0px; background-color: gradient( linear, 0% 0%, 0% 100%, from( rgba(68, 68, 68, 0.95) ), to( rgba(22, 22, 22, 0.95) ) ); border-radius: 4px 4px 0px 0px; z-index: -200;\" />';\n hudRoot.BCreateChildren(probability_panel);\n\n var level_probability_panel = '<Panel id =\"chess_probability\" style=\"width: 100%; flow-children: down; vertical-align: top; margin-top: 6px;\"/>';\n find_dota_hud_element('level_stats_panel').BCreateChildren(level_probability_panel);\n\n var current_level_probability_panel = '<Panel id=\"current_level_probability\" style=\"width: 100%; flow-children: none;\" />';\n find_dota_hud_element('chess_probability').BCreateChildren(current_level_probability_panel);\n\n //Draw slashes\n for (var i = 1; i <= 4; i++) {\n var x_position = i * 18 + ((i-1) * 2.5);\n var slash = '<Label text=\"/\" style=\"font-size: 20px; width: 2.5%; position: ' + x_position + '% 0% 0%; text-align: center; font-family: Radiance,FZLanTingHei-R-GBK,TH Sarabun New,YDYGO 540,Gulim,MingLiU; text-shadow: 1px 1px 1px 1.0 #000000ff; color: #bbb;\"/>';\n find_dota_hud_element('current_level_probability').BCreateChildren(slash);\n }\n \n //Colours for the text for 1-cost, 2-cost etc.\n var colours = ['#bbb', '#bbbbff', '#5194f7', '#ff00ff', '#ff8800'];\n\n //Draw current level probabilities\n for (var i = 0; i <= 4; i++) {\n var x_position = i * 20.5;\n\n var probability_label = '<Label text=\"\" id=\"current_chess_probabilities' + i + '\" style=\"font-size: 20px; width: 18%; position: ' + x_position + '% 0% 0%; text-align: center; color: ' + colours[i] + '; font-family: Radiance,FZLanTingHei-R-GBK,TH Sarabun New,YDYGO 540,Gulim,MingLiU; text-shadow: 1px 1px 1px 1.0 #000000ff;\"/>';\n find_dota_hud_element('current_level_probability').BCreateChildren(probability_label);\n }\n\n var next_level_panel = '<Panel id=\"next_panel\" style=\"width: 100%; flow-children: down; margin-top: 5px;\" />';\n var next_level_text_panel = '<Panel id=\"next_level_text\" style=\"width: 100%;\" />';\n var next_level_probability_holder = '<Panel id=\"next_level_probability_holder\" style=\"width: 100%; flow-children: none; opacity: 0.7;\" />';\n var next_level_probability_panel = '<Panel id=\"next_level_probability\" style=\"flow-children: none; width: 80%; position: 10% 0% 0%;\"/>';\n find_dota_hud_element('chess_probability').BCreateChildren(next_level_panel);\n find_dota_hud_element('next_panel').BCreateChildren(next_level_text_panel);\n find_dota_hud_element('next_panel').BCreateChildren(next_level_probability_holder);\n find_dota_hud_element('next_level_probability_holder').BCreateChildren(next_level_probability_panel);\n \n var next_level_text_label = '<Label text=\"NEXT LEVEL:\" style=\"font-size: 14px; width: 100%; text-align: center; font-family: Radiance,FZLanTingHei-R-GBK,TH Sarabun New,YDYGO 540,Gulim,MingLiU; text-shadow: 1px 1px 1px 1.0 #000000ff; color: #ffffff; font-weight: bold; letter-spacing: 2px;\"/>'\n find_dota_hud_element('next_level_text').BCreateChildren(next_level_text_label);\n\n //Draw slashes\n for (var i = 1; i <= 4; i++) {\n var x_position = i * 18 + ((i-1) * 2.5);\n var slash = '<Label text=\"/\" style=\"font-size: 18px; width: 2.5%; position: ' + x_position + '% 0% 0%; text-align: center; font-family: Radiance,FZLanTingHei-R-GBK,TH Sarabun New,YDYGO 540,Gulim,MingLiU; text-shadow: 1px 1px 1px 1.0 #000000ff; color: #bbb;\"/>';\n find_dota_hud_element('next_level_probability').BCreateChildren(slash);\n }\n\n for (var i = 0; i <= 4; i++) {\n var x_position = i * 20.5;\n\n var probability_label = '<Label text=\"\" id=\"next_chess_probabilities' + i + '\" style=\"font-size: 18px; width: 18%; position: ' + x_position + '% 0% 0%; text-align: center; color: ' + colours[i] + '; font-family: Radiance,FZLanTingHei-R-GBK,TH Sarabun New,YDYGO 540,Gulim,MingLiU; text-shadow: 1px 1px 1px 1.0 #000000ff;\"/>';\n find_dota_hud_element('next_level_probability').BCreateChildren(probability_label);\n }\n\n var xp_required_to_level_panel = '<Panel id=\"xp-required-to-level\" style=\"width: 100%; vertical-align: bottom; margin-bottom: 6px;\" />';\n find_dota_hud_element('level_stats_panel').BCreateChildren(xp_required_to_level_panel);\n\n var xp_required_to_level_label = '<Label text=\"\" id=\"xp-required-text\" style=\"font-size: 14px; width: 100%; text-align: center; font-family: Radiance,FZLanTingHei-R-GBK,TH Sarabun New,YDYGO 540,Gulim,MingLiU; text-shadow: 1px 1px 1px 1.0 #000000ff; color: #ffffff; font-weight: bold; letter-spacing: 2px; text-transform: uppercase;\" />'\n find_dota_hud_element('xp-required-to-level').BCreateChildren(xp_required_to_level_label);\n}", "title": "" }, { "docid": "3117beea6f81e29d287234d8483a2d9e", "score": "0.6220379", "text": "render() {\n\t\tstroke(0);\n\n\t\t//Creates vertical grid lines for how many divisions there are\n\t\tfor(let i = 0; i < width; i += this.length.horizontal) {\n\t\t\t//The line position is floored to keep the image clear\n\t\t\tline(floor(i), 0, floor(i), height);\n\t\t}\n\n\t\t//Creates horizontal grid lines for how many divisions there are\n\t\tfor(let i = 0; i < height; i += this.length.vertical) {\n\t\t\t//The line position is floored to keep the image clear\n\t\t\tline(0, floor(i), width, floor(i));\n\t\t}\n\t}", "title": "" }, { "docid": "025c4db80f7f452d4ecba4dff7562c23", "score": "0.6174285", "text": "draw() {\n\t}", "title": "" }, { "docid": "c89dd1470a8f8306407bcaa8fced5ce6", "score": "0.6173854", "text": "drawOrganList(){\n ctx.save();\n //Rectangle to hold list\n ctx.fillStyle = this.buttonStyle;\n ctx.fillRect(310, 620, 880, 170);\n\n ctx.fillStyle = \"#cccccc\";\n //left arrow\n ctx.beginPath();\n ctx.moveTo(315, 705);\n ctx.lineTo(335, 655);\n ctx.lineTo(335, 755);\n ctx.fill();\n\n //right arrow\n ctx.beginPath();\n ctx.moveTo(1185, 705);\n ctx.lineTo(1165, 655);\n ctx.lineTo(1165, 755);\n ctx.fill();\n\n //Draw seperator bars\n for(var x = 0; x < 5; x++){\n ctx.fillStyle = \"#272727\";\n ctx.fillRect(145 + (200 * (x+1)), 635, 10, 150);\n }\n\n //First, we make sure that the array exists\n if(player.inventoryList[this.selectedOrganType]){\n //If there are less than 4 of a given organ type, only print that many,\n //If there's 4 or more of the organ type, print 4 at a time\n if(player.inventoryList[this.selectedOrganType].length < 4){this.max = player.inventoryList[this.selectedOrganType].length;}\n else{this.max = 4;}\n }\n else{\n this.max = 0;\n }\n\n if(this.selectedOrganType == 3){\n //Print out the name and description of the owned organs\n for(var x = 0; x < this.max; x++){\n ctx.font = \"20px Arial\";\n ctx.fillStyle = \"#cccccc\";\n //Print the name of the organ\n ctx.fillText(items[player.inventoryList[this.selectedOrganType][x + this.organScrollIndex]].name, this.creatureListWidth + 160 + (200 * x), 650);\n //ctx.fillText(items.list[player.inventoryList[this.selectedOrganType][x + this.organScrollIndex]][1], this.creatureListWidth + 160 + (200 * x), 650);\n ctx.font = \"10px Arial\";\n ctx.fillStyle = \"#999999\";\n ctx.fillText(x + this.organScrollIndex, this.creatureListWidth + 160 + (200 * x), 780);\n ctx.font = \"15px Courier\";\n ctx.fillStyle = \"#aaaaaa\";\n //Print the flavor text for the organ\n drawMultipleLines(items[player.inventoryList[this.selectedOrganType][x + this.organScrollIndex]].description, 20, 20, this.creatureListWidth + 160 + (200 * x), 675);\n //drawMultipleLines(items.list[player.inventoryList[this.selectedOrganType][x + this.organScrollIndex]][3], 20, 20, this.creatureListWidth + 160 + (200 * x), 675);\n ctx.font = \"20px Arial\";\n ctx.fillStyle = \"#cccccc\";\n //Draw the \"EQUIP\" buttons\n ctx.fillText(\"EQUIP\", 420 + (200 * x), 780);\n }\n }\n else{\n //Print out the name and description of the owned organs\n for(var x = 0; x < this.max; x++){\n ctx.font = \"20px Arial\";\n ctx.fillStyle = \"#cccccc\";\n //Print the name of the organ\n ctx.fillText(masterInventoryList[this.selectedOrganType][player.inventoryList[this.selectedOrganType][x + this.organScrollIndex]].name, this.creatureListWidth + 160 + (200 * x), 650);\n ctx.font = \"10px Arial\";\n ctx.fillStyle = \"#999999\";\n ctx.fillText(x + this.organScrollIndex, this.creatureListWidth + 160 + (200 * x), 780);\n ctx.font = \"15px Courier\";\n ctx.fillStyle = \"#aaaaaa\";\n //Print the flavor text for the organ\n drawMultipleLines(masterInventoryList[this.selectedOrganType][player.inventoryList[this.selectedOrganType][x + this.organScrollIndex]].description, 20, 20, this.creatureListWidth + 160 + (200 * x), 675);\n ctx.font = \"20px Arial\";\n ctx.fillStyle = \"#cccccc\";\n //Draw the \"EQUIP\" buttons\n ctx.fillText(\"EQUIP\", 420 + (200 * x), 780);\n }\n }\n\n ctx.restore();\n }", "title": "" }, { "docid": "67b79e7612677f6081ec98d5d820d378", "score": "0.61709625", "text": "function draw(){\r\n\r\n\t\t\t\tfor(var i=0; i<size; ++i)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar marge = getMarge(i);\r\n\t\t\t\t\t$(\".piece-\"+i,$game).css({\r\n\t\t\t\t\t\tmarginLeft : marge.x+\"px\",\r\n\t\t\t\t\t\tmarginTop : marge.y+\"px\"\r\n\t\t\t\t\t})\r\n\t\t\t\t}\r\n\t\t\t}", "title": "" }, { "docid": "f47afc69035a7d4deeb543c19adeac77", "score": "0.6166494", "text": "redraw(){\n \tthis.seg_group.remove()\n\t\tthis.seg_group= create_svg_elem(\"g\")\n\t\tthis.seg_group.classList.add(\"seg-group\")\n\t\tthis.segments.forEach(seg => seg.appendTo(this.seg_group))\n\t\tthis.html_elem.append(this.seg_group)\n\n\t\tthis.pt_group.remove()\n\t\tthis.pt_group= create_svg_elem(\"g\")\n\t\tthis.pt_group.classList.add(\"point-group\")\n\t\tthis.points.forEach(pt => pt.appendTo(this.pt_group))\n\t\tthis.html_elem.append(this.pt_group)\n\n\t\tlet center_loc= get_center(this.points.map(pt => pt.loc))\n\t\tthis.center.moveTo(center_loc)\n\t}", "title": "" }, { "docid": "fd3a6eec7574f9a6bb1a736619e7a66b", "score": "0.61636233", "text": "function initDraw(context) {\n \n\n var simpleParameter = {};\n simpleParameter = context.Parameters.filter((parameter, i) => { \n return parameter.ParameterName === 'simeplePanel';\n })\n this.parameter = simpleParameter[0]\n\n\n var ele = new definitionObject();\n\n this.width = this.parameter.value[0].width\n this.height = this.parameter.value[0].height;\n this.centerNote = this.parameter.value[1].centerNote;\n \n // parameter calculation\n this.calHeight = 10 * this.height;\n this.rate = oriHeight/this.calHeight;\n this.calWidth = 10 * this.width * this.rate;\n this.widthDifference = this.calWidth - oriWidth;\n\n this.upWidth = this.width;\n this.downWidth = this.width;\n this.leftHeight = this.height;\n this.rightHeight = this.height;\n\n \n this.dis_upWidth = this.width;\n this.dis_downWidth = this.width;\n this.dis_leftHeight = this.height;\n this.dis_rightHeight = this.height;\n \n\n this.init2d_pos = [{x:-10000, y:0}, {x:-10000 , y:0},]\n this.initSignle_pos = {x:-10000, y:-10000};\n // main line \n this.upline_pos = ele.upLine.getPosition()\n this.downline_pos =ele.downLine.getPosition()\n this.leftline_pos = ele.leftLine.getPosition()\n this.rightline_pos = ele.rightLine.getPosition()\n\n // main arrow\n this.upArrowline_pos = ele.upArrowline.getPosition()\n this.ulArrowP_pos = ele.ulArrowP.getPosition()\n this.urArrowP_pos = ele.urArrowP.getPosition()\n this.ulTip_pos = ele.ulTip.getPosition()\n this.urTip_pos = ele.urTip.getPosition()\n\n this.downArrowline_pos = [{x:this.downline_pos[0].x, y:935}, {x:this.downline_pos[1].x, y:935},]\n this.dlArrowP_pos = [{x:this.downline_pos[0].x, y:945},{x:this.downline_pos[0].x, y:925}] \n this.drArrowP_pos = [{x:this.downline_pos[1].x, y:945},{x:this.downline_pos[1].x, y:925}]\n this.dlTip_pos = {x:this.downline_pos[0].x, y:935};\n this.drTip_pos = {x:this.downline_pos[1].x, y:935};\n\n this.rArrowline_pos = [{x:this.rightline_pos[0].x+77, y:this.rightline_pos[0].y}, {x:this.rightline_pos[1].x+77, y:this.rightline_pos[1].y},]\n this.rgupArrowP_pos = [{x:this.rightline_pos[0].x-10+77, y:this.rightline_pos[0].y}, {x:this.rightline_pos[1].x+10+77, y:this.rightline_pos[0].y}]\n this.rgdownArrowP_pos = [{x:this.rightline_pos[1].x-10+77, y:this.rightline_pos[1].y},{x:this.rightline_pos[1].x+10+77, y:this.rightline_pos[1].y}]\n this.rgupTip_pos = {x:this.rightline_pos[0].x+77, y:this.rightline_pos[0].y};\n this.rgdownTip_pos ={x:this.rightline_pos[1].x+77, y:this.rightline_pos[1].y};\n\n\n this.lArrowline_pos =ele.lArrowline.getPosition();\n this.lfupArrowP_pos = ele.lfupArrowP.getPosition();\n this.lfdownArrowP_pos = ele.lfdownArrowP.getPosition();\n this.lfupTip_pos = ele.lfupTip.getPosition();\n this.lfdownTip_pos =ele.lfdownTip.getPosition();\n // group\n this.upletter = ele.upmainGroup.getPosition()\n this.downletter = ele.downmainGroup.getPosition();\n this.rightletter =ele.rightmainGroup.getPosition();\n this.leftletter = ele.leftmainGroup.getPosition()\n\n this.CLUW_Group = ele.CLUW_Group.getPosition();\n this.CRUW_Group = ele.CRUW_Group.getPosition();\n this.CLBW_Group = ele.CLBW_Group.getPosition();\n this.CRBW_Group = ele.CRBW_Group.getPosition();\n \n this.CLUH_Group = ele.CLUH_Group.getPosition();\n this.CLBH_Group = ele.CLBH_Group.getPosition();\n this.CRUH_Group = ele.CRUH_Group.getPosition();\n this.CRBH_Group = ele.CRBH_Group.getPosition();\n\n this.RLUW_Group = ele.RLUW_Group.getPosition();\n this.RRUW_Group = ele.RRUW_Group.getPosition();\n this.RLBW_Group = ele.RLBW_Group.getPosition();\n this.RRBW_Group = ele.RRBW_Group.getPosition();\n \n this.RLUH_Group = ele.RLUH_Group.getPosition();\n this.RLBH_Group = ele.RLBH_Group.getPosition();\n this.RRUH_Group = ele.RRUH_Group.getPosition();\n this.RRBH_Group = ele.RRBH_Group.getPosition();\n \n\n // rect\n this.ruRectmove = {x:ele.ruRect.getPosition().x, y:ele.ruRect.getPosition().y};\n this.rbRectmove = {x:ele.rbRect.getPosition().x, y:ele.rbRect.getPosition().y};\n this.luRectmove = {x:ele.luRect.getPosition().x, y:ele.luRect.getPosition().y};\n this.lbRectmove = {x:ele.lbRect.getPosition().x, y:ele.lbRect.getPosition().y};\n\n this.ruRectmove1 = {x:ele.ruRect1.getPosition().x, y:ele.ruRect1.getPosition().y};\n this.rbRectmove1 = {x:ele.rbRect1.getPosition().x, y:ele.rbRect1.getPosition().y};\n this.luRectmove1 = {x:ele.luRect1.getPosition().x, y:ele.luRect1.getPosition().y};\n this.lbRectmove1 = {x:ele.lbRect1.getPosition().x, y:ele.lbRect1.getPosition().y};\n\n // letters\n this.frontletterMove = {x:303 + (this.widthDifference)/2 - 10*4/2, y:115};\n this.backletterMove = {x:303 + (this.widthDifference)/2 - 10*4/2, y:20};\n this.centernoteMove = {x:297 + (this.calWidth-oriWidth)/2-10* ( this.centerNote.length)/2 ,y:320};\n\n\n // corner && radius\n\n this.CL_upArrowline = ele.CL_upArrowline.getPosition();\n this.CL_ulArrowP = ele.CL_ulArrowP.getPosition();\n this.CL_ulTip = ele.CL_ulTip.getPosition();\n this.CL_urTip = ele.CL_urTip.getPosition();\n \n this.CR_upArrowline = ele.CR_upArrowline.getPosition();\n this.CR_ulArrowP = ele.CR_ulArrowP.getPosition();\n this.CR_ulTip = ele.CR_ulTip.getPosition();\n this.CR_urTip = ele.CR_urTip.getPosition();\n \n // down\n this.CL_downArrowline = ele.CL_downArrowline.getPosition();\n this.CL_dlArrowP = ele.CL_dlArrowP.getPosition();\n this.CL_dlTip = ele.CL_dlTip.getPosition();\n this.CL_drTip = ele.CL_drTip.getPosition();\n \n this.CR_downArrowline = ele.CR_downArrowline.getPosition();\n this.CR_dlArrowP = ele.CR_dlArrowP.getPosition();\n this.CR_dlTip = ele.CR_dlTip.getPosition();\n this.CR_drTip = ele.CR_drTip.getPosition();\n \n // left\n this.CU_lArrowline = ele.CU_lArrowline.getPosition();\n this.CU_lfupArrowP = ele.CU_lfupArrowP.getPosition();\n this.CU_lfupTip = ele.CU_lfupTip.getPosition();\n this.CU_lfdownTip = ele.CU_lfdownTip.getPosition();\n \n this.CD_lArrowline = ele.CD_lArrowline.getPosition();\n this.CD_lfdownArrowP = ele.CD_lfdownArrowP.getPosition();\n this.CD_lfupTip = ele.CD_lfupTip.getPosition();\n this.CD_lfdownTip = ele.CD_lfdownTip.getPosition();\n \n // right\n this.CU_rArrowline = ele.CU_rArrowline.getPosition();\n this.CU_rgupArrowP = ele.CU_rgupArrowP.getPosition()\n this.CU_rgupTip = ele.CU_rgupTip.getPosition();\n this.CU_rgdownTip = ele.CU_rgdownTip.getPosition();\n \n this.CD_rArrowline = ele.CD_rArrowline.getPosition();\n this.CD_rgdownArrowP = ele.CD_rgdownArrowP.getPosition();\n this.CD_rgupTip = ele.CD_rgupTip.getPosition();\n this.CD_rgdownTip = ele.CD_rgdownTip.getPosition();\n\n // Radius\n\n this.RL_upArrowline = ele.RL_upArrowline.getPosition();\n this.RL_ulArrowP = ele.RL_ulArrowP.getPosition();\n this.RL_ulTip = ele.RL_ulTip.getPosition();\n this.RL_urTip = ele.RL_urTip.getPosition();\n \n this.RR_upArrowline = ele.RR_upArrowline.getPosition();\n this.RR_ulArrowP = ele.RR_ulArrowP.getPosition();\n this.RR_ulTip = ele.RR_ulTip.getPosition();\n this.RR_urTip = ele.RR_urTip.getPosition();\n \n // down\n this.RL_downArrowline = ele.RL_downArrowline.getPosition();\n this.RL_dlArrowP = ele.RL_dlArrowP.getPosition();\n this.RL_dlTip = ele.RL_dlTip.getPosition();\n this.RL_drTip = ele.RL_drTip.getPosition();\n \n this.RR_downArrowline = ele.RR_downArrowline.getPosition();\n this.RR_dlArrowP = ele.RR_dlArrowP.getPosition();\n this.RR_dlTip = ele.RR_dlTip.getPosition();\n this.RR_drTip = ele.RR_drTip.getPosition();\n \n // left\n this.RU_lArrowline = ele.RU_lArrowline.getPosition();\n this.RU_lfupArrowP = ele.RU_lfupArrowP.getPosition();\n this.RU_lfupTip = ele.RU_lfupTip.getPosition();\n this.RU_lfdownTip = ele.RU_lfdownTip.getPosition();\n \n this.RD_lArrowline = ele.RD_lArrowline.getPosition();\n this.RD_lfdownArrowP = ele.RD_lfdownArrowP.getPosition();\n this.RD_lfupTip = ele.RD_lfupTip.getPosition();\n this.RD_lfdownTip = ele.RD_lfdownTip.getPosition();\n \n // right\n this.RU_rArrowline = ele.RU_rArrowline.getPosition();\n this.RU_rgupArrowP = ele.RU_rgupArrowP.getPosition();\n this.RU_rgupTip = ele.RU_rgupTip.getPosition();\n this.RU_rgdownTip = ele.RU_rgdownTip.getPosition();\n \n this.RD_rArrowline = ele.RD_rArrowline.getPosition();\n this.RD_rgdownArrowP = ele.RD_rgdownArrowP.getPosition();\n this.RD_rgupTip = ele.RD_rgupTip.getPosition();\n this.RD_rgdownTip = ele.RD_rgdownTip.getPosition();\n \n // = = = = = = = left outage = = = = = = = == =\n\n \n this.LLL_E_dot_Line_1 = ele.LLL_E_dot_Line_1.getPosition();\n this.LLL_E_dot_Line_2 = ele.LLL_E_dot_Line_2.getPosition();\n this.L_Elbow_1 = ele.L_Elbow_1.getPosition();\n this.L_Elbow_2 = ele.L_Elbow_2.getPosition();\n\n // = = = = = = = == = right outage = = = = = = == = =\n\n this.RLL_E_dot_Line_1 = ele.RLL_E_dot_Line_1.getPosition();\n this.RLL_E_dot_Line_2 = ele.RLL_E_dot_Line_2.getPosition();\n this.R_Elbow_1 = ele.R_Elbow_1.getPosition();\n this.R_Elbow_2 = ele.R_Elbow_2.getPosition();\n\n \n // = = = = Notch\n this.extra_p1 = ele.extra_p1.getPosition();\n this.extra_p2 = ele.extra_p2.getPosition();\n this.extra_p3 = ele.extra_p3.getPosition();\n this.extra_p4 = ele.extra_p4.getPosition();\n this.extra_p5 = ele.extra_p5.getPosition();\n this.extra_p6 = ele.extra_p6.getPosition();\n this.extra_p7 = ele.extra_p7.getPosition();\n this.extra_p8 = ele.extra_p8.getPosition();\n\n // = = = = = = Joints = = = = = = = \n\n this.BULine = ele.BULine.getPosition()\n this.BLLine = ele.BLLine.getPosition()\n this.BRLine = ele.BRLine.getPosition()\n this.BDLine = ele.BDLine.getPosition()\n\n this.LM_dot = ele.LM_dot.getPosition();\n this.RM_dot = ele.RM_dot.getPosition();\n\n\n\n // = = = = == = = Hole = = = = = = = \n // single\n this.singleCircle = ele.singleCircle.getPosition();\n\n this.SL_upArrowline = ele.SL_upArrowline.getPosition();\n this.SL_ulArrowP = ele.SL_ulArrowP.getPosition();\n this.SL_ulTip = ele.SL_ulTip.getPosition();\n this.SL_urTip = ele.SL_urTip.getPosition();\n this.SW_group = ele.SW_group.getPosition();\n\n\n this.SU_lArrowline = ele.SU_lArrowline.getPosition();\n this.SU_lfupArrowP = ele.SU_lfupArrowP.getPosition();\n this.SU_lfupTip = ele.SU_lfupTip.getPosition();\n this.SU_lfdownTip = ele.SU_lfdownTip.getPosition();\n this.SH_group = ele.SH_group.getPosition();\n \n this.circleDiameter = {x:-900000,y:-70000000};\n \n // double\n this.doubleCircle = ele.doubleCircle.getPosition()\n\n this.SDL_upArrowline = ele.SDL_upArrowline.getPosition();\n this.SDL_ulArrowP = ele.SDL_ulArrowP.getPosition();\n this.SDL_ulTip = ele.SDL_ulTip.getPosition();\n this.SDL_urTip = ele.SDL_urTip.getPosition();\n this.SDW_group = ele.SDW_group.getPosition();\n\n this.SDU_lArrowline = ele.SDU_lArrowline.getPosition();\n this.SDU_lfupArrowP = ele.SDU_lfupArrowP.getPosition();\n this.SDU_lfupTip = ele.SDU_lfupTip.getPosition();\n this.SDU_lfdownTip = ele.SDU_lfdownTip.getPosition();\n this.SDH_group = ele.SDH_group.getPosition();\n\n // = = = = = U nortch\n this.UNcircle = this.initSignle_pos;\n this.UNrect = ele.UNrect.getPosition();\n // this.UN_upline = ele.UN_upline.getPosition()\n // this.UN_downline = ele.UN_downline.getPosition()\n\n\n\n\n this.draw =function () {\n\n var shape = new definitionObject();\n// mainline\n shape.upLine.drawPath(this.upline_pos);\n shape.downLine.drawPath(this.downline_pos);\n shape.leftLine.drawPath(this.leftline_pos);\n shape.rightLine.drawPath(this.rightline_pos);\n// arrow\n shape.upArrowline.drawPath(this.upArrowline_pos)\n shape.ulArrowP.drawPath(this.ulArrowP_pos)\n shape.urArrowP.drawPath(this.urArrowP_pos)\n shape.ulTip.drawArrow(this.ulTip_pos)\n shape.urTip.drawArrow(this.urTip_pos)\n\n shape.downArrowline.drawPath(this.downArrowline_pos)\n shape.dlArrowP.drawPath(this.dlArrowP_pos)\n shape.drArrowP.drawPath(this.drArrowP_pos)\n shape.dlTip.drawArrow(this.dlTip_pos)\n shape.drTip.drawArrow(this.drTip_pos)\n\n\n shape.rArrowline.drawPath(this.rArrowline_pos)\n shape.rgupArrowP.drawPath(this.rgupArrowP_pos)\n shape.rgdownArrowP.drawPath(this.rgdownArrowP_pos)\n shape.rgupTip.drawArrow(this.rgupTip_pos)\n shape.rgdownTip.drawArrow(this.rgdownTip_pos)\n\n shape.lArrowline.drawPath(this.lArrowline_pos)\n shape.lfupArrowP.drawPath(this.lfupArrowP_pos)\n shape.lfdownArrowP.drawPath(this.lfdownArrowP_pos)\n shape.lfupTip.drawArrow(this.lfupTip_pos)\n shape.lfdownTip.drawArrow(this.lfdownTip_pos)\n\n\n// group\n shape.upmainGroup.moveGroup(this.upletter)\n shape.downmainGroup.moveGroup(this.downletter)\n shape.rightmainGroup.moveGroup(this.rightletter)\n shape.leftmainGroup.moveGroup(this.leftletter)\n// rect\n shape.ruRect.moveRect(this.ruRectmove)\n shape.rbRect.moveRect(this.rbRectmove)\n shape.luRect.moveRect(this.luRectmove)\n shape.lbRect.moveRect(this.lbRectmove)\n\n shape.ruRect1.moveRect(this.ruRectmove1)\n shape.rbRect1.moveRect(this.rbRectmove1)\n shape.luRect1.moveRect(this.luRectmove1)\n shape.lbRect1.moveRect(this.lbRectmove1)\n// letter\n shape.frontletter.moveletter(this.frontletterMove)\n shape.backletter.moveletter(this.backletterMove)\n shape.centerNote.moveletter(this.centernoteMove)\n shape.centerNote.changeletter(this.centerNote)\n\n \n if(this.dis_upWidth.n%this.dis_upWidth.d == 0) {\n shape.up_Widthletter.changeletter('' + parseInt(this.dis_upWidth.n/this.dis_upWidth.d));\n } else {\n shape.up_Widthletter.changeletter(''+parseInt(this.dis_upWidth.n/this.dis_upWidth.d)+ '-'+this.dis_upWidth.n%this.dis_upWidth.d + '/' + this.dis_upWidth.d);\n }\n\n if(this.dis_downWidth.n%this.dis_downWidth.d == 0) {\n shape.down_Widthletter.changeletter('' + parseInt(this.dis_downWidth.n/this.dis_downWidth.d));\n } else {\n shape.down_Widthletter.changeletter(''+parseInt(this.dis_downWidth.n/this.dis_downWidth.d)+ '-'+this.dis_downWidth.n%this.dis_downWidth.d + '/' + this.dis_downWidth.d);\n }\n \n\n if(this.dis_leftHeight.n%this.dis_leftHeight.d == 0) {\n shape.left_Heightletter.changeletter('' + parseInt(this.dis_leftHeight.n/this.dis_leftHeight.d));\n } else {\n shape.left_Heightletter.changeletter(''+parseInt(this.dis_leftHeight.n/this.dis_leftHeight.d) + '-'+this.dis_leftHeight.n%this.dis_leftHeight.d + '/' + this.dis_leftHeight.d);\n }\n\n if(this.dis_rightHeight.n%this.dis_rightHeight.d == 0) {\n shape.right_Heightletter.changeletter('' + parseInt(this.dis_rightHeight.n/this.dis_rightHeight.d));\n } else {\n shape.right_Heightletter.changeletter(''+parseInt(this.dis_rightHeight.n/this.dis_rightHeight.d) + '-'+this.dis_rightHeight.n%this.dis_rightHeight.d + '/' + this.dis_rightHeight.d);\n }\n \n // = = = = = = = corner\n shape.CL_upArrowline.drawPath(this.CL_upArrowline)\n shape.CL_ulArrowP.drawPath(this.CL_ulArrowP) \n shape.CL_ulTip.drawArrow(this.CL_ulTip) \n shape.CL_urTip.drawArrow(this.CL_urTip) \n\n shape.CR_upArrowline.drawPath(this.CR_upArrowline) \n shape.CR_ulArrowP.drawPath(this.CR_ulArrowP) \n shape.CR_ulTip.drawArrow(this.CR_ulTip) \n shape.CR_urTip.drawArrow(this.CR_urTip) \n\n // down\n shape.CL_downArrowline.drawPath(this.CL_downArrowline) \n shape.CL_dlArrowP.drawPath(this.CL_dlArrowP)\n shape.CL_dlTip.drawArrow(this.CL_dlTip) \n shape.CL_drTip.drawArrow(this.CL_drTip)\n\n shape.CR_downArrowline.drawPath(this.CR_downArrowline) \n shape.CR_dlArrowP.drawPath(this.CR_dlArrowP) \n shape.CR_dlTip.drawArrow(this.CR_dlTip) \n shape.CR_drTip.drawArrow(this.CR_drTip) \n\n // left\n shape.CU_lArrowline.drawPath(this.CU_lArrowline) \n shape.CU_lfupArrowP.drawPath(this.CU_lfupArrowP)\n shape.CU_lfupTip.drawArrow(this.CU_lfupTip) \n shape.CU_lfdownTip.drawArrow(this.CU_lfdownTip) \n\n shape.CD_lArrowline.drawPath(this.CD_lArrowline) \n shape.CD_lfdownArrowP.drawPath(this.CD_lfdownArrowP)\n shape.CD_lfupTip.drawArrow(this.CD_lfupTip) \n shape.CD_lfdownTip.drawArrow(this.CD_lfdownTip)\n\n // right\n shape.CU_rArrowline.drawPath(this.CU_rArrowline)\n shape.CU_rgupArrowP.drawPath(this.CU_rgupArrowP)\n shape.CU_rgupTip.drawArrow(this.CU_rgupTip) \n shape.CU_rgdownTip.drawArrow(this.CU_rgdownTip)\n\n shape.CD_rArrowline.drawPath(this.CD_rArrowline)\n shape.CD_rgdownArrowP.drawPath(this.CD_rgdownArrowP)\n shape.CD_rgupTip.drawArrow(this.CD_rgupTip) \n shape.CD_rgdownTip.drawArrow(this.CD_rgdownTip)\n \n\n shape.CLUW_Group.moveGroup(this.CLUW_Group);\n shape.CRUW_Group.moveGroup( this.CRUW_Group);\n shape.CLBW_Group.moveGroup(this.CLBW_Group);\n shape.CRBW_Group.moveGroup(this.CRBW_Group);\n \n shape.CLUH_Group.moveGroup(this.CLUH_Group);\n shape.CLBH_Group.moveGroup(this.CLBH_Group);\n shape.CRUH_Group.moveGroup(this.CRUH_Group);\n shape.CRBH_Group.moveGroup(this.CRBH_Group);\n \n\n // = = = = = = = = = Radius\n shape.RL_upArrowline.drawPath(this.RL_upArrowline)\n shape.RL_ulArrowP.drawPath(this.RL_ulArrowP) \n shape.RL_ulTip.drawArrow(this.RL_ulTip) \n shape.RL_urTip.drawArrow(this.RL_urTip) \n\n shape.RR_upArrowline.drawPath(this.RR_upArrowline) \n shape.RR_ulArrowP.drawPath(this.RR_ulArrowP) \n shape.RR_ulTip.drawArrow(this.RR_ulTip) \n shape.RR_urTip.drawArrow(this.RR_urTip) \n\n // down\n shape.RL_downArrowline.drawPath(this.RL_downArrowline) \n shape.RL_dlArrowP.drawPath(this.RL_dlArrowP)\n shape.RL_dlTip.drawArrow(this.RL_dlTip) \n shape.RL_drTip.drawArrow(this.RL_drTip)\n\n shape.RR_downArrowline.drawPath(this.RR_downArrowline) \n shape.RR_dlArrowP.drawPath(this.RR_dlArrowP) \n shape.RR_dlTip.drawArrow(this.RR_dlTip) \n shape.RR_drTip.drawArrow(this.RR_drTip) \n\n // left\n shape.RU_lArrowline.drawPath(this.RU_lArrowline) \n shape.RU_lfupArrowP.drawPath(this.RU_lfupArrowP)\n shape.RU_lfupTip.drawArrow(this.RU_lfupTip) \n shape.RU_lfdownTip.drawArrow(this.RU_lfdownTip) \n\n shape.RD_lArrowline.drawPath(this.RD_lArrowline) \n shape.RD_lfdownArrowP.drawPath(this.RD_lfdownArrowP)\n shape.RD_lfupTip.drawArrow(this.RD_lfupTip) \n shape.RD_lfdownTip.drawArrow(this.RD_lfdownTip)\n\n // right\n shape.RU_rArrowline.drawPath(this.RU_rArrowline)\n shape.RU_rgupArrowP.drawPath(this.RU_rgupArrowP)\n shape.RU_rgupTip.drawArrow(this.RU_rgupTip) \n shape.RU_rgdownTip.drawArrow(this.RU_rgdownTip)\n\n shape.RD_rArrowline.drawPath(this.RD_rArrowline)\n shape.RD_rgdownArrowP.drawPath(this.RD_rgdownArrowP)\n shape.RD_rgupTip.drawArrow(this.RD_rgupTip) \n shape.RD_rgdownTip.drawArrow(this.RD_rgdownTip)\n\n\n shape.RLUW_Group.moveGroup(this.RLUW_Group);\n shape.RRUW_Group.moveGroup( this.RRUW_Group);\n shape.RLBW_Group.moveGroup(this.RLBW_Group);\n shape.RRBW_Group.moveGroup(this.RRBW_Group);\n \n shape.RLUH_Group.moveGroup(this.RLUH_Group);\n shape.RLBH_Group.moveGroup(this.RLBH_Group);\n shape.RRUH_Group.moveGroup(this.RRUH_Group);\n shape.RRBH_Group.moveGroup(this.RRBH_Group);\n\n // == = = = = leftOutage\n shape.LLL_E_dot_Line_1.drawPath(this.LLL_E_dot_Line_1)\n shape.LLL_E_dot_Line_2.drawPath(this.LLL_E_dot_Line_2)\n shape.L_Elbow_1.drawPath(this.L_Elbow_1)\n shape.L_Elbow_2.drawPath(this.L_Elbow_2)\n \n // == = = = = leftOutage\n shape.RLL_E_dot_Line_1.drawPath(this.RLL_E_dot_Line_1)\n shape.RLL_E_dot_Line_2.drawPath(this.RLL_E_dot_Line_2)\n shape.R_Elbow_1.drawPath(this.R_Elbow_1)\n shape.R_Elbow_2.drawPath(this.R_Elbow_2)\n\n // = = = notch\n shape.extra_p1.drawPath(this.extra_p1)\n shape.extra_p2.drawPath(this.extra_p2)\n shape.extra_p3.drawPath(this.extra_p3)\n shape.extra_p4.drawPath(this.extra_p4)\n shape.extra_p5.drawPath(this.extra_p5)\n shape.extra_p6.drawPath(this.extra_p6)\n shape.extra_p7.drawPath(this.extra_p7)\n shape.extra_p8.drawPath(this.extra_p8)\n\n // = = = = = = Joints\n shape.BULine.drawPath(this.BULine)\n shape.BLLine.drawPath(this.BLLine)\n shape.BDLine.drawPath(this.BDLine)\n shape.BRLine.drawPath(this.BRLine)\n\n shape.LM_dot.drawPath(this.LM_dot)\n shape.RM_dot.drawPath(this.RM_dot)\n\n\n // = = = = = = =Hole = = = =\n \n // single\n shape.singleCircle.moveCircle(this.singleCircle)\n \n shape.SL_upArrowline.drawPath(this.SL_upArrowline)\n shape.SL_ulArrowP.drawPath(this.SL_ulArrowP)\n shape.SL_ulTip.drawArrow(this.SL_ulTip) \n shape.SL_urTip.drawArrow(this.SL_urTip) \n shape.SW_group.moveGroup(this.SW_group);\n\n shape.SU_lArrowline.drawPath(this.SU_lArrowline)\n shape.SU_lfupArrowP.drawPath(this.SU_lfupArrowP)\n shape.SU_lfupTip.drawArrow(this.SU_lfupTip) \n shape.SU_lfdownTip.drawArrow(this.SU_lfdownTip) \n shape.SH_group.moveGroup(this.SH_group);\n\n shape.circleDiameter.moveletter(this.circleDiameter)\n\n // double\n shape.doubleCircle.moveCircle(this.doubleCircle)\n\n shape.SDL_upArrowline.drawPath(this.SDL_upArrowline)\n shape.SDL_ulArrowP.drawPath(this.SDL_ulArrowP)\n shape.SDL_ulTip.drawArrow(this.SDL_ulTip) \n shape.SDL_urTip.drawArrow(this.SDL_urTip) \n shape.SDW_group.moveGroup(this.SDW_group);\n\n shape.SDU_lArrowline.drawPath(this.SDU_lArrowline)\n shape.SDU_lfupArrowP.drawPath(this.SDU_lfupArrowP)\n shape.SDU_lfupTip.drawArrow(this.SDU_lfupTip) \n shape.SDU_lfdownTip.drawArrow(this.SDU_lfdownTip) \n shape.SDH_group.moveGroup(this.SDH_group);\n\n // = = = == U nortch = = = = = = \n shape.UNcircle.moveCircle(this.UNcircle)\n shape.UNrect.moveRect(this.UNrect)\n // shape.UN_upline.drawPath(this.UN_upline)\n // shape.UN_downline.drawPath(this.UN_downline)\n }\n }", "title": "" }, { "docid": "8c1879e7857deef62364d36bea26219c", "score": "0.61592007", "text": "displayComponents() {\n if (mode == 0) fill('#aaaaaa');\n else fill(this.r, this.g, this.b, this.brightness);\n ellipse(this.x, this.y, this.size, this.size);\n this.displayText();\n this.updateComponentPositions();\n \n if (mode == 0) this.displayLayoutEditorComponents(); \n else this.displayAnimationEditorComponents(); \n }", "title": "" }, { "docid": "4bdf1742971f4f1d801fba5175b3f7a8", "score": "0.61530006", "text": "function draw_rect(element){\n\tctx.beginPath();\n\tctx.strokeRect(x(element.x1),y(element.y1),scale(element.x2-element.x1),scale(element.y1-element.y2) );\n\tif (typeof element.sprinkler != \"undefined\"){\n\t\tfor (var i = 0; element.sprinkler.length > i; i++){\n\t\t\telement_zeichnen(element.sprinkler[i]);\n\t\t}\n\t}\n}", "title": "" }, { "docid": "2e8684844b82b083a1e75500870efba9", "score": "0.61483437", "text": "function draw() {\n // If the array is sorted\n if (max === 1) {\n max--;\n focusedIndex = -1;\n comparedIndex = -1;\n }\n clear();\n // Draws the elements\n for (let i = 0; i <= elementsLength; i++) {\n fill(0, 255, 0);\n if (i === focusedIndex) fill(0, 0, 255);\n else if (i === comparedIndex) fill(128, 0, 128);\n else if (i >= max) fill(128, 128, 128);\n rect(i * width / elementsLength + 1, (elementsLength - objects[i]) * elementHeight + 1, width / elementsLength - 4, (objects[i] + 1) * elementHeight - 1);\n }\n // Continue the animation if the array isn't sorted and 60 / fps frames have passed\n if (max > 1 && frames++ > 60 / fps) continueAnimation();\n}", "title": "" }, { "docid": "f84c0df578d6308da68c1bb3de813740", "score": "0.614227", "text": "function draw_all()\n{\n\tdraw_hold();\n\tdraw_next();\n\tdraw_board();\n}", "title": "" }, { "docid": "27c590f3c3220163c845b9426ec5e6b3", "score": "0.6130582", "text": "DrawUI( gfx )\n\t{\n\t}", "title": "" }, { "docid": "75157bef80ce160cc40bd874f15db9b9", "score": "0.6125472", "text": "display(){\n if(this.isclicked){\n fill(66, 244, 155);\n }else{\n fill(this.shade);\n }\n if(this.over){\n fill(255, 199, 225);\n }\n ellipse(this.x, this.y, this.w, this.h);\n }", "title": "" }, { "docid": "1cf8d1f93539d6b371e48cb02fdca22e", "score": "0.6119746", "text": "display(){\n\n fill('red');\n ellipse(this.position.x, this.position.y, this.size);\n }", "title": "" }, { "docid": "9728e777163dfa004973010d4af8128f", "score": "0.61182755", "text": "draw_shapes() {\n\t\t\tlet params = { offsetX: 0, offsetY: 0 };\n\t\t\tlet ctx = this.canvas.getContext(\"2d\");\n\t\t\tfor (let shape_name in this.shapes) {\n\t\t\t\tlet shape = this.shapes[shape_name];\n\t\t\t\t// draw all visible shapes\n\t\t\t\tif (shape.visible && !shape.active) {\n\t\t\t\t\tdocument.draw_shape(ctx, shape, params);\n\t\t\t\t\tdocument.draw_shape_border(ctx, shape, params);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// make sure to draw active shape last (so it appears 'on top')\n\t\t\tif (this.pento_active_shape && this.pento_active_shape.visible) {\n\t\t\t\tdocument.draw_shape(ctx, this.pento_active_shape, params);\n\t\t\t\tdocument.draw_shape_border(ctx, this.pento_active_shape, params);\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "ce7d104d0d9d4fd464e235f281a95b96", "score": "0.6109561", "text": "function draw() {\n\tctx.clearRect(0, 0, canvas.width, canvas.height);\t\n draw_grid()\n draw_manufacturer()\n draw_color_map()\n\tdraw_cars()\n}", "title": "" }, { "docid": "e38b1abf50360ae78fd365eef4684b88", "score": "0.6108214", "text": "draw(){\n if(!this.Filled){\n context.strokeRect(this.positionX,this.positionY,this.Width,this.Height);\n }\n else{\n context.fillRect(this.positionX,this.positionY,this.Width,this.Height);\n }\n this.displaysStats();\n }", "title": "" }, { "docid": "e6f30063c793bbcf4117aacd5fde7d75", "score": "0.6104842", "text": "draw() {\n const drawer = this[__WEBPACK_IMPORTED_MODULE_7__const__[\"b\" /* DRAWER */]] || (this[__WEBPACK_IMPORTED_MODULE_7__const__[\"b\" /* DRAWER */]] = new __WEBPACK_IMPORTED_MODULE_0__draw__[\"a\" /* default */](this[__WEBPACK_IMPORTED_MODULE_7__const__[\"a\" /* CONTAINER */]]));\n // draw under layers first\n // IDEA: add some optimization options here for purely static layers\n // we shouldn't need to re-draw every item individually if they\n // haven't changed at all\n drawer.removeCanvases(this[__WEBPACK_IMPORTED_MODULE_7__const__[\"k\" /* ROOMS */]].length * 2);\n for (let i = this[__WEBPACK_IMPORTED_MODULE_7__const__[\"k\" /* ROOMS */]].length - 1; i >= 0; --i) {\n drawer.view(this[__WEBPACK_IMPORTED_MODULE_7__const__[\"r\" /* VIEWS */]][i]);\n for (let obj of this[__WEBPACK_IMPORTED_MODULE_7__const__[\"f\" /* OBJECTS */]][i]) {\n obj instanceof __WEBPACK_IMPORTED_MODULE_3__drawable__[\"b\" /* default */] && obj.draw(drawer.object(obj));\n }\n this[__WEBPACK_IMPORTED_MODULE_7__const__[\"k\" /* ROOMS */]][i] && this[__WEBPACK_IMPORTED_MODULE_7__const__[\"k\" /* ROOMS */]][i].draw(drawer);\n drawer.render(i);\n // draw GUI\n drawer.view(new __WEBPACK_IMPORTED_MODULE_1__struct__[\"d\" /* Rectangle */](0, 0, ...this.size));\n for (let obj of this[__WEBPACK_IMPORTED_MODULE_7__const__[\"f\" /* OBJECTS */]][i]) {\n obj instanceof __WEBPACK_IMPORTED_MODULE_3__drawable__[\"b\" /* default */] && obj.drawGUI(drawer.object(obj));\n }\n this[__WEBPACK_IMPORTED_MODULE_7__const__[\"k\" /* ROOMS */]][i] && this[__WEBPACK_IMPORTED_MODULE_7__const__[\"k\" /* ROOMS */]][i].drawGUI(drawer);\n drawer.render(this[__WEBPACK_IMPORTED_MODULE_7__const__[\"k\" /* ROOMS */]].length + i);\n }\n }", "title": "" }, { "docid": "3938e3a8b3928e10fcbfed292ee31edd", "score": "0.6102413", "text": "function drawchooser(obj,color) {\r\n var Location = obj.Location;\r\n var Size = obj.Size;\r\n var lineSize = 20;\r\n var Center = new Point(Location.X + (Size.X / 2) , Location.Y + (lineSize /2) );\r\n\r\n //Rettangolo fisso\r\n context.beginPath();\r\n context.rect(Location.X,Location.Y,Size.X,lineSize);\r\n context.fillStyle = \"white\";\r\n context.fill();\r\n context.strokeStyle = color;\r\n context.stroke();\r\n\r\n //Linea di scelta\r\n context.beginPath();\r\n context.moveTo(Location.X+Size.X-lineSize,Location.Y);\r\n context.lineTo(Location.X+Size.X-lineSize,Location.Y+lineSize);\r\n context.strokeStyle = color;\r\n context.stroke();\r\n\r\n //Elemento selezionato\r\n context.beginPath();\r\n context.font = \"12px Arial\";\r\n context.fillStyle = 'black';\r\n context.textAlign = 'center';\r\n context.textBaseline = 'middle';\r\n context.fillText(obj.Element[obj.Selected][0],Center.X,Center.Y);\r\n\r\n if(obj.isShow){\r\n\r\n //Triangolo in giù\r\n context.beginPath();\r\n context.moveTo(Location.X+Size.X-lineSize+5,Location.Y+5);\r\n context.lineTo(Location.X+Size.X-lineSize+15,Location.Y+5);\r\n context.lineTo(Location.X+Size.X-lineSize+10,Location.Y+15);\r\n context.lineTo(Location.X+Size.X-lineSize+5,Location.Y+5);\r\n context.strokeStyle = color;\r\n context.stroke();\r\n\r\n //Rettangolo di lista\r\n context.beginPath();\r\n context.rect(Location.X,Location.Y+lineSize,Size.X,obj.Element.length * lineSize);\r\n context.fillStyle = \"white\";\r\n context.fill();\r\n context.strokeStyle = color;\r\n context.stroke();\r\n\r\n //Disegno della scelta selezionata\r\n context.beginPath();\r\n context.rect(Location.X,Location.Y + ((obj.Selected + 1) * (lineSize)),Size.X,lineSize);\r\n context.fillStyle = color;\r\n context.fill();\r\n\r\n //Disegno delle scelte\r\n context.beginPath();\r\n context.font = \"12px Arial\";\r\n context.fillStyle = 'black';\r\n context.textAlign = 'center';\r\n context.textBaseline = 'middle';\r\n for(var i=0;i<obj.Element.length;i++) {\r\n context.fillText(obj.Element[i][0], Center.X, Center.Y + ((i+1)*lineSize));\r\n }\r\n } else {\r\n //Triangolo a destra\r\n context.beginPath();\r\n context.moveTo(Location.X+Size.X-lineSize+5,Location.Y+5);\r\n context.lineTo(Location.X+Size.X-lineSize+5,Location.Y+15);\r\n context.lineTo(Location.X+Size.X-lineSize+15,Location.Y+10);\r\n context.lineTo(Location.X+Size.X-lineSize+5,Location.Y+5);\r\n context.strokeStyle = color;\r\n context.stroke();\r\n }\r\n }", "title": "" }, { "docid": "ad62b55c676adb8444f86b955637bcb0", "score": "0.6098838", "text": "render() {\n // this.drawBoard(this.ctx);\n this.drawPiece(this.currPos);\n\n }", "title": "" }, { "docid": "9a0feb75b7f08bab6a1894602d3e4428", "score": "0.6098488", "text": "drawAll() {\n this.drawScene();\n this.colorCircle(this.state.ballX,this.state.ballY, 10, 'red'); // Ball\n this.colorRect(this.state.paddleX, Breakout.const.canvas.height - this.state.paddleDistFromEdge, this.state.paddleWidth, this.state.paddleThickness, 'white'); // Paddle\n\n this.drawBricks();\n\n // Position lives HUD in bottom left corner\n this.colorText(\"Lives: \"+this.state.livesLeft, this.state.paddleDistFromEdge/2,Breakout.const.canvas.height - this.state.paddleDistFromEdge/2, 'white');\n // Position score HUD in bottom right corner\n this.colorText(\"Score:\" + this.state.score, Breakout.const.canvas.width - 100, Breakout.const.canvas.height - this.state.paddleDistFromEdge/2, \"white\");\n }", "title": "" }, { "docid": "b269977a846dbcce5d0cb19bc8e57da5", "score": "0.6096287", "text": "function draw() {\n\tnoTint();//ensures other images aren't affected by tints in other functions\n\tdrawBackground();\n\tslideshow();\n\tnoTint();\n\tdrawArtist();\n\tdrawMidLeft();\n\tdrawRight();\n\tslideControl();\n\ttrentonMakes();\n\t//drawBorders();\n}", "title": "" }, { "docid": "d2b0ec8ad4744508e9cc3528b8e72673", "score": "0.6095338", "text": "function draw()\n {\n // Background\n ctx.fillStyle = \"rgba(0,0,0,1)\";\n ctx.fillRect(0,0,W,H);\n \n // Draw the boxes\n //ctx.globalCompositeOperation = \"lighter\";\n for(i=0; i < boxes.length; i++)\n boxes[i].draw();\n \n // Draw the text on bottom\n update();\n }", "title": "" }, { "docid": "8a218efe9485a5034bf257268d5257ae", "score": "0.608875", "text": "function draw() {\n drawPlane();\n drawWorm();\n dropBomb();\n drawBombs();\n removeBombs();\n }", "title": "" }, { "docid": "658143a10c49aed4247dfc4051b1b8f3", "score": "0.60722226", "text": "function render() {\n if(showSelection) {\n\n\t\t\t// Makes it easyer to draw the selection rectangle\n var leftMin = Math.min(mouseDownCoord.x, mouseMoveCoord.x);\n var leftMax = Math.max(mouseDownCoord.x, mouseMoveCoord.x);\n var topMin = Math.min(mouseDownCoord.y, mouseMoveCoord.y);\n var topMax = Math.max(mouseDownCoord.y, mouseMoveCoord.y);\n\n\t\t\t// Draw the selection element\n $selection.css('left', leftMin + 'px');\n $selection.css('top', topMin + 'px');\n $selection.css('width', (leftMax - leftMin) + 'px');\n $selection.css('height', (topMax - topMin) + 'px');\n $selection.show();\n\n } else {\n $selection.hide();\n }\n\n\t\t// Resize grid to pattern dims\n\n\t\t$grid.css({\n\t\t\t'width':(cfg.x * song.pattern.length()) + 'px',\n\t\t\t'height':(cfg.y * 87) + 'px',\n\t\t\t'background-size':'50px ' + (12 * cfg.y) + 'px',\n\t\t\t'background-position':'0 ' + cfg.y + 'px'\n\t\t});\n\n\t\tif(mappedKeys) {\n\t\t\t$grid.addClass('mapped-keys');\n\t\t\t$grid.css('height', Object.keys(mappedKeys).length * cfg.y);\n\t\t\t$grid.css('background-size', '50px ' + (cfg.y) + 'px');\n\t\t} else {\n\t\t\t$grid.removeClass('mapped-keys')\n\t\t}\n\n\t\t// Remove all notes and draw them again\n $grid.find('[data-type=\"note\"]').remove();\n\n song.pattern.getNotes().forEach(renderNote);\n\n }", "title": "" }, { "docid": "8d3d62cc197411609e89b576dff590aa", "score": "0.6070893", "text": "function drawLayers() {\n // Start here to make Division file for interface\n\n // Main Division as base division\n divMain = document.createElement(\"div\");\n\tdivMain.style.border = \"#95a5a6 3px solid\";\n\tdivMain.style.width = \"1000px\";\n divMain.style.height = \"860px\";\n\tdivMain.style.background = \"#eee\";\n divMain.style.margin = \"auto\";\n divMain.style.textAlign = \"center\";\n\n // Head division. Work as header.\n divHead = document.createElement(\"div\");\n\tdivHead.style.border = \"#95a5a6 0px solid\";\n\tdivHead.style.width = \"990px\";\n divHead.style.height = \"100px\";\n\tdivHead.style.background = \"#eee\";\n divHead.style.margin = \"auto\";\n divHead.style.textAlign = \"center\";\n\n // Body division. Containing all core Simulation\n divBody = document.createElement(\"div\");\n\tdivBody.style.border = \"#f00 0px solid\";\n\tdivBody.style.width = \"990px\";\n\tdivBody.style.background = \"#eee\";\n divBody.style.margin = \"auto\";\n divBody.style.textAlign = \"center\";\n\n // Foot Division. For Inserting result and others\n divFoot = document.createElement(\"div\");\n\tdivFoot.style.border = \"#f00 0px solid\";\n\tdivFoot.style.width = \"990px\";\n divFoot.style.height = \"100px\";\n\tdivFoot.style.background = \"#eee\";\n divFoot.style.margin = \"auto\";\n divFoot.style.textAlign = \"center\";\n\n // Button division. Put button on respective place\n divBtn = document.createElement(\"div\");\n\tdivBtn.style.border = \"#aaa 0px solid\";\n divBtn.style.width = \"900px\";\n divBtn.style.height = \"25px\";\n\tdivBtn.style.background = \"#eee\";\n divBtn.style.margin = \"auto\";\n divBtn.style.textAlign = \"center\";\n\n // Canvas Division. Core of the program\n divCan = document.createElement(\"div\");\n\tdivCan.style.border = \"#aaa 0px solid\";\n divCan.style.width = MW;\n divCan.style.height = NW;\n\tdivCan.style.background = \"#eee\";\n divCan.style.margin = \"auto\";\n divCan.style.textAlign = \"center\";\n\n // Slider division. Put slider to the program\n divSld = document.createElement(\"div\");\n\tdivSld.style.border = \"#aaa 0px solid\";\n divSld.style.width = \"200px\";\n divSld.style.height = \"50px\";\n\tdivSld.style.background = \"#eee\";\n divSld.style.margin = \"auto\";\n divSld.style.textAlign = \"center\";\n\n // ---------------------------------------------------- //\n\n W = createWorldMatrix();\n\tD1 = createDirectionMatrix1();\n\tD2 = createDirectionMatrix2();\n\tD3 = createDirectionMatrix3();\n\tD4 = createDirectionMatrix4();\n\tA = createAgentMatrix();\n\tports = createPorts();\n\n var NW = W.length;\n\tvar MW = W[0]. length;\n\tvar boxSize = 20;\n\n\tcan = createCanvas(MW, NW, boxSize);\n can.style.margin = \"auto\";\n can.style.border = \"#95a5a6 2px solid\";\n\n taIn = document.createElement(\"textarea\");\n\ttaIn.style.width = \"800px\";\n\ttaIn.style.height = \"80px\";\n taIn.style.margin = \"auto\";\n taIn.style.border = \"0px\";\n taIn.disabled = \"true\";\n taIn.style.resize = \"none\";\n taIn.style.fontSize = \"15px\";\n taIn.style.fontStyle = \"italic\";\n taIn.style.textAlign = \"center\";\n\n tbIn = document.createElement(\"textarea\");\n\ttbIn.style.width = \"300px\";\n\ttbIn.style.height = \"150px\";\n\ttbIn.style.margin = \"auto\";\n tbIn.style.resize = \"none\";\n\n tdIn = document.createElement(\"textarea\");\n tdIn.style.width = \"300px\";\n tdIn.style.height = \"150px\";\n tdIn.style.margin = \"auto\";\n tdIn.style.resize = \"none\";\n tdIn.disabled = \"true\";\n\n btnClr = document.createElement(\"button\");\n btnClr.innerHTML = \"Clear\";\n btnClr.addEventListener(\"click\", btnClck);\n\n btnStr = document.createElement(\"button\");\n btnStr.innerHTML = \"Start\";\n btnStr.addEventListener(\"click\", btnClck);\n\n sldTxt = document.createElement(\"text\");\n sldTxt.innerHTML = \"Density Flow\";\n sldTxt.style.fontSize = \"20px\";\n\n sldA = document.createElement(\"input\");\n sldA.type = \"range\";\n sldA.value = \"0\";\n sldA.addEventListener(\"input\", changeDensity);\n\n function h1(text){\n var h = document.write('<h1>'+ hello +'</h1>');\n }\n\n\n // Put every component to its respective place\n\t\tif(devel == 0) {\n\t\t\tdocument.body.append(divMain);\n\t\t\tdivMain.append(divHead);\n\t\t\t\t\tdivHead.append(taIn);\n\t\t\tdivMain.append(divBody);\n\t\t\t\t\tdivBody.append(divCan);\n\t\t\t\t\t\t\tdivCan.append(can);\n\t\t\t\t\tdivBody.append(divSld);\n\t\t\t\t\t\t\tdivSld.append(sldTxt);\n\t\t\t\t\t\t\tdivSld.append(sldA);\n\t\t\t\t\tdivBody.append(divBtn);\n\t\t\t\t\t\t\tdivBtn.append(btnClr);\n\t\t\t\t\t\t\tdivBtn.append(btnStr);\n\t\t\t\t\tdivBody.append(tbIn);\n\t\t\t\t\tdivBody.append(tdIn);\n\t\t\tdivMain.append(divFoot);\n\t\t} else if(devel == 1) {\n\t\t\tdocument.body.append(can);\n\t\t\tdocument.body.append(btnStr);\n\t\t}\n\n}", "title": "" }, { "docid": "42e60312e06024b7f243feacf322074d", "score": "0.60679245", "text": "draw(){\n\t\t// If it's a button, draws a rect, with different color depending if its selected or not. \n\t\tif(this.mode == 0){\n\t\t\tif(TOOL == 5 && this.text == \"Player Pos.\" ||\n\t\t\t TOOL == 6 && this.text == \"Goal Pos.\" ||\n\t\t\t TOOL == 4 && this.text == \"Delete\" ||\n\t\t\t TOOL == 3 && this.text == \"Draw\" || \n\t\t\t TOOL == 2 && this.text == \"Run\" || \n\t\t\t TOOL == 1 && this.text == \"Stop\"){\n\t\t\t\tfill(red(GUI_COLOR) + 40,green(GUI_COLOR) + 40,blue(GUI_COLOR) + 40);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfill(red(GUI_COLOR) + 20,green(GUI_COLOR) + 20,blue(GUI_COLOR) + 20);\n\t\t\t}\n\t\t\t\n\t\t\trect(this.pos.x,this.pos.y,this.size.x,this.size.y);\n\n\t\t\t// Setup text drawn on the button.\n\t\t\ttextSize(16);\n\t\t\tfill(210);\n\t\t\ttextAlign(CENTER,CENTER);\n\t\t\tif(this.text == \"Selection Method:\" || this.text == \"Crossover Method:\"){\n\t\t\t\ttextSize(14);\n\t\t\t\ttextAlign(CENTER,CENTER);\n\t\t\t\ttext(this.text + \" \" + this.varText,this.pos.x,this.pos.y,this.size.x,this.size.y);\n\t\t\t}\n\t\t\telse text(this.text,this.pos.x,this.pos.y,this.size.x,this.size.y);\n\t\t}\n\t\t// If its a button with increment/decrement, needs to configure and draw the 3 separate rects.\n\t\telse if(this.mode == 1){\n\t\t\t// Main Box\n\t\t\tfill(red(GUI_COLOR) + 20,green(GUI_COLOR) + 20,blue(GUI_COLOR) + 20);\n\t\t\trect(this.pos.x,this.pos.y,(3 *this.size.x / 4), this.size.y);\n\t\t\ttextSize(14);\n\n\t\t\t// Draw text for the main box\n\t\t\tfill(210);\n\t\t\ttextAlign(CENTER,CENTER);\n\t\t\ttext(this.text + this.varText,this.pos.x,this.pos.y,(3 * this.size.x / 4),this.size.y);\n\n\t\t\t// Increment Box\n\t\t\tfill(red(GUI_COLOR) + 10,green(GUI_COLOR) + 50,blue(GUI_COLOR) + 10);\n\t\t\trect(this.pos.x + (3 *this.size.x / 4),this.pos.y, (this.size.x / 4), (this.size.y / 2));\n\t\t\ttextSize(20);\n\t\t\tfill(210);\n\t\t\ttext(\" + \",this.pos.x + (3 *this.size.x / 4),this.pos.y, (this.size.x / 4), (this.size.y / 2));\n\n\t\t\t// Decrement Box\n\t\t\tfill(red(GUI_COLOR) + 50,green(GUI_COLOR) + 10,blue(GUI_COLOR) + 10);\n\t\t\trect(this.pos.x + (3 *this.size.x / 4),this.pos.y + (this.size.y / 2), (this.size.x / 4), (this.size.y / 2));\n\t\t\ttextSize(20);\n\t\t\tfill(210);\n\t\t\ttext(\" - \",this.pos.x + (3 *this.size.x / 4),this.pos.y + (this.size.y / 2), (this.size.x / 4),(this.size.y / 2));\n\t\t}\n\t\t// Button containing a scrollbar, that has a little button which changes position along scrollbar.\n\t\telse if(this.mode == 2){\n\t\t\t// Main box\n\t\t\tfill(red(GUI_COLOR) + 20,green(GUI_COLOR) + 20,blue(GUI_COLOR) + 20);\n\t\t\trect(this.pos.x,this.pos.y,this.size.x, (3*this.size.y/4));\n\t\t\ttextSize(12);\n\n\t\t\tfill(210);\n\t\t\ttextAlign(CENTER,CENTER);\n\t\t\tif(this.text == \"Crossover\" || this.text == \"Mutation\" || this.text == \"Elitism\" || this.text == \"Falloff\"){\n\t\t\t\ttext(this.text + \": \" + (100* this.varText).toFixed() + \"%\",this.pos.x,this.pos.y,this.size.x, (3*this.size.y/4));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttext(this.text + \": \" + this.varText,this.pos.x,this.pos.y,this.size.x, (3*this.size.y/4));\n\t\t\t}\n\n\t\t\t// Scroll box - Long rectangle on bottom\n\t\t\tfill(red(GUI_COLOR) + 50,green(GUI_COLOR) + 50,blue(GUI_COLOR) + 50);\n\t\t\trect(this.pos.x,this.pos.y + (3*this.size.y/4),this.size.x, this.size.y/4);\n\n\t\t\t// Tiny box - Used to configure value of bar\n\t\t\tfill(red(GUI_COLOR) + 30,green(GUI_COLOR) + 30,blue(GUI_COLOR) + 30);\n\t\t\tstroke(red(GUI_COLOR),green(GUI_COLOR),blue(GUI_COLOR));\n\t\t\trect(this.pos.x + ((this.size.x - this.size.y/4) * this.bar),this.pos.y + (3*this.size.y/4),(this.size.y/4),(this.size.y/4));\n\n\t\t}\n\t}", "title": "" }, { "docid": "977dffcbe24f2ab0b0596792daa40153", "score": "0.606579", "text": "display() {\n push();\n noStroke();\n fill(this.fill.r, this.fill.g, this.fill.b);\n ellipse(this.x,this.y,this.size);\n pop();\n }", "title": "" }, { "docid": "3f1bddef05ded0fc6744ea043202549f", "score": "0.60598975", "text": "draw() {\n // draw background\n this.ctx.fillStyle = this.background\n this.ctx.strokeStyle = this.stroke\n this.ctx.lineWidth = this.lineWidth\n this.ctx.fillRect( 0,0, this.rect.width, this.rect.height )\n\n // draw fill (multiSlider value representation)\n this.ctx.fillStyle = this.fill\n\n let sliderWidth = this.style === 'vertical' ? this.rect.width / this.count : this.rect.height / this.count\n\n for( let i = 0; i < this.count; i++ ) {\n \n if( this.style === 'horizontal' ) {\n let ypos = Math.floor( i * sliderWidth )\n this.ctx.fillRect( 0, ypos, this.rect.width * this.__value[ i ], Math.ceil( sliderWidth ) )\n this.ctx.strokeRect( 0, ypos, this.rect.width, sliderWidth )\n }else{\n let xpos = Math.floor( i * sliderWidth )\n this.ctx.fillRect( xpos, this.rect.height - this.__value[ i ] * this.rect.height, Math.ceil(sliderWidth), this.rect.height * this.__value[ i ] )\n this.ctx.strokeRect( xpos, 0, sliderWidth, this.rect.height )\n }\n }\n\n \n }", "title": "" }, { "docid": "b74dae6987250fab754de359f4d6d0c9", "score": "0.60441756", "text": "display(initialx, initialy, size) {\n\t\tif (this.visible) {\n\t\t\tfill(0, 255, 0);\n\t\t\tstroke(0);\n\t\t\tstrokeWeight(3);\n\t\t\trect(initialx + this.j * size, initialy + this.i * size, size, size);\n\t\t}\n\t}", "title": "" }, { "docid": "8701522319786951c805b8e40dffd110", "score": "0.60421157", "text": "function draw() {\n for (var i = 0; i < cells.length; i++)\n cells[i].draw();\n }", "title": "" }, { "docid": "8bdee3706307f535bd13a70f3392c091", "score": "0.6037263", "text": "function draw() {\n background(bgColor);\n Shape.displayAllShapes();\n}", "title": "" }, { "docid": "5224d074d41cdaa9f082b18b7aeed496", "score": "0.60371196", "text": "draw() {\n // Create and structure elements.\n const {\n message\n } = this.props;\n const els = this.elements;\n els.container = createDiv('fbv-toast-container');\n els.message = createDiv('fbv-toast-message');\n els.message.innerHTML = message;\n els.container.appendChild(els.message);\n this.drawButtons();\n this.target.appendChild(els.container);\n }", "title": "" }, { "docid": "7104b297b732fd0f0745e807129df89f", "score": "0.6035443", "text": "drawButtons(){\n ctx.save();\n ctx.fillStyle = this.buttonStyle;\n\n for(var x = 0; x < 4; x++){\n ctx.fillRect(this.creatureListWidth + 10, 620 + (45 * x), 90, 35);\n }\n\n //ctx.fillRect(this.creatureListWidth + 10, 620, 90, 35);\n //ctx.fillRect(this.creatureListWidth + 10, 665, 90, 35);\n //ctx.fillRect(this.creatureListWidth + 10, 710, 90, 35);\n //ctx.fillRect(this.creatureListWidth + 10, 755, 90, 35);\n\n ctx.font = \"25px Arial\";\n ctx.fillStyle = \"#cccccc\";\n if(this.selectedOrganType == 0){ctx.fillStyle = \"#fcc201\";}\n ctx.fillText('Body', this.creatureListWidth + 15, 645);\n ctx.fillStyle = \"#cccccc\";\n if(this.selectedOrganType == 1){ctx.fillStyle = \"#fcc201\";}\n ctx.fillText('Guts', this.creatureListWidth + 15, 690);\n ctx.fillStyle = \"#cccccc\";\n if(this.selectedOrganType == 2){ctx.fillStyle = \"#fcc201\";}\n ctx.fillText('Head', this.creatureListWidth + 15, 735);\n ctx.fillStyle = \"#cccccc\";\n if(this.selectedOrganType == 3){ctx.fillStyle = \"#fcc201\";}\n ctx.fillText('Items', this.creatureListWidth + 15, 780);\n\n ctx.restore();\n }", "title": "" }, { "docid": "d7c7fb1dbd878295f5152bbfac04aa76", "score": "0.6019057", "text": "draw() {\n fill(this.filled ? 0 : 255)\n strokeWeight(0.05);\n\n beginShape()\n this.edges.forEach(edge => {\n let [a, b] = edge\n vertex(a.x, a.y)\n vertex(b.x, b.y)\n })\n endShape(CLOSE);\n }", "title": "" }, { "docid": "83cbc2cea335c68c409edd32549a94b3", "score": "0.60153747", "text": "function DrawAllViz() {\n\t\t\t\tVisual1();\n\t\t\t\tVisual2();\n\t\t\t}", "title": "" }, { "docid": "43589f4877510ab5bbafa5bddfbf274a", "score": "0.6005406", "text": "function draw() {\n wisdomText.innerText = `Wisdom: ${wisdom}`\n peopleText.innerText = `People: ${people}`\n stageText.innerText = `Stage: ${stage}`\n autoText.innerText = `WPS: ${auto}`\n meaningText.innerText = `Meaning of Life: ${meaning}`\n teachText.innerText = `costs ${teachCost} Wisdom. Taught: ${peopleTaught}.`\n bookText.innerText = `costs ${bookCost} Wisdom. Written: ${booksBought}.`\n libraryText.innerText = `costs ${libraryCost} Wisdom. Built: ${libraryBuilt}.`\n collegeText.innerText = `costs ${collegeCost} Wisdom. Built: ${collegeBuilt}.`\n orbitalText.innerText = `costs ${orbitalCost} Wisdom. Built: ${orbitalsBuilt}.`\n marsText.innerText = `costs ${marsCost} Wisdom. Built: ${marsBuilt}.`\n dysonText.innerText = `costs ${dysonCost} Wisdom. Built: ${dysonBuilt}.`\n ftlText.innerText = `costs ${ftlCost} Wisdom. Built: ${ftlBuilt}.`\n}", "title": "" }, { "docid": "bebcfc19d0eb22d8c829be53e8819ef0", "score": "0.600503", "text": "function draw() {\n if (canvasValid == false) {\n clear(ctx);\n plotWindow();\n // Add stuff you want drawn in the background all the time here\n \n // draw all boxes\n var l = boxes.length;\n for (var i = 0; i < l; i++) {\n drawshape(ctx, boxes[i], boxes[i].fill);\n }\n \n // draw selection\n // right now this is just a stroke along the edge of the selected box\n if (mySel != null) {\n ctx.strokeStyle = mySelColor;\n ctx.lineWidth = mySelWidth;\n ctx.strokeRect(mySel.x,mySel.y,mySel.w,mySel.h);\n }\n \n // Add stuff you want drawn on top all the time here\n \n \n canvasValid = true;\n }\n}", "title": "" }, { "docid": "796d06be8524e208d0eef3fd456ab059", "score": "0.6003825", "text": "function renderFormat() {\n Backgrounds = []\n for(var i = 0; i < maxQs; i++){\n Y = (Boxheight+Boxpadding)*i+Questionsize+2*Questionpadding\n bounds = [100, Y, 800, Boxheight]\n Backgrounds.push(createBox(bounds).attr('fill','#80b1d3'))\n }\n bl = [100, Y, Boxheight, Boxheight]\n leftbox = createBox(bl).attr('fill','#ffff7f')\n br = [900-Boxheight, Y, Boxheight, Boxheight]\n rightbox = createBox(br).attr('fill','#30b364')\n textg = svg.append('g');\n for(var i = 0; i < maxQs; i++){\n Y = (Boxheight+Boxpadding)*i+Questionsize+2*Questionpadding\n bounds = [100, Y, 800, Boxheight]\n createBox(bounds).attr('fill','transparent').datum(i).on('click',d=>{if(ANSWERS[d]==\"prev\"){previous(d)}else{Answers[questionindex] = d; renderQuestion(d)}})\n }\n leftcbox = createBox(bl).attr('fill','transparent').on(\"click\",function(d){nextq(1)})\n rightcbox = createBox(br).attr('fill','transparent').on(\"click\",d=>{(Selected<ANSWERS.length-OMIT_N)?nextq(1.5):nextq(1)})\n}", "title": "" }, { "docid": "a75dc3ac15aeaba96855085cb77bff53", "score": "0.6002781", "text": "function drawHelper() {\r\n var sortedArtworks,\r\n minOfSort,\r\n currentWork,\r\n works,\r\n progressCircCSS,\r\n paddingDiv,\r\n circle,\r\n i, h, w, j;\r\n\r\n\r\n if (!artworks || artworks.length === 0){\r\n tileCircle.hide();\r\n if (onAssocMediaView) {\r\n assocMediaButton.css({ \"color\": SECONDARY_FONT_COLOR });\r\n artworksButton.css({ \"color\": TAG.Util.UI.dimColor(SECONDARY_FONT_COLOR, DIMMING_FACTOR) });\r\n } else {\r\n assocMediaButton.css({ \"color\": TAG.Util.UI.dimColor(SECONDARY_FONT_COLOR, DIMMING_FACTOR) });\r\n artworksButton.css({ \"color\": SECONDARY_FONT_COLOR });\r\n }\r\n assocMediaButton.removeAttr('disabled');\r\n artworksButton.removeAttr('disabled');\r\n return;\r\n }\r\n\r\n if (tag){\r\n sortedArtworks = sortCatalog(artworks, tag);\r\n minOfSort = sortedArtworks.min();\r\n currentWork = minOfSort ? minOfSort.artwork : null;\r\n works = sortedArtworks.getContents();\r\n } else {\r\n //If no sort options\r\n works = artworks;\r\n currentWork = artworks[0];\r\n }\r\n i = start;\r\n h = catalogDiv.height() * 0.48;\r\n w = h * 1.4;\r\n \r\n tileDiv.empty();\r\n tileDivHeight = tileDiv.height();\r\n\r\n \r\n for (j = 0; j < works.length; j++) {\r\n if (tag){\r\n loadQueue.add(drawArtworkTile(works[j].artwork, tag, onSearch, i+j, j === works.length-1));\r\n }\r\n else{\r\n loadQueue.add(drawArtworkTile(works[j], null, onSearch, i+j, j === works.length-1));\r\n }\r\n }\r\n if (works.length == 0) {\r\n\r\n if (onAssocMediaView) {\r\n assocMediaButton.css({ \"color\": SECONDARY_FONT_COLOR });\r\n artworksButton.css({ \"color\": TAG.Util.UI.dimColor(SECONDARY_FONT_COLOR, DIMMING_FACTOR) });\r\n } else {\r\n assocMediaButton.css({ \"color\": TAG.Util.UI.dimColor(SECONDARY_FONT_COLOR, DIMMING_FACTOR) });\r\n artworksButton.css({ \"color\": SECONDARY_FONT_COLOR });\r\n }\r\n\r\n assocMediaButton.removeAttr('disabled');\r\n artworksButton.removeAttr('disabled');\r\n \r\n }\r\n loadQueue.add(function () {\r\n if (works.length > 0) {\r\n paddingDiv = $(document.createElement(\"div\"))\r\n .css({\r\n 'height': \"100%\",\r\n \"width\": TILE_BUFFER,\r\n \"pointer-events\": \"none\",\r\n 'position': 'absolute',\r\n \"margin\": \"none\",\r\n 'left': tileDiv.children().eq(-1).position().left + tileDiv.children().eq(-1).width() // to get last child position\r\n });\r\n tileDiv.append(paddingDiv);\r\n }\r\n })\r\n \r\n loadQueue.add(function () {\r\n \ttileCircle.hide();\r\n })\r\n if (IS_WINDOWS){\r\n loadQueue.add(function () {\r\n showArtwork(currentArtwork, multipleShown && multipleShown)();\r\n })\r\n }\r\n tileDiv.css({'left': infoDiv.width()});\r\n if (infoDiv.width()===0){\r\n tileDiv.css({'margin-left':'2%'});\r\n } else{\r\n tileDiv.css({'margin-left':'0%'});\r\n }\r\n catalogDiv.append(tileDiv);\r\n clearTimeline(artworks);\r\n \r\n }", "title": "" }, { "docid": "d88048912d52f91a5612f73b5baea3c6", "score": "0.60013634", "text": "draw() {\n this.context.clearRect(0,0, this.canvas.width, this.canvas.height);\n\n this.players.forEach(player => {\n player.draw(this.context);\n });\n\n this.bombs.forEach(bomb => {\n bomb.draw(this.context);\n });\n\n this.walls.forEach(wall => {\n wall.draw(this.context);\n });\n\n this.items.forEach(item => {\n item.draw(this.context);\n });\n }", "title": "" }, { "docid": "21fbc33a0451e5e19e9e72b1279796f8", "score": "0.5995192", "text": "draw(){\n this.drawRect(this.xMouseStart, this.yMouseStart, this.w, this.h);\n\n }", "title": "" }, { "docid": "f8a1ebed6428291720bb893564271518", "score": "0.59832764", "text": "display() {\n noStroke();\n fill(this.color);\n\n rect(this.x, this.y, this.size); //body\n rect(this.x, this.y + 49, this.legW, this.leftLegH); //left leg\n rect(this.x + 35, this.y + 49, this.legW, this.rightLegH); //right leg\n\n //eyes\n fill(\"black\");\n square(this.x + 3, this.y + 20, 15);\n square(this.x + 30, this.y + 20, 15);\n\n }", "title": "" }, { "docid": "2b28a71ad1b16bb1942e78a77c177533", "score": "0.5982694", "text": "function render() {\n\n // render the nodes\n renderNodes();\n\n // render links\n renderLinks();\n\n // render the reveal arrow\n renderReveal();\n }", "title": "" }, { "docid": "215ec639845818e40e19685bb05553b2", "score": "0.5979521", "text": "function draw() {\n ///////////////////////////////////////////////\n background(245);\n ///////////////////////////////////////////////\n //var t0 = performance.now();\n ///////////////////////////////////////////////\n if (W1.show === 1) W1.draw();\n if (W2.show === 1) W2.draw();\n if (W3.show === 1) W3.draw();\n if (W4.show === 1) W4.draw();\n if (W5.show === 0) W5.draw();\n ///////////////////////////////////////////////\n \n\n ///////////////////////////////////////////////\n draw__info();\n draw__menu();\n draw__VCB();\n Terminal_Data_Packets.draw();\n /////////////////////////////////////////////// \n //var t1 = performance.now();\n /////////////////////////////////////////////// \n //loop();\n //info.announce(1, Terminal_Data_Packets.text_len, xText[4]);\n //mm_CC++;\n}", "title": "" }, { "docid": "a195fe11bb7da425daa2f2879208b92e", "score": "0.597706", "text": "function draw() {\n for(var i=1;i<listado.length;i++){\n fill(14+(i*10),210,14+(i*10));\n textSize(20);\n text(listado[i],50*(i+1),50);\n rect(50*(i+1), 55, 30, listado[i]*5);\n }\n}", "title": "" }, { "docid": "a8f837987db5f05bbfc1fb918c397104", "score": "0.5974679", "text": "_draw_state() {\n\n for (let i = 0; i < this._engine._tabPiece.length; ++i) {\n let intersection = this._engine._cases[i];\n\n let letter = this._engine._tabPiece[i]._coordinates._letter;\n let number = this._engine._tabPiece[i]._coordinates._number;\n let color = this._engine._tabPiece[i]._color;\n\n let stack = this._engine._tabPiece[i]._stack;\n let level = this._engine._tabPiece[i]._level;\n\n this._draw_piece(letter, number, color, intersection.sixth(), stack, level);\n }\n }", "title": "" }, { "docid": "53282e63ea9796ca245c22eb29be6a90", "score": "0.59740865", "text": "function draw() {\n\n var\tselectValue = d3.select('select').property('value');\n d3.select('svg').remove();\n createMap(selectValue);\n d3.select(\"#rubutton\")\n .style(\"font\", \"Monotype Corsiva\")\n .on(\"click\", function(){\n createPie();});\n}", "title": "" }, { "docid": "82386303cd51fc53da52dc49bf33ae8d", "score": "0.5970175", "text": "drawObjs() {\n\t\t\t// draw each object\n\t\t\tfor (const obj of Object.values(this.objs))\t{\n\t\t\t\t// skip any gripped object here\n\t\t\t\tif (obj.gripped) { continue; }\n\n\t\t\t\tlet blockMatrix = obj.block_matrix;\n\t\t\t\t\n\t\t\t\t// call drawing helper functions with additional infos (gripped, color)\n\t\t\t\tlet ctx = this.objCanvas.getContext(\"2d\");\n\t\t\t\tlet params = {\n\t\t\t\t\tx: obj.x,\n\t\t\t\t\ty: obj.y,\n\t\t\t\t\tcolor: obj.color,\n\t\t\t\t\thighlight: false\n\t\t\t\t}\n\t\t\t\tthis._drawBlockObj(ctx, blockMatrix, params);\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "f3c04699c31fd65ee7df662723f2cfb8", "score": "0.59669006", "text": "draw()\n {\n // Tegner kassen til vinduet\n fill(0);\n stroke(60, 60, 60);\n strokeWeight(5);\n rect(this.position.x, this.position.y, this.size.x, this.size.y);\n\n if (this.close != undefined)\n {\n // Tegner luk knappen\n fill(255, 0, 0);\n stroke(60, 60, 60);\n strokeWeight(5);\n rect(this.position.x + this.size.x - 30, this.position.y + 10, 20, 20);\n\n // Aktiverer hvis man klikker på luk knappen\n if (isClicked == false && mouseIsPressed && \n this.position.x + this.size.x - 30 < mouseX && \n mouseX < this.position.x + this.size.x - 10 && \n this.position.y + 10 < mouseY && \n mouseY < this.position.y + 30)\n {\n isClicked = true;\n buttonLabels[getIndex(buttonLabels, this.btnName)].subButtons[getIndex(buttonLabels[getIndex(buttonLabels, this.btnName)].subButtons, this.content.name)].active = false; // Finder knappen og ændrer dens aktiv værdi til false\n }\n }\n\n // Tegner titlen på vinduet\n strokeWeight(0);\n fill(255);\n textSize(30);\n text(this.content.name, this.position.x + this.size.x / 2 - textWidth(this.content.name) / 2, this.position.y + 30);\n\n //Tegner beskrivelsen af vinduet\n textSize(15);\n text(this.content.description, this.position.x + 10, this.position.y + 50, this.size.x - 20);\n }", "title": "" }, { "docid": "11e1f0bd64b9b90f02de9480942f298f", "score": "0.5961821", "text": "drawView(x, y, width, height) {\n const emails = this.main.dataHandler.getEmails();\n const start = this.main.dataHandler.timeSpan.startTime;\n const end = this.main.dataHandler.timeSpan.endTime;\n\n for(const email of emails) {\n const edgeX = this.approximateX(start, end, email.date.getTime(), width);\n const y1 = Math.round(this.order.get(email.fromId) / this.order.size * height);\n const y2 = Math.round(this.order.get(email.toId) / this.order.size * height);\n \n const edgeY = Math.min(y1, y2);\n const edgeHeight = Math.max(y1, y2) - edgeY;\n\n if(edgeX < 0) continue;\n\n this.graphics.globalAlpha = this.styleOptions.alpha;\n\n if(this.main.dataHandler.highlightPersons !== undefined){\n for(let person of this.main.dataHandler.highlightPersons){\n if(person === email.fromId || person === email.toId) {\n this.graphics.fillStyle = this.styleOptions.highlightedEdgeColor;\n break;\n }\n else {\n this.graphics.fillStyle = this.styleOptions.color;\n }\n }\n }\n\n else if(this.styleOptions.useGradient) {\n const gradient = this.graphics.createLinearGradient(0, edgeY + y, 0, edgeHeight + edgeY + y);\n\n if(y1 >= y2) {\n gradient.addColorStop(0, this.styleOptions.gradientColor1);\n gradient.addColorStop(0.5, this.styleOptions.gradientColor2);\n gradient.addColorStop(1, this.styleOptions.gradientColor3);\n } \n else {\n gradient.addColorStop(0, this.styleOptions.gradientColor3);\n gradient.addColorStop(0.5, this.styleOptions.gradientColor2);\n gradient.addColorStop(1, this.styleOptions.gradientColor1);\n }\n\n this.graphics.fillStyle = gradient;\n }\n else {\n this.graphics.fillStyle = this.styleOptions.color;\n }\n \n this.graphics.fillRect(x + edgeX, y + edgeY, 1, edgeHeight);\n this.graphics.globalAlpha = 1;\n }\n }", "title": "" }, { "docid": "10a5365a269327b85ccd8981ac91a1c2", "score": "0.5961286", "text": "function paint() {\n\t\n\tpush()\n\ttranslate(width / 2, height / 2)\n\t\n\tpaintBackground()\n\tpaintScale()\n\tpaintLabels()\n\tpaintPointer()\n\tpaintForeground()\t\n\t\n\tpop()\t\n\n\n}", "title": "" }, { "docid": "1651f05b4f15c40296eebbb202ca8d00", "score": "0.59550714", "text": "function draw ()\n {\n // clear html\n $('#content_container').html(\"\");\n\n // this array is used to store items with the right status\n var foundItemsArray = [];\n\n // count how many items are drawn\n var counter = 0;\n\n // show all items\n if (whatToShow === 0)\n {\n // how many items to show?\n itemsNumber = responseArray.length;\n // how many pages?\n pagesNumber = Math.ceil(itemsNumber / itemsPerPage);\n // show\n if (responseArray.length === 0)\n {\n $('#content_container').html('<div class=\"message\"><div class=\"mt\">Nothing to show...</div></div>');\n }\n else\n {\n // show itemsPerPage items on a page, depending on the selected page\n for (var i = (selectedPage * itemsPerPage) - itemsPerPage; i < responseArray.length; i++) // [*FOR*]\n {\n if (counter < itemsPerPage)\n {\n if (responseArray[i].state === \"p\")\n {\n $('#content_container').append('<div class=\"item\" id=\"' + responseArray[i].id\n + '\"><div class=\"checkbox\" id=\"' + responseArray[i].id + '\"></div><div class=\"content\" id=\"'\n + responseArray[i].id + '\">' + responseArray[i].value + '</div><div class=\"remove_item\" id=\"'\n + responseArray[i].id + '\"></div></div>');\n counter++;\n }\n else\n {\n $('#content_container').append('<div class=\"item done\" id=\"' + responseArray[i].id\n + '\"><div class=\"checkbox checked\" id=\"' + responseArray[i].id + '\"></div><div class=\"content\" id=\"'\n + responseArray[i].id + '\">' + responseArray[i].value + '</div><div class=\"remove_item\" id=\"'\n + responseArray[i].id + '\"></div></div>');\n counter++;\n }\n }\n else\n {\n break;\n }\n }\n }\n }\n\n\n // show pending items\n if (whatToShow === 1)\n {\n // get items with the right status\n responseArray.forEach(function (item)\n {\n if (item.state === \"p\")\n {\n foundItemsArray.push(item);\n }\n });\n // how many items to show?\n itemsNumber = foundItemsArray.length;\n // just in case...\n pend = foundItemsArray.length;\n // how many pages?\n pagesNumber = Math.ceil(itemsNumber / itemsPerPage);\n // show\n if (foundItemsArray.length === 0)\n {\n $('#content_container').html('<div class=\"message\"><div class=\"mt\">Nothing to show...</div></div>');\n }\n else\n {\n // show itemsPerPage items on a page, depending on the selected page\n for (var i = (selectedPage * itemsPerPage) - itemsPerPage; i < foundItemsArray.length; i++) // [*FOR*]\n {\n if (counter < itemsPerPage)\n {\n $('#content_container').append('<div class=\"item\" id=\"' + foundItemsArray[i].id\n + '\"><div class=\"checkbox\" id=\"' + foundItemsArray[i].id + '\"></div><div class=\"content\" id=\"'\n + foundItemsArray[i].id + '\">' + foundItemsArray[i].value + '</div><div class=\"remove_item\" id=\"'\n + foundItemsArray[i].id + '\"></div></div>');\n counter++;\n }\n else\n {\n break;\n }\n }\n }\n }\n\n // show completed items\n if (whatToShow === 2)\n {\n // get items with the right status\n responseArray.forEach(function (item)\n {\n if (item.state === \"d\")\n {\n foundItemsArray.push(item);\n }\n });\n // how many items to show?\n itemsNumber = foundItemsArray.length;\n // just in case...\n done = foundItemsArray.length;\n // how many pages?\n pagesNumber = Math.ceil(itemsNumber / itemsPerPage);\n // show\n if (foundItemsArray.length === 0)\n {\n $('#content_container').html('<div class=\"message\"><div class=\"mt\">Nothing to show...</div></div>');\n }\n else\n {\n // show itemsPerPage items on a page, depending on the selected page\n for (var i = (selectedPage * itemsPerPage) - itemsPerPage; i < foundItemsArray.length; i++) // [*FOR*]\n {\n if (counter < itemsPerPage)\n {\n $('#content_container').append('<div class=\"item done\" id=\"' + foundItemsArray[i].id\n + '\"><div class=\"checkbox checked\" id=\"' + foundItemsArray[i].id + '\"></div><div class=\"content\" id=\"'\n + foundItemsArray[i].id + '\">' + foundItemsArray[i].value + '</div><div class=\"remove_item\" id=\"'\n + foundItemsArray[i].id + '\"></div></div>');\n counter++;\n }\n else\n {\n break;\n }\n }\n }\n }\n navigation();\n stats();\n }", "title": "" }, { "docid": "5c5323ffc7d89d599a341d0b52c72e59", "score": "0.5950627", "text": "draw() {\n for ( let o of this.objects ) {\n o.draw()\n }\n }", "title": "" }, { "docid": "a42237f0011975aa5eb407dc9394f8b1", "score": "0.59493923", "text": "function mainDraw(data) {\n\t\t\t\tif (data.canvasValid == false) {\n\t\t\t\t\tclear(data.ctx);\n\t\t\t\t\tdata.ctx.fillStyle = options.fill;\n\t\t\t\t\tdata.ctx.fillRect(0, 0, data.canvas.width, data.canvas.height); // on rend le canvas opaque pour mettre en valeur la selection\n\n\t\t\t\t\t// Add stuff you want drawn in the background all the time here\n\t\t\t\t\tdata.rectangle.draw(data.ctx,data,options); // we used to call drawshape, but now each box draws itself\n\t\t\t\t\t// Add stuff you want drawn on top all the time here\n\t\t\t\t\tdata.canvasValid = true;\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "d0442bbdaba77b31d7cb258aee15fc22", "score": "0.5947607", "text": "function _render() {\n var player = game.player();\n var canvas = document.getElementById(\"game-layer\");\n var context = canvas.getContext(\"2d\");\n context.fillStyle = \"black\";\n context.fillRect(0, 0, canvas.width, canvas.height);\n var entity, enemies = game.enemies();\n for (var i = 0; i < game.barricades().length; i++) {\n if (game.barricades()[i].destroyed) continue;\n _drawBarricade(context, game.barricades()[i]);\n }\n for (var i = 0; i < game.missiles().length; i++) {\n if (game.missiles()[i] == null) continue;\n _drawMissile(context, game.missiles()[i])\n }\n for (var i = 0; i < game.rows(); i++) {\n for (var j = 0; j < game.cols(); j++) {\n entity = enemies[i][j];\n if (entity == null) continue;\n _drawEnemy(context, entity, i+1);\n }\n }\n if (!player.blink) _drawPlayer(context, player);\n }", "title": "" }, { "docid": "ba4c35ada7ee26fb80ce8fc550d27bc7", "score": "0.59421915", "text": "show () {\n noFill();\n stroke(255);\n strokeWeight(2);\n rect(this.x, this.y, this.width, this.height);\n }", "title": "" }, { "docid": "8b5fb85e985a173b860995b922f06281", "score": "0.5941228", "text": "function drawObjects() {\r\n for (let i = 0; i < trees.length; i++)\r\n trees[i].draw();\r\n for (let i = 0; i < movingObjects.length; i++)\r\n movingObjects[i].draw();\r\n basket.draw();\r\n showHighscore();\r\n }", "title": "" }, { "docid": "1b65a364721eac55a9cee8f60510e5c2", "score": "0.59372926", "text": "function draw() {\nfor(var i = 0; i < 75; i++) {\nret[i].display();\nret2[i].display();\n\t}\n}", "title": "" }, { "docid": "3284ff8a74c146fd98d0ebbe94191d59", "score": "0.593708", "text": "function drawItems(items){\n //we will take in a paramter(items) and iterate over it to build\n //a template to draw to the screen.\n\n }", "title": "" } ]
8d2814c71830ef0ce26803838ef80e51
Loads Braintree client and modules
[ { "docid": "a57a68a91db9c831a48a413c1bf2fc65", "score": "0.78820294", "text": "load ({ form }) {\n debug('loading Braintree libraries');\n this.form = form;\n\n const part = after(2, () => this.initialize());\n const get = (lib, done = () => {}) => {\n const uri = `https://js.braintreegateway.com/web/${BRAINTREE_CLIENT_VERSION}/js/${lib}.min.js`;\n loadScript(uri, error => {\n if (error) this.error('venmo-load-error', { cause: error });\n else done();\n });\n };\n\n const modules = () => {\n if (this.braintreeClientAvailable('venmo')) part();\n else get('venmo', part);\n if (this.braintreeClientAvailable('dataCollector')) part();\n else get('data-collector', part);\n };\n\n if (this.braintreeClientAvailable()) modules();\n else get('client', modules);\n }", "title": "" } ]
[ { "docid": "d6f607f251e8dffcbad1a8325fd873ef", "score": "0.66306573", "text": "initialize () {\n debug('Initializing Braintree client');\n\n const authorization = this.config.clientAuthorization;\n const braintree = window.braintree;\n\n braintree.client.create({ authorization }, (error, client) => {\n if (error) return this.fail('venmo-braintree-api-error', { cause: error });\n debug('Braintree client created');\n braintree.dataCollector.create({ client, paypal: true }, (error, collector) => {\n if (error) return this.fail('venmo-braintree-api-error', { cause: error });\n debug('Device data collector created');\n this.deviceFingerprint = collector.deviceData;\n braintree.venmo.create({ client, allowDesktop: true }, (error, venmo) => {\n if (error) return this.fail('venmo-braintree-api-error', { cause: error });\n debug('Venmo client created');\n this.venmo = venmo;\n this.emit('ready');\n });\n });\n });\n }", "title": "" }, { "docid": "8049ddfff19b9d32a9097ac2239fc517", "score": "0.65951586", "text": "connectBraintree() {\n this.braintreeGateway = braintree.connect({\n environment: braintree.Environment.Sandbox,\n merchantId: this.braintreeMerchantId,\n publicKey: this.braintreePublicKey,\n privateKey: this.braintreePrivateKey\n });\n }", "title": "" }, { "docid": "7d696cd2be68056b47f10b21d1389e83", "score": "0.56130224", "text": "function loadClient() {\n gapi.load('client', start);\n}", "title": "" }, { "docid": "d828a2a0caba78a572d8d6a82100bee5", "score": "0.5594828", "text": "waitForLibrariesThenInit () {\n if (typeof braintree !== 'undefined' && typeof braintree.client !== 'undefined' && typeof braintree.hostedFields !== 'undefined' && braintree.threeDSecure !== 'undefined') {\n this.initFields()\n }\n else {\n window.setTimeout(() => {\n this.waitForLibrariesThenInit()\n }, 100)\n }\n }", "title": "" }, { "docid": "418ea927aad42d7c355a2c7f19648f1e", "score": "0.5571694", "text": "function addCheckout(){var A=document.getElementsByTagName(\"head\")[0],v=document.createElement(\"script\");v.type=\"text/javascript\",v.id=\"braintree-dropin-paypal-checkout-script\",v.async=1,v.setAttribute(\"data-log-level\",\"warn\"),v.src=\"https://www.paypalobjects.com/api/checkout.4.0.130.min.js\",A.appendChild(v)}", "title": "" }, { "docid": "b21bf1b03fcfe2cefdb435878162cd5d", "score": "0.54125285", "text": "initFields () {\n this.startLoading()\n braintree.client.create({\n authorization: this.settings.payment_token\n }).then((clientInstance) => {\n this.client = clientInstance\n this.$wrappers = this.$element.find('.braintree-hosted-fields-wrapper')\n const fields = {}\n this.$wrappers.each(function () {\n const $this = $(this)\n const name = $this.data('braintreeHostedFieldsField')\n const settings = {\n container: this,\n }\n const $input = $this.children('input, select')\n if ($input.get(0).tagName === 'SELECT') {\n settings.select = true\n $this.addClass('select-input')\n }\n else {\n settings.placeholder = this.getAttribute('placeholder')\n $this.addClass('text-input')\n }\n fields[name] = settings\n $this.css({\n 'height': $input.outerHeight(),\n 'box-sizing': 'border-box',\n })\n })\n return braintree.hostedFields.create({\n client: clientInstance,\n styles: this.getStyles(),\n fields: $.extend(true, {}, this.settings.fields, fields),\n })\n }).then((hostedFieldsInstance) => {\n this.hostedFields = hostedFieldsInstance\n // The type attributes conflict with jquery.validate 1.11. Remove them.\n this.$wrappers.find('iframe').removeAttr('type')\n this.$wrappers.addClass('braintree-hosted-fields-processed')\n this.$wrappers.addClass(this.settings.wrapperClasses.join(' '))\n return braintree.threeDSecure.create({\n version: 2,\n client: this.client,\n })\n }).then((threeDSecureInstance) => {\n this.client3ds = threeDSecureInstance\n this.stopLoading()\n })\n }", "title": "" }, { "docid": "c59a00c98262e9765170476e3f098d3c", "score": "0.53832614", "text": "function braintreeVDotZeroIntegration(configObj) {\n config = configObj;\n\n $form = config.form;\n\n braintree.client.create({\n authorization: config.clientToken\n }, function braintreeClientInstanceCallback(clientCreateError, clientInstance) {\n if (clientCreateError) {\n onBraintreeClientInitError();\n\n return;\n }\n\n btClient = clientInstance;\n braintree.dataCollector.create({\n client: clientInstance,\n kount: true\n }, handleDeviceDataCollection);\n\n onBraintreeClientInit();\n });\n\n if (config.submitButton) {\n config.submitButton.off('click').click(tokenize);\n } else {\n $('body')\n .off('orderFormFSMBeforeFormSerialization')\n .on('orderFormFSMBeforeFormSerialization', tokenize);\n }\n }", "title": "" }, { "docid": "7e42870a201213281befa64651d4dfba", "score": "0.5287054", "text": "async loadBlockchainData() {\n console.log(\"init web3\");\n let web3;\n if (window.ethereum) {\n web3 = new Web3(window.ethereum);\n window.ethereum.enable();\n }\n else web3 = new Web3(Web3.givenProvider);\n this.contractISUSD = new web3.eth.Contract(abiLoanToken, loanTokenSUSD);\n this.contractIRBTC = new web3.eth.Contract(abiLoanToken, loanTokenRBTC);\n this.contractTokenSUSD = new web3.eth.Contract(abiTestToken, testTokenSUSD);\n this.contractTokenRBTC = new web3.eth.Contract(abiTestToken, testTokenRBTC);\n const accounts = await web3.eth.getAccounts();\n this.web3 = web3;\n this._isMounted && this.setState({ account: accounts[0] });\n }", "title": "" }, { "docid": "6d00394a1493946675d3d9417147bd69", "score": "0.5263188", "text": "loadRpcClient () {\n this.rpc = new RpcClient(this.config.rpc)\n }", "title": "" }, { "docid": "13491a42560e19d94cf2f2133b869e88", "score": "0.51604706", "text": "async function loadWeb3() {\n // Connect to the network\n // Modern dapp browsers...\n if (window.ethereum) {\n try {\n // Request account access if needed\n await ethereum.enable();//If this doesn't work an error is thrown\n console.log(\"User has a MODERN dapp browser!\");\n provider = new ethers.providers.Web3Provider(ethereum);\n // console.log(provider);\n\n // Acccounts now exposed. Load the contract!\n loadBlockchainData();\n } catch (error) {\n console.log(\"There was and error: \", error.message);//In case user denied access\n }\n }\n // Legacy dapp browsers (acccounts always exposed)...\n else if (window.web3) {\n provider = new ethers.providers.Web3Provider(web3.currentProvider);\n console.log(\"User has a LEGACY dapp browser!\");\n loadBlockchainData();\n }\n // Non-dapp browsers...\n else {\n //Load blockchain and contract data (jackpot, last games) via ethers default provider (Infura, Etherscan)\n window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!');\n provider = ethers.getDefaultProvider('ropsten');\n // console.log(provider);\n loadBlockchainData();\n }\n}", "title": "" }, { "docid": "a4faa71066d8cac8f67cf11efa41d13c", "score": "0.5158473", "text": "async function init() {\n \n // let kovanProvider = new Web3.providers.HttpProvider(\"https://kovan.infura.io/v3/d126f392798444609246423b06116c77\");\n // setLoadingMessage(\"Initializing Biconomy ...\");\n let matictestProvider = new Web3.providers.HttpProvider(maticProvider);\n const biconomy = new Biconomy(matictestProvider, { apiKey: 'Mg4po8zbw.b0e298c7-8f86-4543-b9c5-64ae297ebc16', debug: true });\n\n // This web3 instance is used to read normally and write to contract via meta transactions.\n web3 = new Web3(biconomy); \n // This web3 instance is used to get user signature from connected wallet\n // walletWeb3 = new Web3(window.ethereum);\n\n biconomy.onEvent(biconomy.READY, () => {\n // Initialize your dapp here like getting user accounts etc\n contract = new web3.eth.Contract(\n abi, contractAddress \n );\n \n \n // Instantiate a new truffle contract from the artifact\n contracts.FanTestToken = TruffleContract(JSON.parse(JSON.stringify(jsonData)));\n // Connect provider to interact with contract\n contracts.FanTestToken.setProvider(matictestProvider);\n contracts.FanTestToken.deployed().then(function(instance) {\n console.log(\"Fan Test Token Address: \", instance.address);\n });\n \n console.log(contract);\n //console.log(contract.currentProvider.selectedAddress);\n //setSelectedAddress(provider.selectedAddress);\n //getQuoteFromNetwork();\n // provider.on(\"accountsChanged\", function (accounts) {\n // setSelectedAddress(accounts[0]);\n \n // });\n }).onEvent(biconomy.ERROR, (error, message) => {\n // Handle error while initializing mexa\n });\n// } else {\n// console.log(\"Metamask not installed\");\n// }\n}", "title": "" }, { "docid": "e51211921ce97f6184c31750c5835b88", "score": "0.5130251", "text": "function handleClientLoad() {\n gapi.load(\"client\", initClient);\n }", "title": "" }, { "docid": "2191dabb32bc59846a55aa8e29033b2b", "score": "0.51106936", "text": "async function loadWeb3() {\n if (window.ethereum) {\n window.web3 = new Web3(window.ethereum);\n window.ethereum.enable();\n }\n}", "title": "" }, { "docid": "3993fa65450e87756c420a0a530ab8ee", "score": "0.51059216", "text": "function load()\n{\n dashcode.setupParts();\n return;\n}", "title": "" }, { "docid": "508b70872237d079612196eef8202f4c", "score": "0.50899756", "text": "async loadWeb3(){\n if(window.ethereum){\n window.web3 = new Web3(window.ethereum)\n //console.log(window.web3)\n await window.ethereum.enable()\n } else if(window.web3){\n window.web3 = new Web3(window.web3.currentProvider)\n await window.ethereum.enable()\n }else{\n window.alert('Please use metamask!!!')\n }\n\n }", "title": "" }, { "docid": "9466814666846d49020183dfb91ca118", "score": "0.5057796", "text": "async loadBlockchainData() { \n const web3 = window.web3\n const accounts = await web3.eth.getAccounts()\n this.setState({ account: accounts[0] })\n const ethBalance = Number(web3.utils.fromWei(await web3.eth.getBalance(accounts[0]), 'Ether')).toFixed(3)\n this.setState({ ethBalance }) \n\n // get networkId\n const networkId = await web3.eth.net.getId()\n this.setState({ networkId }) \n\n // Block to load token (Token.sol) \n const tokenData = Token.networks[networkId]\n\n if(tokenData) {\n var token = new web3.eth.Contract(Token.abi, tokenData.address)\n this.setState({ token })\n const tokenAddress = tokenData.address\n this.setState({ tokenAddress })\n const totalSupply = await token.methods.totalSupply().call()\n this.setState({ totalSupply })\n const tokenSymbol = await token.methods.symbol().call()\n this.setState({ tokenSymbol }) \n const tokenName = await token.methods.name().call()\n this.setState({ tokenName }) \n // Block to calculate token balanceOf\n const tokenBalance = await token.methods.balanceOf(this.state.account).call()\n console.log(tokenBalance)\n this.setState({ tokenBalance: Number(web3.utils.fromWei(tokenBalance, 'ether')).toFixed(3) })\n // block to calculate tierLevel\n if(tokenBalance) {\n if(web3.utils.fromWei(tokenBalance, 'ether') >= 1000) { \n var tierLevel ='Gorvernor' \n } \n else { \n tierLevel = 'Frequent flyer' \n }\n this.setState({ tierLevel: tierLevel })\n }\n } else {\n window.alert('Token Contract not deployed to the detected network')\n }\n\n // block to load EthSwap (EthSwap.sol)\n const ethSwapData = EthSwap.networks[networkId]\n\n if(ethSwapData) {\n var ethSwap = new web3.eth.Contract(EthSwap.abi, ethSwapData.address)\n this.setState({ ethSwap })\n const ethSwapAddress = ethSwapData.address\n this.setState({ ethSwapAddress })\n const ethSwapBalance = Number(web3.utils.fromWei(await web3.eth.getBalance(ethSwapAddress), 'Ether')).toFixed(3)\n this.setState({ ethSwapBalance })\n const ethSwapTokenBalance = await token.methods.balanceOf(this.state.ethSwapAddress).call()\n this.setState({ ethSwapTokenBalance}) \n //console.log(\"ethSwapTokenBalance=\", this.state.ethSwapTokenBalance) \n // const contractRate = await ethSwap.methods.getRate().call()\n // this.setState({ contractRate})\n // console.log(\"contractRate=\", this.state.contractRate) \n } else {\n window.alert('EthSwap Contract not deployed to the detected network')\n }\n\n // block to compute the circulating tokens\n if(ethSwapData && tokenData) { \n const circulatingToken = Number(web3.utils.fromWei(this.state.totalSupply, \"ether\") - web3.utils.fromWei(this.state.ethSwapTokenBalance, \"ether\")).toFixed(3)\n this.setState({ circulatingToken: circulatingToken })\n }\n\n // block to compute etherscan Tx url\n if(this.state.Tx) {\n const etherscan = \"https://rinkeby.etherscan.io/tx/\"\n const txUrl = etherscan+this.state.Tx\n this.setState({ txUrl })\n }\n\n // block to compute etherscan contract url for ethswap\n if(this.state.ethSwapAddress) {\n const etherscan = \"https://rinkeby.etherscan.io/address/\"\n const ethSwapContractUrl = etherscan+this.state.ethSwapAddress\n this.setState({ ethSwapContractUrl })\n }\n\n // block to compute etherscan contract url for token\n if(this.state.tokenAddress) {\n const etherscan = \"https://rinkeby.etherscan.io/token/\"\n const tokenContractUrl = etherscan+this.state.tokenAddress\n this.setState({ tokenContractUrl })\n }\n\n this.setState({ loading: false })\n }", "title": "" }, { "docid": "a7ca92c1cf80a6b5b1028b4a803a93e0", "score": "0.50468785", "text": "async loadWeb3() {\n if (window.ethereum) {\n window.web3 = new Web3(window.ethereum)\n await window.ethereum.enable()\n }\n else if (window.web3) {\n window.web3 = new Web3(window.web3.currentProvider)\n }\n\n //check metamask extension is installed on chrome browser\n else {\n window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')\n }\n }", "title": "" }, { "docid": "8840a41e9ccc6d99d2a9b09d6d4b039f", "score": "0.50245893", "text": "async loadWeb3(){\n if (window.ethereum) { // Modern dapp browsers...\n window.web3 = new web3(window.ethereum)\n await window.ethereum.enable();\n }\n else if (window.web3) { // Legacy dapp browsers...\n window.web3 = new web3(window.web3.currentProvider)\n }\n else { // If no injected web3 instance is detected, fall back to Ganache\n window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')\n }\n }", "title": "" }, { "docid": "9ffccdbca9ffa4219a027344d5ac99f1", "score": "0.5013118", "text": "function load()\n{\n\tdashcode.setupParts();\n\tloadPrefs();\n\tversionCheck();\n}", "title": "" }, { "docid": "b29e8c2abf344ed111c5c5ef64b497a2", "score": "0.5011397", "text": "function handleClientLoad() {\n gapi.load('client', initClient);\n}", "title": "" }, { "docid": "b29e8c2abf344ed111c5c5ef64b497a2", "score": "0.5011397", "text": "function handleClientLoad() {\n gapi.load('client', initClient);\n}", "title": "" }, { "docid": "e297a0ff27a94d0a676418f64e019cd6", "score": "0.5005416", "text": "async function initControllers() {\n await blockChainController.initBlockchain();\n}", "title": "" }, { "docid": "ae9e7647f31019649f7a4a6fb0a28bd7", "score": "0.49982333", "text": "async function loadWeb3() {\n // Connect to the network\n // Modern dapp browsers...\n if (window.ethereum) {\n try {\n // Request account access if needed\n await ethereum.enable();//If this doesn't work an error is thrown\n console.log(\"User has a MODERN dapp browser!\");\n showAlert(\"You are ready to play!\", \"success\");\n provider = new ethers.providers.Web3Provider(ethereum);\n // console.log(provider);\n\n // Acccounts now exposed. Load the contract!\n // loadBlockchainData();\n } catch (error) {\n console.log(\"There was and error: \", error.message);//In case user denied access\n showAlert(\"App needs access your account in order to play\", \"fail\");\n //Load blockchain and contract data (jackpot, last games) via ethers default provider (Infura, Etherscan)\n provider = ethers.getDefaultProvider('goerli');\n }\n }\n // Legacy dapp browsers (acccounts always exposed)...\n else if (window.web3) {\n provider = new ethers.providers.Web3Provider(web3.currentProvider);\n console.log(\"User has a LEGACY dapp browser!\");\n showAlert(\"You are ready to play!\", \"success\");\n // loadBlockchainData();\n }\n // Non-dapp browsers...\n else {\n //Load blockchain and contract data (jackpot, last games) via ethers default provider (Infura, Etherscan)\n console.log('Non-Ethereum browser detected. You should consider trying MetaMask!');\n showAlert(\"Non-Ethereum browser detected. You should consider trying MetaMask in order to play\", \"fail\");\n provider = ethers.getDefaultProvider('goerli');\n // console.log(provider);\n // loadBlockchainData();\n }\n loadBlockchainData();\n}", "title": "" }, { "docid": "41ea99e31edf35df3c46ec8d0118a4e6", "score": "0.49780935", "text": "function BuybidApi () {}", "title": "" }, { "docid": "9bf1de634cf6609629fc600492a9084e", "score": "0.4975236", "text": "loadProvider() {\n const ethereumProvider = metamask.createDefaultProvider()\n this.provider = 'mascara'\n this.web3 = new Web3(ethereumProvider)\n }", "title": "" }, { "docid": "bd535e36218eaa04ee49f085ef164796", "score": "0.49540657", "text": "async loadWeb3() {\n if (window.ethereum) {\n window.web3 = new Web3(window.ethereum)\n await window.ethereum.enable()\n }\n else if (window.web3) {\n window.web3 = new Web3(window.web3.currentProvider)\n }\n else {\n window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')\n }\n }", "title": "" }, { "docid": "bd535e36218eaa04ee49f085ef164796", "score": "0.49540657", "text": "async loadWeb3() {\n if (window.ethereum) {\n window.web3 = new Web3(window.ethereum)\n await window.ethereum.enable()\n }\n else if (window.web3) {\n window.web3 = new Web3(window.web3.currentProvider)\n }\n else {\n window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')\n }\n }", "title": "" }, { "docid": "bd535e36218eaa04ee49f085ef164796", "score": "0.49540657", "text": "async loadWeb3() {\n if (window.ethereum) {\n window.web3 = new Web3(window.ethereum)\n await window.ethereum.enable()\n }\n else if (window.web3) {\n window.web3 = new Web3(window.web3.currentProvider)\n }\n else {\n window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')\n }\n }", "title": "" }, { "docid": "7d9a5d8bf59e168ad8d4675523a4c206", "score": "0.4942416", "text": "function load()\n{\n dashcode.setupParts();\n}", "title": "" }, { "docid": "7d9a5d8bf59e168ad8d4675523a4c206", "score": "0.4942416", "text": "function load()\n{\n dashcode.setupParts();\n}", "title": "" }, { "docid": "04a74b8c79e16e819c5fae625acb71ad", "score": "0.49373144", "text": "async loadWeb3() {\n\t\tif (window.ethereum) {\n\t\t\twindow.web3 = new Web3(window.ethereum);\n\t\t\tawait window.ethereum.enable();\n\t\t} else if (window.web3) {\n\t\t\twindow.web3 = new Web3(window.web3.currentProvider);\n\t\t} else {\n\t\t\twindow.alert('Non-Ethereum browser detected. You should consider trying MetaMask!');\n\t\t}\n\t}", "title": "" }, { "docid": "2ae27796131a73fb59d128116f955c5a", "score": "0.49275133", "text": "async function initContract() {\n // Initialize connection to the NEAR testnet\n const near = await (0, _nearApiJs.connect)(Object.assign({\n deps: {\n keyStore: new _nearApiJs.keyStores.BrowserLocalStorageKeyStore()\n }\n }, nearConfig)); // Initializing Wallet based Account. It can work with NEAR testnet wallet that\n // is hosted at https://wallet.testnet.near.org\n\n window.walletConnection = new _nearApiJs.WalletConnection(near);\n window.utils = _nearApiJs.utils; // Getting the Account ID. If still unauthorized, it's just empty string\n\n window.accountId = window.walletConnection.getAccountId();\n window.account = new _nearApiJs.Account(near.connection, accountId); // Initializing our contract APIs by contract name and configuration\n\n window.contract = await new _nearApiJs.Contract(window.walletConnection.account(), nearConfig.contractName, {\n // View methods are read only. They don't modify the state, but usually return some value.\n viewMethods: [\"get_greeting\", \"getUserName\", \"get_ipfs_key\", \"getTwitchName\", \"getNearName\", \"get_user_name_list\", \"get_likes\", \"get_dislikes\", \"get_listens\"],\n // Change methods can modify the state. But you don't receive the returned value when called.\n changeMethods: [\"set_greeting\", \"setNewUserName\", \"set_IPFS_Keys\", \"setTwitchName\", \"setNearName\", \"addUserNameToRegistry\", \"add_user_name_to_registry\", \"add_to_likes\", \"add_to_dislikes\", \"add_listens\", \"sub_listens\", \"transfer_listens\"]\n });\n}", "title": "" }, { "docid": "1fe7b89bf359d1cb031bc9de3e77854f", "score": "0.49243644", "text": "function init(){\n // Initialize the billing plugin\n inappbilling.init(successHandler, errorHandler, {showLog:true});\n }", "title": "" }, { "docid": "3d198b9688b3fe86c67a05dfb554f61b", "score": "0.48968494", "text": "async loadBlockChain() {\n\t\t// Modern DApp Browsers\n\t\tif (window.ethereum) {\n\t\t\tweb3 = new Web3(window.ethereum);\n this.getAccounts();\n\t\t\ttry { \n\t\t\t\twindow.ethereum.enable().then(function() {\n\t\t\t\t\t//Set State When recieve Emission from Event from Smart Contract\n //LinkPal = new web3.eth.Contract(abiLinkPal, contractAddress);\n ChainlinkContract = new web3.eth.Contract(abiERC20, ChainlinkContractAddress);\n //this.setState({ LinkPalState : LinkPal });\n\t\t\t\t}.bind(this));\n\t\t\t} catch(e) {\n // User has denied account access to DApp...\n console.log(e);\n\t\t\t}\n\t\t}\n\t\t// Legacy DApp Browsers\n\t\telse if (window.web3) {\n\t\t\tweb3 = new Web3(window.web3.currentProvider);\n this.getAccounts();\n\t\t}\n\t\t// Non-DApp Browsers\n\t\telse {\n this.toggleError();\n\t\t}\n\t}", "title": "" }, { "docid": "7d934a6b525fe6a60e9ffe6476a4e3fa", "score": "0.48857525", "text": "function load() {\n var opts = state.opts;\n // re-initialize dom now that we have the body\n dom.init({ window: window });\n // grab the root element\n var root = dom.getDocumentNode(opts.appRoot);\n // make sure the app root is set\n dom.updateRoots(root, root, root);\n // if we are buffering, need to switch around the divs\n if (opts.buffer) {\n bufferManager.prep(preboot);\n }\n // if we could potentially freeze the UI, we need to prep (i.e. to add divs for overlay, etc.)\n // note: will need to alter this logic when we have more than one freeze strategy\n if (opts.freeze) {\n state.freeze = opts.freeze.name === 'spinner' ? freezeSpin : opts.freeze;\n state.freeze.prep(preboot, opts);\n }\n // start listening to events\n eventManager.startListening(preboot, opts);\n}", "title": "" }, { "docid": "bec5cadb5edc541a82fbdd4b60de8484", "score": "0.48752907", "text": "function init() {\n process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;\n process.env.SHARDS = `[${process.env.SHARD - 1}]` // Yes\n\n process.setMaxListeners(100);\n bot.bus = new EventEmitter();\n loadModules().then(() => {\n bot.logger.log(\"All modules loaded!\");\n bot.bus.emit(\"modulesLoaded\");\n })\n}", "title": "" }, { "docid": "f0f77f75c29db56136ae6be1d4e4b29e", "score": "0.48716977", "text": "async function run() { \n // 3 change last arg to true\n // 4 change last arge to false\n // coinbase pro requires key, we can bypass\n load('https://api.gdax.com/products/eth-usd/book',getHeaders(),false);\n\n // 9\n load('https://api.gdax.com/products/btc-usd/book',getHeaders(),false);\n}", "title": "" }, { "docid": "83b3a1d5cba6c9dc9cc14f5638348916", "score": "0.48664153", "text": "getApi() {\n if (this.exchange === 'GDAX') {\n return new Gdax.AuthenticatedClient(process.env.GDAX_KEY, process.env.GDAX_SECRET, process.env.GDAX_PASSPHRASE, 'https://api.gdax.com') // 'https://api-public.sandbox.gdax.com'\n }\n if (this.exchange === 'POLONIEX') {\n return new Poloniex(process.env.POLONIEX_KEY, process.env.POLONIEX_SECRET)\n }\n if (this.exchange === 'BITTREX') {\n bittrex.options({ 'apikey': process.env.BITTREX_KEY, 'apisecret': process.env.BITTREX_SECRET })\n return bittrex\n }\n if (this.exchange === 'COINBASE') {\n var Client = coinbase.Client\n return new Client({ 'apiKey': process.env.COINBASE_KEY, 'apiSecret': process.env.COINBASE_SECRET })\n }\n }", "title": "" }, { "docid": "38d3bc448dbea56c70a61a62a26077a7", "score": "0.48317274", "text": "function loadAccount() {\n\tconnect(\"/hiwi/Provider/js/loadAccount\", \"\", handleLoadAccountResponse);\n\n}", "title": "" }, { "docid": "68e4cabf8bb371cdb5d65c903adab0c8", "score": "0.48251203", "text": "async function loadBlockchainData() {\n loadWeb3();\n const web3 = window.web3;\n // Load cuurent account\n // const accounts = await web3.eth.getAccounts();\n // setAccount(accounts[0]);\n const networkId = await web3.eth.net.getId();\n // console.log(\"networkId\", networkId);\n //Infrachain.json : get networks after truffle migration\n const networkData = Infrachain.networks[networkId];\n if (networkData) {\n const contract = web3.eth.Contract(Infrachain.abi, networkData.address);\n //add Contract to State\n setContract(contract);\n } else {\n window.alert(\"Smart contract not deployed to detected network.\");\n }\n }", "title": "" }, { "docid": "550d57a222222e877730b8b987a88086", "score": "0.48174992", "text": "function handleClientLoad () {\n // gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "868c1441f0b6894fa220a924567bcd26", "score": "0.48146746", "text": "function handleClientLoad() {\ngapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "66f73e3db18005a611b8eb7a957f07cc", "score": "0.48141232", "text": "function loadKeys(keys) {\n const client = new api.BinanceRest({\n // key: \"R5s8SH34CzINGQLDRRkAq6NnffsnCvOh011DjDVPsjORUEb4ZG23W8zvDi2xdRPR\",\n key: keys[0],\n //secret: \"Yc4rdtDn1DfOpsucZ2G860yKADW8cvcl4hUTC46naA77qPUxmTzTRBtnywWBrXsT\",\n secret: keys[1],\n timeout: 15000, // request time out in milliseconds\n recvWindow: 10000, // Optional, defaults to 5000, increase if you're getting timestamp errors\n disableBeautification: false,\n handleDrift: true\n });\n\n return client;\n}", "title": "" }, { "docid": "adcc20c891c3e93040c3c8ba41c45ff5", "score": "0.4801678", "text": "function handleClientLoad() {\n connectElements();\n return new Promise((resolve, reject) => {\n gapi.load('client:auth2', () => initClient(resolve, reject));\n });\n}", "title": "" }, { "docid": "dd07c5e77d84560329a9352b96c0e793", "score": "0.47964224", "text": "function loadGAPI() {\n\t// load library and execute local client for api...\n\tgapi.load('client', initClient);\n}", "title": "" }, { "docid": "3e0e33a6279f7b8be8fb9ebed0d2d4c8", "score": "0.47910038", "text": "function handleClientLoad() {\n\t\tgapi.load('client:auth2', initClient);\n\t}", "title": "" }, { "docid": "f7ae8d742429916d43079f3e7fb3def6", "score": "0.47729713", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "dfca0ab8124de94629c2e6a4e9f0c64b", "score": "0.47704425", "text": "function load() {\n dashcode.setupParts();\n if (widget.preferenceForKey('hostkey') && widget.preferenceForKey('portkeyxbmc')) {load_preferences();};\n}", "title": "" }, { "docid": "c7dc655ad4be2292b4064b528312f5d9", "score": "0.47691053", "text": "function init() {\r\n\t\t// get nav button\r\n\t\tdocument.querySelector(\"nearby-btn\").addEventListener(\"click\",\r\n\t\t\t\tloadNearbyItems);\r\n\t\tdocument.querySelector(\"fav-btn\").addEventListener(\"click\",\r\n\t\t\t\tloadFavoriteItems);\r\n\t\tdocument.querySelector(\"recommend-btn\").addEventListener(\"click\",\r\n\t\t\t\tloadRecommendedItems);\r\n\r\n\t\t// initially activate nearby and load nearby items\r\n\t\tloadNearbyItems();\r\n\t}", "title": "" }, { "docid": "20e08a52673b51c83c67eae298d7b41b", "score": "0.4766668", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "20e08a52673b51c83c67eae298d7b41b", "score": "0.4766668", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "e4f4e294df26a94ddc81998c6a4df736", "score": "0.47651526", "text": "function handleClientLoad() {\r\n\tgapi.load('client:auth2', initClient);\r\n}", "title": "" }, { "docid": "ec2fbfb322f7dc4a4f8d3edd123489a3", "score": "0.47535342", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient); // eslint-disable-line no-undef\n}", "title": "" }, { "docid": "53f410f9baf0d40cf5bd8ce02a76e2c0", "score": "0.47519982", "text": "function handleClientLoad() {\r\n gapi.load('client:auth2', initClient);\r\n}", "title": "" }, { "docid": "53f410f9baf0d40cf5bd8ce02a76e2c0", "score": "0.47519982", "text": "function handleClientLoad() {\r\n gapi.load('client:auth2', initClient);\r\n}", "title": "" }, { "docid": "83d933d6715a22a2e863062a01a567f4", "score": "0.47507975", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "b88b3e3b59ba71adb8c7012d8ea927e6", "score": "0.4746539", "text": "function __prepare() {\n\n // undefine config and settings if running in lite mode and dont deal with require()\n if (__lite) {\n exports.config = undefined;\n }\n else {\n\n // mutant hybrid require() for maximum compatibility, always defined now because some bootstraps have bad implementations\n __print('defining require...');\n //if (typeof (require) == \"undefined\") {\n var r = DiscordNative.nativeModules.requireModule(\"discord_/../electron\").remote.require;\n window.require = m => {\n try {\n return DiscordNative.nativeModules.requireModule(\"discord_/../\" + m);\n }\n catch (e) {\n return r(m);\n }\n };\n //}\n\n // here we import and define some stuff that usually gets defined by the bootstrap, just in case\n __print('requiring necessary modules...');\n window.electron = require('electron').remote;\n window.app = electron.app;\n window.fs = require(\"original-fs\");\n\n // kinclude executes a file directly in the context of the page\n window.kinclude = function (p) {\n return eval(fs.readFileSync(p, 'utf8').toString());\n }\n\n // krequire is a reimplementation of require(), only intended for loading plugins\n window.krequire = function (p) {\n var exports = {};\n eval(fs.readFileSync($api.data + '/plugins/' + p + (p.endsWith('.js') ? '' : '.js'), 'utf8').toString());\n return exports;\n }\n\n }\n\n window.kparse = function (p) {\n var exports = {};\n eval(p);\n return exports;\n }\n\n // this part sets up webcrack, which is a very important part of EPAPI -- credit to bootsy\n __print('initializing webcrack...');\n webpackJsonp([1e3], { webcrack_ver01_xyzzy: function (n, b, d) { mArr = d.m, mCac = d.c, mCar = [], Object.keys(mCac).forEach(function (n) { mCar[n] = mCac[n] }), findFunc = function (n) { results = []; if (\"string\" == typeof n) mArr.forEach(function (r, t) { -1 !== r.toString().indexOf(n) && results.push(mCac[t]) }); else { if (\"function\" != typeof n) throw new TypeError(\"findFunc can only find via string and function, \" + typeof n + \" was passed\"); mArr.forEach(function (r, e) { n(r) && results.push(mCac[e]) }) } return results }, findCache = function (n) { if (results = [], \"function\" == typeof n) mCar.forEach(function (r, t) { n(r) && results.push(r) }); else { if (\"string\" != typeof n) throw new TypeError(\"findCache can only find via function or string, \" + typeof n + \" was passed\"); mCar.forEach(function (r, t) { if (\"object\" == typeof r.exports) for (p in r.exports) if (p == n && results.push(r), \"default\" == p && \"object\" == typeof r.exports[\"default\"]) for (p in r.exports[\"default\"]) p == n && results.push(r) }) } return results }, window.wc = { get: d, modArr: mArr, modCache: mCac, modCArr: mCar, findFunc: findFunc, findCache: findCache } } }); webpackJsonp([1e3], \"\", [\"webcrack_ver01_xyzzy\"]);\n\n __print('defining helper functions...');\n\n // shorthand methods that are used internally and in many plugins, maintained for compatibility and convenience\n window.$listen = (e, c) => {\n var listener = {\n name: e,\n callback: function () {\n try {\n c.apply(null, arguments);\n }\n catch (e) {\n __error(e, 'An event listener threw an exception');\n }\n\n },\n unregister: function () {\n document.removeEventListener(this.name, this.callback);\n }\n }\n document.addEventListener(listener.name, listener.callback);\n return listener;\n };\n window.$dispatch = e => document.dispatchEvent(e);\n window.$ = s => document.querySelector(s);\n window.$$ = s => document.querySelectorAll(s);\n window.$purge = e => e.innerHTML = '';\n window.$_ = function (e, c, t, i) {\n var elm = document.createElement(e);\n if (typeof (c) != 'undefined') {\n elm.className = c;\n if (typeof (t) != 'undefined') {\n elm.innerText = t;\n if (typeof (i) != 'undefined') {\n elm.id = i;\n }\n }\n }\n return elm;\n };\n window.$chan = exports.ui.getCurrentChannel;\n window.$guild = exports.ui.getCurrentGuild;\n window.$me = exports.internal.getId;\n\n // expose EPAPI as $api, which is what most plugins expect it to be known as\n window.$api = exports;\n\n // extension methods used in some older plugins, maintained for compatibility\n String.prototype.replaceAll = function (search, replacement) { return this.split(search).join(replacement) };\n Array.prototype.contains = function (s) { return this.indexOf(s) != -1 };\n\n // derive the date of creation from a discord snowflake id\n Date.fromSnowflake = (id) => new Date((id / 4194304) + 1420070400000);\n\n}", "title": "" }, { "docid": "abd845fd6898b02eeccd4bd2ce11c637", "score": "0.47407672", "text": "function handleClientLoad(){\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "10f73a45e4e2418f3f9e55ee4fd93b77", "score": "0.47397476", "text": "function handleClientLoad() {\r\n gapi.load(\"client:auth2\", initClient);\r\n }", "title": "" }, { "docid": "eefb53b3903cdaf81047dd4fa1ebb50e", "score": "0.4739515", "text": "function handleClientLoad() {\n\tgapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "da3cdc63aed47ae6505df9e1ec4a3e7d", "score": "0.47333455", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "f7e5f2a7827815f23002b36a2a6fea03", "score": "0.47295943", "text": "async function initializeWeb3(){\n if(window.ethereum){\n window.web3 = new Web3(window.ethereum)\n await window.ethereum.enable()\n }\n else if (window.web3){\n window.web3 = new Web3(window.web3.currentProvider)\n }\n else{\n window.alert('No Ethereum Provider detected!')\n }\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "b49cd9f93780be03b9a56b24f3e9bc5d", "score": "0.47292197", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n}", "title": "" }, { "docid": "3805cf2f7451d28c5f8f609bbc3470aa", "score": "0.4724979", "text": "initializeBlockchain() {\n\t\tthis.database.getBlockAll().then(resp => {\n\t\t\tthis.blockchain.loadBlockchain(resp);\n\t\t});\n\t}", "title": "" }, { "docid": "da2edb0eda89ab68104c14acf4a76ad1", "score": "0.4718745", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "da2edb0eda89ab68104c14acf4a76ad1", "score": "0.4718745", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "d9d132105138c7c73be6b470b6dd5036", "score": "0.4717814", "text": "function handleClientLoad() {\n gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "e5acdcbb779d00e19fd6629233b39875", "score": "0.47069156", "text": "function handleClientLoad() {\n window.gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "c2f8550314df3395ddd639c8d27880e5", "score": "0.47020617", "text": "function handleClientLoad() {\r\n gapi.load('client:auth2', initClient);\r\n }", "title": "" }, { "docid": "88799fd05a2a8069065fdb54e3206ea5", "score": "0.4701799", "text": "function handleClientLoad() {\r\n gapi.load('client:auth2', initClient);\r\n }", "title": "" }, { "docid": "c958c1ec54e0bd4c2d323e384159124a", "score": "0.46966693", "text": "function configureLoader() {\n var state = getState(function (_ref3) {\n var config = _ref3.config,\n resolve = _ref3.resolve,\n reject = _ref3.reject;\n return {\n config: config,\n resolve: resolve,\n reject: reject\n };\n });\n var require = window.require;\n\n require.config(state.config);\n\n require(['vs/editor/editor.main'], function (monaco) {\n storeMonacoInstance(monaco);\n state.resolve(monaco);\n }, function (error) {\n state.reject(error);\n });\n}", "title": "" }, { "docid": "6f7a43655a7755713229e171d4bfa731", "score": "0.46918815", "text": "async UNSAFE_componentWillMount(){\n await this.loadWeb3Data() // This function will connect to the blockchain provider\n await this.loadLocalBlockchainData() // This will aloud as to check accounts, balances, transactions...all kind blockchain methods.\n }", "title": "" }, { "docid": "b01a3cd2e0b773edee4c15b2e2cf84ee", "score": "0.46891454", "text": "function init() {\n loadDownloads();\n loadTheme();\n loadBorderRadius();\n}", "title": "" }, { "docid": "fd6568b4c4d80493cd051b0cf0819199", "score": "0.4684252", "text": "function handleClientLoad() {\n window.gapi.load('client:auth2', initClient);\n }", "title": "" }, { "docid": "a0a09b761fd5b3b234491ea35b909c6a", "score": "0.4676107", "text": "function _loadBowerProject() {\n // notify bower project is being loaded\n exports.trigger(PROJECT_LOADING);\n\n // load bowerrc if any\n ConfigurationManager.loadBowerRc(_bowerProject);\n\n // load bower.json if any\n BowerJsonManager.loadBowerJson(_bowerProject).always(function () {\n\n // start loading project dependencies\n PackageManager.loadProjectDependencies().always(function () {\n\n FileSystemHandler.startListenToFileSystem(_bowerProject);\n\n // notify bower project is ready\n exports.trigger(PROJECT_READY);\n });\n });\n }", "title": "" }, { "docid": "26767c34f6c150805ac01ca3d59cc5e7", "score": "0.46719202", "text": "async _initialization() {\n \n // first initialization of web3js\n // we need to detect if browser is 'injected' with web3js, so we can reed adress of user\n if (window.ethereum) {\n\n this._web3 = new Web3(window.ethereum);\n try {\n await window.ethereum.enable();\n } catch (e) {\n return { success: false, errorMessage: e.message };\n // return Promise().reject(e.message);\n // User denied account access...\n // TODO: you must test that and throw some errors that app needs this premissions\n }\n }\n // Legacy dapp browsers, they can always read everything they need\n else if (window.web3) {\n this._web3 = new Web3(web3.currentProvider);\n }\n // Non-dapp browsers (they do not have any wallet injected in them)...\n else {\n // We are either on the server or the user isn't running metamask\n // this must throw error in production\n // currently you can fall back to localhost but then you will use first account as default\n const provider = new Web3.providers.HttpProvider(\"http://localhost:8545\");\n this._web3 = new Web3(provider);\n //TODO: MUST THROW ERROR;\n return { success: false, errorMessage: \"You must have Metamask in your browser to access Ethereum blockchain\"}\n }\n\n\n // saving user address\n this._userAddress = this._web3.givenProvider.selectedAddress;\n\n this._userBalance = await this._getCurrentUserBalance();\n\n //initialization of conncection to smart contract\n try {\n // also need to automate somehow path finding\n this._testContractAbi = require(\"../../build/contracts/CryptoRoulette.json\");\n } catch (e) {\n return { success: false, errorMessage: \"There is no smart contract ABI provided\" }\n //TODO: return and handle error needed\n }\n\n if(appSettings._contractAddress === null) {\n return { success: false, errorMessage: \"No Address for smart contract provided\" };\n }\n\n // need better handle and read on what address smart contract is located\n this._contract = this._web3.eth.Contract(this._testContractAbi.abi, appSettings._contractAddress);\n\n // now we have in this._contractInstance instance of our smart contract and now we can call functions on it\n // TEMPLATE FOR CALLING FUNCTIONS, wrapper must be async func: \n // const res = await this._contract.methods.MethodName(params).call() for functions that read smart contract state\n // for altering smart contract state you must send a transaction \n // also check the docs https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods for more\n // OTHER USEFUL STUFF: web3.utils.hexToNumberString\n // also TODO: check if actually connected and check if account changed?\n // idea for connection, write some random function on smart contract which you will ping for connection right here\n return { success: true };\n }", "title": "" }, { "docid": "5567df690dfa3d27ffe13dac4d5be4a3", "score": "0.46714193", "text": "init() {\n this.detectWallet();\n }", "title": "" }, { "docid": "330cc5efa5ba5aef33229df3376f0e8c", "score": "0.46669874", "text": "function loadTokenContract(abi) {\n\t\t\t\t\tconst contract = myWeb3.eth.contract(abi);\n\t\t\t\t\tconst address = token.address || token;\n\t\t\t\t\tconst instance = contract.at(address);\n\t\t\t\t\tif(!instance.TOKEN_VERSION) {\n\t\t\t\t\t\tconst err = \"Wrong ERC721 ABI format: TOKEN_VERSION is undefined\";\n\t\t\t\t\t\tlogError(err);\n\t\t\t\t\t\ttryCallbackIfProvided(callback, ERR_WRONG_ABI, err);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tinstance.TOKEN_VERSION(function(err, version) {\n\t\t\t\t\t\tif(err) {\n\t\t\t\t\t\t\tlogError(\"Error accessing ERC721 instance: \", err, \"\\nCannot access TOKEN_VERSION.\");\n\t\t\t\t\t\t\ttryCallbackIfProvided(callback, ERR_WEB3_ERROR, err);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(TOKEN_VERSION != version) {\n\t\t\t\t\t\t\tconst err = \"Error accessing ERC721 instance: not a valid instance.\\n\" +\n\t\t\t\t\t\t\t\t\"Check if the address specified points to an ERC721 instance with a valid TOKEN_VERSION.\\n\" +\n\t\t\t\t\t\t\t\t\"Version required: \" + TOKEN_VERSION + \". Version found: \" + version;\n\t\t\t\t\t\t\tlogError(err);\n\t\t\t\t\t\t\ttryCallbackIfProvided(callback, ERR_CONTRACT_VERSION_MISMATCH, err);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\tlogInfo(\"Successfully connected to ERC721 instance at \", address);\n\t\t\t\t\t\ttokenInstance = instance;\n\t\t\t\t\t\tinstanceLoaded(callback);\n\t\t\t\t\t\ttokenInstance.balanceOf(myAccount, function(err, result) {\n\t\t\t\t\t\t\tif(err) {\n\t\t\t\t\t\t\t\tlogError(\"Unable to get ERC721 token balance for account \", myAccount, \": \", err);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(result > 0) {\n\t\t\t\t\t\t\t\tlogInfo(\"You own \", result, \" ERC721 tokens\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tlogInfo(\"You don't own any ERC721 tokens\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}", "title": "" }, { "docid": "b2a9a1de53b16ff9288757874b3d358f", "score": "0.46607864", "text": "handleClientLoad() {\n gapi.load(\"client:auth2\", this.initClient);\n }", "title": "" }, { "docid": "0a43895d8363dca6b66704f62c25391b", "score": "0.46598262", "text": "async loadBlockchainData() {\n\n //Obteniendo un proveedor desde Metamask\n const web3 = new Web3(Web3.givenProvider || \"http://localhost:8545\");\n\n //Solicitando autorizar el proveedor de Metamask\n window.ethereum.enable();\n\n //Obteniendo todas las cuentas asociadas a la billetera\n const accounts = await web3.eth.getAccounts();\n\n //Guarda toda la cuenta desde la cual se hara peticiones, en el state de React\n this.setState({ account: accounts[0] });\n\n //Crea uns conexion al contrato usando la direccion de este en la blockchain y su interfas ABI\n const electoralContract = new web3.eth.Contract(TODO_LIST_ABI_ELECTORAL, TODO_LIST_ADDRESS_ELECTORAL);\n\n //Se guarda la instancia del contrato obtenida y una instancia de la libreria web3js para futuras peticiones\n this.setState({ electoralContract, web3 });\n }", "title": "" }, { "docid": "97b5249cf40a36ecc3c8c5e880a02ec4", "score": "0.4658056", "text": "function load_extension() {\n config.load(); // trigger loading config parameters\n\n $.getJSON(\"/nbextensions/source_UI/code_snippets.json\", function (data) {\n // Add the header as the top option, does nothing on click\n var option = $(\"<option></option>\")\n .attr(\"id\", \"snippet_header\")\n .text(\"Snippets\");\n $(\"select#snippet_picker\").append(option);\n\n // Add options for each code snippet in the snippets.json file\n $.each(data['code_snippets'], function (key, snippet) {\n var option = $(\"<option></option>\")\n .attr(\"value\", snippet['name'])\n .text(snippet['name'])\n .attr(\"code\", snippet['code'].join('\\n'));\n $(\"select#snippet_picker\").append(option);\n });\n })\n .error(function (jqXHR, textStatus, errorThrown) {\n // Add an error message if the JSON fails to load\n var option = $(\"<option></option>\")\n .attr(\"value\", 'ERROR')\n .text('Error: failed to load snippets!')\n .attr(\"code\", \"\");\n $(\"select#snippet_picker\").append(option);\n });\n\n }", "title": "" }, { "docid": "c4880ca66cfb6680a90d3c53f6c04225", "score": "0.46531782", "text": "async function loadModules() {\n bot.modules = {};\n bot.logger.log(\"Loading modules...\");\n const moduleFiles = config.get(\"Modules\");\n const modulePath = config.get(\"General.ModulePath\");\n\n //Attempt to load each module file\n for (let i = 0; i < moduleFiles.length; i++) {\n const fileName = moduleFiles[i];\n //The module loading is wrapped in a try/catch incase the module fails to load, the server will still run.\n try {\n let loadedModule = require(`.${modulePath}/${fileName}.js`);\n if (loadedModule instanceof Function) {\n bot.logger.log(\"Detected class-style module \" + loadedModule.name);\n loadedModule = new loadedModule(bot);\n } else if (!loadedModule.name || !loadedModule.init) {\n console.log(loadedModule);\n //If the app has not got these. It's not setup properly.\n //Throw out a warning and skip attempting to load it.\n bot.logger.warn(`${fileName} is not a valid module. Missing 'name' and/or 'init'`);\n continue;\n }\n //Here the module itself starts execution. In the future we might want to do this asynchronously.\n //The app object is passed to the\n Sentry.configureScope(function initModule(scope) {\n scope.addBreadcrumb({\n category: 'modules',\n message: 'Loading module.',\n level: \"info\",\n data: {\n name: loadedModule.name,\n path: modulePath,\n file: fileName,\n moduleFiles: moduleFiles\n }\n });\n });\n if (loadedModule.async)\n await loadedModule.init(bot);\n else\n loadedModule.init(bot);\n bot.modules[fileName] = loadedModule;\n bot.logger.log(`Loaded module ${loadedModule.name}`);\n } catch (e) {\n //Spit the error out and continue loading modules.\n //Modules that depend on the failed module's functions will probably also fail too.\n bot.logger.error(`Error loading ${fileName}:`);\n console.error(e);\n if (bot.client && bot.client.shard) {\n bot.rabbit.event({\n type: \"warning\", payload: {\n id: \"badModule-\" + fileName,\n message: `Couldn't load module ${module}:\\n${e.message}`\n }\n });\n }\n }\n }\n}", "title": "" }, { "docid": "a29883cb5a3f155074727b6065948dbe", "score": "0.46503773", "text": "async loadBlockchainData() {\n\n //Obteniendo un proveedor desde Metamask\n const web3 = new Web3(Web3.givenProvider || \"http://localhost:8545\");\n\n //Solicitando autorizar el proveedor de Metamask\n window.ethereum.enable();\n\n //Obteniendo todas las cuentas asociadas a la billetera\n const accounts = await web3.eth.getAccounts();\n\n //Guarda toda la cuenta desde la cual se hara peticiones, en el state de React\n this.setState({ account: accounts[0] });\n\n //Crea uns conexion al contrato VotingTableContract usando la direccion de este en la blockchain y su interfas ABI\n const tableContract = new web3.eth.Contract(TODO_LIST_ABI_TABLE, TODO_LIST_ADDRESS_TABLE);\n\n //Crea uns conexion al contrato TokenVoteContract usando la direccion de este en la blockchain y su interfas ABI\n const tokenVoteContract = new web3.eth.Contract(TODO_LIST_ABI_TOKEN, TODO_LIST_ADDRESS_TOKEN);\n\n //Se almacena la instancia de los dos contratos en el state de React y ademas una instancia de la libreria Web3js para emplearla posteriormente\n this.setState({ tableContract, tokenVoteContract, web3 });\n\n //Consulta el numero de tokens que tiene asociados la mesa y para ser presentados a los jurados\n let result = await this.state.tokenVoteContract.methods.balanceOf(TODO_LIST_ADDRESS_TABLE).call({ from: this.state.account });\n\n //Almacena en el state el numero de tokens que le fueron transferidos a esta mesa en particular\n this.setState({ numTokens: result.balance });\n\n }", "title": "" }, { "docid": "1db7737dc06bed907884e9bbb009d1b6", "score": "0.46373224", "text": "function loadScript() { \n // Use global document since Angular's $document is weak\n var script = document.createElement('script');\n script.src = 'https://js.stripe.com/v2/';\n script.onload = () => {\n deferred.resolve();\n }\n\n document.body.appendChild(script);\n }", "title": "" } ]
1b5eabf1d1a18a8a4897a34565d64489
Get block by hash
[ { "docid": "d70de41dd25054a0a12ee95fd934b63e", "score": "0.5925933", "text": "getBlockByWalletAddress(address) {\n\t\tlet self = this;\n\t\tlet block = [];\n\t\tlet i = 0;\n\t\treturn new Promise(function(resolve, reject){\n\t\t\tself.db.createReadStream()\n\t\t\t.on('data', function (data) {\n\t\t\t\tlet jblock = Object.assign(new BlockClass.Block, JSON.parse(data.value));\t\t\n\t\t\t\tif (jblock.height != 0){\t\n\t\t\t\t\tif(jblock.body.address === address){\n\t\t\t\t\t\tblock[i] = jblock;\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\t\n\t\t\t})\n\t\t\t.on('error', function (err) {\n\t\t\t\treject(err)\n\t\t\t})\n\t\t\t.on('close', function () {\n\t\t\t\tresolve(block);\n\t\t\t});\n\t\t});\n\t}", "title": "" } ]
[ { "docid": "a783d34ffc0b5a9bb5f2c009ecb3c8b7", "score": "0.83494586", "text": "function getBlockByHash(hash) {\n let block = null;\n return new Promise(function(resolve, reject){\n db.createReadStream()\n .on('data', function (data) {\n if(JSON.parse(data.value).hash === hash){\n block = JSON.parse(data.value);\n }\n })\n .on('error', function (err) {\n reject(err)\n })\n .on('close', function () {\n resolve(block);\n });\n });\n}", "title": "" }, { "docid": "c3926eeea500ea23e7264dd575e70691", "score": "0.8349373", "text": "async getBlockByHash(hash) {\n let self = this;\n let block = null;\n return new Promise((resolve, reject) => {\n self.db.createReadStream()\n .on('data', function (data) {\n let currentBlock = JSON.parse(data.value);\n if(currentBlock.hash === hash) {\n block = data.value;\n }\n })\n .on('error', function (err) {\n reject(err)\n })\n .on('close', function () {\n if(block === null) {\n reject(new Error(`Block with hash '${hash}' not found`));\n }\n else {\n resolve(block);\n } \n });\n });\n }", "title": "" }, { "docid": "69f54334581d3561f4c9f0b8d4c539b8", "score": "0.82325596", "text": "async getBlockByHash(request, h) {\n var block = await mBlockModel.BlockModel.findOne({ hash: request.params.hash }).exec();\n return h.response(block);\n }", "title": "" }, { "docid": "c001c7b2db1ea6337af9b770ab6f6e18", "score": "0.81377953", "text": "getBlockByHash(hash) {\n\t\tlet self = this;\n\t\tlet block = null;\n\t\treturn new Promise(function(resolve, reject){\n\t\t\tself.db.createReadStream()\n\t\t\t.on('data', function (data) {\n\t\t\t\tlet jblock = Object.assign(new BlockClass.Block, JSON.parse(data.value));\n\t\t\t\tif(jblock.hash === hash){\n\t\t\t\t\tblock = jblock;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.on('error', function (err) {\n\t\t\t\treject(err)\n\t\t\t})\n\t\t\t.on('close', function () {\n\t\t\t\tresolve(block);\n\t\t\t});\n\t\t});\n\t}", "title": "" }, { "docid": "a7fafe79321fecc27b4482bbea73bc82", "score": "0.8099548", "text": "getBlockByHash(hash) {\n return this.bd.getBlockByHash(hash); \n }", "title": "" }, { "docid": "cabfde2d6fc3a330cb14ae2670bf4d11", "score": "0.80202883", "text": "getByHash(hash) {\n return new Promise((resolve,reject)=>{\n db.getBlockByHash(hash).then(block =>{\n resolve(block);\n }).catch((err)=>{\n reject(err);\n });\n });\n }", "title": "" }, { "docid": "1dac92f9361f65b3897047474e61f5c8", "score": "0.7940717", "text": "getBlockByHash(hash) {\n let recursion = function (key, context) {\n return context.getBlockByHeight(key)\n .then((block) => {\n return block.hash === hash ? block : recursion(key + 1, context);\n })\n .catch(() => undefined);\n };\n\n return recursion(0, this);\n }", "title": "" }, { "docid": "d4e2328207157b12729a065b4f6af380", "score": "0.7866158", "text": "async getBlockByHash(hash) {\n const parsedBlock = await this.db.getLevelDBDataByHash(hash);\n return parsedBlock;\n }", "title": "" }, { "docid": "694d9cd7a751061096ce505548f07d63", "score": "0.7864881", "text": "getBlockByHash(hash) {\r\n let self = this;\r\n let block = null;\r\n console.log('hash', hash);\r\n return new Promise((resolve, reject) => {\r\n self.db.createReadStream()\r\n .on('data', (data) => {\r\n if(JSON.parse(data.value).hash === hash) {\r\n block = JSON.parse(data.value);\r\n // block.body.star.storyDecoded = hex2ascii(block.body.star.story)\r\n }\r\n })\r\n .on('error', (err) => {\r\n reject(err);\r\n })\r\n .on('close', () => {\r\n resolve(block);\r\n })\r\n })\r\n }", "title": "" }, { "docid": "bb498dd5fb2ddaa66e722687441d72c3", "score": "0.7851382", "text": "getBlockByHash(hash) {\n return new Promise((resolve, reject) => {\n let block = null;\n db.createReadStream()\n .on('data', (data) => {\n if (JSON.parse(data.value).hash === hash) {\n block = JSON.parse(data.value);\n // decoding star's story\n block.body.star.storyDecoded = hex2ascii(block.body.star.story);\n }\n })\n .on('error', function (err) {\n reject(err)\n })\n .on('close', function () {\n resolve(block);\n });\n });\n }", "title": "" }, { "docid": "9c766b11daed64c7b1afb477bee6038c", "score": "0.78205603", "text": "async getBlockByHash(hash) { \n \n return persistence.getLevelDBDataValueByAttribute(\"hash\", hash); \n }", "title": "" }, { "docid": "fe9b79344221f2353c1c442ab0868c35", "score": "0.77000964", "text": "getBlockByHash() {\n this.app.get(\"/stars/hash::hash\", (req, res) => {\n this.blocks.getBlockByHash(req.params.hash)\n .then(block => res.json(this._addDecodedStory(block)))\n });\n }", "title": "" }, { "docid": "090ac0cc720006a7032c9dae3a64ccf7", "score": "0.7402677", "text": "async getBlockByHash(hash){\n \n return await new Promise(function(resolve, reject) {\n levelSandbox.getData().then( function(chain) {\n if(chain.length>0){\n for (var i = 0; i < (chain.length); i++) {\n if (chain[i].hash === hash){\n console.log('done!!');\n resolve(chain[i]);\n }\n }\n reject({'error': 'hash not found!'});\n } else{\n reject({'error': 'chain empty'});\n }\n \n }).catch(function (message) {\n console.log(message);\n reject({'error': message});\n });\n });\n}", "title": "" }, { "docid": "2801eecd50f00322dd798f1f2dbb41f7", "score": "0.7305325", "text": "getBlockByHash() {\n this.server.route({\n method: 'GET',\n path: '/stars/hash:{hash}',\n handler: async (request, h) => {\n const block = await blockchain.getBlockByHash(encodeURIComponent(request.params.hash))\n .then((value)=>{\n value.body.star.storyDecoded = this.decodeStarStory(value.body.star.story);\n return value;\n }).catch((err)=>{\n return BoomErrorHandle.notFound('Was not possibly find any star block by hash');\n });\n return block;\n }\n });\n }", "title": "" }, { "docid": "5656678df7f8312d82e76263a9809213", "score": "0.7303893", "text": "function handle_queryBlockByHash(params, res, req) {\n\tlogger.debug('================ GET BLOCK BY HASH ======================');\n var body = {\n code : retCode.OK,\n msg : \"OK\",\n };\n\n\tlet hash = params.hash;\n\tlet peer = params.peer;\n if (!peer) {\n peer = 'peer1'\n }\n\n\tif (!hash) {\n\t\tres.json(paraInvalidMessage('\\'hash\\''));\n\t\treturn;\n\t}\n\n var username = params.usr;\n\tif (!username) {\n\t\tusername = 'admin'\n\t}\n\n var orgname = params.org;\n\tif (!orgname) {\n orgname = 'org1'\n\t}\n\n\n\treturn hfc_wrap.getBlockByHash(peer, hash, username, orgname)\n\t.then((response)=>{\n logger.debug('getBlockByHash success, response=', response)\n body.msg = 'ok'\n body.result = response\n res.send(body);\n })\n .catch((err)=>{\n logger.error('getBlockByHash failed, err=%s', err)\n body.msg = '' + err\n res.send(body);\n });\n}", "title": "" }, { "docid": "2481f766a488115c4e18abffe52c0dbe", "score": "0.729034", "text": "getBlockByHash(hash) {\n // let self = this;\n let block = null;\n return new Promise(function(resolve, reject){\n db.createReadStream()\n .on('data', function (data) {\n data = JSON.parse(data.value);\n if(data.hash === hash){\n data.body.star.storyDecoded = hex2ascii(data.body.star.story);\n block = data;\n }\n })\n .on('error', function (err) {\n reject(err)\n })\n .on('close', function () {\n resolve(block);\n });\n });\n}", "title": "" }, { "docid": "c4448bbe532f665f58a9e1c716c0056e", "score": "0.7159616", "text": "getBlockByHash(blockHash) {\n let self = this\n async function getBlockAsysnc() {\n let block = null;\n try {\n block = await self.chain.getBlockByHash(blockHash);\n return block;\n } catch (err) {\n throw 'getBlockByHash Error: err=' + err;\n }\n }\n // Return a Promise from which the Block could be thenned.\n return getBlockAsysnc();\n }", "title": "" }, { "docid": "9fc6f7fb852c4a1904bd8458296d9230", "score": "0.707275", "text": "getBlockByHash(blockHash){\n let self = this;\n console.log(`BlockChain.js - getBlockByHash: hash ${blockHash}`);\n return new Promise(function(resolve, reject) {\n self.bd.getLevelDBDatabyHash(blockHash).then(function(result) {\n // return object as a single string\n resolve(result);\n }, function(error) {\n reject(error);\n }\n );\n });\n }", "title": "" }, { "docid": "955a6d90fa294f1aba14857ef09effd2", "score": "0.6981841", "text": "async getBlockOrActionByHash(hashStr: string): Promise<TGetBlkOrActResponse> {\n return await this.send(this.getBlockOrActionByHash.name, hashStr);\n }", "title": "" }, { "docid": "ed2d2816ec36eec22ba91e6d733f0161", "score": "0.6967032", "text": "BlockContent(bhash) {\n // Access each block via hash, using an API call.\n let url = this.api + this.endpoint + \"/block/\" + bhash + \"/txids\";\n return new Promise((resolve, reject) => {\n request(url, (err, res, body) => {\n // If there is an error, reject and show.\n if (err) reject(err)\n // If there is no error, access the information.\n let info = JSON.parse(body); \n resolve(info)\n })\n })\n }", "title": "" }, { "docid": "e917848b2b9bfcb5bcc15b4cc4fa8350", "score": "0.68405354", "text": "async getBlock(height) {\n try {\n let requestedBlock = await this.blockDb.getDbBlockByHeight(height);\n // console.log(\"Requested block at height \" + height + \" is - \" + JSON.stringify(requestedBlock));\n return requestedBlock;\n } catch (err) {\n // console.log(\"Error getting block at height \" + height + \" - \" + JSON.stringify(err));\n throw err;\n }\n\n }", "title": "" }, { "docid": "a23f3a3aec3447fa80142a80610bba98", "score": "0.68332416", "text": "async getBlock(blockHeight){\n let block = await this.db.getSingleData(blockHeight);\n return block;\t\n }", "title": "" }, { "docid": "0abc77be30a99fbc011efe13ad3aabc5", "score": "0.679618", "text": "getBlockByHash() {\n this.app.get(\"/stars/hash::hash\", (req, res) => {\n let hash = req.params[\"hash\"];\n this.blockChain.getBlockByHash(hash).then((block) => {\n if(block) {\n block.body.star.storyDecoded = this._decode(block.body.star.story);\n res.json(block);\n } else {\n res.status(400).json({ error: 'Star not found.' });\n }\n }).catch((err) => {console.log(err);});\n });\n }", "title": "" }, { "docid": "9ffe14d976f1339c977c23a8ec33845c", "score": "0.67924327", "text": "function getBlockByHeight(height) {\n return new Promise(function(resolve, reject) {\n db.get(height, (err, value) => {\n if(err){\n if (err.type == 'NotFoundError') {\n resolve(undefined);\n }else {\n console.log('Block ' + height + ' get failed', err);\n reject(err);\n }\n }else {\n resolve(JSON.parse(value));\n }\n });\n });\n}", "title": "" }, { "docid": "64b5e1a4f19172b39e36bf01ee6475ed", "score": "0.6785889", "text": "getBlockByHash(hash, includeTransactions = false) {\n return this.send('eth_getBlockByHash', hash, includeTransactions)\n }", "title": "" }, { "docid": "9e2ae3b04334d9bafb45979c18c5743b", "score": "0.6762895", "text": "getBlockByHeight(height) {\n return Blockchain.getInstance()\n .then((instance) => instance.getBlock(height))\n .then((block) => {\n if (block.body.star && block.body.star.story) {\n block.body.star.storyDecoded = new Buffer(block.body.star.story, 'hex').toString();\n }\n \n return block;\n });\n }", "title": "" }, { "docid": "cb1dce695d728c2c4491aff232c51215", "score": "0.6650035", "text": "function getBlock(height) {\n return new Promise((resolve, reject) => {\n if (blockDict[height] != null) {\n resolve(blockDict[height]);\n } else {\n rpcClient.getBlockJson(height)\n .then((res) => {\n if (res.desc === 'UNKNOWN BLOCK') {\n log('Retrying...');\n setTimeout(() => {\n getBlock(height)\n .then((b) => {\n resolve(b);\n })\n .catch((e) => {\n reject(e);\n });\n }, 500);\n } else {\n const header = res.result.Header;\n const timestamp = header.Timestamp;\n const transactionCount = res.result.Transactions.length;\n const block = {\n timestamp,\n transactionCount,\n };\n\n blockDict[height] = block;\n if (blockDict[height - previous - 5] != null) {\n delete blockDict[height - previous - 5];\n }\n\n resolve(block);\n }\n })\n .catch((error) => {\n log('Failed to get block');\n reject(error);\n });\n }\n });\n}", "title": "" }, { "docid": "98b4c9e69c365b16547fcecb4deee1a5", "score": "0.66474515", "text": "getByHeight(height) {\n return new Promise((resolve,reject)=>{\n db.getBlockByHeight(height).then(block =>{\n resolve(block);\n }).catch(err=>{\n reject(err);\n });\n });\n }", "title": "" }, { "docid": "c0288c7b2bdd7c68e623023a454cfd1b", "score": "0.6631265", "text": "function getBlock(height) {\n return getKey(BLOCK_PREFIX + height);\n}", "title": "" }, { "docid": "df1c2ed293c54de362c3602594570511", "score": "0.65625656", "text": "getBlockByHash() {\n this.app.get(\"/blocks/hash::value\", (req, res) => {\n if(req.params.value) {\n const hash = req.params.value;\n this.blockchain.getBlockByHash(hash)\n .then((result) =>{\n if(result){\n return res.status(200).json(result);\n } else {\n return res.status(404).send(\"Block Not Found!\");\n }\n })\n .catch((err) => {\n res.status(404).send(err);\n });\n }\n });\n}", "title": "" }, { "docid": "d5a111b5c681e160528c0da2fcaccf47", "score": "0.6549092", "text": "LastBlockHash() {\n let url = this.api + this.endpoint + \"/blocks/tip/hash\";\n return new Promise((resolve, reject) => {\n request(url, (err, res, body) => {\n if (err) reject(err)\n resolve(body);\n })\n })\n }", "title": "" }, { "docid": "af39e92bc2589c8fa4bcee75ad2b9318", "score": "0.6478577", "text": "getBestBlockHash() {\n return __awaiter(this, void 0, void 0, function* () {\n return this.query('getbestblockhash', null);\n });\n }", "title": "" }, { "docid": "b5b11b7f16cc9f27f2faf906ebe0cddd", "score": "0.6400186", "text": "async getBlock(blockHeight) {\n return JSON.parse(await this.getLevelDBBlock(blockHeight))\n }", "title": "" }, { "docid": "b9b17a6a51b956fd9c77973219f5da48", "score": "0.63980794", "text": "get(hash) {\n const file = this.getFilePath(hash);\n\n return readFile(file);\n }", "title": "" }, { "docid": "4dac1d2a8a71c90036a022e07f0cccfd", "score": "0.63684404", "text": "getBlockByHeight() {\n this.server.route({\n method: 'GET',\n path: '/block/{height}',\n handler: async (request, h) => {\n const block = await blockchain.getBlockByHeight(encodeURIComponent(request.params.height))\n .then((value)=>{\n value.body.star.storyDecoded = this.decodeStarStory(value.body.star.story);\n return value;\n }).catch((err)=>{\n return BoomErrorHandle.notFound('Was not possibly find any star block by height');\n });\n return block;\n }\n });\n }", "title": "" }, { "docid": "869805ea8a6a70f5b30861bb2936799e", "score": "0.63455296", "text": "get(addr) { return this._blocks.get(addr); }", "title": "" }, { "docid": "42918a4ff38cbf6e6e3e57ba4cf7cd49", "score": "0.6342333", "text": "getStarByHash() {\n this.server.route({\n method: 'GET',\n path: '/stars/hash:{blockHash}',\n handler: (request, h) => {\n\t\t\t\t\n\t\t\t\treturn(this.getBlockByHash(request.params.blockHash));\n\t }\n });\n }", "title": "" }, { "docid": "2a64398ffc7d09bc650d8ceb76510c0d", "score": "0.63274264", "text": "getBlock(key) {\n if (key >= 0) return this.chain.get(key);\n return Promise.resolve(undefined);\n }", "title": "" }, { "docid": "d30573a4d056c05aaca90b87170c26f1", "score": "0.6290128", "text": "async getHeader(hash) {\n this.node = await this.ipfs.dag.get(hash);\n return this.node.value;\n }", "title": "" }, { "docid": "be5af9af79777c126d2157ac31f6a900", "score": "0.62366486", "text": "getBlockByHeight(blockHeight) {\n let self = this\n async function getBlockAsysnc() {\n let block = null;\n try {\n block = await self.chain.getLevelDBData(blockHeight);\n return block;\n } catch (err) {\n throw 'getBlockByHeight Error: err=' + err;\n }\n }\n // Return a Promise from which the Block could be thenned.\n return getBlockAsysnc();\n }", "title": "" }, { "docid": "b4b6ab91b998b1d5c3eba09c99e2c5b6", "score": "0.6230487", "text": "getDbBlockByHeight(blockHeight) {\n let self = this;\n return new Promise(function (resolve, reject) {\n self.db.get(blockHeight)\n .then((block) => {\n // console.log(\"DAL: Data retrieved from database at height \" + blockHeight + \" - \" + JSON.stringify(block));\n resolve(JSON.parse(block));\n })\n .catch((err) => {\n // console.log(\"DAL: Error retrieving block from database at height \" + blockHeight + \" - \" + JSON.stringify(err));\n reject(err);\n });\n });\n }", "title": "" }, { "docid": "506a7c252ea3026bf6cdf196bc0349b3", "score": "0.622102", "text": "get(hash) {\n return this.m_entryCache.get(hash);\n }", "title": "" }, { "docid": "b06041df8dea308b9a6a704579ab4d12", "score": "0.6214634", "text": "getBlockByIndex() {\n this.app.get(\"/block/:height\", (req, res) => {\n if (req.params.height < 0 ){\n res.json({error: \"Block index can't be negative\"});\n } else {\n this.blocks.getBlock(req.params.height)\n .then(block => res.json(req.params.height == 0 ? block : this._addDecodedStory(block)))\n }\n });\n }", "title": "" }, { "docid": "1d5bd160fc7751d02bc31d7b4895f7c0", "score": "0.6203536", "text": "getBlockByHash() {\n let self = this;\n this.app.get('/stars/hash\\::hash', (req, res) => {\n console.log(`BlockController.js - getBlockByHash input: hash ${req.params.hash}`);\n self.myBlockChain.getBlockByHash(req.params.hash).then((block) => {\n\n // Decode the star story into a new property storyDecoded\n let resultObject = JSON.parse(block);\n resultObject.body.star.storyDecoded = hex2ascii(resultObject.body.star.story);\n console.log(`BlockController.js - getBlockByHash output: ${JSON.stringify(resultObject)}`);\n res.status(200);\n res.type('application/json');\n res.set('Cache-Control', 'no-cache');\n res.set('Accept-Ranges', 'bytes');\n res.set('Connection', 'close');\n res.send(JSON.stringify(resultObject));\n }).catch((err) => {\n console.log(err);\n res.set('Connection', 'close');\n res.status(404);\n res.send(`getBlockByHash output: error message: ${err}`);\n });\n });\n }", "title": "" }, { "docid": "bb02099a0b2183db1f068da3b938e712", "score": "0.61707574", "text": "async function loadBlock(redisX, blockId) {\n return await redisX.hgetallAsync([`!blk:${blockId}`]);\n}", "title": "" }, { "docid": "30e0549451a3f0fb2a744dee6f34d7cd", "score": "0.6170619", "text": "async get(multihash) {\n\t\tthis.node = await this.ipfs.dag.get(multihash);\n\t\tthis.data = JSON.parse(this.node.value.data.toString());\n\t\tthis.data.hash = hashFromMultihash(multihash);\n return this.data;\n // return new Promise((resolve, reject) => util.cid(this.node.data, {\n // version: 1,\n // hashAlg: 'sha2-256'\n // }, async (error, cid) => {\n // if (error) reject(error);\n // resolve(this.transformBlock(this.node, cid))\n // }));\n\t}", "title": "" }, { "docid": "eab47d65f189fb3f36635b9aa6ee5c63", "score": "0.61438835", "text": "getBlockByIndex() {\n\t\tthis.app.get(`${this.urlPrefix}/block/:id`, async (req, res) => {\n\t\t\tlet blockId = req.params.id;\n\n\t\t\t// validate if block id is numeric\n\t\t\tif (helper.isNumeric(blockId)) {\n\t\t\t\t// parse block id string to integer\n\t\t\t\tblockId = parseInt(blockId);\n\n\t\t\t\t// get block data\n\t\t\t\tconst block = await this.myBlockChain.getBlock(blockId);\n\n\t\t\t\tif (block) {\n\t\t\t\t\tres.json(block);\n\t\t\t\t} else {\n\t\t\t\t\tres.sendStatus(404);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tres.sendStatus(400);\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "2a600b6e6cc4eda62511fac249388d11", "score": "0.6142254", "text": "getBlockByIndex() {\n this.server.route({\n method: 'GET',\n path: '/api/block/{index}',\n handler: (request, h) => {\n let block = this.Blockchain.getBlock(request.params.index);\n return block;\n\n }\n });\n }", "title": "" }, { "docid": "0627f4221d8c26062c8955341871ce9e", "score": "0.61260957", "text": "validateBlock(height) {\n return new Promise((resolve,reject)=>{\n this.getBlock(height).then((block)=>{\n let blockhash= block.hash;\n block.hash='';\n let validblockhash = SHA256(JSON.stringify(block)).toString();\n if(blockhash==validblockhash){\n console.log('valid block')\n resolve(true);\n }else{\n reject('invalid hash');\n }\n }).catch((err)=>{\n console.log('unable to get block '+height);\n reject(err);\n });\n });\n }", "title": "" }, { "docid": "b3c34757043a6c275da8bf0935bf232f", "score": "0.6117864", "text": "async getBlock(blockId) {\n return this.store.readBlock(blockId);\n }", "title": "" }, { "docid": "21b280d87fdefdc3d016b8ee7bc0f4d8", "score": "0.6117628", "text": "getBlockByIndex(index) {\n return this.chain.blocks[index]\n }", "title": "" }, { "docid": "aec6a928b246acc9765f3b6b0dea680f", "score": "0.6098856", "text": "get hash() {\n const block_str = JSON.stringify(this);\n const hash = crypto.createHash('SHA256');\n hash.update(block_str).end();\n return hash.digest('hex');\n }", "title": "" }, { "docid": "430c16e7428317fb0568c4e2301468bc", "score": "0.6098011", "text": "getBlock(b, d, h) {\n return b.find(i => i.day === d && i.hour === h);\n }", "title": "" }, { "docid": "a0e94057ecf9c7731355e980eb9aa609", "score": "0.60902804", "text": "getBlockByHeight() {\n this.app.get(\"/block/:height\", (req, res) => {\n let height = req.params[\"height\"];\n this.blockChain.getBlock(height).then((block) => {\n if(block) {\n block.body.star.storyDecoded = this._decode(block.body.star.story);\n res.json(block);\n } else {\n res.status(400).json({ error: 'Star not found.' });\n }\n }).catch((err) => {\n console.log(err);\n res.status(400).json({ error: 'Star not found.' });\n });\n });\n }", "title": "" }, { "docid": "7af039cc3b618cd78f61a992fcf6f2ef", "score": "0.60748774", "text": "addNewBlock(prevHash) {\n let block = {\n index: this.chain.length + 1,\n timestamp: Date.now(),\n votes: this.curr_votes,\n prevHash: prevHash,\n nonce: 0\n };\n //save the block only if it satisfies the hash puzzle\n if (validator.proofOfWork(block).toString().substring(0, difficulty) === Array(difficulty + 1).join('0')) {\n block.hash = hash(block);\n console.log('hash after mining: ', block.hash);\n console.log('hash of original: ', hash({\n timestamp: block.timestamp,\n votes: block.votes,\n index: block.index,\n prevHash: block.prevHash,\n nonce: block.nonce\n }));\n //Add it to the instance Save it on the DB Console Success\n this.saveBlock(block);\n return block;\n }\n }", "title": "" }, { "docid": "f42012105b4a6c7cabee258fc479b5fc", "score": "0.6073315", "text": "static blockHash(block) {\n //using ES6 destruction variable to assign the respective values inside the block object\n const {timestamp, last_hash, data, nonce, difficulty} = block;\n return Block.hash(timestamp, last_hash, data, nonce, difficulty);\n }", "title": "" }, { "docid": "b585fd37adf2d4149dc9a1baade612e5", "score": "0.60425514", "text": "validateBlock(height) {\n let self = this;\n return new Promise(function(resolve, reject) {\n self.getBlock(height).then(function(block) {\n const validBlockHash = block.hash;\n // to be able to compare blocks, it must not have the field hash\n delete block.hash;\n const blockHash = SHA256(JSON.stringify(block)).toString();\n\n if (validBlockHash === blockHash) {\n resolve(true);\n } else {\n resolve(false);\n }\n });\n });\n }", "title": "" }, { "docid": "78c984e36add29296dc4d8b14be9f234", "score": "0.60403657", "text": "getBlock(blockHeight){\n let self = this;\n console.log(`BlockChain.js - getBlock: height ${blockHeight}`);\n return new Promise(function(resolve, reject) {\n self.bd.getLevelDBData(blockHeight).then(function(result) {\n // return object as a single string\n resolve(JSON.parse(result));\n }, function(error) {\n reject(error);\n }\n );\n });\n }", "title": "" }, { "docid": "f572d43c918175ae80d802e4e34040ec", "score": "0.60368437", "text": "static blockHash(block) { \r\n const { timestamp, lastHash, data, nonce, difficulty } = block; // uses ES6 to assign variables within the block object\r\n return Block.hash(timestamp, lastHash, data, nonce, difficulty); // wraps around the hash function and provides the block as regular input\r\n }", "title": "" }, { "docid": "cd077bb4e182498be9700c02ffab4951", "score": "0.59994286", "text": "async getBlock(blockHeight) { \n \n return persistence.getLevelDBDataValue(blockHeight); \n }", "title": "" }, { "docid": "101183650a3691252e8ecab9886ecfc1", "score": "0.5993533", "text": "getBlock(height) {\n return this.db.getBlock(height);\n }", "title": "" }, { "docid": "c8f917865d4d8711131a1a40da69d2d2", "score": "0.59925884", "text": "getBlock(height) {\n // Add your code here\n\t\tlet self = this;\n\t\treturn self.db.getLevelDBData(height).then(function(blockString) {\n\t\t\treturn JSON.parse(blockString);\n\t\t});\n\n }", "title": "" }, { "docid": "8388dcc3f91e03a05b510e0872203b41", "score": "0.5991737", "text": "static hash(block){\n\n const blockString = JSON.stringify(block, Object.keys(block).sort());\n return crypto.createHash(\"sha256\").update(blockString).digest(\"hex\");\n\n\n /**\n * Returns the last blcok in the chain\n */\n lastBlock() {\n\n return this.chain.length && this.chain[this.chin.length - 1];\n\n }\n /** Determines if a hash begins with a \"difficulty\" number of 0s \n * \n * @param hashofBlcok: the hash of the block (hex string0\n * @param difficulty: an integer defining the dificulty\n */\n\n static powisAcceptable(hashOfBlock , difficulty ) {\n\n return hashOfBlock.slice( 0 , difficulty ) == \"0\".repeat(difficulty);\n\n }\n\n /**\n * Generates a random 32 byte string\n */\n\n static nonce() {\n\n return crypto.createHash(\"sha526\").update(crypto.randomBytes(32).digest(\"hex\");)\n\n }\n\n /**\n * \n * Proof of Work mining algorithm\n * \n * We hash the block with radom string util \n * the has begins with a \"difficulty\" number of 0s.\n */\n\n mine (blockToMine = null , dificulty = 4 ) {\n\n const block = blockToMine || this.lastBlock();\n\n while ( true ) {\n\n block.nounce = Blockchain.nounve();\n if(Blockchain.powIsAcceptable(Blockchain.hash(block), difficulty)) {\n console.log(\"We mined a block!\")\n console.log(`_BLock hash: ${Blochain.hash(block)}`)\n console.log (`-noncue: ${block.nonce}`);\n return block;\n \n }\n\n }\n\n }\n\n }", "title": "" }, { "docid": "07d81fdaa5ea8965dcc4a678bd044af1", "score": "0.59881526", "text": "function Latest(callback) {\n if (base) {\n var req = base + 'blocks/';\n request(req, function (error, response, body) {\n if (error) callback(error, null);\n try {\n if (JSON.parse(body).status === 200) {\n var data = JSON.parse(body).data.blocks;\n var result = {\n blockHex: null,\n blockId: data[0].hash\n };\n callback(null, result);\n }\n else {\n console.log(JSON.parse(body).messages);\n }\n }\n catch (err) {\n callback(err, null);\n }\n });\n }\n else {\n callback('error: no block IDs provided', null);\n }\n }", "title": "" }, { "docid": "a5aae2971e71205d13d2feb3ba17a53f", "score": "0.59795886", "text": "getBlockByIndex() {\n this.app.get(\"/block/:height\", async (req, res) => {\n let blockHeight = await this.blockChain.getBlockHeight(); \n if(req.params.height > blockHeight){\n res.status(404)\n .send('Not found');\n } else {\n let block = await this.blockChain.getBlock(req.params.height);\n if(block.body.star){\n block.body.star = {...block.body.star,\"storyDecoded\":hex2ascii(block.body.star.story)}\n }\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify(block));\n }\n });\n }", "title": "" }, { "docid": "ea719abb82a0a5167c7d3a2cd0d184c8", "score": "0.597481", "text": "getUncleCountByBlockHash(hash) {\n return this.send('eth_getUncleCountByBlockHash', hash).then(parseInt)\n }", "title": "" }, { "docid": "c7d377e664840d402157f26926374704", "score": "0.59655416", "text": "static blockHash(block){\n // get values from block object\n const { timestamp, lastHash, data, nonce, difficulty } = block;\n return Block.hash(timestamp, lastHash, data, nonce, difficulty);\n }", "title": "" }, { "docid": "071d9a2f24960224fe6555c83141181b", "score": "0.5958871", "text": "getBlock(key){\n\t\tlet self = this; // because we are returning a promise we will need this to be able to reference 'this' inside the Promise constructor\n\t\treturn new Promise(function(resolve, reject) {\n\t\t\t\t\t self.db.get(key, (err, value) => {\n if (err) {\n let err_msg = 'Not found! ' + err;\n console.log(err_msg);\n reject(err_msg); \n } else {\n let jblock = Object.assign(new BlockClass.Block, JSON.parse(value));\n resolve(jblock);\n }\n\t\t\t\t\t });\n\t\t});\n\t}", "title": "" }, { "docid": "3d3f2ad3dcef814e8a944974741d0138", "score": "0.59539866", "text": "function getBlockHeightInfo(chainId, height) {\n return web3.thk.GetBlockHeader(chainId, height)\n}", "title": "" }, { "docid": "e955131302703b3beb381f5ebe8a475b", "score": "0.5947313", "text": "async getBlock(height) {\n // return object as a single string\n // return JSON.parse(JSON.stringify(this.chain[blockHeight]));\n return JSON.parse(await dbtools.getLevelDBData(height))\n }", "title": "" }, { "docid": "95428272c9f6ee7f38f9efb0971abc79", "score": "0.5935289", "text": "function getLatestBlock(web3) {\n var latestBlock = {\n method: 'eth_blockNumber',\n params: []\n };\n return rpcGet(latestBlock, web3);\n}", "title": "" }, { "docid": "6f5d57525b2625d0df5d07791785d048", "score": "0.5926745", "text": "function findTimeblock(hour) {\n for (i = 0; i < timeblocks.length; i++) {\n if (timeblocks[i].hour == hour) {\n //found it so return it\n return timeblocks[i].hour;\n }\n }\n return -1;\n }", "title": "" }, { "docid": "bdd5203edb97b5a97104a0f3933e0f68", "score": "0.59254336", "text": "async getHeadBlock() {\n let blockId = await this.store.readHeadBlock();\n return this.getBlock(blockId);\n }", "title": "" }, { "docid": "16a3dc349fed730e2f65a535599c3d9f", "score": "0.592061", "text": "getBlockByHeight() {\n this.app.get(\"/block/:height\", async (req, res) => {\n if(req.params.height) {\n const height = parseInt(req.params.height);\n let block = await this.blockchain.getBlockByHeight(height);\n if(block){\n return res.status(200).json(block);\n } else {\n return res.status(404).send(\"Block Not Found!\");\n }\n } else {\n return res.status(404).send(\"Block Not Found! Review the Parameters!\");\n }\n \n });\n }", "title": "" }, { "docid": "153f7faea78707e840527e59ceb3c6bd", "score": "0.5920205", "text": "async getBlockByIndex() {\n let self = this;\n this.app.get(\"/block/:index\",async (req, res) => {\n // returns any block if its in the blockchain height \n if(req.params.index > await self.bc.getBlockHeight()){\n res.send(\"this block doesn't exist\");\n }else{\n let block = await self.bc.getBlock(req.params.index);\n console.log(block)\n \n res.send(block);\n }\n });\n }", "title": "" }, { "docid": "927df01ec902779f1cf8ac1fbf3c42c5", "score": "0.58831245", "text": "getBlock(blockId) {\n\n\t\tlet foundBlock = this.currentBlocks.blocks.find(element =>\n\t\t\telement.blockId === blockId);\n\n\t\tconst jsonPromise = () => new Promise((resolve, reject) => {\n\t\t\tif (!foundBlock) {\n\t\t\t\tfoundBlock = {}\n\t\t\t}\n\t\t\tresolve(foundBlock)\n\t\t});\n\t\tlet promise;\n\t\tif (!foundBlock) {\n\t\t\tpromise = new Promise((resolve, reject) => {\n\t\t\t\tsetTimeout(() => resolve({\n\t\t\t\t\tstatus: 404,\n\t\t\t\t\tstatusText: \"Block not Found\",\n\t\t\t\t}), this.delay);\n\t\t\t});\n\t\t} else {\n\t\t\tpromise = new Promise((resolve, reject) => {\n\t\t\t\tsetTimeout(() => resolve({\n\t\t\t\t\tstatus: 200,\n\t\t\t\t\tstatusText: \"OK\",\n\t\t\t\t\tjson: jsonPromise\n\t\t\t\t}), this.delay);\n\t\t\t});\n\t\t}\n\t\t\n\t\treturn promise;\n\t}", "title": "" }, { "docid": "114198eb7ca688e4d419285a96e60d39", "score": "0.58769166", "text": "getBlockByIndex() {\n this.app.get('/block/:height(\\\\d+)', this.convertHeightToInt, (req, res, next) => {\n const requestedHeight = req.params.height;\n this.blockchain.getBlockHeight()\n .then(height => {\n if (height === this.EMPTY_HEIGHT) {\n const emptyBlockchainMessage = 'Blockchain is empty';\n res.status(404).json(this.getErrorResponse(emptyBlockchainMessage));\n next(`ERROR: ${emptyBlockchainMessage}`);\n } else if (requestedHeight < 0 || requestedHeight > height) {\n const invalidBlockMessage = (\n `Invalid block (${requestedHeight}) requested`);\n res.status(400).json(this.getErrorResponse(invalidBlockMessage));\n next(`ERROR: ${invalidBlockMessage}`);\n } else {\n return this.blockchain.getBlock(requestedHeight)\n .then(curBlock => {\n let block = JSON.parse(curBlock);\n res.status(200).json(this.getBlockResponse(block));\n })\n }\n })\n .catch(error => {\n res.status(500).json(this.getErrorResponse(this.UNKNOWN_ERROR_MSG));\n next(`ERROR: ${error}`);\n });\n });\n }", "title": "" }, { "docid": "f2a8381ecd4f344ed284677322dc4d80", "score": "0.5874106", "text": "validateBlock(height) {\n // Add your code here\n\t\tlet self = this;\n\t\treturn new Promise(function(resolve, reject) {\n\t\t\tself.getBlock(height).then(function(block){\n\t\t\t\tvar storedHash = block.hash;\n\t\t\t\tblock.hash='';\n\t\t\t\tvar recalculatedHash = SHA256(JSON.stringify(block)).toString();\n\t\t\t\tif (storedHash == recalculatedHash) {\n\t\t\t\t\tconsole.log(\"block hash same\");\n\t\t\t\t\tresolve(true);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(false);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(function (getBlock_err) {\n\t\t\t\tconsole.log(getBlock_err);\n\t\t\t\treject(getBlock_err)\n\t\t\t});\n\t\t});\n }", "title": "" }, { "docid": "f9e07d53094b640f58cff75bc38def92", "score": "0.58569974", "text": "async getBlockByWalletAddress(address) {\n let self = this;\n let blocks = [];\n return new Promise((resolve, reject) => {\n self.db.createReadStream()\n .on('data', function (data) {\n let currentBlock = JSON.parse(data.value);\n if(currentBlock.body.address === address) {\n blocks.push(currentBlock);\n }\n })\n .on('error', function (err) {\n reject(err)\n })\n .on('close', function () {\n if(blocks.length === 0) {\n reject(new Error(`Block with address '${address}' not found`));\n }\n else {\n resolve(blocks);\n }\n });\n });\n }", "title": "" }, { "docid": "ccb9d350c9387c961e3beca71561f8f0", "score": "0.5852774", "text": "async function latest_block() {\n return new Promise((resolve, reject) => {\n // Go look for the block in a promise\n web3.eth.getBlock('latest', (err, block) => {\n if (err) {\n // If we fail, reject\n return reject(err)\n }\n \n // Otherwise, resolve with the block\n return resolve(block)\n })\n })\n}", "title": "" }, { "docid": "8f1202dc5ff34087cbcf4ba227fc02f8", "score": "0.58522785", "text": "getBlockByWalletAddress(address) {\r\n let self = this;\r\n let blocks = [];\r\n // console.log('address', address);\r\n return new Promise((resolve, reject) => {\r\n self.db.createReadStream()\r\n .on('data', (data) => {\r\n if(JSON.parse(data.value).body.address === address) {\r\n let block = JSON.parse(data.value);\r\n block.body.star.storyDecoded = hex2ascii(block.body.star.story)\r\n blocks.push(block);\r\n }\r\n })\r\n .on('error', (err) => {\r\n reject(err);\r\n })\r\n .on('close', () => {\r\n resolve(blocks);\r\n })\r\n })\r\n }", "title": "" }, { "docid": "af5c6175c83496a1108c54342bc11560", "score": "0.5830048", "text": "validateBlock(blockHeight){\n let self = this;\n return new Promise(function(resolve, reject) {\n // get block object\n self.getBlock(blockHeight).then(function(block) {\n // get block hash\n let blockHash = block.hash;\n // remove block hash to test block integrity\n block.hash = '';\n // generate block hash\n let validBlockHash = SHA256(JSON.stringify(block)).toString();\n // Compare\n if (blockHash === validBlockHash) {\n resolve(true);\n } else {\n resolve(false);\n }\n }, function(error) {\n reject(`validateBlock: Error found when calling getBlock: ${error}`);\n }\n );\n });\n }", "title": "" }, { "docid": "6eb4ed9d2c4694f22c9ffa0ab4894a30", "score": "0.5826007", "text": "static calculateHashForBlock (block) {\n return Ruleset.calculateHash(block.index, block.nonce, block.previousHash, block.timestamp, block.data, block.status, block.creatorID);\n }", "title": "" }, { "docid": "e44af2ae0d415137473f0340556edf66", "score": "0.5810887", "text": "function handle_queryBlockById(params, res, req) {\n\tlogger.debug('==================== GET BLOCK BY NUMBER ==================');\n var body = {\n code : retCode.OK,\n msg : \"OK\",\n };\n\n\tlet blockId = params.blockId;\n\tlet peer = params.peer;\n if (!peer) {\n peer = 'peer1'\n }\n\tlogger.debug('BlockID : ' + blockId);\n\tlogger.debug('Peer : ' + peer);\n\tif (!blockId) {\n\t\tres.json(paraInvalidMessage('\\'blockId\\''));\n\t\treturn;\n\t}\n\n var username = params.usr;\n\tif (!username) {\n\t\tusername = 'admin'\n\t}\n\n var orgname = params.org;\n\tif (!orgname) {\n orgname = 'org1'\n\t}\n\n\treturn hfc_wrap.getBlockByNumber(peer, blockId, username, orgname)\n\t.then((response)=>{\n logger.debug('getBlockById success, response=', response)\n body.msg = 'ok'\n body.result = response\n res.send(body);\n })\n .catch((err)=>{\n logger.error('getBlockById failed, err=%s', err)\n body.msg = '' + err\n res.send(body);\n });\n}", "title": "" }, { "docid": "5f9a47b1827de50b0737c9f193391946", "score": "0.5807285", "text": "async getBlockByAddress(address){\n let blocks = [] ; \n return await new Promise(function(resolve, reject) {\n levelSandbox.getData().then( function(chain) {\n if(chain.length>0){\n for (var i = 0; i < (chain.length); i++) {\n console.log(address);\n console.log(i+ ') '+chain[i].body.address);\n if (chain[i].body.address === address){\n console.log('found!!');\n blocks.push(chain[i]);\n }\n }\n if (blocks.length >0){\n //console.log('Blocks'+ JSON.stringify(blocks));\n resolve(blocks);\n } else{\n reject({'error': 'invalid address'});\n }\n } else{\n reject({'error': 'Blockchain is empty'});\n }\n \n }).catch(function (message) {\n console.log(message);\n reject({'error': message});\n });\n });\n \n }", "title": "" }, { "docid": "cd7db85a340168c0a588795f158a5f0d", "score": "0.5776222", "text": "getBlockByIndex() {\n this.app.get(\"/block/:index\", (req, res) => {\n this.myBlockChain.getBlock(req.params[\"index\"]).then((bloco) => {\n res.send(bloco);\n }).catch((err) => { res.send(\"Block \" + req.params[\"index\"] + \" not found!\");});\n });\n\n this.app.get(\"/block/\", (req, res) => {\n res.send(\"You must ask for a valid block!\");\n });\n }", "title": "" }, { "docid": "ed0ae12590735778873293da8f8a9e08", "score": "0.5761027", "text": "receive(transferAmt, sendBlockHash) {\n const newReceiveBlock = new Block('receive', {\n previous: this.getPrevBlockHash(),\n source: sendBlockHash,\n })\n\n this.chain.push(newReceiveBlock);\n\n this.balance += transferAmt;\n\n return newReceiveBlock.hash;\n }", "title": "" }, { "docid": "c851d36936c084fb93c8b958ee5cf35b", "score": "0.57591665", "text": "static verifyBlockHash(block, hash) {\n\t\treturn hash === this.calcBlockHash(block.index, block.previousHash, block.timestamp, block.data);\n\t}", "title": "" }, { "docid": "06165dbf1587092008d8105691e61fc0", "score": "0.5758428", "text": "async getBlock(blockHeight) {\n await this._checkInit();\n return getLevelDBJSONAsync(blockHeight);\n }", "title": "" }, { "docid": "112b4fa2b34ac620a46e14ada408dc99", "score": "0.57498467", "text": "async fetchBlock (cid) {\n // found is either the block or a promise of the block.\n const found = this.blockByCid[cid]\n if (found) return found\n\n const fullBlockPromise = api.getJson(`/api/show/block/${cid}`).then(fullBlock => {\n return {\n\t cid: cid,\n header: mapAllBigInts(fullBlock.Header),\n messages: fullBlock.Messages,\n messageReceipts: fullBlock.Receipts\n }\n });\n \n // Handle if another req for the same cid comes in while we're waiting for this one.\n // fetchBlock is an async funtion, so it always returns a promise.\n this.blockByCid[cid] = fullBlockPromise\n\n const fullBlock = await fullBlockPromise\n\n this.blockByCid[cid] = fullBlock\n this.addBlockToChain(fullBlock)\n\n return Object.assign({}, fullBlock)\n }", "title": "" }, { "docid": "c85516b3493fdd92bef27dfb87f07846", "score": "0.57339776", "text": "async getBlockByAddress(address) {\n const parsedBlock = await this.db.getLevelDBDataByAddress(address);\n return parsedBlock;\n }", "title": "" }, { "docid": "8feb244f6acc571de5948cc3dac1ecae", "score": "0.5732126", "text": "validateBlock(height) {\n return new Promise((resolve, reject) => {\n // get block\n let block = this.getBlock(height);\n // get block hash\n let blockHash = block.hash;\n // remove block hash for test\n block.hash = '';\n // create valid hash\n let validBlockHash = SHA256(JSON.stringify(block));\n // comparison\n if (blockHash === validBlockHash) {\n resolve(true);\n } else {\n console.log('Block No. ' + height + ' invalid hash:\\n' + blockHash + '-' + validBlockHash);\n resolve(false);\n }\n })\n\n }", "title": "" }, { "docid": "9db434c62a60baeaa43ec6c1788c9994", "score": "0.5729954", "text": "getLatestBlock() {\n let self = this\n async function getBlockAsysnc() {\n let block = null;\n try {\n let height = await self.getBlockHeight();\n block = await self.getBlockByHeight(height + 1);\n return block;\n } catch (err) {\n throw 'getLatestBlock Error: err=' + err;\n }\n }\n // Return a Promise from which the Block could be thenned.\n return getBlockAsysnc();\n }", "title": "" }, { "docid": "16ae1374deefa5572d0b45ba80b45b0d", "score": "0.57255995", "text": "async getBlockByID(blkID: string): Promise<TBlock> {\n return await this.send(this.getBlockByID.name, blkID);\n }", "title": "" }, { "docid": "4085c9f2e56afe159ba1248aa42c0726", "score": "0.5713502", "text": "function pickPastBlockHash(cb) {\n if (lastBlockHash) {\n // Use lastBlockHash already known to Baron\n cb(null, lastBlockHash);\n }\n else {\n db.getLatestPaymentWithBlockHash(function(err,payment) {\n if (payment) {\n // Startup: attempt to find recent blockhash from the latest paid transaction\n findPastValidBlock(payment.blockhash, function(err, blockHash) {\n if (err) {\n cb(err);\n }\n else {\n console.log('lastBlockHash Initialized: ' + blockHash);\n cb(null, blockHash);\n }\n });\n }\n else {\n // Not found, set to genesis so listSinceBlock does not miss any transactions\n findGenesisBlock(function(err, blockHash) {\n if (err) {\n cb(err);\n }\n else {\n console.log('lastBlockHash Initialized from Genesis: ' + blockHash);\n cb(null, blockHash);\n }\n });\n }\n });\n }\n}", "title": "" }, { "docid": "a0b8acdc43c948399bb93a29b17bda04", "score": "0.570385", "text": "function getPathFromHash(hash) {\n for (var i in flowObject) {\n if (flowObject[i].hash == hash) {\n return flowObject[i].page\n }\n }\n return null;\n}", "title": "" }, { "docid": "3011adcc03d9a60e49130716434f0a6a", "score": "0.5700871", "text": "firstblock() {\r\n return this.blockchain[0];\r\n }", "title": "" }, { "docid": "32da4bef94be9f7fb15291f9bb41d0ae", "score": "0.5686457", "text": "getTransactionByHash(hash) {\n return this.send('eth_getTransactionByHash', hash)\n }", "title": "" }, { "docid": "9cb762494f8a488b0d60795a63a3d0e9", "score": "0.56766474", "text": "async updateBlock(request, h) {\n const { hash } = request.params\n var result = await mBlockModel.BlockModel.findOneAndUpdate({ hash }, request.payload, { new: true });\n return h.response(result);\n }", "title": "" }, { "docid": "4580acdeefff18c76a9b679c4a2e5aa8", "score": "0.5672996", "text": "getBlockByHeight() {\n let self = this;\n this.app.get('/block/:height', (req, res) => {\n console.log(`BlockController.js - getBlockByHeight input: height ${req.params.height}`);\n self.myBlockChain.getBlock(req.params.height).then((block) => {\n\n // Decode the star story into a new property storyDecoded\n let resultObject = block;\n resultObject.body.star.storyDecoded = hex2ascii(resultObject.body.star.story);\n\n console.log(`BlockController.js - getBlockByHeight output: ${JSON.stringify(resultObject)}`);\n res.status(200);\n res.type('application/json');\n res.set('Cache-Control', 'no-cache');\n res.set('Accept-Ranges', 'bytes');\n res.set('Connection', 'close');\n res.send(JSON.stringify(resultObject));\n }).catch((err) => {\n console.log(err);\n res.set('Connection', 'close');\n res.status(404);\n res.send(`getBlockByHash output: error message: ${err}`);\n });\n });\n }", "title": "" } ]
a3a29d7c75f170ce4ae108e2f5c331bd
CSV Parser input: csv output: array of objects where aech object is mapped from heading (key) to value per row of csv also need to pass in sort by attribute
[ { "docid": "b5e3d4bf2b97e6162c0dbd5b2728b517", "score": "0.8145466", "text": "function parseCSV(csv, attributeSortBy) {\n var lines = csv.split('\\n');\n // split lines up\n var heading = lines[0].split(',');\n var headingLength = heading.length;\n // further split up the heading by comma separated values\n var result = [];\n\n for (var i = 1; i < lines.length; i++) {\n var map = {};\n var row = lines[i].split(',');\n for (var j = 0; j < headingLength; j++) {\n // we know that for each heading we want to just process if it has a key\n map[heading[j]] = row[j];\n }\n // after setting up map, push in the result\n result.push(map);\n }\n\n // sort by attribute\n result.sort(function(value1, value2) {\n // override sort comparator\n return value1.attributeSortBy > value2.attributeSortBy;\n });\n\n console.log(result);\n}", "title": "" } ]
[ { "docid": "7d151d4c45e15370cb0818b613b0b3d7", "score": "0.6735732", "text": "function csvParser(csv){\n\n var parsed = []; //clear array\n\n var lines=csv.toString().split(\"\\r\\n\"); //split cvs file into readable lines of data by endlines\n var headers=lines[0].split(\",\"); //split the first line into object variable names\n\n //goes through every line but the header line\n for(var i=1;i<lines.length - 1;i++){ //last line is empty. dont put that in the array\n\n\t var obj = {}; //create new object to be added to the array\n\t var currentline = lines[i].split(\",\"); //split the current line into object variable values\n\n //hotfix for provinces with commas in the name\n if(headers.length < currentline.length) {\n var combinedLines = currentline[2] + ',' + currentline[3];\n var removeQuotes = combinedLines.split(\"\\\"\");\n currentline[2] = removeQuotes[1];\n currentline[3] = currentline[4];\n currentline[4] = currentline[5];\n currentline[5] = currentline[6];\n currentline[6] = currentline[7];\n currentline[7] = currentline[8];\n }\n\n //for each variable name in header, assign the value from that line\n\t for(var j=0;j<headers.length;j++){\n\t\t obj[headers[j]] = currentline[j];\n\t }\n\n\t parsed.push(obj); //push newly created object on to array\n }\n return parsed;\n}", "title": "" }, { "docid": "eec22735d61df20a0694ee5e006a5fd5", "score": "0.6671635", "text": "function csvToObj(csv) {\n const cleanedCsv = csv.replace(/\\r/g, '').replace(/^\\uFEFF/, '');\n const lines = cleanedCsv.split('\\n');\n const results = [];\n const headers = lines[0].split(',');\n for (let i = 1; i < lines.length; i++) {\n const obj = {};\n const currentline = lines[i].split(',');\n for (let j = 0; j < headers.length; j++) {\n obj[headers[j]] = currentline[j];\n }\n results.push(obj);\n }\n const empArray = Object.values(results.reduce((result, emp) => {\n const empId = emp['Employee ID'];\n const effDate = emp['Effective Date'];\n const manager = emp['Manager 1'];\n // Create new group\n if (empId && !result[empId])\n result[empId] = {\n empId,\n lines: []\n };\n // Append to group\n result[empId].lines.push({\n effDate,\n manager\n });\n return result;\n }, {}));\n empArray.sort((a, b) => Number(a.empId) - Number(b.empId));\n return empArray;\n}", "title": "" }, { "docid": "b70a3f3c9b0366ba53843f20962e2eab", "score": "0.66604817", "text": "function csv_parse(csvFile){\n \n var array = csvFile.split(\"\\n\");\n var headers = array[0].split(\",\");\n \n var array2 = [];\n var counter = 0; \n \n while(counter < array.length-2)\n {\n var values = array[counter+1].split(\",\");\n var obj = {};\n for (var i = 0; i < values.length; i++){\n obj[headers[i]] = values[i]; \n }\n array2.push(obj);\n counter+=1;\n }\n return array2;\n}", "title": "" }, { "docid": "bf799a9e2771419837b307c3519ffd9d", "score": "0.659942", "text": "function csvArr(csv){\n\n var lines=csv.split(\"\\n\");\n\n var result = [];\n\n var headers=lines[0].split(\",\");\n\n for(var i=1;i<lines.length;i++){\n\n\t var obj = {};\n\t var currentline=lines[i].split(\",\");\n\n\t for(var j=0;j<headers.length;j++){\n\t\t obj[headers[j]] = currentline[j];\n\t }\n\n\t result.push(obj);\n\n }\n\n return result; //JavaScript object\n //return JSON.stringify(result); //JSON\n}", "title": "" }, { "docid": "e690a4f7789c54b821f54c729e851b2a", "score": "0.656677", "text": "function _csv2table(csv) {\n let lines = Papa.parse(csv, {\n delimiter: \",\",\n newline: \"\\n\",\n dynamicTyping: true\n }).data;\n let fields = lines.shift();\n let headers = {};\n let rows = [];\n\n for (let field of fields) headers[field] = {};\n\n for (let line of lines) {\n var obj = {};\n for (let field in fields) {\n let header = headers[fields[field]];\n let value = line[field];\n\n if (\n value === \"\" ||\n value === '\"\"' ||\n value === \"null\" ||\n value === null\n ) {\n obj[fields[field]] = null;\n header.null = header.null ? header.null + 1 : 1;\n } else if (value === \"true\" || value === true) {\n obj[fields[field]] = true;\n header.bool = header.bool ? header.bool + 1 : 1;\n } else if (value === \"false\" || value === false) {\n obj[fields[field]] = false;\n header.bool = header.bool ? header.bool + 1 : 1;\n } else if (typeof value === \"object\") {\n obj[fields[field]] = value.toISOString();\n header.string = header.string ? header.string + 1 : 1;\n } else if (!isNaN(value)) {\n obj[fields[field]] = value;\n if (parseInt(value) == value) {\n header.int = header.int ? header.int + 1 : 1;\n } else {\n header.float = header.float ? header.float + 1 : 1;\n }\n } else {\n obj[fields[field]] = value;\n header.string = header.string ? header.string + 1 : 1;\n }\n }\n rows.push(obj);\n }\n\n for (let field in headers) {\n // strings\n if (headers[field].string) {\n headers[field] = \"string\";\n continue;\n }\n // nulls\n if (Object.keys(headers[field]).length === 1 && headers[field].null) {\n headers[field] = \"string\";\n continue;\n }\n // floats\n if (headers[field].float) {\n headers[field] = \"float\";\n continue;\n }\n // integers\n if (headers[field].int) {\n headers[field] = \"int\";\n continue;\n }\n // booleans\n if (headers[field].bool) {\n headers[field] = \"bool\";\n continue;\n }\n headers[field] = \"string\";\n }\n\n return { headers, rows };\n}", "title": "" }, { "docid": "830104b3c9c4ca60c239603b00486ed2", "score": "0.6564224", "text": "function csv2Array(csv)\n{\nvar DEBUG = debug(false, arguments, false), FUNCNAME = funcname(arguments);\n\n\tDEBUG && GM_log(\"csv.length=\", csv.length);\n\n\tvar csvArr = csv.split(/\\r\\n|\\r|\\n/);\n\n\tDEBUG && GM_log(\"csvArr.length=\", csvArr.length);\n\n\tvar headers = csvArr.shift().split(/,/);\t// pop the first element and split it\n\tfor(var index = 0; index < headers.length; index++)\t\n\t\theaders[index] = headers[index].trim();\t// trim the values\n\t\n\tDEBUG && GM_log(\"headers=\", headers);\n\n\tvar retArr = [];\n\n\tvar line;\n\twhile(line = csvArr.shift())\n\t{\n\t\tDEBUG && GM_log(\"line=\" + line);\n\n\t\tvar length = line.length;\n\n\t\tif(length == 0)\n\t\t\tcontinue;\n\n\t\tvar rowarr = [];\n\t\tvar stringarr = [];\n\t\tvar inString = false;\n\t\tfor(var charIndex = 0; charIndex < length; charIndex++)\n\t\t{\n\t\t\tvar ch = line.charAt(charIndex);\n\n\t\t\tif(ch == '\"')\n\t\t\t\tinString = !inString;\n\t\t\telse if(!inString && ch == ',')\n\t\t\t{\n\t\t\t\tvar string = stringarr.join('');\n\t\t\t\trowarr.push(string);\n\t\t\t\tstringarr = [];\n\t\t\t}\n\t\t\telse\n\t\t\t\tstringarr.push(ch);\n\t\t}\n\t\t\n\t\tvar string = stringarr.join('');\n\t\trowarr.push(string);\n\t\t\n\t\t\n\t\t/* add properties to match headers */\n\t\tfor(var rowIndex = 0; rowIndex < rowarr.length; rowIndex++)\n\t\t{\n\t\t\trowarr[rowIndex] = rowarr[rowIndex].trim();\t// trim the value\n\n\t\t\tvar header = headers[rowIndex];\n\n\t\t\trowarr[header] = rowarr[rowIndex];\t// also assign the value as a property on the row\n\t\t}\n\n\t\tretArr.push(rowarr);\n\t}\n\n\tDEBUG && GM_log(\"retArr.length=\", retArr.length);\n\treturn retArr;\n}", "title": "" }, { "docid": "eb25a99d2cfa91a5d7b5484c810bc429", "score": "0.65424275", "text": "function processDataAsObj(csv){\n var allTextLines = csv.split(/\\r\\n|\\n/);\n var lines = [];\n \n //first line of csv\n var keys = allTextLines.shift().split(',');\n \n while (allTextLines.length) {\n var arr = allTextLines.shift().split(',');\n var obj = {};\n for(var i = 0; i < keys.length; i++){\n obj[keys[i]] = arr[i];\n }\n lines.push(obj);\n }\n console.log(lines);\n drawOutputAsObj(lines);\n }", "title": "" }, { "docid": "333fdf36f5ec4b20ac37cfe2eee1b7d7", "score": "0.65157837", "text": "function csvToJson(csv) {\n let lines=csv.split(\"\\n\");\n let headers= lines[0].split(\",\");\n let result = [];\n \n // loop through each line and split by \",\"\n for (let i=1; i<lines.length; i++) {\n let obj = {};\n let currentline = lines[i].split(\",\");\n\n // check for typos ie. extra/ not enough commas\n if (currentline.length !== headers.length) {\n console.log(\"error: invalid format \" + currentline)\n } else {\n // loop through currentline and assign to their respective attribute \n for (let j=0; j<headers.length; j++) {\n obj[headers[j]] = currentline[j];\n }\n \n // push the resulting object into the JSON\n result.push(validator(obj));\n }\n }\n \n //return JSON\n return result;\n }", "title": "" }, { "docid": "55b580fd591929ea731593bad51b417b", "score": "0.64681184", "text": "function csvJSON(csv)\r\n{\r\n\r\n var lines = csv.split(\"\\n\");\r\n\r\n var result =[];\r\n\r\n var headers = lines[0].split(\",\");\r\n\r\n for(var i = 1; i<lines.length; i++)\r\n {\r\n\r\n var obj =\r\n {\r\n };\r\n\r\n var currentline = lines[i].split(\",\");\r\n\r\n for(var j = 0; j<headers.length; j++)\r\n {\r\n obj[headers[j]] = currentline[j];\r\n }\r\n\r\n result.push(obj);\r\n\r\n }\r\n\r\n //return result; //JavaScript object\r\n return result //JSON.stringify(result); //JSON\r\n}", "title": "" }, { "docid": "1da9bc80eec13ec24f0029776795fcb6", "score": "0.646695", "text": "function processCsvData(allText) {\n\tvar numHeadings = 5; // or however many elements there are in each row\n\tvar allTextLines = allText.split(/\\r\\n|\\n/);\n\t//console.log('found',allTextLines.length,'text lines!!!')\n\tvar headings = allTextLines[0].split(',');\n\tnumHeadings = headings.length;\n\t//console.log('headings',numHeadings,headings);\n\tlet entries = allTextLines.splice(1);\n\t//entries = entries.slice(0,10);\n\t//entries.map(x=>console.log(x)); \n\tvar records = { headings: headings };\n\t// var recordsByName = {};\n\tfor (const e of entries) {\n\t\tlet o = {};\n\t\tlet values = e.split(',');\n\t\tfor (let i = 0; i < numHeadings; i++) {\n\t\t\tlet k = headings[i];\n\t\t\to[k] = values[i];\n\t\t}\n\t\to.order = Number(arrLast(values));\n\n\t\trecords[o.hexcode] = o;\n\t\t//recordsByName[o.annotation] = o.hexcode;\n\t}\n\t//console.log('recordsByName',recordsByName)\n\treturn records; //{ records: records, recordsByName: recordsByName };\n}", "title": "" }, { "docid": "b8b4575926b8dab44bd709f9c4deac9d", "score": "0.6342248", "text": "function csvJSON(csv){\n\n var lines=csv.split(\"\\r\\n\");\n var result = [];\n \n var headers=lines[0].split(\",\");\n \n for(var i=1;i<lines.length;i++){\n \n var obj = {};\n var currentline=lines[i].split(\",\");\n \n for(var j=0;j<headers.length;j++){\n obj[headers[j]] = currentline[j];\n }\n \n result.push(obj);\n \n }\n \n return JSON.stringify(result); //JSON\n}", "title": "" }, { "docid": "341d3d0942e676f031c486c6381d5c04", "score": "0.6298816", "text": "function csvJSON(csv){\n\n var lines=csv.split(\"\\n\");\n var result = [];\n\n var headers=lines[0].split(\",\");\n headers[headers.length-1] = headers[headers.length-1].replace('\\r', '');\n \n for(var i=1;i<lines.length;i++){\n\n\t var obj = {};\n\t var currentline=lines[i].split(\",\");\n\n\t for(var j=0;j<headers.length;j++){\n\t\t obj[headers[j]] = currentline[j];\n\t }\n\n\t result.push(obj);\n }\n \n return result; //JavaScript object\n // return JSON.stringify(result); //JSON\n}", "title": "" }, { "docid": "2867a730e97e3e77f2255026cd64fb5f", "score": "0.62984884", "text": "function csvJSON(csv){\n csv = csv.replace(/\\0/g, '');\n \n var lines=csv.split(\"\\n\");\n\n var result = [];\n\n var headers=lines[0].split(\",\");\n\n for(var i=1;i<lines.length;i++){\n\n var obj = {};\n var currentline=lines[i].split(\",\");\n\n for(var j=0;j<headers.length;j++){\n obj[headers[j]] = currentline[j];\n }\n\n result.push(obj);\n\n }\n \n //return result; //JavaScript object\n console.log(result);\n console.log(JSON.stringify(result));\n return JSON.stringify(result); //JSON \n}", "title": "" }, { "docid": "99151bc88d86771933bcd98395487d7e", "score": "0.6250151", "text": "function CSVToArray( strData, strDelimiter ){\n// Check to see if the delimiter is defined. If not,\n// then default to comma.\nstrDelimiter = (strDelimiter || \",\");\n \n// Create a regular expression to parse the CSV values.\nvar objPattern = new RegExp(\n(\n// Delimiters.\n\"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n \n// Quoted fields.\n\"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n \n// Standard fields.\n\"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n),\n\"gi\"\n);\n \n \n// Create an array to hold our data. Give the array\n// a default empty first row.\nvar arrData = [[]];\n \n// Create an array to hold our individual pattern\n// matching groups.\nvar arrMatches = null;\n \n \n// Keep looping over the regular expression matches\n// until we can no longer find a match.\nwhile (arrMatches = objPattern.exec( strData )){\n \n// Get the delimiter that was found.\nvar strMatchedDelimiter = arrMatches[ 1 ];\n \n// Check to see if the given delimiter has a length\n// (is not the start of string) and if it matches\n// field delimiter. If id does not, then we know\n// that this delimiter is a row delimiter.\nif (\nstrMatchedDelimiter.length &&\n(strMatchedDelimiter != strDelimiter)\n){\n \n// Since we have reached a new row of data,\n// add an empty row to our data array.\narrData.push( [] );\n \n}\n \n \n// Now that we have our delimiter out of the way,\n// let's check to see which kind of value we\n// captured (quoted or unquoted).\nif (arrMatches[ 2 ]){\n \n// We found a quoted value. When we capture\n// this value, unescape any double quotes.\nvar strMatchedValue = arrMatches[ 2 ].replace(\nnew RegExp( \"\\\"\\\"\", \"g\" ),\n\"\\\"\"\n);\n \n} else {\n \n// We found a non-quoted value.\nvar strMatchedValue = arrMatches[ 3 ];\n \n}\n \n \n// Now that we have our value string, let's add\n// it to the data array.\narrData[ arrData.length - 1 ].push( strMatchedValue );\n}\n \n// Return the parsed data.\nreturn( arrData );\n}", "title": "" }, { "docid": "bacaf6224df595d0503a9b519000d97d", "score": "0.6200818", "text": "function csvJSON(csv){\r\n\r\n var lines=csv.split(\"\\n\");\r\n\r\n var result = [];\r\n\r\n var headers=lines[0].split(\";\");\r\n\r\n for(var i=1;i<lines.length;i++){\r\n\r\n\t var obj = {};\r\n\t var currentline=lines[i].split(\";\");\r\n\r\n\t for(var j=0;j<headers.length;j++){\r\n\t\t obj[headers[j]] = currentline[j];\r\n\t }\r\n\r\n\t result.push(obj);\r\n\r\n }\r\n\r\n //return result; //JavaScript object\r\n return JSON.stringify(result); //JSON\r\n}", "title": "" }, { "docid": "86272733a5edf29b1661c09457d99160", "score": "0.6159671", "text": "function csvParse(csvFile){\n var arrayOfObjects = [];\n var arr = csvFile.split(\"\\n\");\n var newObj;\n var keys = arr.shift().split(\",\");\n arr.forEach(function(contact){\n contact = contact.split(\",\");\n newObj = {};\n for(var i =0; i<contact.length; i++){\n newObj[keys[i]] = contact[i];\n }\n arrayOfObjects.push(newObj);\n });\n return arrayOfObjects;\n}", "title": "" }, { "docid": "5ae2ea2518e1a26ba413073fc1fbb3de", "score": "0.6095522", "text": "function csvParse(csvFile){\n var rows = csvFile.split('\\n');\n var data = [];\n var headers = rows[0].split(',');\n // loop through rows starting on second line\n for (var i = 1; i < rows.length; i++) {\n \tvar rowArray = rows[i].split(',');\n \tvar object = {};\n \t// loop through columns\n \tfor (var j = 0; j < rowArray.length; j++) {\n \t\tobject[headers[j]] = rowArray[j];\n \t};\n \tdata.push(object);\n };\n return data;\n}", "title": "" }, { "docid": "5df0e7b5153b8363608183ce7f567884", "score": "0.60860527", "text": "function csvJSON(csv){\n\n \tvar lines=csv.split(\"\\n\");\n\n \tvar result = [];\n\n \tvar headers=lines[0].replace(\"\\r\", \"\").split(\",\");\n\n \tfor(var i=1;i<lines.length;i++){\n\n\t \tvar obj = {};\n\t \tvar currentline=lines[i].replace(\"\\r\", \"\").split(\",\");\n\n\t \tfor(var j=0;j<headers.length;j++){\n\t\t \tobj[headers[j]] = currentline[j];\n\t \t}\n\n\t \tresult.push(obj);\n\n \t}\n \n \t//return result; //JavaScript object\n \treturn result; //JSON\n}", "title": "" }, { "docid": "d7c6b60706285a59ec293a60cf1cf92c", "score": "0.6076734", "text": "function csvParse(data) {\n data = data.split('\\n');\n\n var parsedData = [],\n key = data.shift().split(','),\n newEntry;\n \n data.forEach(function(row) {\n newEntry = {};\n row = row.split(',');\n \n for (var i = 0; i < key.length; i++) {\n newEntry[key[i]] = row[i];\n }\n parsedData.push(newEntry);\n });\n return parsedData;\n}", "title": "" }, { "docid": "6560a3dd2d3b029e9616586747f55e9b", "score": "0.6026641", "text": "function CSVToArray(strData, strDelimiter) {\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = strDelimiter || \",\";\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp(\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\", \"gi\");\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [[]];\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec(strData)) {\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[1];\n\n //console.log(arrMatches);\n\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (strMatchedDelimiter.length && strMatchedDelimiter != strDelimiter) {\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push([]);\n }\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n\n if (arrMatches[2]) {\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n var strMatchedValue = arrMatches[2].replace(new RegExp(\"\\\"\\\"\", \"g\"), \"\\\"\");\n } else {\n // We found a non-quoted value.\n var strMatchedValue = arrMatches[3];\n }\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[arrData.length - 1].push(strMatchedValue);\n }\n // Return the parsed data.\n return arrData;\n}", "title": "" }, { "docid": "417f9199f6baf61aa828d5f76abba7af", "score": "0.59948695", "text": "function CSVToArray( strData, strDelimiter ){\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \",\");\n\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp(\n (\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n ),\n \"gi\"\n );\n\n\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [[]];\n\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n\n\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec( strData )){\n\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[ 1 ];\n\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (\n strMatchedDelimiter.length &&\n strMatchedDelimiter !== strDelimiter\n ){\n\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push( [] );\n\n }\n\n var strMatchedValue;\n\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n if (arrMatches[ 2 ]){\n\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n strMatchedValue = arrMatches[ 2 ].replace(\n new RegExp( \"\\\"\\\"\", \"g\" ),\n \"\\\"\"\n );\n\n } else {\n\n // We found a non-quoted value.\n strMatchedValue = arrMatches[ 3 ];\n\n }\n\n\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[ arrData.length - 1 ].push( strMatchedValue );\n }\n\n // Return the parsed data.\n return( arrData );\n}", "title": "" }, { "docid": "5b49b27d8a51ed97a621b214fe40731a", "score": "0.5992633", "text": "function CSVToArray( strData, strDelimiter ){\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \",\");\n\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp(\n (\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n ),\n \"gi\"\n );\n\n\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [[]];\n\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n\n\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec( strData )){\n\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[ 1 ];\n\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (\n strMatchedDelimiter.length &&\n strMatchedDelimiter !== strDelimiter\n ){\n\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push( [] );\n\n }\n\n var strMatchedValue;\n\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n if (arrMatches[ 2 ]){\n\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n strMatchedValue = arrMatches[ 2 ].replace(\n new RegExp( \"\\\"\\\"\", \"g\" ),\n \"\\\"\"\n );\n\n } else {\n\n // We found a non-quoted value.\n strMatchedValue = arrMatches[ 3 ];\n\n }\n\n\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[ arrData.length - 1 ].push( strMatchedValue );\n }\n\n // Return the parsed data.\n return( arrData );\n}", "title": "" }, { "docid": "bbb8c6ed30b1610a4970f49b8aa18338", "score": "0.59766227", "text": "function CSVToArray(strData, strDelimiter) {\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \",\");\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp((\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"), \"gi\");\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [\n []\n ];\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec(strData)) {\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[1];\n\n //console.log(arrMatches);\n\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (strMatchedDelimiter.length && (strMatchedDelimiter != strDelimiter)) {\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push([]);\n }\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n\n if (arrMatches[2]) {\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n var strMatchedValue = arrMatches[2].replace(\n new RegExp(\"\\\"\\\"\", \"g\"), \"\\\"\");\n } else {\n // We found a non-quoted value.\n var strMatchedValue = arrMatches[3];\n }\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[arrData.length - 1].push(strMatchedValue);\n }\n // Return the parsed data.\n return (arrData);\n}", "title": "" }, { "docid": "e0b0e21f4967474577f2ebea4f7b26f8", "score": "0.5971086", "text": "function parseCSVData(file) {\n //typeof file\n file\n .text()\n .then((data) => {\n const first = data.split(\"\\n\"); //creates an array for each newline\n\n const propertyNames = first[0].split(\",\"); //gets the first index of comma seperated values as the headers/properties\n const values = first.slice(1, first.length); //the rest of the properties in the array and makes them the values\n\n let newArray = values.map((val) => {\n //mapping over the values\n const v = val.split(\",\");\n let newObj = {};\n\n for (let i = 0; i < propertyNames.length; i++) {\n const prop = propertyNames[i];\n const value = v[i];\n\n newObj[prop] = value;\n }\n\n return newObj;\n });\n\n return newArray;\n })\n .then((obj) => {\n console.log(obj);\n });\n}", "title": "" }, { "docid": "b8f31bbc59851121132c9b9c739b2a38", "score": "0.5923757", "text": "function csvToJSON(csv) {\n\n function trim(str) {\n return str.trim();\n }\n\n var result = [];\n var lines = csv.split(\"\\n\");\n var headers = lines[0].split(\",\").map(trim);\n\n for (var i = 1; i < lines.length; i++){\n\n var obj = {};\n var currentline = lines[i].split(\",\").map(trim);\n\n for (var j = 0; j < headers.length; j++){\n obj[headers[j]] = currentline[j];\n }\n result.push(obj);\n }\n\n return result; // POJO\n // return JSON.stringify(result); // JSON\n }", "title": "" }, { "docid": "d66b6da8d52438e868917b1fadeae415", "score": "0.592299", "text": "function convertCSVsToObjects(skill_data) {\n let skillData = {};\n for (const csvData in skill_data) {\n if (csvData != \"skills\") {\n skillData[csvData] = {};\n skill_data[csvData].forEach(function (tableRow) {\n skillData[csvData][tableRow.name] = tableRow.value;\n });\n } else {\n skillData[csvData] = {};\n let professionName = \"\";\n let category = \"\";\n skill_data[csvData].forEach(function (tableRow) {\n let currentSkill = Object.fromEntries(\n Object.entries(tableRow).map(([key, value]) => [\n key.toLowerCase(),\n value.match(/^-?\\d+$/) ? value * 1 : value,\n ])\n );\n\n if (currentSkill.is_hidden == \"false\") {\n if (currentSkill.is_profession == \"true\") {\n professionName = currentSkill.name;\n currentSkill.professionName = professionName;\n } else {\n currentSkill.professionName = professionName;\n }\n\n currentSkill.skills_required = currentSkill.skills_required\n .split(\",\")\n .filter((x) => x);\n\n currentSkill.commands = currentSkill.commands\n .split(\",\")\n .filter((x) => x);\n\n currentSkill.preclusion_skills = currentSkill.preclusion_skills\n .split(\",\")\n .filter((x) => x);\n\n let skillMods = {};\n currentSkill.skill_mods\n .split(\",\")\n .filter((x) => x)\n .forEach(function (skillMod) {\n let modName = skillMod.split(\"=\")[0];\n let modValue = skillMod.split(\"=\")[1];\n\n if (modName != \"\" && modValue != null) {\n skillMods[modName] = modValue * 1;\n }\n });\n\n currentSkill.skill_mods = skillMods;\n\n skillData[csvData][currentSkill.name] = currentSkill;\n }\n });\n }\n }\n\n return skillData;\n}", "title": "" }, { "docid": "31c97e38dc41cd551a8a02eb05e2036f", "score": "0.59109026", "text": "function processCSV(csvPath, shield) {\n var outputObject = {};\n var csvParse = fs.readFileSync(csvPath, 'utf8');\n var shieldIndex;\n csvParse.split(/\\r?\\n/).forEach((line,index) => {\n var splitLine = line.split(',')\n if (shieldIndex === undefined) {\n shieldIndex = splitLine.indexOf(shield);\n } else if (shieldIndex > -1 && index !== csvParse.split(/\\r?\\n/).length - 1) {\n if (splitLine[shieldIndex] !== 'N/A') {\n var color = splitLine[0];\n outputObject[color] = [];\n if (Number(splitLine[1]) > Number(splitLine[shieldIndex])) {\n outputObject[color].push(Number(splitLine[1]));\n outputObject[color].push(Number(splitLine[shieldIndex]));\n } else {\n outputObject[color].push(Number(splitLine[shieldIndex]));\n outputObject[color].push(Number(splitLine[1]));\n }\n }\n }\n })\n return outputObject;\n}", "title": "" }, { "docid": "0fcbbfcf19af318b6c62586a31d5329c", "score": "0.5891876", "text": "function getCsvFromJson(data, header) {\n\t\t\tvar rows;\n\t\t\tvar n = header.length;\n\t\t\tvar result = Array();\n\t\t\tfor (var i = 0; i < n; i++) {\n\t\t\t\tresult.push(header[i]);\n\t\t\t}\n\t\t\t$.each(data, function(index, value) {\n\t\t\t\tname = header[0];\n\t\t\t\tif (name == 'date') {\n\t\t\t\t\tresult.push('\\n' + formatDateToCsv(value.date));\n\t\t\t\t} else {\n\t\t\t\t\tresult.push('\\n' + parseResult(value[name]));\n\t\t\t\t}\n\t\t\t\tfor (var i = 1; i < n; i++) {\n\t\t\t\t\tname = header[i];\n\t\t\t\t\tresult.push(parseResult(value[name]));\n\t\t\t\t}\n\n\t\t\t})\n\t\t\treturn result;\n\t\t}", "title": "" }, { "docid": "f9ff58d5cd44954f15fed4b5f1fcb417", "score": "0.58898544", "text": "function CSVToArray(strData, strDelimiter) {\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \",\");\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp((\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"), \"gi\");\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [[]];\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec(strData)) {\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[1];\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (strMatchedDelimiter.length && (strMatchedDelimiter != strDelimiter)) {\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push([]);\n }\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n if (arrMatches[2]) {\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n var strMatchedValue = arrMatches[2].replace(\n new RegExp(\"\\\"\\\"\", \"g\"), \"\\\"\");\n } else {\n // We found a non-quoted value.\n var strMatchedValue = arrMatches[3];\n }\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[arrData.length - 1].push(strMatchedValue);\n }\n // Return the parsed data.\n return (arrData);\n}", "title": "" }, { "docid": "f5e5d3767dc144a20c486d2f3c0e0400", "score": "0.5880099", "text": "function csvToArray( strData, strDelimiter ){\r\n strDelimiter = (strDelimiter || \",\");\r\n var objPattern = new RegExp(\r\n (\r\n // Delimiters.\r\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\r\n // Quoted fields.\r\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\r\n // Standard fields.\r\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\r\n ),\r\n \"gi\"\r\n );\r\n var arrData = [[]];\r\n var arrMatches = null;\r\n while (arrMatches = objPattern.exec( strData )){\r\n // Get the delimiter that was found.\r\n var strMatchedDelimiter = arrMatches[ 1 ];\r\n // Check to see if the given delimiter has a length\r\n // (is not the start of string) and if it matches\r\n // field delimiter. If id does not, then we know\r\n // that this delimiter is a row delimiter.\r\n if (\r\n strMatchedDelimiter.length &&\r\n strMatchedDelimiter !== strDelimiter\r\n ){\r\n // Since we have reached a new row of data,\r\n // add an empty row to our data array.\r\n arrData.push( [] );\r\n }\r\n var strMatchedValue;\r\n // Now that we have our delimiter out of the way,\r\n // let's check to see which kind of value we\r\n // captured (quoted or unquoted).\r\n if (arrMatches[ 2 ]){\r\n // We found a quoted value. When we capture\r\n // this value, unescape any double quotes.\r\n strMatchedValue = arrMatches[ 2 ].replace(\r\n new RegExp( \"\\\"\\\"\", \"g\" ),\r\n \"\\\"\"\r\n );\r\n\r\n } else {\r\n // We found a non-quoted value.\r\n strMatchedValue = arrMatches[ 3 ];\r\n }\r\n // Now that we have our value string, let's add\r\n // it to the data array.\r\n arrData[ arrData.length - 1 ].push( strMatchedValue );\r\n }\r\n var headers = arrData[0];\r\n var output = [];\r\n for (var i=1,l=arrData.length;i<l;i++) {\r\n var row = {};\r\n for (var j=0,m=headers.length;j<m;j++) {\r\n row[headers[j]] = arrData[i][j];\r\n }\r\n output.push(row)\r\n }\r\n // Return the parsed data.\r\n return( output );\r\n}", "title": "" }, { "docid": "eaa219c15c9845813c7fe3bbbeee0886", "score": "0.58524", "text": "function CSVToArray( strData, strDelimiter )\n{\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \";\");\n\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp(\n (\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n ),\n \"gi\"\n );\n\n\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [[]];\n\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n\n\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec( strData )){\n\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[ 1 ];\n\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (\n strMatchedDelimiter.length &&\n strMatchedDelimiter !== strDelimiter\n ){\n\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push( [] );\n\n }\n\n var strMatchedValue;\n\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n if (arrMatches[ 2 ]){\n\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n strMatchedValue = arrMatches[ 2 ].replace(\n new RegExp( \"\\\"\\\"\", \"g\" ),\n \"\\\"\"\n );\n\n } else {\n\n // We found a non-quoted value.\n strMatchedValue = arrMatches[ 3 ];\n\n }\n\n\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[ arrData.length - 1 ].push( strMatchedValue );\n }\n\n // Return the parsed data.\n return( arrData );\n}", "title": "" }, { "docid": "f165305e1fe4beb57dd989d393898328", "score": "0.58156866", "text": "function CSVtoJSONRowArray(d,c,rn){\n\t//will output the item in a row as a number, string or null value (null is a string \"null\")\n\t//think of better name\n\tfunction doDa(i){\n\t\tre_TimeStamp=/(\\d{4})(\\.|-|\\/)(\\d{2})(\\.|-|\\/)(\\d{2})( |D|d|t)?/;\n\n\t\tif(isNum(i))return i;\n\t\telse if(i==null||i.replace(/\\s+/g,\"\")==\"\")return \"null\";\n\t\telse if(re_TimeStamp.test(i)){\n\t\t\tvar a=new Date(i.toString().replace(re_TimeStamp,\"$1-$3-$5T\"));\n\t\t\ta=a.getTime()-(a.getTimezoneOffset()*60000);\n\t\t\treturn a;\n\t\t}\n\t\telse return \"\\\"\"+i+\"\\\"\";\n\t}\n\ttry{\n\t\tvar csvSplit=d.split('\\n'),numberRows=csvSplit.length,output=\"\";\n\t\t$.each(csvSplit,function(indexRows,row){\n\t\t\t\tvar row=row.split(','),numberRowItems=row.length,tempOutput=\"\";\n\t\t\t\t/*\n\t\t\t\tc && rn = first row is names and return the names\n\t\t\t\tc && !rn = first row is names and do not return them\n\t\t\t\t!c && rn || !c && !rn = first row is not names\n\t\t\t\t*/\n\t\t\t\tif(c&&rn){ //c&&rn\n\t\t\t\t\t$.each(row,function(indexRowItem,item){\n\t\t\t\t\t\tif(indexRows==0)tempOutput+=\"\\\"\"+item+\"\\\"\";\n\t\t\t\t\t\telse tempOutput+=doDa(item);\n\t\t\t\t\t\tif(indexRowItem<numberRowItems-1)tempOutput+=\",\";\n\t\t\t\t\t});\n\t\t\t\t\toutput+=\"[\"+tempOutput+\"]\";\n\t\t\t\t\tif(indexRows<numberRows-1)output+=\",\";\n\t\t\t\t}\n\t\t\t\telse if((c&&!rn&&indexRows>0)||(!c)){ //c&&!rn - !c&&rn\n\t\t\t\t\ttempOutput+=\"[\";\n\t\t\t\t\t$.each(row,function(indexRowItem,item){\n\t\t\t\t\t\ttempOutput+=doDa(item);\n\t\t\t\t\t\tif(indexRowItem<numberRowItems-1)tempOutput+=\",\";\n\t\t\t\t\t});\n\t\t\t\t\ttempOutput+=\"]\";\n\t\t\t\t\tif(indexRows<numberRows-1)tempOutput+=\",\";\n\t\t\t\t\toutput+=tempOutput;\n\t\t\t\t}\n\t\t});\n\t\tif((numberRows==1)||(!rn&&numberRows<=2))return output;\n\t\telse return \"[\"+output+\"]\";\n\t}\n\tcatch(err){em(16,[err]);}\n}", "title": "" }, { "docid": "491efd70847adb2f0fc0fc5ded198cab", "score": "0.5806314", "text": "function ParseCSV(csv){\n let splitted = csv.split(\"\\n\")\n // console.log(splitted)\n let header = splitted[0].split(\",\")\n console.log(header)\n let charaname = \"\"\n let skillid =\"\"\n let talentname = \"\"\n let collectionJson = {}\n let currenttalentnum =0\n let currenttalentgroup = 0\n for(i=1;i<splitted.length;i++){\n // console.log(splitted[i])\n let currentSplit = splitted[i].split(\",\")\n if(currentSplit[0]!=\"\"){\n charaname = currentSplit[0]\n talentname= currentSplit[3]\n \n if(!collectionJson[charaname]){\n var currunread= unread.find(search2=>charaname.includes(search2.name))\n var namesearch = \"\"\n if(currunread){\n console.log(\"found\")\n namesearch = ` (${currunread.name_en})`\n }\n console.log(charaname)\n \n charaname = charalist.find(search=>{\n \n if(search.name+namesearch==charaname){\n console.log(search.id)\n return search.id\n }\n \n // else if(charaname.includes(search.name))\n // return search.id\n }).id\n currenttalentnum=0\n currenttalentgroup=0\n }\n \n // console.log(charadetail)\n \n \n collectionJson[charaname]=[]\n collectionJson[charaname].push([])\n // collectionJson[skillid].name=currentSplit[3]\n // collectionJson[skillid].desc=[]\n }\n if(charadetail[charaname].talents[currenttalentgroup]){\n \n if(!charadetail[charaname].talents[currenttalentgroup].candidates[currenttalentnum]){\n currenttalentgroup+=1\n currenttalentnum=0\n collectionJson[charaname].push([])\n }\n currenttalentnum+=1\n }\n let currjson = {}\n // console.log(currenttalentgroup)\n // console.log(currenttalentnum)\n // console.log(collectionJson[charaname])\n // console.log(splitted[i])\n let regex = /(,\")(.*)(\",)/\n let check = regex.exec(splitted[i])\n if(check){\n let regex2 = /(.*)(,)(.*)(,\")/\n let check2 = regex2.exec(splitted[i])\n collectionJson[charaname][(currenttalentgroup)].push({name:check2[3],desc:check[2]}) \n }else{\n collectionJson[charaname][(currenttalentgroup)].push({name:currentSplit[2],desc:currentSplit[3]}) \n }\n \n \n \n }\n console.log(collectionJson)\n return collectionJson\n // console.log(collectionJson)\n}", "title": "" }, { "docid": "a461dfb69e9b414cbab6fe31df77862c", "score": "0.58039904", "text": "function CSVtoJSON(lines, headers) {\n //loop through entries (proceeding the headers)\n let emails = [];\n let json = {};\n let j = 0;\n lines.filter(line => line.length > 1)\n .slice(1) //remove the headers\n .forEach(line => {\n\n if (line[0] !== \"\") {\n //loop through columns\n json = {};\n for (j = 0; j < headers.length; j++) {\n json[headers[j]] = line[j];\n }\n\n //add to array\n emails.push(json);\n }\n\n });\n\n return emails;\n}", "title": "" }, { "docid": "f7648d6c8365f89af7948281f602e39e", "score": "0.5795332", "text": "function parse(csv) {\n const options = {\n header: true,\n transformHeader: transformHeader\n };\n var parsed = papa.parse(csv, options);\n return parsed;\n}", "title": "" }, { "docid": "d67e3b242aff8458831615ceff35f28a", "score": "0.57896364", "text": "toJSON(input) {\n if (input === '') {\n return { data: [] };\n }\n\n const lines = input.split(config.lineSeparator);\n\n let fields;\n let metadata,\n min = 0,\n max = 0;\n\n if (this.fields === null) {\n fields = lines\n .shift()\n .split(config.delimiter)\n .map(field => field.trim());\n if (fields[fields.length - 1] === '') {\n fields.pop();\n }\n } else {\n fields = this.fields;\n }\n const result = [];\n\n if (Array.isArray(lines) && lines.length > 0) {\n // remove metadata lines from CSV\n for (let i = 0; i < lines.length; i++) {\n if (lines[i].includes(fields[0])) {\n // found start of stuff\n metadata = lines.splice(0, i + 1);\n break;\n }\n }\n\n for (let i = 0; i < lines.length; i++) {\n result[i] = {};\n let cols = lines[i].split(config.delimiter);\n\n for (let j = 0; j < fields.length; j++) {\n // parse int for special case only of PM\n if (fields[j] === CSVLabels.pm) {\n let pm = parseInt(cols[j]);\n result[i][fields[j]] = pm;\n\n // find highest and lowest PM readings for this sensor\n if (pm < min) {\n // min\n min = pm;\n } else if (pm > max) {\n // max\n max = pm;\n }\n } else {\n result[i][fields[j]] = cols[j];\n }\n }\n }\n }\n\n return {\n meta: {\n min,\n max,\n sensorOutputHeader: metadata\n },\n data: result\n };\n }", "title": "" }, { "docid": "5eab830d9f9bf4fbd2221b0811aa3b14", "score": "0.57758474", "text": "function parseCSV() {\n // TODO: iterate on new categories\n for (header_option in csv_object.header_options) {\n // console.log(header_option);\n // console.log(csv_object.header_options[header_option]);\n header_options_by_cat[header_option] = csv_object.header_options[header_option]\n document.getElementById(`col_filter_select`).innerHTML += header_options_by_cat[header_option]\n document.getElementById(`data_col_select0`).innerHTML += header_options_by_cat[header_option]\n }\n // header_options_by_cat[99] = csv_object.header_options[0];\n external_data_array = csv_object.data_object\n external_data_headers = csv_object.header_object\n const key_col = csv_object.match_col\n var start_col = csv_object.start_col\n const new_categories_options = csv_object.external_cat_options[0]\n // var new_categories = csv_object.new_categories[0];\n var start_col = csv_object.start_col\n // console.log(\"Matched by \" + key_col);\n // console.log(\"start by \" + start_col);\n // console.log(external_data_headers);\n // Add the data to the displayed featureGroup.\n addExtrnalData(geojsonLayer, external_data_array, external_data_headers, key_col, start_col)\n // console.log(\"after new table\");\n // Change the category selector options.\n // TODO: Move the functionality.\n categories_select_all_options += new_categories_options\n if (document.getElementById(`cat_sel`)) {\n const cat_id = document.getElementById(`cat_sel`).value\n document.getElementById(`cat_sel`).innerHTML = categories_select_all_options\n document.getElementById(`cat_sel`).value = cat_id\n // console.log('change cat');\n }\n // Add the new column to the select columns array.\n }", "title": "" }, { "docid": "520c8fbdcc66ce95d9b0ea4cb1cfaf59", "score": "0.5772531", "text": "function csv2object(rows) {\n\tvar i = 0;\n\trows.forEach(function(row) {\n\t\t\t// if a target (exemplar) is not member of targets array, update data for source and target, update targets array\n\t\t\tif (targets.indexOf(row.target) == -1 ) {\n\t\t\t\t// add new source (document) in data\n\t\t\t\tdata[i] = new Object();\n\t\t\t\tdata[i].radius = sourceSize;\n\t\t\t\tdata[i].color = colorHsl(row.clusterId); //color(row.clusterId);\n\t\t\t\tdata[i].name = row.source;\n\t\t\t\tdata[i].APlevel = row.APlevel;\n\t\t\t\tdata[i].filename = row.sourcefilename;\n\t\t\t\tdata[i].clustersize = row.clustersize;\n\t\t\t\tdata[i].topwords = row.sourceTopWords;\n\t\t\t\t//data[i].targetTopWords = row.targetTopWords;\n\t\t\t\t// add new target (exemplar) in data\n\t\t\t\tdata[i+1] = new Object();\n\t\t\t\tdata[i+1].radius = targetSize;\n\t\t\t\tdata[i+1].color = colorHsl(row.clusterId); //color(row.clusterId);\n\t\t\t\tdata[i+1].name = row.target;\n\t\t\t\tdata[i+1].APlevel = row.APlevel;\n\t\t\t\tdata[i+1].filename = row.targetfilename;\n\t\t\t\tdata[i+1].clustersize = row.clustersize;\n\t\t\t\t//data[i+1].sourceTopWords = row.sourceTopWords;\n\t\t\t\tdata[i+1].topwords = row.targetTopWords;\n\t\t\t\t// keep track of targets (dont add it again)\n\t\t\t\ttargets.push(row.target);\n\t\t\t\ti = i+2;\n\t\t\t} \n\t\t\t// otherwise, add new source in data\n\t\t\telse {\n\t\t\t\tdata[i] = new Object();\n\t\t\t\tdata[i].radius = sourceSize;\n\t\t\t\tdata[i].color = colorHsl(row.clusterId); //color(row.clusterId);\n\t\t\t\tdata[i].name = row.source;\n\t\t\t\tdata[i].APlevel = row.APlevel;\n\t\t\t\tdata[i].filename = row.sourcefilename;\n\t\t\t\tdata[i].clustersize = row.clustersize;\n\t\t\t\tdata[i].topwords = row.sourceTopWords;\n\t\t\t\ti = i+1;\n\t\t\t} // end for if else\n\t} // end forEach\n\t) // end forEach\n\tconsole.log(\"Data length after reading the file: \" + data.length);\n\tconsole.log(\"Data objects: \");\n\tconsole.log(data);\n}", "title": "" }, { "docid": "4170ca8679ed38081bcc7716974b2364", "score": "0.5770763", "text": "function rec2json(row){\n var o = {};\n for (var i=0; i < header.length; i++){\n var name = header[i];\n var value = row[i];\n if (name === 'RecordType' && value != 'LineItem'){\n return null;\n }\n\n if (name === 'RecordId'){\n o['_id'] = value; \n continue;\n }\n if (name === 'LinkedAccountId' && value != ''){\n o[name] = value; \n continue;\n }\n if (name === 'UsageType' && value != ''){\n o[name] = value; \n continue;\n }\n if (name === 'ResourceId' && value != ''){\n o[name] = value; \n continue;\n }\n if (name === 'ProductName' && value != ''){\n o[name] = value; \n continue;\n }\n if (name === 'AvailabilityZone' && value != ''){\n o[name] = value; \n continue;\n }\n if (name === 'UnBlendedCost'){\n o['cost'] = parseFloat(value); \n continue;\n }\n if (name === 'UsageStartDate'){\n o['time'] = new Date(value + 'Z'); // UTC\n try{\n var prefix = o['time'].toISOString().split(\"-\")[0];\n prefix += o['time'].toISOString().split(\"-\")[1];\n o['_id'] = prefix + o['_id'];\n }catch(err){\n console.log(err);\n }\n continue;\n }\n // For AWS resource Tagging\n if (name.match(/^user:/) && value != '' ){\n o[name] = value; \n continue;\n }\n //o[name] = row[i]; \n }\n\n csvCount++;\n if (!o['cost'] || o['cost'] === 0){\n //console.log(row)\n zeroCount++;\n return null;\n }\n if (!o['_id'] || o['_id'] === ''){\n return null;\n }\n \n\n //console.log(o);\n return o;\n}", "title": "" }, { "docid": "ab8c9031a79adb2aa0162fb4fccd43aa", "score": "0.5770438", "text": "function CSVToArray( strData, strDelimiter ) {\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \",\");\n\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp(\n (\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n ),\n \"gi\"\n );\n\n\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [[]];\n\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n\n\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec(strData)) {\n\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[1];\n\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (\n strMatchedDelimiter.length &&\n strMatchedDelimiter !== strDelimiter\n ) {\n\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push([]);\n\n }\n\n var strMatchedValue;\n\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n if (arrMatches[2]) {\n\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n strMatchedValue = arrMatches[2].replace(\n new RegExp(\"\\\"\\\"\", \"g\"),\n \"\\\"\"\n );\n\n } else {\n\n // We found a non-quoted value.\n strMatchedValue = arrMatches[3];\n\n }\n\n\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[arrData.length - 1].push(strMatchedValue);\n }\n\n // Return the parsed data.\n return (arrData);\n}", "title": "" }, { "docid": "d9b3048e8ce5587fb67bfabcdd33005d", "score": "0.5750253", "text": "function CsvParser() {\n}", "title": "" }, { "docid": "ee96dd0e49b781f47939a8db9f6d8d42", "score": "0.5742695", "text": "function csvJSON(csv, type){\n var lines = csv.split('\\n')\n var feature = lines[0].split(',')\n feature[feature.length - 1] = feature[feature.length - 1].replace('\\r','') // remove '/r'\n var my_map = []\n \n //create the key on the map\n for(var t =0; t<feature.length; t++){\n my_map[feature[t]] = []\n }\n //create the map key and valu\n for(var i = 1; i<lines.length-1; i++){\n var row = lines[i].split(',')\n row[row.length - 1] = row[row.length - 1].replace('\\r','') // remove '/r'\n for(var j=0; j<feature.length; j++){\n my_map[feature[j]].push(row[j]) \n }\n }\n // create json file\n var my_json = {}\n for(var k =0; k<feature.length; k++){\n my_json[feature[k]] = my_map[feature[k]]\n }\n let json = JSON.stringify(my_json); //JSON\n if (type == 'train'){\n fs.writeFileSync('train.json', json);\n }\n if (type == 'test'){\n fs.writeFileSync('test.json', json);\n\n }\n return json\n}", "title": "" }, { "docid": "c8a4eac3273194b593d0e2b37c9267e0", "score": "0.5731583", "text": "getOrderedValuesForCSV(typeOfReport) {\n\t\tlet weightedValues = _.map(this.state.selectedAds, typeOfReport)\n\t\tconsole.log(weightedValues)\n\t\tconst weighted = {}\n\t\tfor (let kpi in weightedValues[0]) {\n\t\t\tlet kpisVal = {}\n\t\t\tkpisVal['kpi'] = kpi\n\t\t\tweightedValues = _.pickBy(weightedValues, _.identity)\n\t\t\tfor (let v in weightedValues) {\n\t\t\t\tkpisVal[weightedValues[v]['adID']] = weightedValues[v][kpi]\n\t\t\t}\n\t\t\tweighted[kpi] = kpisVal\n\t\t}\n\n\t\t// Returns an ordered array§ of results\n\t\tlet result = []\n\t\tresult.push(weighted.total)\n\t\tresult.push(weighted.brandRelevance)\n\t\tresult.push(weighted.brandRecall)\n\t\tresult.push(weighted.relevance)\n\t\tresult.push(weighted.brandFit)\n\t\tresult.push(weighted.viewerEngagement)\n\t\tresult.push(weighted.adAppeal)\n\t\tresult.push(weighted.shareability)\n\t\tresult.push(weighted.callToAction)\n\t\tresult.push(weighted.adMessage)\n\t\tresult.push(weighted.toneOfVoice)\n\t\tresult.push(weighted.emotion)\n\t\tresult.push(weighted.uniqueness)\n\t\tresult.push(weighted.messaging)\n\n\t\treturn result\n\t}", "title": "" }, { "docid": "47e06a59af502208ca82c0b27f959e0c", "score": "0.5722684", "text": "function csvAdv(constructResult){\n if (constructResult !== false){\n\tconstructResult=true;\n }\n var instance= csv.apply(this);\n\n this.parseRules=[];\n this.resultObject={csvRows:[]};\n this.headRow=[];\n var that=this;\n instance.on(\"record\",function(row,index){\n\tif (index ==0){\n\t that._headRowProcess(row);\n\t}else{\n\t var resultRow={};\n\t that._rowProcess(row,index,resultRow);\n\t if (constructResult){\n\t\tthat.resultObject.csvRows.push(resultRow);\n\t }\n\t instance.emit(\"record_parsed\",resultRow,row,index);\n\t}\n });\n\n instance.on(\"end\",function(){\n\tinstance.emit(\"end_parsed\",that.resultObject);\n });\n\n return instance;\n}", "title": "" }, { "docid": "fdd3400425aca785ee6270b6139e8b8e", "score": "0.57207304", "text": "function transformCSVtoJSON_2() {\n let filePath = '../data/data.csv';\n let filePathToWrite = filePath.replace('csv', 'json');\n\n const readStream = fs.createReadStream(filePath);\n const writeStream = fs.createWriteStream(filePathToWrite);\n\n let CSVtoJSON = function(chunk){\n let lines=chunk.toString().split(\"\\n\");\n let result = [];\n let headers=lines[0].split(\",\");\n\n for(let i=1; i<lines.length; i++) {\n let obj = {};\n let currentline=lines[i].split(\",\");\n for(let j=0;j<headers.length;j++) {\n obj[headers[j]] = currentline[j];\n }\n result.push(obj);\n }\n \n return JSON.stringify(result);\n }\n\n let toUp = function(chunk, enc, callback) {\n this.push(CSVtoJSON(chunk));\n callback();\n }\n\n readStream.pipe(through(toUp)).pipe(writeStream);\n}", "title": "" }, { "docid": "a3c0623d1c901183902b847f8e4b35cc", "score": "0.5717152", "text": "function csvJSON(csv) {\n const l = csv.split(\"\\n\"),\n h = l[0].split(\",\"),\n r = [];\n for (let i = 1; i < l.length; i++) {\n let o = {},\n c = l[i].split(\",\");\n for (let j = 0; j < h.length; j++) {\n o[h[j]] = c[j];\n }\n r.push(o);\n }\n return r.slice(0, -1);\n}", "title": "" }, { "docid": "738edf8261ee6a16ebc972c27adf9c46", "score": "0.5707242", "text": "function OverviewCSVtoJSON(lines) {\n\n let json = {};\n let subJson = {};\n let arrVal = [];\n let j = 0;\n\n //loop through entries\n for (let i = 0; i < lines.length; i++) {\n\n //remove colons that are at the end of the string\n for(let k = 0; k < lines[i].length; k++) {\n if (lines[i][k][lines[i][k].length - 1] === \":\") {\n lines[i][k] = lines[i][k].substring(0, lines[i][k].length - 1);\n }\n }\n\n //check if line is just a header\n //determined by: either it only has one column, OR the second column is empty (and the first column is not empty)\n if ((lines[i].length === 1 && lines[i][0].length > 2) || (lines[i][0].length > 1 && lines[i][1] === \"\")) {\n\n subJson = {};\n\n for (j = i + 1; j < lines.length; j++) {\n if (lines[j][0].length < 3){\n break;\n }\n //subJson[j - (i + 1)] = lines[j];\n subJson[lines[j][0]] = Array(lines[j].length - 1).fill(\"\").map(\n (value, index) => lines[j][index + 1]\n );\n lines[j] = \"\";\n }\n\n json[lines[i]] = subJson;\n i = j - 1;\n }\n\n //otherwise, proceed to make json entry as normal\n else if (lines[i].length > 1) {\n json[lines[i][0]] = lines[i][1];\n\n }\n }\n\n return json;\n}", "title": "" }, { "docid": "e88ed5c0964fc6799fb1b2e6c4719747", "score": "0.5692288", "text": "function csvJSON(csv){\n\n var lines=csv.split(\"\\n\");\n\n result = [];\n\n user_database={};\n\n var headers=lines[0].split(\",\");\n\n for(var i=1;i<lines.length;i++){\n\n var obj = {};\n\n var currentline=lines[i].split(\",\");\n\n for(var j=0;j<headers.length;j++){\n\n obj[headers[j]] = currentline[j];\n\n if(j===0){\n var cust_id = currentline[j];\n }\n }\n result.push(obj);\n user_database[cust_id] = obj;\n }\n //return result; //JavaScript object\n return JSON.stringify(result); //JSON\n }", "title": "" }, { "docid": "bac23f95bc972128daeede9f9c1cffef", "score": "0.5685121", "text": "_CSVtoArray(text) {\n var re_valid = /^\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*(?:,\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*)*$/;\n var re_value = /(?!\\s*$)\\s*(?:'([^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*)'|\"([^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*)\"|([^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*))\\s*(?:,|$)/g;\n // Return NULL if input string is not well formed CSV string.\n if (!re_valid.test(text)) return null;\n var a = []; // Initialize array to receive values.\n text.replace(re_value, // \"Walk\" the string using replace with callback.\n function(m0, m1, m2, m3) {\n // Remove backslash from \\' in single quoted values.\n if (m1 !== undefined) a.push(m1.replace(/\\\\'/g, \"'\"));\n // Remove backslash from \\\" in double quoted values.\n else if (m2 !== undefined) a.push(m2.replace(/\\\\\"/g, '\"'));\n else if (m3 !== undefined) a.push(m3);\n return ''; // Return empty string.\n });\n // Handle special case of empty last value.\n if (/,\\s*$/.test(text)) a.push('');\n return a;\n }", "title": "" }, { "docid": "60340feae40a2bb96078de4836b6e499", "score": "0.5673118", "text": "function readCSV(row) {\n const ret = Object.assign({}, row);\n ret.links = ret.links.split(\" \");\n return ret;\n }", "title": "" }, { "docid": "72ba659136fb396d77789630243d725e", "score": "0.5657327", "text": "function sort(input) {\n let msgContent = null;\n let msgType = null; // step 1.\n // ===========================\n // depends what was passed in,\n\n if (typeof input !== \"string\") {\n throw new TypeError(`csv-sort/csvSort(): [THROW_ID_01] The input is of a wrong type! We accept either string of array of arrays. We got instead: ${typeof input}, equal to:\\n${JSON.stringify(input, null, 4)}`);\n } else if (!input.trim()) {\n return {\n res: [[\"\"]],\n msgContent,\n msgType\n };\n }\n\n let content = splitEasy(input); // step 2.\n // ===========================\n // - iterate from the bottom\n // - calculate schema as you go to save calculation rounds\n // - first row can have different amount of columns\n // - think about 2D trim feature\n\n let schema = [];\n let stateHeaderRowPresent = false;\n let stateDataColumnRowLengthIsConsistent = true;\n const stateColumnsContainingSameValueEverywhere = []; // used for 2D trimming:\n\n let indexAtWhichEmptyCellsStart = null;\n\n for (let i = content.length - 1; i >= 0; i--) {\n\n if (!schema.length) {\n // prevention against last blank row:\n\n /* istanbul ignore next */\n if (content[i].length !== 1 || content[i][0] !== \"\") {\n for (let y = 0, len = content[i].length; y < len; y++) {\n schema.push(findType(content[i][y].trim()));\n\n if (indexAtWhichEmptyCellsStart === null && findType(content[i][y].trim()) === \"empty\") {\n indexAtWhichEmptyCellsStart = y;\n }\n\n if (indexAtWhichEmptyCellsStart !== null && findType(content[i][y].trim()) !== \"empty\") {\n indexAtWhichEmptyCellsStart = null;\n }\n }\n }\n } else {\n if (i === 0) {\n // Check is this header row.\n // Header rows should consist of only text content.\n // Let's iterate through all elements and find out.\n stateHeaderRowPresent = content[i].every(el => findType(el) === \"text\" || findType(el) === \"empty\"); // if schema was calculated (this means there's header row and at least one content row),\n // find out if the column length in the header differs from schema's\n // if (stateHeaderRowPresent && (schema.length !== content[i].length)) {\n // }\n }\n /* istanbul ignore else */\n\n\n if (!stateHeaderRowPresent && schema.length !== content[i].length) {\n stateDataColumnRowLengthIsConsistent = false;\n }\n\n let perRowIndexAtWhichEmptyCellsStart = null;\n\n for (let y = 0, len = content[i].length; y < len; y++) {\n // trim\n\n /* istanbul ignore else */\n if (perRowIndexAtWhichEmptyCellsStart === null && findType(content[i][y].trim()) === \"empty\") {\n perRowIndexAtWhichEmptyCellsStart = y;\n }\n /* istanbul ignore else */\n\n\n if (perRowIndexAtWhichEmptyCellsStart !== null && findType(content[i][y].trim()) !== \"empty\") {\n perRowIndexAtWhichEmptyCellsStart = null;\n } // checking schema\n\n /* istanbul ignore else */\n\n\n if (findType(content[i][y].trim()) !== schema[y] && !stateHeaderRowPresent) {\n const toAdd = findType(content[i][y].trim());\n /* istanbul ignore else */\n\n if (Array.isArray(schema[y])) {\n if (!schema[y].includes(toAdd)) {\n schema[y].push(findType(content[i][y].trim()));\n }\n } else if (schema[y] !== toAdd) {\n const temp = schema[y];\n schema[y] = [];\n schema[y].push(temp);\n schema[y].push(toAdd);\n }\n }\n } // when row has finished, get the perRowIndexAtWhichEmptyCellsStart\n // that's to cover cases where last row got schema calculated, but it\n // had more empty columns than the following rows:\n //\n // [8, 9, 0, 1, , ]\n // [4, 5, 6, 7, , ] <<< perRowIndexAtWhichEmptyCellsStart would be 3 (indexes start at zero)\n // [1, 2, 3, , , ] <<< indexAtWhichEmptyCellsStart would be here 2 (indexes start at zero)\n //\n // as a result, indexAtWhichEmptyCellsStart above would be assigned to 3, not 2\n //\n // That's still an achievement, we \"trimmed\" CSV by two places.\n // I'm saying \"trimmed\", but we're not really trimming yet, we're only\n // setting inner variable which we will later use to limit the traversal,\n // so algorithm skips those empty columns.\n //\n\n /* istanbul ignore next */\n\n\n if (indexAtWhichEmptyCellsStart !== null && perRowIndexAtWhichEmptyCellsStart !== null && perRowIndexAtWhichEmptyCellsStart > indexAtWhichEmptyCellsStart && (!stateHeaderRowPresent || stateHeaderRowPresent && i !== 0)) {\n indexAtWhichEmptyCellsStart = perRowIndexAtWhichEmptyCellsStart;\n }\n }\n }\n /* istanbul ignore else */\n\n\n if (!indexAtWhichEmptyCellsStart) {\n indexAtWhichEmptyCellsStart = schema.length;\n } // find out at which index non-empty columns start. This is effectively left-side trimming.\n\n\n let nonEmptyColsStartAt = 0;\n\n for (let i = 0, len = schema.length; i < len; i++) {\n if (schema[i] === \"empty\") {\n nonEmptyColsStartAt = i;\n } else {\n break;\n }\n } // if there are empty column in front, trim (via slice) both content and schema\n\n /* istanbul ignore else */\n\n\n if (nonEmptyColsStartAt !== 0) {\n content = content.map(arr => arr.slice(nonEmptyColsStartAt + 1, indexAtWhichEmptyCellsStart));\n schema = schema.slice(nonEmptyColsStartAt + 1, indexAtWhichEmptyCellsStart);\n } // step 3.\n // ===========================\n // CHALLENGE: without any assumptions, identify \"current balance\" and \"debit\",\n // \"credit\" columns by analysing their values.\n //\n // - double entry accounting rows will have the \"current balance\" which will\n // be strictly numeric, and will be present across all rows. These are the\n // two first signs of a \"current balance\" column.\n // - \"current balance\" should also match up with at least one field under it,\n // if subracted/added the value from one field in its row\n // swoop in traversing the schema array to get \"numeric\" columns:\n // ----------------\n\n\n const numericSchemaColumns = [];\n let balanceColumnIndex;\n schema.forEach((colType, i) => {\n if (colType === \"numeric\") {\n numericSchemaColumns.push(i);\n }\n });\n const traverseUpToThisIndexAtTheTop = stateHeaderRowPresent ? 1 : 0;\n\n if (numericSchemaColumns.length === 1) {\n // Bob's your uncle, the only numeric column is your Balance column\n balanceColumnIndex = numericSchemaColumns[0];\n } else if (numericSchemaColumns.length === 0) {\n throw new Error('csv-sort/csvSort(): [THROW_ID_03] Your CSV file does not contain numeric-only columns and computer was not able to detect the \"Balance\" column!');\n } else {\n // So (numericSchemaColumns > 0) and we'll have to do some work.\n // Fine.\n //\n // Clone numericSchemaColumns array, remove columns that have the same value\n // among consecutive rows.\n // For example, accounting CSV's will have \"Account number\" repeated.\n // Balance is never the same on two rows, otherwise what's the point of\n // accounting if nothing happened?\n // Traverse the CSV vertically on each column from numericSchemaColumns and\n // find out `balanceColumnIndex`:\n // ----------------\n let potentialBalanceColumnIndexesList = Array.from(numericSchemaColumns); // iterate through `potentialBalanceColumnIndexesList`\n\n const deleteFromPotentialBalanceColumnIndexesList = [];\n\n for (let i = 0, len = potentialBalanceColumnIndexesList.length; i < len; i++) {\n // if any two rows are in sequence currently and they are equal, this column is out\n const suspectedBalanceColumnsIndexNumber = potentialBalanceColumnIndexesList[i]; // we traverse column suspected to be \"Balance\" with index `index` vertically,\n // from the top to bottom. Depending if there's heading row, we start at 0 or 1,\n // which is set by `traverseUpToThisIndexAtTheTop`.\n // We will look for two rows having the same value. If it's found that column is\n // not \"Balance\":\n // EASY ATTEMPT TO RULE-OUT NOT-BALANCE COLUMNS\n\n let previousValue; // to check if two consecutive are the same\n\n let lookForTwoEqualAndConsecutive = true;\n let firstValue; // to check if all are the same\n\n let lookForAllTheSame = true;\n\n for (let rowNum = traverseUpToThisIndexAtTheTop, len2 = content.length; rowNum < len2; rowNum++) {\n // 1. check for two consecutive equal values\n\n /* istanbul ignore else */\n if (lookForTwoEqualAndConsecutive) {\n // deliberate == to catch undefined and null\n if (previousValue == null) {\n previousValue = content[rowNum][suspectedBalanceColumnsIndexNumber];\n } else if (previousValue === content[rowNum][suspectedBalanceColumnsIndexNumber]) {\n // potentialBalanceColumnIndexesList.splice(suspectedBalanceColumnsIndexNumber, 1)\n // don't mutate the `potentialBalanceColumnIndexesList`, do it later.\n // Let's compile TO-DELETE list instead:\n deleteFromPotentialBalanceColumnIndexesList.push(suspectedBalanceColumnsIndexNumber);\n lookForTwoEqualAndConsecutive = false;\n } else {\n previousValue = content[rowNum][suspectedBalanceColumnsIndexNumber];\n }\n } // 2. also, tell if ALL values are the same:\n\n /* istanbul ignore else */\n\n\n if (lookForAllTheSame) {\n // deliberate == to catch undefined and null\n if (firstValue == null) {\n firstValue = content[rowNum][suspectedBalanceColumnsIndexNumber];\n } else if (content[rowNum][suspectedBalanceColumnsIndexNumber] !== firstValue) {\n lookForAllTheSame = false;\n }\n }\n\n if (!lookForTwoEqualAndConsecutive) {\n break;\n }\n }\n /* istanbul ignore else */\n\n\n if (lookForAllTheSame) {\n stateColumnsContainingSameValueEverywhere.push(suspectedBalanceColumnsIndexNumber);\n }\n } // now mutate the `potentialBalanceColumnIndexesList` using\n // `deleteFromPotentialBalanceColumnIndexesList`:\n\n\n potentialBalanceColumnIndexesList = pull(potentialBalanceColumnIndexesList, ...deleteFromPotentialBalanceColumnIndexesList);\n /* istanbul ignore else */\n\n if (potentialBalanceColumnIndexesList.length === 1) {\n balanceColumnIndex = potentialBalanceColumnIndexesList[0];\n } else if (potentialBalanceColumnIndexesList.length === 0) {\n throw new Error('csv-sort/csvSort(): [THROW_ID_04] The computer can\\'t find the \"Balance\" column! It saw some numeric-only columns, but they all seem to have certain rows with the same values as rows right below/above them!');\n } else ; // at this point 99% of normal-size, real-life bank account CSV's should have\n // \"Balance\" column identified because there will be both \"Credit\" and \"Debit\"\n // transaction rows which will be not exclusively numeric, but [\"empty\", \"numeric\"] type.\n // Even Lloyds Business banking CSV's that output account numbers\n // will have \"Balance\" column identified this stage.\n\n }\n\n if (!balanceColumnIndex) {\n throw new Error(\"csv-sort/csvSort(): [THROW_ID_05] Sadly computer couldn't find its way in this CSV and had to stop working on it.\");\n } // step 4.\n // ===========================\n // query the schema and find out potential Credit/Debit columns\n // take schema, filter all indexes that are equal to or are arrays and have\n // \"numeric\" among their values, then remove the index of \"Balance\" column:\n\n\n const potentialCreditDebitColumns = pull(Array.from(schema.reduce((result, el, index) => {\n if (typeof el === \"string\" && el === \"numeric\" || Array.isArray(el) && el.includes(\"numeric\")) {\n result.push(index);\n }\n\n return result;\n }, [])), balanceColumnIndex, ...stateColumnsContainingSameValueEverywhere); // step 5.\n // ===========================\n\n const resContent = []; // Now that we know the `balanceColumnIndex`, traverse the CSV rows again,\n // assembling a new array\n // step 5.1. Put the last row into the new array.\n // ---------------------------------------------------------------------------\n // Worst case scenario, if it doesn't match with anything, we'll throw in the end.\n // For now, let's assume CSV is correct, only rows are mixed.\n\n resContent.push(content[content.length - 1].slice(0, indexAtWhichEmptyCellsStart));\n const usedUpRows = [];\n const bottom = stateHeaderRowPresent ? 1 : 0;\n\n for (let y = content.length - 2; y >= bottom; y--) {\n // for each row above the last-one (which is already in place), we'll traverse\n // all the rows above to find the match.\n // go through all the rows and pick the right row which matches to the above:\n\n for (let suspectedRowsIndex = content.length - 2; suspectedRowsIndex >= bottom; suspectedRowsIndex--) {\n\n if (!usedUpRows.includes(suspectedRowsIndex)) {\n // go through each of the suspected Credit/Debit columns:\n let thisRowIsDone = false;\n\n for (let suspectedColIndex = 0, len = potentialCreditDebitColumns.length; suspectedColIndex < len; suspectedColIndex++) {\n let diffVal = null;\n\n if (content[suspectedRowsIndex][potentialCreditDebitColumns[suspectedColIndex]] !== \"\") {\n diffVal = currency(content[suspectedRowsIndex][potentialCreditDebitColumns[suspectedColIndex]]);\n }\n\n let totalVal = null;\n /* istanbul ignore else */\n\n if (content[suspectedRowsIndex][balanceColumnIndex] !== \"\") {\n totalVal = currency(content[suspectedRowsIndex][balanceColumnIndex]);\n }\n\n let topmostResContentBalance = null;\n /* istanbul ignore else */\n\n if (resContent[0][balanceColumnIndex] !== \"\") {\n topmostResContentBalance = currency(resContent[0][balanceColumnIndex]).format();\n }\n\n let currentRowsDiffVal = null;\n /* istanbul ignore else */\n\n if (resContent[resContent.length - 1][potentialCreditDebitColumns[suspectedColIndex]] !== \"\") {\n currentRowsDiffVal = currency(resContent[resContent.length - 1][potentialCreditDebitColumns[suspectedColIndex]]).format();\n }\n\n let lastResContentRowsBalance = null;\n /* istanbul ignore else */\n\n if (resContent[resContent.length - 1][balanceColumnIndex] !== \"\") {\n lastResContentRowsBalance = currency(resContent[resContent.length - 1][balanceColumnIndex]);\n }\n /* istanbul ignore else */\n\n if (diffVal && totalVal.add(diffVal).format() === topmostResContentBalance) { // ADD THIS ROW ABOVE EVERYTHING\n // add this row above the current HEAD in resContent lines array (index `0`)\n\n resContent.unshift(content[suspectedRowsIndex].slice(0, indexAtWhichEmptyCellsStart));\n usedUpRows.push(suspectedRowsIndex);\n thisRowIsDone = true;\n break;\n } else if (diffVal && totalVal.subtract(diffVal).format() === topmostResContentBalance) {\n // ADD THIS ROW ABOVE EVERYTHING\n resContent.unshift(content[suspectedRowsIndex].slice(0, indexAtWhichEmptyCellsStart));\n usedUpRows.push(suspectedRowsIndex);\n thisRowIsDone = true;\n break;\n } else if (currentRowsDiffVal && lastResContentRowsBalance.add(currentRowsDiffVal).format() === totalVal.format()) {\n // ADD THIS ROW BELOW EVERYTHING\n resContent.push(content[suspectedRowsIndex].slice(0, indexAtWhichEmptyCellsStart));\n usedUpRows.push(suspectedRowsIndex);\n thisRowIsDone = true;\n break;\n } else if (currentRowsDiffVal && lastResContentRowsBalance.subtract(currentRowsDiffVal).format() === totalVal.format()) {\n // ADD THIS ROW BELOW EVERYTHING\n resContent.push(content[suspectedRowsIndex].slice(0, indexAtWhichEmptyCellsStart));\n usedUpRows.push(suspectedRowsIndex);\n thisRowIsDone = true;\n break;\n }\n }\n /* istanbul ignore else */\n\n\n if (thisRowIsDone) {\n thisRowIsDone = false;\n break;\n }\n }\n }\n } // restore title row if present\n\n /* istanbul ignore else */\n\n\n if (stateHeaderRowPresent) {\n // trim header row of trailing empty columns if they protrude outside of the (consistent row length) schema\n if (stateDataColumnRowLengthIsConsistent && content[0].length > schema.length) {\n content[0].length = schema.length;\n } // push header row on top of the results array:\n\n\n resContent.unshift(content[0].slice(0, indexAtWhichEmptyCellsStart));\n }\n /* istanbul ignore else */\n\n\n if (content.length - (stateHeaderRowPresent ? 2 : 1) !== usedUpRows.length) {\n msgContent = \"Not all rows were recognised!\";\n msgType = \"alert\";\n }\n\n return {\n res: resContent,\n msgContent,\n msgType\n };\n}", "title": "" }, { "docid": "3587b729ed3570e028a994df0cec6d12", "score": "0.56566626", "text": "function transformCSVtoJSON() {\n let filePath = '../data/data.csv';\n let filePathToWrite = '../data/data2.csv';\n\n const readStream = fs.createReadStream(filePath);\n\n let CSVtoJSON = function(chunk){\n let lines=chunk.toString().split(\"\\n\");\n let result = [];\n let headers=lines[0].split(\",\");\n\n for(let i=1; i<lines.length; i++) {\n let obj = {};\n let currentline=lines[i].split(\",\");\n for(let j=0;j<headers.length;j++) {\n obj[headers[j]] = currentline[j];\n }\n result.push(obj);\n }\n \n return JSON.stringify(result);\n }\n\n let toUp = function(chunk, enc, callback) {\n this.push(CSVtoJSON(chunk));\n callback();\n }\n\n readStream.pipe(through(toUp)).pipe(process.stdout);\n}", "title": "" }, { "docid": "244ca78fca1788c21c402884658e4af1", "score": "0.56433034", "text": "function convertCSVData(popEmpDataset) {\n let TAZTitle = 'TAZ1669';\n let tmpData = {};\n for(let k in popEmpDataset){\n let result = {};\n for(let title in popEmpDataset[k]){\n if(title!== TAZTitle){\n result[title] = popEmpDataset[k][title]\n }\n }\n tmpData[popEmpDataset[k][TAZTitle]] = result;\n }\n return tmpData\n}", "title": "" }, { "docid": "244ca78fca1788c21c402884658e4af1", "score": "0.56433034", "text": "function convertCSVData(popEmpDataset) {\n let TAZTitle = 'TAZ1669';\n let tmpData = {};\n for(let k in popEmpDataset){\n let result = {};\n for(let title in popEmpDataset[k]){\n if(title!== TAZTitle){\n result[title] = popEmpDataset[k][title]\n }\n }\n tmpData[popEmpDataset[k][TAZTitle]] = result;\n }\n return tmpData\n}", "title": "" }, { "docid": "a6880ac11feed1ab7b813ee830a51d46", "score": "0.56324005", "text": "function csvJSON(csv){\n var lines= csv.split(\"\\n\");\n var result = [];\n var headers=lines[0].split(\";\");\n \n for(var i=1;i<lines.length;i++){\n var obj = {};\n var currentline=lines[i].split(\";\");\n for(var j=0;j<headers.length;j++){\n obj[headers[j]] = currentline[j];\n }\n result.push(obj);\n }\n const stringify = JSON.stringify(result)\n const data = JSON.parse(stringify);\n let loc = [];\n\n $.each(data, function(k,v){\n loc.push(`${v.street}, ${v.city} SE1 0JF, ${v.country}`);\n });\n locations(loc);\n }", "title": "" }, { "docid": "85226100c55d6fdddcf7798c54ae9fa0", "score": "0.5609326", "text": "function csv(options, callback){\n var path = options.path;\n fs.readFile(path, 'utf8', function(err,d){\n data = d;\n data = data.toString().replace(/\\r/g,\"\").split(\"\\n\");\n var header = data[0].split(\",\");\n data = data.slice(1).map(function(d){\n var line = {};\n d.split(\",\").forEach(function(d,i){\n line[header[i]] = d;\n });\n return line;\n }); \n exports.data = data;\n callback();\n });\n}", "title": "" }, { "docid": "4c839a7d0e345b2d57e1cf7d7d9cbea6", "score": "0.55894357", "text": "transformRecord(csvRow) {\n if (!csvRow) {\n throw Error('transformRecord - required csvRow must be non-null.');\n }\n\n const order = { ...super.transformRecord(csvRow) };\n\n order['_sourceRefStringId'] = csvRow['authnumber'] || '';\n\n order['recordType'] = 'Order';\n order['dateIssued'] = csvRow['issuedate'] || null;\n\n order['issuingAgency'] = 'Ministry of Environment and Climate Change Strategy';\n order['author'] = 'Ministry of Environment and Climate Change Strategy';\n\n order['recordName'] = (csvRow['authnumber'] && `AMS Authorization # ${csvRow['authnumber']}`) || '-';\n\n const region = csvRow['region'];\n if (region && region.startsWith('Authorizations - ')) {\n order['location'] = region.substring(17);\n } else {\n order['location'] = 'British Columbia';\n }\n\n if (csvRow['longitude'] && csvRow['latitude']) {\n order['centroid'] = [Number(csvRow['longitude']), Number(csvRow['latitude'])];\n } else {\n order['centroid'] = null;\n }\n\n order['issuedTo'] = {\n type: MiscConstants.IssuedToEntityTypes.Company,\n companyName: csvRow['clientname'] || ''\n };\n\n const wasteType = csvRow['wastetype'];\n if (wasteType) {\n order['summary'] = `Authorization Number: ${csvRow['authnumber']}; Waste Type: ${wasteType}`;\n } else {\n order['summary'] = `Authorization Number: ${csvRow['authnumber']}`;\n }\n\n const authorizationType = csvRow['authorizationtype'];\n const legislation = {\n act: 'Environmental Management Act'\n };\n if (authorizationType === 'Information') {\n legislation['section'] = 77;\n legislation['legislationDescription'] = 'Information Order';\n } else if (authorizationType === 'Pollution Prevention') {\n legislation['section'] = 81;\n legislation['legislationDescription'] = 'Pollution Prevention Order';\n } else if (authorizationType === 'Pollution Abatement') {\n legislation['section'] = 83;\n legislation['legislationDescription'] = 'Pollution Abatement Order';\n }\n\n order['legislation'] = [legislation];\n\n return order;\n }", "title": "" }, { "docid": "b324d53c49df71e50b3f2868fa30e818", "score": "0.5586917", "text": "function array2csv(doc, separator, arr, includeHeaders, priorityKeys, unpriorityKeys)\n{\n\tif(typeof includeHeaders == 'undefined') includeHeaders = true;\n\n\tfunction getKeys(arr)\n\t{\n\t\tvar keysAll = [];\n\n\t\t/* gather all the keys for the objects in the array (or maybe just the first 10 objects or so) */\n\t\tfor(var arrIndex = 0; arrIndex < 10 && arrIndex < arr.length; arrIndex++)\n\t\t{\n\t\t\tvar keys = Object.keys(arr[arrIndex]);\n\n\t\t\tkeysAll = keysAll.concat(keys);\n\t\t}\n\n\t\treturn keysAll;\n\t}\n\n\tvar keys = getKeys(arr);\n\n\tif(priorityKeys && priorityKeys.length > 0)\n\t\tkeys = priorityKeys.concat(keys);\n\t\n\tkeys = unique(keys);\t//XXX unique is too slow for a concatenation of all the keys\n\t\n\tif(unpriorityKeys && unpriorityKeys.length > 0)\n\t{\n\t\tkeys = keys.concat(unpriorityKeys);\n\t\tkeys.reverse();\n\t\tkeys = unique(keys);\n\t\tkeys.reverse();\n\t}\n\t\n\t//XXX move keyPrev to be right after key?\n\t\n\tif(includeHeaders)\n\t\tdoc.write(keys.join(separator) + \"\\n\");\n\n\tfor(var arrIndex = 0; arrIndex < arr.length; arrIndex++)\n\t{\n\t\tvar obj = arr[arrIndex];\n\n\t\tvar row = [];\n\n\t\tfor(var keyIndex = 0; keyIndex < keys.length; keyIndex++)\n\t\t{\n\t\t\tvar key = keys[keyIndex];\n\n\t\t\tvar value = obj[key];\n\n\t\t\tif(value == null)\n\t\t\t\tvalue = \"\";\t// null or undefined becomes blank\n\t\t\telse\n\t\t\t{\n\t\t\t\tvalue = '' + value;\t//stringify\n\n//\t\t\t\tvalue = value.replace(/([,\\\\])/g, \"\\\\$1\");\t// escape commas, backslashes, etc XXX UNNECESSARY?\n\t\t\t\tvalue = value.replace(/[\"]/g, '\"\"');\t// escape double quotes as double-double quote for OpenOffice Calc, etc.\n\n\t\t\t\tif(value.match(/ /))\n\t\t\t\t\tvalue = '\"' + value + '\"';\t//need quotes if contains embedded spaces?\n\t\t\t}\n\n\t\t\trow.push(value);\n\t\t}\n\n\t\tdoc.write(row.join(separator) + \"\\n\");\n\t}\n}", "title": "" }, { "docid": "2ac0f556032c8800de2e4e84bc9b4417", "score": "0.55864424", "text": "function object2CSV(input) {\n\t\n\tvar headers = [];\n\tvar output = [headers];\n\t\n\t// Get full list of headers first\n\t\n\tfor( x in input) {\n\t\tfor (y in input[x]) {\n\t\t\tif (headers.indexOf(y) == -1) {\n\t\t\t\theaders.push(y);\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Populate data in headers\n\n\tfor( x in input) {\n\t\n\tvar current = [];\n\t\t\n\t\tfor( y in input[x]) {\n\t\t\n\t\t\t//fill in data\n\t\t\tif (input[x][y] == \"null\" || input[x][y] == null ){\n\t\t\t\tcurrent[headers.indexOf(y)] = \"\\\"\\\"\";\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrent[headers.indexOf(y)] = \"\\\"\" + input[x][y] + \"\\\"\"; \n\t\t\t}\n\t\t}\n\t\t\n\t\toutput.push(current + \"<br>\");\n\t}\n\t\n\tvar tdisp = \"\";\n\t\n\tfor (var i = 0; i < output.length; i++) {\n\t\tif (i == 0) {\n\t\t\ttdisp = tdisp + output[0] + \"<br>\";\n\t\t}\n\t\telse {\n\t\t\ttdisp = tdisp + output[i];\n\t\t}\n\t}\n\treturn tdisp;\n}", "title": "" }, { "docid": "25f589ce52a747e63738527c1e772633", "score": "0.5568057", "text": "function CSVToArray(strData, strDelimiter) {\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \",\");\n\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp(\n (\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n ),\n \"gi\"\n );\n\n\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [[]];\n\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n\n\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec(strData)) {\n\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[1];\n\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (\n strMatchedDelimiter.length &&\n strMatchedDelimiter !== strDelimiter\n ) {\n\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push([]);\n\n }\n\n var strMatchedValue;\n\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n if (arrMatches[2]) {\n\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n strMatchedValue = arrMatches[2].replace(\n new RegExp(\"\\\"\\\"\", \"g\"),\n \"\\\"\"\n );\n\n } else {\n\n // We found a non-quoted value.\n strMatchedValue = arrMatches[3];\n\n }\n\n\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[arrData.length - 1].push(strMatchedValue);\n }\n\n // Return the parsed data.\n return (arrData);\n}", "title": "" }, { "docid": "58749e0dffcb9a3f04a013e376b5c874", "score": "0.55598366", "text": "function processCSVLine(line) {\n\tvar lineArr = line.split('\"');\n\tvar entry;\n\n\t// quotation marks are not present\n\tif (lineArr.length === 1) {\n\t\tlineArr = line.split(',');\n\t\tentry = {\n\t\t\ttimestamp: lineArr[0],\n\t\t\taddress: lineArr[1],\n\t\t\tzipcode: lineArr[2],\n\t\t\tfullName: lineArr[3],\n\t\t\tfooDuration: lineArr[4],\n\t\t\tbarDuration: lineArr[5],\n\t\t\ttotalDuration: lineArr[6],\n\t\t\tnotes: lineArr[7]\n\t\t}\n\t\treturn entry;\n\t}\n\n\t/* \n\t\tusing the max length of timestamp to determine whether data \n\t\twith quotation marks is in address column or notes\n\t*/\n\tif (lineArr[0].length <= 21) {\n\t\tvar partLineArr = lineArr[2].split(',');\n\t\tentry = {\n\t\t\ttimestamp: lineArr[0].slice(0, -1), // remove ending comma\n\t\t\taddress: lineArr[1],\n\t\t\tzipcode: partLineArr[1],\n\t\t\tfullName: partLineArr[2],\n\t\t\tfooDuration: partLineArr[3],\n\t\t\tbarDuration: partLineArr[4],\n\t\t\ttotalDuration: partLineArr[5],\n\t\t\tnotes: partLineArr[6]\n\t\t}\n\t\treturn entry;\n\t}\n\n\tvar partLineArr = lineArr[0].split(',');\n\tentry = {\n\t\ttimestamp: partLineArr[0],\n\t\taddress: partLineArr[1],\n\t\tzipcode: partLineArr[2],\n\t\tfullName: partLineArr[3],\n\t\tfooDuration: partLineArr[4],\n\t\tbarDuration: partLineArr[5],\n\t\ttotalDuration: partLineArr[6],\n\t\tnotes: lineArr[1]\n\t}\n\n\treturn entry;\n}", "title": "" }, { "docid": "ecb37677806d13d6040a71179ef9a4a6", "score": "0.5548504", "text": "function csvParse(file) {\n\t var arrayFile = file.split(\"\\n\") //arrayFile = [\"first,last,lastContact,email\", \"Scott,Dallas,0,[email protected]\", \"Tom,Sharon,1,[email protected]\", \"\"]\n\t arrayFile.splice(3, 1); // removes the last element, which was an empty string, from arrayFile. Can't prevent csvFile from including an empty line as the last row. So must slice it out here. \n\t for(var i = 0; i < arrayFile.length; i++) {\n\t \tarrayFile[i] = arrayFile[i].split(\",\") //arrayFile = [ [\"first\",\"last\",\"lastContact\",\"email\"], [\"Scott\",\"Dallas\",\"0\",\"[email protected]\"], [\"Tom\",\"Sharon\",\"1\",\"[email protected]\"] ]\n\t } \n\tvar titles = arrayFile.shift(); //titles = [\"first\",\"last\",\"lastContact\",\"email\"] &&& arrayFile = [ [\"Scott\",\"Dallas\",\"0\",\"[email protected]\"], [\"Tom\",\"Sharon\",\"1\",\"[email protected]\"] ]\n\tvar convertedFile = arrayFile.map(function(arrayFileElement) {\n\t\tvar newObj = {}; // create a newObj for every arrayFileElement\n\t\ttitles.forEach(function(title, index){\n\t\t\tnewObj[title] = arrayFileElement[index];\n\t\t})\n\t\treturn newObj; // return newObj into convertedFile.\n\t})\n\treturn convertedFile;\n}", "title": "" }, { "docid": "6d7ea4891295a3a49da6c4cc987bbbef", "score": "0.55419594", "text": "parseObjectToCSV(JSONObject) {\n let outputHeaders = [...Object.keys(JSONObject[0])];\n let Output = [];\n\n for (let rowIndex = 0; rowIndex < JSONObject.length; rowIndex++) {\n let rowData = [];\n for (\n let keyIndex = 0;\n keyIndex < Object.keys(JSONObject[rowIndex]).length;\n keyIndex++\n ) {\n rowData.push(\n JSONObject[rowIndex][Object.keys(JSONObject[rowIndex])[keyIndex]]\n );\n }\n Output = [...Output, rowData.join(\",\") + \"\\r\\n\"];\n }\n Output = [outputHeaders.join(\",\") + \"\\r\\n\", ...Output];\n\n return Output;\n }", "title": "" }, { "docid": "58353a51367864ebfa38a213b700cb36", "score": "0.5527849", "text": "function getHeaderInfo(csvfile) {\n // field values to scan, with name mapping for JSON keys\n let fieldmap = {\n 'Report Date': 'startTime',\n 'Experiment': 'experiment',\n 'Tube': 'tube',\n 'Sort Layout': 'barcode',\n 'Sort Elapsed Time(hh:mm:ss)': 'elapsedTime'\n };\n\n let prfname = csvfile.replace(/^.*\\//,\"\");\n let headerInfo = {\"csvFile\":prfname};\n let facscsv = fs.readFileSync(csvfile, 'utf8');\n let qread = false; // becomes true when in quadrant section\n let qval = 'Undefined';\n\n facscsv.split(/\\r?\\n/).forEach(function(fline){\n let flarr = fline.split(',');\n\n if (flarr[0] in fieldmap && flarr[1] !== undefined) {\n let prkey = fieldmap[flarr[0]];\n let prval = flarr[1];\n if (prkey == \"startTime\") { // make formatted timestamp\n let uldt = prval.replace(/\\./g,\"-\");\n uldt = uldt.replace(\" at \",\"T\");\n pacdt = moment.tz(uldt,\"America/Los_Angeles\");\n prval = pacdt.format('x');\n } else if (prkey == \"elapsedTime\") { // convert to Epoch milliseconds\n let eltime = prval.split(':')\n let elms = (Number(eltime[0])*3600 +\n Number(eltime[1])*60 + Number(eltime[2]))*1000;\n prval = elms;\n }\n headerInfo[prkey] = prval;\n } else if (flarr[0].startsWith(\"Sort Layout\")) {\n qread = true\n } else if (qread) { // test if Quadrant info is consistent\n let qmatches = fline.match(/(Q\\d)/g);\n if (qmatches != undefined) {\n qmatches.forEach(function(qmatch) {\n if (qval == 'Undefined') {\n qval = qmatch;\n } else if (qval != qmatch) {\n console.log(\"Warning: Quadrant inconsistency\")\n }\n })\n }\n }\n });\n headerInfo['quadrant'] = qval;\n return headerInfo;\n}", "title": "" }, { "docid": "0767b81ec7cdb18d971658161d94e303", "score": "0.5522828", "text": "function papaparse(csv){\r\n\t\r\n\tPapa.parse(csv, {\r\n\t\t //header: true,\r\n\t\t dynamicTyping: true,\r\n\t\t complete: function(results) {\r\n\t\t\t compRedData = results.data;\r\n\t\t }\r\n\t\t});\r\n\t\r\n\t\r\n}", "title": "" }, { "docid": "bdaf282d8ed8ddf8fc1439e6f2112be3", "score": "0.5498399", "text": "function csvStringToArray(strData) {\n const objPattern = new RegExp((\"(\\\\,|\\\\r?\\\\n|\\\\r|^)(?:\\\"((?:\\\\\\\\.|\\\"\\\"|[^\\\\\\\\\\\"])*)\\\"|([^\\\\,\\\"\\\\r\\\\n]*))\"), \"gi\");\n\n let arrMatches = null, arrData = [[]];\n while (arrMatches = objPattern.exec(strData)) {\n if (arrMatches[1].length && arrMatches[1] !== \",\") arrData.push([]);\n arrData[arrData.length - 1].push(arrMatches[2] ?\n arrMatches[2].replace(new RegExp(\"[\\\\\\\\\\\"](.)\", \"g\"), '$1') :\n arrMatches[3]);\n }\n\n headerData = arrData.shift();\n hashData = arrData.map(row => {\n let i = 0;\n return headerData.reduce(\n (acc, key) => {\n acc[key] = row[i++];\n return acc;\n },\n {}\n );\n });\n return hashData;\n}", "title": "" }, { "docid": "af0dcc5a8b22d2493c0cc514aab77372", "score": "0.5493743", "text": "function parseCsv() {\n// get file name from DOM\n var file = $('#csv_input')[0].files[0];\n// Setup config for Papa.parse\n var config = {\n delimiter: \"\", // auto-detect\n newline: \"\", // auto-detect\n quoteChar: '\"',\n header: true,\n dynamicTyping: true,\n preview: 0,\n encoding: \"\",\n worker: false,\n comments: false,\n step: undefined,\n complete : processJSON,\n error : errorHandler,\n download: false,\n skipEmptyLines: false,\n chunk: undefined,\n fastMode: undefined,\n beforeFirstChunk: undefined,\n withCredentials: undefined\n };\n Papa.parse(file, config);\n}", "title": "" }, { "docid": "9991098e6b4fd2fba37297008eddb82c", "score": "0.54738975", "text": "function csvToJson(str, callback){\r\n let csvData = []\r\n\r\n let newRow = str.split(\"\\n\");\r\n for (let row of newRow){\r\n let arrayOfRow = []\r\n let allowedChar = row.replace(/, /g, \"£@@@\")\r\n let devideToObject = allowedChar.split(',');\r\n for(let objectString of devideToObject){\r\n arrayOfRow.push(objectString.replace(/£@@@/g, \", \"))\r\n }\r\n csvData.push(arrayOfRow)\r\n }\r\n \r\n /**\r\n * assign string to object key\r\n */\r\n \r\n let objKeys = csvData.shift();\r\n \r\n let csvJson = []\r\n \r\n csvData.forEach((countryData) => {\r\n let countryDataObject = {}\r\n objKeys.forEach((key, index) =>{\r\n countryData.forEach((string, indexString) => {\r\n if(index === indexString){\r\n countryDataObject[key] = string\r\n }\r\n })\r\n })\r\n csvJson.push(countryDataObject)\r\n })\r\n callback(csvJson)\r\n}", "title": "" }, { "docid": "e99a84aebfe5f0b7cc3a5a66ccc482d5", "score": "0.54712325", "text": "function parseCSV (input, separator = ',', quote = '\"') {\n let parsedCSV = [];\n let line = [];\n\n let buffer = '';\n let openedQuotes = false;\n\n function clearLine () {\n clearBuffer();\n parsedCSV.push(line);\n line = [];\n }\n\n function clearBuffer () {\n line.push(buffer);\n buffer = '';\n openedQuotes = false;\n }\n\n // check type methods for clearer code\n const isNewline = (symbol) => symbol === '\\n' && !openedQuotes;\n const isSeperator = (symbol) => symbol === separator && !openedQuotes;\n const isQuote = (symbol) => symbol === quote;\n const isDoubleQuoute = (symbol, nextSymbol, nextNextSymobl) => symbol === quote && nextSymbol === quote && !isSeperator(nextNextSymobl);\n\n for(let i = 0, l = input.length; i < l; i++) {\n const symbol = input[i];\n \n if (isNewline(symbol)) {\n clearLine();\n continue;\n }\n\n if (isSeperator(symbol)) {\n clearBuffer();\n continue;\n }\n\n if (isDoubleQuoute(symbol, input[i + 1], input[i + 2])) {\n buffer += `${quote}`;\n i++;\n continue;\n }\n\n if (isQuote(symbol)) {\n openedQuotes = !openedQuotes; \n continue;\n }\n\n buffer += symbol;\n }\n\n // handle the last element in row as it doesn't have a seperator\n clearLine();\n\n return parsedCSV;\n}", "title": "" }, { "docid": "fb24d19470850b6851b5289895f44bf7", "score": "0.54692423", "text": "parseCsv(filename)\r\n {\r\n var _this=this;var datatype=new Array();var colname= new Array();var tempArray=new Array();\r\n csv.fromPath('./Temp/' + filename).on(\"data\", function(data){\r\n len=data.length;\r\n\r\n for(var i=0;i<len;i++)\r\n {\r\n tempArray.push(data[i]);\r\n }\r\n })\r\n .on(\"end\", function(){\r\n for(var i=0;i<len;i++)\r\n {\r\n colname.push(tempArray[i]);\r\n }\r\n for(var i=len;i<2*len;i++)\r\n {\r\n if(tempArray[i].charAt(2)=='/' || tempArray[i].charAt(1)=='/')\r\n {\r\n datatype.push('date');\r\n }\r\n else if(isNaN(tempArray[i]))\r\n {\r\n datatype.push('VARCHAR(100)');\r\n }\r\n else {\r\n datatype.push('INT(100)');\r\n }\r\n }\r\n\r\n _this.createSchema(filename,colname,datatype,tempArray);\r\n\r\n });\r\n }", "title": "" }, { "docid": "13564e9502bbe1c31b3b80c578a6b409", "score": "0.5467351", "text": "buildObjFormat (rows) {\n return rows.map((row, index) => {\n if (index === 0) return row\n const obj = {}\n rows[0].forEach((headCol, indexHead) => {\n obj[headCol.toLowerCase()] = row[indexHead]\n })\n return obj\n })\n }", "title": "" }, { "docid": "79f9fdd572073997175e1f9f0b2dc9b4", "score": "0.54000676", "text": "function CSVToArray( strData, strDelimiter ){\n\t// Check to see if the delimiter is defined. If not,\n\t// then default to comma.\n\tstrDelimiter = (strDelimiter || \",\");\n\n\t// Create a regular expression to parse the CSV values.\n\tvar objPattern = new RegExp(\n\t\t(\n\t\t\t// Delimiters.\n\t\t\t\"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\n\t\t\t// Quoted fields.\n\t\t\t\"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\n\t\t\t// Standard fields.\n\t\t\t\"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n\t\t),\n\t\t\"gi\"\n\t\t);\n\n\n\t// Create an array to hold our data. Give the array\n\t// a default empty first row.\n\tvar arrData = [[]];\n\n\t// Create an array to hold our individual pattern\n\t// matching groups.\n\tvar arrMatches = null;\n\n\n\t// Keep looping over the regular expression matches\n\t// until we can no longer find a match.\n\twhile (arrMatches = objPattern.exec( strData )){\n\n\t\t// Get the delimiter that was found.\n\t\tvar strMatchedDelimiter = arrMatches[ 1 ];\n\n\t\t// Check to see if the given delimiter has a length\n\t\t// (is not the start of string) and if it matches\n\t\t// field delimiter. If id does not, then we know\n\t\t// that this delimiter is a row delimiter.\n\t\tif (\n\t\t\tstrMatchedDelimiter.length &&\n\t\t\t(strMatchedDelimiter != strDelimiter)\n\t\t\t){\n\n\t\t\t// Since we have reached a new row of data,\n\t\t\t// add an empty row to our data array.\n\t\t\tarrData.push( [] );\n\n\t\t}\n\n\n\t\t// Now that we have our delimiter out of the way,\n\t\t// let's check to see which kind of value we\n\t\t// captured (quoted or unquoted).\n\t\tif (arrMatches[ 2 ]){\n\n\t\t\t// We found a quoted value. When we capture\n\t\t\t// this value, unescape any double quotes.\n\t\t\tvar strMatchedValue = arrMatches[ 2 ].replace(\n\t\t\t\tnew RegExp( \"\\\"\\\"\", \"g\" ),\n\t\t\t\t\"\\\"\"\n\t\t\t\t);\n\n\t\t} else {\n\n\t\t\t// We found a non-quoted value.\n\t\t\tvar strMatchedValue = arrMatches[ 3 ];\n\n\t\t}\n\n\n\t\t// Now that we have our value string, let's add\n\t\t// it to the data array.\n\t\tarrData[ arrData.length - 1 ].push( strMatchedValue );\n\t}\n\n\t// Return the parsed data.\n\treturn( arrData );\n}", "title": "" }, { "docid": "c2e1e935410eecc78e7f02f9752b6277", "score": "0.5379176", "text": "function csv2json(csv) {\n var data = [];\n var sequences = [];\n\n // sort the dataframe ascending by sequence (d[0]) then by stage (d[1])\n csv.sort(function(a, b) {\n if (a[2] === b[2]) {\n return d3.ascending(a[0], b[0]);\n }\n return d3.ascending(a[1], b[1]);\n });\n csv.forEach(function(record) {\n var sequence = record[0];\n if (sequences.indexOf(sequence) < 0) sequences.push(sequence);\n });\n\n sequences.forEach(function(sequence) {\n var d = {\n nodes: [],\n size: 0\n };\n csv.forEach(function(record) {\n var node = record[2];\n var size = record[3];\n if (sequence === record[0]) {\n d.nodes.push(node);\n d.size = size;\n }\n });\n data.push(d);\n });\n return data;\n }", "title": "" }, { "docid": "6afd02d6760d89fc277e9a72c0964ab1", "score": "0.53749937", "text": "function convertArrayOfObjectsToCSV(args) { \n var result, ctr, keys, columnDelimiter, lineDelimiter, data;\n\n data = args.data || null;\n if (data == null || !data.length) {\n return null;\n }\n\n columnDelimiter = args.columnDelimiter || ',';\n lineDelimiter = args.lineDelimiter || '\\n';\n\n keys = Object.keys(data[0]);\n\n result = '';\n result += keys.join(columnDelimiter);\n result += lineDelimiter;\n\n data.forEach(function(item) {\n ctr = 0;\n keys.forEach(function(key) {\n if (ctr > 0) result += columnDelimiter;\n\n result += item[key];\n ctr++;\n });\n result += lineDelimiter;\n });\n\n return result;\n}", "title": "" }, { "docid": "84145e879b81d5c6d4438699166feacc", "score": "0.5374597", "text": "function CSVToArray( strData, strDelimiter ){\n\t// Check to see if the delimiter is defined. If not,\n\t// then default to comma.\n\tstrDelimiter = (strDelimiter || \",\");\n\n\t// Create a regular expression to parse the CSV values.\n\tvar objPattern = new RegExp(\n\t\t(\n\t\t\t// Delimiters.\n\t\t\t\"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\n\t\t\t// Quoted fields.\n\t\t\t\"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\n\t\t\t// Standard fields.\n\t\t\t\"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n\t\t),\n\t\t\"gi\"\n\t);\n\n\n\t// Create an array to hold our data. Give the array\n\t// a default empty first row.\n\tvar arrData = [[]];\n\n\t// Create an array to hold our individual pattern\n\t// matching groups.\n\tvar arrMatches = null;\n\n\n\t// Keep looping over the regular expression matches\n\t// until we can no longer find a match.\n\twhile (arrMatches = objPattern.exec( strData )){\n\n\t\t// Get the delimiter that was found.\n\t\tvar strMatchedDelimiter = arrMatches[ 1 ];\n\n\t\t// Check to see if the given delimiter has a length\n\t\t// (is not the start of string) and if it matches\n\t\t// field delimiter. If id does not, then we know\n\t\t// that this delimiter is a row delimiter.\n\t\tif (\n\t\t\tstrMatchedDelimiter.length &&\n\t\t\tstrMatchedDelimiter !== strDelimiter\n\t\t){\n\n\t\t\t// Since we have reached a new row of data,\n\t\t\t// add an empty row to our data array.\n\t\t\tarrData.push( [] );\n\n\t\t}\n\n\t\tvar strMatchedValue;\n\n\t\t// Now that we have our delimiter out of the way,\n\t\t// let's check to see which kind of value we\n\t\t// captured (quoted or unquoted).\n\t\tif (arrMatches[ 2 ]){\n\n\t\t\t// We found a quoted value. When we capture\n\t\t\t// this value, unescape any double quotes.\n\t\t\tstrMatchedValue = arrMatches[ 2 ].replace(\n\t\t\t\tnew RegExp( \"\\\"\\\"\", \"g\" ),\n\t\t\t\t\"\\\"\"\n\t\t\t);\n\n\t\t} else {\n\n\t\t\t// We found a non-quoted value.\n\t\t\tstrMatchedValue = arrMatches[ 3 ];\n\n\t\t}\n\n\n\t\t// Now that we have our value string, let's add\n\t\t// it to the data array.\n\t\tarrData[ arrData.length - 1 ].push( strMatchedValue );\n\t}\n\n\t// Return the parsed data.\n\treturn( arrData );\n}", "title": "" }, { "docid": "9525bff84fe4c8df4c7ab1659c8fdc1a", "score": "0.5367174", "text": "function CSVtoArray (text) {\n var re_valid = /^\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*(?:,\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*)*$/;\n var re_value = /(?!\\s*$)\\s*(?:'([^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*)'|\"([^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*)\"|([^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*))\\s*(?:,|$)/g;\n // Return NULL if input string is not well formed CSV string.\n if (!re_valid.test(text)) return null;\n var a = []; // Initialize array to receive values.\n text.replace(re_value, // \"Walk\" the string using replace with callback.\n function(m0, m1, m2, m3) {\n // Remove backslash from \\' in single quoted values.\n if (m1 !== undefined) a.push(m1.replace(/\\\\'/g, \"'\"));\n // Remove backslash from \\\" in double quoted values.\n else if (m2 !== undefined) a.push(m2.replace(/\\\\\"/g, '\"'));\n else if (m3 !== undefined) a.push(m3);\n return ''; // Return empty string.\n });\n // Handle special case of empty last value.\n if (/,\\s*$/.test(text)) a.push('');\n return a;\n}", "title": "" }, { "docid": "0d875cce3ebeae4ca89ffd203e24ed36", "score": "0.5356656", "text": "function processCsv(){\n \t// Parse each page to fulfill the CSV + display the csv at the end:\n \tfor (var i = 0; i <= LAST_PAGE; i++) {\n \t\t// Get the page and parse it + display the csv once all the pages have been parsed.\n \t\tgetPageAndParseIt(i, fulfillCsvAndDisplayIt);\n \t}\n }", "title": "" }, { "docid": "51f75a97dd0e840581387bf772b96ce6", "score": "0.53558594", "text": "function CSVtoArray(text) {\n var re_valid = /^\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*(?:,\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*)*$/;\n var re_value = /(?!\\s*$)\\s*(?:'([^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*)'|\"([^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*)\"|([^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*))\\s*(?:,|$)/g;\n // Return NULL if input string is not well formed CSV string.\n if (!re_valid.test(text)) return null;\n var a = []; // Initialize array to receive values.\n text.replace(re_value, // \"Walk\" the string using replace with callback.\n function(m0, m1, m2, m3) {\n // Remove backslash from \\' in single quoted values.\n if (m1 !== undefined) a.push(m1.replace(/\\\\'/g, \"'\"));\n // Remove backslash from \\\" in double quoted values.\n else if (m2 !== undefined) a.push(m2.replace(/\\\\\"/g, '\"'));\n else if (m3 !== undefined) a.push(m3);\n return ''; // Return empty string.\n });\n return a;\n}", "title": "" }, { "docid": "62a8b47f33ed0fef488219f6c94d29f2", "score": "0.53499234", "text": "function convertOne(json, type){\n var csvLines = [[],[]]\n\n for(var key in convert_to[type]){\n var k = key.split('^')[0]\n var header = convert_to[type][key][0]\n\n if(k in json){\n var f = convert_to[type][key][1]\n var value = f(json[k])\n\n if(header == null){\n csvLines = csvLines.concat(value)\n }else if(header == \"\"){\n csvLines[0] = csvLines[0].concat(value[0])\n csvLines[1] = csvLines[1].concat(value[1])\n }else{\n csvLines[0].push(protect(header))\n csvLines[1].push(protect(value))\n }\n }else if(type == \"pca\" || type == \"df\" || k == \"fonte\"){\n csvLines[0].push(protect(header))\n csvLines[1].push(protect(\"\"))\n }\n }\n\n return csvLines\n}", "title": "" }, { "docid": "d8a377fc9f6e1da64f918c14837c6d88", "score": "0.53458756", "text": "function CSVtoArray(text) {\r\n\tvar re_valid = /^\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*(?:,\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*)*$/;\r\n\tvar re_value = /(?!\\s*$)\\s*(?:'([^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*)'|\"([^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*)\"|([^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*))\\s*(?:,|$)/g;\r\n\t// Return NULL if input string is not well formed CSV string.\r\n\tif (!re_valid.test(text)) return null;\r\n\tvar a = []; // Initialize array to receive values.\r\n\ttext.replace(re_value, // \"Walk\" the string using replace with callback.\r\n\t\tfunction(m0, m1, m2, m3) {\r\n\t\t\t// Remove backslash from \\' in single quoted values.\r\n\t\t\tif (m1 !== undefined) a.push(m1.replace(/\\\\'/g, \"'\"));\r\n\t\t\t// Remove backslash from \\\" in double quoted values.\r\n\t\t\telse if (m2 !== undefined) a.push(m2.replace(/\\\\\"/g, '\"'));\r\n\t\t\telse if (m3 !== undefined) a.push(m3);\r\n\t\t\treturn ''; // Return empty string.\r\n\t\t});\r\n\t// Handle special case of empty last value.\r\n\tif (/,\\s*$/.test(text)) a.push('');\r\n\treturn a;\r\n}", "title": "" }, { "docid": "ff2826b714c45a44ca150495a0b3561c", "score": "0.5324859", "text": "function CSVtoArray(text) {\n var re_valid = /^\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*(?:,\\s*(?:'[^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*\"|[^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*)\\s*)*$/;\n var re_value = /(?!\\s*$)\\s*(?:'([^'\\\\]*(?:\\\\[\\S\\s][^'\\\\]*)*)'|\"([^\"\\\\]*(?:\\\\[\\S\\s][^\"\\\\]*)*)\"|([^,'\"\\s\\\\]*(?:\\s+[^,'\"\\s\\\\]+)*))\\s*(?:,|$)/g;\n // Return NULL if input string is not well formed CSV string.\n if (!re_valid.test(text)) return null;\n var a = []; // Initialize array to receive values.\n text.replace(re_value, // \"Walk\" the string using replace with callback.\n function (m0, m1, m2, m3) {\n // Remove backslash from \\' in single quoted values.\n if (m1 !== undefined) a.push(m1.replace(/\\\\'/g, \"'\"));\n // Remove backslash from \\\" in double quoted values.\n else if (m2 !== undefined) a.push(m2.replace(/\\\\\"/g, '\"'));\n else if (m3 !== undefined) a.push(m3);\n return ''; // Return empty string.\n });\n // Handle special case of empty last value.\n if (/,\\s*$/.test(text)) a.push('');\n return a;\n}", "title": "" }, { "docid": "f1addbaf18306425a704a646babe5a23", "score": "0.53219825", "text": "function parseCsvResponse_( strData, strDelimiter ){\r\n // Check to see if the delimiter is defined. If not,\r\n // then default to comma.\r\n strDelimiter = (strDelimiter || \",\");\r\n strData = strData.replace(/^\\s+|\\s+$/g, '');\r\n\r\n // Create a regular expression to parse the CSV values.\r\n var objPattern = new RegExp(\r\n (\r\n // Delimiters.\r\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\r\n\r\n // Quoted fields.\r\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\r\n\r\n // Standard fields.\r\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\r\n ),\r\n \"gi\"\r\n );\r\n\r\n\r\n // Create an array to hold our data. Give the array\r\n // a default empty first row.\r\n var arrData = [[]];\r\n\r\n // Create an array to hold our individual pattern\r\n // matching groups.\r\n var arrMatches = null;\r\n\r\n\r\n // Keep looping over the regular expression matches\r\n // until we can no longer find a match.\r\n while (arrMatches = objPattern.exec( strData )){\r\n\r\n // Get the delimiter that was found.\r\n var strMatchedDelimiter = arrMatches[ 1 ], strMatchedValue;\r\n\r\n // Check to see if the given delimiter has a length\r\n // (is not the start of string) and if it matches\r\n // field delimiter. If id does not, then we know\r\n // that this delimiter is a row delimiter.\r\n if (\r\n strMatchedDelimiter.length &&\r\n (strMatchedDelimiter !== strDelimiter)\r\n ){\r\n\r\n // Since we have reached a new row of data,\r\n // add an empty row to our data array.\r\n arrData.push( [] );\r\n\r\n }\r\n\r\n // Now that we have our delimiter out of the way,\r\n // let's check to see which kind of value we\r\n // captured (quoted or unquoted).\r\n if (arrMatches[ 2 ]){\r\n\r\n // We found a quoted value. When we capture\r\n // this value, unescape any double quotes.\r\n strMatchedValue = arrMatches[ 2 ].replace(\r\n new RegExp( \"\\\"\\\"\", \"g\" ),\r\n \"\\\"\"\r\n );\r\n\r\n } else {\r\n\r\n // We found a non-quoted value.\r\n strMatchedValue = arrMatches[ 3 ];\r\n\r\n }\r\n\r\n // Now that we have our value string, let's add\r\n // it to the data array.\r\n if(strMatchedValue === undefined){\r\n strMatchedValue = '';\r\n }\r\n arrData[ arrData.length - 1 ].push( strMatchedValue );\r\n\r\n }\r\n\r\n // Return the parsed data.\r\n return arrData;\r\n}", "title": "" }, { "docid": "bd7583fd8ca054045e334aa4d76aa52e", "score": "0.53116024", "text": "function processData(csv) {\n var allTextLines = csv.split(/\\r\\n|\\n/);\n var lines = [];\n for (var i=0; i<allTextLines.length; i++) {\n var data = allTextLines[i].split(';');\n var tarr = [];\n for (var j=0; j<data.length; j++) {\n tarr.push(data[j]);\n }\n lines.push(tarr);\n }\n //calculateData(lines);\n noRemainder(lines);\n}", "title": "" }, { "docid": "46497f38d60109b85c2c65e3ec397c02", "score": "0.53103906", "text": "function csv_to_json(text){\r\n var lines = text.split(\"\\n\");\r\n\r\n var json_objs = {};\r\n for (var i = 1; i < lines.length; i++){\r\n var values = lines[i].split(\",\");\r\n json_objs[values[0]] = {\"bias\": parseFloat(values[2]),\r\n \"quality\": values[3],\r\n \"url\": values[1]};\r\n }\r\n\r\n return json_objs;\r\n}", "title": "" }, { "docid": "81b72799b2cfb64392b576f1edebf0df", "score": "0.5284069", "text": "function convert_row(headers, row){\n\tvar d = {};\n\trow = row.split(\",\");\n\t// JSON parse is important here otherwise strings\n\t// will look like \"\"house\"\", etc.\n\t$.each(row, function(i, val){d[JSON.parse(headers[i])] = JSON.parse(row[i]);});\n\treturn d;\n}", "title": "" }, { "docid": "ec3905356e57e276df53851c4508a394", "score": "0.5276733", "text": "function convertArrayOfObjectsToCSV(args) {\n var result, ctr, keys, columnDelimiter, lineDelimiter, data;\n\n data = args.data || null;\n if (data == null || !data.length) {\n return null;\n }\n\n columnDelimiter = args.columnDelimiter || ',';\n lineDelimiter = args.lineDelimiter || '\\n';\n\n keys = Object.keys(data[0]);\n\n result = '';\n result += keys.join(columnDelimiter);\n result += lineDelimiter;\n\n data.forEach(function(item) {\n ctr = 0;\n keys.forEach(function(key) {\n if (ctr > 0) result += columnDelimiter;\n\n result += item[key];\n ctr++;\n });\n result += lineDelimiter;\n });\n\n return result;\n}", "title": "" }, { "docid": "7ad5ead246e6a7aef3dce6a410c055f5", "score": "0.52581984", "text": "_consumeHeader (header) {\r\n for (const headerPos in header) {\r\n const columnData = header[headerPos]\r\n for (const key in columnData) {\r\n if (key === 'identifier') {\r\n this.identifier.push(header[headerPos].name)\r\n }\r\n }\r\n }\r\n }", "title": "" }, { "docid": "fad35336683eddcc90249e4455b54a83", "score": "0.5248096", "text": "function parseData(data) {\r\n var allRows = data.split(/\\r?\\n|\\r/);\r\n csvHeader = [];\r\n csvContent = [];\r\n for (var row = 0; row < allRows.length; row++) {\r\n var rowCells = allRows[row].split(',');\r\n if (row == 0)\r\n csvHeader = rowCells;\r\n else\r\n csvContent[row - 1] = rowCells;\r\n }\r\n}", "title": "" }, { "docid": "7cf61d6cbab432dabd335645c51a4798", "score": "0.52456754", "text": "transform(input) {\n if (input === '') {\n return [];\n }\n\n const lines = input.split(config.lineSeparator);\n let fields;\n\n if (!config.header && this.fields === null) \n throw {name : \"InvalidConfigError\", message : \"Fields should be specified or in the file header\"}; ;\n\n if (config.header) {\n fields = lines\n .shift()\n .split(config.delimiter)\n .map(field => field.trim());\n if (fields[fields.length -1] === '') {\n fields.pop();\n }\n } else {\n fields = this.fields;\n }\n const result = [];\n if (Array.isArray(lines) && lines.length > 0) {\n for (let i = 0; i < lines.length; i++) {\n result[i] = {};\n let cols = lines[i].split(config.delimiter);\n\n for (let j = 0; j < fields.length; j++) {\n result[i][fields[j]] = cols[j];\n }\n }\n }\n return result;\n }", "title": "" }, { "docid": "deb2ba057cd1af1b1184e114d2621313", "score": "0.5236785", "text": "function mapCSVHeadersToListHeaders() {\n vm.defaultHeaders = [];\n for (var i = 0; i < vm.csv.headers.length; i++) {\n vm.defaultHeaders.push(0);\n }\n angular.forEach(vm.csv.headers, function(h, index) {\n if (isEmailField(h)) {\n vm.defaultHeaders[index] = 'email';\n }\n if (isFirstNameField(h)) {\n vm.defaultHeaders[index] = 'firstname';\n }\n if (isLastNameField(h)) {\n vm.defaultHeaders[index] = 'lastname';\n }\n setExistingFieldMatch(h, index);\n });\n\n function isEmailField(header) {\n var trimmed = _.chain(header).toLower().trim().replace(/ /g, '').value();\n return _.includes(['email', 'emailid', 'emailaddress'], trimmed);\n }\n\n function isFirstNameField(header) {\n var trimmed = _.chain(header).toLower().trim().replace(/ /g, '').value();\n return (trimmed === 'firstname');\n }\n\n function isLastNameField(header) {\n var trimmed = _.chain(header).toLower().trim().replace(/ /g, '').value();\n return (trimmed === 'lastname');\n }\n\n function setExistingFieldMatch(header, index) {\n var trimmed = _.chain(header).toLower().trim().replace(/ /g, '').value();\n if (_.includes(_.keys(vm.list.contactHeaders), trimmed)) {\n vm.defaultHeaders[index] = trimmed;\n }\n }\n console.log(vm.defaultHeaders);\n }", "title": "" }, { "docid": "ba522885fe249f1dc17ca0dad908fa25", "score": "0.5232522", "text": "function convertArrayOfObjectsToCSV(args) {\n var result, ctr, keys, columnDelimiter, lineDelimiter, data, dummy;\n\n console.log(\"args.data as received by convertArrayOfObjectsToCSV\");\n console.log(args.data);\n\n data = args.data || null;\n\n console.log(\"data after copying from args.data\");\n console.log(data);\n\n if (data == null) {\n console.log(\"null data sent to convertArrayOfObjectsToCSV\");\n return null;\n }\n if (!data.length) {\n console.log(\"array sent to convertArrayOfObjectsToCSV has no length\");\n return null;\n }\n\n columnDelimiter = args.columnDelimiter || ',';\n lineDelimiter = args.lineDelimiter || '\\r\\n';\n\n console.log(data[0]);\n dummy = data[0];\n console.log(dummy);\n keys = Object.keys(data[0]);\n // console.log(Object.getOwnPropertyNames(data[0]));\n console.log(keys);\n\n result = '';\n result += keys.join(columnDelimiter);\n result += lineDelimiter;\n\n console.log(result);\n\n data.forEach(function(item) {\n ctr = 0;\n keys.forEach(function(key) {\n if (ctr > 0) result += columnDelimiter;\n\n result += item[key];\n ctr++;\n });\n result += lineDelimiter;\n });\n\n return result;\n }", "title": "" }, { "docid": "557149020b11d2b3579d397ea0171d39", "score": "0.5230525", "text": "function CSVToArray(strData, strDelimiter) {\n // Check to see if the delimiter is defined. If not,\n // then default to comma.\n strDelimiter = (strDelimiter || \",\");\n // Create a regular expression to parse the CSV values.\n var objPattern = new RegExp(\n (\n // Delimiters.\n \"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n // Quoted fields.\n \"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n // Standard fields.\n \"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n ),\n \"gi\"\n );\n // Create an array to hold our data. Give the array\n // a default empty first row.\n var arrData = [\n []\n ];\n // Create an array to hold our individual pattern\n // matching groups.\n var arrMatches = null;\n // Keep looping over the regular expression matches\n // until we can no longer find a match.\n while (arrMatches = objPattern.exec(strData)) {\n // Get the delimiter that was found.\n var strMatchedDelimiter = arrMatches[1];\n // Check to see if the given delimiter has a length\n // (is not the start of string) and if it matches\n // field delimiter. If id does not, then we know\n // that this delimiter is a row delimiter.\n if (\n strMatchedDelimiter.length &&\n (strMatchedDelimiter != strDelimiter)\n ) {\n // Since we have reached a new row of data,\n // add an empty row to our data array.\n arrData.push([]);\n }\n // Now that we have our delimiter out of the way,\n // let's check to see which kind of value we\n // captured (quoted or unquoted).\n if (arrMatches[2]) {\n // We found a quoted value. When we capture\n // this value, unescape any double quotes.\n var strMatchedValue = arrMatches[2].replace(\n new RegExp(\"\\\"\\\"\", \"g\"),\n \"\\\"\"\n );\n } else {\n // We found a non-quoted value.\n var strMatchedValue = arrMatches[3];\n }\n // Now that we have our value string, let's add\n // it to the data array.\n arrData[arrData.length - 1].push(strMatchedValue);\n }\n // Return the parsed data.\n return (arrData);\n }", "title": "" }, { "docid": "605179cb1fa639a5e27aa3b4e6f843c4", "score": "0.5228131", "text": "function processCSVData(csvContent) {\n return Papa.parse(csvContent, {\n delimiter: ',',\n header: true,\n skipEmptyLines: true\n });\n}", "title": "" }, { "docid": "59b8132c156b50a3700380f36514cab7", "score": "0.52215004", "text": "function MyFileJSON(){\n \n this.result=[]; \n this.header=[];\n this.success= true;\n this.errorHeader=\"\";\n this.errorResult=[];\n \n this.parseCSV= function(csv,flag,datos){ \n \n var archivo = csv.replace(/\\r\\n|\\r/g,'\\n');\n \n var lines=archivo.split(new RegExp('\\n(?![^\"]*\"(?:(?:[^\"]*\"){2})*[^\"]*$)'));\n\n var resultJSON = []; \n var start = 0;\n var columnCount = lines[0].split(\",\").length;\n \n var headers = [];\n var error=[];\n if (flag) {\n headers=lines[0].split(\",\");\n start = 1;\n var resptH=verificarHeader(datos,headers);\n if(!resptH.flag){\n this.success = false;\n this.errorHeader = resptH.error;\n flag = false;\n }\n }\n \n // lines[0]=lines[0].substr(0,lines[0].length-1); \n // this.header=lines[0].split(\",\");;\n \n \n for(var i=start;i<lines.length;i++){ \n var obj = {};\n var respt={};\n var currentline=lines[i].split(new RegExp(\",\"+'(?![^\"]*\"(?:(?:[^\"]*\"){2})*[^\"]*$)')); \n // currentline=currentline.split(\",\");\n if ( currentline.length === columnCount ) {\n if (flag) {\n for (var j=0; j<headers.length; j++) {\n obj[headers[j]] = currentline[j];\n respt=verificarContenido(datos[headers[j]],obj[headers[j]]);\n if(!respt.flag){ \n error.push(\"Fila:\"+i+\" \"+\"Columna:\"+ parseFloat(j+1)+\" ; \"+ respt.error+\" ### \");\n }\n }\n } else {\n for (var k=0; k<currentline.length; k++) {\n obj[k] = currentline[k];\n }\n }\n resultJSON.push(obj);\n } \n \n }\n \n this.result = resultJSON;\n this.header = headers; \n if(error.length>0){\n this.success=false;\n this.errorResult=error;\n }\n };\n \n}", "title": "" }, { "docid": "02680d6a3dea604b1e4e2f35f6479600", "score": "0.52061784", "text": "function CSVToArray( strData, strDelimiter ){\n\t\t// Check to see if the delimiter is defined. If not,\n\t\t// then default to comma.\n\t\tstrDelimiter = (strDelimiter || \",\");\n\n\t\t// Create a regular expression to parse the CSV values.\n\t\tvar\n\t\t\tobjPattern = new RegExp(\n\t\t\t\t(\n\t\t\t\t// Delimiters.\n\t\t\t\t\"(\\\\\" + strDelimiter + \"|\\\\r?\\\\n|\\\\r|^)\" +\n\t\t\t\t// Quoted fields.\n\t\t\t\t\"(?:\\\"([^\\\"]*(?:\\\"\\\"[^\\\"]*)*)\\\"|\" +\n\t\t\t\t// Standard fields.\n\t\t\t\t\"([^\\\"\\\\\" + strDelimiter + \"\\\\r\\\\n]*))\"\n\t\t\t\t),\n\t\t\t\t\"gi\"\n\t\t\t),\n\t\t\t// Create an array to hold our data. Give the array\n\t\t\t// a default empty first row.\n\t\t\tarrData = [[]],\n\t\t\t// Create an array to hold our individual pattern\n\t\t\t// matching groups.\n\t\t\tarrMatches = null,\n\t\t\tstrMatchedValue,\n\t\t\tstrMatchedDelimiter\n\t\t;\n\n\t\t// Keep looping over the regular expression matches\n\t\t// until we can no longer find a match.\n\t\twhile (arrMatches = objPattern.exec( strData )){\n\t\t\t// Get the delimiter that was found.\n\t\t\tstrMatchedDelimiter = arrMatches[ 1 ];\n\n\t\t\t// Check to see if the given delimiter has a length\n\t\t\t// (is not the start of string) and if it matches\n\t\t\t// field delimiter. If id does not, then we know\n\t\t\t// that this delimiter is a row delimiter.\n\t\t\tif (\n\t\t\t\tstrMatchedDelimiter.length &&\n\t\t\t\t(strMatchedDelimiter != strDelimiter)\n\t\t\t\t){\n\t\t\t\t// Since we have reached a new row of data,\n\t\t\t\t// add an empty row to our data array.\n\t\t\t\tarrData.push( [] );\n\t\t\t}\n\n\t\t\t// Now that we have our delimiter out of the way,\n\t\t\t// let's check to see which kind of value we\n\t\t\t// captured (quoted or unquoted).\n\t\t\tif (arrMatches[ 2 ]){\n\t\t\t\t// We found a quoted value. When we capture\n\t\t\t\t// this value, unescape any double quotes.\n\t\t\t\tstrMatchedValue = arrMatches[ 2 ].replace(\n\t\t\t\t\tnew RegExp( \"\\\"\\\"\", \"g\" ),\n\t\t\t\t\t\"\\\"\"\n\t\t\t\t);\n\t\t\t}else{\n\t\t\t\t// We found a non-quoted value.\n\t\t\t\tstrMatchedValue = arrMatches[ 3 ];\n\t\t\t}\n\n\t\t\t// Now that we have our value string, let's add\n\t\t\t// it to the data array.\n\t\t\tarrData[ arrData.length - 1 ].push( strMatchedValue );\n\t\t}\n\n\t\t// Return the parsed data.\n\t\treturn( arrData );\n\t}", "title": "" }, { "docid": "2e17f0963b9719219d7653f07c3808ac", "score": "0.5195197", "text": "function csvToArray (csv) {\n rows = csv.split(\"\\n\");\n return rows.map(function (row) {\n \treturn row.split(\",\");\n });\n}", "title": "" }, { "docid": "a12b4d820e6a0dd1d4442d38cf3fbd61", "score": "0.51753443", "text": "function generateCsvData(data) {\n if (!data) {\n return;\n }\n\n const row1 = [];\n const row2 = [];\n const keys = Object.keys(data);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const type = typeof data[key];\n\n // If data is too hierarchical to fit in a table, just return undefined as we can't generate a CSV.\n if (type === \"object\" && data[key] !== null) {\n // covers both objects and arrays.\n return;\n }\n if (type === \"function\") {\n // Ignore template functions we may add.\n continue;\n }\n\n row1.push(makeSafeForCsv(key));\n row2.push(makeSafeForCsv(data[key]));\n }\n\n return row1.join(\",\") + \"\\n\" + row2.join(\",\");\n}", "title": "" }, { "docid": "0c35a4cc7fbfa13930e717a390603681", "score": "0.51734155", "text": "function joinData(asianCountries, csvData){\n //loop through csv to assign each set of csv attribute values to geojson region\n for (var i=0; i<csvData.length; i++){\n var csvRegion = csvData[i]; //the current region\n var csvKey = csvRegion.ADM0_A3; //the CSV primary key\n //loop through geojson regions to find correct region\n for (var a=0; a<asianCountries.length; a++){\n var geojsonProps = asianCountries[a].properties; //the current region geojson properties\n var geojsonKey = geojsonProps.ADM0_A3; //the geojson primary key\n //where primary keys match, transfer csv data to geojson properties object\n if (geojsonKey == csvKey){\n //assign all attributes and values\n asianArray.forEach(function(attr){\n if($.isNumeric(csvRegion[attr])){ //parse out Long_Name\n var val = parseFloat(csvRegion[attr]); //get csv attribute value\n if (Number.isInteger(val)){//check for integer values\n geojsonProps[attr] = val; //assign attribute and value to geojson properties\n }else { //all other values are floats\n geojsonProps[attr] = val.toFixed(2); //to only 2 decimal places\n }\n } else {\n geojsonProps[attr] = csvRegion[attr];//assign Long_Name\n };\n });\n };//if geojson == csvKey\n };//end of second for loop a=0\n }; //end of first for loop i=0\n return asianCountries;\n}", "title": "" }, { "docid": "d940884271700362530eb4e56c8c8a7f", "score": "0.5153022", "text": "function parseWithCSVParser(coll, db) {\n var dataArr = [];\n fs.createReadStream(path.join(__dirname, '', dataFile))\n .on('error', function() {\n console.log(`An error ocurred while reading file :(`);\n })\n .pipe(csvParser())\n .on('data', function(row) {\n var newData = objectWithCustomKeys(row);\n dataArr.push(newData);\n })\n .on('end', function() {\n // console.log(dataArr);\n coll.insertMany(dataArr, (err, res) => {\n if (err) throw err;\n console.log(`Inserted ${res.insertedCount} documents`);\n db.close();\n });\n });\n}", "title": "" }, { "docid": "1c51fca6c8ae3942465768d18fd1fec2", "score": "0.51506734", "text": "function convertArrayOfObjectsToCSV(args, callback) {\n var result, ctr, keys, columnDelimiter, lineDelimiter, data;\n\n data = args || null;\n if (data == null || !data.length) {\n return null;\n }\n columnDelimiter = args.columnDelimiter || ',';\n lineDelimiter = args.lineDelimiter || '\\n';\n keys = Object.keys(data[0]);\n result = '';\n result += 'user_id' + columnDelimiter + ' post_id' + columnDelimiter + ' page_id';\n result += lineDelimiter;\n\n args.forEach(function(object) {\n if (object.length != 0) {\n object.forEach(function(item) {\n if ('likes' in item && 'data' in item.likes) {\n var postId = item.id;\n if (item.id == undefined) {console.log(result)}\n item.likes.data.forEach(function(likeId) {\n if ('id' in likeId) {\n var likeArray = likeId;\n result += likeArray.id + columnDelimiter + postId.split('_').reverse() + lineDelimiter;\n } else {\n result += columnDelimiter + postId.split('_').reverse() + lineDelimiter;\n };\n });\n }\n });\n }\n })\n console.log('converted to CSV')\n return result;\n callback();\n }", "title": "" } ]
b0316b7fd83fada3eeb867eb5c52a275
Generates a random single rgb colour value
[ { "docid": "2c24426ac83ff9b9086387c3cdcd6af5", "score": "0.82922524", "text": "function randomRGBColour() {\n var red = Math.floor( Math.random() * 256 ),\n green = Math.floor( Math.random() * 256 ),\n blue = Math.floor( Math.random() * 256 );\n return \"rgb(\" + red + \", \" + green + \", \" + blue + \")\";\n}", "title": "" } ]
[ { "docid": "7912bdfeb39b9366df4e08bfd4b7df0f", "score": "0.8674331", "text": "function getRandomColorRGB() {\n return 'rgb(' + calcRndGen(255, true).toString() + \",\" + calcRndGen(255, true).toString() + \",\" + calcRndGen(255, true).toString() + ')';\n }", "title": "" }, { "docid": "7be294d83755162ca7cfef0e2d15d715", "score": "0.8651737", "text": "function random_rgb() {\n var o = Math.round, r = Math.random, s = 255;\n return 'rgb(' + o(r()*s) + ',' + o(r()*s) + ',' + o(r()*s) + ',' + 0.5 + ')';\n }", "title": "" }, { "docid": "52dd523a5b71558e5ddfd1fd962c32d8", "score": "0.86215556", "text": "function generateRandomRGB() {\n return (Math.floor(Math.random() * 250) + 1);\n}", "title": "" }, { "docid": "bc61270d25280d31a528e269ce97991b", "score": "0.86164194", "text": "function gencolor() {\n len = _COLOR.length;\n rand = Math.floor(Math.random()*len); \n return _COLOR[rand];\n }", "title": "" }, { "docid": "98fe822e62d51374f63fc6827710e58c", "score": "0.86136794", "text": "function randColor() {\n return Math.floor(Math.random() * 256);\n}", "title": "" }, { "docid": "678eba39fc37be3a1e075f939ea0d322", "score": "0.8609892", "text": "function randomRgb(){\n\treturn Math.floor(Math.random() * 256) + 1;\n}", "title": "" }, { "docid": "91831a7b89672001728ab9499a76cc7b", "score": "0.86017644", "text": "function randomRGB() {\n return Math.floor(Math.random() * 256);\n}", "title": "" }, { "docid": "91831a7b89672001728ab9499a76cc7b", "score": "0.86017644", "text": "function randomRGB() {\n return Math.floor(Math.random() * 256);\n}", "title": "" }, { "docid": "91831a7b89672001728ab9499a76cc7b", "score": "0.86017644", "text": "function randomRGB() {\n return Math.floor(Math.random() * 256);\n}", "title": "" }, { "docid": "aa3168bc4c147431bac2580a6d6afa64", "score": "0.85962564", "text": "function genColorVal(){\r\n return Math.floor(Math.random() * 256);\r\n }", "title": "" }, { "docid": "e45f502a981db560e366f2d13e64b336", "score": "0.8583133", "text": "function randomRGB() {\n\treturn Math.floor(Math.random() * 256);\n}", "title": "" }, { "docid": "7712e9adc41a567c6a31dc48e0553296", "score": "0.85607415", "text": "function randomrgb() {\n var r = Math.floor(Math.random() * 256);\n var g = Math.floor(Math.random() * 256);\n var b = Math.floor(Math.random() * 256);\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n\n}", "title": "" }, { "docid": "be6781c8defae1bea8f265f17c6ad0b0", "score": "0.8543566", "text": "function getRandomRGB() {\n var red = getRandomInt(255);\n var green = getRandomInt(255);\n var blue = getRandomInt(255);\n return \"rgb(\" + red + \", \" + blue + \", \" + green + \")\";\n}", "title": "" }, { "docid": "be6781c8defae1bea8f265f17c6ad0b0", "score": "0.8543566", "text": "function getRandomRGB() {\n var red = getRandomInt(255);\n var green = getRandomInt(255);\n var blue = getRandomInt(255);\n return \"rgb(\" + red + \", \" + blue + \", \" + green + \")\";\n}", "title": "" }, { "docid": "2607fe0b316b28cc0d9bf8bc5ad40f73", "score": "0.85199463", "text": "function generateColor() {\n var r = Math.floor(Math.random() * 256);\n var g = Math.floor(Math.random() * 256);\n var b = Math.floor(Math.random() * 256);\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "1d66db5ba331905a245725f92ee093b0", "score": "0.84953976", "text": "function GetRandomColor() {\r\n var r = 0,\r\n g = 0,\r\n b = 0;\r\n while (r < 100 && g < 100 && b < 100) {\r\n r = Math.floor(Math.random() * 256);\r\n g = Math.floor(Math.random() * 256);\r\n b = Math.floor(Math.random() * 256);\r\n }\r\n return \"rgb(\" + r + \",\" + g + \",\" + b + \")\";\r\n}", "title": "" }, { "docid": "75544546d9f48a8f2a724fc0f99b6044", "score": "0.8476258", "text": "function generateRandomColour(){\n var r = Math.random()*254 +1;\n var g = Math.random()*254 +1;\n var b = Math.random()*254 +1;\n\n return `rgb(${r},${g},${b})`;\n}", "title": "" }, { "docid": "5dc3ccf18cbc08bf56751a316ee1e03d", "score": "0.8470508", "text": "function generateRGB() {\n const color = chroma.random();\n return color;\n}", "title": "" }, { "docid": "16000b4170845577dee18ec46ba9ef57", "score": "0.8468981", "text": "function randomRGB() {\r\n let r = randomInt(0, 256);\r\n let g = randomInt(0, 256);\r\n let b = randomInt(0, 256);\r\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\r\n}", "title": "" }, { "docid": "33d27cb518b8de49a8a624df5789efd9", "score": "0.843563", "text": "function getRandomColor() {\n return 'rgb(' + Math.floor(Math.random() * 256) + ',' + Math.floor(Math.random() * 256) + ',' + Math.floor(Math.random() * 256) + ')';\n}", "title": "" }, { "docid": "3715dbab0434294b862df23263ce73c7", "score": "0.84268826", "text": "function color_rand() {\n return color(random(127,255),random(127,255),random(127,255));\n}", "title": "" }, { "docid": "9c975d42ce5aabf20c4cfd0a5c86ac59", "score": "0.8424", "text": "function getRandomRgb() {\n var num = Math.round(0xffffff * Math.random());\n var r = num >> 16;\n var g = num >> 8 & 255;\n var b = num & 255;\n return 'rgb(' + r + ', ' + g + ', ' + b + ')';\n}", "title": "" }, { "docid": "d560f8ef55dd170527ee5bd107b45a4f", "score": "0.8420195", "text": "function rgbColorGenerator() {\n let r = Math.floor(Math.random() * 255);\n let g = Math.floor(Math.random() * 255);\n let b = Math.floor(Math.random() * 255);\n\n return console.log(`rgb(${r}, ${g}, ${b})`);\n}", "title": "" }, { "docid": "bb1635de7aefdde5ac115c80e6197f38", "score": "0.84116614", "text": "function randomColour() {\n return new rgb(\n Math.floor(Math.random() * 255),\n Math.floor(Math.random() * 255),\n Math.floor(Math.random() * 255)\n );\n}", "title": "" }, { "docid": "29a1eb1d539db1004f496cb8068370e7", "score": "0.8410759", "text": "function rndRGB() {\n var num1 = Math.floor(Math.random() *256);\n var num2 = Math.floor(Math.random() *256);\n var num3 = Math.floor(Math.random() *256);\n return 'rgb(' + num1 +', ' + num2 + ', ' + num3 +')';\n}", "title": "" }, { "docid": "342ccbd346ece58fe56dc06ea815779d", "score": "0.8408949", "text": "function randomColor() {\n var r = random(256) | 0,\n g = random(256) | 0,\n b = random(256) | 0;\n return 'rgb(' + r + ',' + g + ',' + b + ')';\n }", "title": "" }, { "docid": "2d453baab688d95c615bf477a09e16d4", "score": "0.84066385", "text": "function getRandomRGB() {\n let r = Math.floor(Math.random() * Math.floor(256));\n let g = Math.floor(Math.random() * Math.floor(256));\n let b = Math.floor(Math.random() * Math.floor(256));\n return `rgb(${r}, ${g}, ${b})`;\n}", "title": "" }, { "docid": "6e8239e9b1eb5d5d66264339d1480694", "score": "0.83922976", "text": "function randomColor () {\nreturn Math.floor (Math.random() * 256) ;\n}", "title": "" }, { "docid": "1a4fe03817c283ec800c86d102f8d1eb", "score": "0.83883816", "text": "function randomRGB(){\n return Math.floor(Math.random()*256);\n}", "title": "" }, { "docid": "8283d929ca8274686973ff506c85184a", "score": "0.8381831", "text": "function rgbGenerator()\r\n{\r\n\tvar r= Math.floor(Math.random()*256);\r\n\tvar g= Math.floor(Math.random()*256);\r\n\tvar b= Math.floor(Math.random()*256);\r\n\r\n\treturn \"rgb(\"+r+\", \"+g+\", \"+b+\")\" ;\r\n}", "title": "" }, { "docid": "83ae98c19289542bc5af998e74a0e34f", "score": "0.8374373", "text": "function generateRGB() {\n\tvar temp = Math.floor(Math.random() * 256 + 0);\t\t\t \n\treturn temp;\n}", "title": "" }, { "docid": "8e2a897359227e9c576a5b5fb324660d", "score": "0.8368251", "text": "function randomRGB(num){\n return \"rgb(\" + random255() + \", \" + random255() + \", \" + random255() + \")\"\n}", "title": "" }, { "docid": "44a31dede00112599b017bdd45b6ee01", "score": "0.8359381", "text": "function randomRGB() {\n // Use math.floor to generate random value btween 1-255\n return Math.floor(Math.random() * 255)\n}", "title": "" }, { "docid": "b81d5e83633576e25c9beaf15eb3d3a0", "score": "0.83591276", "text": "function randomRGB(){\n return Math.floor(Math.random() * 256 );\n}", "title": "" }, { "docid": "ceb96ec56939d0554beaebf4648ea436", "score": "0.8356952", "text": "function getRandomRgb() { \n var r = Math.floor(Math.random() * 256);\n var g = Math.floor(Math.random() * 256);\n var b = Math.floor(Math.random() * 256);\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "af6a836a17510a36e6d759e0e94f4378", "score": "0.83556384", "text": "function getRandomColor() {\n let r = 0;\n let b = 255;\n let g = 0; //Math.round(Math.random()*255);\n return \"rgb(\" + r + \",\" + g + \",\" + b + \")\";\n}", "title": "" }, { "docid": "b66daf106b48d42d16f9bd013dd632b3", "score": "0.83540535", "text": "function getRandomColor() {\r\n var rand = function() {\r\n return Math.floor(Math.random() * 256);\r\n };\r\n return `rgb(${rand()}, ${rand()}, ${rand()})`;\r\n }", "title": "" }, { "docid": "ef83f3d990d9ebca5bea71c2dd11175e", "score": "0.835335", "text": "function randomRGB(){\n let r = randomNum(256);\n let g = randomNum(256);\n let b = randomNum(256);\n return \"rgb(\"+r+\", \"+g+\", \"+b+\")\";\n}", "title": "" }, { "docid": "3f745f413fda53f7ab72f35b5f6727e4", "score": "0.8340287", "text": "function randomColorGenerator() {\n\tvar randomColor;\n\tred = Math.floor(Math.random() * 256 );\n\tgreen = Math.floor(Math.random() * 256 );\n\tblue = Math.floor(Math.random() * 256 );\n\trandomColor = 'rgb(' + red + ',' + green + ',' + blue + ')';\n\treturn randomColor;\n}", "title": "" }, { "docid": "7c2fde55bf3e02f6d63132c69dc3866a", "score": "0.833855", "text": "function generateRandomColor() {\n // return '#'+Math.floor(Math.random()*16777215).toString(16);\n return myColors[Math.floor(Math.random()*myColors.length)];\n}", "title": "" }, { "docid": "5a36d34f9403bd8ee89ff579b9d5bd58", "score": "0.8330421", "text": "function randomRGB () {\n let red = randomNum()\n let green = randomNum()\n let blue = randomNum()\n return [red, green, blue]\n }", "title": "" }, { "docid": "709bd0cecbc53bca1628b49803618c75", "score": "0.8327502", "text": "function randColor() {\r\n var r = Math.floor(Math.random() * (256)),\r\n g = Math.floor(Math.random() * (256)),\r\n b = Math.floor(Math.random() * (256));\r\n return '#' + r.toString(16) + g.toString(16) + b.toString(16);\r\n}", "title": "" }, { "docid": "c2a4e081556b0907a5c5c9ecf1a52d08", "score": "0.8321358", "text": "function getRandomColor() {\n if (numberOfRgbaColorsTaken > (rgbColors.length - 1))\n return random_rgba();\n return rgbColors[numberOfRgbaColorsTaken++];\n}", "title": "" }, { "docid": "f736e64e9f8a9eef7d93e8e0bc381dc7", "score": "0.83126837", "text": "function randomColor() {\n // Generate random integer between 0 and 255\n function generateNumber() {\n return Math.floor(Math.random() * 256);\n }\n return \"rgb(\" + generateNumber() + \", \" + generateNumber() + \", \" + generateNumber() + \")\";\n}", "title": "" }, { "docid": "a1ae08866e473f0980cc381f4d5cae4c", "score": "0.83126664", "text": "function generateRandomColor() {\n const r = Math.floor(Math.random() * 256);\n const g = Math.floor(Math.random() * 256);\n const b = Math.floor(Math.random() * 256);\n return `rgb(${r}, ${g}, ${b})`;\n }", "title": "" }, { "docid": "93204255d72378ba7dcf9b7cf77edf2e", "score": "0.83088994", "text": "function randomRgbVal() {\n let rValue = Math.floor(Math.random() * 256);\n let gValue = Math.floor(Math.random() * 256);\n let bValue = Math.floor(Math.random() * 256);\n return `rgb(${rValue}, ${gValue}, ${bValue})`;\n}", "title": "" }, { "docid": "91e83eaedc326cbd2ef162ab760ee1d7", "score": "0.83066404", "text": "function generateRandomColorValues () {\n r = Math.round(Math.random() * (256));\n g = Math.round(Math.random() * (256));\n b = Math.round(Math.random() * (256));\n}", "title": "" }, { "docid": "cc023f200048e110ad2810e360aa3c53", "score": "0.82950866", "text": "function randomColor() {\n var r = Math.floor(Math.random() * 256);\n var g = Math.floor(Math.random() * 256);\n var b = Math.floor(Math.random() * 256);\n\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "b7a0e2ff7a9b34423d21b64c270c617e", "score": "0.8294965", "text": "function randomColor() {\n let red = Math.floor(Math.random() * 256);\n let green = Math.floor(Math.random() * 256);\n let blue = Math.floor(Math.random() * 256);\n let rgb = \"rgb(\" + red + \",\" + green + \",\" + blue + \")\";\n return rgb;\n}", "title": "" }, { "docid": "59e5daf14c930dce7be4cf1899698081", "score": "0.8294728", "text": "function getRandomColor() {\n let r = getRandomInt(0, 256);\n let g = getRandomInt(0, 256);\n let b = getRandomInt(0, 256);\n return `rgb(${r},${g},${b})`;\n}", "title": "" }, { "docid": "c44154f4fad6a45f2ea03e14fa8b7243", "score": "0.8294683", "text": "function randomColor() {\n return Math.floor(Math.random() * 255);\n}", "title": "" }, { "docid": "9a2f082ced1f0729ca7aed2fd8187adc", "score": "0.82850724", "text": "function randomColour() {\n\n\tfunction value() {\n\t\treturn Math.floor(Math.random() * Math.floor(255)) \n\t}\n\treturn 'rgb(' + value() + ',' + value() + ',' + value() + ')';\n}", "title": "" }, { "docid": "804dbe2b6bb99c660632dd95bd2c7c2c", "score": "0.8274566", "text": "function randomColor(){\r\n var r= Math.floor(Math.random() * 256);\r\n var g= Math.floor(Math.random() * 256);\r\n var b= Math.floor(Math.random() * 256);\r\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\r\n}", "title": "" }, { "docid": "c493c12fe382da62d2a1e66fcda3019e", "score": "0.82741547", "text": "function generateColor() {\n\tvar array = [];\n\tfor (var i = 0; i < 3; i++) {\n\t\tvar number = Math.floor(Math.random() * 256);\n\t\tarray.push(number);\n\t} \n\tvar newRgb = \"rgb(\" + array[0] + \",\" + array[1] + \",\" + array[2] + \")\";\n\treturn newRgb;\n}", "title": "" }, { "docid": "95fd4e054bf44935e3d8f27c6eca16d0", "score": "0.8273299", "text": "function createRandomRGB(){\n const r = Math.floor(Math.random()*256);\n const g = Math.floor(Math.random()*256);\n const b = Math.floor(Math.random()*256);\n return `rgb(${r},${g},${b})`;\n}", "title": "" }, { "docid": "8c8b7c78842f1a63aa1ac5c5845a533a", "score": "0.8272482", "text": "function randColor()\n {\n return '#'+ Math.floor(Math.random()*16777215).toString(16);\n }", "title": "" }, { "docid": "9d840ce690f65108e4e0e11027faacaa", "score": "0.82723415", "text": "function randomColor(){\n\tvar r=Math.floor(Math.random()*256);\n\tvar g=Math.floor(Math.random()*256);\n\tvar b=Math.floor(Math.random()*256);\n\treturn \"rgb(\"+r+\", \"+g+\", \"+b+\")\";\n\n}", "title": "" }, { "docid": "b69d8ca40ed770fee60217131f9472f7", "score": "0.826418", "text": "function randomColor() {\n r = random(255);\n g = random(255);\n b = random(255);\n}", "title": "" }, { "docid": "be187bdd5f59e250a0d83a0c617241a2", "score": "0.82602024", "text": "function getRandomRGB() {\n return {\n red: rangedRandomVal(31, 223),\n green: rangedRandomVal(31, 223),\n blue: rangedRandomVal(31, 223),\n };\n}", "title": "" }, { "docid": "946875ed0c741e5bb8de790224a2889d", "score": "0.8258816", "text": "function randomRGB() {\n const red = Math.floor(Math.random() * 255);\n const green = Math.floor(Math.random() * 255);\n const blue = Math.floor(Math.random() * 255);\n return (`rgb(${red}, ${green}, ${blue})`);\n}", "title": "" }, { "docid": "55e4f793cd3a1747b1796957d46ac152", "score": "0.8258314", "text": "function randomRGB() {\n return `rgb(${random(0, 255)},${random(0, 255)},${random(0, 255)})`;\n}", "title": "" }, { "docid": "5513d3bf4100531c544d1f80eaabbd8a", "score": "0.82572895", "text": "function getRandomRGBColor() {\n let randomColor = {\n r: random(255),\n g: random(255),\n b: random(255)\n }\n\n return randomColor;\n}", "title": "" }, { "docid": "c30164d89316a58bd7241a326e9641d9", "score": "0.82555556", "text": "function generateColor(){\r\n\tvar i,j,k;\r\n\t i=Math.floor(Math.random()*255 + 1);\r\n\t j=Math.floor(Math.random()*255 + 1);\r\n\t k=Math.floor(Math.random()*255 + 1);\r\n\r\n\t \r\n\t return \"rgb(\" + i + \", \" + j +\", \" + k + \")\" ;\r\n}", "title": "" }, { "docid": "3db9cb16eb2fc275036e7b7e20422edb", "score": "0.82530576", "text": "function randomColor(){\n var r = Math.floor(Math.random() * 256);\n var g = Math.floor(Math.random() * 256);\n var b = Math.floor(Math.random() * 256);\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "fcbc9107000918a583488b4b5ab16bbd", "score": "0.8251744", "text": "function generateColor() {\n const ranges = [\n [150, 256],\n [0, 190],\n [0, 30]\n ];\n var g = function() {\n var range = ranges.splice(Math.floor(Math.random() * ranges.length), 1)[0];\n return Math.floor(Math.random() * (range[1] - range[0])) + range[0];\n }\n return \"rgb(\" + g() + \",\" + g() + \",\" + g() + \")\";\n }", "title": "" }, { "docid": "7a3bf9558c44df65b5554a7939e57484", "score": "0.82517165", "text": "function rgbGenerator(){\n\treturn \"rgb(\" + randomizer() + \", \" + randomizer() + \", \" + randomizer() + \")\";\n}", "title": "" }, { "docid": "ce7d5253f6e80f38c484538a1851bafe", "score": "0.82326806", "text": "function ranColor(){\n\tvar red = Math.floor(Math.random() * 256);\n\tvar green = Math.floor(Math.random() * 256);\n\tvar blue = Math.floor(Math.random() * 256);\n\t\n\treturn \"rgb(\" + red + \",\" + green + \",\" + blue + \")\";\n\n}", "title": "" }, { "docid": "e06b1ff408d02371dfc4926b1d2eb3a1", "score": "0.82325065", "text": "static random_color () {\n let r = rand_in_range(0, 256)\n let g = rand_in_range(0, 256)\n let b = rand_in_range(0, 256)\n let a = rand_in_range(0, 128)\n\n return [r, g, b, a]\n }", "title": "" }, { "docid": "5460ac8e0b1c7d3af6cb7cb68930b3b4", "score": "0.82300615", "text": "function randomColor(){\n return `rgb(${randomInt(0,256)},${randomInt(0,256)},${randomInt(0,256)})`;\n}", "title": "" }, { "docid": "46a4c2285acb0720776e985171f2ea05", "score": "0.8226497", "text": "function randomColor() {\n\t//pick r, g, b from 0 - 255\n\tvar r = Math.floor(Math.random() * 256);\n\tvar g = Math.floor(Math.random() * 256);\n\tvar b = Math.floor(Math.random() * 256);\n\treturn \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "c160b78b2f2d9dabc01371b0159e7437", "score": "0.82234687", "text": "function randomColor() {\n\n let r = Math.floor(Math.random(256) * 256);\n let g = Math.floor(Math.random(256) * 256);\n let b = Math.floor(Math.random(256) * 256);\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "a38e1e07f04a49b0cbb3c876ceaf5778", "score": "0.82221746", "text": "function randomColor(){\n\tvar red = getRandomNumber(255);\n\tvar green = getRandomNumber(255);\n\tvar blue = getRandomNumber(255);\n\treturn \"rgb(\" + red +\", \" + green + \", \"+ blue + \")\";\n}", "title": "" }, { "docid": "2190aa79cd602fd6a7237d1abbe9faa4", "score": "0.82172704", "text": "function randomColor()\n{\n\treturn \"rgb(\" + Math.floor(Math.random()*255)+\",\"+\n\t\t\t\t Math.floor(Math.random()*255)+\",\"+\n\t\t\t\t Math.floor(Math.random()*255)+\")\";\n}", "title": "" }, { "docid": "373a71bd78c33511742f49b3d0e0147e", "score": "0.8214284", "text": "function randomColor() {\n var r = random(0, 255);\n var b = random(0, 255);\n var g = random(0, 255);\n\n\n return color(r, b, g);\n}", "title": "" }, { "docid": "d30963664a6b46333c615153f17c8af4", "score": "0.82118183", "text": "function getRandomColor() {\n var red = Math.floor(Math.random() * 255);\n var green = Math.floor(Math.random() * 255);\n var blue = Math.floor(Math.random() * 255);\n return 'rgb(' + red + ',' + green + ',' + blue + ')';\n\n}", "title": "" }, { "docid": "b89997a1568e7eecd60541c7511c5855", "score": "0.8211181", "text": "function randomColor(){\n return color3(Math.floor(Math.random()*256),\n Math.floor(Math.random()*256),\n Math.floor(Math.random()*256));\n}", "title": "" }, { "docid": "121e71bd19f2e668d892a04299378220", "score": "0.81908256", "text": "function getRandomColor() {\n let color = 'rgb(';\n color += randomNumGen(rgbNum) + ',';\n color += randomNumGen(rgbNum) + ',';\n color += randomNumGen(rgbNum) + ')';\n return color;\n }", "title": "" }, { "docid": "4c868d0f9017685ae007998f2de220a2", "score": "0.81777877", "text": "function newRGB() {\n let r = Math.floor(Math.random() * 256);\n let g = Math.floor(Math.random() * 256);\n let b = Math.floor(Math.random() * 256);\n rgbValue = \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n return rgbValue;\n}", "title": "" }, { "docid": "3a8da1b1642615944cf5fdd4368defe2", "score": "0.8169348", "text": "function getRandomColor() {\n let r = 0;\n let g = 0;\n let b = 0;\n while (r < 100 && g < 100 && b < 100) {\n r = Math.floor(Math.random() * 256);\n g = Math.floor(Math.random() * 256);\n b = Math.floor(Math.random() * 256);\n }\n return `rgba(${r},${g},${b},0.6)`;\n}", "title": "" }, { "docid": "e965140b004fbe45b9bb7c5be2be1d4f", "score": "0.8167469", "text": "function randomColor(){\n\tlet r = Math.floor(Math.random() * 256);\n\tlet g = Math.floor(Math.random() * 256);\n\tlet b = Math.floor(Math.random() * 256);\n\n\treturn \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n\n}", "title": "" }, { "docid": "eabd602c4e29c36626839b855b0402f1", "score": "0.8166605", "text": "function randomColor() {\n // pick a red from 0 - 255\n // need to multiply by 256 for 255 to be the greatest number possible\n var r = Math.floor(Math.random() * 256);\n // pick green from 0 - 255\n var g = Math.floor(Math.random() * 256);\n // pick a blue from 0 - 255\n var b = Math.floor(Math.random() * 256);\n // make into string\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "dc4a7f8d49ad416f21b975ea31157c71", "score": "0.8162713", "text": "function randomColor() {\r\n let red = Math.floor(Math.random()*256);\r\n let green = Math.floor(Math.random()*256);\r\n let blue = Math.floor(Math.random()*256);\r\n\r\n return `rgb(${red}, ${green}, ${blue})`;\r\n}", "title": "" }, { "docid": "0c07e676c9292e763d96a2bb3e73ba16", "score": "0.8153634", "text": "function randomColor() {\r\n let red = randomNumber(0, 255)\r\n let green = randomNumber(0, 255)\r\n let blue = randomNumber(0, 255)\r\n return `rgb(${red},${green},${blue})`\r\n}", "title": "" }, { "docid": "94654a49e69eab2f751b75d6d32039de", "score": "0.8152251", "text": "function randomColor() {\n return (\n \"rgb(\" +\n Math.round(Math.random() * 250) + \",\" +\n Math.round(Math.random() * 250) + \",\" +\n Math.round(Math.random() * 250)\n + \")\"\n );\n}", "title": "" }, { "docid": "835ac12445a3baf6d1df3fd0163af20b", "score": "0.81491375", "text": "function randomColor() {\n let r = Math.floor(Math.random() * 256);\n let g = Math.floor(Math.random() * 256);\n let b = Math.floor(Math.random() * 256);\n return (`rgb(${r},${g},${b})`);\n}", "title": "" }, { "docid": "e88866f976f41e7ada57f2dcd1a10378", "score": "0.81471217", "text": "function randomColor(){\n\tval = Math.floor(Math.random()*255);\n\treturn val;\n}", "title": "" }, { "docid": "a239bd4f05b0baf05ab391741dbd83f0", "score": "0.81361574", "text": "function randomColor() {\n //pick a \"red\" from 0 -255\n const r = Math.floor(Math.random() * 256);\n //pick a \"green\" from 0 -255\n const g = Math.floor(Math.random() * 256);\n //pick a \"blue\" from 0 -255\n const b = Math.floor(Math.random() * 256);\n\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "30e90ffc6c45883068865e9f4f12c00b", "score": "0.813524", "text": "function randomColor() {\n // Pick red, green, and blue from 0 - 255\n let r = Math.floor(Math.random() * 256);\n let g = Math.floor(Math.random() * 256);\n let b = Math.floor(Math.random() * 256);\n\n return \"rgb(\" + r + \", \" + g + \", \" + b + \")\";\n}", "title": "" }, { "docid": "e69ca426d4146ef2040b61c0566ad01d", "score": "0.81288654", "text": "function randomColorGenerator() {\n\t\t\t\t\t\t\treturn '#'\n\t\t\t\t\t\t\t\t\t+ (Math.random().toString(16) + '0000000')\n\t\t\t\t\t\t\t\t\t\t\t.slice(2, 8);\n\t\t\t\t\t\t}", "title": "" }, { "docid": "dc336aceb07e10842fa1ca81c27e5b70", "score": "0.81257975", "text": "function getRandomColorDigit() {\n\treturn Math.floor(Math.random() * window.colors.length);\n}", "title": "" }, { "docid": "0400ab55e41686265269715b71516e2f", "score": "0.812466", "text": "function generateRandomColor() {\n let r = Math.floor(Math.random() * 255);\n let g = Math.floor(Math.random() * 255);\n let b = Math.floor(Math.random() * 255);\n let color = \"rgba(\" + r + \",\" + g + \",\" + b + \",\" + 1 + \")\";\n return color;\n }", "title": "" }, { "docid": "154aff80372e69d5e6f17fbaf5f2a753", "score": "0.81162375", "text": "function randomColor() {\n let r = Math.floor(Math.random() * 256),\n g = Math.floor(Math.random() * 256),\n b = Math.floor(Math.random() * 256);\n return `rgb(${r}, ${g}, ${b})`;\n}", "title": "" }, { "docid": "dd05ce48e8c14a88409d7f435ef2b11b", "score": "0.8113304", "text": "function randomColor(){\n //pick \"red\" from 0 -> 255\n let red = Math.floor(Math.random()*256);\n //pick \"green\" from 0 -> 255\n let green = Math.floor(Math.random()*256);\n //pick \"blue\" from 0 -> 255\n let blue = Math.floor(Math.random()*256);\n //construct string to match rgb format\n return \"rgb(\"+red+\", \"+green+\", \"+blue+\")\";\n}", "title": "" }, { "docid": "24b0c7208ee4ac9da042df596d941180", "score": "0.8109852", "text": "function randomColor() {\n var rColor;\n var red = Math.floor(Math.random() * 256 );\n \tvar green = Math.floor(Math.random() * 256 );\n \tvar blue = Math.floor(Math.random() * 256 );\n\n rColor = 'rgb(' + red + ',' + green + ',' + blue + ')';\n\n return rColor;\n }", "title": "" }, { "docid": "64c4e48b5b5fc4e6a405f82f4a6b1dd1", "score": "0.8108866", "text": "function randColour()\n{\n\tvar c = Math.round(0xffffff * Math.random());\t\n\treturn ('#0' + c.toString(16)).replace(/^#0([0-9a-f]{6})$/i, '#$1');\n}", "title": "" }, { "docid": "e1382aed82f38c669d5650e9c76f9ec6", "score": "0.81072503", "text": "function randomColor() {\n var x = Math.floor(Math.random() * 256);\n var y = Math.floor(Math.random() * 256);\n var z = Math.floor(Math.random() * 256);\n return Color = \"rgb(\" + x + \",\" + y + \",\" + z + \")\";\n}", "title": "" }, { "docid": "48d21df5f790e4dfa4141e25df095cc9", "score": "0.8106457", "text": "function randomColor() {\n\tconst r = Math.round(255 * Math.random());\n\tconst g = Math.round(255 * Math.random());\n\tconst b = Math.round(255 * Math.random());\n\treturn {r, g, b};\n}", "title": "" }, { "docid": "678efd0b002de53aac1f9256f1aaf694", "score": "0.81064296", "text": "function randomColor() {\n return \"rgb(\" + random(0, 235) +\n \", \" + random(0, 235) +\n \", \" + random(0, 235) + \")\";\n}", "title": "" }, { "docid": "daa444c73420f2aa4f9c3e21049aed8c", "score": "0.81021935", "text": "function randomColor() {\n\t//pick a \"red\" from 0 - 255\n\tvar red = Math.floor(Math.random() * 256);\n\tvar green = Math.floor(Math.random() * 256);\n\tvar blue = Math.floor(Math.random() * 256);\n\treturn \"rgb(\" + red + \", \" + green + \", \" + blue + \")\";\n}", "title": "" }, { "docid": "1c0010287c7ba4a251419af7b6c813c5", "score": "0.80948573", "text": "function randomColor(){ \n num = Math.floor(Math.random() * 255);\n return num\n}", "title": "" } ]
9b3e9f7d45271b2a8969155b0ba62cdc
const clickTargets = gallery2.querySelectorAll('.galleriesItem__figure'); anim core fn
[ { "docid": "e3cf5e92de07859e17ed9c14c888146a", "score": "0.0", "text": "function animate(opts) {\n var start = new Date;\n var id = setInterval(function(){\n var timePassed = new Date - start;\n var progress = timePassed / opts.duration;\n\n if (progress > 1) {\n progress = 1;\n }\n var delta = opts.delta(progress);\n opts.step(delta);\n if (progress == 1){\n clearInterval(id);\n\n }\n }, opts.delay || 10)\n}", "title": "" } ]
[ { "docid": "b2f39d69e002563dec7ce23c72e21fe3", "score": "0.64693797", "text": "function galleryThree(e) {\n let imgContainer = document.getElementById('option3').children[0].children;\n let imgContainerLng = imgContainer.length - 1;\n let targetEl = e.target;\n let targetIndex = Array.prototype.indexOf.call(imgMainArr, targetEl.src);\n let clickedEl = targetEl.src;\n // let currentEl = imgContainer[0].children[0].src;\n\n imgContainer[0].children[0].src = targetEl.src;\n\n let newArr = imgMainArr.slice(0, targetIndex).concat(imgMainArr.slice(targetIndex + 1, imgContainerLng));\n\n for( let i = 0; i < newArr.length; i++) {\n imgContainer[i + 1].children[0].src = newArr[i]\n }\n\n // imgContainer[0].children[0].src = currentEl;\n imgContainer[0].children[0].src = clickedEl;\n\n // tried to implement smooth fade with javascript but looked ugly\n // setTimeout(fadeOut, 150);\n // function fadeOut() {\n // imgContainer[0].children[0].style.opacity = '0';\n // }\n // setTimeout(fadeIn, 250);\n // function fadeIn() {\n // imgContainer[0].children[0].style.opacity = '1';\n // imgContainer[0].children[0].src = clickedEl;\n // }\n\n e.preventDefault();\n return false;\n}", "title": "" }, { "docid": "0f424a5a6993904b4b38d4dbcb71f07e", "score": "0.64032453", "text": "GetTargets(){this.targets = document.querySelectorAll(this.target_selector)}", "title": "" }, { "docid": "10f62268083c118ff5575c4f47ada44e", "score": "0.6226681", "text": "function makeEvents(i){\n var dotElement = document.getElementById('h5p-image-gallery-dot-'+i);\n dotElement.onclick = function(){\n showContentDot(i);\n }\n}", "title": "" }, { "docid": "7aace9ad936099d14232dc3c23c36bcb", "score": "0.61670053", "text": "function clickToChange() {\n for (let i = 0; i < 3; i++) {\n let dot = document.getElementsByClassName('dot')[i]\n let visual = document.getElementsByClassName('visual')[i]\n dot.addEventListener('click', () => {\n presetStyle()\n dot.style.backgroundColor = 'black'\n visual.style.zIndex = '100'\n visual.style.opacity = '1'\n if (slideIndex < 2) {\n slideIndex = i + 1\n } else {\n slideIndex = 0\n }\n })\n }\n}", "title": "" }, { "docid": "b515a2358dd6f55b921186ef112f53e8", "score": "0.6124387", "text": "function toggleMultipleItems(e) {\n // const optionValue = e.srcElement.innerHTML.toLowerCase();\n const optionValue = e.target.id;\n const category = e.target.classList[1];\n // console.log(e.srcElement);\n // console.log(e.srcElement.classList[1]);\n // console.log(e.target.querySelector(\"circle\"));\n const imgItem = document.getElementById(`${category}-${optionValue}`);\n if (!imgItem.classList.contains(\"display\")) {\n imgItem.classList.add(\"display\");\n render();\n e.target.querySelector(\"circle\").style.stroke = `${darkPurpleColor}`;\n e.target.querySelector(\"circle\").style.strokeWidth = `3`;\n\n // console.log(document.getElementById(`fairy-${optionValue}`));\n } else {\n imgItem.classList.remove(\"display\");\n e.target.querySelector(\"circle\").style.stroke = ``;\n e.target.querySelector(\"circle\").style.strokeWidth = ``;\n render();\n }\n // console.log(document.getElementById(`${category}-${optionValue}`));\n}", "title": "" }, { "docid": "8cc580ae90bbb95603627abd8139d0ba", "score": "0.6082091", "text": "changeReleaseImages() {\n this.releaseImagesContainer.addEventListener('click', (e) => {\n this.changeCurrentImage(e);\n this.changeReleaseImageOpacity(e);\n this.changeCurrentReleaseLink(e);\n });\n }", "title": "" }, { "docid": "89c5adea5d78163ec1233625e0b08574", "score": "0.6024194", "text": "function Gallery(section) {\n this.container = section;\n this.imgList = section.querySelectorAll('.img');\n this.imgList = Array.from(this.imgList);\n console.log(this);\n\n this.container.addEventListener('click', function (e) {\n if (e.target.classList.contains('img')) {\n openModal(e.target, this.imgList);\n }\n }.bind(this));\n}", "title": "" }, { "docid": "dbf1b5a9181cabfe3647b96ef038a49a", "score": "0.60117346", "text": "function getGalleryImages($gallery){\n return $gallery.children('[rb-zoom-src]');\n }", "title": "" }, { "docid": "50f093cd3e57e1a303f602e42df66c18", "score": "0.6009017", "text": "function loadMainImages() {\nvar pg2 = document.getElementById('pg2');\n \n for (var i = 0; i < images.length; i++) {\n var anImage = document.createElement('img');\n anImage.setAttribute('src', images[i]);\n anImage.setAttribute('left', window.innerWidth);\n anImage.setAttribute('top', i*200);\n anImage.classList.add('mainImage');\n\n pg2.appendChild(anImage);\n DOMMainImages.push(anImage);\n anImage.addEventListener('click', function() {\n currentSection = \"aWork\";\n console.log(\"clicked\");\n });\n \n }\n}", "title": "" }, { "docid": "3626da0a5b1ada3da08d6a40baed3fc1", "score": "0.59523076", "text": "function gallery(){\n var tutteLeImmagini = document.images; //salvo tutte le immagini in questa variabile\n for(var i=0; i<tutteLeImmagini.length; i++){\n\n\ttutteLeImmagini[i].onclick = CambiaImmagine; //ogni volta che si clicca sull'immagine,chiama la funzione CambiaImmagine\n\n }\n}", "title": "" }, { "docid": "4e85e23dacf22277532c40256094d1c0", "score": "0.58901244", "text": "function setClickable5() {\r\n var tab = window.document.getElementById(\"lesFormes\").getElementsByTagName(\"g\")[0].children;\r\n for (var i=0, length = tab.length; i<length; i++) {\r\n tab[i].addEventListener(\"click\", clickable)\r\n }\r\n}", "title": "" }, { "docid": "4c73fa282901354de0da7f3ee39e1110", "score": "0.5862657", "text": "addListeners() {\n\t\tlet gallerySelectorIds = [\n\t\t{ containerId: \"#gallerySelector__1-container\", gallerySelectorId: \"#gallerySelector__1\"}, \n\t\t{ containerId: \"#gallerySelector__2-container\", gallerySelectorId: \"#gallerySelector__2\"}, \n\t\t{ containerId: \"#gallerySelector__3-container\", gallerySelectorId: \"#gallerySelector__3\"}, \n\t\t{ containerId: \"#gallerySelector__4-container\", gallerySelectorId: \"#gallerySelector__4\"}\n\t\t];\n\t\tgallerySelectorIds.forEach( ({ containerId, gallerySelectorId, galleryName }) => {\n\t\t\t$(containerId).hover(() => this.hoverIn(gallerySelectorId), () => this.hoverOut(gallerySelectorId));\n\t\t});\n\t}", "title": "" }, { "docid": "49baaa9059b44447e1d8ee3702c8166b", "score": "0.58218306", "text": "function initGallery(){\n console.trace('initGallery');\n let divGallery = document.getElementById('gallery');\n for ( let i = 1; i <= 7 ; i++){\n divGallery.innerHTML += `<img onclick=\"selectAvatar(event)\" \n class=\"avatar\" \n data-path=\"avatar${i}.png\"\n src=\"img/avatar${i}.png\">`;\n }\n}", "title": "" }, { "docid": "b9a9b7efc98057c0df57e9499b965231", "score": "0.58112603", "text": "function initGalleries() {\n for (let slideCounter = 0; slideCounter < galleries.length; slideCounter++) {\n let gallery = document.querySelector('#div' + slideCounter);\n\n // get the prev and next slide button elements of this gallery\n let nextSlide = gallery.querySelector('.next');\n let prevSlide = gallery.querySelector('.prev');\n\n nextSlide.addEventListener('click', event => {\n const grandMotherElId = event.target.parentElement.parentElement.id;\n const position = grandMotherElId.substring(3, grandMotherElId.length);\n\n slideIndex[position] += 1;\n showSlides(slideIndex[position], grandMotherElId);\n });\n\n prevSlide.addEventListener('click', event => {\n const grandMotherElId = event.target.parentElement.parentElement.id;\n const position = grandMotherElId.substring(3, grandMotherElId.length);\n\n slideIndex[position] -= 1;\n showSlides(slideIndex[position], grandMotherElId);\n });\n }\n showSlides();\n}", "title": "" }, { "docid": "e2e1d0667255c854c90567e11ed897f6", "score": "0.58029306", "text": "function pickedImg() { //the clicked img will be run every other time\n for ( var k = 0; k < imgShort.length; k +=2 ) {\n };\n function clicky(event) {\n var clicked1 = event.target.id;\n document.getElementById('img_box').addEventListener('click', clicky);\n }\n}", "title": "" }, { "docid": "e13062a881cb7c64aec6bd274a932244", "score": "0.57907987", "text": "function clickRegularViewFocusImg(e) {\n\n var clickedThing = e.target;\n\n // if clicked element is a single image or the focus img in a gallery\n if (clickedThing.classList.contains('clickme')) {\n\n // define imgToShow\n var imgToShow = clickedThing;\n\n // call NAMED lightbox function\n lightbox(imgToShow);\n\n // call NAMED function to populate lightbox dots\n populateLightboxDots(imgToShow);\n\n } // close if ('clickme')\n} // close function", "title": "" }, { "docid": "b65a50451d716bd2405428c2e8e00bed", "score": "0.5772713", "text": "function showAllGallery(){\n $('.galleryItem').toggleClass('galleryShowAll');\n offBtnEffects();\n}", "title": "" }, { "docid": "e8e98869cc00a24a22e085513a4e654e", "score": "0.5770877", "text": "updateGallery() {\n this.carouselArray.forEach(el => {\n el.classList.remove('gallery-item-1');\n el.classList.remove('gallery-item-2');\n el.classList.remove('gallery-item-3');\n el.classList.remove('gallery-item-4');\n el.classList.remove('gallery-item-5');\n });\n\n this.carouselArray.slice(0, 5).forEach((el, i) => {\n el.classList.add(`gallery-item-${i+1}`);\n });\n\n this.titleArray.forEach(el => {\n el.classList.remove('card-1');\n el.classList.remove('card-2');\n el.classList.remove('card-3');\n el.classList.remove('card-4');\n el.classList.remove('card-5');\n });\n\n this.titleArray.slice(0, 5).forEach((el, j) => {\n el.classList.add(`card-${j+1}`);\n })\n }", "title": "" }, { "docid": "2110811d5b230793ab9e210a079ee41b", "score": "0.57686174", "text": "function onClickSlider(e, sec = .2) {\n let id = e.target.id;\n for (let i = 0; i < imgSrcArr.length; i++) {\n if ((\"slider\" + `${i}`) === id) {\n let index = i;\n choiceOfStyles(sec, index)\n }\n }\n}", "title": "" }, { "docid": "64e232a10532f918cf07d6f73546b1a0", "score": "0.5739857", "text": "function slideshow() {\n\n // establish vars\n var galleryList = document.getElementsByClassName('gallery'); // find any/all galleries in the blogpost\n var screenWidth = window.innerWidth; // get screen width\n var galleryCaptionList = document.getElementsByClassName('gallerycaption');\n\n\n // --------------------------------------------------------------------------------\n // FOR ALL CAPTIONS WITHIN A GALLERY\n\n // hide all captions to start\n for (h = 0; h < galleryCaptionList.length; h++) {\n galleryCaptionList[h].style.display = \"none\";\n } // close h\n\n\n // --------------------------------------------------------------------------------\n // FOR ALL GALLERIES\n\n // for each gallery\n for (i = 0; i < galleryList.length; i++) {\n\n // all gallery-specific vars\n var galleryName = galleryList[i].getAttribute('id'); // declare the gallery's name, so it can be identified later vs other galleries on the page\n var arrowContainer = document.createElement('div');\n var placeholderBox = document.createElement('div');\n var dotsContainer = document.createElement('span');\n var figure = galleryList[i].firstElementChild.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var firstCaption = figure.lastElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // create advance/retreat arrows for each gallery\n galleryList[i].appendChild(arrowContainer);\n arrowContainer.setAttribute('class', 'arrowcontainer');\n arrowContainer.style.position = 'relative';\n arrowContainer.innerHTML = '<img src=\"https://curiositycoloredglasses.com/assets/images/sitewide/left-arrowhead.svg\" alt=\"retreat\" title=\"Previous image\" class=\"galleryarrows yellowhover\" data-retreatarrow>' + '<img src=\"https://curiositycoloredglasses.com/assets/images/sitewide/right-arrowhead.svg\" alt=\"advance\" title=\"Next image\" class=\"galleryarrows yellowhover\" data-advancearrow>' + '<img class=\"imgfullscreentoggle imgtofullscreen yellowhover\" title=\"View larger\" alt=\"View larger\" src=\"https://curiositycoloredglasses.com/assets/images/sitewide/to-full-screen.svg\">';\n\n // establish placeholder box to keep text after img at proper height\n galleryList[i].appendChild(placeholderBox);\n placeholderBox.style.position = 'relative';\n placeholderBox.style.top = '1.024rem'; // this size works for 1225+ only ...see if this can be styled with CSS and mediaqueries instead\n placeholderBox.setAttribute('id', 'placeholderbox');\n\n // create dots container for each gallery\n galleryList[i].appendChild(dotsContainer);\n dotsContainer.setAttribute('class', 'dotcontainer');\n dotsContainer.setAttribute('id', 'regviewdotcontainer');\n dotsContainer.style.position = 'relative';\n\n // show first slide's caption, if it has one\n if (firstCaption.hasAttribute('data-galleryfigcaption')) {\n firstCaption.style.display = \"block\";\n }\n\n // if the first slide has a caption & the screen is less than 1225px wide\n if ((firstCaption.hasAttribute('data-galleryfigcaption')) && (screenWidth < 1225)) {\n\n // if there is a caption, set the <figure> element as the placeholder box's height (just the height of the <figure> element)\n placeholderBox.style.height = 'calc(' + figure.offsetHeight + 'px)';\n\n } else {\n\n // add some extra spacing if 1225+ (caption will be in edgeling, not below img) or if there is no caption (therefore not caption below img regardless of screenwidth)\n placeholderBox.style.height = 'calc(1.072rem + ' + figure.offsetHeight + 'px)';\n }\n\n\n // --------------------------------------------------------------------------------\n // FOR ALL SLIDES WITHIN EACH GALLERY\n\n // for each slide within each gallery (but subtract 3 to keep from counting the arrowContainer, dotsContainer and placeholderBox as children)\n for (j = 0; j < (galleryList[i].children.length - 3); j++) { // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION (e.g. may need to be \"- 4\" instead) !!!\n\n // slide-specific vars\n var dot = document.createElement('span');\n var slide = galleryList[i].children; // <li> item (containing <figure>)\n\n // create dots + put dots into dots container (positioned later, once placeHolderBox and img heights established)\n dot.setAttribute('class', 'dot dotunfilled');\n dot.innerHTML = '<img src=\"https://curiositycoloredglasses.com/assets/images/sitewide/dot.svg\" alt=\"go to this slide\" class=\"dotimg dotimgunfilled\">';\n dotsContainer.appendChild(dot);\n dotsList = dotsContainer.children;\n dotsList[j].setAttribute('data-dot-index', (j));\n dotsList[j].setAttribute('data-galleryname', galleryName); // store the gallery name as an attribute so it can be pulled in a later function to find and declare the gallery\n\n // then override the first dot, to indicate it is the current dot/slide\n dotsList[0].setAttribute('class', 'dot');\n dotsList[0].innerHTML = '<img src=\"https://curiositycoloredglasses.com/assets/images/sitewide/dot-filled.svg\" alt=\"go to this slide\" class=\"dotimg dotimgfill\">';\n\n // position all slides' <li> elements horizontally (absolute) + add data-* attribute to recognize them as side slides if clicked on\n slide[j].setAttribute('class', 'image-list-item'); // used for excluding from regular text <li> visual treatments in text.css\n slide[j].setAttribute('data-slide-index', (j));\n slide[j].setAttribute('data-sideslide', '');\n slide[j].style.position = \"absolute\";\n\n // position slides at increments equal to the post text width + 1 margin\n if (screenWidth < 817) {\n slide[j].style.left = 'calc(85.714vw * ' + j + ')';\n } else {\n slide[j].style.left = 'calc(700px * ' + j + ')';\n }\n\n // position <figure> element vertically (relative) within <li> element, so it can be even with top of first slide\n slide[j].firstElementChild.style.position = \"relative\"; // styling <figure> to be relatively positioned within <li> which is absolutely positioned\n\n // set first slide up as \"current slide\"\n slide[0].removeAttribute('data-sideslide');\n slide[0].firstElementChild.style.top = '0'; // first slide's <figure> item\n slide[0].setAttribute('id', galleryName + '-current');\n\n // making current img clickable to open lightbox (in a different function), by adding \"clickme\" class\n slide[0].firstElementChild.firstElementChild.setAttribute('class', 'contentimage clickme'); // first slide's <img> element // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // make first slide's caption NOT have a white left edge (so it won't cover home glasses) but subsequent slides need the white left edge as a border with previous image behind, so this only applies to first image\n if (slide[0].firstElementChild.lastElementChild.hasAttribute('data-galleryfigcaption')) { // if it has the attribute, it's a <figcaption> // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n var firstGalleryCaption = slide[0].firstElementChild.lastElementChild; // <figcaption> // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n firstGalleryCaption.setAttribute('class', 'xs-textface caption gallerycaption whiteedge');\n }\n\n // position dotsContainer\n dotsContainer.style.top = 'calc(-' + (placeholderBox.offsetHeight - slide[0].firstElementChild.firstElementChild.offsetHeight) + 'px + 1.536rem)'; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // position arrows\n arrowContainer.style.top = 'calc(' + (slide[0].firstElementChild.firstElementChild.offsetHeight) + 'px + 1.024rem)'; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n arrowContainer.style.left = 0;\n\n } // close j\n } // close i\n\n // when page is refreshed, this removes the lightbox's #hash from the URL, since refreshing the page automatically also removes the lightbox view, so this syncs the URL back up with the view onscreen\n removeHashReturnScroll();\n\n} // close function", "title": "" }, { "docid": "16e26de524efa8d77857e8c5c35b7ada", "score": "0.57260996", "text": "function clickGalleryArrow(e) {\n\n var clickedThing = e.target;\n\n if (clickedThing.getAttribute('class') == ('galleryarrows yellowhover')) {\n\n var dotsContainer = clickedThing.parentNode.parentNode.lastElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var gallery = clickedThing.parentNode.parentNode; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var galleryName = gallery.getAttribute('id');\n var currentSlide = document.getElementById(galleryName + '-current');\n\n // get total number of slides in gallery; subtract 3 to prevent counting arrowContainer, dotsContainer, and placeholderBox\n var slideCount = gallery.children.length - 3; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION (e.g. may need to be \"- 4\" instead) !!!\n\n if (clickedThing.hasAttribute('data-advancearrow')) {\n\n // if current slide is not the last slide\n // (slideCount - 1) because the index starts at 0, not 1, so need to subtract 1 from count to match them up\n if (currentSlide.getAttribute('data-slide-index') != (slideCount - 1)) {\n\n // id'ing the next slide\n var clickedSideSlide = currentSlide.nextElementSibling; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n\n } else { // implied that advance arrow was clicked when last slide was current\n\n // id'ing the first slide\n var clickedSideSlide = currentSlide.parentNode.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n\n } // closing inner if/else statement\n\n } else { // implied that retreat arrow was clicked\n\n // if current slide is not the first slide\n if (currentSlide.getAttribute('data-slide-index') != 0) {\n\n // id'ing previous slide\n var clickedSideSlide = currentSlide.previousElementSibling; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n\n } else { // implied that retreat arrow was clicked when first slide was current\n\n // id'ing the last slide\n var clickedSideSlide = currentSlide.parentNode.lastElementChild.previousElementSibling.previousElementSibling.previousElementSibling;\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n\n } // closing inner if/else statement\n\n } // closing semi-outer if/else statement\n }\n}", "title": "" }, { "docid": "cf35656048e0e24c7faa848320577f22", "score": "0.5716639", "text": "function addImageEvents() {\n let images = document.querySelectorAll(\"#posters img\");\n \n for (let i = 0; i < images.length; i++) {\n images[i].addEventListener(\"click\", function (e) {\n var elem = e.target;\n let index = elem.dataset.index;\n player.src = movies.movieList[index].movUrl;\n player.poster = movies.movieList[index].postUrl;\n player.preload = \"metadata\";\n })\n }\n}", "title": "" }, { "docid": "a54c6f7b74fd8e7b4ab56e70f121b382", "score": "0.568905", "text": "function initGallery() {\n let divGallery = document.getElementById(\"gallery\");\n for (let i = 1; i <= 7; i++) {\n divGallery.innerHTML += `<img onclick=\"selectAvatar(event)\" \n class=\"avatar\" \n data-path=\"img/avatar${i}.png\"\n src=\"img/avatar${i}.png\">`;\n }\n}", "title": "" }, { "docid": "e678730a11e2be2131b49e59da24d263", "score": "0.568701", "text": "selectImageHandler() {\n\t\tconst {data, currentPhoto} = this.props,\n\t\t\timages = document.querySelectorAll('.gallery__photo-item');\n\n\t\tfor (let image of images) {\n\t\t\tconst id = +image.dataset.imageMinId;\n\n\t\t\tif (id === currentPhoto) {\n\t\t\t\timage.style.transform = 'translateY(-10px)';\n\t\t\t}\n\t\t\telse {\n\t\t\t\timage.style.transform = '';\n\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "45c61198392e0d186c6945fcfd807724", "score": "0.5686263", "text": "function news_photo() {\n\n\t$(\".canhcam-news-photo-1 .box-zoom\").lightGallery({\n\t\tthumbnail: true,\n\t\tselector: 'a'\n\t});\n\n\t// $('.canhcam-news-photo-1 .wrapper-gallery').each(function() {\n\t// \t$(this).click(function() {\n\t// \t\t$(this).find('.hidden a:first-child').trigger('click')\n\t// \t})\n\t// });\n}", "title": "" }, { "docid": "d5eb5a2c465cec26183a3be46ac74a9d", "score": "0.5682464", "text": "function galleryChangePicture(element) {\n var number;\n var gallery_container = element.parentNode;\n gallery_pictures = gallery_container.getElementsByClassName(\"gallery\")\n countPicture = gallery_pictures.length;\n for (var i = 0; i < countPicture; i++) {\n if (gallery_pictures[i] == element) {\n number = i; //define index of clicked picture\n break;\n }\n }\n for (j = 0; j < countPicture; j++) {\n gallery_pictures[j].style.display = \"none\"; //hide all picture\n }\n number++;\n if (number == countPicture) {\n number = 0;\n }\n gallery_pictures[number].style.display = \"block\" //show picture whith index number.\n}", "title": "" }, { "docid": "246e846435aa89de5c42fdd8ad1c4ef0", "score": "0.5681348", "text": "function showSlides(n, interactedGalleryId) {\n for (let slideCounter = 0; slideCounter < galleries.length; slideCounter++) {\n // current gallery id, for example \"div1\"\n const currentGalleryId = 'div' + slideCounter;\n\n // the current gallery within the loop\n let gallery = document.querySelector('#div' + slideCounter);\n\n // all the slides in this gallery\n let slides = gallery.querySelectorAll('.mySlides');\n\n // get the thumbnails of this gallery\n let thumbs = gallery.querySelectorAll('.demo');\n\n // only apply this rule when it's the currently interacted gallery\n // as in: I've pressed prev or next on this gallery\n if (interactedGalleryId === currentGalleryId && n > slides.length) {\n slideIndex[slideCounter] = 1;\n }\n\n // only apply this rule when it's the currently interacted gallery\n // as in: I've pressed prev or next on this gallery\n if (interactedGalleryId === currentGalleryId && n < 1) {\n slideIndex[slideCounter] = slides.length;\n }\n\n // set all slides to display 'none'\n for (let i = 0; i < slides.length; i++) {\n slides[i].style.display = 'none';\n }\n\n // set all thumbs from \" active\" to \"\"\n for (let i = 0; i < thumbs.length; i++) {\n thumbs[i].className = thumbs[i].className.replace(' active', '');\n }\n\n // grab the correct slide and set it to \"block\"\n slides[slideIndex[slideCounter] - 1].style.display = 'block';\n // grab the correct thumb and set it to \" active\"\n thumbs[slideIndex[slideCounter] - 1].className += ' active';\n }\n}", "title": "" }, { "docid": "da8c660a692f28df7127a5d3f9bac5fc", "score": "0.56662756", "text": "function createAnimListeners() {\n let toAnimate = document.querySelectorAll(\".toAnimate\");\n\n // go over all animated divs and add scroll-point\n // and listeners for enter and exit screen\n for (let i = 0; i < toAnimate.length; i++) {\n const element = toAnimate[i];\n element.classList.add(\"scroll-point\");\n element.classList.remove(\"toAnimate\");\n element.addEventListener(\"viewenter\", animate);\n element.addEventListener(\"viewout\", resetAnimation);\n }\n\n let imgDiv = document.querySelectorAll(\".switch-img\");\n // go over all switching images divs and add enter screen listener\n for (let i = 0; i < imgDiv.length; i++) {\n const element = imgDiv[i];\n element.classList.add(\"scroll-point\");\n element.addEventListener(\"viewenter\", switchImgTimer);\n }\n}", "title": "" }, { "docid": "3feb154e37aa15bc8ddf72d6eec9fb2b", "score": "0.565978", "text": "function popGallery(numImgs) {\n\n}", "title": "" }, { "docid": "6174cbcb2823abb2e815603143302cb9", "score": "0.5644316", "text": "function startGalleryTwo() {\n \n // let imgSrc = document.getElementsByTagName('img');\n let navEl = document.getElementById('nav').children;\n let imgContainer = document.getElementById('option2').children[0].children;\n \n for(let i = 0; i < imgMainArr.length; i++) {\n navEl[i].style.background = 'url(\"' + imgMainArr[i] + '\") no-repeat';\n navEl[i].style.backgroundPosition = 'center';\n navEl[i].style.backgroundSize = '75px';\n }\n \n for(let i = 0; i < imgContainer.length; i++) {\n imgContainer[i].removeAttribute('style');\n }\n return false;\n }", "title": "" }, { "docid": "51098b3c19c0775457332be43e43ca29", "score": "0.56370676", "text": "function requirement3() {\n var imgs = document.querySelectorAll(\"div#top>img , div#middle>img\");\n for (let i = 0; i < imgs.length; ++i) {\n imgs[i].ondblclick = doubleClickOnImg;\n }\n}", "title": "" }, { "docid": "b5c7f0c7fb972272cade0ced302d8304", "score": "0.56249166", "text": "function gallery_click(){\n $(\".gallery_filter li\").on('click',function(){\n $(\".gallery_filter li\").removeClass(\"active\");\n $(this).addClass(\"active\");\n\n var selector = $(this).attr(\"data-filter\");\n $(\".grid_gallery_item_inner, .cobage_g_masonary\").isotope({\n filter: selector,\n animationOptions: {\n duration: 450,\n easing: \"linear\",\n queue: false,\n }\n });\n return false;\n });\n }", "title": "" }, { "docid": "a88367925fdb24b92889fe35729c48df", "score": "0.56087184", "text": "function selectOtherSlide(e) {\n\n var clickedThing = e.target;\n\n // <li> element, if clickedThing was a side slide's <img>\n var clickedThingGrandparent = clickedThing.parentNode.parentNode; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n if (clickedThingGrandparent.hasAttribute('data-sideslide')) {\n\n var imgToShow = clickedThing;\n\n // declare variables needed for named function\n var clickedSideSlide = clickedThingGrandparent;\n var dotsContainer = clickedSideSlide.parentNode.lastElementChild;// !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var gallery = clickedSideSlide.parentNode;// !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n var galleryName = gallery.getAttribute('id');\n var currentSlide = document.getElementById(galleryName + '-current');\n\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n\n } // close if\n} // close function", "title": "" }, { "docid": "0ad3292824306c8c27203db0da6c3d5e", "score": "0.5580669", "text": "function setClickable7() {\r\n var tab = window.document.getElementsByTagName(\"g\")[0].children;\r\n for (var i=0, length = tab.length; i<length; i++) {\r\n tab[i].addEventListener(\"click\", clickable2)\r\n }\r\n }", "title": "" }, { "docid": "ef3d697cd6ed71b89769033b8f1b4fab", "score": "0.557933", "text": "function tutorial() {\n $('.tutorial nav img:first-of-type').hover(function(){\n $('.tutorial_slides img').attr('src', 'image/tutorial_1.svg');\n });\n\n $('.tutorial nav img:nth-of-type(2)').hover(function(){\n $('.tutorial_slides img').attr('src', 'image/tutorial_2.svg');\n });\n\n $('.tutorial nav img:nth-of-type(3)').hover(function(){\n $('.tutorial_slides img').attr('src', 'image/tutorial_3.svg');\n });\n} // end of function tutorial", "title": "" }, { "docid": "577137ca890aee6e07356dcf55f28c96", "score": "0.5569255", "text": "function addClick(){\n\tfor(var i = 0; i < images.length; i++){\n\t\timages[i].addEventListener(\"click\", gameNotStarted);\n\t}\n}", "title": "" }, { "docid": "29353874d8abdd8074c2dcbddf63b4d2", "score": "0.5566765", "text": "function clickEffect() {\n takePic.forEach(pic => {\n var effect = dropMenu.value;\n if (effect === 'sepia') {\n pic.classList = 'thumbs-item';\n pic.classList.add('sepia');\n }\n if (effect === 'grayscale') {\n pic.classList = 'thumbs-item';\n pic.classList.add('grayscale');\n }\n if (effect === 'invert') {\n pic.classList = 'thumbs-item';\n pic.classList.add('invert');\n }\n if (effect === '') {\n pic.classList = 'thumbs-item';\n }\n });\n\n}", "title": "" }, { "docid": "c6731b2fe8829b3b7078435e36c5e486", "score": "0.5559979", "text": "function lightboxDots(e) {\n\n var clickedThing = e.target;\n var clickedThingParent = clickedThing.parentNode; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var clickedThingGrandparent = clickedThingParent.parentNode; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n if (clickedThingGrandparent.getAttribute('id') == 'lightboxdotcontainer') {\n\n var clickedLightboxDot = clickedThingParent;\n\n // declare vars for advanceOrRetreat function\n // mine data-* attribute from dot to get current gallery's name\n var galleryName = clickedLightboxDot.getAttribute('data-galleryname');\n var gallery = document.getElementById(galleryName);\n var dotsContainer = gallery.lastElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var clickedIndex = clickedLightboxDot.getAttribute('data-dot-index');\n var currentSlide = document.getElementById(galleryName + '-current');\n\n\n var currentCaptionDuringLightbox = currentSlide.firstElementChild.lastElementChild.previousElementSibling;\n\n // find the current slide's index\n var currentIndex = currentSlide.getAttribute('data-slide-index');\n\n // if the reg view current slide has a caption && if the clicked dot is NOT the current dot, hide the caption\n if (currentCaptionDuringLightbox.hasAttribute('data-galleryfigcaption')\n && (clickedIndex != currentIndex)) {\n currentCaptionDuringLightbox.style.display = \"none\";\n }\n\n // for loop to be able to define clickedSideSlide, based on currentDotIndex\n for (l = 0; l < dotsContainer.children.length; l++) { // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // find slide with matching index to current dot\n if (clickedIndex == gallery.children[l].getAttribute('data-slide-index')) { // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n var clickedSideSlide = gallery.children[l]; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // calling NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n\n } // close if\n } // close l\n\n // all functionality for building lightbox upon lightbox dot click\n var dotsLightboxContainer = clickedThingGrandparent;\n\n // for loop to be able to define imgToShow, based on clickedLightboxDot\n for (m = 0; m < dotsLightboxContainer.children.length; m++) { // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // find slide with matching index to current dot\n if (gallery.children[m].getAttribute('data-slide-index') == clickedLightboxDot.getAttribute('data-dot-index')) { // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var imgToShow = gallery.children[m].firstElementChild.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // remove current lightbox\n var currentLightbox = document.getElementById('singlelightbox');\n currentLightbox.parentNode.removeChild(currentLightbox); // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // call NAMED lightbox function\n lightbox(imgToShow);\n\n // call NAMED function to populate lightbox dots (defined in lightbox.js)\n populateLightboxDots(imgToShow);\n\n } // close if\n } // close m\n } // close if\n} // close function", "title": "" }, { "docid": "4cd30093f0482671fb56b155c26496ae", "score": "0.5557543", "text": "function addClickEvents() {\n //Iterate through each elements\n options.forEach((element, index) => {\n element.addEventListener('click', playGame);\n });\n}", "title": "" }, { "docid": "58cad067f0f3203d10be241d3aa73f24", "score": "0.55465335", "text": "function gallery(id){\n $(id + '-link').on('click', function(e){\n e.preventDefault();\n $('#all-galleries').toggleClass('hidden');\n $(id).toggleClass('hidden');\n });\n $('.all-galleries-link').on('click', function(e){\n e.preventDefault();\n $('#all-galleries').toggleClass('hidden');\n $(id).toggleClass('hidden');\n });\n}", "title": "" }, { "docid": "e4e96b47f2eef041f2060a67418ec30a", "score": "0.5545553", "text": "function addAnimations() {\n images.forEach((element) => {\n element.classList.add('animation');\n })\n\n}", "title": "" }, { "docid": "25893465a86d6727c496c362e8d1c6f9", "score": "0.55432767", "text": "function oneOpenedAnotherClicked(el, contentHeights, theIc, icons_btns, clickedContentArr, contents_box) {\n console.log(el, contentHeights, theIc, icons_btns, clickedContentArr, contents_box);\n $(icons_contents).each(function(){\n $(this).stop();\n\n })\n for (i = 0; i < icons_btns.length; i++) {\n icons_btns[i].classList.remove(\"active_icon\");\n }\n $(el.target).addClass(\"active_icon\");\n\n $(\"#\" + clickedContentArr[0]).css({\n opacity: \"0\"\n })\n\n $(contents_box).css({\n height: contentHeights[theIc - 1],\n maxHeight: contentHeights[theIc - 1]\n })\n $(\"#\" + clickedContentArr[0]).css({\n // transition: \"max-height .3s ease-in-out opacity 1s ease-in-out\",\n maxHeight: 0\n })\n $(\"#\" + theIc).css({\n transition: \"max-height 0s ease-in-out, opacity .35s ease-in-out\",\n maxHeight: contentHeights[theIc - 1],\n })\n $(\"#\" + theIc).css({\n // transition: \"opacity 1s ease-in-out\",\n opacity: \"1\",\n })\n }", "title": "" }, { "docid": "22cffcf29096215ac9407029d8ec6ee6", "score": "0.5538378", "text": "getCreateGalleryButtonAndClick() {\r\n return cy.get('.mr-auto > :nth-child(3) > .nav-link').click()\r\n }", "title": "" }, { "docid": "47fe06e617114bb6568e85a09dd9ed16", "score": "0.5535953", "text": "function gallery(){\n\t\t$('.gallery-bnt-1').on('click', function(){\n\t\t\t$('.small-image').removeClass('hide-html');\n\t\t});\n\t\t$('.gallery-bnt-2').on('click', function(){\n\t\t\t$('.small-image').addClass('hide-html');\n\t\t\t$('.meat').removeClass('hide-html');\n\t\t});\n\t\t$('.gallery-bnt-3').on('click', function(){\n\t\t\t$('.small-image').addClass('hide-html');\n\t\t\t$('.fish').removeClass('hide-html');\n\t\t});\n\t\t$('.gallery-bnt-4').on('click', function(){\n\t\t\t$('.small-image').addClass('hide-html');\n\t\t\t$('.dessert').removeClass('hide-html');\n\t\t});\n\t\t$('.gallery-bnt-5').on('click', function(){\n\t\t\t$('.small-image').addClass('hide-html');\n\t\t\t$('.veg').removeClass('hide-html');\n\t\t});\n\t\t// ENLARGE AND TOGGLE EACH GALLERY IMAGE\n\t\t$('.inspect-image span').on('click', function(){\n\t\t\t$(this).parent().parent().prev().removeClass('hide-html');\n\t\t\t$(this).parent().parent().prev().prev().removeClass('hide-html');\n\t\t});\n\t\t$('.remove-image').on('click', function(){\n\t\t\t$(this).next().addClass('hide-html');\n\t\t\t$(this).addClass('hide-html');\n\t\t});\t\t\n\t}", "title": "" }, { "docid": "0c29a616f8153b3700dae942420c8725", "score": "0.55297583", "text": "animate() {\n clickAnimation(\"#miracle_div\", this.target);\n }", "title": "" }, { "docid": "979e091cf53f679a20b8cbdc3e32ce55", "score": "0.5529056", "text": "function galleryTabs() {\n var tabs = document.querySelector('.btn-list ul');\n var tabImages = document.querySelector('.gallery-tab');\n tabs.addEventListener('click', function (e) {\n var btn = e.target;\n var btnList = document.querySelectorAll('.btn-list .btn');\n var index = 0;\n if (btn.classList.contains('btn-primary')) {\n return;\n }\n else if (btn.classList.contains('btn')) {\n for (var i = 0; i < btnList.length; i++) {\n btnList[i].classList.remove('btn-primary');\n }\n btn.classList.add('btn-primary');\n index = btn.dataset.galleryTab;\n }\n //fix span target in btn\n if (btn.parentElement.classList.contains('btn-primary')) {\n return;\n }\n else if (btn.parentElement.classList.contains('btn')) {\n for (var i = 0; i < btnList.length; i++) {\n btnList[i].classList.remove('btn-primary');\n }\n btn.parentElement.classList.add('btn-primary');\n index = btn.parentElement.dataset.galleryTab;\n }\n var imgList = document.querySelectorAll('.gallery-tab>[data-gallery-tab]');\n var a;\n for (var i = 0; i < imgList.length; i++) {\n a = imgList[i].getAttribute('data-gallery-tab');\n if (a == index) {\n imgList[i].classList.add('show');\n imgList[i].classList.remove('hide');\n }\n else {\n imgList[i].classList.remove('show');\n imgList[i].classList.add('hide');\n }\n }\n });\n}", "title": "" }, { "docid": "79ea9718898e02192b0d69442332210c", "score": "0.552098", "text": "function displayLinks() {\n $('[data-type=gallery] .image').each(function(index, item) {\n const link = $('a', item.parentNode);\n if (!link.get(0)) return;\n\n item = $(item);\n item.addClass('clickable');\n item.data('href', link.attr('href'));\n item.on('click', goto_article);\n });\n\n function goto_article(event) {\n let el = event.currentTarget;\n window.location = $(el).data('href');\n }\n}", "title": "" }, { "docid": "839e5557400a29c7b22f6c5729b74523", "score": "0.55209535", "text": "function createListeners() {\n\t\tDOMElement.querySelector(\".view-gallery\").addEventListener(\"click\", function(e) {onViewGalleryClicked(e);});\n\t}", "title": "" }, { "docid": "f7d8e2fcfdcbefe590b5daaf16096fc8", "score": "0.5503923", "text": "function galleryBtns() {\n let galleryButtons = document.querySelector('.gallery-buttons');\n let likeBtn = document.createElement('div');\n let saveBtn = document.createElement('div');\n likeBtn.classList.add('gif-expand-like-btn');\n saveBtn.classList.add('gif-expand-save-btn');\n galleryButtons.append(likeBtn, saveBtn);\n likeBtn.addEventListener('click', () => addFavorite(gif));\n saveBtn.addEventListener('click', () => downloadGif(url));\n}", "title": "" }, { "docid": "a6150c2e3b6133c7093cffc65d66e23b", "score": "0.55004084", "text": "function getClickedImage() {\n \"use strict\";\n var mIC; //short for miscImageCounter\n if (document.getElementById(\"marbleCircle\")) {\n list = document.getElementById(\"marbleCircle\");\n item = $(list.lastChild);\n \n if ($(item).is('img')) {\n $(list.lastChild).remove();\n }\n for (mIC = 0; mIC < miscImageHolder.length; mIC++) {\n if ($(miscImageHolder[mIC]).attr(\"alt\") === $(item).attr(\"alt\")) {\n $(miscImageHolder[mIC]).parent().parent().addClass(\"reveal\");\n } else {\n $(miscImageHolder[mIC]).parent().parent().addClass(\"hide\");\n }\n }\n placeCenterMaterial();\n }\n}", "title": "" }, { "docid": "c9a83f98c420fcf58aedd13c3b21097d", "score": "0.54977894", "text": "function onThumbnailsClick(e) {\n\t\t\t\te = e || window.event;\n\t\t\t\te.preventDefault ? e.preventDefault() : e.returnValue = false;\n\n\t\t\t\tvar eTarget = e.target || e.srcElement;\n\n\t\t\t\t// find root element of slide\n\t\t\t\tvar clickedListItem = closest(eTarget, function(el) {\n\t\t\t\t\treturn (el.tagName && el.tagName.toUpperCase() === 'FIGURE');\n\t\t\t\t});\n\n\t\t\t\tif(!clickedListItem) { return; }\n\n\t\t\t\tvar index = parseInt(clickedListItem.getAttribute('data-slide-index'));\n\t\t\t\tif(index >= 0) {\n\t\t\t\t\telements.addClass(elements.find('.js-img-overlay', clickedListItem)[0], 'animate-out');\n\t\t\t\t\telements.addClass(header, 'is-gallery');\n\n\t\t\t\t\twindow.setTimeout(function(){\n\t\t\t\t\t\telements.addClass(header, 'delay--5');\n\t\t\t\t\t\topenPhotoSwipe( index, galleryElements[0] );\n\t\t\t\t\t}, 400);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}", "title": "" }, { "docid": "0805f2c1a60f15258fe10f76bb696b32", "score": "0.549529", "text": "function setonclick(){\n imgArray[0].onclick = function onclick(event) {currentSlide(pullNum(imgArray[0].src)) } \n imgArray[1].onclick = function onclick(event) {currentSlide(pullNum(imgArray[1].src)) } \n imgArray[2].onclick = function onclick(event) {currentSlide(pullNum(imgArray[2].src)) } \n imgArray[3].onclick = function onclick(event) {currentSlide(pullNum(imgArray[3].src)) } \n imgArray[4].onclick = function onclick(event) {currentSlide(pullNum(imgArray[4].src)) } \n imgArray[5].onclick = function onclick(event) {currentSlide(pullNum(imgArray[5].src)) } \n}", "title": "" }, { "docid": "1eea96255d8eabcfa8c230d005fa6e22", "score": "0.5491442", "text": "function dotToSlideOne() {\r\n slide1Image.className = slide2Image.className = slide3Image.className = \"hero-image\";\r\n blobBackgrounds.style.opacity = 1;\r\n toOne();\r\n}", "title": "" }, { "docid": "c30e173855c09e0bac1d446ac8e8a5a8", "score": "0.54884124", "text": "function slides() {\n\n return $( '.gallery' ).find( 'img' );\n\n }", "title": "" }, { "docid": "35f8541281d11b71e235bd2507ed750f", "score": "0.5488272", "text": "setup() {\n\t\tthis.mediaGalleries.forEach( gallery => {\n\t\t\tconst featuredImgContainer = gallery.querySelector( '.media-img' );\n\t\t\tconst modalButton = gallery.querySelector( '.js-modal-button' );\n\t\t\tconst modalContentContainer = gallery.querySelector( '.js-modal-content' );\n\t\t\tconst previews = gallery.querySelectorAll( '.media-preview' );\n\n\t\t\tpreviews.forEach( ( preview, index ) => {\n\t\t\t\tif ( 0 === index ) {\n\t\t\t\t\tif ( preview.classList.contains( 'is-video' ) ) {\n\t\t\t\t\t\tmodalButton.style.display = 'block';\n\t\t\t\t\t\tmodalContentContainer.innerHTML = preview.querySelector( '.video-content' ).innerHTML;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpreview.addEventListener( 'click', ( event ) => {\n\t\t\t\t\tconst { target } = event;\n\n\t\t\t\t\tpreviews.forEach( notSelected => {\n\t\t\t\t\t\tnotSelected.classList.remove( 'selected' );\n\t\t\t\t\t});\n\n\t\t\t\t\ttarget.classList.add( 'selected' );\n\t\t\t\t\tfeaturedImgContainer.src = target.querySelector( '.fullsize' ).src;\n\t\t\t\t\tmodalButton.style.display = 'none';\n\t\t\t\t\tif ( target.classList.contains( 'is-video' ) ) {\n\t\t\t\t\t\tmodalButton.style.display = 'block';\n\t\t\t\t\t\tmodalContentContainer.innerHTML = target.querySelector( '.video-content' ).innerHTML;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}", "title": "" }, { "docid": "871367a416bee7582c2ba3c82624869f", "score": "0.54856664", "text": "function loopElements(loop) {\n if(loop == 1) {\n let colorClick = document.querySelectorAll('.colorBtn');\n for(var i = 0; i < colorClick.length; i++) {\n colorClick[i].addEventListener('click', colorDisplay);\n }\n } else if(loop == 2) {\n let iconClick = document.querySelectorAll('.icons');\n for(var i = 0; i < iconClick.length; i++) {\n iconClick[i].addEventListener('click', iconDisplay);\n }\n }\n}", "title": "" }, { "docid": "145b868200aaab029df3311de6254bd1", "score": "0.54836446", "text": "function selectorTut() {\n console.log(\"selectorTuT:\");\n document.querySelector(\".classNames\").classList.remove(\"hidden\"); \n // Create variables and let them stand for the attributes\n // changes to that variable apllyes on the original attributes!!!\n \n // find first element with the searched class / id...\n //...let the variable stand for the selected html/css instance\n const DOTCLASSNAME = document.querySelector(\".classname\");\n //changes the html/css by changing the variable, adding newClassname\n DOTCLASSNAME.className = \"classname newClassname\";\n console.log(document.querySelector(\".newClassname\"));\n console.log(\"----------------\");\n \n var tagId = document.querySelector(\"#originalId\");\n tagId.innerHTML = \"changed #Id content\";\n console.log(tagId);\n console.log(\"-----------------\");\n \n // select second/third etc element with classname\n const SECOND = document.querySelectorAll(\".classname\");\n console.log(SECOND);\n SECOND[1].innerHTML = \"changed second class element\";\n console.log(SECOND[1]);\n console.log(\"-----------------\");\n console.log(\"-----------------\");\n \n // Nesting\n const IMAGEFIGURE = document.querySelector(\".moon-pic-figure\");\n const IMAGE = IMAGEFIGURE.querySelector(\"img\");\n \n console.log(IMAGEFIGURE);\n console.log(IMAGE);\n \n }", "title": "" }, { "docid": "75d263b17da270d6144438c877d70cc6", "score": "0.54823166", "text": "function clickToFullScreenButton(e) {\n\n var clickedThing = e.target;\n\n // if clicked element is a single image or the focus img in a gallery\n if (clickedThing.classList.contains('imgtofullscreen')) {\n\n var toFullScreen = clickedThing;\n\n // if it is part of a single img (non-gallery)\n if (toFullScreen.previousElementSibling.classList.contains('clickme')) {\n\n // define imgToShow\n var imgToShow = toFullScreen.previousElementSibling;\n\n // call NAMED lightbox function\n lightbox(imgToShow);\n\n // call NAMED function to populate lightbox dots\n populateLightboxDots(imgToShow);\n\n } else { // it must be part of a gallery\n\n var currentGallery = toFullScreen.parentNode.parentNode;\n var galleryName = currentGallery.getAttribute('id');\n\n for (i = 0; i < (currentGallery.children.length - 3); i++) {\n\n if (currentGallery.children[i].getAttribute('id') == galleryName + '-current') {\n\n // define imgToShow\n var imgToShow = currentGallery.children[i].firstElementChild.firstElementChild;\n\n // call NAMED lightbox function\n lightbox(imgToShow);\n\n // call NAMED function to populate lightbox dots\n populateLightboxDots(imgToShow);\n\n }\n\n } // close for loop\n\n }\n\n } // close if ('clickme')\n} // close function", "title": "" }, { "docid": "5fdfd38a232e707c2781e77bfba93001", "score": "0.54795897", "text": "clickCercle(elm){\r\n\r\n let index = this.indexImageActive()\r\n let indexClick = this.indexCercle(elm)\r\n\r\n this.images[index].classList.remove('active')\r\n this.cercles[index].classList.remove('active-cercle')\r\n\r\n this.images[indexClick].classList.add('active')\r\n this.cercles[indexClick].classList.add('active-cercle')\r\n\r\n\r\n }", "title": "" }, { "docid": "bc6dd34266b3e67f52fc39cf587118c6", "score": "0.54735595", "text": "function carouselsBlog() {\n var $carouselGalleryText = $('.carusel-gallery-text').flickity({\n cellAlign: \"left\",\n contain: true,\n wrapAround: true,\n draggable: false,\n prevNextButtons: false\n });\n var $carouselGalleryPhoto = $('.carusel-gallery-photo').flickity({\n cellAlign: \"left\",\n contain: true,\n wrapAround: true,\n draggable: false,\n pageDots: false,\n prevNextButtons: false\n });\n $('.carusel-gallery-tabs').on( 'click', 'li', function() {\n var index = $(this).index();\n $carouselGalleryText.flickity( 'select', index );\n $carouselGalleryPhoto.flickity( 'select', index );\n $(this).addClass('active').siblings().removeClass('active');\n return false;\n });\n}", "title": "" }, { "docid": "54145460c1b68f41f168c003f80f8b19", "score": "0.5470028", "text": "function lightboxArrows(e) {\n\n var clickedThing = e.target;\n\n if (clickedThing.getAttribute('class') == ('galleryarrows lightboxarrows yellowhover')) {\n\n var clickedLightboxArrow = clickedThing;\n\n // declare vars for advanceOrRetreat function\n // mine data-* attribute from last dot right before arrows to get current gallery's name\n var galleryName = clickedLightboxArrow.parentNode.previousElementSibling.firstElementChild.getAttribute('data-galleryname'); // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var gallery = document.getElementById(galleryName);\n var dotsContainer = gallery.lastElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n var currentSlide = document.getElementById(galleryName + '-current');\n\n var currentCaptionDuringLightbox = currentSlide.firstElementChild.lastElementChild.previousElementSibling;\n\n // find the current slide's index\n var currentIndex = currentSlide.getAttribute('data-slide-index');\n\n // if the reg view current slide has a caption\n if (currentCaptionDuringLightbox.hasAttribute('data-galleryfigcaption')) {\n currentCaptionDuringLightbox.style.display = \"none\";\n }\n\n // all functionality for building lightbox upon lightbox arrow click\n var dotsLightboxContainer = clickedThing.parentNode.previousElementSibling; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n\n // get total number of slides in gallery; subtract 3 to prevent counting arrowContainer, dotsContainer, and placeholderBox\n var slideCount = gallery.children.length - 3; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION (e.g. may need to be \"- 4\" instead) !!!\n\n var currentLightbox = document.getElementById('singlelightbox');\n\n if (clickedThing.hasAttribute('data-advancelightboxarrow')) {\n\n // if current img is not the last one in gallery\n // (slideCount - 1) because the index starts at 0, not 1, so need to subtract 1 from count to match them up\n if (currentSlide.getAttribute('data-slide-index') != (slideCount - 1)) {\n\n // id'ing the next slide\n var clickedSideSlide = currentSlide.nextElementSibling; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n // define imgToShow for NAMED functions called within the following nested if-statements\n var imgToShow = clickedSideSlide.firstElementChild.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // remove current lightbox\n currentLightbox.parentNode.removeChild(currentLightbox); // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // call NAMED lightbox function\n lightbox(imgToShow);\n // call NAMED function to populate lightbox dots (defined in lightbox.js)\n populateLightboxDots(imgToShow);\n\n } else { // implied that advance arrow was clicked when last slide was current\n\n // id'ing the first slide\n var clickedSideSlide = currentSlide.parentNode.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // var clickedIndex = -(slideCount - 1);\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n var imgToShow = clickedSideSlide.firstElementChild.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // remove current lightbox\n currentLightbox.parentNode.removeChild(currentLightbox); // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // call NAMED lightbox function\n lightbox(imgToShow);\n // call NAMED function to populate lightbox dots (defined in lightbox.js)\n populateLightboxDots(imgToShow);\n\n } // closing inner if/else statement\n\n } else { // implied that retreat arrow was clicked\n\n // if current slide is not the first slide\n if (currentSlide.getAttribute('data-slide-index') != 0) {\n\n // id'ing previous slide\n var clickedSideSlide = currentSlide.previousElementSibling;\n // var clickedIndex = -1;\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n var imgToShow = clickedSideSlide.firstElementChild.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // remove current lightbox\n currentLightbox.parentNode.removeChild(currentLightbox);\n // call NAMED lightbox function\n lightbox(imgToShow);\n // call NAMED function to populate lightbox dots (defined in lightbox.js)\n populateLightboxDots(imgToShow);\n\n } else { // implied that retreat arrow was clicked when first slide was current\n\n // id'ing the last slide\n var clickedSideSlide = currentSlide.parentNode.lastElementChild.previousElementSibling.previousElementSibling.previousElementSibling; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // var clickedIndex = (slideCount - 1);\n var clickedIndex = clickedSideSlide.getAttribute('data-slide-index');\n // calls NAMED FUNCTION\n advanceOrRetreat(clickedSideSlide, dotsContainer, gallery, clickedIndex, galleryName, currentSlide);\n var imgToShow = clickedSideSlide.firstElementChild.firstElementChild; // !!! FULLSCREEN BUTTON MAY AFFECT THIS DOM NAVIGATION !!!\n // remove current lightbox\n currentLightbox.parentNode.removeChild(currentLightbox);\n // call NAMED lightbox function\n lightbox(imgToShow);\n // call NAMED function to populate lightbox dots (defined in lightbox.js)\n populateLightboxDots(imgToShow);\n\n } // closing inner if/else statement\n } // closing semi-outer if/else statement\n } // close if\n} // close function", "title": "" }, { "docid": "06148591d605365182750984aa42a49f", "score": "0.5465025", "text": "function selectAdvancedImage(event) {\n document.querySelectorAll(\".qwant-panel__content__img-container__element--active\")[0]\n .classList.remove(\"qwant-panel__content__img-container__element--active\");\n event.target.classList.add(\"qwant-panel__content__img-container__element--active\");\n}", "title": "" }, { "docid": "b4302d40cdefd3ca6a5a17221f202a48", "score": "0.5460082", "text": "function getAllInfoboxes(svgElement) {\n\n let infoboxes = svgElement.querySelectorAll('[id^=\"infobox\"]');\n let infoxbox1 = svgElement.querySelector(\"#point1\");\n\n // For EACH LOOP FOR \"2-9 INFOBOXES AND SEPERATE FOR THE FIRST ONE / ADD STYLING\n infoxbox1.classList.add(\"infoboxStyles\");\n infoxbox1.addEventListener(\"click\",(event) => {\n \n event.preventDefault();\n ModalClicked(infoxbox1); \n }); \n\n infoboxes.forEach(infobox => {\n console.log(\"Box\",infobox);\n\n infobox.classList.add(\"infoboxStyles\");\n\n infobox.addEventListener(\"click\",(event) => {\n \n event.preventDefault();\n ModalClicked(infobox); \n }); \n });\n\n EventhandleFunction();\n\n}", "title": "" }, { "docid": "cbfc1e9d8ea7abdba983a84daecd5eb5", "score": "0.5458031", "text": "function change_cagle_thumbs() {\r\n var images_changed = 0;\r\n\r\n main_content_div = document.getElementById('mainContent');\r\n div_array = main_content_div.getElementsByTagName('div');\r\n\r\n if (document.getElementById('bl_displayNoItemsBox') != null) {\r\n\t if (debug >= 3) GM_log(\"Found NoItemsBox\");\r\n\t add_click_listener('bl_displayNoItemsBox');\r\n }\r\n\r\n if (debug >= 3) GM_log(\"DIV tags found: \" + div_array.length);\r\n for (i = 0; i < div_array.length; i++) {\r\n\t var img_array = div_array[i].getElementsByTagName('img');\r\n\t for (ii = 0; ii < img_array.length; ii++) {\r\n\t if (debug >= 3) GM_log(\"Testing div # \" + i + \" image # \" + ii + \": \" + img_array[ii].src);\r\n\t // http://www.cagle.com/thumbs/100201/payne_200w.jpg\r\n\t if (img_array[ii].src.search(/www.cagle.com\\/thumbs/) != -1) {\r\n\t\t if (debug >= 2) GM_log(\"Found thumbnail image #: \" + ii);\r\n\t\t var pattern = /(\\d+)\\/([a-z]+)_\\w+.(jpg|gif)/i;\r\n\t\t var match = pattern.exec(img_array[ii].src);\r\n\r\n\t\t var date_pattern = /^\\d+/i;\r\n\t\t var date_folder = match[1];\r\n\r\n\t\t var author_pattern = /[a-z]+/i;\r\n\t\t var author = match[2];\r\n\r\n\t\t // http://www.cagle.com/working/100202/cole.jpg\r\n\t\t if ((date_folder == null) || (author == null)) {\r\n\t\t\t GM_log(\"ERROR detecting pattern: \" + match);\r\n\t\t } else {\r\n\t\t\t var new_src = 'http://www.cagle.com/working/' + date_folder + '/' + author + '.' + match[3];\r\n\t\t\t if (debug >= 2) GM_log(\"new src: \" + new_src);\r\n\t\t\t img_array[ii].src = new_src;\r\n\r\n\t\t\t img_array[ii].width = 600;\r\n\t\t\t images_changed++;\r\n\t\t }\r\n\t } else if (img_array[ii].src.search(/www.cagle.com\\/working/) != -1) {\r\n\t\t if (debug >= 2) GM_log(\"Found miniaturized image #: \" + ii);\r\n\t\t img_array[ii].width = 600;\r\n\t\t images_changed++;\r\n\t }\r\n\t }\r\n\t \r\n }\r\n\r\n if (images_changed > 0) {\r\n\t if (debug >= 2) GM_log(\"Images changed: \" + images_changed);\r\n }\r\n}", "title": "" }, { "docid": "09c71f784e89a8734e3504c8e13ff968", "score": "0.54518485", "text": "function clickEnlarge(num, index) {\n indexModal = index; \n \n const trendingModal = document.querySelectorAll('.modal-container');\n const trendingModalEl = trendingModal[0]; \n const path_trending = `https://api.giphy.com/v1/gifs/trending?api_key=${apiKey}&limit=${num}`; \n\n fetch (path_trending).then(function (res) { \n return res.json();\n }).then(function(json){\n //console.log(json.data[0].images.fixed_width.url);\n let resultsTrending = '';\n \n json.data.forEach(function(obj) {\n //console.log(obj);\n\n const url = obj.images.fixed_width.url;\n const width = obj.images.fixed_width.width;\n const title = obj.title;\n const height= obj.images.fixed_height.height;\n const user = obj.username;\n //To add strings\n \n resultsTrending += `<div class=\"mySlidesModal\">\n <div><img class=\"imgSize\" src=\"${url}\" alt=\"${title}\"><h5 id= \"titleModal\">Titulo:${title}<br><span id=\"userModal\">User:${user}</span></h5></div>\n <div class=\"modal-icon-layer\">\n <button class=\"icons-layer-modal\" onclick=\"clickDownload('${url}')\"><img src=\"assets/icon-download.svg\" onmouseleave=\"this.src='assets/icon-download.svg'\" onmouseover=\"this.src='assets/icon-download-hover.svg'\" alt=\"Descargar\"></button>\n <button class=\"icons-layer-modal\" onclick=\"clickLike('${url}', '${width}', '${title}', '${height}','${user}')\"><img src=\"assets/icon-fav.svg\" onmouseleave=\"this.src='assets/icon-fav.svg'\" onmouseover=\"this.src='assets/icon-fav-hover.svg'\" alt=\"Me Gusta\"></button> \n </div>\n </div>`;\n slideButtons = `<a class=\"prev2 arrowsModal\" onclick=\"plusSlideModal(-1)\">&#10094;</a>\n <a class=\"next2 arrowsModal\" onclick=\"plusSlidesModal(1)\">&#10095;</a>`;\n\n });\n \n //console.log(resultsTrending);\n trendingModalEl.innerHTML = resultsTrending + slideButtons; //to introduce it in html\n \n showTrendingModal(indexModal);\n\n }).catch(function(err) {\n console.log(err.message);\n });\n\n showModal();\n}", "title": "" }, { "docid": "c8aa770040d6c7321e56151f498a2ba9", "score": "0.54390436", "text": "function Initialize2()\n{\n const Slides = document.querySelectorAll('.slides1');\n const pages = document.querySelectorAll('section');\n let current=0;\n\n Slides.forEach((slide,index) => {\n slide.addEventListener('click', function(){\n changeDots(this);\n nextSlide(index);\n });\n });\n\n\n function changeDots(dot)\n {\n Slides.forEach(slide => {\n slide.classList.remove(\"active\");\n })\n\n dot.classList.add(\"active\");\n }\n\n function nextSlide(pageNumber)\n {\n const nextPage = pages[pageNumber];\n const currentPage = pages[current];\n\n const tl = new TimelineMax({defaults:{ease:\"power2.out\"}});\n\n tl.fromTo(currentPage , 0.8,{opacity:1,pointerEvents:\"all\"},{opacity:0,pointerEvents:\"none\"})\n .fromTo(nextPage,0.8,{opacity:0,pointerEvents:\"none\"},{opacity:1,pointerEvents:\"all\"},'-=0.4') \n\n current = pageNumber;\n }\n}", "title": "" }, { "docid": "a7ec4aa93d50d299fb1ea9b382661d20", "score": "0.5437267", "text": "function creatSlideOutListeners() {\n let slideOut = document.querySelectorAll(\".slide-out .tab\");\n for (let i = 0; i < slideOut.length; i++) {\n const element = slideOut[i];\n element.addEventListener(\"click\", openSlideOut);\n }\n}", "title": "" }, { "docid": "c1c6dd6a8a60816d82f5396be9cbc086", "score": "0.54312974", "text": "function toggleGallery(galleryItem){\n $('.galleryItem').removeClass('galleryDocLoad galleryShowAll');\n $('.'+ galleryItem +'Item').toggleClass('galleryItemActive');\n offBtnShowAll()\n gallEmptyCheck()\n}", "title": "" }, { "docid": "58fa23fdbdbc79f0f4a83bce2a9b4ced", "score": "0.5424508", "text": "function controlls_animation () {\n $('ul.gallery li').hover(function(){\n $('img',this).fadeToggle(1000);\n $(this).find('.gallery-controls').remove();\n $(this).append('<div class=\"well gallery-controls\">'+\n '<p><a href=\"#\" class=\"gallery-edit btn\"><i class=\"icon-edit\"></i></a> <a href=\"#\" class=\"gallery-delete btn\"><i class=\"icon-remove\"></i></a></p>'+\n '</div>');\n $(this).find('.gallery-controls').stop().animate({'margin-top':'-1'},400,'easeInQuint');\n },function(){\n $('img',this).fadeToggle(1000);\n $(this).find('.gallery-controls').stop().animate({'margin-top':'-30'},200,'easeInQuint',function(){\n $(this).remove();\n });\n });\n }", "title": "" }, { "docid": "dfa3e677255b72fa4456fca16cd3dd94", "score": "0.5418595", "text": "function randomGalleryChange() {\n var galleryImages = [firstImage, secondImage, thirdImage, fourthImage, fifthImage, sixthImage, seventhImage];\n\n galleryImages.sort(sortFunc);\n\n gallery.appendChild(galleryImages[0]);\n gallery.appendChild(galleryImages[1]);\n gallery.appendChild(galleryImages[2]);\n gallery.appendChild(galleryImages[3]);\n gallery.appendChild(galleryImages[4]);\n gallery.appendChild(galleryImages[5]);\n gallery.appendChild(galleryImages[6]);\n\n gallery.style.transitionTimingFunction = \"ease\";\n}", "title": "" }, { "docid": "fbc79103169521d6fdfaa28574a185bd", "score": "0.54184663", "text": "function showImagesGallery(array) {\n\n //Inicio las variables en la primera posicion para activar esta posicion\n let htmlContentToAppend = `<div div class=\"carousel-item active\"><img src=\"` + array[0] + `\" class=\"d-block w-100\" alt=\"\"></div>`;\n let htmlContentSlide = `<li data-target=\"#carouselExampleIndicators\" data-slide-to=\"0\" class=\"active\"></li>`;\n\n for (let i = 1; i < array.length; i++) {\n let imageSrc = array[i];\n\n htmlContentSlide += `<li data-target=\"#carouselExampleIndicators\" data-slide-to=\"` + i + `\" class=\"active\"></li>`\n\n htmlContentToAppend += `\n <div class=\"carousel-item\">\n <img src=\"` + imageSrc + `\" class=\"d-block w-100\" alt=\"\">\n </div> \n `\n }\n document.getElementById(\"slides\").innerHTML = htmlContentSlide;\n document.getElementById(\"carrusel\").innerHTML = htmlContentToAppend;\n\n\n}", "title": "" }, { "docid": "f433c28e4ef8a576090aa802d44663b9", "score": "0.5407597", "text": "function addListener(array) {\n array.forEach(function(thumb) {\n thumb.addEventListener(\"click\", function(event) {\n event.preventDefault();\n setImage(thumb);\n setCaption(thumb);\n });\n });\n}", "title": "" }, { "docid": "22febcd9813953d7a4a9222c57e60dd4", "score": "0.5404029", "text": "function videos_array_clicked(evnt) {\n if (evnt.target.tagName == 'IMG') { //This if is to be doubly sure an image was clicked\n player.pauseVideo();\n player.loadVideoById(playlist[evnt.target.video_index]);\n console.log(\"Currently Playing video: \" + playlist[evnt.target.video_index]);\n featured_image.style.display = \"none\";\n youtube_vid.style.display = \"block\";\n }\n current_featured_is_video = true;\n }", "title": "" }, { "docid": "66d7d489d9835584c11ec9bf8ae86bc9", "score": "0.5403785", "text": "function addListeners1(){\n for (let i = 0; i < talen.length; i++){\n talen[i].addEventListener('click', function(evt){\n if (hold == null) {\n camera.innerHTML += '<a-box id=\"js--hold\" class=\"js--talen js--interact\" color=\"'+ this.getAttribute(\"color\") + '\" height='+ this.getAttribute(\"height\") +' rotation=\"0 0 90\" position=\"2 -1 -2\" depth=\"0.1\" width=\"0.8\">'+ this.innerHTML + '</a-box>'\n hold = \"box\";\n console.log(\"true\");\n }\n });\n }\n }", "title": "" }, { "docid": "b24189a3d50ff1ce27bfe418a9665c3b", "score": "0.53946674", "text": "function imagesSlidWeOffer() {\n createElementsSlidWeOffer.CatWeOffer.src = CatWeOffer;\n createElementsSlidWeOffer.CatWeOffer.alt = 'catWeOffer';\n createElementsSlidWeOffer.CatWeOffer.classList.add('catWeOfffer');\n slid2.appendChild(createElementsSlidWeOffer.CatWeOffer);\n\n createElementsSlidWeOffer.MoonWeOffer.src = MoonWeOffer;\n createElementsSlidWeOffer.MoonWeOffer.alt = 'moon';\n createElementsSlidWeOffer.MoonWeOffer.classList.add('moonWeOfffer');\n slid2.appendChild(createElementsSlidWeOffer.MoonWeOffer);\n\n createElementsSlidWeOffer.Sun.src = Sun;\n createElementsSlidWeOffer.Sun.alt = 'Sun';\n createElementsSlidWeOffer.Sun.classList.add('sunWeOfffer');\n slid2.appendChild(createElementsSlidWeOffer.Sun);\n\n createElementsSlidWeOffer.BackgroundHome.src = BackgroundHome;\n createElementsSlidWeOffer.BackgroundHome.alt = 'BackgroundHome';\n createElementsSlidWeOffer.BackgroundHome.classList.add('homeWeOfffer');\n slid2.appendChild(createElementsSlidWeOffer.BackgroundHome);\n\n createElementsSlidWeOffer.Grass.src = Grass;\n createElementsSlidWeOffer.Grass.alt = 'Grass';\n createElementsSlidWeOffer.Grass.classList.add('grassWeOfffer');\n slid2.appendChild(createElementsSlidWeOffer.Grass);\n}", "title": "" }, { "docid": "6887e31394f1083edae4df081f19ed85", "score": "0.53913754", "text": "function slideshowGPhotoAlbums(a) {\n var albums_html = '';\n var albums_explore_btn = $('.h_ex_your_ph');\n\n\n if(albums_explore_btn.find('.list-albums-o').length) return albums_explore_btn.find('.list-albums-o').fadeIn();\n\n for(var i = 0; i < a.length; i++) {\n var _xkoe = a[i];\n albums_html += '<div id=\"sl-i-alb-' + _xkoe.id + '\" onclick=\"evstop(event);getUserSphotosFalbum(event,this,function(data,id){slideshowPhotosFromAlbum(data,id);});\" class=\"col-card __no-decor _novitrina ovr-menu_soh\">\\\n\t\t\t\t\t\t<div><div class=\"photo-sc_i_cover\">\\\n\t\t\t\t\t\t<div class=\"photo-sc_i_cnt __prw\">\\\n\t\t\t\t\t\t<a href=\"javascript:void(0)\" class=\"photo-sc_i_cnt_a\">\\\n\t\t\t\t\t\t<img class=\"photo-sc_i_cnt_a_img va_target\" src=\"/getPhoto?p=' + _xkoe.cover + '&sz=thumb\">\\\n\t\t\t\t\t\t<div class=\"col-card_ovr\"></div></a></div></div>\\\n\t\t\t\t\t\t<div class=\"photo-sc_grid_abt ellip\">\\\n\t\t\t\t\t\t<span class=\"o\" title=\"' + _xkoe.name + '\">' + _xkoe.name + '</span><span class=\"alb_count_pp\">' + _xkoe.count + ' photos</span></div></div></div>';\n }\n if(!albums_explore_btn.find('.list-albums-o').length) {\n\n albums_explore_btn.append('<div class=\"list-albums-o\" onclick=\"evstop(event);\"><div class=\"up_arr_st3\"></div><div class=\"nano albums_list-9q0\" ><div class=\"nano-content\">' + albums_html + '</div></div></div>');\n ga(\".list-albums-o .nano\").nanoScroller();\n ga(window).off('keyup.slideshow-dropdownhide').on('keyup.slideshow-dropdownhide', function(ev) {\n ev.preventDefault();\n ev.stopImmediatePropagation();\n if(ev.keyCode == 27)\n albums_explore_btn.find('.list-albums-o').fadeOut();\n });\n ga('body').off('click.slideshow-dropdownhide').on('click.slideshow-dropdownhide', function(e) {\n //e.preventDefault();\n albums_explore_btn.find('.list-albums-o').fadeOut();\n });\n }\n}", "title": "" }, { "docid": "9b02a78aa4d991682fd3084299d00f65", "score": "0.5380863", "text": "function func(e) {\r\n // console.log(e.target.parentNode.getAttribute('class'));\r\n var p = e.target\r\n while (p.className !== \"music_image\") {\r\n p = p.parentNode\r\n }\r\n // var change = p.querySelector('img').src;\r\n\r\n changePreview(p.id);\r\n }", "title": "" }, { "docid": "dd22a6782954fa379a516a96c2098b7a", "score": "0.53774935", "text": "function animationFallingBoxes() {\n\n document.querySelector(\"#playButton\").addEventListener(\"click\", () => {\n document.querySelector(\"#youWonPlaceholder\").innerHTML =\n \"YOU WON <span id='pointsPlaceholder'>30</span> POINTS\";\n\n document.querySelector(\"#FIRST\").classList.add(\"hide\");\n TweenLite.to(\"#playButton\", 1, {\n scale: 0.5\n });\n\n let whooshSound = document.querySelectorAll(\n \"#whooshSound0, #whooshSound1, #whooshSound2, #whooshSound3\"\n );\n let boxesWithHorses = document.querySelectorAll(\n \"#horse1, #horse2, #horse3, #horse4\"\n );\n\n for (let i = 0; i < boxesWithHorses.length; i++) {\n console.log(i);\n\n TweenLite.from(boxesWithHorses[i], 1, {\n delay: i / 2,\n y: \"-=519\",\n ease: Elastic.easeOut.config(0.5, 0.3),\n onStart: function() {\n console.log(\"play \" + i);\n whooshSound[i].play();\n //document.querySelector(\"#whooshSound0\").play();\n }\n });\n }\n document.querySelector(\"#SECOND\").classList.remove(\"hide\");\n document\n .querySelectorAll(\"#horse1, #horse2, #horse3, #horse4\")\n .forEach(element => {\n element.addEventListener(\"click\", event => {\n clickToBet(event);\n document.querySelector(\"#SECOND\").classList.add(\"hide\");\n document.querySelector(\"#THIRD\").classList.remove(\"hide\");\n\n TweenMax.to(\"#lets-race\", 1.4, {\n scale: 5,\n opacity: 0,\n transformOrigin: \"50% 50%\"\n });\n\n // document.querySelector(\"#lets-race\").addEventListener(\"click\", () => {\n // document.querySelector(\"#THIRD\").classList.add(\"hide\");\n // document.querySelector(\".cls-4-1\").classList.remove(\"hide\");\n // });\n });\n });\n });\n}", "title": "" }, { "docid": "ab1a3198e73ae125a523be2d178b8918", "score": "0.537526", "text": "function prepareGallery() {\n if (!document.getElementsByTagName) { //these ifs check all required parts of script are available on page\n return false; //and terminate script if they are not all found\n }\n if (!document.getElementById) {\n return false;\n }\n if (!document.getElementById(\"imagegallery\")) {\n return false;\n }\n \n var gallery = document.getElementById(\"imagegallery\"); //find the images\n var links = gallery.getElementsByTagName(\"a\"); //find their anchors\n for (var i=0; i < links.length; i++) { //for loop through these anchors\n links[i].onmouseover = function() {\n return showPic(this); //add mouseover command so that they change the image\n }\n links[i].onclick = links[i].onmouseover; //make onclick work as well\n links[i].onfocus = links[i].onclick; //also onfocus (tabs)\n links[i].onkeypress = links[i].onclick; //also onkeypress (any key)\n }\n}", "title": "" }, { "docid": "6ece82e7da10d572383a9ad312b8ae5e", "score": "0.5373222", "text": "handleTwoCardsClickedEvent() {\n if (this.clicks == 2) {\n const cards = document.querySelectorAll('.card-image');\n // convert cards from nodelist to array\n const cardsArray = Array.from(cards);\n\n const clickedCards = cardsArray.filter(this.checkForClickClass);\n\n const [card1, card2] = clickedCards;\n this.cardsMatchHandler(card1, card2);\n\n this.resetClicks();\n }\n }", "title": "" }, { "docid": "6e6ca2e8a6e6fb5f57ae15f145c38875", "score": "0.5370993", "text": "useControls() {\n const triggers = [...galleryControlsContainer.childNodes];\n\n triggers.forEach(control => {\n control.addEventListener('click', e => {\n e.preventDefault();\n this.setCurrentState(control);\n\n });\n });\n }", "title": "" }, { "docid": "6ed6ae884bd409b57556cf284542fa0e", "score": "0.5365648", "text": "imageClickHandler() {\n\t\tconst {data} = this.props,\n\t\t\tlistOfPhotos = document.querySelector('.gallery__photo-list');\n\n\t\tlistOfPhotos.addEventListener('click', e => {\n\t\t\tconst {target} = e,\n\t\t\t\t{imageMinId: id} = target.dataset;\n\n\t\t\tif (target.tagName !== 'IMG') return;\n\t\t\tthis.props.currentPhoto = +id;\n\t\t\tthis.changeGeneralPhoto(+id);\n\t\t\tthis.selectImageHandler();\n\t\t});\n\t}", "title": "" }, { "docid": "137bed8ad9e861a9729773eb6282fc42", "score": "0.53602475", "text": "initGallery(gallery) {\n this.siema = new Siema({\n selector: gallery,\n duration: 200,\n easing: 'ease-out',\n perPage: 5,\n startIndex: 0,\n draggable: true,\n threshold: 20,\n loop: false,\n });\n }", "title": "" }, { "docid": "600d500e378a86740c930ec38e840719", "score": "0.5353255", "text": "function getCards() {\n const whichCard = document.querySelectorAll('.card');\n for (let i = 0; i < whichCard.length; i++){\n whichCard[i].addEventListener('click', function(e) {\n updateCards(e.target);\n })\n }\n}", "title": "" }, { "docid": "2d7b6d5e7b80f633357eba2bf2bd3218", "score": "0.5352191", "text": "function showSlide(n){\n // Getting all images\n var slides = document.getElementsByClassName(\"mySlides\");\n // Selecting one image\n var imageElement = slides[n];\n // Displaying selected image\n lightBoxModal(imageElement);\n}", "title": "" }, { "docid": "17cee2cd01b7946b0c8413c65b114032", "score": "0.5351946", "text": "function selectImage (event) {\n const button = event.currentTarget; //significa botão clicad\n console.log('selectImage', event.currentTarget);\n //(button.children)\n\n //acessar cada button e excluir de cada um no html a class=\"active\"\n const buttons = document.querySelectorAll(\".images button\");\n console.log(buttons);\n buttons.forEach( (button) => {\n button.classList.remove(\"active\");\n });\n /*\n buttons.forEach(removeActiveClass);\n\n function removeActiveClass (button) {\n button.classList.remove(\"active\")\n }\n*/\n\n\n//clicando e carregando a imagem no principal:\nconst image = button.children[0]\nconst imageContainer = document.querySelector(\".orphanage-details > img\")\n\n//mudando o container, ou seja, a imagem principal\nimageContainer.src = image.src;\n\n\n//adicionando a class=\"active\" em cada button\nbutton.classList.add(\"active\") // está buscando o button da const no começo da funcão\n\n}", "title": "" }, { "docid": "9ec232287e4cc41ac0413f162041c330", "score": "0.5344116", "text": "function _findGalleryItems(gallery) {\n\t\t// fetch or construct gallery identifier\n\t\tvar id = gallery.attr('id');\n\t\tid = id ? BOXPLUS + '-' + id : BOXPLUS;\n\n\t\t$('li', gallery).each(function () {\n\t\t\t$('a:first', this).attr('rel', id);\n\t\t});\n\t\treturn $('a[rel=' + id + ']', gallery);\n\t}", "title": "" }, { "docid": "79ce6128919c78c4fa0064c4d1d3a8fd", "score": "0.5341092", "text": "function addClickEvents()\n{\n\tvar allImg = document.getElementsByTagName(\"img\");\n\t\n\tfor (var i = 0; i < allImg.length; i++)\n\t{\n\t\tallImg[i].addEventListener('click', imgClicked);\n\t}\t\n}", "title": "" }, { "docid": "191aa8b1faceb508c3395d3a8631500a", "score": "0.53349394", "text": "function sectionWork()\r\n{\r\n let collapsibleTriggers = document.querySelectorAll('.collapsible__label');\r\n for (let trigger = 0; trigger < collapsibleTriggers.length; trigger++) \r\n collapsibleTriggers[trigger].addEventListener('click', updateCollapsibles);\r\n}", "title": "" }, { "docid": "5238dac8e7fd26d6fa5e53893d7fc270", "score": "0.5333002", "text": "function updateActiveGallery (galleryButtonIdx) {\n var selectedGallerySection = document.getElementsByClassName('selected-gallery')\n selectedGallerySection[galleryIndex].innerText = objectProperyNames[galleryButtonIdx]\n }", "title": "" }, { "docid": "71adc72f97357f2a8dee65ff14a0f023", "score": "0.5331744", "text": "function toggleGalleryScenes() {\n castGallery.classList.add('hide');\n castBtn.classList.remove('gallerySelected');\n scenesGallery.classList.remove('hide');\n castBtn.style.fontWeight = '';\n castBtn.style.color = '';\n scenesBtn.style.fontWeight = 'bold';\n scenesBtn.style.color = '#b78b4e';\n }", "title": "" }, { "docid": "917ee9673a85d984ecd8adee2198ebed", "score": "0.53285146", "text": "function setUpClickListeners() {\n $(\"#content a\").live('click', function() { //If links point to galleries, make them use getContent.\n var href = $(this).attr('href');\n if(href.indexOf(\"image/tid\") > -1) {\n var id = href.split(\"/\")[3];\n getContent(id);\n return false;\n }\n });\n $('.galleria-images .galleria-image img').live('click', function() { //Make images clickable. This is to make up for the\n window.open($(this).attr('src'), '_blank'); //wrapping a-tag removed above.\n });\n }", "title": "" }, { "docid": "777462f93ddcb80728dd5114c9d0cc8c", "score": "0.53269815", "text": "function addEventListenersToSquares(selectSquares) {\n for (let i = 0; i < selectSquares.length; i++){\n selectSquares[i].addEventListener(\"click\", function () {\n\n\n this.classList.add(\"kokos\");\n console.log(\"I'm clicked\");\n })\n }\n }", "title": "" }, { "docid": "d1924ab7b1fbd0cb152d5675abde512e", "score": "0.5326547", "text": "function SetGalleryImage(event) {\r\n\r\n // If statement\r\n if (event.target.className === \"Gallery__gallery-thumbnail\") {\r\n\r\n // Set image source\r\n let TargetSrc = event.target.attributes.src.nodeValue;\r\n GalleryImg.setAttribute(\"src\", TargetSrc);\r\n };\r\n}", "title": "" }, { "docid": "0cefa0d464160cc4daf629538d30fb90", "score": "0.5319988", "text": "function mouseItemArray(){\r\n \tvar items = $('.circleNavi a');\r\n \tfor(var i = 0, l = items.length; i < l; i++) {\r\n \t\t$(items[i]).animate({\r\n \t\t\tleft:(Math.cos(Math.PI + (1/(l-1))*i*Math.PI)).toFixed(4) + \"px\",\r\n \t\t\ttop:(Math.sin(Math.PI + (1/(l-1))*i*Math.PI)).toFixed(4) + \"px\"\r\n \t\t});\r\n \t}\r\n \t$(menu).removeClass('open');\r\n }", "title": "" }, { "docid": "f113512f34c87db21bd890ff4ae70d81", "score": "0.53194326", "text": "function manipulaBotoes() {\n for (var i = 0; i < slideshowNavegationButtons.length; i++) {\n $(slideshowNavegationButtons[i]).attr({\n\t\t\t\"id\": i\n\t\t});\n\n $(slideshowNavegationButtons[i]).click(function() {\n showImageNavegationButtonSelected($(this).attr(\"id\"));\n });\n }\n\n var leftButton = $(\"#left_button\");\n $(leftButton).click(function(){\n\t\tbackwardImage();\n\t});\n\n var rightButton = $(\"#right_button\");\n $(rightButton).click(function(){\n\t\tforwardImage();\n\t});\n}", "title": "" }, { "docid": "2a57ab798e41552c933d231cea2daf1c", "score": "0.5315214", "text": "function addClickToGifs() {\n $('.gif').on('click', function(e) {\n var state = $(this).attr('data-state');\n\n if (state === 'still') {\n $(this).attr('src', $(this).attr('data-animate')).attr('data-state', 'animate');\n console.log(this)\n } else {\n $(this).attr('src', $(this).attr('data-still')).attr('data-state', 'still');\n console.log(this)\n }\n\n });\n}", "title": "" }, { "docid": "4a31f24b1cdcb84e44c80123e72f8a33", "score": "0.53097373", "text": "function getHitGroups() {\r\n\treturn $('.capsuletarget');\r\n}", "title": "" }, { "docid": "d38ec3678745b55cb7af1eff7afff54e", "score": "0.5307221", "text": "addClickHandlers() {\n //boxes is outside the class you are going to loop over every element of this nodelist...\n boxes.forEach(box => {\n //..then add a event listener on each one\n box.addEventListener('click', e => {\n //then run the following functions\n this.changeNumber(box.dataset.place);\n this.changeColor(box.dataset.place);\n })\n })\n }", "title": "" }, { "docid": "94a153cd69e53df6a0bcc088546def3a", "score": "0.53044647", "text": "loadSVG(e) {\n var svgDoc = e.currentTarget.contentDocument;\n var svgItems = svgDoc.getElementsByTagName(\"path\");\n for (var i = 0; i < 51; i++) {\n if (this.props.campus.sts.indexOf(svgItems[i].id) > -1) {\n svgItems[i].style.fill = \"#61DAFB\";\n svgItems[i].addEventListener(\"click\", (e) => {\n this.selectState(e.target.id);\n });\n } else {\n svgItems[i].style.fill = \"#525252\";\n }\n }\n e.currentTarget.style.opacity = \"1.0\";\n }", "title": "" }, { "docid": "e01ed2c42563d8bd5282fcbbf73d1fe2", "score": "0.530217", "text": "function displaySlide( arr, container ) {\n //console.log(container);\n var el = container.querySelectorAll(\".gallry .slides > figure\");\n\n // if elements created and variable successful\n if (el) {\n for ( var i = 0; i < arr.length; i++ ) {\n // clear out all active class assignments\n el[i].classList.remove(\"active\");\n // set default active state\n if ( arr[i].active ) {\n el[i].classList.add(\"active\");\n Velocity( el[i], { left: \"0%\" }, { display: \"block\" }, { duration: prefs.timing, easing: prefs.easing });\n }\n else if ( i < currentSlide( arr ).index() ) {\n Velocity( el[i], { left: \"-100%\" }, { display: \"none\" }, { duration: prefs.timing, easing: prefs.easing });\n }\n else {\n Velocity( el[i], { left: \"100%\" }, { display: \"none\" }, { duration: prefs.timing, easing: prefs.easing });\n }\n\n if (arr[i].backgroundPosition !== undefined) {\n el[i].style.backgroundSize = arr[i].size;\n el[i].style.backgroundPosition = arr[i].backgroundPosition;\n }\n else {\n el[i].style.backgroundSize = \"cover\";\n el[i].style.backgroundPosition = \"center\";\n }\n\n // this conditional currently requires 2x assets to be available. If no 2x assets are available,\n // no fallback images are provided.\n if (prefs.retina) {\n // do some device sniffing to determine if the screen is retina display or not\n if (window.devicePixelRatio > 1.5) {\n var str = arr[i].src;\n var first = str.slice(0, str.length - 4); // get first part of string\n var last = str.slice(str.length - 4, str.length); // get .jpg, .png, .svg, .gif files --- must be 4 character file extension\n el[i].style.backgroundImage = \"url('\" + first + \"_2x\" + last + \"')\"; // defining gallery slide image via arr.src prop\n }\n else {\n // if the device pixel ratio doesnt match up, use the 1x asset\n el[i].style.backgroundImage = \"url('\" + arr[i].src + \"')\"; // defining gallery slide image via arr.src prop\n }\n }\n // if prefs.retina is false, use the 1x image asset.\n else {\n el[i].style.backgroundImage = \"url('\" + arr[i].src + \"')\"; // defining gallery slide image via arr.src prop\n }\n\n el[i].classList.add( arr[i].name, \"slide\" ); // cycle through array.name values to assign as class to element\n el[i].style.backgroundRepeat = \"no-repeat\";\n el[i].style.height = \"100%\";\n el[i].style.margin = \"0\";\n }\n }\n else {\n console.log(\"Check el element is assigned to correct querySelectorAll value.\");\n }\n }", "title": "" } ]
41287599ad94c47fe99b874135440a19
AnimateChild only accept one child node. `transitionSupport` is used for none transition test case. Default we use browser transition event support check.
[ { "docid": "81b055408bc4104cb3030ec607d9b5a3", "score": "0.69113725", "text": "function genAnimateChild(transitionSupport) {\n var AnimateChild = function (_React$Component) {\n babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(AnimateChild, _React$Component);\n\n function AnimateChild() {\n babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, AnimateChild);\n\n // [Legacy] Since old code addListener on the element.\n // To avoid break the behaviour that component not handle animation/transition\n // also can handle the animate, let keep the logic.\n var _this = babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(this, (AnimateChild.__proto__ || Object.getPrototypeOf(AnimateChild)).call(this));\n\n _this.state = {\n child: null,\n\n eventQueue: [],\n eventActive: false\n };\n\n _this.onDomUpdated = function () {\n var eventActive = _this.state.eventActive;\n var _this$props = _this.props,\n transitionName = _this$props.transitionName,\n animation = _this$props.animation,\n onChildLeaved = _this$props.onChildLeaved,\n animateKey = _this$props.animateKey;\n\n\n var $ele = _this.getDomElement();\n\n // Skip if dom element not ready\n if (!$ele) return;\n\n // [Legacy] Add animation/transition event by dom level\n if (transitionSupport && _this.$prevEle !== $ele) {\n _this.cleanDomEvent();\n\n _this.$prevEle = $ele;\n _this.$prevEle.addEventListener(_util__WEBPACK_IMPORTED_MODULE_12__[\"animationEndName\"], _this.onMotionEnd);\n _this.$prevEle.addEventListener(_util__WEBPACK_IMPORTED_MODULE_12__[\"transitionEndName\"], _this.onMotionEnd);\n }\n\n var currentEvent = _this.getCurrentEvent();\n if (currentEvent.empty) {\n // Additional process the leave event\n if (currentEvent.lastEventType === 'leave') {\n onChildLeaved(animateKey);\n }\n return;\n }\n\n var eventType = currentEvent.eventType,\n restQueue = currentEvent.restQueue;\n\n var nodeClasses = component_classes__WEBPACK_IMPORTED_MODULE_10___default()($ele);\n\n // [Legacy] Since origin code use js to set `className`.\n // This caused that any component without support `className` can be forced set.\n // Let's keep the logic.\n function legacyAppendClass() {\n if (!transitionSupport) return;\n\n var basicClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, '' + eventType);\n if (basicClassName) nodeClasses.add(basicClassName);\n\n if (eventActive) {\n var activeClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, eventType + '-active');\n if (activeClassName) nodeClasses.add(activeClassName);\n }\n }\n\n if (_this.currentEvent && _this.currentEvent.type === eventType) {\n legacyAppendClass();\n return;\n }\n\n // Clear timeout for legacy check\n clearTimeout(_this.timeout);\n\n // Clean up last event environment\n if (_this.currentEvent && _this.currentEvent.animateObj && _this.currentEvent.animateObj.stop) {\n _this.currentEvent.animateObj.stop();\n }\n\n // Clean up last transition class\n if (_this.currentEvent) {\n var basicClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, '' + _this.currentEvent.type);\n var activeClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, _this.currentEvent.type + '-active');\n if (basicClassName) nodeClasses.remove(basicClassName);\n if (activeClassName) nodeClasses.remove(activeClassName);\n }\n\n // New event come\n _this.currentEvent = {\n type: eventType\n };\n\n var animationHandler = (animation || {})[eventType];\n // =============== Check if has customize animation ===============\n if (animationHandler) {\n _this.currentEvent.animateObj = animationHandler($ele, function () {\n _this.onMotionEnd({ target: $ele });\n });\n\n // Do next step if not animate object provided\n if (!_this.currentEvent || !_this.currentEvent.animateObj) {\n _this.nextEvent(restQueue);\n }\n\n // ==================== Use transition instead ====================\n } else if (transitionSupport) {\n legacyAppendClass();\n if (!eventActive) {\n // Trigger `eventActive` in next frame\n raf__WEBPACK_IMPORTED_MODULE_11___default()(function () {\n if (_this.currentEvent && _this.currentEvent.type === eventType && !_this._destroy) {\n _this.setState({ eventActive: true }, function () {\n // [Legacy] Handle timeout if browser transition event not handle\n var transitionDelay = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getStyleValue\"])($ele, 'transition-delay') || 0;\n var transitionDuration = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getStyleValue\"])($ele, 'transition-duration') || 0;\n var animationDelay = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getStyleValue\"])($ele, 'animation-delay') || 0;\n var animationDuration = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getStyleValue\"])($ele, 'animation-duration') || 0;\n var totalTime = Math.max(transitionDuration + transitionDelay, animationDuration + animationDelay);\n\n if (totalTime >= 0) {\n _this.timeout = setTimeout(function () {\n _this.onMotionEnd({ target: $ele });\n }, totalTime * 1000);\n }\n });\n }\n });\n }\n\n // ======================= Just next action =======================\n } else {\n _this.onMotionEnd({ target: $ele });\n }\n };\n\n _this.onMotionEnd = function (_ref) {\n var target = _ref.target;\n var _this$props2 = _this.props,\n transitionName = _this$props2.transitionName,\n onChildLeaved = _this$props2.onChildLeaved,\n animateKey = _this$props2.animateKey,\n onAppear = _this$props2.onAppear,\n onEnter = _this$props2.onEnter,\n onLeave = _this$props2.onLeave,\n onEnd = _this$props2.onEnd;\n\n var currentEvent = _this.getCurrentEvent();\n if (currentEvent.empty) return;\n\n // Clear timeout for legacy check\n clearTimeout(_this.timeout);\n\n var restQueue = currentEvent.restQueue;\n\n\n var $ele = _this.getDomElement();\n if (!_this.currentEvent || $ele !== target) return;\n\n if (_this.currentEvent.animateObj && _this.currentEvent.animateObj.stop) {\n _this.currentEvent.animateObj.stop();\n }\n\n // [Legacy] Same as above, we need call js to remove the class\n if (transitionSupport && _this.currentEvent) {\n var basicClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, _this.currentEvent.type);\n var activeClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, _this.currentEvent.type + '-active');\n\n var nodeClasses = component_classes__WEBPACK_IMPORTED_MODULE_10___default()($ele);\n if (basicClassName) nodeClasses.remove(basicClassName);\n if (activeClassName) nodeClasses.remove(activeClassName);\n }\n\n // Additional process the leave event\n if (_this.currentEvent && _this.currentEvent.type === 'leave') {\n onChildLeaved(animateKey);\n }\n\n // [Legacy] Trigger on event when it's last event\n if (_this.currentEvent && !restQueue.length) {\n if (_this.currentEvent.type === 'appear' && onAppear) {\n onAppear(animateKey);\n } else if (_this.currentEvent.type === 'enter' && onEnter) {\n onEnter(animateKey);\n } else if (_this.currentEvent.type === 'leave' && onLeave) {\n onLeave(animateKey);\n }\n\n if (onEnd) {\n // OnEnd(key, isShow)\n onEnd(animateKey, _this.currentEvent.type !== 'leave');\n }\n }\n\n _this.currentEvent = null;\n\n // Next queue\n _this.nextEvent(restQueue);\n };\n\n _this.getDomElement = function () {\n if (_this._destroy) return null;\n return react_dom__WEBPACK_IMPORTED_MODULE_6___default.a.findDOMNode(_this);\n };\n\n _this.getCurrentEvent = function () {\n var _this$state$eventQueu = _this.state.eventQueue,\n eventQueue = _this$state$eventQueu === undefined ? [] : _this$state$eventQueu;\n var _this$props3 = _this.props,\n animation = _this$props3.animation,\n exclusive = _this$props3.exclusive,\n transitionAppear = _this$props3.transitionAppear,\n transitionEnter = _this$props3.transitionEnter,\n transitionLeave = _this$props3.transitionLeave;\n\n\n function hasEventHandler(eventType) {\n return eventType === 'appear' && (transitionAppear || animation.appear) || eventType === 'enter' && (transitionEnter || animation.enter) || eventType === 'leave' && (transitionLeave || animation.leave);\n }\n\n var event = null;\n // If is exclusive, only check the last event\n if (exclusive) {\n var eventType = eventQueue[eventQueue.length - 1];\n if (hasEventHandler(eventType)) {\n event = {\n eventType: eventType,\n restQueue: []\n };\n }\n } else {\n // Loop check the queue until find match\n var cloneQueue = eventQueue.slice();\n while (cloneQueue.length) {\n var _cloneQueue = cloneQueue,\n _cloneQueue2 = babel_runtime_helpers_toArray__WEBPACK_IMPORTED_MODULE_0___default()(_cloneQueue),\n _eventType = _cloneQueue2[0],\n restQueue = _cloneQueue2.slice(1);\n\n if (hasEventHandler(_eventType)) {\n event = {\n eventType: _eventType,\n restQueue: restQueue\n };\n break;\n }\n cloneQueue = restQueue;\n }\n }\n\n if (!event) {\n event = {\n empty: true,\n lastEventType: eventQueue[eventQueue.length - 1]\n };\n }\n\n return event;\n };\n\n _this.nextEvent = function (restQueue) {\n // Next queue\n if (!_this._destroy) {\n _this.setState({\n eventQueue: restQueue,\n eventActive: false\n });\n }\n };\n\n _this.cleanDomEvent = function () {\n if (_this.$prevEle && transitionSupport) {\n _this.$prevEle.removeEventListener(_util__WEBPACK_IMPORTED_MODULE_12__[\"animationEndName\"], _this.onMotionEnd);\n _this.$prevEle.removeEventListener(_util__WEBPACK_IMPORTED_MODULE_12__[\"transitionEndName\"], _this.onMotionEnd);\n }\n };\n\n _this.$prevEle = null;\n\n _this.currentEvent = null;\n _this.timeout = null;\n return _this;\n }\n\n babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(AnimateChild, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n this.onDomUpdated();\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n this.onDomUpdated();\n }\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {\n clearTimeout(this.timeout);\n this._destroy = true;\n this.cleanDomEvent();\n }\n }, {\n key: 'render',\n value: function render() {\n var _state = this.state,\n child = _state.child,\n eventActive = _state.eventActive;\n var _props = this.props,\n showProp = _props.showProp,\n transitionName = _props.transitionName;\n\n var _ref2 = child.props || {},\n className = _ref2.className;\n\n var currentEvent = this.getCurrentEvent();\n\n // Class name\n var connectClassName = transitionSupport && this.currentEvent ? classnames__WEBPACK_IMPORTED_MODULE_9___default()(className, Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, this.currentEvent.type), eventActive && Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, this.currentEvent.type + '-active')) : className;\n\n var show = true;\n\n // Keep show when is in transition or has customize animate\n if (transitionSupport && (!currentEvent.empty || this.currentEvent && this.currentEvent.animateObj)) {\n show = true;\n } else {\n show = child.props[showProp];\n }\n\n // Clone child\n var newChildProps = {\n className: connectClassName\n };\n\n if (showProp) {\n newChildProps[showProp] = show;\n }\n\n return react__WEBPACK_IMPORTED_MODULE_5___default.a.cloneElement(child, newChildProps);\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(nextProps, prevState) {\n var _prevState$prevProps = prevState.prevProps,\n prevProps = _prevState$prevProps === undefined ? {} : _prevState$prevProps;\n var appeared = nextProps.appeared;\n\n\n var newState = {\n prevProps: Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"cloneProps\"])(nextProps, clonePropList)\n };\n\n function processState(propName, updater) {\n if (prevProps[propName] !== nextProps[propName]) {\n if (updater) {\n updater(nextProps[propName]);\n }\n return true;\n }\n return false;\n }\n\n function pushEvent(eventType) {\n var eventQueue = newState.eventQueue || prevState.eventQueue.slice();\n var matchIndex = eventQueue.indexOf(eventType);\n\n // Clean the rest event if eventType match\n if (matchIndex !== -1) {\n eventQueue = eventQueue.slice(0, matchIndex);\n }\n\n eventQueue.push(eventType);\n newState.eventQueue = eventQueue;\n }\n\n // Child update. Only set child.\n processState('children', function (child) {\n newState.child = child;\n });\n\n processState('appeared', function (isAppeared) {\n if (isAppeared) {\n pushEvent('appear');\n }\n });\n\n // Show update\n processState('show', function (show) {\n if (!appeared) {\n if (show) {\n pushEvent('enter');\n } else {\n pushEvent('leave');\n }\n }\n });\n\n return newState;\n }\n }]);\n\n return AnimateChild;\n }(react__WEBPACK_IMPORTED_MODULE_5___default.a.Component);\n\n AnimateChild.propTypes = {\n transitionName: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.object]),\n transitionAppear: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.bool,\n transitionEnter: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.bool,\n transitionLeave: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.bool,\n exclusive: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.bool,\n appeared: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.bool,\n showProp: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.string,\n\n animateKey: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.any,\n animation: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.object,\n onChildLeaved: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.func,\n\n onEnd: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.func,\n onAppear: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.func,\n onEnter: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.func,\n onLeave: prop_types__WEBPACK_IMPORTED_MODULE_7___default.a.func\n };\n\n\n Object(react_lifecycles_compat__WEBPACK_IMPORTED_MODULE_8__[\"polyfill\"])(AnimateChild);\n\n return AnimateChild;\n}", "title": "" } ]
[ { "docid": "86345e46bfea9b20aa164b99f62e0e6e", "score": "0.7053825", "text": "function genAnimateChild(transitionSupport) {\n var AnimateChild = function (_React$Component) {\n __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_inherits___default()(AnimateChild, _React$Component);\n\n function AnimateChild() {\n __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, AnimateChild);\n\n // [Legacy] Since old code addListener on the element.\n // To avoid break the behaviour that component not handle animation/transition\n // also can handle the animate, let keep the logic.\n var _this = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_possibleConstructorReturn___default()(this, _React$Component.call(this));\n\n _this.state = {\n child: null,\n\n eventQueue: [],\n eventActive: false\n };\n\n _this.onDomUpdated = function () {\n var eventActive = _this.state.eventActive;\n var _this$props = _this.props,\n transitionName = _this$props.transitionName,\n animation = _this$props.animation,\n onChildLeaved = _this$props.onChildLeaved,\n animateKey = _this$props.animateKey;\n\n\n var $ele = _this.getDomElement();\n\n // Skip if dom element not ready\n if (!$ele) return;\n\n // [Legacy] Add animation/transition event by dom level\n if (transitionSupport && _this.$prevEle !== $ele) {\n _this.cleanDomEvent();\n\n _this.$prevEle = $ele;\n _this.$prevEle.addEventListener(__WEBPACK_IMPORTED_MODULE_10__util__[\"a\" /* animationEndName */], _this.onMotionEnd);\n _this.$prevEle.addEventListener(__WEBPACK_IMPORTED_MODULE_10__util__[\"g\" /* transitionEndName */], _this.onMotionEnd);\n }\n\n var currentEvent = _this.getCurrentEvent();\n if (currentEvent.empty) {\n // Additional process the leave event\n if (currentEvent.lastEventType === 'leave') {\n onChildLeaved(animateKey);\n }\n return;\n }\n\n var eventType = currentEvent.eventType,\n restQueue = currentEvent.restQueue;\n\n var nodeClasses = __WEBPACK_IMPORTED_MODULE_8_component_classes___default()($ele);\n\n // [Legacy] Since origin code use js to set `className`.\n // This caused that any component without support `className` can be forced set.\n // Let's keep the logic.\n function legacyAppendClass() {\n if (!transitionSupport) return;\n\n var basicClassName = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, '' + eventType);\n if (basicClassName) nodeClasses.add(basicClassName);\n\n if (eventActive) {\n var activeClassName = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, eventType + '-active');\n if (activeClassName) nodeClasses.add(activeClassName);\n }\n }\n\n if (_this.currentEvent && _this.currentEvent.type === eventType) {\n legacyAppendClass();\n return;\n }\n\n // Clear timeout for legacy check\n clearTimeout(_this.timeout);\n\n // Clean up last event environment\n if (_this.currentEvent && _this.currentEvent.animateObj && _this.currentEvent.animateObj.stop) {\n _this.currentEvent.animateObj.stop();\n }\n\n // Clean up last transition class\n if (_this.currentEvent) {\n var basicClassName = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, '' + _this.currentEvent.type);\n var activeClassName = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, _this.currentEvent.type + '-active');\n if (basicClassName) nodeClasses.remove(basicClassName);\n if (activeClassName) nodeClasses.remove(activeClassName);\n }\n\n // New event come\n _this.currentEvent = {\n type: eventType\n };\n\n var animationHandler = (animation || {})[eventType];\n // =============== Check if has customize animation ===============\n if (animationHandler) {\n _this.currentEvent.animateObj = animationHandler($ele, function () {\n _this.onMotionEnd({ target: $ele });\n });\n\n // Do next step if not animate object provided\n if (!_this.currentEvent.animateObj) {\n _this.nextEvent(restQueue);\n }\n\n // ==================== Use transition instead ====================\n } else if (transitionSupport) {\n legacyAppendClass();\n if (!eventActive) {\n // Trigger `eventActive` in next frame\n __WEBPACK_IMPORTED_MODULE_9_raf___default()(function () {\n if (_this.currentEvent && _this.currentEvent.type === eventType && !_this._destroy) {\n _this.setState({ eventActive: true }, function () {\n // [Legacy] Handle timeout if browser transition event not handle\n var transitionDelay = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"c\" /* getStyleValue */])($ele, 'transition-delay') || 0;\n var transitionDuration = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"c\" /* getStyleValue */])($ele, 'transition-duration') || 0;\n var animationDelay = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"c\" /* getStyleValue */])($ele, 'animation-delay') || 0;\n var animationDuration = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"c\" /* getStyleValue */])($ele, 'animation-duration') || 0;\n var totalTime = Math.max(transitionDuration + transitionDelay, animationDuration + animationDelay);\n\n if (totalTime >= 0) {\n _this.timeout = setTimeout(function () {\n _this.onMotionEnd({ target: $ele });\n }, totalTime * 1000);\n }\n });\n }\n });\n }\n\n // ======================= Just next action =======================\n } else {\n _this.onMotionEnd({ target: $ele });\n }\n };\n\n _this.onMotionEnd = function (_ref) {\n var target = _ref.target;\n var _this$props2 = _this.props,\n transitionName = _this$props2.transitionName,\n onChildLeaved = _this$props2.onChildLeaved,\n animateKey = _this$props2.animateKey,\n onAppear = _this$props2.onAppear,\n onEnter = _this$props2.onEnter,\n onLeave = _this$props2.onLeave,\n onEnd = _this$props2.onEnd;\n\n var currentEvent = _this.getCurrentEvent();\n if (currentEvent.empty) return;\n\n // Clear timeout for legacy check\n clearTimeout(_this.timeout);\n\n var restQueue = currentEvent.restQueue;\n\n\n var $ele = _this.getDomElement();\n if (!_this.currentEvent || $ele !== target) return;\n\n if (_this.currentEvent.animateObj && _this.currentEvent.animateObj.stop) {\n _this.currentEvent.animateObj.stop();\n }\n\n // [Legacy] Same as above, we need call js to remove the class\n if (transitionSupport && _this.currentEvent) {\n var basicClassName = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, _this.currentEvent.type);\n var activeClassName = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, _this.currentEvent.type + '-active');\n\n var nodeClasses = __WEBPACK_IMPORTED_MODULE_8_component_classes___default()($ele);\n if (basicClassName) nodeClasses.remove(basicClassName);\n if (activeClassName) nodeClasses.remove(activeClassName);\n }\n\n // Additional process the leave event\n if (_this.currentEvent && _this.currentEvent.type === 'leave') {\n onChildLeaved(animateKey);\n }\n\n // [Legacy] Trigger on event when it's last event\n if (_this.currentEvent && !restQueue.length) {\n if (_this.currentEvent.type === 'appear' && onAppear) {\n onAppear(animateKey);\n } else if (_this.currentEvent.type === 'enter' && onEnter) {\n onEnter(animateKey);\n } else if (_this.currentEvent.type === 'leave' && onLeave) {\n onLeave(animateKey);\n }\n\n if (onEnd) {\n // OnEnd(key, isShow)\n onEnd(animateKey, _this.currentEvent.type !== 'leave');\n }\n }\n\n _this.currentEvent = null;\n\n // Next queue\n _this.nextEvent(restQueue);\n };\n\n _this.getDomElement = function () {\n if (_this._destroy) return null;\n return __WEBPACK_IMPORTED_MODULE_4_react_dom___default.a.findDOMNode(_this);\n };\n\n _this.getCurrentEvent = function () {\n var _this$state$eventQueu = _this.state.eventQueue,\n eventQueue = _this$state$eventQueu === undefined ? [] : _this$state$eventQueu;\n var _this$props3 = _this.props,\n animation = _this$props3.animation,\n exclusive = _this$props3.exclusive,\n transitionAppear = _this$props3.transitionAppear,\n transitionEnter = _this$props3.transitionEnter,\n transitionLeave = _this$props3.transitionLeave;\n\n\n function hasEventHandler(eventType) {\n return eventType === 'appear' && (transitionAppear || animation.appear) || eventType === 'enter' && (transitionEnter || animation.enter) || eventType === 'leave' && (transitionLeave || animation.leave);\n }\n\n var event = null;\n // If is exclusive, only check the last event\n if (exclusive) {\n var eventType = eventQueue[eventQueue.length - 1];\n if (hasEventHandler(eventType)) {\n event = {\n eventType: eventType,\n restQueue: []\n };\n }\n } else {\n // Loop check the queue until find match\n var cloneQueue = eventQueue.slice();\n while (cloneQueue.length) {\n var _cloneQueue = cloneQueue,\n _eventType = _cloneQueue[0],\n restQueue = _cloneQueue.slice(1);\n\n if (hasEventHandler(_eventType)) {\n event = {\n eventType: _eventType,\n restQueue: restQueue\n };\n break;\n }\n cloneQueue = restQueue;\n }\n }\n\n if (!event) {\n event = {\n empty: true,\n lastEventType: eventQueue[eventQueue.length - 1]\n };\n }\n\n return event;\n };\n\n _this.nextEvent = function (restQueue) {\n // Next queue\n if (!_this._destroy) {\n _this.setState({\n eventQueue: restQueue,\n eventActive: false\n });\n }\n };\n\n _this.cleanDomEvent = function () {\n if (_this.$prevEle && transitionSupport) {\n _this.$prevEle.removeEventListener(__WEBPACK_IMPORTED_MODULE_10__util__[\"a\" /* animationEndName */], _this.onMotionEnd);\n _this.$prevEle.removeEventListener(__WEBPACK_IMPORTED_MODULE_10__util__[\"g\" /* transitionEndName */], _this.onMotionEnd);\n }\n };\n\n _this.$prevEle = null;\n\n _this.currentEvent = null;\n _this.timeout = null;\n return _this;\n }\n\n AnimateChild.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {\n var _prevState$prevProps = prevState.prevProps,\n prevProps = _prevState$prevProps === undefined ? {} : _prevState$prevProps;\n var appeared = nextProps.appeared;\n\n\n var newState = {\n prevProps: Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"b\" /* cloneProps */])(nextProps, clonePropList)\n };\n\n function processState(propName, updater) {\n if (prevProps[propName] !== nextProps[propName]) {\n if (updater) {\n updater(nextProps[propName]);\n }\n return true;\n }\n return false;\n }\n\n function pushEvent(eventType) {\n var eventQueue = newState.eventQueue || prevState.eventQueue.slice();\n var matchIndex = eventQueue.indexOf(eventType);\n\n // Clean the rest event if eventType match\n if (matchIndex !== -1) {\n eventQueue = eventQueue.slice(0, matchIndex);\n }\n\n eventQueue.push(eventType);\n newState.eventQueue = eventQueue;\n }\n\n // Child update. Only set child.\n processState('children', function (child) {\n newState.child = child;\n });\n\n processState('appeared', function (isAppeared) {\n if (isAppeared) {\n pushEvent('appear');\n }\n });\n\n // Show update\n processState('show', function (show) {\n if (!appeared) {\n if (show) {\n pushEvent('enter');\n } else {\n pushEvent('leave');\n }\n }\n });\n\n return newState;\n };\n\n AnimateChild.prototype.componentDidMount = function componentDidMount() {\n this.onDomUpdated();\n };\n\n AnimateChild.prototype.componentDidUpdate = function componentDidUpdate() {\n this.onDomUpdated();\n };\n\n AnimateChild.prototype.componentWillUnmount = function componentWillUnmount() {\n clearTimeout(this.timeout);\n this._destroy = true;\n this.cleanDomEvent();\n };\n\n AnimateChild.prototype.render = function render() {\n var _state = this.state,\n child = _state.child,\n eventActive = _state.eventActive;\n var _props = this.props,\n showProp = _props.showProp,\n transitionName = _props.transitionName;\n\n var _ref2 = child.props || {},\n className = _ref2.className;\n\n var currentEvent = this.getCurrentEvent();\n\n // Class name\n var connectClassName = transitionSupport && this.currentEvent ? __WEBPACK_IMPORTED_MODULE_7_classnames___default()(className, Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, this.currentEvent.type), eventActive && Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"d\" /* getTransitionName */])(transitionName, this.currentEvent.type + '-active')) : className;\n\n var show = true;\n\n // Keep show when is in transition or has customize animate\n if (transitionSupport && (!currentEvent.empty || this.currentEvent && this.currentEvent.animateObj)) {\n show = true;\n } else {\n show = child.props[showProp];\n }\n\n // Clone child\n var newChildProps = {\n className: connectClassName\n };\n\n if (showProp) {\n newChildProps[showProp] = show;\n }\n\n return __WEBPACK_IMPORTED_MODULE_3_react___default.a.cloneElement(child, newChildProps);\n };\n\n return AnimateChild;\n }(__WEBPACK_IMPORTED_MODULE_3_react___default.a.Component);\n\n AnimateChild.propTypes = {\n transitionName: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object]),\n transitionAppear: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n transitionEnter: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n transitionLeave: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n exclusive: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n appeared: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n showProp: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,\n\n animateKey: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,\n animation: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,\n onChildLeaved: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n\n onEnd: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n onAppear: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n onEnter: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n onLeave: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func\n };\n\n\n Object(__WEBPACK_IMPORTED_MODULE_6_react_lifecycles_compat__[\"polyfill\"])(AnimateChild);\n\n return AnimateChild;\n}", "title": "" }, { "docid": "503e23ee64a57a5d954df70605ef49bd", "score": "0.7040142", "text": "function genAnimateChild(transitionSupport) {\n var AnimateChild = function (_React$Component) {\n __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_inherits___default()(AnimateChild, _React$Component);\n\n function AnimateChild() {\n __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, AnimateChild);\n\n // [Legacy] Since old code addListener on the element.\n // To avoid break the behaviour that component not handle animation/transition\n // also can handle the animate, let keep the logic.\n var _this = __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_possibleConstructorReturn___default()(this, (AnimateChild.__proto__ || Object.getPrototypeOf(AnimateChild)).call(this));\n\n _this.state = {\n child: null,\n\n eventQueue: [],\n eventActive: false\n };\n\n _this.onDomUpdated = function () {\n var eventActive = _this.state.eventActive;\n var _this$props = _this.props,\n transitionName = _this$props.transitionName,\n animation = _this$props.animation,\n onChildLeaved = _this$props.onChildLeaved,\n animateKey = _this$props.animateKey;\n\n\n var $ele = _this.getDomElement();\n\n // Skip if dom element not ready\n if (!$ele) return;\n\n // [Legacy] Add animation/transition event by dom level\n if (transitionSupport && _this.$prevEle !== $ele) {\n _this.cleanDomEvent();\n\n _this.$prevEle = $ele;\n _this.$prevEle.addEventListener(__WEBPACK_IMPORTED_MODULE_12__util__[\"a\" /* animationEndName */], _this.onMotionEnd);\n _this.$prevEle.addEventListener(__WEBPACK_IMPORTED_MODULE_12__util__[\"g\" /* transitionEndName */], _this.onMotionEnd);\n }\n\n var currentEvent = _this.getCurrentEvent();\n if (currentEvent.empty) {\n // Additional process the leave event\n if (currentEvent.lastEventType === 'leave') {\n onChildLeaved(animateKey);\n }\n return;\n }\n\n var eventType = currentEvent.eventType,\n restQueue = currentEvent.restQueue;\n\n var nodeClasses = __WEBPACK_IMPORTED_MODULE_10_component_classes___default()($ele);\n\n // [Legacy] Since origin code use js to set `className`.\n // This caused that any component without support `className` can be forced set.\n // Let's keep the logic.\n function legacyAppendClass() {\n if (!transitionSupport) return;\n\n var basicClassName = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, '' + eventType);\n if (basicClassName) nodeClasses.add(basicClassName);\n\n if (eventActive) {\n var activeClassName = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, eventType + '-active');\n if (activeClassName) nodeClasses.add(activeClassName);\n }\n }\n\n if (_this.currentEvent && _this.currentEvent.type === eventType) {\n legacyAppendClass();\n return;\n }\n\n // Clear timeout for legacy check\n clearTimeout(_this.timeout);\n\n // Clean up last event environment\n if (_this.currentEvent && _this.currentEvent.animateObj && _this.currentEvent.animateObj.stop) {\n _this.currentEvent.animateObj.stop();\n }\n\n // Clean up last transition class\n if (_this.currentEvent) {\n var basicClassName = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, '' + _this.currentEvent.type);\n var activeClassName = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, _this.currentEvent.type + '-active');\n if (basicClassName) nodeClasses.remove(basicClassName);\n if (activeClassName) nodeClasses.remove(activeClassName);\n }\n\n // New event come\n _this.currentEvent = {\n type: eventType\n };\n\n var animationHandler = (animation || {})[eventType];\n // =============== Check if has customize animation ===============\n if (animationHandler) {\n _this.currentEvent.animateObj = animationHandler($ele, function () {\n _this.onMotionEnd({ target: $ele });\n });\n\n // Do next step if not animate object provided\n if (!_this.currentEvent || !_this.currentEvent.animateObj) {\n _this.nextEvent(restQueue);\n }\n\n // ==================== Use transition instead ====================\n } else if (transitionSupport) {\n legacyAppendClass();\n if (!eventActive) {\n // Trigger `eventActive` in next frame\n __WEBPACK_IMPORTED_MODULE_11_raf___default()(function () {\n if (_this.currentEvent && _this.currentEvent.type === eventType && !_this._destroy) {\n _this.setState({ eventActive: true }, function () {\n // [Legacy] Handle timeout if browser transition event not handle\n var transitionDelay = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"c\" /* getStyleValue */])($ele, 'transition-delay') || 0;\n var transitionDuration = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"c\" /* getStyleValue */])($ele, 'transition-duration') || 0;\n var animationDelay = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"c\" /* getStyleValue */])($ele, 'animation-delay') || 0;\n var animationDuration = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"c\" /* getStyleValue */])($ele, 'animation-duration') || 0;\n var totalTime = Math.max(transitionDuration + transitionDelay, animationDuration + animationDelay);\n\n if (totalTime >= 0) {\n _this.timeout = setTimeout(function () {\n _this.onMotionEnd({ target: $ele });\n }, totalTime * 1000);\n }\n });\n }\n });\n }\n\n // ======================= Just next action =======================\n } else {\n _this.onMotionEnd({ target: $ele });\n }\n };\n\n _this.onMotionEnd = function (_ref) {\n var target = _ref.target;\n var _this$props2 = _this.props,\n transitionName = _this$props2.transitionName,\n onChildLeaved = _this$props2.onChildLeaved,\n animateKey = _this$props2.animateKey,\n onAppear = _this$props2.onAppear,\n onEnter = _this$props2.onEnter,\n onLeave = _this$props2.onLeave,\n onEnd = _this$props2.onEnd;\n\n var currentEvent = _this.getCurrentEvent();\n if (currentEvent.empty) return;\n\n // Clear timeout for legacy check\n clearTimeout(_this.timeout);\n\n var restQueue = currentEvent.restQueue;\n\n\n var $ele = _this.getDomElement();\n if (!_this.currentEvent || $ele !== target) return;\n\n if (_this.currentEvent.animateObj && _this.currentEvent.animateObj.stop) {\n _this.currentEvent.animateObj.stop();\n }\n\n // [Legacy] Same as above, we need call js to remove the class\n if (transitionSupport && _this.currentEvent) {\n var basicClassName = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, _this.currentEvent.type);\n var activeClassName = Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, _this.currentEvent.type + '-active');\n\n var nodeClasses = __WEBPACK_IMPORTED_MODULE_10_component_classes___default()($ele);\n if (basicClassName) nodeClasses.remove(basicClassName);\n if (activeClassName) nodeClasses.remove(activeClassName);\n }\n\n // Additional process the leave event\n if (_this.currentEvent && _this.currentEvent.type === 'leave') {\n onChildLeaved(animateKey);\n }\n\n // [Legacy] Trigger on event when it's last event\n if (_this.currentEvent && !restQueue.length) {\n if (_this.currentEvent.type === 'appear' && onAppear) {\n onAppear(animateKey);\n } else if (_this.currentEvent.type === 'enter' && onEnter) {\n onEnter(animateKey);\n } else if (_this.currentEvent.type === 'leave' && onLeave) {\n onLeave(animateKey);\n }\n\n if (onEnd) {\n // OnEnd(key, isShow)\n onEnd(animateKey, _this.currentEvent.type !== 'leave');\n }\n }\n\n _this.currentEvent = null;\n\n // Next queue\n _this.nextEvent(restQueue);\n };\n\n _this.getDomElement = function () {\n if (_this._destroy) return null;\n return __WEBPACK_IMPORTED_MODULE_6_react_dom___default.a.findDOMNode(_this);\n };\n\n _this.getCurrentEvent = function () {\n var _this$state$eventQueu = _this.state.eventQueue,\n eventQueue = _this$state$eventQueu === undefined ? [] : _this$state$eventQueu;\n var _this$props3 = _this.props,\n animation = _this$props3.animation,\n exclusive = _this$props3.exclusive,\n transitionAppear = _this$props3.transitionAppear,\n transitionEnter = _this$props3.transitionEnter,\n transitionLeave = _this$props3.transitionLeave;\n\n\n function hasEventHandler(eventType) {\n return eventType === 'appear' && (transitionAppear || animation.appear) || eventType === 'enter' && (transitionEnter || animation.enter) || eventType === 'leave' && (transitionLeave || animation.leave);\n }\n\n var event = null;\n // If is exclusive, only check the last event\n if (exclusive) {\n var eventType = eventQueue[eventQueue.length - 1];\n if (hasEventHandler(eventType)) {\n event = {\n eventType: eventType,\n restQueue: []\n };\n }\n } else {\n // Loop check the queue until find match\n var cloneQueue = eventQueue.slice();\n while (cloneQueue.length) {\n var _cloneQueue = cloneQueue,\n _cloneQueue2 = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toArray___default()(_cloneQueue),\n _eventType = _cloneQueue2[0],\n restQueue = _cloneQueue2.slice(1);\n\n if (hasEventHandler(_eventType)) {\n event = {\n eventType: _eventType,\n restQueue: restQueue\n };\n break;\n }\n cloneQueue = restQueue;\n }\n }\n\n if (!event) {\n event = {\n empty: true,\n lastEventType: eventQueue[eventQueue.length - 1]\n };\n }\n\n return event;\n };\n\n _this.nextEvent = function (restQueue) {\n // Next queue\n if (!_this._destroy) {\n _this.setState({\n eventQueue: restQueue,\n eventActive: false\n });\n }\n };\n\n _this.cleanDomEvent = function () {\n if (_this.$prevEle && transitionSupport) {\n _this.$prevEle.removeEventListener(__WEBPACK_IMPORTED_MODULE_12__util__[\"a\" /* animationEndName */], _this.onMotionEnd);\n _this.$prevEle.removeEventListener(__WEBPACK_IMPORTED_MODULE_12__util__[\"g\" /* transitionEndName */], _this.onMotionEnd);\n }\n };\n\n _this.$prevEle = null;\n\n _this.currentEvent = null;\n _this.timeout = null;\n return _this;\n }\n\n __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(AnimateChild, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n this.onDomUpdated();\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n this.onDomUpdated();\n }\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {\n clearTimeout(this.timeout);\n this._destroy = true;\n this.cleanDomEvent();\n }\n }, {\n key: 'render',\n value: function render() {\n var _state = this.state,\n child = _state.child,\n eventActive = _state.eventActive;\n var _props = this.props,\n showProp = _props.showProp,\n transitionName = _props.transitionName;\n\n var _ref2 = child.props || {},\n className = _ref2.className;\n\n var currentEvent = this.getCurrentEvent();\n\n // Class name\n var connectClassName = transitionSupport && this.currentEvent ? __WEBPACK_IMPORTED_MODULE_9_classnames___default()(className, Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, this.currentEvent.type), eventActive && Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"d\" /* getTransitionName */])(transitionName, this.currentEvent.type + '-active')) : className;\n\n var show = true;\n\n // Keep show when is in transition or has customize animate\n if (transitionSupport && (!currentEvent.empty || this.currentEvent && this.currentEvent.animateObj)) {\n show = true;\n } else {\n show = child.props[showProp];\n }\n\n // Clone child\n var newChildProps = {\n className: connectClassName\n };\n\n if (showProp) {\n newChildProps[showProp] = show;\n }\n\n return __WEBPACK_IMPORTED_MODULE_5_react___default.a.cloneElement(child, newChildProps);\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(nextProps, prevState) {\n var _prevState$prevProps = prevState.prevProps,\n prevProps = _prevState$prevProps === undefined ? {} : _prevState$prevProps;\n var appeared = nextProps.appeared;\n\n\n var newState = {\n prevProps: Object(__WEBPACK_IMPORTED_MODULE_12__util__[\"b\" /* cloneProps */])(nextProps, clonePropList)\n };\n\n function processState(propName, updater) {\n if (prevProps[propName] !== nextProps[propName]) {\n if (updater) {\n updater(nextProps[propName]);\n }\n return true;\n }\n return false;\n }\n\n function pushEvent(eventType) {\n var eventQueue = newState.eventQueue || prevState.eventQueue.slice();\n var matchIndex = eventQueue.indexOf(eventType);\n\n // Clean the rest event if eventType match\n if (matchIndex !== -1) {\n eventQueue = eventQueue.slice(0, matchIndex);\n }\n\n eventQueue.push(eventType);\n newState.eventQueue = eventQueue;\n }\n\n // Child update. Only set child.\n processState('children', function (child) {\n newState.child = child;\n });\n\n processState('appeared', function (isAppeared) {\n if (isAppeared) {\n pushEvent('appear');\n }\n });\n\n // Show update\n processState('show', function (show) {\n if (!appeared) {\n if (show) {\n pushEvent('enter');\n } else {\n pushEvent('leave');\n }\n }\n });\n\n return newState;\n }\n }]);\n\n return AnimateChild;\n }(__WEBPACK_IMPORTED_MODULE_5_react___default.a.Component);\n\n AnimateChild.propTypes = {\n transitionName: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.object]),\n transitionAppear: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,\n transitionEnter: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,\n transitionLeave: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,\n exclusive: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,\n appeared: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.bool,\n showProp: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.string,\n\n animateKey: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.any,\n animation: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.object,\n onChildLeaved: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,\n\n onEnd: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,\n onAppear: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,\n onEnter: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func,\n onLeave: __WEBPACK_IMPORTED_MODULE_7_prop_types___default.a.func\n };\n\n\n Object(__WEBPACK_IMPORTED_MODULE_8_react_lifecycles_compat__[\"polyfill\"])(AnimateChild);\n\n return AnimateChild;\n}", "title": "" }, { "docid": "b79a9872fdd118cc7139e87121e189d6", "score": "0.57515967", "text": "function animateChild() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n return {\n type: 9\n /* AnimateChild */\n ,\n options: options\n };\n}", "title": "" }, { "docid": "40492ab92f49711b8693d6dfc100cfc3", "score": "0.57218593", "text": "function animateChild(options) {\n if (options === void 0) { options = null; }\n return { type: 9 /* AnimateChild */, options: options };\n}", "title": "" }, { "docid": "13a8a485a64be75cb9b5ca661ed1829c", "score": "0.550251", "text": "function animateChild(options = null) {\n return { type: 9 /* AnimateChild */, options };\n}", "title": "" }, { "docid": "13a8a485a64be75cb9b5ca661ed1829c", "score": "0.550251", "text": "function animateChild(options = null) {\n return { type: 9 /* AnimateChild */, options };\n}", "title": "" }, { "docid": "13a8a485a64be75cb9b5ca661ed1829c", "score": "0.550251", "text": "function animateChild(options = null) {\n return { type: 9 /* AnimateChild */, options };\n}", "title": "" }, { "docid": "13a8a485a64be75cb9b5ca661ed1829c", "score": "0.550251", "text": "function animateChild(options = null) {\n return { type: 9 /* AnimateChild */, options };\n}", "title": "" }, { "docid": "dbbf0aabef18ddbf599c18c082700a1d", "score": "0.5401067", "text": "function hasTransitionSupport() {\n var thisBody = document.body || document.documentElement;\n var thisStyle = thisBody.style;\n\n var support = (\n thisStyle.transition !== undefined ||\n thisStyle.WebkitTransition !== undefined ||\n thisStyle.MozTransition !== undefined ||\n thisStyle.MsTransition !== undefined ||\n thisStyle.OTransition !== undefined\n );\n\n return support;\n }", "title": "" }, { "docid": "3e308db2b42291bb81b4f4ddcb10173b", "score": "0.5126989", "text": "function supportTransitions() {\n\t\tvar b = document.body || document.documentElement;\n\t\tvar s = b.style;\n\t\tvar p = 'transition';\n\t\tif(typeof s[p] == 'string') {return true; }\n\n\t\t// Tests for vendor specific prop\n\t\tv = ['Moz', 'Webkit', 'Khtml', 'O', 'ms', 'Icab'],\n\t\tp = p.charAt(0).toUpperCase() + p.substr(1);\n\t\tfor(var i=0; i<v.length; i++) {\n\t\t if(typeof s[v[i] + p] == 'string') { return true; }\n\t\t}\n\t\treturn false;\n\t}", "title": "" }, { "docid": "a98d40aa42c36470ef5f0d257cccaf51", "score": "0.508177", "text": "function transitionSupport() {\n\t// env.window is not defined yet when this is called\n\tvar b = win.document.body || win.document.documentElement,\n\t\ts = b.style,\n\t\tp = 'transition',\n\t\tv = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'];\n\t\n\tif (typeof s[p] == 'string') { return true; }\n\t\n\tp = p.charAt(0).toUpperCase() + p.substr(1);\n\tfor (var i=0; i<v.length; i++) {\n\t\tif (typeof s[v[i] + p] == 'string') { return true; }\n\t}\n\treturn false;\n}", "title": "" }, { "docid": "2573c7921637c510ff1745e1105bd72d", "score": "0.5056597", "text": "function transitionSupport() {\n\t\n\t// env.window is not defined yet when this is called\n\tif (!win) return false;\n\t\n\tvar b = win.document.body || win.document.documentElement,\n\t\ts = b.style,\n\t\tp = 'transition',\n\t\tv = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'];\n\t\n\tif (typeof s[p] == 'string') { return true; }\n\t\n\tp = p.charAt(0).toUpperCase() + p.substr(1);\n\tfor (var i=0; i<v.length; i++) {\n\t\tif (typeof s[v[i] + p] == 'string') { return true; }\n\t}\n\treturn false;\n}", "title": "" }, { "docid": "3134958aa375b70a880f0eb1b366e645", "score": "0.50347584", "text": "function doAnimation() {\n slideContainer.children[0].classList.add('moveSlide')\n slideContainer.children[1].classList.add('moveSlide')\n addAnimationEventToChild()\n}", "title": "" }, { "docid": "a16f6d4c5f7289321f70cee6e8e7d16b", "score": "0.5000752", "text": "function supportsTransitions() {\n var b = document.body || document.documentElement,\n s = b.style,\n p = 'transition';\n \n if(typeof s[p] == 'string') {return true; }\n\n v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'],\n p = p.charAt(0).toUpperCase() + p.substr(1);\n for(var i=0; i<v.length; i++) {\n if(typeof s[v[i] + p] == 'string') { return true; }\n }\n return false;\n }", "title": "" }, { "docid": "831466988ca319a26ac70ad029f78046", "score": "0.4984975", "text": "function supportsTransitions() {\r\n\t\tvar b = document.body || document.documentElement,\r\n\t\t\ts = b.style,\r\n\t\t\tp = 'transition';\r\n\t\t\r\n\t\tif(typeof s[p] == 'string') {return true; }\r\n\r\n\t\tv = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'],\r\n\t\tp = p.charAt(0).toUpperCase() + p.substr(1);\r\n\t\tfor(var i=0; i<v.length; i++) {\r\n\t\t\tif(typeof s[v[i] + p] == 'string') { return true; }\r\n\t\t}\r\n\t\treturn false;\r\n\t}", "title": "" }, { "docid": "27f9f84f264b59a5c1a33fc2fa3a8b1c", "score": "0.49702328", "text": "function supportsTransitions() {\n\t\tvar b = document.body || document.documentElement,\n\t\t\ts = b.style,\n\t\t\tp = 'transition',\n\t\t\tv = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'];\n\t\t\n\t\tif (typeof s[p] == 'string') { return true; }\n\t\t\n\t\tp = p.charAt(0).toUpperCase() + p.substr(1);\n\t\tfor (var i=0; i<v.length; i++) {\n\t\t\tif (typeof s[v[i] + p] == 'string') { return true; }\n\t\t}\n\t\treturn false;\n\t}", "title": "" }, { "docid": "359790f72bbafedd078a6112ecdf75ac", "score": "0.49066743", "text": "_expandSingleChildRow(childRow) {\r\n if (!childRow) {\r\n return;\r\n }\r\n\r\n if (this.animation !== 'none') {\r\n childRow.classList.remove('smart-hidden');\r\n\r\n requestAnimationFrame(() => {\r\n childRow.classList.add('no-height');\r\n\r\n childRow.ontransitionend = function () {\r\n childRow.classList.remove('no-height');\r\n childRow.ontransitionend = null;\r\n }\r\n\r\n childRow.removeAttribute('aria-hidden');\r\n childRow.classList.remove('collapsed');\r\n });\r\n }\r\n else {\r\n childRow.removeAttribute('aria-hidden');\r\n childRow.classList.remove('collapsed', 'smart-hidden');\r\n }\r\n }", "title": "" }, { "docid": "a42103155a99111850116736c120dd0a", "score": "0.4878693", "text": "function supportsTransitions() {\n\t\tvar bodyStyle = (document.body || document.documentElement).style,\n\t\t\tvendors = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms'];\n\n\t\tif(typeof bodyStyle['transition'] == 'string')\n\t\t\treturn true;\n\n\t\tfor(var i=0; i<bodyStyle.length; i++) {\n\t\t\tif(typeof bodyStyle[vendors[i] + 'Transition'] == 'string')\n\t\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "title": "" }, { "docid": "092464a5f95e8ff50f8b6ff258dffb1c", "score": "0.4860235", "text": "function genAnimate(ChildComponent) {\n var Animate = function (_React$Component) {\n __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_inherits___default()(Animate, _React$Component);\n\n function Animate() {\n var _temp, _this, _ret;\n\n __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, Animate);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return _ret = (_temp = (_this = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default()(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {\n appeared: true,\n mergedChildren: []\n }, _this.onChildLeaved = function (key) {\n // Remove child which not exist anymore\n if (!_this.hasChild(key)) {\n var mergedChildren = _this.state.mergedChildren;\n\n _this.setState({\n mergedChildren: mergedChildren.filter(function (node) {\n return node.key !== key;\n })\n });\n }\n }, _this.hasChild = function (key) {\n var children = _this.props.children;\n\n\n return Object(__WEBPACK_IMPORTED_MODULE_7_rc_util_es_Children_toArray__[\"a\" /* default */])(children).some(function (node) {\n return node && node.key === key;\n });\n }, _temp), __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_possibleConstructorReturn___default()(_this, _ret);\n }\n // [Legacy] Not sure usage\n // commit: https://github.com/react-component/animate/commit/0a1cbfd647407498b10a8c6602a2dea80b42e324\n // eslint-disable-line\n\n Animate.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {\n var _prevState$prevProps = prevState.prevProps,\n prevProps = _prevState$prevProps === undefined ? {} : _prevState$prevProps;\n\n var newState = {\n prevProps: Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"b\" /* cloneProps */])(nextProps, clonePropList)\n };\n var showProp = nextProps.showProp;\n\n\n function processState(propName, updater) {\n if (prevProps[propName] !== nextProps[propName]) {\n updater(nextProps[propName]);\n return true;\n }\n return false;\n }\n\n processState('children', function (children) {\n var currentChildren = Object(__WEBPACK_IMPORTED_MODULE_7_rc_util_es_Children_toArray__[\"a\" /* default */])(children).filter(function (node) {\n return node;\n });\n var prevChildren = prevState.mergedChildren.filter(function (node) {\n // Remove prev child if not show anymore\n if (currentChildren.every(function (_ref) {\n var key = _ref.key;\n return key !== node.key;\n }) && showProp && !node.props[showProp]) {\n return false;\n }\n return true;\n });\n\n // Merge prev children to keep the animation\n newState.mergedChildren = Object(__WEBPACK_IMPORTED_MODULE_10__util__[\"e\" /* mergeChildren */])(prevChildren, currentChildren);\n });\n\n return newState;\n };\n\n Animate.prototype.componentDidMount = function componentDidMount() {\n // No need to re-render\n this.state.appeared = false;\n };\n\n Animate.prototype.render = function render() {\n var _this2 = this;\n\n var _state = this.state,\n appeared = _state.appeared,\n mergedChildren = _state.mergedChildren;\n var _props = this.props,\n Component = _props.component,\n componentProps = _props.componentProps,\n className = _props.className,\n style = _props.style,\n showProp = _props.showProp;\n\n\n var $children = mergedChildren.map(function (node) {\n if (mergedChildren.length > 1 && !node.key) {\n __WEBPACK_IMPORTED_MODULE_8_fbjs_lib_warning___default()(false, 'must set key for <rc-animate> children');\n return null;\n }\n\n var show = true;\n\n if (!_this2.hasChild(node.key)) {\n show = false;\n } else if (showProp) {\n show = node.props[showProp];\n }\n\n var key = node.key || defaultKey;\n\n return __WEBPACK_IMPORTED_MODULE_4_react___default.a.createElement(\n ChildComponent,\n __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, _this2.props, {\n appeared: appeared,\n show: show,\n className: node.props.className,\n style: node.props.style,\n key: key,\n\n animateKey: node.key // Keep trans origin key\n , onChildLeaved: _this2.onChildLeaved\n }),\n node\n );\n });\n\n // Wrap with component\n if (Component) {\n var passedProps = this.props;\n if (typeof Component === 'string') {\n passedProps = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({\n className: className,\n style: style\n }, componentProps);\n }\n\n return __WEBPACK_IMPORTED_MODULE_4_react___default.a.createElement(\n Component,\n passedProps,\n $children\n );\n }\n\n return $children[0] || null;\n };\n\n return Animate;\n }(__WEBPACK_IMPORTED_MODULE_4_react___default.a.Component);\n\n Animate.isAnimate = true;\n Animate.propTypes = {\n component: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.any,\n componentProps: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,\n animation: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,\n transitionName: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object]),\n transitionEnter: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n transitionAppear: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n exclusive: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n transitionLeave: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.bool,\n onEnd: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n onEnter: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n onLeave: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n onAppear: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.func,\n showProp: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string,\n children: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.node,\n style: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.object,\n className: __WEBPACK_IMPORTED_MODULE_5_prop_types___default.a.string\n };\n Animate.defaultProps = {\n animation: {},\n component: 'span',\n componentProps: {},\n transitionEnter: true,\n transitionLeave: true,\n transitionAppear: false\n };\n\n\n Object(__WEBPACK_IMPORTED_MODULE_6_react_lifecycles_compat__[\"polyfill\"])(Animate);\n\n return Animate;\n}", "title": "" }, { "docid": "18e7fef439f9f9c9f43e4753b6b670ff", "score": "0.4812363", "text": "function genAnimate(ChildComponent) {\n var Animate = function (_React$Component) {\n __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_inherits___default()(Animate, _React$Component);\n\n function Animate() {\n var _ref;\n\n var _temp, _this, _ret;\n\n __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, Animate);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return _ret = (_temp = (_this = __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_possibleConstructorReturn___default()(this, (_ref = Animate.__proto__ || Object.getPrototypeOf(Animate)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n appeared: true,\n mergedChildren: []\n }, _this.onChildLeaved = function (key) {\n // Remove child which not exist anymore\n if (!_this.hasChild(key)) {\n var mergedChildren = _this.state.mergedChildren;\n\n _this.setState({\n mergedChildren: mergedChildren.filter(function (node) {\n return node.key !== key;\n })\n });\n }\n }, _this.hasChild = function (key) {\n var children = _this.props.children;\n\n\n return Object(__WEBPACK_IMPORTED_MODULE_8_rc_util_es_Children_toArray__[\"a\" /* default */])(children).some(function (node) {\n return node && node.key === key;\n });\n }, _temp), __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_possibleConstructorReturn___default()(_this, _ret);\n }\n // [Legacy] Not sure usage\n // commit: https://github.com/react-component/animate/commit/0a1cbfd647407498b10a8c6602a2dea80b42e324\n // eslint-disable-line\n\n __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(Animate, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n // No need to re-render\n this.state.appeared = false;\n }\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n var _state = this.state,\n appeared = _state.appeared,\n mergedChildren = _state.mergedChildren;\n var _props = this.props,\n Component = _props.component,\n componentProps = _props.componentProps,\n className = _props.className,\n style = _props.style,\n showProp = _props.showProp;\n\n\n var $children = mergedChildren.map(function (node) {\n if (mergedChildren.length > 1 && !node.key) {\n __WEBPACK_IMPORTED_MODULE_9_fbjs_lib_warning___default()(false, 'must set key for <rc-animate> children');\n return null;\n }\n\n var show = true;\n\n if (!_this2.hasChild(node.key)) {\n show = false;\n } else if (showProp) {\n show = node.props[showProp];\n }\n\n var key = node.key || defaultKey;\n\n return __WEBPACK_IMPORTED_MODULE_5_react___default.a.createElement(\n ChildComponent,\n __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, _this2.props, {\n appeared: appeared,\n show: show,\n className: node.props.className,\n style: node.props.style,\n key: key,\n\n animateKey: node.key // Keep trans origin key\n , onChildLeaved: _this2.onChildLeaved\n }),\n node\n );\n });\n\n // Wrap with component\n if (Component) {\n var passedProps = this.props;\n if (typeof Component === 'string') {\n passedProps = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({\n className: className,\n style: style\n }, componentProps);\n }\n\n return __WEBPACK_IMPORTED_MODULE_5_react___default.a.createElement(\n Component,\n passedProps,\n $children\n );\n }\n\n return $children[0] || null;\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(nextProps, prevState) {\n var _prevState$prevProps = prevState.prevProps,\n prevProps = _prevState$prevProps === undefined ? {} : _prevState$prevProps;\n\n var newState = {\n prevProps: Object(__WEBPACK_IMPORTED_MODULE_11__util__[\"b\" /* cloneProps */])(nextProps, clonePropList)\n };\n var showProp = nextProps.showProp;\n\n\n function processState(propName, updater) {\n if (prevProps[propName] !== nextProps[propName]) {\n updater(nextProps[propName]);\n return true;\n }\n return false;\n }\n\n processState('children', function (children) {\n var currentChildren = Object(__WEBPACK_IMPORTED_MODULE_8_rc_util_es_Children_toArray__[\"a\" /* default */])(children).filter(function (node) {\n return node;\n });\n var prevChildren = prevState.mergedChildren.filter(function (node) {\n // Remove prev child if not show anymore\n if (currentChildren.every(function (_ref2) {\n var key = _ref2.key;\n return key !== node.key;\n }) && showProp && !node.props[showProp]) {\n return false;\n }\n return true;\n });\n\n // Merge prev children to keep the animation\n newState.mergedChildren = Object(__WEBPACK_IMPORTED_MODULE_11__util__[\"e\" /* mergeChildren */])(prevChildren, currentChildren);\n });\n\n return newState;\n }\n }]);\n\n return Animate;\n }(__WEBPACK_IMPORTED_MODULE_5_react___default.a.Component);\n\n Animate.isAnimate = true;\n Animate.propTypes = {\n component: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.any,\n componentProps: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.object,\n animation: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.object,\n transitionName: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.object]),\n transitionEnter: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,\n transitionAppear: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,\n exclusive: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,\n transitionLeave: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.bool,\n onEnd: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func,\n onEnter: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func,\n onLeave: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func,\n onAppear: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.func,\n showProp: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.string,\n children: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.node,\n style: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.object,\n className: __WEBPACK_IMPORTED_MODULE_6_prop_types___default.a.string\n };\n Animate.defaultProps = {\n animation: {},\n component: 'span',\n componentProps: {},\n transitionEnter: true,\n transitionLeave: true,\n transitionAppear: false\n };\n\n\n Object(__WEBPACK_IMPORTED_MODULE_7_react_lifecycles_compat__[\"polyfill\"])(Animate);\n\n return Animate;\n}", "title": "" }, { "docid": "60cd9f0146d4789247084acb76961bee", "score": "0.47827205", "text": "_supportsTransitionEnd() {\n if (window.QUnit) return false\n\n const el = document.body || document.documentElement\n\n if (!el) return false\n\n let result = false\n TRANSITION_PROPERTIES.forEach(evnt => {\n if (typeof el.style[evnt] !== 'undefined') result = true\n })\n\n return result\n }", "title": "" }, { "docid": "9d63d8fb5548017e0e53b6ee600e06ba", "score": "0.47516328", "text": "function AnimationAnimateChildMetadata() { }", "title": "" }, { "docid": "9d63d8fb5548017e0e53b6ee600e06ba", "score": "0.47516328", "text": "function AnimationAnimateChildMetadata() { }", "title": "" }, { "docid": "651ae949911b37c53ca82bb1315d5d91", "score": "0.47303116", "text": "function areAnimationsAllowed(node, parentNode, event) {\n var bodyNode = $document[0].body;\n var rootNode = getDomNode($rootElement);\n\n var bodyNodeDetected = (node === bodyNode) || node.nodeName === 'HTML';\n var rootNodeDetected = (node === rootNode);\n var parentAnimationDetected = false;\n var elementDisabled = disabledElementsLookup.get(node);\n var animateChildren;\n\n var parentHost = jqLite.data(node, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentNode = getDomNode(parentHost);\n }\n\n while (parentNode) {\n if (!rootNodeDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootNodeDetected = (parentNode === rootNode);\n }\n\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentNodeDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentNodeDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentNodeDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentNode, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyNodeDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyNodeDetected = (parentNode === bodyNode);\n }\n\n if (bodyNodeDetected && rootNodeDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootNodeDetected) {\n // If `rootNode` is not detected, check if `parentNode` is pinned to another element\n parentHost = jqLite.data(parentNode, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentNode = getDomNode(parentHost);\n continue;\n }\n }\n\n parentNode = parentNode.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootNodeDetected && bodyNodeDetected;\n }", "title": "" }, { "docid": "651ae949911b37c53ca82bb1315d5d91", "score": "0.47303116", "text": "function areAnimationsAllowed(node, parentNode, event) {\n var bodyNode = $document[0].body;\n var rootNode = getDomNode($rootElement);\n\n var bodyNodeDetected = (node === bodyNode) || node.nodeName === 'HTML';\n var rootNodeDetected = (node === rootNode);\n var parentAnimationDetected = false;\n var elementDisabled = disabledElementsLookup.get(node);\n var animateChildren;\n\n var parentHost = jqLite.data(node, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentNode = getDomNode(parentHost);\n }\n\n while (parentNode) {\n if (!rootNodeDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootNodeDetected = (parentNode === rootNode);\n }\n\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentNodeDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentNodeDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentNodeDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentNode, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyNodeDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyNodeDetected = (parentNode === bodyNode);\n }\n\n if (bodyNodeDetected && rootNodeDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootNodeDetected) {\n // If `rootNode` is not detected, check if `parentNode` is pinned to another element\n parentHost = jqLite.data(parentNode, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentNode = getDomNode(parentHost);\n continue;\n }\n }\n\n parentNode = parentNode.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootNodeDetected && bodyNodeDetected;\n }", "title": "" }, { "docid": "651ae949911b37c53ca82bb1315d5d91", "score": "0.47303116", "text": "function areAnimationsAllowed(node, parentNode, event) {\n var bodyNode = $document[0].body;\n var rootNode = getDomNode($rootElement);\n\n var bodyNodeDetected = (node === bodyNode) || node.nodeName === 'HTML';\n var rootNodeDetected = (node === rootNode);\n var parentAnimationDetected = false;\n var elementDisabled = disabledElementsLookup.get(node);\n var animateChildren;\n\n var parentHost = jqLite.data(node, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentNode = getDomNode(parentHost);\n }\n\n while (parentNode) {\n if (!rootNodeDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootNodeDetected = (parentNode === rootNode);\n }\n\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentNodeDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentNodeDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentNodeDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentNode, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyNodeDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyNodeDetected = (parentNode === bodyNode);\n }\n\n if (bodyNodeDetected && rootNodeDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootNodeDetected) {\n // If `rootNode` is not detected, check if `parentNode` is pinned to another element\n parentHost = jqLite.data(parentNode, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentNode = getDomNode(parentHost);\n continue;\n }\n }\n\n parentNode = parentNode.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootNodeDetected && bodyNodeDetected;\n }", "title": "" }, { "docid": "651ae949911b37c53ca82bb1315d5d91", "score": "0.47303116", "text": "function areAnimationsAllowed(node, parentNode, event) {\n var bodyNode = $document[0].body;\n var rootNode = getDomNode($rootElement);\n\n var bodyNodeDetected = (node === bodyNode) || node.nodeName === 'HTML';\n var rootNodeDetected = (node === rootNode);\n var parentAnimationDetected = false;\n var elementDisabled = disabledElementsLookup.get(node);\n var animateChildren;\n\n var parentHost = jqLite.data(node, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentNode = getDomNode(parentHost);\n }\n\n while (parentNode) {\n if (!rootNodeDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootNodeDetected = (parentNode === rootNode);\n }\n\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentNodeDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentNodeDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentNodeDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentNode, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyNodeDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyNodeDetected = (parentNode === bodyNode);\n }\n\n if (bodyNodeDetected && rootNodeDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootNodeDetected) {\n // If `rootNode` is not detected, check if `parentNode` is pinned to another element\n parentHost = jqLite.data(parentNode, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentNode = getDomNode(parentHost);\n continue;\n }\n }\n\n parentNode = parentNode.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootNodeDetected && bodyNodeDetected;\n }", "title": "" }, { "docid": "651ae949911b37c53ca82bb1315d5d91", "score": "0.47303116", "text": "function areAnimationsAllowed(node, parentNode, event) {\n var bodyNode = $document[0].body;\n var rootNode = getDomNode($rootElement);\n\n var bodyNodeDetected = (node === bodyNode) || node.nodeName === 'HTML';\n var rootNodeDetected = (node === rootNode);\n var parentAnimationDetected = false;\n var elementDisabled = disabledElementsLookup.get(node);\n var animateChildren;\n\n var parentHost = jqLite.data(node, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentNode = getDomNode(parentHost);\n }\n\n while (parentNode) {\n if (!rootNodeDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootNodeDetected = (parentNode === rootNode);\n }\n\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentNodeDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentNodeDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentNodeDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentNode, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyNodeDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyNodeDetected = (parentNode === bodyNode);\n }\n\n if (bodyNodeDetected && rootNodeDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootNodeDetected) {\n // If `rootNode` is not detected, check if `parentNode` is pinned to another element\n parentHost = jqLite.data(parentNode, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentNode = getDomNode(parentHost);\n continue;\n }\n }\n\n parentNode = parentNode.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootNodeDetected && bodyNodeDetected;\n }", "title": "" }, { "docid": "2f354b8c0b6e6d7be5b8bdf2482094e0", "score": "0.47280863", "text": "function areAnimationsAllowed(node, parentNode, event) {\n var bodyNode = $document[0].body;\n var rootNode = getDomNode($rootElement);\n\n var bodyNodeDetected = (node === bodyNode) || node.nodeName === 'HTML';\n var rootNodeDetected = (node === rootNode);\n var parentAnimationDetected = false;\n var elementDisabled = disabledElementsLookup.get(node);\n var animateChildren;\n\n var parentHost = jqLite.data(node, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentNode = getDomNode(parentHost);\n }\n\n while (parentNode) {\n if (!rootNodeDetected) {\n // AngularJS doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootNodeDetected = (parentNode === rootNode);\n }\n\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentNodeDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentNodeDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentNodeDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentNode, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyNodeDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyNodeDetected = (parentNode === bodyNode);\n }\n\n if (bodyNodeDetected && rootNodeDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootNodeDetected) {\n // If `rootNode` is not detected, check if `parentNode` is pinned to another element\n parentHost = jqLite.data(parentNode, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentNode = getDomNode(parentHost);\n continue;\n }\n }\n\n parentNode = parentNode.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootNodeDetected && bodyNodeDetected;\n }", "title": "" }, { "docid": "2f354b8c0b6e6d7be5b8bdf2482094e0", "score": "0.47280863", "text": "function areAnimationsAllowed(node, parentNode, event) {\n var bodyNode = $document[0].body;\n var rootNode = getDomNode($rootElement);\n\n var bodyNodeDetected = (node === bodyNode) || node.nodeName === 'HTML';\n var rootNodeDetected = (node === rootNode);\n var parentAnimationDetected = false;\n var elementDisabled = disabledElementsLookup.get(node);\n var animateChildren;\n\n var parentHost = jqLite.data(node, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentNode = getDomNode(parentHost);\n }\n\n while (parentNode) {\n if (!rootNodeDetected) {\n // AngularJS doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootNodeDetected = (parentNode === rootNode);\n }\n\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentNodeDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentNodeDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentNodeDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentNode, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyNodeDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyNodeDetected = (parentNode === bodyNode);\n }\n\n if (bodyNodeDetected && rootNodeDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootNodeDetected) {\n // If `rootNode` is not detected, check if `parentNode` is pinned to another element\n parentHost = jqLite.data(parentNode, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentNode = getDomNode(parentHost);\n continue;\n }\n }\n\n parentNode = parentNode.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootNodeDetected && bodyNodeDetected;\n }", "title": "" }, { "docid": "14a50209954fe21f5ea5b40fa89fbb9a", "score": "0.47227705", "text": "function genAnimate(ChildComponent) {\n var Animate = function (_React$Component) {\n babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(Animate, _React$Component);\n\n function Animate() {\n var _ref;\n\n var _temp, _this, _ret;\n\n babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, Animate);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return _ret = (_temp = (_this = babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(this, (_ref = Animate.__proto__ || Object.getPrototypeOf(Animate)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n appeared: true,\n mergedChildren: []\n }, _this.onChildLeaved = function (key) {\n // Remove child which not exist anymore\n if (!_this.hasChild(key)) {\n var mergedChildren = _this.state.mergedChildren;\n\n _this.setState({\n mergedChildren: mergedChildren.filter(function (node) {\n return node.key !== key;\n })\n });\n }\n }, _this.hasChild = function (key) {\n var children = _this.props.children;\n\n\n return Object(rc_util_es_Children_toArray__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(children).some(function (node) {\n return node && node.key === key;\n });\n }, _temp), babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(_this, _ret);\n }\n // [Legacy] Not sure usage\n // commit: https://github.com/react-component/animate/commit/0a1cbfd647407498b10a8c6602a2dea80b42e324\n // eslint-disable-line\n\n babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(Animate, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n // No need to re-render\n this.state.appeared = false;\n }\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n var _state = this.state,\n appeared = _state.appeared,\n mergedChildren = _state.mergedChildren;\n var _props = this.props,\n Component = _props.component,\n componentProps = _props.componentProps,\n className = _props.className,\n style = _props.style,\n showProp = _props.showProp;\n\n\n var $children = mergedChildren.map(function (node) {\n if (mergedChildren.length > 1 && !node.key) {\n fbjs_lib_warning__WEBPACK_IMPORTED_MODULE_9___default()(false, 'must set key for <rc-animate> children');\n return null;\n }\n\n var show = true;\n\n if (!_this2.hasChild(node.key)) {\n show = false;\n } else if (showProp) {\n show = node.props[showProp];\n }\n\n var key = node.key || defaultKey;\n\n return react__WEBPACK_IMPORTED_MODULE_5___default.a.createElement(\n ChildComponent,\n babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, _this2.props, {\n appeared: appeared,\n show: show,\n className: node.props.className,\n style: node.props.style,\n key: key,\n\n animateKey: node.key // Keep trans origin key\n , onChildLeaved: _this2.onChildLeaved\n }),\n node\n );\n });\n\n // Wrap with component\n if (Component) {\n var passedProps = this.props;\n if (typeof Component === 'string') {\n passedProps = babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({\n className: className,\n style: style\n }, componentProps);\n }\n\n return react__WEBPACK_IMPORTED_MODULE_5___default.a.createElement(\n Component,\n passedProps,\n $children\n );\n }\n\n return $children[0] || null;\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(nextProps, prevState) {\n var _prevState$prevProps = prevState.prevProps,\n prevProps = _prevState$prevProps === undefined ? {} : _prevState$prevProps;\n\n var newState = {\n prevProps: Object(_util__WEBPACK_IMPORTED_MODULE_11__[\"cloneProps\"])(nextProps, clonePropList)\n };\n var showProp = nextProps.showProp;\n\n\n function processState(propName, updater) {\n if (prevProps[propName] !== nextProps[propName]) {\n updater(nextProps[propName]);\n return true;\n }\n return false;\n }\n\n processState('children', function (children) {\n var currentChildren = Object(rc_util_es_Children_toArray__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(children).filter(function (node) {\n return node;\n });\n var prevChildren = prevState.mergedChildren.filter(function (node) {\n // Remove prev child if not show anymore\n if (currentChildren.every(function (_ref2) {\n var key = _ref2.key;\n return key !== node.key;\n }) && showProp && !node.props[showProp]) {\n return false;\n }\n return true;\n });\n\n // Merge prev children to keep the animation\n newState.mergedChildren = Object(_util__WEBPACK_IMPORTED_MODULE_11__[\"mergeChildren\"])(prevChildren, currentChildren);\n });\n\n return newState;\n }\n }]);\n\n return Animate;\n }(react__WEBPACK_IMPORTED_MODULE_5___default.a.Component);\n\n Animate.isAnimate = true;\n Animate.propTypes = {\n component: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.any,\n componentProps: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object,\n animation: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object,\n transitionName: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object]),\n transitionEnter: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n transitionAppear: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n exclusive: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n transitionLeave: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n onEnd: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n onEnter: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n onLeave: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n onAppear: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n showProp: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.string,\n children: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.node,\n style: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object,\n className: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.string\n };\n Animate.defaultProps = {\n animation: {},\n component: 'span',\n componentProps: {},\n transitionEnter: true,\n transitionLeave: true,\n transitionAppear: false\n };\n\n\n Object(react_lifecycles_compat__WEBPACK_IMPORTED_MODULE_7__[\"polyfill\"])(Animate);\n\n return Animate;\n}", "title": "" }, { "docid": "14a50209954fe21f5ea5b40fa89fbb9a", "score": "0.47227705", "text": "function genAnimate(ChildComponent) {\n var Animate = function (_React$Component) {\n babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_4___default()(Animate, _React$Component);\n\n function Animate() {\n var _ref;\n\n var _temp, _this, _ret;\n\n babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, Animate);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return _ret = (_temp = (_this = babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(this, (_ref = Animate.__proto__ || Object.getPrototypeOf(Animate)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n appeared: true,\n mergedChildren: []\n }, _this.onChildLeaved = function (key) {\n // Remove child which not exist anymore\n if (!_this.hasChild(key)) {\n var mergedChildren = _this.state.mergedChildren;\n\n _this.setState({\n mergedChildren: mergedChildren.filter(function (node) {\n return node.key !== key;\n })\n });\n }\n }, _this.hasChild = function (key) {\n var children = _this.props.children;\n\n\n return Object(rc_util_es_Children_toArray__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(children).some(function (node) {\n return node && node.key === key;\n });\n }, _temp), babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(_this, _ret);\n }\n // [Legacy] Not sure usage\n // commit: https://github.com/react-component/animate/commit/0a1cbfd647407498b10a8c6602a2dea80b42e324\n // eslint-disable-line\n\n babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(Animate, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n // No need to re-render\n this.state.appeared = false;\n }\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n var _state = this.state,\n appeared = _state.appeared,\n mergedChildren = _state.mergedChildren;\n var _props = this.props,\n Component = _props.component,\n componentProps = _props.componentProps,\n className = _props.className,\n style = _props.style,\n showProp = _props.showProp;\n\n\n var $children = mergedChildren.map(function (node) {\n if (mergedChildren.length > 1 && !node.key) {\n fbjs_lib_warning__WEBPACK_IMPORTED_MODULE_9___default()(false, 'must set key for <rc-animate> children');\n return null;\n }\n\n var show = true;\n\n if (!_this2.hasChild(node.key)) {\n show = false;\n } else if (showProp) {\n show = node.props[showProp];\n }\n\n var key = node.key || defaultKey;\n\n return react__WEBPACK_IMPORTED_MODULE_5___default.a.createElement(\n ChildComponent,\n babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, _this2.props, {\n appeared: appeared,\n show: show,\n className: node.props.className,\n style: node.props.style,\n key: key,\n\n animateKey: node.key // Keep trans origin key\n , onChildLeaved: _this2.onChildLeaved\n }),\n node\n );\n });\n\n // Wrap with component\n if (Component) {\n var passedProps = this.props;\n if (typeof Component === 'string') {\n passedProps = babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({\n className: className,\n style: style\n }, componentProps);\n }\n\n return react__WEBPACK_IMPORTED_MODULE_5___default.a.createElement(\n Component,\n passedProps,\n $children\n );\n }\n\n return $children[0] || null;\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(nextProps, prevState) {\n var _prevState$prevProps = prevState.prevProps,\n prevProps = _prevState$prevProps === undefined ? {} : _prevState$prevProps;\n\n var newState = {\n prevProps: Object(_util__WEBPACK_IMPORTED_MODULE_11__[\"cloneProps\"])(nextProps, clonePropList)\n };\n var showProp = nextProps.showProp;\n\n\n function processState(propName, updater) {\n if (prevProps[propName] !== nextProps[propName]) {\n updater(nextProps[propName]);\n return true;\n }\n return false;\n }\n\n processState('children', function (children) {\n var currentChildren = Object(rc_util_es_Children_toArray__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(children).filter(function (node) {\n return node;\n });\n var prevChildren = prevState.mergedChildren.filter(function (node) {\n // Remove prev child if not show anymore\n if (currentChildren.every(function (_ref2) {\n var key = _ref2.key;\n return key !== node.key;\n }) && showProp && !node.props[showProp]) {\n return false;\n }\n return true;\n });\n\n // Merge prev children to keep the animation\n newState.mergedChildren = Object(_util__WEBPACK_IMPORTED_MODULE_11__[\"mergeChildren\"])(prevChildren, currentChildren);\n });\n\n return newState;\n }\n }]);\n\n return Animate;\n }(react__WEBPACK_IMPORTED_MODULE_5___default.a.Component);\n\n Animate.isAnimate = true;\n Animate.propTypes = {\n component: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.any,\n componentProps: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object,\n animation: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object,\n transitionName: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object]),\n transitionEnter: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n transitionAppear: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n exclusive: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n transitionLeave: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.bool,\n onEnd: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n onEnter: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n onLeave: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n onAppear: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.func,\n showProp: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.string,\n children: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.node,\n style: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.object,\n className: prop_types__WEBPACK_IMPORTED_MODULE_6___default.a.string\n };\n Animate.defaultProps = {\n animation: {},\n component: 'span',\n componentProps: {},\n transitionEnter: true,\n transitionLeave: true,\n transitionAppear: false\n };\n\n\n Object(react_lifecycles_compat__WEBPACK_IMPORTED_MODULE_7__[\"polyfill\"])(Animate);\n\n return Animate;\n}", "title": "" }, { "docid": "460da494c453b208b6d4f082f9a019bf", "score": "0.4717081", "text": "_collapseSingleChildRow(childRow) {\r\n if (!childRow) {\r\n return;\r\n }\r\n\r\n if (this.animation !== 'none') {\r\n childRow.ontransitionend = function () {\r\n childRow.classList.add('smart-hidden');\r\n childRow.ontransitionend = null;\r\n }\r\n }\r\n else {\r\n childRow.classList.add('smart-hidden');\r\n }\r\n\r\n childRow.setAttribute('aria-hidden', true);\r\n childRow.classList.add('collapsed');\r\n }", "title": "" }, { "docid": "ea41d31945628da44beebe3f0feabe12", "score": "0.46916994", "text": "animateNode(node, animationName, callback) {\n node.classList.add('animated', animationName);\n \n function handleAnimationEnd() {\n node.classList.remove('animated', animationName)\n node.removeEventListener('animationend', handleAnimationEnd)\n\n if (typeof callback === 'function') {\n callback();\n }\n }\n node.addEventListener('animationend', handleAnimationEnd)\n }", "title": "" }, { "docid": "5eef0e01b074d95113fba0654165182b", "score": "0.46112058", "text": "function useTransition(inheritedTransition) {\n var valid = validTransition(inheritedTransition);\n\n if (inheritedTransition.ease && !valid.ease) {\n console.log(\"chart: creating transition. inherited transition expired on node:\", \n inheritedTransition.node());\n return valid.transition().duration(150); \n } \n\n return valid;\n }", "title": "" }, { "docid": "f775679b0ce0f5994a1e3923baa5d299", "score": "0.46020466", "text": "componentWillUpdate(nextProps) {\n const {\n cachedChildren\n } = this.state;\n const child = toChildArray(nextProps.children)[0];\n if (cachedChildren === child) return null;\n const patch = {\n cachedChildren: child\n }; // Enter transition\n\n if (child && !cachedChildren) {\n patch.className = `${transitionName}-enter`;\n cancelAnimationFrame(this.animationFrame);\n clearTimeout(this.leaveTimeout);\n this.leaveTimeout = undefined;\n this.animationFrame = requestAnimationFrame(() => {\n // Force it to render before we add the active class\n // this.base.getBoundingClientRect()\n this.setState({\n className: `${transitionName}-enter ${transitionName}-enter-active`\n });\n this.enterTimeout = setTimeout(() => {\n this.setState({\n className: ''\n });\n }, duration);\n });\n } // Leave transition\n\n\n if (cachedChildren && !child && this.leaveTimeout === undefined) {\n patch.cachedChildren = cachedChildren;\n patch.className = `${transitionName}-leave`;\n cancelAnimationFrame(this.animationFrame);\n clearTimeout(this.enterTimeout);\n this.enterTimeout = undefined;\n this.animationFrame = requestAnimationFrame(() => {\n this.setState({\n className: `${transitionName}-leave ${transitionName}-leave-active`\n });\n this.leaveTimeout = setTimeout(() => {\n this.setState({\n cachedChildren: null,\n className: ''\n });\n }, duration);\n });\n } // eslint-disable-next-line\n\n\n this.setState(patch);\n }", "title": "" }, { "docid": "67b917cd45732d0458c78c7dadd8c95f", "score": "0.457991", "text": "animateElement(selector, animationName, callback) {\n const node = document.querySelector(selector);\n this.animateNode(node, animationName, callback);\n }", "title": "" }, { "docid": "c55a021be750594c468f95626e09515b", "score": "0.45342287", "text": "function transformWithTransition(element, transition) {\n // transition's properties:\n // - duration: Number representing the duration of the animation in milliseconds.\n // - timing: String representing the CSS timing function that controls the progress of the animation.\n // - to: The value of *element*'s transform property after the animation.\n var duration = transition.duration * _TransitionAnimation._animationFactor;\n var transitionProperty = _BaseUtils._browserStyleEquivalents[\"transition\"].scriptName;\n element.style[transitionProperty] = duration + \"ms \" + transformNames.cssName + \" \" + transition.timing;\n element.style[transformNames.scriptName] = transition.to;\n\n var finish;\n return new Promise(function (c) {\n var onTransitionEnd = function (eventObject) {\n if (eventObject.target === element && eventObject.propertyName === transformNames.cssName) {\n finish();\n }\n };\n\n var didFinish = false;\n finish = function () {\n if (!didFinish) {\n _Global.clearTimeout(timeoutId);\n element.removeEventListener(_BaseUtils._browserEventEquivalents[\"transitionEnd\"], onTransitionEnd);\n element.style[transitionProperty] = \"\";\n didFinish = true;\n }\n c();\n };\n\n // Watch dog timeout\n var timeoutId = _Global.setTimeout(function () {\n timeoutId = _Global.setTimeout(finish, duration);\n }, 50);\n\n element.addEventListener(_BaseUtils._browserEventEquivalents[\"transitionEnd\"], onTransitionEnd);\n }, function () {\n finish(); // On cancelation, complete the promise successfully to match PVL\n });\n }", "title": "" }, { "docid": "6206f6396a55abfe8de8953ad270bada", "score": "0.45123988", "text": "function areAnimationsAllowed(element, parentElement, event) {\n var bodyElement = jqLite($document[0].body);\n var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n var rootElementDetected = isMatchingElement(element, $rootElement);\n var parentAnimationDetected = false;\n var animateChildren;\n var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n var parentHost = element.data(NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentElement = parentHost;\n }\n\n while (parentElement && parentElement.length) {\n if (!rootElementDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootElementDetected = isMatchingElement(parentElement, $rootElement);\n }\n\n var parentNode = parentElement[0];\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentElementDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentElementDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentElementDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = parentElement.data(NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyElementDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n }\n\n if (bodyElementDetected && rootElementDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootElementDetected) {\n // If no rootElement is detected, check if the parentElement is pinned to another element\n parentHost = parentElement.data(NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentElement = parentHost;\n continue;\n }\n }\n\n parentElement = parentElement.parent();\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootElementDetected && bodyElementDetected;\n }", "title": "" }, { "docid": "6206f6396a55abfe8de8953ad270bada", "score": "0.45123988", "text": "function areAnimationsAllowed(element, parentElement, event) {\n var bodyElement = jqLite($document[0].body);\n var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n var rootElementDetected = isMatchingElement(element, $rootElement);\n var parentAnimationDetected = false;\n var animateChildren;\n var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n var parentHost = element.data(NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentElement = parentHost;\n }\n\n while (parentElement && parentElement.length) {\n if (!rootElementDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootElementDetected = isMatchingElement(parentElement, $rootElement);\n }\n\n var parentNode = parentElement[0];\n if (parentNode.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentNode) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentElementDisabled = disabledElementsLookup.get(parentNode);\n\n if (parentElementDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentElementDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = parentElement.data(NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyElementDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n }\n\n if (bodyElementDetected && rootElementDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootElementDetected) {\n // If no rootElement is detected, check if the parentElement is pinned to another element\n parentHost = parentElement.data(NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentElement = parentHost;\n continue;\n }\n }\n\n parentElement = parentElement.parent();\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootElementDetected && bodyElementDetected;\n }", "title": "" }, { "docid": "45ca53b916573e7fd354063ee5d6043e", "score": "0.44852224", "text": "function waitForCSSAnimation (target, propRegExp) {\n var deferred = $.Deferred();\n\n if (Browser.IS_IE9) {\n // They're not getting a transition, so we aren't getting an end event.\n triggerResize();\n return deferred.resolve();\n }\n // allows us to pass in jquery object, dom node, or string selector\n var $target = $(target);\n\n var durationString = $target.css('transition-duration');\n if (durationString[durationString.length - 1] !== 's') {\n triggerResize();\n return deferred.resolve();\n }\n\n var duration = 1000*parseFloat(durationString.slice(0, -1));\n\n // If the target element isn't in the body yet, we won't get animation events on it.\n if (!$target.closest('body').length) {\n triggerResize();\n return deferred.resolve();\n }\n\n target = $target[0];\n \n animationStarted();\n triggerResize();\n \n var events = 'transitionend webkitTransitionEnd MSTransitionEnd';\n \n // Can be called directly in case transitionend fails to fire.\n function _onAnimationEnd () {\n clearTimeout(transitionEndTimeout);\n $target.off(events);\n animationEnded();\n deferred.resolve();\n }\n\n function onAnimationEnd (evt) {\n // must have the exact target\n if (evt) {\n if (evt.target !== target) return;\n if (propRegExp && !evt.originalEvent.propertyName.match(propRegExp)) {\n return;\n }\n }\n \n _onAnimationEnd();\n }\n\n $target.on(events, onAnimationEnd);\n // Transitions sometimes fail to fire (epecially noticeable in firefox). This might\n // happen if the transition doesn't actually cause a repaint, or maybe sometimes its\n // just a bug. In any case, look out for it and take corrective action.\n var transitionEndTimeout = setTimeout(function () {\n _onAnimationEnd();\n }, duration + 100);\n return deferred;\n}", "title": "" }, { "docid": "5a3696b073fbd5d429b954cba9bcf9fa", "score": "0.44549188", "text": "function areAnimationsAllowed(element, parentElement, event) {\n var bodyElement = jqLite($document[0].body);\n var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n var rootElementDetected = isMatchingElement(element, $rootElement);\n var parentAnimationDetected = false;\n var animateChildren;\n var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentElement = parentHost;\n }\n\n parentElement = getDomNode(parentElement);\n\n while (parentElement) {\n if (!rootElementDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootElementDetected = isMatchingElement(parentElement, $rootElement);\n }\n\n if (parentElement.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentElement) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n if (parentElementDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentElementDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyElementDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n }\n\n if (bodyElementDetected && rootElementDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootElementDetected) {\n // If no rootElement is detected, check if the parentElement is pinned to another element\n parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentElement = getDomNode(parentHost);\n continue;\n }\n }\n\n parentElement = parentElement.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootElementDetected && bodyElementDetected;\n }", "title": "" }, { "docid": "02962cdf81a1f237ed40b8b3e54f58d9", "score": "0.44271728", "text": "function areAnimationsAllowed(element, parentElement, event) {\n var bodyElement = jqLite($document[0].body);\n var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n var rootElementDetected = isMatchingElement(element, $rootElement);\n var parentAnimationDetected = false;\n var animateChildren;\n var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentElement = parentHost;\n }\n\n parentElement = getDomNode(parentElement);\n\n while (parentElement) {\n if (!rootElementDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootElementDetected = isMatchingElement(parentElement, $rootElement);\n }\n\n if (parentElement.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentElement) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n if (parentElementDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentElementDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyElementDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n }\n\n if (bodyElementDetected && rootElementDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootElementDetected) {\n // If no rootElement is detected, check if the parentElement is pinned to another element\n parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentElement = getDomNode(parentHost);\n continue;\n }\n }\n\n parentElement = parentElement.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootElementDetected && bodyElementDetected;\n }", "title": "" }, { "docid": "02962cdf81a1f237ed40b8b3e54f58d9", "score": "0.44271728", "text": "function areAnimationsAllowed(element, parentElement, event) {\n var bodyElement = jqLite($document[0].body);\n var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n var rootElementDetected = isMatchingElement(element, $rootElement);\n var parentAnimationDetected = false;\n var animateChildren;\n var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentElement = parentHost;\n }\n\n parentElement = getDomNode(parentElement);\n\n while (parentElement) {\n if (!rootElementDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootElementDetected = isMatchingElement(parentElement, $rootElement);\n }\n\n if (parentElement.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentElement) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n if (parentElementDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentElementDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyElementDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n }\n\n if (bodyElementDetected && rootElementDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootElementDetected) {\n // If no rootElement is detected, check if the parentElement is pinned to another element\n parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentElement = getDomNode(parentHost);\n continue;\n }\n }\n\n parentElement = parentElement.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootElementDetected && bodyElementDetected;\n }", "title": "" }, { "docid": "94d186877ac837d40d5dbfd5b29358e0", "score": "0.44184625", "text": "function areAnimationsAllowed(element, parentElement, event) {\n var bodyElement = jqLite(rawDocument.body);\n var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n var rootElementDetected = isMatchingElement(element, $rootElement);\n var parentAnimationDetected = false;\n var animateChildren;\n var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentElement = parentHost;\n }\n\n parentElement = getDomNode(parentElement);\n\n while (parentElement) {\n if (!rootElementDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootElementDetected = isMatchingElement(parentElement, $rootElement);\n }\n\n if (parentElement.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentElement) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n if (parentElementDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentElementDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyElementDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n }\n\n if (bodyElementDetected && rootElementDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootElementDetected) {\n // If no rootElement is detected, check if the parentElement is pinned to another element\n parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentElement = getDomNode(parentHost);\n continue;\n }\n }\n\n parentElement = parentElement.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootElementDetected && bodyElementDetected;\n }", "title": "" }, { "docid": "94d186877ac837d40d5dbfd5b29358e0", "score": "0.44184625", "text": "function areAnimationsAllowed(element, parentElement, event) {\n var bodyElement = jqLite(rawDocument.body);\n var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n var rootElementDetected = isMatchingElement(element, $rootElement);\n var parentAnimationDetected = false;\n var animateChildren;\n var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n parentElement = parentHost;\n }\n\n parentElement = getDomNode(parentElement);\n\n while (parentElement) {\n if (!rootElementDetected) {\n // angular doesn't want to attempt to animate elements outside of the application\n // therefore we need to ensure that the rootElement is an ancestor of the current element\n rootElementDetected = isMatchingElement(parentElement, $rootElement);\n }\n\n if (parentElement.nodeType !== ELEMENT_NODE) {\n // no point in inspecting the #document element\n break;\n }\n\n var details = activeAnimationsLookup.get(parentElement) || {};\n // either an enter, leave or move animation will commence\n // therefore we can't allow any animations to take place\n // but if a parent animation is class-based then that's ok\n if (!parentAnimationDetected) {\n var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n if (parentElementDisabled === true && elementDisabled !== false) {\n // disable animations if the user hasn't explicitly enabled animations on the\n // current element\n elementDisabled = true;\n // element is disabled via parent element, no need to check anything else\n break;\n } else if (parentElementDisabled === false) {\n elementDisabled = false;\n }\n parentAnimationDetected = details.structural;\n }\n\n if (isUndefined(animateChildren) || animateChildren === true) {\n var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n if (isDefined(value)) {\n animateChildren = value;\n }\n }\n\n // there is no need to continue traversing at this point\n if (parentAnimationDetected && animateChildren === false) break;\n\n if (!bodyElementDetected) {\n // we also need to ensure that the element is or will be a part of the body element\n // otherwise it is pointless to even issue an animation to be rendered\n bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n }\n\n if (bodyElementDetected && rootElementDetected) {\n // If both body and root have been found, any other checks are pointless,\n // as no animation data should live outside the application\n break;\n }\n\n if (!rootElementDetected) {\n // If no rootElement is detected, check if the parentElement is pinned to another element\n parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n if (parentHost) {\n // The pin target element becomes the next parent element\n parentElement = getDomNode(parentHost);\n continue;\n }\n }\n\n parentElement = parentElement.parentNode;\n }\n\n var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n return allowAnimation && rootElementDetected && bodyElementDetected;\n }", "title": "" }, { "docid": "863ae57fc1550cb6b489557d027f3aef", "score": "0.4404498", "text": "function areAnimationsAllowed(element, parentElement, event) {\n\t var bodyElement = jqLite($document[0].body);\n\t var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n\t var rootElementDetected = isMatchingElement(element, $rootElement);\n\t var parentAnimationDetected = false;\n\t var animateChildren;\n\t var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n\t var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n\t if (parentHost) {\n\t parentElement = parentHost;\n\t }\n\n\t parentElement = getDomNode(parentElement);\n\n\t while (parentElement) {\n\t if (!rootElementDetected) {\n\t // angular doesn't want to attempt to animate elements outside of the application\n\t // therefore we need to ensure that the rootElement is an ancestor of the current element\n\t rootElementDetected = isMatchingElement(parentElement, $rootElement);\n\t }\n\n\t if (parentElement.nodeType !== ELEMENT_NODE) {\n\t // no point in inspecting the #document element\n\t break;\n\t }\n\n\t var details = activeAnimationsLookup.get(parentElement) || {};\n\t // either an enter, leave or move animation will commence\n\t // therefore we can't allow any animations to take place\n\t // but if a parent animation is class-based then that's ok\n\t if (!parentAnimationDetected) {\n\t var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n\t if (parentElementDisabled === true && elementDisabled !== false) {\n\t // disable animations if the user hasn't explicitly enabled animations on the\n\t // current element\n\t elementDisabled = true;\n\t // element is disabled via parent element, no need to check anything else\n\t break;\n\t } else if (parentElementDisabled === false) {\n\t elementDisabled = false;\n\t }\n\t parentAnimationDetected = details.structural;\n\t }\n\n\t if (isUndefined(animateChildren) || animateChildren === true) {\n\t var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n\t if (isDefined(value)) {\n\t animateChildren = value;\n\t }\n\t }\n\n\t // there is no need to continue traversing at this point\n\t if (parentAnimationDetected && animateChildren === false) break;\n\n\t if (!bodyElementDetected) {\n\t // we also need to ensure that the element is or will be a part of the body element\n\t // otherwise it is pointless to even issue an animation to be rendered\n\t bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n\t }\n\n\t if (bodyElementDetected && rootElementDetected) {\n\t // If both body and root have been found, any other checks are pointless,\n\t // as no animation data should live outside the application\n\t break;\n\t }\n\n\t if (!rootElementDetected) {\n\t // If no rootElement is detected, check if the parentElement is pinned to another element\n\t parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n\t if (parentHost) {\n\t // The pin target element becomes the next parent element\n\t parentElement = getDomNode(parentHost);\n\t continue;\n\t }\n\t }\n\n\t parentElement = parentElement.parentNode;\n\t }\n\n\t var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n\t return allowAnimation && rootElementDetected && bodyElementDetected;\n\t }", "title": "" }, { "docid": "863ae57fc1550cb6b489557d027f3aef", "score": "0.4404498", "text": "function areAnimationsAllowed(element, parentElement, event) {\n\t var bodyElement = jqLite($document[0].body);\n\t var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n\t var rootElementDetected = isMatchingElement(element, $rootElement);\n\t var parentAnimationDetected = false;\n\t var animateChildren;\n\t var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n\t var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n\t if (parentHost) {\n\t parentElement = parentHost;\n\t }\n\n\t parentElement = getDomNode(parentElement);\n\n\t while (parentElement) {\n\t if (!rootElementDetected) {\n\t // angular doesn't want to attempt to animate elements outside of the application\n\t // therefore we need to ensure that the rootElement is an ancestor of the current element\n\t rootElementDetected = isMatchingElement(parentElement, $rootElement);\n\t }\n\n\t if (parentElement.nodeType !== ELEMENT_NODE) {\n\t // no point in inspecting the #document element\n\t break;\n\t }\n\n\t var details = activeAnimationsLookup.get(parentElement) || {};\n\t // either an enter, leave or move animation will commence\n\t // therefore we can't allow any animations to take place\n\t // but if a parent animation is class-based then that's ok\n\t if (!parentAnimationDetected) {\n\t var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n\t if (parentElementDisabled === true && elementDisabled !== false) {\n\t // disable animations if the user hasn't explicitly enabled animations on the\n\t // current element\n\t elementDisabled = true;\n\t // element is disabled via parent element, no need to check anything else\n\t break;\n\t } else if (parentElementDisabled === false) {\n\t elementDisabled = false;\n\t }\n\t parentAnimationDetected = details.structural;\n\t }\n\n\t if (isUndefined(animateChildren) || animateChildren === true) {\n\t var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n\t if (isDefined(value)) {\n\t animateChildren = value;\n\t }\n\t }\n\n\t // there is no need to continue traversing at this point\n\t if (parentAnimationDetected && animateChildren === false) break;\n\n\t if (!bodyElementDetected) {\n\t // we also need to ensure that the element is or will be a part of the body element\n\t // otherwise it is pointless to even issue an animation to be rendered\n\t bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n\t }\n\n\t if (bodyElementDetected && rootElementDetected) {\n\t // If both body and root have been found, any other checks are pointless,\n\t // as no animation data should live outside the application\n\t break;\n\t }\n\n\t if (!rootElementDetected) {\n\t // If no rootElement is detected, check if the parentElement is pinned to another element\n\t parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n\t if (parentHost) {\n\t // The pin target element becomes the next parent element\n\t parentElement = getDomNode(parentHost);\n\t continue;\n\t }\n\t }\n\n\t parentElement = parentElement.parentNode;\n\t }\n\n\t var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n\t return allowAnimation && rootElementDetected && bodyElementDetected;\n\t }", "title": "" }, { "docid": "a1307f3a4d02fe9787172e05d83377c5", "score": "0.43752977", "text": "animate() {\n if(this.finishedAnimating) {\n return false;\n }\n\n const svg = this.shadowRoot.querySelector(\"svg\");\n\n svg.classList.add(\"animate\");\n\n this.finishedAnimating = true;\n return true;\n }", "title": "" }, { "docid": "bb9dfd20de17a99ac21781fb716077b4", "score": "0.43742326", "text": "supportsTransitionEnd() {\n return Boolean(TRANSITION_END);\n }", "title": "" }, { "docid": "32828d78584400843e2a517b985a3d63", "score": "0.43520713", "text": "function areAnimationsAllowed(element, parentElement, event) {\n\t var bodyElement = jqLite($document[0].body);\n\t var bodyElementDetected = isMatchingElement(element, bodyElement) || element[0].nodeName === 'HTML';\n\t var rootElementDetected = isMatchingElement(element, $rootElement);\n\t var parentAnimationDetected = false;\n\t var animateChildren;\n\t var elementDisabled = disabledElementsLookup.get(getDomNode(element));\n\n\t var parentHost = jqLite.data(element[0], NG_ANIMATE_PIN_DATA);\n\t if (parentHost) {\n\t parentElement = parentHost;\n\t }\n\n\t parentElement = getDomNode(parentElement);\n\n\t while (parentElement) {\n\t if (!rootElementDetected) {\n\t // angular doesn't want to attempt to animate elements outside of the application\n\t // therefore we need to ensure that the rootElement is an ancestor of the current element\n\t rootElementDetected = isMatchingElement(parentElement, $rootElement);\n\t }\n\n\t if (parentElement.nodeType !== ELEMENT_NODE) {\n\t // no point in inspecting the #document element\n\t break;\n\t }\n\n\t var details = activeAnimationsLookup.get(parentElement) || {};\n\t // either an enter, leave or move animation will commence\n\t // therefore we can't allow any animations to take place\n\t // but if a parent animation is class-based then that's ok\n\t if (!parentAnimationDetected) {\n\t var parentElementDisabled = disabledElementsLookup.get(parentElement);\n\n\t if (parentElementDisabled === true && elementDisabled !== false) {\n\t // disable animations if the user hasn't explicitly enabled animations on the\n\t // current element\n\t elementDisabled = true;\n\t // element is disabled via parent element, no need to check anything else\n\t break;\n\t } else if (parentElementDisabled === false) {\n\t elementDisabled = false;\n\t }\n\t parentAnimationDetected = details.structural;\n\t }\n\n\t if (isUndefined(animateChildren) || animateChildren === true) {\n\t var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA);\n\t if (isDefined(value)) {\n\t animateChildren = value;\n\t }\n\t }\n\n\t // there is no need to continue traversing at this point\n\t if (parentAnimationDetected && animateChildren === false) break;\n\n\t if (!bodyElementDetected) {\n\t // we also need to ensure that the element is or will be a part of the body element\n\t // otherwise it is pointless to even issue an animation to be rendered\n\t bodyElementDetected = isMatchingElement(parentElement, bodyElement);\n\t }\n\n\t if (bodyElementDetected && rootElementDetected) {\n\t // If both body and root have been found, any other checks are pointless,\n\t // as no animation data should live outside the application\n\t break;\n\t }\n\n\t if (!rootElementDetected) {\n\t // If no rootElement is detected, check if the parentElement is pinned to another element\n\t parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA);\n\t if (parentHost) {\n\t // The pin target element becomes the next parent element\n\t parentElement = getDomNode(parentHost);\n\t continue;\n\t }\n\t }\n\n\t parentElement = parentElement.parentNode;\n\t }\n\n\t var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;\n\t return allowAnimation && rootElementDetected && bodyElementDetected;\n\t }", "title": "" }, { "docid": "9ce007e9c0776f611fdbaa3fdd71094f", "score": "0.43467066", "text": "function transitionEnd() {\n var el = document.createElement(\"bootstrap\");\n\n var transEndEventNames = {\n WebkitTransition: \"webkitTransitionEnd\",\n MozTransition: \"transitionend\",\n OTransition: \"oTransitionEnd otransitionend\",\n transition: \"transitionend\",\n };\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return {\n end: transEndEventNames[name],\n };\n }\n }\n\n return false; // explicit for ie8 ( ._.)\n}", "title": "" }, { "docid": "d15ca83f03ccef998e1124d9d3a3e868", "score": "0.43276584", "text": "function prepareTransition(element) {\n element.addEventListener(\n 'transitionend',\n function(event) {\n event.currentTarget.classList.remove('is-transitioning');\n },\n { once: true }\n );\n\n var properties = [\n 'transition-duration',\n '-moz-transition-duration',\n '-webkit-transition-duration',\n '-o-transition-duration'\n ];\n\n var duration = 0;\n\n properties.forEach(function(property) {\n var computedValue = getComputedStyle(element)[property];\n\n if (computedValue) {\n computedValue.replace(/\\D/g, '');\n duration || (duration = parseFloat(computedValue));\n }\n });\n\n if (duration !== 0) {\n element.classList.add('is-transitioning');\n element.offsetWidth;\n }\n }", "title": "" }, { "docid": "f7a9577699bb7b67c7aafc49ee5400b2", "score": "0.42995006", "text": "_animate(band, startOffset, endOffset) {\n // If start and end are the same there is nothing to do. The reason for\n // explicitly handling this case is that this method waits for an\n // `transitionend` event which won’t fire if there is no animation.\n if (startOffset === endOffset)\n return Promise.resolve();\n // Set the `animating` class on the `<howto-accordion>` element. This\n // discards all further `change` events until the animation is done.\n this.classList.add('is-animating');\n // Turn the list of children into a proper array with all the helper\n // functions defined on it.\n const children = Array.from(this.children);\n // Find the index of the band that is being animated.\n const idx = children.indexOf(band);\n // Only that band and all the headings and bands _after_ the given band\n // need to be animated.\n const animatedChildren = children.slice(idx);\n\n // Some children will be translated\n // beyond the top of the element and might end up being visible above the\n // element. Switch the `<howto-accordion>` element to `overflow: hidden`\n // to prevent that.\n this.style.overflow = 'hidden';\n // Switch all children to `position: relative` so that the element\n // has full control over paint order using `z-index`.\n children.forEach(child => {\n child.style.position = 'relative';\n // All children _before_ the animated ones need to be painted _over_\n // all the animated children. Therefore, set all children to\n // `z-index: 2` and set all the animated children to `z-index: 1` next.\n child.style.zIndex = 2;\n });\n\n // Set `z-index: 1` on all animated children translate them to the\n // start position. Because this function uses a CSS transition we don’t\n // need to use `will-change`.\n animatedChildren.forEach(child => {\n child.style.position = 'relative';\n child.style.zIndex = 1;\n child.style.transform = `translateY(${startOffset}px)`;\n });\n\n // Wait two frames for all the styles to take effect.\n return requestAnimationFramePromise()\n .then(_ => requestAnimationFramePromise())\n .then(_ => {\n // Set up the CSS transition on all the children and set them to\n // their end position.\n animatedChildren.forEach(child => {\n child.style.transform = `translateY(${endOffset}px)`;\n child.classList.add('is-animating');\n });\n // Wait for the transition to end.\n return transitionEndPromise(band);\n })\n .then(_ => {\n // Clean up all the temporary styles\n animatedChildren.forEach(child => {\n child.style.transform = '';\n child.classList.remove('is-animating');\n });\n children.forEach(child => {\n child.style.position = '';\n child.style.zIndex = '';\n });\n this.style.overflow = '';\n // this.style.height = endOffset + 'px';\n this.classList.remove('is-animating');\n });\n }", "title": "" }, { "docid": "bc72e6e63d42b9d88a1d6bd4bb0cb990", "score": "0.42830592", "text": "function transitions_startAnimation(key, value, target, transition) {\n if (transition === void 0) { transition = {}; }\n return value.start(function (onComplete) {\n var delayTimer;\n var controls;\n var animation = transitions_getAnimation(key, value, target, transition, onComplete);\n var delay = getDelayFromTransition(transition, key);\n var start = function () { return (controls = animation()); };\n if (delay) {\n delayTimer = setTimeout(start, secondsToMilliseconds(delay));\n }\n else {\n start();\n }\n return function () {\n clearTimeout(delayTimer);\n controls === null || controls === void 0 ? void 0 : controls.stop();\n };\n });\n}", "title": "" }, { "docid": "2025b363fa033dc1ca7754bc9a4ed74a", "score": "0.42802638", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'transitionend',\n OTransition: 'oTransitionEnd otransitionend',\n transition: 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return {\n end: transEndEventNames[name]\n }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "2eb6b37fe29aafad79888fbce2445e5c", "score": "0.4272861", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'transitionend',\n OTransition: 'oTransitionEnd otransitionend',\n transition: 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "4dfaafd8606065f0f67da096269bb37d", "score": "0.42539862", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition': 'webkitTransitionEnd',\n 'MozTransition': 'transitionend',\n 'OTransition': 'oTransitionEnd otransitionend',\n 'transition': 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return {\n end: transEndEventNames[name]\n }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "d475749ed191678bb97507270824844e", "score": "0.4253394", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'transitionend',\n OTransition: 'oTransitionEnd otransitionend',\n transition: 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return {end: transEndEventNames[name]}\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "d475749ed191678bb97507270824844e", "score": "0.4253394", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'transitionend',\n OTransition: 'oTransitionEnd otransitionend',\n transition: 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return {end: transEndEventNames[name]}\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "d475749ed191678bb97507270824844e", "score": "0.4253394", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'transitionend',\n OTransition: 'oTransitionEnd otransitionend',\n transition: 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return {end: transEndEventNames[name]}\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "6c71a9212dd7e3bcc6cf137f51acfad2", "score": "0.42514896", "text": "function transitionEnd() {\n var el = document.createElement(\"bootstrap\");\n var transEndEventNames = {\n WebkitTransition: \"webkitTransitionEnd\",\n MozTransition: \"transitionend\",\n OTransition: \"oTransitionEnd otransitionend\",\n transition: \"transitionend\"\n };\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return {\n end: transEndEventNames[name]\n };\n }\n }\n\n return false; // explicit for ie8 ( ._.)\n} // http://blog.alexmaccaw.com/css-transitions", "title": "" }, { "docid": "8e1ee628aef895d43095af89eb351a2c", "score": "0.4248833", "text": "function eventCollapseChild(d) {\n if (d.children) {\n d._children = d.children;\n d.children = null;\n } else {\n d.children = d._children;\n d._children = null;\n }\n update(d);\n }", "title": "" }, { "docid": "2900e8947253ac7b7c40656803cbbc8f", "score": "0.4240729", "text": "function animate(slide, startParams, endParams) {\n\tif (_instanceof(slide.transitionable, Array) === false) {\n\t\tslide.transitionable = [];\n\t}\n\tfor (var i = 0; i < startParams.length; i++) {\n\t\tslide.transitionable[i] = new _Transitionable2.default(startParams[i]);\n\t\tslide.transitionable[i].set(endParams[i], slide.currentTransformOpts\n\t\t// function(){ console.log(\"finished\"); } // callback\n\t\t);\n\t}\n}", "title": "" }, { "docid": "b3451ec58d689c18941f274545f4a67d", "score": "0.42367148", "text": "__onTransitionHandler(event) {\n\n if (\n !(event instanceof TransitionEvent) || \n event.propertyName !== 'transform' ||\n getRootTarget(event).nodeName !== 'PAPER-BUTTON'\n ) {\n return;\n }\n\n if (this._btnAnimationClass === 'show-btn') {\n\n this._overflowClass = 'allow-overflow';\n this._circleClass = 'circle-enter';\n this._labelClass = 'show-label';\n this._rectangleClass = 'rectangle-enter';\n }\n }", "title": "" }, { "docid": "54f491d96550f6575a109ec6bc2e6b5c", "score": "0.42213318", "text": "function transitionEnd() {\n var el = document.createElement( 'bootstrap' )\n var transEndEventNames = {\n WebkitTransition: 'webkitTransitionEnd',\n MozTransition: 'transitionend',\n OTransition: 'oTransitionEnd otransitionend',\n transition: 'transitionend'\n }\n for ( var name in transEndEventNames ) {\n if ( el.style[ name ] !== undefined ) {\n return {\n end: transEndEventNames[ name ]\n }\n }\n }\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "470ec640a9a8411470a3d50226735ac8", "score": "0.4198517", "text": "function animChildToParent(){\n\n //place child inside parent container\n parent = child;\n //create new child inside child container\n child = new Person(\"defaultChild\");\n\n //hide child column, replace with parent column\n $(\"#child-col\").hide();\n $(\"#parent-col\").show();\n\n //fade out offset col while fading in child column\n\t$(\".offsetDiv\").hide('slow', function(){});\n $(\"#child-col\").show('slow',function(){});\n}", "title": "" }, { "docid": "251b44a827efc181846f2e0808c9fb75", "score": "0.4185849", "text": "runWithTransition(fn, duration) {\n const me = this;\n\n // Do not attempt to enter animating state if we are not visible\n if (me.isVisible) {\n // Allow calling with true/false to keep code simpler in other places\n if (duration == null || duration === true) {\n duration = this.transitionDuration;\n }\n\n // Ask Grid superclass to enter the animated state if requested and enabled.\n if (duration && me.enableEventAnimations) {\n me.isAnimating = true;\n me.setTimeout(me.exitTransition, duration);\n }\n }\n\n fn();\n }", "title": "" }, { "docid": "f74fd4782c81011947f97a7b76a846e7", "score": "0.41851327", "text": "function removeTransition(elem) {\n if (elem.propertyName !== 'transform') return;\n elem.target.classList.remove('playing');\n}", "title": "" }, { "docid": "0a04f3176f091a6addaec2612aee56c2", "score": "0.4164745", "text": "function switchToParent(){\n\n //check if this is the first transition\n if(parent !== undefined){\n animReplaceParent();\n } else {\n //for the first transition\n animChildToParent();\n }\n\n //set parent events\n parent.allowableEvents = parentEvents.slice();\n}", "title": "" }, { "docid": "3be202ebf6954e7fb0444071074300e1", "score": "0.416032", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n WebkitTransition : 'webkitTransitionEnd',\n MozTransition : 'transitionend',\n OTransition : 'oTransitionEnd otransitionend',\n transition : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "dbce181b7b35b7084a9d3e6ae0fa4e55", "score": "0.41593888", "text": "function NodeCanHaveChild() {\r\n Node.apply(this, arguments);\r\n this._children = []; \r\n}", "title": "" }, { "docid": "f33a64c64c297fad92bf66003b7dfeef", "score": "0.41564327", "text": "runWithTransition(fn, duration) {\n const me = this; // Do not attempt to enter animating state if we are not visible\n\n if (me.isVisible) {\n // Allow calling with true/false to keep code simpler in other places\n if (duration == null || duration === true) {\n duration = me.transitionDuration;\n } // Ask Grid superclass to enter the animated state if requested and enabled.\n\n if (duration && me.enableEventAnimations) {\n me.isAnimating = true; // Exit animating state in duration milliseconds.\n // Cancel any previous outstanding exit timer.\n\n exitTransition.delay = duration;\n me.setTimeout(exitTransition);\n }\n }\n\n fn();\n }", "title": "" }, { "docid": "ee7456311c430b8ac8d03a97a044c7ac", "score": "0.41480556", "text": "function transitionEnd(){var el=document.createElement('bootstrap');var transEndEventNames={WebkitTransition:'webkitTransitionEnd',MozTransition:'transitionend',OTransition:'oTransitionEnd otransitionend',transition:'transitionend'};for(var name in transEndEventNames){if(el.style[name]!==undefined){return{end:transEndEventNames[name]};}}return false;// explicit for ie8 ( ._.)\n}// http://blog.alexmaccaw.com/css-transitions", "title": "" }, { "docid": "ee7456311c430b8ac8d03a97a044c7ac", "score": "0.41480556", "text": "function transitionEnd(){var el=document.createElement('bootstrap');var transEndEventNames={WebkitTransition:'webkitTransitionEnd',MozTransition:'transitionend',OTransition:'oTransitionEnd otransitionend',transition:'transitionend'};for(var name in transEndEventNames){if(el.style[name]!==undefined){return{end:transEndEventNames[name]};}}return false;// explicit for ie8 ( ._.)\n}// http://blog.alexmaccaw.com/css-transitions", "title": "" }, { "docid": "612e272aefade98b9d973d6c0ea1208c", "score": "0.41278574", "text": "function startAnimation(key, value, target, transition) {\n if (transition === void 0) { transition = {}; }\n return value.start(function (onComplete) {\n var delayTimer;\n var controls;\n var animation = getAnimation(key, value, target, transition, onComplete);\n var delay = getDelayFromTransition(transition, key);\n var start = function () { return (controls = animation()); };\n if (delay) {\n delayTimer = setTimeout(start, (0,_utils_time_conversion_js__WEBPACK_IMPORTED_MODULE_2__.secondsToMilliseconds)(delay));\n }\n else {\n start();\n }\n return function () {\n clearTimeout(delayTimer);\n controls === null || controls === void 0 ? void 0 : controls.stop();\n };\n });\n}", "title": "" }, { "docid": "612e272aefade98b9d973d6c0ea1208c", "score": "0.41278574", "text": "function startAnimation(key, value, target, transition) {\n if (transition === void 0) { transition = {}; }\n return value.start(function (onComplete) {\n var delayTimer;\n var controls;\n var animation = getAnimation(key, value, target, transition, onComplete);\n var delay = getDelayFromTransition(transition, key);\n var start = function () { return (controls = animation()); };\n if (delay) {\n delayTimer = setTimeout(start, (0,_utils_time_conversion_js__WEBPACK_IMPORTED_MODULE_2__.secondsToMilliseconds)(delay));\n }\n else {\n start();\n }\n return function () {\n clearTimeout(delayTimer);\n controls === null || controls === void 0 ? void 0 : controls.stop();\n };\n });\n}", "title": "" }, { "docid": "c77fd3a27407a0b2237ac4e4905c4631", "score": "0.41218635", "text": "function isChildNode(parent, child) {\n if (!isNode(parent) || !isNode(child)) {\n return false;\n }\n return child.parentNode === parent;\n }", "title": "" }, { "docid": "5a935e42c71bd0086fd0614480fc0986", "score": "0.41161466", "text": "function genCSSMotion(transitionSupport) {\n function isSupportTransition(props) {\n return !!(props.motionName && transitionSupport);\n }\n\n var CSSMotion = function (_React$Component) {\n __WEBPACK_IMPORTED_MODULE_5_babel_runtime_helpers_inherits___default()(CSSMotion, _React$Component);\n\n function CSSMotion() {\n __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_classCallCheck___default()(this, CSSMotion);\n\n var _this = __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_possibleConstructorReturn___default()(this, (CSSMotion.__proto__ || Object.getPrototypeOf(CSSMotion)).call(this));\n\n _this.onDomUpdate = function () {\n var _this$state = _this.state,\n status = _this$state.status,\n newStatus = _this$state.newStatus;\n var _this$props = _this.props,\n onAppearStart = _this$props.onAppearStart,\n onEnterStart = _this$props.onEnterStart,\n onLeaveStart = _this$props.onLeaveStart,\n onAppearActive = _this$props.onAppearActive,\n onEnterActive = _this$props.onEnterActive,\n onLeaveActive = _this$props.onLeaveActive,\n motionAppear = _this$props.motionAppear,\n motionEnter = _this$props.motionEnter,\n motionLeave = _this$props.motionLeave;\n\n\n if (!isSupportTransition(_this.props)) {\n return;\n }\n\n // Event injection\n var $ele = __WEBPACK_IMPORTED_MODULE_7_react_dom___default.a.findDOMNode(_this);\n if (_this.$ele !== $ele) {\n _this.removeEventListener(_this.$ele);\n _this.addEventListener($ele);\n _this.$ele = $ele;\n }\n\n // Init status\n if (newStatus && status === STATUS_APPEAR && motionAppear) {\n _this.updateStatus(onAppearStart, null, null, function () {\n _this.updateActiveStatus(onAppearActive, STATUS_APPEAR);\n });\n } else if (newStatus && status === STATUS_ENTER && motionEnter) {\n _this.updateStatus(onEnterStart, null, null, function () {\n _this.updateActiveStatus(onEnterActive, STATUS_ENTER);\n });\n } else if (newStatus && status === STATUS_LEAVE && motionLeave) {\n _this.updateStatus(onLeaveStart, null, null, function () {\n _this.updateActiveStatus(onLeaveActive, STATUS_LEAVE);\n });\n }\n };\n\n _this.onMotionEnd = function (event) {\n var _this$state2 = _this.state,\n status = _this$state2.status,\n statusActive = _this$state2.statusActive;\n var _this$props2 = _this.props,\n onAppearEnd = _this$props2.onAppearEnd,\n onEnterEnd = _this$props2.onEnterEnd,\n onLeaveEnd = _this$props2.onLeaveEnd;\n\n if (status === STATUS_APPEAR && statusActive) {\n _this.updateStatus(onAppearEnd, { status: STATUS_NONE }, event);\n } else if (status === STATUS_ENTER && statusActive) {\n _this.updateStatus(onEnterEnd, { status: STATUS_NONE }, event);\n } else if (status === STATUS_LEAVE && statusActive) {\n _this.updateStatus(onLeaveEnd, { status: STATUS_NONE }, event);\n }\n };\n\n _this.addEventListener = function ($ele) {\n if (!$ele) return;\n\n $ele.addEventListener(__WEBPACK_IMPORTED_MODULE_12__util_motion__[\"d\" /* transitionEndName */], _this.onMotionEnd);\n $ele.addEventListener(__WEBPACK_IMPORTED_MODULE_12__util_motion__[\"a\" /* animationEndName */], _this.onMotionEnd);\n };\n\n _this.removeEventListener = function ($ele) {\n if (!$ele) return;\n\n $ele.removeEventListener(__WEBPACK_IMPORTED_MODULE_12__util_motion__[\"d\" /* transitionEndName */], _this.onMotionEnd);\n $ele.removeEventListener(__WEBPACK_IMPORTED_MODULE_12__util_motion__[\"a\" /* animationEndName */], _this.onMotionEnd);\n };\n\n _this.updateStatus = function (styleFunc, additionalState, event, callback) {\n var statusStyle = styleFunc ? styleFunc(__WEBPACK_IMPORTED_MODULE_7_react_dom___default.a.findDOMNode(_this), event) : null;\n\n if (statusStyle === false || _this._destroyed) return;\n\n var nextStep = void 0;\n if (callback) {\n nextStep = function nextStep() {\n _this.nextFrame(callback);\n };\n }\n\n _this.setState(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_extends___default()({\n statusStyle: typeof statusStyle === 'object' ? statusStyle : null,\n newStatus: false\n }, additionalState), nextStep); // Trigger before next frame & after `componentDidMount`\n };\n\n _this.updateActiveStatus = function (styleFunc, currentStatus) {\n // `setState` use `postMessage` to trigger at the end of frame.\n // Let's use requestAnimationFrame to update new state in next frame.\n _this.nextFrame(function () {\n var status = _this.state.status;\n\n if (status !== currentStatus) return;\n\n _this.updateStatus(styleFunc, { statusActive: true });\n });\n };\n\n _this.nextFrame = function (func) {\n _this.cancelNextFrame();\n _this.raf = __WEBPACK_IMPORTED_MODULE_11_raf___default()(func);\n };\n\n _this.cancelNextFrame = function () {\n if (_this.raf) {\n __WEBPACK_IMPORTED_MODULE_11_raf___default.a.cancel(_this.raf);\n _this.raf = null;\n }\n };\n\n _this.state = {\n status: STATUS_NONE,\n statusActive: false,\n newStatus: false,\n statusStyle: null\n };\n _this.$ele = null;\n _this.raf = null;\n return _this;\n }\n\n __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_createClass___default()(CSSMotion, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n this.onDomUpdate();\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n this.onDomUpdate();\n }\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {\n this._destroyed = true;\n this.removeEventListener(this.$ele);\n this.cancelNextFrame();\n }\n }, {\n key: 'render',\n value: function render() {\n var _classNames;\n\n var _state = this.state,\n status = _state.status,\n statusActive = _state.statusActive,\n statusStyle = _state.statusStyle;\n var _props = this.props,\n children = _props.children,\n motionName = _props.motionName,\n visible = _props.visible,\n removeOnLeave = _props.removeOnLeave;\n\n\n if (!children) return null;\n\n if (status === STATUS_NONE || !isSupportTransition(this.props)) {\n return visible || !removeOnLeave ? children({}) : null;\n }\n\n return children({\n className: __WEBPACK_IMPORTED_MODULE_10_classnames___default()((_classNames = {}, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty___default()(_classNames, Object(__WEBPACK_IMPORTED_MODULE_12__util_motion__[\"b\" /* getTransitionName */])(motionName, status), status !== STATUS_NONE), __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty___default()(_classNames, Object(__WEBPACK_IMPORTED_MODULE_12__util_motion__[\"b\" /* getTransitionName */])(motionName, status + '-active'), status !== STATUS_NONE && statusActive), __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_defineProperty___default()(_classNames, motionName, typeof motionName === 'string'), _classNames)),\n style: statusStyle\n });\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(props, _ref) {\n var prevProps = _ref.prevProps;\n\n if (!isSupportTransition(props)) return {};\n\n var visible = props.visible,\n motionAppear = props.motionAppear,\n motionEnter = props.motionEnter,\n motionLeave = props.motionLeave,\n motionLeaveImmediately = props.motionLeaveImmediately;\n\n var newState = {\n prevProps: props\n };\n\n // Appear\n if (!prevProps && visible && motionAppear) {\n newState.status = STATUS_APPEAR;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n // Enter\n if (prevProps && !prevProps.visible && visible && motionEnter) {\n newState.status = STATUS_ENTER;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n // Leave\n if (prevProps && prevProps.visible && !visible && motionLeave || !prevProps && motionLeaveImmediately && !visible && motionLeave) {\n newState.status = STATUS_LEAVE;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n return newState;\n }\n }]);\n\n return CSSMotion;\n }(__WEBPACK_IMPORTED_MODULE_6_react___default.a.Component);\n\n CSSMotion.propTypes = {\n visible: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.bool,\n children: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n motionName: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.oneOfType([__WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.string, __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.object]),\n motionAppear: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.bool,\n motionEnter: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.bool,\n motionLeave: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.bool,\n motionLeaveImmediately: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.bool, // Trigger leave motion immediately\n removeOnLeave: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.bool,\n onAppearStart: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onAppearActive: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onAppearEnd: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onEnterStart: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onEnterActive: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onEnterEnd: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onLeaveStart: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onLeaveActive: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func,\n onLeaveEnd: __WEBPACK_IMPORTED_MODULE_8_prop_types___default.a.func\n };\n CSSMotion.defaultProps = {\n visible: true,\n motionEnter: true,\n motionAppear: true,\n motionLeave: true,\n removeOnLeave: true\n };\n\n\n Object(__WEBPACK_IMPORTED_MODULE_9_react_lifecycles_compat__[\"a\" /* polyfill */])(CSSMotion);\n\n return CSSMotion;\n}", "title": "" }, { "docid": "d330eb7aef7da5996a5b75ffd60835e0", "score": "0.41158995", "text": "function toggleExpand(event) {\n if (state.animationInProgress) {\n return;\n }\n state.animationInProgress = !state.animationInProgress;\n\n const previouslyActivated = expandableItems.find(item => {\n return item.classList.contains(\"active\");\n });\n\n let usedBtn = event.currentTarget;\n\n if (event.currentTarget.tagName === \"DIV\") usedBtn = event.currentTarget;\n\n if (event.currentTarget.tagName === \"SPAN\")\n usedBtn = event.currentTarget.nextElementSibling;\n\n const currentExpandableItem =\n usedBtn.parentElement.parentElement.parentElement;\n\n //If none was active\n\n if (!previouslyActivated) {\n const currentCollapsedContent = currentExpandableItem.getAttribute(\n \"content-height\"\n );\n\n const currentContentElement = appendExpandableContainer(\n currentExpandableItem,\n templateElt\n );\n\n const contentEltDesiredScale =\n currentCollapsedContent /\n currentContentElement.getBoundingClientRect().height;\n\n const unactiveEltsTranslateAmount = 10 * contentEltDesiredScale;\n\n const expandablesBelowCurrent = getAllExpandablesBelow(\n currentExpandableItem,\n expandableItems\n );\n\n currentExpandableItem.classList.add(\"active\");\n currentExpandableItem.querySelector(\"svg\").innerHTML = activeSVG;\n\n currentContentElement.style.transformOrigin = \"top\";\n\n currentContentElement.style.transform = `scaleY(${contentEltDesiredScale})`;\n\n expandablesBelowCurrent.forEach(elt => {\n elt.style.transform = `translateY(${unactiveEltsTranslateAmount +\n 0.04 * unactiveEltsTranslateAmount}px)`;\n });\n\n currentContentElement.addEventListener(\n \"transitionend\",\n event => {\n showContent(event, currentExpandableItem, contentEltDesiredScale);\n },\n { once: true }\n );\n\n return;\n }\n\n // Runs if current was previously active\n\n if (previouslyActivated === currentExpandableItem) {\n const currentCollapsedContent = currentExpandableItem.getAttribute(\n \"content-height\"\n );\n\n const currentContentElement = appendExpandableContainer(\n currentExpandableItem,\n templateElt\n );\n\n const contentEltDesiredScale =\n currentCollapsedContent /\n currentContentElement.getBoundingClientRect().height;\n\n const unactiveEltsTranslateAmount = 10 * contentEltDesiredScale - 10;\n\n const expandablesBelowCurrent = getAllExpandablesBelow(\n currentExpandableItem,\n expandableItems\n );\n\n hideContent(previouslyActivated);\n\n previouslyActivated.nextElementSibling.addEventListener(\n \"deactivateIt\",\n () => {\n expandablesBelowCurrent.forEach(elt => {\n elt.style.transform = `translateY(-${unactiveEltsTranslateAmount}px)`;\n });\n previouslyActivated.classList.remove(\"active\");\n previouslyActivated.querySelector(\"svg\").innerHTML = inactiveSVG;\n\n state.animationInProgress = !state.animationInProgress;\n },\n { once: true }\n );\n\n return;\n }\n\n //Runs if some other was previously active\n\n if (previouslyActivated && previouslyActivated !== currentExpandableItem) {\n const currentExpandedContent = previouslyActivated.getAttribute(\n \"content-height\"\n );\n\n const previousContentElement = appendExpandableContainer(\n previouslyActivated,\n templateElt\n );\n\n const previousContentScale =\n currentExpandedContent /\n previousContentElement.getBoundingClientRect().height;\n\n const activeEltTranslateAmount = 10 * previousContentScale - 10;\n\n const expandablesBelowPrevious = getAllExpandablesBelow(\n previouslyActivated,\n expandableItems\n );\n\n hideContent(previouslyActivated);\n\n previouslyActivated.nextElementSibling.addEventListener(\n \"deactivateIt\",\n e => {\n if (expandablesBelowPrevious.length > 0) {\n expandablesBelowPrevious[0].addEventListener(\n \"transitionend\",\n () => {\n state.animationInProgress = !state.animationInProgress;\n usedBtn.click();\n },\n { once: true }\n );\n expandablesBelowPrevious.forEach(elt => {\n elt.style.transform = `translateY(-${activeEltTranslateAmount}px)`;\n });\n\n previouslyActivated.classList.remove(\"active\");\n previouslyActivated.querySelector(\"svg\").innerHTML = inactiveSVG;\n } else {\n const targetNode = document.querySelector(\"main\");\n const config = { childList: true };\n\n function clickBtn() {\n previouslyActivated.querySelector(\"svg\").innerHTML = inactiveSVG;\n previouslyActivated.classList.remove(\"active\");\n\n state.animationInProgress = !state.animationInProgress;\n\n usedBtn.click();\n observer.disconnect();\n }\n\n const observer = new MutationObserver(clickBtn);\n\n observer.observe(targetNode, config);\n }\n },\n { once: true }\n );\n\n return;\n }\n\n //Runs if none active\n}", "title": "" }, { "docid": "e31657635c11911d884ec3fd7a1f9a07", "score": "0.41142595", "text": "function examineParentAnimation(node, animationDetails) {\n // enter/leave/move always have priority\n if (animationDetails.structural || !hasAnimationClasses(animationDetails.options)) return;\n\n if (animationDetails.state === RUNNING_STATE) {\n animationDetails.runner.end();\n }\n clearElementAnimationState(node);\n }", "title": "" }, { "docid": "7a2e1e4f909ee4193fde640ebfab0b54", "score": "0.41141874", "text": "function isChildNode(parent, child) {\n if (!isNode(parent) || !isNode(child)) {\n return false;\n }\n return child.parentNode === parent;\n }", "title": "" }, { "docid": "06859d8d9166c3ceec6aa87813a6bea4", "score": "0.4104184", "text": "function applyTransitionClass (el, stage, changeState, hasAnimation) {\n\n if (!endEvents.trans) {\n changeState()\n return codes.CSS_SKIP\n }\n\n // if the browser supports transition,\n // it must have classList...\n var onEnd,\n classList = el.classList,\n existingCallback = el.vue_trans_cb,\n enterClass = config.enterClass,\n leaveClass = config.leaveClass,\n endEvent = hasAnimation ? endEvents.anim : endEvents.trans\n\n // cancel unfinished callbacks and jobs\n if (existingCallback) {\n el.removeEventListener(endEvent, existingCallback)\n classList.remove(enterClass)\n classList.remove(leaveClass)\n el.vue_trans_cb = null\n }\n\n if (stage > 0) { // enter\n\n // set to enter state before appending\n classList.add(enterClass)\n // append\n changeState()\n // trigger transition\n if (!hasAnimation) {\n batcher.push({\n execute: function () {\n classList.remove(enterClass)\n }\n })\n } else {\n onEnd = function (e) {\n if (e.target === el) {\n el.removeEventListener(endEvent, onEnd)\n el.vue_trans_cb = null\n classList.remove(enterClass)\n }\n }\n el.addEventListener(endEvent, onEnd)\n el.vue_trans_cb = onEnd\n }\n return codes.CSS_E\n\n } else { // leave\n\n if (el.offsetWidth || el.offsetHeight) {\n // trigger hide transition\n classList.add(leaveClass)\n onEnd = function (e) {\n if (e.target === el) {\n el.removeEventListener(endEvent, onEnd)\n el.vue_trans_cb = null\n // actually remove node here\n changeState()\n classList.remove(leaveClass)\n }\n }\n // attach transition end listener\n el.addEventListener(endEvent, onEnd)\n el.vue_trans_cb = onEnd\n } else {\n // directly remove invisible elements\n changeState()\n }\n return codes.CSS_L\n \n }\n\n}", "title": "" }, { "docid": "1e8da20c1b73a7a70a188ac1b4b6c5f4", "score": "0.410359", "text": "function startAnimation(key, value, target, transition) {\n if (transition === void 0) { transition = {}; }\n return value.start(function (onComplete) {\n var delayTimer;\n var controls;\n var animation = getAnimation(key, value, target, transition, onComplete);\n var delay = getDelayFromTransition(transition, key);\n var start = function () { return (controls = animation()); };\n if (delay) {\n delayTimer = setTimeout(start, secondsToMilliseconds(delay));\n }\n else {\n start();\n }\n return function () {\n clearTimeout(delayTimer);\n controls === null || controls === void 0 ? void 0 : controls.stop();\n };\n });\n}", "title": "" }, { "docid": "0ad5c05b43cf56889313c55d1bef17fb", "score": "0.4102796", "text": "function removeTransition(e) {\n if (e.propertyName !== \"transform\") return; \n e.target.classList.remove(\"playing\");\n}", "title": "" }, { "docid": "bb3bb15121a413d7791d5452c17965e3", "score": "0.41024968", "text": "function removeTransition(e) {\n // I first wondered why bother to write this line of code because it works anyways\n // It seems like transform property defines the time the animation will take, and\n // you can't remove the class before transform is done.\n if (e.propertyName !== 'transform') return;\n this.classList.remove('playing');\n}", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8f321e27ef3d067dfa6e72bb559ad60d", "score": "0.40978462", "text": "function transitionEnd() {\n var el = document.createElement('bootstrap')\n\n var transEndEventNames = {\n 'WebkitTransition' : 'webkitTransitionEnd',\n 'MozTransition' : 'transitionend',\n 'OTransition' : 'oTransitionEnd otransitionend',\n 'transition' : 'transitionend'\n }\n\n for (var name in transEndEventNames) {\n if (el.style[name] !== undefined) {\n return { end: transEndEventNames[name] }\n }\n }\n\n return false // explicit for ie8 ( ._.)\n }", "title": "" }, { "docid": "8c8faffc959bf16010fc6f4a4082bb3d", "score": "0.40885565", "text": "function genCSSMotion(transitionSupport) {\n function isSupportTransition(props) {\n return !!(props.motionName && transitionSupport);\n }\n\n var CSSMotion = function (_React$Component) {\n _inherits(CSSMotion, _React$Component);\n\n function CSSMotion() {\n _classCallCheck(this, CSSMotion);\n\n var _this = _possibleConstructorReturn(this, (CSSMotion.__proto__ || Object.getPrototypeOf(CSSMotion)).call(this));\n\n _this.onDomUpdate = function () {\n var _this$state = _this.state,\n status = _this$state.status,\n newStatus = _this$state.newStatus;\n var _this$props = _this.props,\n onAppearStart = _this$props.onAppearStart,\n onEnterStart = _this$props.onEnterStart,\n onLeaveStart = _this$props.onLeaveStart,\n onAppearActive = _this$props.onAppearActive,\n onEnterActive = _this$props.onEnterActive,\n onLeaveActive = _this$props.onLeaveActive,\n motionAppear = _this$props.motionAppear,\n motionEnter = _this$props.motionEnter,\n motionLeave = _this$props.motionLeave;\n\n\n if (!isSupportTransition(_this.props)) {\n return;\n }\n\n // Event injection\n var $ele = ReactDOM__default.findDOMNode(_this);\n if (_this.$ele !== $ele) {\n _this.removeEventListener(_this.$ele);\n _this.addEventListener($ele);\n _this.$ele = $ele;\n }\n\n // Init status\n if (newStatus && status === STATUS_APPEAR && motionAppear) {\n _this.updateStatus(onAppearStart, null, null, function () {\n _this.updateActiveStatus(onAppearActive, STATUS_APPEAR);\n });\n } else if (newStatus && status === STATUS_ENTER && motionEnter) {\n _this.updateStatus(onEnterStart, null, null, function () {\n _this.updateActiveStatus(onEnterActive, STATUS_ENTER);\n });\n } else if (newStatus && status === STATUS_LEAVE && motionLeave) {\n _this.updateStatus(onLeaveStart, null, null, function () {\n _this.updateActiveStatus(onLeaveActive, STATUS_LEAVE);\n });\n }\n };\n\n _this.onMotionEnd = function (event) {\n var _this$state2 = _this.state,\n status = _this$state2.status,\n statusActive = _this$state2.statusActive;\n var _this$props2 = _this.props,\n onAppearEnd = _this$props2.onAppearEnd,\n onEnterEnd = _this$props2.onEnterEnd,\n onLeaveEnd = _this$props2.onLeaveEnd;\n\n if (status === STATUS_APPEAR && statusActive) {\n _this.updateStatus(onAppearEnd, { status: STATUS_NONE }, event);\n } else if (status === STATUS_ENTER && statusActive) {\n _this.updateStatus(onEnterEnd, { status: STATUS_NONE }, event);\n } else if (status === STATUS_LEAVE && statusActive) {\n _this.updateStatus(onLeaveEnd, { status: STATUS_NONE }, event);\n }\n };\n\n _this.addEventListener = function ($ele) {\n if (!$ele) return;\n\n $ele.addEventListener(transitionEndName, _this.onMotionEnd);\n $ele.addEventListener(animationEndName, _this.onMotionEnd);\n };\n\n _this.removeEventListener = function ($ele) {\n if (!$ele) return;\n\n $ele.removeEventListener(transitionEndName, _this.onMotionEnd);\n $ele.removeEventListener(animationEndName, _this.onMotionEnd);\n };\n\n _this.updateStatus = function (styleFunc, additionalState, event, callback) {\n var statusStyle = styleFunc ? styleFunc(ReactDOM__default.findDOMNode(_this), event) : null;\n\n if (statusStyle === false || _this._destroyed) return;\n\n var nextStep = void 0;\n if (callback) {\n nextStep = function nextStep() {\n _this.nextFrame(callback);\n };\n }\n\n _this.setState(_extends$1({\n statusStyle: typeof statusStyle === 'object' ? statusStyle : null,\n newStatus: false\n }, additionalState), nextStep); // Trigger before next frame & after `componentDidMount`\n };\n\n _this.updateActiveStatus = function (styleFunc, currentStatus) {\n // `setState` use `postMessage` to trigger at the end of frame.\n // Let's use requestAnimationFrame to update new state in next frame.\n _this.nextFrame(function () {\n var status = _this.state.status;\n\n if (status !== currentStatus) return;\n\n _this.updateStatus(styleFunc, { statusActive: true });\n });\n };\n\n _this.nextFrame = function (func) {\n _this.cancelNextFrame();\n _this.raf = raf_1(func);\n };\n\n _this.cancelNextFrame = function () {\n if (_this.raf) {\n raf_1.cancel(_this.raf);\n _this.raf = null;\n }\n };\n\n _this.state = {\n status: STATUS_NONE,\n statusActive: false,\n newStatus: false,\n statusStyle: null\n };\n _this.$ele = null;\n _this.raf = null;\n return _this;\n }\n\n _createClass(CSSMotion, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n this.onDomUpdate();\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n this.onDomUpdate();\n }\n }, {\n key: 'componentWillUnmount',\n value: function componentWillUnmount() {\n this._destroyed = true;\n this.removeEventListener(this.$ele);\n this.cancelNextFrame();\n }\n }, {\n key: 'render',\n value: function render() {\n var _classNames;\n\n var _state = this.state,\n status = _state.status,\n statusActive = _state.statusActive,\n statusStyle = _state.statusStyle;\n var _props = this.props,\n children = _props.children,\n motionName = _props.motionName,\n visible = _props.visible,\n removeOnLeave = _props.removeOnLeave;\n\n\n if (!children) return null;\n\n if (status === STATUS_NONE || !isSupportTransition(this.props)) {\n return visible || !removeOnLeave ? children({}) : null;\n }\n\n return children({\n className: classnames((_classNames = {}, _defineProperty(_classNames, getTransitionName$1(motionName, status), status !== STATUS_NONE), _defineProperty(_classNames, getTransitionName$1(motionName, status + '-active'), status !== STATUS_NONE && statusActive), _defineProperty(_classNames, motionName, typeof motionName === 'string'), _classNames)),\n style: statusStyle\n });\n }\n }], [{\n key: 'getDerivedStateFromProps',\n value: function getDerivedStateFromProps(props, _ref) {\n var prevProps = _ref.prevProps;\n\n if (!isSupportTransition(props)) return {};\n\n var visible = props.visible,\n motionAppear = props.motionAppear,\n motionEnter = props.motionEnter,\n motionLeave = props.motionLeave,\n motionLeaveImmediately = props.motionLeaveImmediately;\n\n var newState = {\n prevProps: props\n };\n\n // Appear\n if (!prevProps && visible && motionAppear) {\n newState.status = STATUS_APPEAR;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n // Enter\n if (prevProps && !prevProps.visible && visible && motionEnter) {\n newState.status = STATUS_ENTER;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n // Leave\n if (prevProps && prevProps.visible && !visible && motionLeave || !prevProps && motionLeaveImmediately && !visible && motionLeave) {\n newState.status = STATUS_LEAVE;\n newState.statusActive = false;\n newState.newStatus = true;\n }\n\n return newState;\n }\n }]);\n\n return CSSMotion;\n }(React__default.Component);\n\n CSSMotion.propTypes = {\n visible: propTypes.bool,\n children: propTypes.func,\n motionName: propTypes.oneOfType([propTypes.string, propTypes.object]),\n motionAppear: propTypes.bool,\n motionEnter: propTypes.bool,\n motionLeave: propTypes.bool,\n motionLeaveImmediately: propTypes.bool, // Trigger leave motion immediately\n removeOnLeave: propTypes.bool,\n onAppearStart: propTypes.func,\n onAppearActive: propTypes.func,\n onAppearEnd: propTypes.func,\n onEnterStart: propTypes.func,\n onEnterActive: propTypes.func,\n onEnterEnd: propTypes.func,\n onLeaveStart: propTypes.func,\n onLeaveActive: propTypes.func,\n onLeaveEnd: propTypes.func\n };\n CSSMotion.defaultProps = {\n visible: true,\n motionEnter: true,\n motionAppear: true,\n motionLeave: true,\n removeOnLeave: true\n };\n\n\n polyfill(CSSMotion);\n\n return CSSMotion;\n }", "title": "" } ]
81fab31992f435863acf901958d397dd
increases the winners score, return strings for game result,
[ { "docid": "632ce180b52339e3da9a844065c2c805", "score": "0.0", "text": "function gameTie(playerSelection, computerSelection) {\n return `Tie! You both picked ${playerSelection}!`;\n}", "title": "" } ]
[ { "docid": "cda34f317ba0f7be25a8bfffcdd91d9d", "score": "0.74581164", "text": "function increaseScore(winner) {\n if (winner == \"p\") {\n playerScore += 1;\n playerScoreText.textContent = playerScore;\n } else if (winner == \"c\") {\n computerScore += 1;\n computerScoreText.textContent = computerScore;\n }\n}", "title": "" }, { "docid": "ad6f28e4b805b5c22927cc1a73e62331", "score": "0.74456763", "text": "function determineWinner() {\n if (playerOption == 1 && comOption == 3) {\n userScore += 1;\n console.log(`Your opponent choose scissors. You won! \\nScores \n \\nYou: ${userScore} Opponent: ${comScore}`)\n } \n else if (playerOption == 2 && comOption == 1) {\n userScore += 1;\n console.log(`Your opponent choose rock. You won! \\nScores \n \\nYou: ${userScore} Opponent: ${comScore}`)\n }\n else if (playerOption == 3 && comOption == 2) {\n userScore += 1;\n console.log(`Your opponent choose paper. You won! \\nScores \n \\nYou: ${userScore} Opponent: ${comScore}`)\n } \n else if (playerOption == 1 && comOption == 2) {\n comScore += 1;\n console.log(`Your opponent choose paper. You lost! \\nScores \n \\nYou: ${userScore} Opponent: ${comScore}`)\n } \n else if (playerOption == 2 && comOption == 3) {\n comScore += 1;\n console.log(`Your opponent choose scissors. You lost! \\nScores \n \\nYou: ${userScore} Opponent: ${comScore}`)\n } \n else if (playerOption == 3 && comOption == 1) {\n comScore += 1;\n console.log(`Your opponent choose rock. You lost! \\nScores \n \\nYou: ${userScore} Opponent: ${comScore}`)\n } else {\n console.log(`You and the opponent had the same selection. It's a draw!`);\n }\n}", "title": "" }, { "docid": "e84992fd3f0bf39c479563628f791629", "score": "0.73548406", "text": "function updateScore(winner) {\n if (winner === 'human')\n humanScore++;\n else if (winner === 'computer')\n computerScore++;\n}", "title": "" }, { "docid": "544f8230938a9edba352d42783a4714e", "score": "0.73454463", "text": "function getWinner(){\n\n\t\tconsole.log(\"running winner logic\");\n\t\tconsole.log(score[0]);\n\t\tconsole.log(score[1]);\n\n\t\tif (score[0] > score[1]) {\n\t\t\twinner = \"Player 1\";\n\t\t\t$('.modal').fadeIn(1500);\n\t\t\t$('.winner h1').html( winner + \" takes it, baby! You crushed Player 2 by \" + Math.ceil(score[0] - score[1]) + \" points\");\n\t\t} else if (score[1] > score[0]) {\n\t\t\twinner = \"Player 2\";\n\t\t\t$('.modal').fadeIn(1500);\n\t\t\t$('.winner h1').html( winner + \" takes it, baby! You crushed Player 1 by \" + Math.ceil(score[1] - score[0]) + \" points\");\n\t\t} else {\n\t\t\twinner = \"It's a tie - that's boring\";\n\t\t\t$('.modal').fadeIn(1500);\n\t\t\t$('.winner h1').html( winner );\n\n\t\t}\n\n\t\tnewGame();\n}", "title": "" }, { "docid": "15f1d8721400d78e6d2613a50211f8a3", "score": "0.73384917", "text": "function getScore() {\n if (isWon()) {\n return getWinningPlayer() + \" wins\";\n }\n return \"player 1: \" + player1Score + \" - player 2: \" + player2Score;\n }", "title": "" }, { "docid": "34435ea86ead97eaad9ac7ffea6ce7d5", "score": "0.73254734", "text": "evaluateScore(user, computer){\n let userScore = parseInt(this.userScore.textContent);\n let compScore = parseInt(this.compScore.textContent);\n let result = ''\n\n // if and else statement\n if(user != computer){\n if(user === 'rock'){\n if(computer === 'scissors'){\n userScore ++;\n result = 'win';\n } else {\n compScore ++;\n result = 'loss';\n }\n }\n if(user === 'paper'){\n if(computer === 'rock'){\n userScore ++;\n result = 'win';\n }else {\n compScore ++;\n result = 'loss';\n }\n }\n if(user === 'scissors'){\n if(computer === 'paper'){\n userScore ++;\n result ='win';\n }else {\n compScore ++;\n result = 'loss';\n }\n }\n\n // increment scoreboard \n this.userScore.textContent = userScore;\n this.compScore.textContent = compScore;\n } else {\n result = 'draw';\n }\n return result;\n }", "title": "" }, { "docid": "d05a55e3721a4470ac12f57176ec5e3e", "score": "0.7324367", "text": "function checkScore(win) {\n if(win == \"Player wins!\"){\n scorePlayer += 1\n score.textContent = \"Player: \" + scorePlayer + \" Computer: \" + scoreComputer\n } else if (win == \"Computer wins!\") {\n scoreComputer += 1\n score.textContent = \"Player: \" + scorePlayer + \" Computer: \" + scoreComputer\n } else if (win == \"Draw\") {\n score.textContent = \"Player: \" + scorePlayer + \" Computer: \" + scoreComputer\n }\n roundsPlayed += 1\n console.log(roundsPlayed)\n }", "title": "" }, { "docid": "a83399e31626c9fa82f4ed80ef9ffc16", "score": "0.72412384", "text": "function score() {\n winsE.innerHTML = player.wins;\n if(player.wins > player.best) {\n player.best = player.wins;\n }\n bestE.innerHTML = player.best;\n\n if (player.wins < 2) {\n removeGems(gem);\n }\n else{\n collectGems(gem);\n }\n\n}", "title": "" }, { "docid": "db3847896504d2df96a30585288ee55f", "score": "0.72293997", "text": "function getScore() {\n if (this.hasWinner())\n return this.playerWithHighestScore() + ' wins';\n if (this.hasAdvantage())\n return 'Advantage ' + this.playerWithHighestScore();\n if(this.isDeuce())\n return 'Deuce';\n if(this.playerOneScore === this.playerTwoScore)\n return this.translateScore(this.playerOneScore) + ' all';\n return this.playerOneScore > this.playerTwoScore ? \n translateScore(this.playerTwoScore) + ', ' + translateScore(this.playerOneScore) :\n translateScore(this.playerOneScore) + ', ' + translateScore(this.playerTwoScore);\n}", "title": "" }, { "docid": "377bf91a94bafe38f481266987c57bb1", "score": "0.72206104", "text": "function winner() {\n if (scorePlayerOne > scorePlayerTwo) {\n victor = \"Player 1\";\n victorScore = scorePlayerOne;\n } else if (scorePlayerOne < scorePlayerTwo) {\n victor = \"Player 2\";\n victorScore = scorePlayerTwo;\n } else if (scorePlayerOne == scorePlayerTwo) {\n winnerErrorMsg = true;\n }\n}", "title": "" }, { "docid": "a915f25c9b70e1818ee1581a6d724e31", "score": "0.71903926", "text": "function win(userChoice, computerChoice) {\n userScore++;\n userScore_span.innerHTML = userScore;\n computerScore_span.innerHTML = computerScore;\n var smallUserWord = \"user\".fontsize(3).sub();\n var smallCompWord = \"comp\".fontsize(3).sub();\n result_p.innerHTML = `${convertToWord(userChoice)}(user) beats ${convertToWord(computerChoice)}(comp). You win!`;\n}", "title": "" }, { "docid": "43c3dc549a23bca8173df18fd0f5d001", "score": "0.713795", "text": "function winner()\n{\n if (playerScore > compScore)\n return 'Player wins!';\n else if (compScore > playerScore)\n return 'Computer wins!';\n else if (playerScore == compScore)\n return 'It was a draw';\n else\n return 'Something wrong happened!';\n}", "title": "" }, { "docid": "347eca63b089bbae871f51d951289955", "score": "0.7130765", "text": "function win(userChoice, computerChoice) {\n userScore++\n userScoreSpan.innerHTML = userScore\n computerScoreSpan.innerHTML = computerScore\n resultParagraph.innerHTML = `${convertToWord(userChoice)} beats ${convertToWord(computerChoice)}. You win!`\n\n }", "title": "" }, { "docid": "a199ee1d646ab13dda6be681d51d92b2", "score": "0.71230054", "text": "function addScore(winner) {\r\n winnerScore = document.querySelector('#Computer');\r\n\r\n //Checks for who wins\r\n if (winner == 'player')\r\n winnerScore = document.querySelector('#Player');\r\n\r\n else if (winner == 'computer')\r\n winnerScore = document.querySelector('#Computer');\r\n\r\n else\r\n return;\r\n\r\n //Edits HTML to change the score\r\n originalText = winnerScore.textContent;\r\n sliceText = originalText.slice(0, originalText.length - 1);\r\n score = parseInt(originalText[originalText.length - 1]);\r\n score++;\r\n winnerScore.textContent = sliceText + score;\r\n}", "title": "" }, { "docid": "6db4f6339b7f5ba1575202920afa6e7c", "score": "0.7118136", "text": "function updateScore(roundWinner) {\n if (roundWinner == \"human\") {\n humanScore++;\n } else if (roundWinner == \"computer\") {\n computerScore++;\n }\n}", "title": "" }, { "docid": "9785036d5993588cf0eb7828b96266e4", "score": "0.71134704", "text": "function displayWinner() {\n // reduce players array to determine top score\n let topScore = players.reduce((top, current) => {\n return current.score > top ? current.score : top;\n }, 0);\n\n let winner = [];\n // loop through players array to determine who achieved top score\n players.forEach((player) => {\n if (player.score === topScore) winner.push(player.name);\n });\n \n let winnerString = winner[0];\n winner.forEach((person, index) => {\n if (index !== 0) winnerString += `, ${person} `;\n });\n\n if (winner.length > 1) {\n alert(`It's a tie! ${winnerString}: fight to determine the winner`);\n } else {\n alert(`Congratulations, ${winner[0]}! You won Strings Against Humanity!`);\n }\n}", "title": "" }, { "docid": "4d70b7890690bae95da5f34f099afcd7", "score": "0.70966864", "text": "function compareScore(){\n \n\n \n // compare random number and totalsccore\n if(randomNum === totalScore){\n win++// increment win\n $(wins).text(win);// output winning score\n console.log(win)\n totalScore = 0\n \n }\n else if (randomNum < totalScore){\n loss++//increment loss\n $(losses).text(loss);// output lossing score\n console.log(loss) \n totalScore = 0\n \n }\n}", "title": "" }, { "docid": "c60bde444b8c0f9bb9b2a6be49b29f70", "score": "0.709525", "text": "function win(user,com){\n console.log(\"You Win!!!👍\")\n userScore++;\n userScoreHTML.innerHTML = userScore;\n comScoreHTML.innerHTML = comScore;\n resultHTML.innerHTML = (\"You win!! Computer chose \"+ com +\".\")\n}", "title": "" }, { "docid": "dbb2d30c41ffd76e133898bb2bc3497f", "score": "0.70912945", "text": "function updateScore(winner) {\n if (winner === \"X\") {\n xWins++;\n $('#xWins').html(xWins);\n } else if (winner === \"O\") {\n oWins++;\n $('#oWins').html(oWins);\n }\n }", "title": "" }, { "docid": "2da2a514a0978edb98df78b1dce591ce", "score": "0.70881826", "text": "function calculateScore(winner) {\n let computerPoints = 0;\n let playerPoints = 0;\n\n function playerWin() {\n for (let i = 0; i < hand.computer.length; i++) {\n playerPoints += hand.computer[i].value;\n }\n tally.playerTotal += playerPoints;\n }\n \n function computerWin() {\n for (let i = 0; i < hand.player.length; i++) {\n computerPoints += hand.player[i].value;\n }\n tally.computerTotal += computerPoints;\n }\n \n if (winner === 'player') {\n playerWin();\n tally.wins += 1;\n } else if (winner === 'computer') {\n computerWin();\n tally.losses += 1;\n } else if (winner === 'draw') {\n playerWin();\n computerWin();\n }\n\n $('#play-points').text(playerPoints);\n $('#comp-points').text(computerPoints);\n\n const computerLosses = tally.wins;\n const computerWins = tally.losses;\n $('#p-wins').text(tally.wins);\n $('#p-losses').text(tally.losses);\n $('#p-points').text(tally.playerTotal);\n $('#c-wins').text(computerWins);\n $('#c-losses').text(computerLosses);\n $('#c-points').text(tally.computerTotal);\n}", "title": "" }, { "docid": "f61d3e0b3c919b4d84eea1fe95b27115", "score": "0.70653844", "text": "function analyze_results() {\n switch (choice) {\n case \"rock\":\n if (oppChoice === \"rock\") {\n results = \"tie\"\n userTies += 1 \n oppTies += 1\n $(\"#result\").text(\"It's a Tie!\")\n } else if (oppChoice === \"paper\") {\n results = \"loss\"\n userLosses += 1\n oppWins += 1\n $(\"#result\").text(\"You Lose!\")\n } else if (oppChoice === \"scissors\") {\n results = \"win\"\n oppLosses +=1\n userWins += 1\n $(\"#result\").text(\"You Win!\")\n\n }\n break\n \n case \"scissors\":\n if (oppChoice === \"scissors\") {\n results = \"tie\"\n userTies = 1\n oppTies = 1\n $(\"#result\").text(\"It's a Tie!\")\n } else if (oppChoice === \"rock\") {\n results = \"loss\"\n userLosses += 1\n oppWins += 1\n $(\"#result\").text(\"You Lose!\")\n } else if (oppChoice === \"paper\") {\n results = \"win\"\n oppLosses +=1\n userWins += 1\n $(\"#result\").text(\"You Win!\")\n }\n break\n case \"paper\":\n if (oppChoice === \"paper\") {\n results = \"tie\"\n userTies = 1\n oppTies = 1\n $(\"#result\").text(\"It's a Tie!\")\n } else if (oppChoice === \"scissors\") {\n results = \"loss\"\n userLosses += 1\n oppWins += 1\n $(\"#result\").text(\"You Lose!\")\n } else if (oppChoice === \"rock\") {\n results = \"win\"\n oppLosses +=1\n userWins += 1\n $(\"#result\").text(\"You Win!\")\n }\n break\n }}", "title": "" }, { "docid": "ccc427ca59d47cb51689add4617ac20a", "score": "0.70530444", "text": "function playerWin() {\n playerScore += 1;\n declareWinner(winResult, winMessage);\n document.getElementById(\"player-score\").innerHTML = `<br>${playerScore}`;\n\n}", "title": "" }, { "docid": "e36429cca2bc121af55390f9843e6cd5", "score": "0.7049287", "text": "function playRound(getComputerChoice, getPlayerChoice) { \n \n if (getComputerChoice === 'rock' && getPlayerChoice === 'scissors') { // rock to scissors comp wins\n computerScore++;\n return `You lose. rock beats scissors | Score: ${playerScore} to ${computerScore} | PlayerInput: ${getPlayerChoice} CompInput: ${getComputerChoice}`;\n } else if (getComputerChoice === 'scissors' && getPlayerChoice === 'paper') { // scissors to paper comp wins\n computerScore++;\n return `You lose. scissors beats paper | Score: ${playerScore} to ${computerScore} | PlayerInput: ${getPlayerChoice} CompInput: ${getComputerChoice}`;\n } else if (getComputerChoice === 'paper' && getPlayerChoice === 'rock') { // paper to rock comp wins\n computerScore++;\n return `You lose. paper beats rock | Score: ${playerScore} to ${computerScore} | PlayerInput: ${getPlayerChoice} CompInput: ${getComputerChoice}`;\n } else if (getPlayerChoice === 'rock' && getComputerChoice === 'scissors') { // Player options and functions \n playerScore++;\n return `You Win. rock beats scissors | Score: ${playerScore} to ${computerScore}| PlayerInput: ${getPlayerChoice} CompInput: ${getComputerChoice}` ;\n } else if (getPlayerChoice === 'scissors' && getComputerChoice === 'paper') {\n playerScore++;\n return `You Win. scissors beats paper | Score: ${playerScore} to ${computerScore} | PlayerInput: ${getPlayerChoice} CompInput: ${getComputerChoice}`;\n } else if (getPlayerChoice === 'paper' && getComputerChoice === 'rock') {\n playerScore++;\n return `You Win. paper beats rock | Score: ${playerScore} to ${computerScore} | PlayerInput: ${getPlayerChoice} CompInput: ${getComputerChoice}`;\n } else if (getComputerChoice === getPlayerChoice) {\n return ` Its a Draw | Score: ${playerScore} to ${computerScore} | PlayerInput: ${getPlayerChoice} CompInput: ${getComputerChoice}`;\n }\n}", "title": "" }, { "docid": "ab9e4844aa34830a2987829bd0b94b0b", "score": "0.7046695", "text": "function getResult(player, bot) {\n\n //spiller sine valg\n if (player === bot) {\n tieText = \"Uavgjort!\";\n }\n else if (player == 'kniv') {\n if (bot == 'pistol') {\n players[1]++;\n\n } else {\n players[0]++;\n }\n tieText = \"\";\n }\n else if (player == 'bombe') {\n if (bot == 'kniv') {\n players[1]++\n } else {\n players[0]++\n }\n tieText = \"\";\n }\n else if (player == 'pistol') {\n if (bot == 'bombe') {\n players[1]++\n } else {\n players[0]++\n }\n tieText = \"\";\n }\n\n round++;\n\n}", "title": "" }, { "docid": "a200cb8ae7304af05629c3842b76836a", "score": "0.7031933", "text": "function score() {\n console.log(\"You picked \" + userChoice + \", but computer chose \" + choice);\n\n if (choice === userChoice) {\n document.getElementById(\"results\").innerHTML = \"Tie!\"\n }\n else if ((choice === \"s\" && userChoice === \"p\") || (choice === \"p\" && userChoice === \"r\") || (choice === \"r\" && userChoice === \"l\") || (choice === \"sp\" && userChoice === \"s\") || (choice === \"s\" && userChoice === \"l\") || (choice === \"l\" && userChoice === \"p\") || (choice === \"p\" && userChoice === \"sp\") || (choice === \"sp\" && userChoice === \"r\") || (choice === \"r\" && userChoice === \"s\")) {\n document.getElementById(\"results\").innerHTML = \"You lose!\";\n compScore++;\n console.log(userScore);\n updateScore();\n }\n else {\n document.getElementById(\"results\").innerHTML = \"You win!\";\n userScore++;\n console.log(userScore);\n updateScore();\n }\n}", "title": "" }, { "docid": "00f8d16ea124cb0dc211458714db911e", "score": "0.7029372", "text": "function results() {\n if (params.games < params.rounds) { \n result.innerHTML = 'You:'+params.wins+ ' - Computer:'+params.loses+'<br><br> games played: '+params.games+'.'\n }\n}", "title": "" }, { "docid": "c85be9c949eed5c0d905739896166381", "score": "0.7028633", "text": "function updateScore(winner){\n score[winner] += 1;\n $('#'+winner+\"-score\").text(score[winner]);\n }", "title": "" }, { "docid": "3aae8753515bd530937079b45bbe4f37", "score": "0.7027203", "text": "function score(result) {\n if (result === \"won\") {\n playerScore = playerScore + 1;\n } else computerScore = computerScore + 1;\n if (playerScore < 5 && computerScore < 5) {\n pickAgain.textContent = \"Please pick again.\";\n scoreCounter.textContent =\n \"Player: \" + playerScore + \" Computer: \" + computerScore;\n } else finalScore();\n}", "title": "" }, { "docid": "9c6b9ba8c76a0e8e80df2aa4f520bf0a", "score": "0.7021008", "text": "function updateResoults(playerwin) {\n var resultP=parseInt(resultPlayer.innerHTML);\n var resultC=parseInt(resultComputer.innerHTML);\n \n if (playerwin) {\n resultP++;\n resultPlayer.innerHTML=resultP;\n }\n else {\n resultC++;\n resultComputer.innerHTML=resultC;\n }\n if (resultP > 2) {\n resultTourn.innerHTML= 'You have WON the game!';\n alert.classList.remove('alertHide');\n buttons.classList.add('alertHide');\n }\n else if (resultC > 2) {\n resultTourn.innerHTML= 'You have LOST the game!';\n alert.classList.remove('alertHide');\n buttons.classList.add('alertHide');\n } \n}", "title": "" }, { "docid": "b385d1f09282369e0a889bc436503405", "score": "0.70052683", "text": "setResult(score) {\n if (score == 1) {\n this.win.textContent = ++this.win.textContent;\n } else if (score == 0) {\n this.lost.textContent = ++this.lost.textContent;\n }\n this.gameNumber.textContent = ++this.gameNumber.textContent;\n }", "title": "" }, { "docid": "66101ec51688d6f222ce22dbf006138c", "score": "0.7004844", "text": "function countWins(win) {\n\n if (win == \"win\") {\n playerWinCount++;\n if (playerWinCount == 5) {\n printPlayerWin();\n } else if (computerWinCount == 5) {\n printComputerWin();\n } else {\n resultText.classList.add('resultText');\n resultText.textContent = `Your moves are super effective! ${playerSelection} beats ${computerSelection}!`;\n resultDiv.appendChild(resultText);\n }\n\n playerScoreText.textContent = `Score: ${playerWinCount}`;\n playerScore.appendChild(playerScoreText);\n } else if (win == \"lose\") {\n computerWinCount++;\n if (playerWinCount == 5) {\n printPlayerWin();\n } else if (computerWinCount == 5) {\n printComputerWin();\n } else {\n resultText.classList.add('resultText');\n resultText.textContent = `Your moves are not very effective. ${computerSelection} beats ${playerSelection}!`;\n resultDiv.appendChild(resultText);\n }\n\n opponentScoreText.textContent = `Score: ${computerWinCount}`;\n opponentScore.appendChild(opponentScoreText);\n } else if (win == \"tie\") {\n resultText.classList.add('resultText');\n resultText.textContent = \"Both Pokémon fought really hard... and passed out. It's a tie!\";\n resultDiv.appendChild(resultText);\n } else {\n resultText.classList.add('resultText');\n resultText.textContent = \"Something went horribly wrong...\";\n resultDiv.appendChild(resultText);\n }\n}", "title": "" }, { "docid": "3a6a187fa2ae884dedd2dc64e3646642", "score": "0.6998005", "text": "function overallWinner() {\n console.log(`All games have been played. Overall scores:\n \\nYou: ${playerOption} Opponent: ${comOption}`)\n if (playerOption > comOption) {\n console.log(`Congratulations, you won!`)\n } else if (playerOption < comOption) {\n console.log(`What a shame, you lost!`)\n } else {\n console.log(`Oh wow, it's a draw!`)\n }\n}", "title": "" }, { "docid": "79d254accd0c2c04df87a4fb712caa7c", "score": "0.69977427", "text": "checkWinner() {\n let result = null;\n const playerScore = calculateScore(this.props.game.playerHand);\n const dealerScore = calculateScore(this.props.game.dealerHand);\n\n if (playerScore === 21 && dealerScore === 21) result = 'DRAW';\n else if (playerScore === 21 || dealerScore > 21) result = 'PLAYER';\n else if (dealerScore === 21 || playerScore > 21) result = 'DEALER';\n else if (dealerScore === playerScore && !this.props.game.playerTurn) result = 'DRAW';\n else if (dealerScore > playerScore && !this.props.game.playerTurn) result = 'DEALER';\n\n return result;\n }", "title": "" }, { "docid": "c602c9281a0c220947110fee739ed56d", "score": "0.6995595", "text": "function computeWinner(){\n let winner;\n let currentWins = document.querySelector('#wins').innerHTML;\n let currentLosses = document.querySelector('#losses').innerHTML;\n let currentDrews = document.querySelector('#Draws').innerHTML;\n\n if (YOU['score'] <= 21) {\n if (YOU['score'] > DEALER['score'] || (DEALER['score'] >21)){\n winner = blackjackGame['whoWon'].player1;\n currentWins++;\n document.querySelector('#wins').innerHTML = currentWins;\n } else if (YOU['score'] < DEALER['score'] && DEALER['score'] < 21) {\n winner = blackjackGame['whoWon'].player2;\n currentLosses++;\n document.querySelector('#losses').innerHTML = currentLosses;\n } else if (YOU['score'] === DEALER['score']){\n winner = blackjackGame['whoWon'].tie;\n currentDrews++;\n document.querySelector('#Draws').innerHTML = currentDrews;\n }\n } else if (YOU['score'] > 21 && DEALER['score'] <= 21) {\n winner = blackjackGame['whoWon'].player2;\n currentLosses++;\n document.querySelector('#losses').innerHTML = currentLosses;\n } else if (YOU['score'] > 21 && DEALER['score'] >21) {\n winner = blackjackGame['whoWon'].tie;\n currentDrews++;\n document.querySelector('#Draws').innerHTML = currentDrews;\n }\n console.log(winner);\n document.querySelector('#blackjack-result').textContent = winner;\n return winner;\n}", "title": "" }, { "docid": "3e0bb03cb18033587ac40982debabef7", "score": "0.6990319", "text": "function pointScoring (result) {\n if (result == \"draw\") {\n alert(\"The score remains: You = \" + user_score + \" Computer = \" + computer_score);\n return 0;\n }\n else if (result == \"win\") {\n user_score = user_score + 1;\n alert(\"The score is now: You = \" + user_score + \" Computer = \" + computer_score);\n return user_score;\n }\n else if (result == \"lose\") {\n computer_score = computer_score + 1;\n alert(\"The score is now: You = \" + user_score + \" Computer = \" + computer_score);\n return computer_score;\n }\n}", "title": "" }, { "docid": "df01d175561299e6bc14d01ead4e5246", "score": "0.69862866", "text": "function evaluate() {\n if(crystalScore === powerCrystal) {\n $('.wins').html(++wins);\n resetCurrentGuess();\n } else if (crystalScore > powerCrystal) {\n $('.losses').html(++losses);\n resetCurrentGuess();\n }\n}", "title": "" }, { "docid": "e6872718d4238759233d49faa0316826", "score": "0.6982654", "text": "function compareScore() {\n if (scoreUser === numTarget) {\n winsTally++;\n wins.text(winsTally);\n resetGame();\n alert(\"You Won!! Good Job!\");\n scoreUser = 0;\n } else if (scoreUser > numTarget) {\n lossesTally++;\n losses.text(lossesTally);\n resetGame();\n alert(\"You Lost! Boo Hoo!\");\n scoreUser = 0;\n };\n }", "title": "" }, { "docid": "d809520466df45c5b0b64e1bbada5626", "score": "0.6982433", "text": "function game() {\n\n if (playerScore >= 4) {\n DOCscore.innerHTML = \"<h1>YOU WIN</h1>\"\n }\n else if (computerScore >= 4) {\n DOCscore.innerHTML = \"<h1>YOU LOSE</h1>\"\n }\n else {\n indexComputerSelection = computerPlay()\n\n let gameResult = playRound(indexPlayerSelection, indexComputerSelection)\n\n playerScore += gameResult.playerPoint\n computerScore += gameResult.computerPoint\n DOCscore.innerHTML = \"<h1>\"+playerScore + \" - \" + computerScore+\"</h1>\"\n }\n}", "title": "" }, { "docid": "3e795333fd8ec925861dec7091342c5b", "score": "0.6975737", "text": "function setScore(winnerName) {\n \n if (winnerName == 'komputer') {\n var element = document.getElementById(\"computerScore\");\n computerScore++;\n element.innerHTML = computerScore;\n }\n else {\n var element = document.getElementById(\"playerScore\");\n playerScore++;\n element.innerHTML = playerScore;\n }\n isGameOver();\n}", "title": "" }, { "docid": "6bbac68633c4e535ea4ec77f6c172076", "score": "0.6971532", "text": "function winner() {\n var p1 = parseInt($(\"#score1\").text());\n var p2 = parseInt($(\"#score2\").text());\n if(p1 === 15){\n $(\"#leader\").text(\"PLAYER 1 WINNER!!!\");\n }\n else if(p2 === 15){\n $(\"#leader\").text(\"PLAYER 2 WINNER!!!\")\n }\n else if(p1 === 15 && p2=== 15){\n $(\"#leader\").text(\"DRAW!!!\")\n }\n\n}", "title": "" }, { "docid": "184193777e245d19b82a88297c980049", "score": "0.69597447", "text": "function whoWon(player1Choice,player2Choice)\n{\n console.log(\"check1: \"+player1Choice);\n console.log(\"check2: \"+player2Choice);\n var winner=\"\";\n if ((player1Choice === \"rock\") && (player2Choice === \"s\")) {\n player1Wins++;\n player2Loss++;\n winner=\"1\";\n }\n else if ((player1Choice === \"rock\") && (player2Choice === \"paper\")) {\n player2Wins++;\n player1Loss++;\n winner=\"2\";\n }\n else if ((player1Choice === \"scissor\") && (player2Choice === \"rock\")) {\n player2Wins++;\n player1Loss++;\n winner=\"2\";\n }\n else if ((player1Choice === \"scissor\") && (player2Choice === \"paper\")) {\n player1Wins++;\n player2Loss++;\n winner=\"1\";\n }\n else if ((player1Choice === \"paper\") && (player2Choice === \"rock\")) {\n player1Wins++;\n player2Loss++;\n winner=\"1\";\n }\n else if ((player1Choice === \"paper\") && (player2Choice === \"scissor\")) {\n player2Wins++;\n player1Loss++;\n winner=\"2\";\n }\n else if (player1Choice === player2Choice) {\n ties++;\n winner=\"0\";\n }\n console.log(player1Wins);\n console.log(player2Wins);\n console.log(ties);\n $(\"#player1Wins\").html(\"Wins: \"+player1Wins);\n $(\"#player1Lose\").html(\"Losses: \"+ player1Loss);\n $(\"#player2Wins\").html(\"Wins: \"+player2Wins);\n $(\"#player2Lose\").html(\"Losses: \"+ player2Loss);\n \n displayWinner(winner);\n \n}", "title": "" }, { "docid": "041f81d8fda8f9b6461486919b1018c0", "score": "0.69541335", "text": "function getWinner(playerOneScore, playerTwoScore){\r\n if (playerOneScore > playerTwoScore){\r\n document.querySelector(\"h1\").textContent = \"Player One Wins\";\r\n }\r\n else if (playerOneScore < playerTwoScore){\r\n document.querySelector(\"h1\").textContent = \"Player Two Wins\";\r\n }\r\n else{\r\n document.querySelector(\"h1\").textContent = \"Draw\";\r\n }\r\n}", "title": "" }, { "docid": "660aabc5f32c8b89ec16bcee65f69a21", "score": "0.6948268", "text": "function scoreGame() {\n\n if (learnMode == true) return;\n\n let bonus = Math.round(1000 * round + 100 / energy1.vel + 5000 / averageTime - 1000 * player1LinesWrong);\n \n if (round > 3 && round <= 6) {bonus *= 4};\n if (round > 6) {bonus *= 8};\n\n // Player 2 wins\n if (energy1.amt <= 0) {\n bonus = 0;\n }\n\n score1 = Math.round(score1 + bonus);\n\n document.getElementById('endBonus').innerHTML = 'BONUS POINTS: ' + bonus;\n document.getElementById('endScore').innerHTML = 'TOTAL SCORE: ' + score1;\n\n score1Counter.innerHTML = 'Score: ' + score1;\n score2Counter.innerHTML = 'Score: ' + score2;\n\n}", "title": "" }, { "docid": "f8961f6258da4cbb64125f9e99138f97", "score": "0.6940296", "text": "function play(humanPlay) {\n\n computerPlay = getComputerPlay();\n\n//define output statement on screen - value you played and what computer played\n document.getElementById('status').innerHTML = \"<p>You played <strong>\" + humanPlay + \"</strong>. The bot played <strong>\" + computerPlay + \"</strong>.</p>\";\n \n if(humanPlay == 'rock') {\n if(computerPlay == 'rock') {\n document.getElementById('status').innerHTML += \"<p>You tied. :|</p>\";\n } else if (computerPlay == 'paper') {\n document.getElementById('status').innerHTML += \"<p>You lose. :(</p>\";\n computerScore++;\n } else if (computerPlay == 'scissors') {\n document.getElementById('status').innerHTML += \"<p>You win! :)</p>\";\n humanScore++;\n }\n } else if (humanPlay == 'paper') {\n if(computerPlay == 'rock') {\n document.getElementById('status').innerHTML += \"<p>You win! :)</p>\";\n humanScore++;\n } else if (computerPlay == 'paper') {\n document.getElementById('status').innerHTML += \"<p>You tied. :|</p>\";\n } else if (computerPlay == 'scissors') {\n document.getElementById('status').innerHTML += \"<p>You lose. :(</p>\";\n computerScore++;\n } \n } else if (humanPlay == 'scissors') {\n if(computerPlay == 'rock') {\n document.getElementById('status').innerHTML += \"<p>You lose. :(</p>\";\n computerScore++;\n } else if (computerPlay == 'paper') {\n document.getElementById('status').innerHTML += \"<p>You win! :)</p>\";\n humanScore++;\n } else if (computerPlay == 'scissors') {\n document.getElementById('status').innerHTML += \"<p>You tied. :|</p>\";\n } \n }\n\n//get total score based on dynamic score from \".innerHTML\"\n document.getElementById('humanScore').innerHTML = humanScore;\n document.getElementById('computerScore').innerHTML = computerScore;\n \n}", "title": "" }, { "docid": "2bd6638e7a102877e73b9b67be661081", "score": "0.6935862", "text": "function getFinalResult(pOneScore, pTwoScore)\n{\n let resultText = \"\";\n\n resultText = resultText.concat(\"Final results.. \");\n\n if (pOneScore > pTwoScore)\n {\n resultText = resultText.concat(\"You are the winner!\");\n }\n else if (pOneScore < pTwoScore)\n {\n resultText = resultText.concat(\"COM is the winner!\");\n }\n else\n {\n resultText = resultText.concat(\"It is a tie!\");\n }\n\n return resultText;\n}", "title": "" }, { "docid": "e8af983193b0d0f438635b11b07fdb8c", "score": "0.69339794", "text": "function game() {\n // keep track of both player's scores\n let playerScore = 0;\n let computerScore = 0;\n var i;\n for (i = 0; i < 5; i++) {\n let playerSelection = playerPlay();\n let computerSelection = computerPlay();\n // determine who gets a point\n let result = playRound(playerSelection, computerSelection);\n if (result === 'win') {\n playerScore++;\n } else if (result === 'lose') {\n computerScore++;\n }\n console.log(`Player: ${playerScore} vs Computer ${computerScore}`);\n }\n return `The final scores are Player: ${playerScore} and Computer: ${computerScore}`;\n}", "title": "" }, { "docid": "1a6594a868655efe18ee07abb2ebd7f2", "score": "0.69338906", "text": "function checkWin() {\n if (score === goal) {\n wins++;\n $(\"#wins\").text(\"Wins: \" + wins);\n resetGame();\n } else if (score > goal) {\n losses++;\n $(\"#losses\").text(\"Losses: \" + losses);\n resetGame();\n }\n}", "title": "" }, { "docid": "914c7a111f4b4fd026d1d5c169ad6697", "score": "0.6933191", "text": "function givePoints(winner) {\n\n // sends pwin (player) or cwin (cpu) and awards points and updating the scoreboard\n // increments points by one\n if (winner === 'pwin'){\n playerPoints++;\n console.log(playerPoints);\n updatePlayerScore(); \n }\n else if(winner ==='cwin') {\n computerPoints++;\n updateComputerScore();\n console.log(computerPoints);\n }\n \n}", "title": "" }, { "docid": "ffefc5a1ee1731a117aba69b5c604121", "score": "0.6925133", "text": "function getWinnerMsg(scores) {\n let msg;\n let winner = scores[\"X\"] > scores[\"O\"] ? \"X\" : \"O\";\n let loser = winner === \"X\" ? \"O\" : \"X\";\n\n if (scores[\"X\"] + scores[\"O\"] === 1) {\n msg = `${winner} wins!!! \\n ${winner} gets 1 point \\n ${loser} gets 0 points`;\n } else if (scores[\"X\"] === 1.5 || scores[\"O\"] === 1.5) {\n msg = `${winner} wins with a double three-in-a-row!!! \\n ${winner} gets 1.5 points \\n ${loser} gets 0 points`;\n } else if (scores[\"X\"] + scores[\"O\"] === 1.5) {\n msg = `Both players got three in a row, but ${winner} got it first! (The mark placed in${winner}'s three-in-a-row has a smaller subscript than ${loser} \\n ${winner} gets 1 point \\n ${loser} gets 0.5 points`;\n }\n\n return msg;\n}", "title": "" }, { "docid": "314cc7a421c23431299fbe0ba65d850d", "score": "0.6923675", "text": "function gamePlay() {\n\t\tif (totalScore == winningNumber) {\n\t\t\twins++;\n\t\t\t$(\".result\").html(\"You win!!\");\n\t\t\treset();\n\t\t}\n\t\tconsole.log(totalScore);\n\t\tconsole.log(winningNumber);\n\t\tif (totalScore > winningNumber) {\n\t\t\tlosses++;\n\t\t\t$(\".result\").html(\"You lose..\");\n\t\t\treset();\n\t\t}\n\t}", "title": "" }, { "docid": "c218d4aabd8cedb7a6ee2b666eb3899c", "score": "0.6908907", "text": "function getWinningPlayer() {\n if (player1Score > player2Score) {\n return \"player 1\";\n }\n return \"player 2\";\n }", "title": "" }, { "docid": "bcc7de6ce6cae73f6256c138e18164f8", "score": "0.6906831", "text": "function playRound(computerChoice, playerChoice) {\n // Take both values and compare, declare the round winner and print a string\n if (computerChoice == \"rock\" && playerChoice == \"rock\") {\n result = \"It's a draw!\";\n } else if (computerChoice == \"rock\" && playerChoice == \"paper\") {\n result = \"Paper covers Rock, you win!\";\n ++playerScore;\n } else if (computerChoice == \"rock\" && playerChoice == \"scissors\") {\n result = \"Rock beats Scissors, You lose!\";\n ++computerScore;\n } else if (computerChoice == \"paper\" && playerChoice == \"rock\") {\n result = \"Paper covers Rock, You lose!\";\n ++computerScore;\n } else if (computerChoice == \"paper\" && playerChoice == \"paper\") {\n result = \"Both chose Paper! It's a draw!\";\n } else if (computerChoice == \"paper\" && playerChoice == \"scissors\") {\n result = \"Scissors cuts Paper, You win!\";\n ++playerScore;\n } else if (computerChoice == \"scissors\" && playerChoice == \"rock\") {\n result = \"Rock beats Scissors, you win!\";\n ++playerScore;\n } else if (computerChoice == \"scissors\" && playerChoice == \"paper\") {\n result = \"Scissors cuts Paper, You lose!\";\n ++computerScore;\n } else if (computerChoice == \"scissors\" && playerChoice == \"scissors\") {\n result = \"It's a draw!\";\n }\n return document.getElementById('winner').innerHTML = result;\n}", "title": "" }, { "docid": "a324ef7a7b85bedf3cd32f408bce6ffd", "score": "0.6898896", "text": "function checkWhoWon(botsWeapon, playersWeapon) {\n if (botsWeapon === playersWeapon) {\n displayCompleteMessage(\"There was a tie\");\n }\n // if bot wins console.log (\"bot wins\") bot score is updates ++1\t\n else if (\n (botsWeapon === \"scissors\" && playersWeapon === \"paper\") ||\n (botsWeapon === \"scissors\" && playersWeapon === \"lizard\") ||\n (botsWeapon === \"paper\" && playersWeapon === \"rock\") ||\n (botsWeapon === \"paper\" && playersWeapon === \"spock\") ||\n (botsWeapon === \"rock\" && playersWeapon === \"scissors\") ||\n (botsWeapon === \"rock\" && playersWeapon === \"lizard\") ||\n (botsWeapon === \"lizard\" && playersWeapon === \"paper\") ||\n (botsWeapon === \"lizard\" && playersWeapon === \"spock\") ||\n (botsWeapon === \"spock\" && playersWeapon === \"scissors\") ||\n (botsWeapon === \"spock\" && playersWeapon === \"rock\")\n ) {\n increaseBotScore();\n }\n // if user wins console.log (\"you win\") user score is updated ++1 \n else if (\n (playersWeapon === \"scissors\" && botsWeapon === \"paper\") ||\n (playersWeapon === \"scissors\" && botsWeapon === \"lizard\") ||\n (playersWeapon === \"paper\" && botsWeapon === \"rock\") ||\n (playersWeapon === \"paper\" && botsWeapon === \"spock\") ||\n (playersWeapon === \"rock\" && botsWeapon === \"scissors\") ||\n (playersWeapon === \"rock\" && botsWeapon === \"lizard\") ||\n (playersWeapon === \"lizard\" && botsWeapon === \"paper\") ||\n (playersWeapon === \"lizard\" && botsWeapon === \"spock\") ||\n (playersWeapon === \"spock\" && botsWeapon === \"scissors\") ||\n (playersWeapon === \"spock\" && botsWeapon === \"rock\")\n ) {\n increasePlayerScore();\n }\n}", "title": "" }, { "docid": "ae8dfab63936a96a06448ed0bbf69c00", "score": "0.689418", "text": "updateScoreCounter() {\n if (this.playerResult === 'win') {\n this.playerScoreCounter ++;\n } else if (this.computerResult === 'win') {\n this.computerScoreCounter ++;\n };\n }", "title": "" }, { "docid": "b9c15e631d10eb090a34530cd440ef0c", "score": "0.6885532", "text": "function updateScore() {\n\tdocument.getElementById(\"wins\").innerHTML = wins;\n\tdocument.getElementById(\"losses\").innerHTML = losses;\n\tdocument.getElementById(\"numberguesses\").innerHTML = remainedGuesses;\n\tdocument.getElementById(\"letters\").innerHTML = lettersGuessed;\n\n\tvar string = genLettersString(lettersRevealed);\n\tdocument.getElementById(\"underscore\").innerHTML = string;\n}", "title": "" }, { "docid": "ec024d2434492d3f136c3a627bedb574", "score": "0.68833643", "text": "function calcWinner() {\n if ( human === 'rock' && findWinner(computer, rockLoses) ) {\n mantra = \"Remember: Rock crushes Scissors, Rock crushes Lizard\";\n compScore += 1;\n } else if ( human === 'paper' && findWinner(computer, paperLoses) ) {\n mantra = \"Remember: Paper covers Rock, Paper disproves Spock\";\n compScore += 1;\n } else if ( human === 'scissors' && findWinner(computer, scissorsLoses) ) {\n mantra = \"Remember: Scissors decapitates Lizard, Scissors cuts Paper\";\n compScore += 1;\n } else if ( human === 'lizard' && findWinner(computer, lizardLoses) ) {\n mantra = \"Remember: Lizard eats Paper, Lizard poisons Spock\";\n compScore += 1;\n } else if ( human === 'spock' && findWinner(computer, spockLoses) ) {\n mantra = \"Remember: Spock vaporizes Rock, Spock smashses Scissors\";\n compScore += 1;\n } else if (human === computer) {\n compScore += 0;\n humanScore += 0;\n } else {\n humanScore += 1;\n }\n}", "title": "" }, { "docid": "0cedcb2b1fb01ee15c265b5ad847705a", "score": "0.688296", "text": "function wins(){\n\tif (guessNum === score)\n\t\twins++\n\n}", "title": "" }, { "docid": "08ed9a135ea1788647b2a19a278d5b88", "score": "0.68775904", "text": "function win(playerOneChoice, computerChoice) {\n \n pOneScore++;\n $(\"#user-score\").html(pOneScore);\n $(\".result\").html(convertWord(playerOneChoice) + \" beats \" + convertWord(computerChoice) + \". Player 1 Wins!\");\n \n }", "title": "" }, { "docid": "e771634657d06c610c101202c6aad078", "score": "0.68724155", "text": "function getRoundDetail(pOneSelection, pTwoSelection, winner, youScore, comScore)\n{\n let resultText = \"\";\n\n if (winner == 1)\n {\n resultText = resultText.concat(\"(<span class='hl-text'>\",\n pOneSelection, \"</span> beats <span class='hl-text'>\",\n pTwoSelection, \"</span>)\", \" (YOU <span class='hl-text'>\",\n youScore, \"</span> : COM <span class='hl-text'>\", comScore, \"</span>)\");\n }\n else if (winner == 2)\n {\n resultText = resultText.concat(\"(<span class='hl-text'>\",\n pTwoSelection, \"</span> beats <span class='hl-text'>\",\n pOneSelection, \"</span>)\", \" (YOU <span class='hl-text'>\",\n youScore, \"</span> : COM <span class='hl-text'>\", comScore, \"</span>)\");\n }\n else\n {\n resultText = resultText.concat(\"(<span class='hl-text'>\",\n pTwoSelection, \"</span> ties <span class='hl-text'>\",\n pOneSelection, \"</span>)\", \" (YOU <span class='hl-text'>\",\n youScore, \"</span> : COM <span class='hl-text'>\", comScore, \"</span>)\");\n }\n\n return resultText;\n}", "title": "" }, { "docid": "071672beb589dbef2598591137dfb229", "score": "0.6871408", "text": "function updateScoreboard() {\n $(\"#wins\").text(wins);\n $(\"#losses\").text(losses);\n }", "title": "" }, { "docid": "0f63f51eefbfdc663d42fa622801febf", "score": "0.68543434", "text": "function chooseFinalScore(input, currPlayer, nextPlayer) {\n var message = '';\n if (currPlayer == 1) {\n // If user inputs 'dice one' retrieve first element of the respective array and concatenate\n // with second element to generate a string of their final score.\n // Display the score and prompt next player to take their turn by clicking the button.\n if (input == 'dice one') {\n Player1Result = `${PlayerOneDiceRolls[0]}${PlayerOneDiceRolls[1]}`;\n message = `Your score is ${Player1Result}.<br>\n Now it is the turn of Player ${nextPlayer}.<br>\n Click the button to roll your 🎲`;\n } else {\n Player1Result = `${PlayerOneDiceRolls[1]}${PlayerOneDiceRolls[0]}`;\n message = `Your score is ${Player1Result}.<br>\n Now it is the turn of Player ${nextPlayer}.<br>\n Click the button to roll your 🎲`;\n }\n // Same logic as above but for Player 2\n } else if (input == 'dice one') {\n Player2Result = `${PlayerTwoDiceRolls[0]}${PlayerTwoDiceRolls[1]}`;\n message = `Your score is ${Player2Result}. `;\n } else {\n Player2Result = `${PlayerTwoDiceRolls[1]}${PlayerTwoDiceRolls[0]}`;\n message = `Your score is ${Player2Result}.`;\n }\n // Return final score and call getResultsMessage function to display winning message\n return message + '<br>' + getResultsMessage(Player1Result, Player2Result);\n}", "title": "" }, { "docid": "1ed880259644eb6d29af52dab2a79a6b", "score": "0.68539107", "text": "function score () {\n\tvar winNo = win.length;\n\tvar lossNo = loss.length;\n\tdocument.getElementById(\"win\").innerHTML = winNo;\n\tdocument.getElementById(\"loss\").innerHTML = lossNo;\n}", "title": "" }, { "docid": "8fa780b6ca6a74ab63fd43283917254b", "score": "0.6848952", "text": "function scoreKeeper(result){\n window.alert(result)\n if (result == \"A Tie!\"){\n return scoreBoard()\n }\n else if (result == \"You Win!\"){\n userScore++\n return scoreBoard()\n }\n else if (result == \"You Lose!\"){\n computerScore++\n return scoreBoard()\n }\n}", "title": "" }, { "docid": "494cc91004493f3713b3c17f67ff8489", "score": "0.6846914", "text": "function winning(){\n \t\twins++\n\t\tend=\"You Win!\";\n\t\tdocument.getElementById(\"endElement\").innerHTML=\"You Win!\";\n\t\tdocument.getElementById(\"winsElement\").innerHTML=\"Wins: \"+wins;\t\t\t\t\n\t\tconsole.log(wins);\n\t\tconsole.log(end);\n\t\ttotalScore=0;\n\t\tcrystleNum1=0;\n\t\tcrystleNum2=0;\n\t\tcrystleNum3=0;\n\t\tcrystleNum4=0;\n\t\tcompNum = Math.floor(Math.random() * (120 - 19)) + 19;\n\t\tdocument.getElementById(\"compNumElement\").innerHTML=compNum;\n\t}", "title": "" }, { "docid": "030b0b7f6cc211ba5d124358a4c492de", "score": "0.6846001", "text": "function displayGame(player, cpu, winner) {\r\n let win = [\"Tie Game\", \"You Won!\", \"You Lost!\"];\r\n pScore.textContent = `Player Score: ${playerScore}`;\r\n cScore.textContent = `CPU Score: ${cpuScore}`;\r\n output.textContent = `You Chose: ${choices[player].toUpperCase()} | Computer Chose: ${choices[cpu].toUpperCase()}`\r\n result.textContent = `${win[winner]}`;\r\n}", "title": "" }, { "docid": "5fb448a99f98e809592b3f76c69d0b70", "score": "0.68361944", "text": "function getResult(result) {\n matchResult.textContent = result;\n winnerOrLoser.style.display = \"grid\";\n if (result === \"You Win\") {\n score += 1;\n scoreDisplayed.textContent = score;\n } else if (result === \"You Lose\") {\n score -= 1;\n if (score < 0) {\n score = 0;\n }\n scoreDisplayed.textContent = score;\n }\n}", "title": "" }, { "docid": "e8e7f10ff5f754f33e602da53f162839", "score": "0.6834574", "text": "function WinLoose (){\n\n//if they lose\n\tif (score === targetNumber){\n\t\twins += 1;\n $(win).text(wins);\n $(update).html(\"Winner\");\n\t\treset(); //call out reset function to generate a new number\n//if they win \n\t} else if(score > targetNumber){\n\t\tlosses += 1;\n $(loss).text(losses);\n $(update).html(\"Loser\");\n\t\treset();\n\t}\n\t\n}", "title": "" }, { "docid": "2fc3c277da6b5b1e87f515c870e7a23e", "score": "0.683455", "text": "function winnerScore(computerScore, playerScore) {\n if (computerScore > playerScore) {\n div.textContent = `You lost. Computer won ${computerScore} out of 5 rounds.`;\n winner = \"computer\";\n } else if (playerScore > computerScore) {\n div.textContent = `You won ${playerScore} out of 5 rounds.`;\n winner = \"player\";\n } else {\n div.textContent = `You tied with computer!`;\n }\n}", "title": "" }, { "docid": "ecbaa152ed30900b7a1f2a6711e386fc", "score": "0.68285763", "text": "function winnerText(playerSelection, computerSelection){\n playerScore++;\n bgWin();\n return(\"You win! \"+ playerSelection +\" beats \" + computerSelection );\n}", "title": "" }, { "docid": "1af9753c5426f743966cd57830c042da", "score": "0.6825571", "text": "function scoreChecker(){\n if (totalScore === targetNumber){\n wins++;\n generator();\n totalScore = 0;\n $(\"#score\").text(totalScore);\n $(\"#wins\").text(wins);\n\n } else if (totalScore > targetNumber){\n losses++;\n generator();\n totalScore = 0;\n $(\"#score\").text(totalScore);\n $(\"#losses\").text(losses);\n }; \n }", "title": "" }, { "docid": "9b2c1ae9d479769ddce3982cd0c0c61c", "score": "0.6825383", "text": "function setScore() {\n winsDisplay.textContent = wins;\n}", "title": "" }, { "docid": "97af257c1117b7569b385e0cef1b09cd", "score": "0.6823147", "text": "function updateScoreBoard(){\n $(\"#score\").html(Math.floor(overallScore/winningScore) + \" wins\");\n}", "title": "" }, { "docid": "91e8ca51b00866098f04562761a8dc88", "score": "0.68176633", "text": "function increaseWinningScore() {\n increaseScore($('#wins'));\n }", "title": "" }, { "docid": "1f1f1d5e25caab170dc4ce414fb27657", "score": "0.68122345", "text": "function win(playerSelection, computerSelection) {\n playerWinCount++;\n playerScore.innerText = playerWinCount;\n message.innerText = `You won! ${capitalize(playerSelection)} beats ${computerSelection}!`; \n}", "title": "" }, { "docid": "a467f640111f9b79a13cde61794f0246", "score": "0.6811174", "text": "function showResults() {\n if (playerScore > computerScore) {\n console.log(\n `______ GAME OVER ______\\n` +\n `Congratulations! You cheated to win the game!\\n\\n`\n );\n } else if (computerScore > playerScore) {\n console.log(\n `______ GAME OVER ______\\n` +\n `Ha! You lost the game! Better luck next time!\\n\\n`\n );\n } else if (playerScore == computerScore) {\n console.log(\n `______ GAME OVER ______\\n` + `We TIED?! That shouldn't be possible!\\n\\n`\n );\n }\n}", "title": "" }, { "docid": "5e2eaf6cf52772e9e8e31a45b8751115", "score": "0.6807322", "text": "function results() {\n if (scoreKeeper === random) {\n $.alert({\n title: 'BOOM BOOM BOOM',\n content: 'You Destroied The Deathstar! MEOW!<a href=\"/assets/images/boom.jpg\">',\n });\n wins ++ ;\n gameStarted = false;\n return;\n }\n else if (scoreKeeper > random) {\n $.alert({\n title: 'SIZZLE THWAP',\n content: 'TOO MUCH! TOO MUCH! Kitty claws scratch! REWAWR!<img src=\"/assets/images/game over.jpg\">',\n });\n loses ++ ;\n gameStarted = false;\n return;\n }\n else (scoreKeeper < random);{\n return;\n }\n}", "title": "" }, { "docid": "c60bc2b210741114a34f2df571d2a69d", "score": "0.67995507", "text": "function updateScore(){\r\n const userText=\"User \";\r\n const computerText=\" Computer\"\r\n const dashText=\"-\"\r\n scoreboardText=userText.concat(userScore).concat(dashText).concat(computerScore).concat(computerText)\r\n scoreBoard.innerHTML=scoreboardText\r\n }", "title": "" }, { "docid": "e574b0017c07f6a89754c9060530bec3", "score": "0.6799087", "text": "function gamePlay(){\n\n if (totalScore === targetScore){\n winningScore++;\n $('#win-counter').text(winningScore);\n $('#win-or-lost').text('Winner!');\n targetScore=(Math.floor(Math.random()*120)+19);\n $('#target-number').text(targetScore);\n totalScore = 0;\n $('#current-score-counter').text(totalScore);\n shuffleGemsValues();\n }\n else if (totalScore > targetScore){\n losingScore++;\n $('#loss-counter').text(losingScore)\n $('#win-or-lost').text('You Lose');\n targetScore=(Math.floor(Math.random()*120)+19);\n $('#target-number').text(targetScore);\n totalScore = 0;\n $('#current-score-counter').text(totalScore);\n shuffleGemsValues();\n }\n}", "title": "" }, { "docid": "acf0c75f3067dfc2ab1772c199243c52", "score": "0.67985624", "text": "function getGameResult () {\n if (gamesCompleted === 5 ) {\n return `YOU FIXED THE SHIP! CONGRATULATIONS!`\n }\n else if (health === 0) {\n return `THE SHIP RAN OUT OF HEALTH, YOU DIED.`\n }\n}", "title": "" }, { "docid": "8e1a396f5c7e858b03becb61b57e88c3", "score": "0.67974055", "text": "function playGame(player) {\n let winner = playRound(player)\n\n // update who won and add to their score\n if (winner === \"player\") {\n playerNumberOfWins++;\n let playerScore = document.querySelector('#player');\n playerScore.textContent = playerNumberOfWins.toString();\n } else if (winner === \"computer\") {\n computerNumberOfWins++;\n let computerScore = document.querySelector('#computer');\n computerScore.textContent = computerNumberOfWins.toString();\n }\n\n let roundResult = document.querySelector('#round-result');\n\n if (playerNumberOfWins == 5) {\n roundResult.textContent = \"You won the match!\";\n gameOver = true;\n } else if (computerNumberOfWins == 5) {\n roundResult.textContent = \"You lost the match!\";\n gameOver = true;\n }\n}", "title": "" }, { "docid": "e4329686241d3b2ddb1c3e09c9d607a4", "score": "0.6797178", "text": "function computerWin() {\n computerScore += 1;\n declareWinner(loseResult, loseMessage);\n document.getElementById(\"computer-score\").innerHTML = `<br>${computerScore}`;\n}", "title": "" }, { "docid": "f3419ded3b5ba8a11bc93784c54390aa", "score": "0.67963827", "text": "function whoWon () {\n if (playerScore > computerScore) {\n alert('You are the ultimate winner!');\n\n }else if (playerScore < computerScore){\n alert('You have ultimately lost!');\n \n }else {\n alert('Tie game!');\n }\n}", "title": "" }, { "docid": "2b204514ce87c30c631f6abe3c5a6430", "score": "0.67961824", "text": "updateScore(playerChoice, computerChoice) {\n const choices = this._choices();\n const choice = choices[playerChoice];\n\n playerChoice === computerChoice\n ? (resultText.textContent = \"It's a tie.\")\n : choice.defeats.indexOf(computerChoice) > -1\n ? this._displayWon()\n : this._displayLose();\n }", "title": "" }, { "docid": "66f9755cb5d5431d6597352a1f729ce1", "score": "0.6794414", "text": "function whosTheWinner(goals) {\n var team1Score = 0;\n var team2Score = 0;\n\n for (var i = 0; i < goals.length; i++) {\n if (goals[i] === 'Gryffindor') {\n team1Score++\n }else if (goals[i] === 'Slytherin') {\n team2Score++\n }\n }\n if (team1Score > team2Score) {\n return 'Gryffindor Juara Futsal Hogwarts 2018'\n }else if (team1Score < team2Score) {\n return 'Slytherin Juara Futsal Hogwarts 2018'\n }else if (team1Score === team2Score) {\n return 'Draw, pertandingan akan dilanjutkan dengan penalty kick!'\n }\n}", "title": "" }, { "docid": "31b86472782b6c9b56bad8f8b1265121", "score": "0.6793331", "text": "function winner()\n{\n if(playerScore > compScore)\n {\n console.log(\"Player Score: \" + playerScore);\n console.log(\"Computer Score: \" + compScore);\n console.log(\"You Win The Game!\");\n }\n else if(compScore > playerScore)\n {\n console.log(\"Player Score: \" + playerScore);\n console.log(\"Computer Score: \" + compScore);\n console.log(\"Computer Wins The Game!\");\n }\n else\n {\n console.log(\"Game Tied!\");\n }\n}", "title": "" }, { "docid": "23e321d0d3434013848a7a3eded4df70", "score": "0.67927194", "text": "function displayScore() {\n let scoreString = `\\nThe score is now:\\n\\n`;\n players.forEach((player) => {\n scoreString += `${player.name}: ${player.score}\\n`;\n });\n alert(scoreString);\n prompt(`Press Enter to move on to the next round or end the game `);\n console.clear();\n}", "title": "" }, { "docid": "f0fe1f54ad6561a91bc68385c5eaf407", "score": "0.67914456", "text": "function blackJack() {\n\n //win\n if (totalScore === randomNumber){\n alert(\"win ;)\");\n winCount++;\n $(\"#win-count\").text(winCount);\n console.log(\"wins\", winCount);\n newSearch();\n resetScore();\n }\n //lose\n else if (totalScore > randomNumber) {\n alert(\"lose :P\");\n lossCount++;\n $(\"#loss-count\").text(lossCount);\n console.log(\"losses\", lossCount);\n newSearch();\n resetScore();\n };\n }", "title": "" }, { "docid": "d36c1d732f3f1b40ad21e39bd8b9ea7a", "score": "0.6786498", "text": "function updateScore() {\r\n document.getElementById(\"tries\").innerText = tries;\r\n document.getElementById(\"matches\").innerText = matches;\r\n if (matches == 6) {\r\n document.getElementById(\"gameover\").style.visibility = \"visible\";\r\n }\r\n }", "title": "" }, { "docid": "5d36bd492f5566be093c56f46980dd92", "score": "0.678583", "text": "function getFinalScore(score, counter) { return \"Deine Punktzahl ist \" + score + \" von \" + counter + \", \"; }", "title": "" }, { "docid": "8090213c92356c28209ac7f55081e81c", "score": "0.67856497", "text": "function playerOneWin() {\n playerOne.result += 1;\n clearScore()\n}", "title": "" }, { "docid": "5d2ac716bc8268d0539c5f4106f33ec3", "score": "0.67818063", "text": "function win() {\n if (player.innerHTML === \"Player 1\") {\n // console.log(\"player 1 scores!\");\n player1pairs += 1;\n p1pairs.innerHTML = player1pairs;\n };\n if (player.innerHTML === \"Player 2\") {\n // console.log(\"player 1 scores!\");\n player2pairs += 1;\n p2pairs.innerHTML = player2pairs;\n };\n pairsFound += 1;\n if (pairsFound === (choosensize)/2) {\n // stopClock ()\n if (player1pairs > player2pairs) {\n move = player1score;\n moves.innerText = `${move}`;\n winnerSlogan.innerText = `Player 1 WINS by ${move} moves`;\n } else if (player1pairs === player2pairs) {\n move = player1score;\n moves.innerText = `${move}`;\n winnerSlogan.innerText = `You both WINNERS`;\n } else if (player1pairs < player2pairs) {\n move = player2score;\n moves.innerText = `${move}`;\n winnerSlogan.innerText = `Player 2 WINS by ${move} moves`;\n }\n\n winOverlay.classList.toggle('hide');\n let finalTime = document.querySelector('.finaltime');\n finalTime.innerText = `${seconds}`;\n let finalMoves = document.querySelector('.finalmoves');\n finalMoves.innerText = Number(`${player1score}`) + Number(`${player2score}`);\n calcHighscore();\n }\n }", "title": "" }, { "docid": "5d2ac716bc8268d0539c5f4106f33ec3", "score": "0.67818063", "text": "function win() {\n if (player.innerHTML === \"Player 1\") {\n // console.log(\"player 1 scores!\");\n player1pairs += 1;\n p1pairs.innerHTML = player1pairs;\n };\n if (player.innerHTML === \"Player 2\") {\n // console.log(\"player 1 scores!\");\n player2pairs += 1;\n p2pairs.innerHTML = player2pairs;\n };\n pairsFound += 1;\n if (pairsFound === (choosensize)/2) {\n // stopClock ()\n if (player1pairs > player2pairs) {\n move = player1score;\n moves.innerText = `${move}`;\n winnerSlogan.innerText = `Player 1 WINS by ${move} moves`;\n } else if (player1pairs === player2pairs) {\n move = player1score;\n moves.innerText = `${move}`;\n winnerSlogan.innerText = `You both WINNERS`;\n } else if (player1pairs < player2pairs) {\n move = player2score;\n moves.innerText = `${move}`;\n winnerSlogan.innerText = `Player 2 WINS by ${move} moves`;\n }\n\n winOverlay.classList.toggle('hide');\n let finalTime = document.querySelector('.finaltime');\n finalTime.innerText = `${seconds}`;\n let finalMoves = document.querySelector('.finalmoves');\n finalMoves.innerText = Number(`${player1score}`) + Number(`${player2score}`);\n calcHighscore();\n }\n }", "title": "" }, { "docid": "60cd2e8e710590af9f357091c38e54d7", "score": "0.6780608", "text": "function checkScore() {\n console.log(\"CheckScore\");\n if (playerTotal > computerTotal) {\n losses++;\n $(\"#losses\").text(\"You Lost! losses: \" + losses);\n \n initializeGame();\n }\n else if (playerTotal === computerTotal) {\n wins++;\n $(\"#wins\").text(\"You Won! Wins: \" + wins);\n initializeGame();\n }\n else{\n $(\"#wins\").text(\"Wins: \" + wins);\n $(\"#losses\").text(\"Losses: \" + losses);\n\n }\n\n }", "title": "" }, { "docid": "f7e3cf6d3f74f3faa55da6bf1f80c441", "score": "0.67777807", "text": "function setWinnerDetails(points) {\n var player = points[0] > points[1] ? 1 : 2 \n\n document.getElementById(\"winnerTitle\").innerHTML = \"Winner:\";\n document.getElementById(\"theWinnerIs\").innerHTML = \"Player \" + player;\n if (player == 1)\n document.getElementById(\"finalScore\").innerHTML = points[0] + \"/\" + points[1];\n else if (player == 2)\n document.getElementById(\"finalScore\").innerHTML = points[1] + \"/\" + points[0];\n}", "title": "" }, { "docid": "3cd388f1534e5ef02a0c4d8f2ea02f1d", "score": "0.67737186", "text": "function rockPaperScissors (playerSelection, computerSelection) {\n \n var resultOutput = document.getElementById(\"result\");\n playerSelection = this.innerHTML;\n computerSelection = computerPlay(); //runs computerPlay function and returns computers random choice\n\n playerSelectionClean = playerSelection.toLowerCase().slice(0,1); //Lowercase and slices first character\n computerSelectionClean = computerSelection.toLowerCase().slice(0,1); //Lowercase and slices first character\n WinnerWinnerChickenDinner = \"\"; //Winner of this round variable \n // console.log(playerSelection + \"*********\" + computerSelection); //output of choices (debugging)\n\n // checks each Player win scenario if all fail then default computer win scenario\n if (playerSelectionClean == computerSelectionClean) { //checks for a draw scenario\n WinnerWinnerChickenDinner = \"Draw! You both picked \" + playerSelection + \", Play again?\";\n playerScore += 1;\n playerScoreElement.innerHTML = playerScore;\n computerScore += 1;\n computerScoreElement.innerHTML = computerScore;\n } else if (playerSelectionClean == \"r\" && computerSelectionClean == \"s\") {\n WinnerWinnerChickenDinner = \"You win! \" + playerSelection + \" beats \" + computerSelection;\n playerScore += 1;\n playerScoreElement.innerHTML = playerScore;\n } else if (playerSelectionClean == \"s\" && computerSelectionClean == \"p\") {\n WinnerWinnerChickenDinner = \"You win! \" + playerSelection + \" beats \" + computerSelection;\n playerScore += 1;\n playerScoreElement.innerHTML = playerScore;\n } else if (playerSelectionClean == \"p\" && computerSelectionClean == \"r\") {\n WinnerWinnerChickenDinner = \"You win! \" + playerSelection + \" beats \" + computerSelection;\n playerScore += 1;\n playerScoreElement.innerHTML = playerScore;\n } else {\n WinnerWinnerChickenDinner = \"Computer wins! \" + computerSelection + \" beats \" + playerSelection;\n computerScore += 1;\n computerScoreElement.innerHTML = computerScore;\n }\n \n resultOutput.innerHTML = WinnerWinnerChickenDinner; //outputs result to the page.\n // console.log(WinnerWinnerChickenDinner); //returns outcome of round to console\n\n}", "title": "" }, { "docid": "6906011e34ff21e2a11116745dc887bf", "score": "0.67681307", "text": "function evaluateTotalScore (){\n // if the users totalScore is equal to the target number: \n if (totalScore === targetNumber){\n // increment the wins count by one.\n wins ++;\n // use jQuery to add the updated wins amount text to HTML.\n $(\"#wins\").text(wins);\n //call the reset function:\n reset();\n } else if (totalScore > targetNumber){\n // increment the losses count by one. \n losses ++;\n // use jQuery to add the updated losses amount text to HTML.\n $(\"#losses\").text(losses);\n //call the reset function:\n reset();\n }\n}", "title": "" }, { "docid": "490c5c060f8d63ebb62c022735c894eb", "score": "0.6764632", "text": "function renderWin() {\n mainMsg.innerText = \"You win!\"\n pScore ++\n pWins.innerText = `Player: ${pScore}`\n}", "title": "" }, { "docid": "cd3c8849f2e3f52fdde21355b11fb1b5", "score": "0.6764016", "text": "function win() {\n if (currentScore === targetScore) {\n wins++;\n $(\"#wins\").text(wins);\n if (confirm(\"You won. Would you like to play again?\")) {\n reset();\n };\n console.log(\"wins \" + wins);\n }\n else if (currentScore >= targetScore) {\n losses++;\n $(\"#losses\").text(losses);\n if (confirm(\"You lost. Would you like to play again?\")) {\n reset();\n }\n console.log(\"losses \" + losses);\n }\n }", "title": "" }, { "docid": "9d4534bc877dab0a77fc0f517526cc6e", "score": "0.6757035", "text": "function determineWinnings()\n {\n if(strikes == 3) {\n outs++;\n lossNumber++;\n createjs.Sound.play(\"strike3\");\n showLossMessage();\n }\n else if(popFlies == 3) {\n outs++;\n lossNumber++;\n createjs.Sound.play(\"out\");\n showLossMessage();\n }\n else if (singles == 3) {\n runs++;\n winnings = playerBet * 10;\n winNumber++;\n createjs.Sound.play(\"hit\");\n showWinMessage();\n }\n else if(doubles == 3) {\n runs = runs + 2;\n winnings = playerBet * 20;\n winNumber++;\n createjs.Sound.play(\"hit\");\n showWinMessage();\n }\n else if (triples == 3) {\n runs = runs + 3;\n winnings = playerBet * 30;\n winNumber++;\n createjs.Sound.play(\"hit\");\n showWinMessage();\n }\n else if (homeRuns == 3) {\n runs = runs + 4;\n winnings = playerBet * 100;\n winNumber++;\n createjs.Sound.play(\"cheer\");\n showWinMessage();\n }\n else if(groundRollDoubles == 3){\n runs = runs + 2;\n winnings = playerBet * 20;\n winNumber++;\n createjs.Sound.play(\"hit\");\n showWinMessage();\n }\n else if (homeRuns == 1) {\n runs++;\n winnings = playerBet * 10;\n winNumber++;\n createjs.Sound.play(\"cheer\");\n showWinMessage();\n }\n else if (homeRuns == 2) {\n runs = runs + 3;\n winnings = playerBet * 10;\n winNumber++;\n createjs.Sound.play(\"cheer\");\n showWinMessage();\n }\n else {\n lossNumber++;\n jackpot = jackpot + playerBet;\n showLossMessage();\n }\n }", "title": "" }, { "docid": "816b367645893e41b2de41f256022818", "score": "0.6756988", "text": "function results() {\n if (choice1 === \"Rock\" && choice2 === \"Scissors\") {\n return result = \"You Win\"\n } else if (choice1 === \"Paper\" && choice2 === \"Rock\") {\n return result = \"You Win\"\n } else if (choice1 === \"Scissors\" && choice2 === \"Paper\") {\n return result = \"You Win\"\n } else if (choice1 === \"Scissors\" && choice2 === \"Rock\") {\n return result = \"You Lose\"\n } else if (choice1 === \"Paper\" && choice2 === \"Scissors\") {\n return result = \"You Lose\"\n } else if (choice1 === \"Rock\" && choice2 === \"Paper\") {\n return result = \"You Lose\"\n } else if (choice1 === choice2) {\n return result = \"It's a Tie Play Again\"\n }\n}", "title": "" }, { "docid": "8e094ba6e319eac5162a8d80da04098f", "score": "0.6754752", "text": "function winCheck (last_result, score) {\n if ((last_result == \"win\") && (score == 3)) {\n alert(\"Congratulations! You win!\");\n return \"win\";\n }\n else if ((last_result == \"lose\") && (score == 3)) {\n alert(\"You lost!\");\n return \"lose\";\n }\n else {\n return 0;\n }\n}", "title": "" } ]
14b15de129a5dd6b15b0098d67320c90
Sets the virtual parent of an element. Pass `undefined` as the `parent` to clear the virtual parent.
[ { "docid": "770a2e3afef59b78cfbb1ea8aa25c5aa", "score": "0.67097014", "text": "function setVirtualParent(child, parent) {\n var virtualChild = child;\n var virtualParent = parent;\n if (!virtualChild._virtual) {\n virtualChild._virtual = {\n children: []\n };\n }\n var oldParent = virtualChild._virtual.parent;\n if (oldParent && oldParent !== parent) {\n // Remove the child from its old parent.\n var index = oldParent._virtual.children.indexOf(virtualChild);\n if (index > -1) {\n oldParent._virtual.children.splice(index, 1);\n }\n }\n virtualChild._virtual.parent = virtualParent || undefined;\n if (virtualParent) {\n if (!virtualParent._virtual) {\n virtualParent._virtual = {\n children: []\n };\n }\n virtualParent._virtual.children.push(virtualChild);\n }\n}", "title": "" } ]
[ { "docid": "502539adbc8e8fb4f368f69574a98369", "score": "0.6711975", "text": "function setVirtualParent(child, parent) {\n var virtualChild = child;\n var virtualParent = parent;\n if (!virtualChild._virtual) {\n virtualChild._virtual = {\n children: [],\n };\n }\n var oldParent = virtualChild._virtual.parent;\n if (oldParent && oldParent !== parent) {\n // Remove the child from its old parent.\n var index = oldParent._virtual.children.indexOf(virtualChild);\n if (index > -1) {\n oldParent._virtual.children.splice(index, 1);\n }\n }\n virtualChild._virtual.parent = virtualParent || undefined;\n if (virtualParent) {\n if (!virtualParent._virtual) {\n virtualParent._virtual = {\n children: [],\n };\n }\n virtualParent._virtual.children.push(virtualChild);\n }\n}", "title": "" }, { "docid": "502539adbc8e8fb4f368f69574a98369", "score": "0.6711975", "text": "function setVirtualParent(child, parent) {\n var virtualChild = child;\n var virtualParent = parent;\n if (!virtualChild._virtual) {\n virtualChild._virtual = {\n children: [],\n };\n }\n var oldParent = virtualChild._virtual.parent;\n if (oldParent && oldParent !== parent) {\n // Remove the child from its old parent.\n var index = oldParent._virtual.children.indexOf(virtualChild);\n if (index > -1) {\n oldParent._virtual.children.splice(index, 1);\n }\n }\n virtualChild._virtual.parent = virtualParent || undefined;\n if (virtualParent) {\n if (!virtualParent._virtual) {\n virtualParent._virtual = {\n children: [],\n };\n }\n virtualParent._virtual.children.push(virtualChild);\n }\n}", "title": "" }, { "docid": "4ae5e4d1c71b10e659f88e50c030cbd0", "score": "0.66450095", "text": "function setVirtualParent(child, parent) {\r\n var virtualChild = child;\r\n var virtualParent = parent;\r\n if (!virtualChild._virtual) {\r\n virtualChild._virtual = {\r\n children: []\r\n };\r\n }\r\n var oldParent = virtualChild._virtual.parent;\r\n if (oldParent && oldParent !== parent) {\r\n // Remove the child from its old parent.\r\n var index = oldParent._virtual.children.indexOf(virtualChild);\r\n if (index > -1) {\r\n oldParent._virtual.children.splice(index, 1);\r\n }\r\n }\r\n virtualChild._virtual.parent = virtualParent || undefined;\r\n if (virtualParent) {\r\n if (!virtualParent._virtual) {\r\n virtualParent._virtual = {\r\n children: []\r\n };\r\n }\r\n virtualParent._virtual.children.push(virtualChild);\r\n }\r\n}", "title": "" }, { "docid": "cb649cf0b460561eb67ca0e1fb813750", "score": "0.6618537", "text": "set parent(value) {}", "title": "" }, { "docid": "61f167b5f5738cbb9159b2d7deece4c1", "score": "0.65490246", "text": "setParentOf(node, parent) {\n node.setParent(parent);\n }", "title": "" }, { "docid": "f13d3ebb2805b13a8274b0af2179445e", "score": "0.6541005", "text": "SetParent() {}", "title": "" }, { "docid": "7a2597442fbf68cc3afb1bc5caf75d87", "score": "0.6532112", "text": "function setParent(parent) {\n this.parent = parent;\n}", "title": "" }, { "docid": "cdddbf51f51d0bcc7f16a8ea26bb32bb", "score": "0.647739", "text": "setParent(parent) {\n this._parent = parent;\n }", "title": "" }, { "docid": "613a421fb250c6f668f98c2e3f03ebb8", "score": "0.6469112", "text": "setParent(parent) {\n this.parent = parent;\n }", "title": "" }, { "docid": "613a421fb250c6f668f98c2e3f03ebb8", "score": "0.6469112", "text": "setParent(parent) {\n this.parent = parent;\n }", "title": "" }, { "docid": "613a421fb250c6f668f98c2e3f03ebb8", "score": "0.6469112", "text": "setParent(parent) {\n this.parent = parent;\n }", "title": "" }, { "docid": "530e5b9536f91e43cea440e603a1ec41", "score": "0.6423161", "text": "setParent(parent) {\n this.parent = parent;\n }", "title": "" }, { "docid": "8c57af1394451d348293a419fa77c71e", "score": "0.622858", "text": "function setParent(el, newParent)\n {\n newParent.appendChild(el);\n }", "title": "" }, { "docid": "a77656147e6b5f3ce1b59f84a407987d", "score": "0.617888", "text": "setParent(parent) {\n\t\t\t// Remove the object from the parent node.\n\t\t\tif (parentNode && nodeObject) {\n\t\t\t\tconst childIndex = parentNode.children.indexOf(nodeObject);\n\t\t\t\tif (childIndex >= 0) {\n\t\t\t\t\tparentNode.children.splice(childIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add the object to the new parent node.\n\t\t\tif (parent && nodeObject) {\n\t\t\t\tparent.children.push(nodeObject);\n\t\t\t}\n\n\t\t\tparentNode = parent;\n\t\t}", "title": "" }, { "docid": "5e27e26d515814ab9097206bab3500fe", "score": "0.5979813", "text": "function setParentId(el, id) {\n el.setAttribute(consts.FOCUS_PARENT_ID, id);\n }", "title": "" }, { "docid": "a32ba68c62250e5a034e7ea97c4b0edb", "score": "0.597529", "text": "function _resyncParent() {\n if (this.parentPath) {\n this.parent = this.parentPath.node;\n }\n}", "title": "" }, { "docid": "3ddb1a05f7a89a6d0a9eff82f7913eb3", "score": "0.59696007", "text": "_setParent(parent) {\n throw new Error('Unsupported operation');\n }", "title": "" }, { "docid": "3d78d7502f9f0960aaac353aca6173e1", "score": "0.5878168", "text": "function getVirtualParent(child) {\r\n var parent;\r\n if (child && isVirtualElement(child)) {\r\n parent = child._virtual.parent;\r\n }\r\n return parent;\r\n}", "title": "" }, { "docid": "47b495bd5c269e19ac8bb1a649e3123a", "score": "0.58468586", "text": "function getVirtualParent(child) {\n var parent;\n if (child && isVirtualElement(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}", "title": "" }, { "docid": "da231715cf7b8a3c2523b6b3fff94a36", "score": "0.5785271", "text": "clearParent() {\n logger_1.default.system.debug(\"FinsembleWindow.clearParent\", this.parentWindow);\n this.eventManager.trigger(\"parent-unset\", {\n parentName: this.parentWindow.name\n });\n this.parentWindow = null;\n }", "title": "" }, { "docid": "0a8598aecb1fd09a46aa35ee9abf4d13", "score": "0.57587445", "text": "normalizeToParent(element) {\n return element.isChild() ? element.parent() : element;\n }", "title": "" }, { "docid": "329b510482c9d3779e829a4eac831535", "score": "0.5737897", "text": "setParent(parent) {\n if(parent instanceof Tree) {\n this._root_node.parent = parent;\n this._sessionId = parent._sessionId; // automatically sets the sessionId\n // equal to parent\n } else {\n throw new TypeError(\"Tree.setParent takes a Tree instance as a parameter!\");\n }\n }", "title": "" }, { "docid": "e3f328bf452525182803ae8e78cace80", "score": "0.5724269", "text": "normalizeToParent(element) {\n return element.isChild() ? element.parent() : element\n }", "title": "" }, { "docid": "80774aa1248dbee490875840cdb054e2", "score": "0.5706689", "text": "setParent(node) {\n this.state.parent = node;\n }", "title": "" }, { "docid": "267b95664ebf086717ca64a5f7dca76a", "score": "0.56790066", "text": "clearParent() {\n logger_1.default.system.debug(\"BaseWindow.clearParent\");\n this.parentWindow = null;\n this.emit(\"clearParent\", this.parentWindow);\n }", "title": "" }, { "docid": "ac1da0460c0f7590a0e57ea098a8e0ec", "score": "0.5654242", "text": "setParent(parentNode) {\n\t\tif (parentNode instanceof FlowchartNode) {\n\n\t\t\t// set parent reference\n\t\t\tthis.parent = parentNode;\n\n\t\t\t// update parent's child reference to this\n\t\t\tif (!parentNode.children.includes(this)) {\n\t\t\t\tparentNode.addChild(this);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthrow new TypeError(\"parentNode must be instance of class FlowchartNode\");\n\t\t}\n\t}", "title": "" }, { "docid": "c93906b76a00899870c54be3dd524998", "score": "0.5540424", "text": "get parent() {\n\t\tvar parent = this.parentNode;\n\t\treturn (parent instanceof Document ? undefined : parent);\n\t}", "title": "" }, { "docid": "ffd4afd9898b205310a853e553b2ae2c", "score": "0.5538753", "text": "_setParentId (id) {\n this._parentId = id\n }", "title": "" }, { "docid": "a0587ad09a494793de0afc961199d023", "score": "0.552724", "text": "set parent(parent) {\n if (!isLayer(parent)) {\n this.handleError('Invalid parent layer', parent)\n }\n parent.addChild(this)\n }", "title": "" }, { "docid": "e21c98c4d58507d27292dbceec089906", "score": "0.5523332", "text": "function getVirtualParent(child) {\n var parent;\n if (child && Object(_isVirtualElement__WEBPACK_IMPORTED_MODULE_0__[\"isVirtualElement\"])(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}", "title": "" }, { "docid": "e21c98c4d58507d27292dbceec089906", "score": "0.5523332", "text": "function getVirtualParent(child) {\n var parent;\n if (child && Object(_isVirtualElement__WEBPACK_IMPORTED_MODULE_0__[\"isVirtualElement\"])(child)) {\n parent = child._virtual.parent;\n }\n return parent;\n}", "title": "" }, { "docid": "98663656456b726bfc1d34d8edb2e08a", "score": "0.5501273", "text": "function setFocalParent(noodel, newFocalParent) {\r\n noodel.focalParent.isFocalParent = false;\r\n hideActiveSubtree(noodel.root);\r\n newFocalParent.isFocalParent = true;\r\n noodel.focalParent = newFocalParent;\r\n noodel.focalLevel = newFocalParent.level;\r\n showActiveSubtree(noodel.root, newFocalParent.level - 1 + noodel.options.visibleSubtreeDepth);\r\n}", "title": "" }, { "docid": "4ac81129db90ba29ba8fb8747ae86859", "score": "0.5483972", "text": "function referenceParentNode () {\n // If nodeName is an empty string, then reference the parent of the root child.\n if (isEmptyString(nodeName)) {\n nodeName = this.$parentName;\n\n // Even though super might be invoked in different constructors,\n // the same instance will always be referenced. rootName is used\n // to know if the chain has been broken.\n rootName = this.$name;\n\n // Prevent instance from having parent properties applied more than once.\n if (this.$applied) {\n throwError(`Cannot invoke super more than once for ${this.$name} instance.`, 'SUPER');\n } else {\n descriptor.value = true;\n\n Object.defineProperty(this, '$applied', descriptor);\n }\n\n // Otherwise just move to next parent.\n } else {\n // Error out if chain is broken.\n if (this.$name !== rootName) {\n throwError(`Chain started by ${rootName} instance is being broken by ${this.$name} instance.`, 'SUPER');\n }\n\n nodeName = CLASS[nodeName].prototype.$parentName;\n }\n }", "title": "" }, { "docid": "f87413783b9537ced4d673e99b48a2ce", "score": "0.5475503", "text": "up() {\n if (this.parent) {\n return this.parent;\n }\n return this;\n }", "title": "" }, { "docid": "73a69aa26d982e5b38162d15307b999d", "score": "0.5466013", "text": "function _set_device_parent(dparent)\n{\n\tdevice_parent = dparent;\n\tsurface.call('receive_device', 'set_mod_device_parent', 'id', device_parent);\n}", "title": "" }, { "docid": "a8857b5a3b30aa1899902c3572f75770", "score": "0.54278296", "text": "setParent(p, logPos)\n\t{\n\t\tif (this._parent != null)\n\t\t\tthis._parent.removeChild(this)\n\t\tthis._parent = p;\n\t\tthis.adjustPosition(logPos);\n\t}", "title": "" }, { "docid": "4cd1def984a775cd93ba8b7ddcc2fea6", "score": "0.54224867", "text": "up() {\n if (this.isRoot) {\n throw new Error(\"The root node has no parent. Use doc() if you need to get the document object.\");\n }\n return this.parent;\n }", "title": "" }, { "docid": "2c371b2a59a5b7f4fbb3e7e48fe35572", "score": "0.54175186", "text": "function deleteParent(element) {\n\n\tvar parent = element.parentNode;\n\tvar grandparent = parent.parentNode;\n\tgrandparent.removeChild(parent);\n\n}", "title": "" }, { "docid": "1280edbf79fe2df4385d81da4ed5b64f", "score": "0.5410191", "text": "function getParent$1(elem) {\n\t return elem.parent || null;\n\t}", "title": "" }, { "docid": "430b32e2b101e4b334efef5492b39232", "score": "0.54085237", "text": "function parentElement(el) {\n return el.parentElement || el.parentNode;\n }", "title": "" }, { "docid": "426a8da15820ec3d47ba2102a206e282", "score": "0.53828084", "text": "function getParent$1(elem) {\n return elem.parent || null;\n}", "title": "" }, { "docid": "e3e6ca199e3713f0e805bb2d3afcec1e", "score": "0.5373873", "text": "get parent() {\n return childToParent.get(this) || null;\n }", "title": "" }, { "docid": "ae6e1a6e31e21dcbb5475140bc447036", "score": "0.53692394", "text": "function getParent(elem) {\n return elem.parent || null;\n}", "title": "" }, { "docid": "7e154933e3afc6e4945c491c3806e9c6", "score": "0.53649116", "text": "function setChild(parent, node) {\n\n var c, newNode, currentDocument = parent._ownerDocument || parent;\n\n switch (node.type)\n {\n case 'tag':\n case 'script':\n case 'style':\n try {\n newNode = currentDocument.createElement(node.name);\n if (node.location) {\n newNode.sourceLocation = node.location;\n newNode.sourceLocation.file = parent.sourceLocation.file;\n }\n } catch (err) {\n currentDocument.trigger('error', 'invalid markup', {\n exception: err,\n node : node\n });\n\n return null;\n }\n break;\n\n case 'text':\n newNode = currentDocument.createTextNode(HTMLDecode(node.data));\n break;\n\n case 'comment':\n newNode = currentDocument.createComment(node.data);\n break;\n\n default:\n return null;\n break;\n }\n\n if (!newNode)\n return null;\n\n if (node.attribs) {\n for (c in node.attribs) {\n // catchin errors here helps with improperly escaped attributes\n // but properly fixing parent should (can only?) be done in the htmlparser itself\n try {\n newNode.setAttribute(c.toLowerCase(), HTMLDecode(node.attribs[c]));\n } catch(e2) { /* noop */ }\n }\n }\n\n if (node.children) {\n for (c = 0; c < node.children.length; c++) {\n setChild(newNode, node.children[c]);\n }\n }\n\n return parent.appendChild(newNode);\n }", "title": "" }, { "docid": "78b705960b5bdc2ad5ed0d9028336d7b", "score": "0.5349851", "text": "function getParent(elem) {\n return elem.parent || null;\n}", "title": "" }, { "docid": "78b705960b5bdc2ad5ed0d9028336d7b", "score": "0.5349851", "text": "function getParent(elem) {\n return elem.parent || null;\n}", "title": "" }, { "docid": "35f69f797e187d44ae9aee8e1705f975", "score": "0.53431547", "text": "get parentNode() {\n return this.parent;\n }", "title": "" }, { "docid": "5a499304cfb04a84b1d01768680c1e1e", "score": "0.5326776", "text": "reparent(node, newParent) { return node.reparent(newParent); }", "title": "" }, { "docid": "a901162a95a2d91d4e6797ef3db12154", "score": "0.53223413", "text": "__setParents() {\n let parents = Akili.getAkiliParents(this.el);\n\n if (!parents.length) {\n return;\n }\n\n let newParent = this.__parent !== parents[0];\n let evaluationParent = null;\n\n for (let i = 0, l = parents.length; i < l; i++) {\n let parent = parents[i];\n\n if (!parent.__akili.constructor.transparent) {\n evaluationParent = parent;\n break;\n }\n }\n\n this.__compiling.newParent = newParent;\n newParent && this.__detach();\n\n if (this.constructor.transparent) {\n this.__evaluationComponent = evaluationParent.__akili;\n }\n\n this.__evaluationParent = evaluationParent;\n this.__parent = parents[0];\n this.__parents = parents;\n this.scope.__parent = this.__evaluationParent.__akili.scope;\n !this.__recompiling && this.__parent.__akili.__addChild(this.el);\n Object.setPrototypeOf(this.scope, this.__parent.__akili.__scope);\n }", "title": "" }, { "docid": "7eaf6f608c679ec6f87d8b81406fde1b", "score": "0.5313879", "text": "get parent() {\n return this._parent;\n }", "title": "" }, { "docid": "7eaf6f608c679ec6f87d8b81406fde1b", "score": "0.5313879", "text": "get parent() {\n return this._parent;\n }", "title": "" }, { "docid": "b31ec656c0962065b6f56dab5dcf297c", "score": "0.53056633", "text": "moveTo (parentSelector = DEFAULT_DOM_PARENT_SELECTOR) {\n if (this.el)\n document.querySelector(parentSelector).appendChild(this.el)\n return this\n }", "title": "" }, { "docid": "6735fed92527b67c9771ffbf1d53cd19", "score": "0.53005135", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n\n if (parentView) {\n return view.parentNodeDef.parent;\n } else {\n return null;\n }\n }", "title": "" }, { "docid": "c69b264ba891f9bf920bf42624db119c", "score": "0.52962273", "text": "function opSetParentId(id, xml) {\r\n return xml.replace(/\\$\\$PARENT_ID\\$\\$/g, id);\r\n}", "title": "" }, { "docid": "5a08992a0b1170adc1a4b3304757d554", "score": "0.5274242", "text": "function find_parent (el) {\n // if it's not node\n if (el.parents) {\n return find_child(vm.node, el.parents, 0)\n }\n return\n }", "title": "" }, { "docid": "9839fedf94cb374fa536e886d45398f5", "score": "0.5259438", "text": "get parent() {}", "title": "" }, { "docid": "132f99d2863e6daaeafb0a831e6893c7", "score": "0.5251479", "text": "function setAsRoot() {\n //console.log('Set ' + $scope.selectedDepartment.name + ' as root');\n $scope.newParentId = -1;\n }", "title": "" }, { "docid": "c1961bdeae61f3a0002a6352fa559d28", "score": "0.52307016", "text": "_markParentWithSelectedChild() {\n let element = this.parentElement;\n while (element instanceof SideMenuItem) {\n element.setAttribute('hasSelectedChild', true);\n element = element.parentElement;\n }\n }", "title": "" }, { "docid": "cdd3958e34d4127afdfd2cec3279c5dc", "score": "0.52284545", "text": "function attachElementToParent(element, parentElement) {\n var previousRenderNode = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];\n\n if (previousRenderNode) {\n var previousSibling = previousRenderNode.element;\n var previousSiblingPenultimate = penultimateParentOf(previousSibling, parentElement);\n parentElement.insertBefore(element, previousSiblingPenultimate.nextSibling);\n } else {\n parentElement.insertBefore(element, parentElement.firstChild);\n }\n }", "title": "" }, { "docid": "792af56dc6c2dcddefe481b1a7a01d29", "score": "0.521984", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n }", "title": "" }, { "docid": "792af56dc6c2dcddefe481b1a7a01d29", "score": "0.521984", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n }", "title": "" }, { "docid": "e1f272dd692a41a11a7cfcf588a4eb62", "score": "0.5191836", "text": "function setParentNode(node) {\n if (!node.children) return;\n for (var child of node.children) {\n child.parent_node = node;\n setParentNode(child);\n }\n}", "title": "" }, { "docid": "3653012f790a0c18e6799821c26f95ca", "score": "0.5188531", "text": "static SetTransformParent() {}", "title": "" }, { "docid": "0e55b2703bad900aac915a5baa038d58", "score": "0.51826227", "text": "SetChild(obj, prop, value){\n\t\tif (obj[prop])\n\t\t\tobj[prop] = null;\n\n\t\tobj[prop] = value;\n\n\t\tif( obj[prop] )\n\t\t\tobj[prop].parent = this;\n\t}", "title": "" }, { "docid": "045665d3af59b5776519e67946e08a63", "score": "0.51766306", "text": "destroy() {\n this.parent = null;\n }", "title": "" }, { "docid": "f54ddbcbc5ceb28de2f6a49ae898dfac", "score": "0.51756096", "text": "function updateParentComponentVNodes(vNode, dom) {\n\t if (vNode.flags & 28 /* Component */) {\n\t var parentVNode = vNode.parentVNode;\n\t if (parentVNode) {\n\t parentVNode.dom = dom;\n\t updateParentComponentVNodes(parentVNode, dom);\n\t }\n\t }\n\t}", "title": "" }, { "docid": "7691289c06d07caf753f3160709f53a5", "score": "0.5158106", "text": "set defaultChild(value) {\n this._defaultChild = value;\n }", "title": "" }, { "docid": "b19c5ecb6076920404e6fa0f3c2b45b3", "score": "0.51510066", "text": "function updateParentComponentVNodes(vNode, dom) {\n if (vNode.flags & 28 /* Component */) {\n var parentVNode = vNode.parentVNode;\n if (parentVNode) {\n parentVNode.dom = dom;\n updateParentComponentVNodes(parentVNode, dom);\n }\n }\n}", "title": "" }, { "docid": "e0046aa34da055e71b192c56843f9e28", "score": "0.5150124", "text": "function updateParentComponentVNodes(vNode, dom) {\r\n if (vNode.flags & 28 /* Component */) {\r\n var parentVNode = vNode.parentVNode;\r\n if (parentVNode) {\r\n parentVNode.dom = dom;\r\n updateParentComponentVNodes(parentVNode, dom);\r\n }\r\n }\r\n}", "title": "" }, { "docid": "fe4e119126cc4d9bea56d6180ac91f0d", "score": "0.51181126", "text": "function updateParentComponentVNodes(vNode, dom) {\n if (vNode.flags & 28 /* Component */) {\n var parentVNode = vNode.parentVNode;\n if (parentVNode) {\n parentVNode.dom = dom;\n updateParentComponentVNodes(parentVNode, dom);\n }\n }\n }", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "95b591cfdd281a99e42aa6436469556c", "score": "0.5111953", "text": "function viewParentEl(view) {\n var parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "c54a63ff04e4ccd485534f1e0fc443e4", "score": "0.51087683", "text": "function _scrollParentToElement(parent, element) {\n parent.scrollTop = element.offsetTop - parent.offsetTop;\n }", "title": "" }, { "docid": "7452d2b1af4d23e46f6b4a3c783b4f2d", "score": "0.5095077", "text": "function setParentId( parent, node, startId ) {\n\tnode.parent = parent ;\n\tif( typeof setParentId.id === 'undefined' ) {\n\t\tsetParentId.id = startId ;\n\t}\n\tif( typeof node.id === 'undefined' ) {\n\t\tnode.id = setParentId.id ;\n\t\tsetParentId.id ++ ;\n\t}\n\tif( typeof node.children !== 'undefined' ) {\n\t\tnode.children.map( child => setParentId( node, child ) ) ;\n\t}\n\treturn setParentId.id\n}", "title": "" }, { "docid": "76ee02543587c8bbd3310707d925e071", "score": "0.5083388", "text": "goToParent() {\n const parent = this.getParent();\n\n if (!parent) {\n console.error('This comment has no parent.');\n return;\n }\n\n parent.scrollTo({ pushState: true });\n parent.configureLayers();\n\n if (!parent.goToChildButton) {\n parent.addGoToChildButton();\n }\n parent.goToChildButton.setAction(() => {\n this.scrollTo({ pushState: true });\n });\n }", "title": "" }, { "docid": "0d4d24015c0a6fc918985ca3426b8426", "score": "0.5078886", "text": "function setAnalysisParent(graph) {\n\t graph.aNodes.forEach(function (an) {\n\t an.parent = graph;\n\t });\n\t}", "title": "" }, { "docid": "6e16eaec2e3526baab048df93f10c988", "score": "0.5066518", "text": "function domReferenceParent(parent){\n var node = document.getElementById(parent);\n return node;\n}", "title": "" }, { "docid": "6e16eaec2e3526baab048df93f10c988", "score": "0.5066518", "text": "function domReferenceParent(parent){\n var node = document.getElementById(parent);\n return node;\n}", "title": "" }, { "docid": "6fb25d464be3750413059b0877e55fdb", "score": "0.5039248", "text": "function parent() {\n if (elements.length > 0) {\n return a(elements[0].parentNode);\n }\n return this;\n }", "title": "" }, { "docid": "35d80709545b95802e5b015f0d246310", "score": "0.5032388", "text": "parent(selector) {\n let parents = m$();\n this.each((_, elem) => {\n if (!hasParent(elem)) {\n return;\n }\n elem = elem.parentElement;\n if (!matches(elem, selector)) {\n return;\n }\n parents.push(elem);\n });\n return setContext(parents, this);\n }", "title": "" }, { "docid": "aa639c686c74839af21855bc2758f5a9", "score": "0.50318915", "text": "getParent() {\r\n return this.parent;\r\n }", "title": "" }, { "docid": "d3d14db7e4b4bddea7bfbea3f050f2f6", "score": "0.5013417", "text": "set setParentHeight(newHeight) {\r\n this._parentHeight = newHeight;\r\n }", "title": "" }, { "docid": "1360261b14db129b4afe9b8dc026c2e8", "score": "0.50091034", "text": "clear() {\n this.parent.html( '' );\n }", "title": "" }, { "docid": "7692d208e437f98d94d0e2cfb2e1f9da", "score": "0.5005825", "text": "function viewParentEl(view) {\n const parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "7692d208e437f98d94d0e2cfb2e1f9da", "score": "0.5005825", "text": "function viewParentEl(view) {\n const parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "7692d208e437f98d94d0e2cfb2e1f9da", "score": "0.5005825", "text": "function viewParentEl(view) {\n const parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "7692d208e437f98d94d0e2cfb2e1f9da", "score": "0.5005825", "text": "function viewParentEl(view) {\n const parentView = view.parent;\n if (parentView) {\n return view.parentNodeDef.parent;\n }\n else {\n return null;\n }\n}", "title": "" }, { "docid": "dd190f37dcfc472f496a200e4cd968a2", "score": "0.50026035", "text": "onChangeMainParent(newParent, oldParent) { }", "title": "" }, { "docid": "b8f06f8c4cef2dc88ac6f2bbad585048", "score": "0.5000457", "text": "function addParent(obj, parent) {\n\t var isNode = obj && typeof obj.type === 'string';\n\t var childParent = isNode ? obj : parent;\n\n\t for (var k in obj) {\n\t var value = obj[k];\n\t if (Array.isArray(value)) {\n\t value.forEach(function(v) { addParent(v, childParent); });\n\t } else if (value && typeof value === 'object') {\n\t addParent(value, childParent);\n\t }\n\t }\n\n\t if (isNode) {\n\t Object.defineProperty(obj, 'parent', {\n\t configurable: true,\n\t writable: true,\n\t enumerable: false,\n\t value: parent || null\n\t });\n\t }\n\n\t return obj;\n\t}", "title": "" }, { "docid": "ebafb216e7ff2c8778d323d520428d60", "score": "0.4994404", "text": "function showParentBlock(elementID)\r\n{\r\n element = parent.document.getElementById(elementID);\r\n element.parentNode.removeChild(element);\r\n}", "title": "" } ]
c2d230331ccc243982e51a875e4ea887
! vuex v3.5.1 (c) 2020 Evan You
[ { "docid": "5611e6d3af75cbd5e3de4af411d1b51a", "score": "0.0", "text": "function r(t){var e=Number(t.version.split(\".\")[0]);if(e>=2)t.mixin({beforeCreate:r});else{var n=t.prototype._init;t.prototype._init=function(t){void 0===t&&(t={}),t.init=t.init?[r].concat(t.init):r,n.call(this,t)}}function r(){var t=this.$options;t.store?this.$store=\"function\"===typeof t.store?t.store():t.store:t.parent&&t.parent.$store&&(this.$store=t.parent.$store)}}", "title": "" } ]
[ { "docid": "509aac8f04f01c0b31a45682f9f07cc4", "score": "0.6672163", "text": "onInspectState(index){var snapshot=this.replayMutations(index);this.bridge.send('vuex:inspected-state',{index,snapshot});}", "title": "" }, { "docid": "e5ae43d0a0b29a389cc41a3a47381813", "score": "0.6460375", "text": "resetSnapshotsVm(state){this.snapshotsVm=new vue__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({data:{$$state:state||{}},computed:this.store._vm.$options.computed});}", "title": "" }, { "docid": "c4014b309ea84ef813eeabbc2368b3ed", "score": "0.6388049", "text": "onTravelToState(_ref7){var{index,apply}=_ref7;var snapshot=this.replayMutations(index);var state=Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(this.lastState);this.bridge.send('vuex:inspected-state',{index,snapshot});if(apply){this.ensureRegisteredModules(this.mutations[index]);this.hook.emit('vuex:travel-to-state',state);}}", "title": "" }, { "docid": "47d56e35335c96c660075e8b695cbf72", "score": "0.6348341", "text": "function vuexInit() {\n\t var options = this.$options;\n\t var store = options.store;\n\t var vuex = options.vuex;\n\t // store injection\n\n\t if (store) {\n\t this.$store = store;\n\t } else if (options.parent && options.parent.$store) {\n\t this.$store = options.parent.$store;\n\t }\n\t // vuex option handling\n\t if (vuex) {\n\t if (!this.$store) {\n\t console.warn('[vuex] store not injected. make sure to ' + 'provide the store option in your root component.');\n\t }\n\t var state = vuex.state;\n\t var actions = vuex.actions;\n\t var getters = vuex.getters;\n\t // handle deprecated state option\n\n\t if (state && !getters) {\n\t console.warn('[vuex] vuex.state option will been deprecated in 1.0. ' + 'Use vuex.getters instead.');\n\t getters = state;\n\t }\n\t // getters\n\t if (getters) {\n\t options.computed = options.computed || {};\n\t for (var key in getters) {\n\t defineVuexGetter(this, key, getters[key]);\n\t }\n\t }\n\t // actions\n\t if (actions) {\n\t options.methods = options.methods || {};\n\t for (var _key in actions) {\n\t options.methods[_key] = makeBoundAction(this.$store, actions[_key], _key);\n\t }\n\t }\n\t }\n\t }", "title": "" }, { "docid": "2d8e9292b8cce170e762b55ff37478cd", "score": "0.634499", "text": "function vuexInit() {\n\t var options = this.$options;\n\t var store = options.store;\n\t var vuex = options.vuex;\n\t // store injection\n\n\t if (store) {\n\t this.$store = store;\n\t } else if (options.parent && options.parent.$store) {\n\t this.$store = options.parent.$store;\n\t }\n\t // vuex option handling\n\t if (vuex) {\n\t if (!this.$store) {\n\t console.warn('[vuex] store not injected. make sure to ' + 'provide the store option in your root component.');\n\t }\n\t var state = vuex.state;\n\t var getters = vuex.getters;\n\t var actions = vuex.actions;\n\t // handle deprecated state option\n\n\t if (state && !getters) {\n\t console.warn('[vuex] vuex.state option will been deprecated in 1.0. ' + 'Use vuex.getters instead.');\n\t getters = state;\n\t }\n\t // getters\n\t if (getters) {\n\t options.computed = options.computed || {};\n\t for (var key in getters) {\n\t defineVuexGetter(this, key, getters[key]);\n\t }\n\t }\n\t // actions\n\t if (actions) {\n\t options.methods = options.methods || {};\n\t for (var _key in actions) {\n\t options.methods[_key] = makeBoundAction(this.$store, actions[_key], _key);\n\t }\n\t }\n\t }\n\t }", "title": "" }, { "docid": "415ea3ff80591d74cbbe0cd3123206f2", "score": "0.63280123", "text": "function vuexInit() {\n\t var options = this.$options;\n\t var store = options.store;\n\t var vuex = options.vuex;\n\t // store injection\n\t\n\t if (store) {\n\t this.$store = store;\n\t } else if (options.parent && options.parent.$store) {\n\t this.$store = options.parent.$store;\n\t }\n\t // vuex option handling\n\t if (vuex) {\n\t if (!this.$store) {\n\t console.warn('[vuex] store not injected. make sure to ' + 'provide the store option in your root component.');\n\t }\n\t var state = vuex.state;\n\t var actions = vuex.actions;\n\t var getters = vuex.getters;\n\t // handle deprecated state option\n\t\n\t if (state && !getters) {\n\t console.warn('[vuex] vuex.state option will been deprecated in 1.0. ' + 'Use vuex.getters instead.');\n\t getters = state;\n\t }\n\t // getters\n\t if (getters) {\n\t options.computed = options.computed || {};\n\t for (var key in getters) {\n\t defineVuexGetter(this, key, getters[key]);\n\t }\n\t }\n\t // actions\n\t if (actions) {\n\t options.methods = options.methods || {};\n\t for (var _key in actions) {\n\t options.methods[_key] = makeBoundAction(this.$store, actions[_key], _key);\n\t }\n\t }\n\t }\n\t }", "title": "" }, { "docid": "8db6cfaf8616caa22080bafdd4350bb3", "score": "0.6310902", "text": "replayMutations(index){var _this=this;if(!_utils_shared_data__WEBPACK_IMPORTED_MODULE_1__[\"default\"].vuexNewBackend){var snapshot=index===-1?this.legacyBaseSnapshot:this.mutations[index].snapshot;this.lastState=Object(_utils_util__WEBPACK_IMPORTED_MODULE_0__[\"parse\"])(snapshot,true).state;return snapshot;}var originalVm=this.store._vm;var originalState=Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(this.store.state);this.store._vm=this.snapshotsVm;var tempRemovedModules=[];var tempAddedModules=[];// If base state, we need to remove all dynamic registered modules\n// to prevent errors because their state is missing\nif(index===-1){tempRemovedModules=Object.keys(this.registeredModules);tempRemovedModules.filter(m=>this.hasModule(m.split('/'))).sort((a,b)=>b.length-a.length).forEach(m=>{this.origUnregisterModule(m.split('/'));if(!isProd)console.log('before replay unregister',m);});}// Get most recent snapshot for target index\n// for faster replay\nvar stateSnapshot;for(var i=0;i<this.stateSnapshotCache.length;i++){var s=this.stateSnapshotCache[i];if(s.index>index){break;}else{stateSnapshot=s;}}var resultState;// Snapshot was already replayed\nif(stateSnapshot.index===index){resultState=stateSnapshot.state;var state=Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(stateSnapshot.state);this.resetSnapshotsVm(state);this.store.replaceState(state);}else{// Update state when using fake vm to properly temporarily remove modules\nthis.resetSnapshotsVm(originalState);this.store.replaceState(originalState);// Temporarily remove modules if they where not present during first mutation being replayed\nvar startMutation=this.mutations[stateSnapshot.index];if(startMutation){tempRemovedModules=Object.keys(this.registeredModules).filter(m=>!startMutation.registeredModules.includes(m));}else{tempRemovedModules=Object.keys(this.registeredModules);}tempRemovedModules.filter(m=>this.hasModule(m.split('/'))).sort((a,b)=>b.length-a.length).forEach(m=>{this.origUnregisterModule(m.split('/'));if(!isProd)console.log('before replay unregister',m);});var _state=Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(stateSnapshot.state);this.resetSnapshotsVm(_state);this.store.replaceState(_state);_utils_shared_data__WEBPACK_IMPORTED_MODULE_1__[\"default\"].snapshotLoading=true;// Replay mutations\nfor(var _i=stateSnapshot.index+1;_i<=index;_i++){var mutation=this.mutations[_i];if(mutation.registerModule){var key=mutation.payload.path.join('/');var moduleInfo=this.allTimeModules[key];tempAddedModules.push(key);this.origRegisterModule(moduleInfo.path,_objectSpread({},moduleInfo.module,{state:Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(moduleInfo.state)}),moduleInfo.options);this.resetSnapshotsVm(this.store.state);if(!isProd)console.log('replay register module',moduleInfo);}else if(mutation.unregisterModule&&this.hasModule(mutation.payload.path)){var path=mutation.payload.path;var _index=tempAddedModules.indexOf(path.join('/'));if(_index!==-1)tempAddedModules.splice(_index,1);this.origUnregisterModule(path);this.resetSnapshotsVm(this.store.state);if(!isProd)console.log('replay unregister module',path);}else if(mutation.handlers){this.store._committing=true;try{(function(){var payload=mutation.payload;if(_this.isLegacy&&!Array.isArray(payload)){payload=[payload];}if(Array.isArray(mutation.handlers)){if(_this.isLegacy){mutation.handlers.forEach(handler=>handler(_this.store.state,...payload));}else{mutation.handlers.forEach(handler=>handler(payload));}}else{if(_this.isLegacy){mutation.handlers(_this.store.state,...payload);}else{mutation.handlers(payload);}}})();}catch(e){throw e;}this.store._committing=false;}// Optimization: periodically cache snapshots\nif(_i===index||_i%_utils_shared_data__WEBPACK_IMPORTED_MODULE_1__[\"default\"].cacheVuexSnapshotsEvery===0){this.cacheStateSnapshot(_i);}}// Send final state after replay\nresultState=Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(this.store.state);if(!isProd)console.log(\"replayed \".concat(index-stateSnapshot.index,\" mutation(s)\"));}this.lastState=resultState;var result=this.stringifyStore();// Restore user state\ntempAddedModules.sort((a,b)=>b.length-a.length).forEach(m=>{this.origUnregisterModule(m.split('/'));if(!isProd)console.log('after replay unregister',m);});tempRemovedModules.sort((a,b)=>a.length-b.length).forEach(m=>{var{path,module,options,state}=this.registeredModules[m];this.origRegisterModule(path,_objectSpread({},module,{state:Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(state)}),options);if(!isProd)console.log('after replay register',m);});this.store._vm=originalVm;return result;}", "title": "" }, { "docid": "2c86677735c72b9bbf4276b326fc3dac", "score": "0.63101315", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "d6b9507e66d66e2138da85f3ce1483ff", "score": "0.62606806", "text": "function vuexInit () {\n\t var options = this.$options;\n\t // store injection\n\t if (options.store) {\n\t this.$store = options.store;\n\t } else if (options.parent && options.parent.$store) {\n\t this.$store = options.parent.$store;\n\t }\n\t }", "title": "" }, { "docid": "d6b9507e66d66e2138da85f3ce1483ff", "score": "0.62606806", "text": "function vuexInit () {\n\t var options = this.$options;\n\t // store injection\n\t if (options.store) {\n\t this.$store = options.store;\n\t } else if (options.parent && options.parent.$store) {\n\t this.$store = options.parent.$store;\n\t }\n\t }", "title": "" }, { "docid": "fe607fa191bd840c70c7b5862d53a074", "score": "0.6250442", "text": "function vuexInit () {\n\t var options = this.$options\n\t // store injection\n\t if (options.store) {\n\t this.$store = options.store\n\t } else if (options.parent && options.parent.$store) {\n\t this.$store = options.parent.$store\n\t }\n\t }", "title": "" }, { "docid": "fcf7ec990d9d3ae4e9fcfbb922a718bc", "score": "0.62166744", "text": "addMutation(type,payload){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var index=this.mutations.length;if(!_utils_shared_data__WEBPACK_IMPORTED_MODULE_1__[\"default\"].vuexNewBackend){options.snapshot=this.stringifyStore();}this.mutations.push(_objectSpread({type,payload:_utils_shared_data__WEBPACK_IMPORTED_MODULE_1__[\"default\"].vuexNewBackend?Object(_clone__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(payload):null,index,handlers:this.store._mutations[type],registeredModules:Object.keys(this.registeredModules)},options));this.bridge.send('vuex:mutation',{mutation:{type:type,payload:Object(_utils_util__WEBPACK_IMPORTED_MODULE_0__[\"stringify\"])(payload),index},timestamp:Date.now(),options});}", "title": "" }, { "docid": "7aaf8411d98fe46e6a17f7bb73d12573", "score": "0.61531943", "text": "onMutation(_ref6){var{type,payload}=_ref6;if(!_utils_shared_data__WEBPACK_IMPORTED_MODULE_1__[\"default\"].recordVuex)return;this.addMutation(type,payload);}", "title": "" }, { "docid": "ee23fc69b92a6e4d2023a2c788a7c0b0", "score": "0.608202", "text": "onImportState(state){var parsed=Object(_utils_util__WEBPACK_IMPORTED_MODULE_0__[\"parse\"])(state,true);this.initialState=parsed;this.hook.emit('vuex:travel-to-state',parsed);this.reset();this.bridge.send('vuex:init');this.onInspectState(-1);}", "title": "" }, { "docid": "706579d5535c563d37e244937154a1df", "score": "0.6079359", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "fbe846cb8f280d3c5e1137943ef83726", "score": "0.6071786", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "fbe846cb8f280d3c5e1137943ef83726", "score": "0.6071786", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "fbe846cb8f280d3c5e1137943ef83726", "score": "0.6071786", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "fbe846cb8f280d3c5e1137943ef83726", "score": "0.6071786", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "c1e262fef05c5187db3d6e4aded1fe3b", "score": "0.6064388", "text": "function vuexInit() {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "1104f7cb69a89ad8d92e1604c9f1f471", "score": "0.6012248", "text": "function vuexInit() {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function' ?\n options.store() :\n options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "740c1f8684fbd7886aa1b0bce1e82ef2", "score": "0.5995962", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "e33a7681d6aa8e808b612d6b426699e5", "score": "0.59798473", "text": "function vuexInit() {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function' ?\n options.store() :\n options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "e33a7681d6aa8e808b612d6b426699e5", "score": "0.59798473", "text": "function vuexInit() {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function' ?\n options.store() :\n options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "76ca5457e7581360f585b5a1c816f12a", "score": "0.5978215", "text": "allproducts(){\n return this.$store.state.products;\n }", "title": "" }, { "docid": "42982d79171a20cbf6788070af2a9ff5", "score": "0.59767616", "text": "function vuexInit() {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function' ? options.store() : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" }, { "docid": "28cb21b76a5ddec468afef2ab3b068a7", "score": "0.5952627", "text": "function vuexInit () {\n var options = this.$options;\n // store injection\n if (options.store) {\n this.$store = typeof options.store === 'function'\n ? options.store()\n : options.store;\n } else if (options.parent && options.parent.$store) {\n this.$store = options.parent.$store;\n }\n }", "title": "" } ]
eda18f3b0598acb7ad771b1de3384f0d
get product from API
[ { "docid": "a340ad626de66c2d3d3545e7b842c61c", "score": "0.0", "text": "listProduct({ commit }) {\n Vue.axios\n .get(\"http://localhost:3000/product/get\")\n .then(result => {\n commit(\"SAVE_PRODUCT\", result.data);\n })\n .catch(error => {\n throw new Error(`API ${error}`);\n });\n }", "title": "" } ]
[ { "docid": "9158658ec161e7518f0b8d63dcb513ed", "score": "0.76969063", "text": "function getProduct(productId) {\n return fetch(`http://localhost:3000/api/cameras/${productId}`)\n .then(function(res) {\n return res.json()\n })\n .catch(function(error) {\n alert(error)\n });\n}", "title": "" }, { "docid": "f827b55f4ed9b35dea2a816b29c6c227", "score": "0.7578266", "text": "async getProduct() {\n let product = this.ctx.request.body;\n\n this.ctx.body = await this.service.products.query(product);\n }", "title": "" }, { "docid": "bd3ef9609db4e4fc15885c338428b42a", "score": "0.7498209", "text": "function retrieveProduct(req, res, next) {\n const { id } = req.params;\n getProduct(id)\n .then(result => res.json(result))\n .catch(error => next(error));\n}", "title": "" }, { "docid": "2749e1cf63a52eedc0b0dfa0e65e4303", "score": "0.7495223", "text": "getProductByQR(Prod_Id){\n return axios.get(`${PRODUCT_API}/${Prod_Id}`);\n }", "title": "" }, { "docid": "83c14d63438d33d7cc9ae364834fcccb", "score": "0.7494439", "text": "function getProductById(req, res) {\n const product_id = req.query.product_id\n productService\n .getProductById(product_id)\n .then(result => {\n res.json(result)\n })\n .catch(err => {\n res.json(err)\n })\n}", "title": "" }, { "docid": "01940e4990014c8ccaa580d10728f599", "score": "0.74887145", "text": "function getProduct(productId) {\n\treturn (\n\t\tfetch(`https://oricamera.herokuapp.com/api/cameras/${productId}`)\n\t\t\t.then(function (resProducts) {\n\t\t\t\treturn resProducts.json();\n\t\t\t})\n\t\t\t//On retourne le resultat\n\t\t\t.then(function (dataProducts) {\n\t\t\t\tif (dataProducts._id) {\n\t\t\t\t\treturn dataProducts;\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.href = \"index.html\";\n\t\t\t\t}\n\t\t\t})\n\t);\n}", "title": "" }, { "docid": "c623297dc1c1813bdbd27e561bc5d4de", "score": "0.7438927", "text": "function getProductById(productId) {\n return wxp._requestPromise(URL._marketUrl, {\n \"Action\": \"GetProductById\",\n \"ProductId\": productId\n })\n .then((res) => {\n console.log(res);\n return res[\"ErrorCode\"] == NO_ERROR ?\n new Product(res[\"Product\"]) : null;\n });\n}", "title": "" }, { "docid": "23d7e244eb738f71bf8fe0cc46764518", "score": "0.7313469", "text": "async getProductById() {\n try {\n const { params } = this.req;\n if (params.id === undefined) {\n throw Error('missing parameters');\n }\n\n const id = params.id;\n const product = await this.productService.getById(id);\n if (!product) {\n throw Error('product not found');\n }\n\n this.res.status(200).json(response.data(this.req, product));\n } catch (err) {\n this.res.status(err.status || 500).json(response.error({\n message: translate(this.req, err.message || 'unknown'),\n }));\n }\n }", "title": "" }, { "docid": "8c327341348e0b649bfdbd76a83c6559", "score": "0.7253456", "text": "getAllProducts() {\n return axios.get(`${PRODUCT_API}`)\n }", "title": "" }, { "docid": "3792605f41e44fd18ba30a8980a4c794", "score": "0.72493774", "text": "function getProduct(id) {\n return HttpRequest({\n url: `/api/products/product`,\n method: `POST`,\n data: id\n });\n}", "title": "" }, { "docid": "566e027a553efac1af34a4da9cbaa6f8", "score": "0.7236907", "text": "getProduct(active,productId) {\n\n return axios.get(API_URL + 'detail/?active=' + active + '&productId=' + productId, {\n\n });\n\n }", "title": "" }, { "docid": "63ec16938e59fa2b992dac15d59045aa", "score": "0.71924746", "text": "async fetchProducts(/*url*/) {\n // ES7 - Async/Await and FetchAPI requesting data from Storage (API) - we are requesting Products\n const response = await fetch(\"https://api.jsonbin.io/b/5ee155541f9e4e57881b3c25\", {\n method: \"GET\",\n credentials: \"same-origin\", // include, *same-origin, omit\n headers: {\n \"Content-Type\": \"application/json\",\n \"secret-key\": \"$2b$10$ZieyyWLLe6rL9eXtFgI/6.cte.VSFvd6grMohe5MtAIgmahwc3TDC\" // Secret key is required\n }\n });\n\n return response.json();\n }", "title": "" }, { "docid": "2affd24ad80416ef57b1e1c09df4e42f", "score": "0.7175855", "text": "function getProductbyid(id) {\n return fetch(`http://localhost:3000/api/teddies/${id}`)\n .then(response => response.json())\n .then(function (product) {\n return product\n })\n}", "title": "" }, { "docid": "5fb07f65830ca62b0008deef242a7450", "score": "0.7165375", "text": "function getProductDetail(req, res){\n var id = req.params.id;\n moltin.Product.Get(id, function(product) {\n res.status(200).json(product);\n }, function(error, response, c) {\n res.status(400).json(error);\n });\n }", "title": "" }, { "docid": "50a92fbeb514004e6de737cee219a43b", "score": "0.7164876", "text": "function getProduct(req, res) {\n const product = req.produce\n return res.status(200).json(product)\n}", "title": "" }, { "docid": "bda5848e3c27490f7cb8084af78e3df8", "score": "0.71622324", "text": "function getProduct(req, res) {\n product.findById(req.params.id, (err, product) => {\n if(err) res.send(err);\n res.json(product);\n });\n}", "title": "" }, { "docid": "1e99ec74da2fa7efb220655869b2d22e", "score": "0.7133852", "text": "static async getProductWithCategory(category_id, per) {\n let response = await fetch(`http://fshop.ustk.in.ua/products/1.json?category_id=${category_id}&per=${per}`, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n }\n });\n\n return response = await response.json();\n }", "title": "" }, { "docid": "58de6e2a3709857f9a90cff4f93725d3", "score": "0.71264005", "text": "getProduct() {\r\n return instanceSheets\r\n .get(\r\n \"feeds/list/1NVHcPwl7wVG1E87jVy0w-Q6HL7OcUfq3E674tEj7vw0/od6/public/values?alt=json\"\r\n )\r\n .then((response) => response.data);\r\n }", "title": "" }, { "docid": "3ea7b27eb1c55f2f8d5369b87ae39636", "score": "0.7091964", "text": "getProductDetailsById(productId) {\n var url = `/product?id=${productId}`;\n return Method.dataGet(url, token);\n }", "title": "" }, { "docid": "a11a13d1f8d9a4916bceca48a806ab30", "score": "0.7091428", "text": "function getProductById(product_id) {\n return products[product_id]\n}", "title": "" }, { "docid": "ad53f32fd95b6dad9bfb915b1ce9de4b", "score": "0.70911074", "text": "function getProduct(req, res) {\n Product.findById(req.params.productId, (err, product) => {\n if(err) res.send(err);\n //If no errors, send it back to the product\n res.json(product);\n });\n}", "title": "" }, { "docid": "cccbf618ee1496ba232f282d6233b0c1", "score": "0.7064348", "text": "function getProductData(productId) {\n return fetch(`http://localhost:3000/api/teddies/${productId}`)\n .then((httpBodyResponse) => httpBodyResponse.json())\n .then((productData) => productData);\n}", "title": "" }, { "docid": "5f525853dec7c7fb6a02a84ee495d2e3", "score": "0.70393133", "text": "async function getProduct(productId) {\n\tconst promise = makeRequest('GET', apiUrl+'/'+productId);\n\tconst response = await promise;\n\n\tconst itemImg = document.querySelector('.item-img-lg');\n\titemImg.src = response.imageUrl;\n\n\tconst itemName = document.querySelector('h2');\n\titemName.textContent = response.name;\n\n\tconst itemPrice = document.querySelector('h4');\n\titemPrice.innerHTML = currencySymbol+response.price;\n\n\tconst itemCode = document.querySelector('.item-code');\n\titemCode.textContent = productId;\n\n\tconst itemDescription = document.querySelector('.item-desc');\n\titemDescription.innerHTML = response.description;\n\n\tconst itemSelect = document.querySelector('.item-select');\n\tconst colors = response.colors;\n\tfor (let i = 0; i < colors.length; i++) {\n\t\tlet colorOption = document.createElement('option');\n\t\tcolorOption.value = colors[i];\n\t\tcolorOption.textContent = colors[i];\n\t\titemSelect.appendChild(colorOption);\n\t}\n\n\tconst productDiv = document.querySelector('.product-container');\n\tproductDiv.style.visibility = 'visible';\n}", "title": "" }, { "docid": "50c7d046cdc63cf9461022d49f9cb55f", "score": "0.70261794", "text": "async fetchProduct(_,{ id }) {\n const products = await Product.find(id)\n return products.toJSON()\n }", "title": "" }, { "docid": "ec964f3aaaf4a8376643ce76f9e2fdc5", "score": "0.69999623", "text": "async function FetchProduct(id) {\n var nosql = new Agent()\n //console.log(\"id\", id)\n nosql.select('getProduct', 'product').make(function (builder) {\n builder.where('id', id)\n builder.first()\n })\n try {\n var product = await nosql.promise('getProduct')\n return { product: product, err: null }\n } catch (err) {\n return { product: null, err: err }\n }\n}", "title": "" }, { "docid": "8d78e3bbd81e595d45a94b7cc95f70d5", "score": "0.69781417", "text": "async function getProduct(id) {\n // Simulate network delay\n // await delay(350);\n\n var product = null;\n\n // Search for product\n var products = api_data_products.getProducts();\n for (var prod of products) {\n if (prod.id == id) {\n product = prod;\n\n // Calculate rating from reviews\n var reviews = await getProductReviews(prod.id);\n\n // Atleast 1 review\n if (reviews.length >= 1) {\n var sum = 0;\n for (var review of reviews) {\n sum += review.rating;\n }\n\n // Calculate average and attach to payload\n product.rating = (sum / reviews.length);\n } else {\n // No reviews\n product.rating = 0;\n }\n\n // Return\n return product;\n }\n }\n // No product found\n return null;\n}", "title": "" }, { "docid": "d354ab0ff5104ca702d4b65e89591038", "score": "0.6943697", "text": "async function getProduct(id) {\n let res = await ApiGetService(\"getSingleProduct\", id);\n console.log(res);\n setProduct(res);\n setImages(res.varients[0].images);\n setVarient(res.varients);\n\n let tmp = Object.keys(res.type);\n console.log(tmp);\n if (tmp.length === 0 || tmp[0] === \"null\") {\n if (res.varients.length === 0) {\n setVarient(res); //current varient to be checked\n }\n setCurrentVarient(res.varients[0]);\n return;\n }\n tmp = tmp[0];\n let value = res.type[tmp].length > 0 ? res.type[tmp][0] : \"\";\n setCurrentType({ key: tmp, value: value });\n for (let i = 0; i < res.varients.length; i++) {\n if (\n res.varients[i][\"varientType\"][0].value === tmp &&\n (res.typeKey.length === 1 ||\n res.varients[i][\"varientType\"][1].value === res.type[tmp][0])\n ) {\n setCurrentVarient(res.varients[i]); //images to be set here\n }\n }\n }", "title": "" }, { "docid": "82d12d55d99e4d399449c549e5f5217d", "score": "0.69098717", "text": "function getProductData(product) {\n $.get({\n url: `api/search?term=${product}`,\n success: function (data) {\n item.html(data[0].productName);\n itemSub.html(\"in <strong>\" + data[0].productCategory +\"</strong\");\n why.html (data[0].productWhy)\n amazonBtn.attr(\"href\", data[0].productLink);\n image.attr(\"src\", data[0].productPhoto[0].url)\n console.log(data);\n //console.log(data[0].productLink)\n //getCategoryName(data[0].productCategory[0])\n }\n });\n }", "title": "" }, { "docid": "f2957bc2718c426c3da2d0da7bb1a75f", "score": "0.6908585", "text": "static async fetchDetailedProduct(productCode) {\n let productUrl = `https://www.willys.se/axfood/rest/p/${productCode}?avoidCache=${getRandomNumber()}`;\n let rawProduct = await fetch(productUrl);\n let product;\n try {\n product = await rawProduct.json();\n } catch {\n product = null;\n }\n this.detailedProduct = product;\n return this.detailedProduct;\n }", "title": "" }, { "docid": "82d983bf20b9a871fba0d1141f9a625f", "score": "0.6907706", "text": "function getProduct(req, res){\n let productId = req.params.productId\n\n Product.findById(productId, (err, product) => {\n if(err) return res.status(500).send({ message: 'Error al realizar la peticion'+err})\n if(!product) return res.status(404).send({ message: 'El producto no se encontro: '+prodcut})\n\n res.status(200).send({ product: 'El producto es -> '+product })\n })\n}", "title": "" }, { "docid": "f5a97f6f1200bd259c99134ea606d3b4", "score": "0.6907104", "text": "function getProducts(accessToken) {\n $.ajax({\n url: \"https://api.uber.com/v1/products?latitude=\" + startLatitude + \"&longitude=\" + startLongitude,\n headers: {\n Authorization: \"Bearer \" + accessToken\n },\n \n success: function (result) {\n console.log(JSON.stringify(result));\n\n // 'results' is an object with a key containing an Array\n var data = result[\"products\"];\n if (typeof data != typeof undefined) {\n //Get the first product and display product name in the button\n var firstProduct = data[0];\n $(\"#time\").html(\"Ride: \" + firstProduct.display_name);\n $('input[type=hidden]').val(firstProduct.product_id);\n }\n else {\n console.log(\"Error: data is not defined\");\n }\n \n },\n error: function (error) {\n //Log error\n console.log(\"ERROR: \", error);\n }\n });\n\n}", "title": "" }, { "docid": "f0efa0e34ba8e648f71d9f0882d1e3d0", "score": "0.69068456", "text": "getProducts() {\n return axios.get('https://coordenadas-pa.herokuapp.com/productos').then(res => res.data);\n }", "title": "" }, { "docid": "f039739f3c81801ae68c5d23950faad0", "score": "0.6905723", "text": "single (id) {\n return this.execute('get', '/product/single/' + id, {});\n }", "title": "" }, { "docid": "f3f9e87bf496030102487f731034bd5e", "score": "0.69045573", "text": "fetchSingleProduct(id) {\n let query = `query {\n products(prodId: \"${id}\") {\n id\n cartId\n name\n image_url\n description\n }\n }`;\n\n return this.get(query);\n }", "title": "" }, { "docid": "176f16edadd2060c0a5204411f895fd0", "score": "0.6889674", "text": "function getProduct() {\n let queryParams = window.location.search.substr(1).split(\"&\");\n let paramIdIndex = queryParams.findIndex(value => value.split(\"=\")[0] == \"id\");\n let id = queryParams[paramIdIndex].split(\"=\")[1];\n\n fetch(`${urlApi}/${id}`)\n .then(function(res) {\n if (res.ok) {\n return res.json();\n }\n })\n .then(function(value) {\n \n currentProduct = value\n document.getElementById(\"main_Item\")\n .innerHTML = `<div >\n <div class='card' style='width: 18rem;'>\n <img src='${value.imageUrl}' class=\"card-img-top\" alt=\"Camera Vintage\">\n <div class=\"card-body\">\n <h2 class=\"card-title\">${value.name}</h2>\n <p class=\"card-text\">${value.description}</p>\n <p class=\"card-price\">${formatPrice(value.price)} EUR</p>\n <form>\n <label for=\"lenses\">Choisir l'objectif :</label>\n <select name=\"lenses\" id=\"lenses\">\n \n </select>\n \n <button type=\"button\" class=\"add-to-panier\" data-price=\"${(value.price / 100).toFixed(2)}\" data-name=\"${value.name}\" data-id=\"${value._id}\">Ajouter au panier</button>\n </form>\n <a href=\"../index.html\" class=\"retour flex items-center \">\n Retour\n </a>\n </div>\n </div>\n </div>`;\n \n document.querySelector(\"button.add-to-panier\").addEventListener(\"click\", addToBasket);\n indicatorNbOfItemInBasket();\n addLenses(value);\n\n });\n}", "title": "" }, { "docid": "9b9a8c6e46205f5bfbe242182778caf5", "score": "0.6864151", "text": "getProduct(url) {\n this.clearContent();\n\n this.productRepository.getByUrl(url, (response) => {\n let product = response.result;\n\n this.fillProduct(product);\n\n this.addLinkEvents();\n });\n }", "title": "" }, { "docid": "dd1375158cadc947276c02bc9c5f2add", "score": "0.6847465", "text": "getProductData() {\n axios.get(`/service-1.0-SNAPSHOT/products/find?id=${parseInt(this.state.productId)}`).then(response => {\n this.setState({product: response.data})\n })\n }", "title": "" }, { "docid": "c29c712c51c1b0a03408c49d46d62f48", "score": "0.68403393", "text": "function extGET (req) {\n // reset final response var\n finalResponse = {};\n\n let productInfo = {};\n\n productID = req.params.product_id;\n finalResponse.id = parseInt(req.params.product_id);\n\n // URL with product ID\n url = baseUrl + productID + endUrl;\n\n var exGetProm = fetch(url)\n .then(function(response) {\n return response.json();\n })\n .then (function(productJson) {\n\n productInfo = productJson;\n\n // if the req ID does not return data from redsky API, setup json error response\n // else, parse the response for product name\n if (productInfo.product.item.product_description == undefined) {\n\n finalResponse.status = 'error';\n finalResponse.message = 'There is no product description for this product id'\n \n getFinalJson();\n } else { \n parseProductInfo (productInfo);\n }\n return productID\n\n })\n .catch(error => console.error('Error', error));\n\n return exGetProm;\n}", "title": "" }, { "docid": "003653f03bee0df973fcf8d2f9d5536a", "score": "0.68246096", "text": "getCartProducts (opp) {\n \n fetch(\"http://localhost:3001/api/products/from-opp/\"+opp.Id, {\n method: 'GET'\n })\n .then((response) => {\n response.json()\n .then((result) => {\n this.productList = result;\n })\n })\n .catch((err) => {\n console.log(err);\n alert('Something went wrong.');\n });\n\n return { order: opp };\n }", "title": "" }, { "docid": "82f044e8345ef2f13ba28a756504e805", "score": "0.6817863", "text": "function get_product(product_id, product_options) {\n request(product_options, (error, response, product) => {\n if (!error && response.statusCode == 200) {\n var product_styles = JSON.parse(product)[\"styles\"];\n \n check_restock(product_styles, product_id);\n }\n });\n}", "title": "" }, { "docid": "50de559aefd030df24b532ff4fb0dd2a", "score": "0.6811775", "text": "async function getAllProducts(){\r\n // console.log(\"calling getAllproducts\");\r\n let request = {\r\n method: 'GET',\r\n headers: {'Content-Type': 'application/json',\r\n 'x-access-token': token},\r\n redirect: 'follow'\r\n }\r\n \r\n const serverReturn = await fetch(ENDPOINT_URL + '/products',request)\r\n const serverResponse = await serverReturn.json()\r\n products = serverResponse;\r\n }", "title": "" }, { "docid": "f6d6be94869a26ce0466560bc260e3d5", "score": "0.6788", "text": "static async getById(req, res, next) {\n try {\n const product = await Services.Product.getProductById(req.params.id);\n\n const [status, body] = response.success(product);\n res.status(status).send(body);\n } catch (e) {\n const [status, body] = response.errors(e);\n res.status(status).send(body);\n }\n return next();\n }", "title": "" }, { "docid": "f5b832ae4724bec2d59ea750c583c3fb", "score": "0.6786598", "text": "async function displayProduct() {\n const urlSearchId = (new URL(window.location).searchParams);\n productId = urlSearchId.get(\"id\")\n try {\n let url = \"http://localhost:3000/api/cameras/\" + productId;\n let response = await fetch(url);\n if (response.ok) {\n let cameraProduct = await response.json();\n createProductCard(cameraProduct);\n } else {\n console.error('server return: ', response.status)\n }\n } catch (e) {\n console.log(e);\n }\n}", "title": "" }, { "docid": "f1c6cd4804711ddea7845858dd3f3aaf", "score": "0.67632097", "text": "async function getProductById(req, res) {\n try {\n if (!req.params.id) {\n throw \"Missing product id\";\n }\n\n let product = await productModel.getOneByID(req.params.id);\n res.json(product);\n } catch (e) {\n console.log(e);\n res.status(403).end();\n }\n}", "title": "" }, { "docid": "c0bdb23137dc34ceabc6a3ae4649a73b", "score": "0.67530566", "text": "getAllProducts() {\n //fetch data from rest api\n return this.http.get(this.dotNetRestUrl); // from rest api\n }", "title": "" }, { "docid": "a0dc76a636f699b08bdd8a45d0e2e9ff", "score": "0.67321783", "text": "async function getProductById(req, res) {\n const product = await Products.findById(req.params.id);\n\n if (!product)\n return res.status(404).send(`No Product found for ID ${req.params.id}`);\n res.send(product);\n}", "title": "" }, { "docid": "4669b9327d801799e480832eebed5fa0", "score": "0.67227894", "text": "function getProductId(index) {\n return axios.get(`${PRODUCT_API_ENDPOINT}/getProducts`)\n .then((resp) => resp.data.data[index])\n .catch(err => {\n logger.error(\"Unable to get Products from Database\", err)\n return err \n })\n}", "title": "" }, { "docid": "bd1a7546b1f932bc4f69187a2a59869d", "score": "0.6722187", "text": "async function getProduct (req, res, next) {\n try {\n const product = await Product.findById(req.params.id);\n if (product == null) {\n return res.status(404).json({ message: \"Cant find product\" });\n }\n res.product = product;\n next();\n } catch (err) {\n return res.status(500).json({ message: err.message });\n }\n}", "title": "" }, { "docid": "7288e9dc834ec552b57d7b4b091344ad", "score": "0.67220235", "text": "async function getSingleOfferProduct(req, res, next) {\n try {\n const id = req.params.id;\n const offerProduct = await SpecialOffer.findOne({ _id: id });\n res.status(200).json(offerProduct);\n } catch (err) {\n res.status(500).json({\n error: \"Internal Server Error!\",\n });\n }\n}", "title": "" }, { "docid": "92e7cd24b2a729d6f2dd57775b2f802d", "score": "0.6715437", "text": "function getCatalog() {\n return HttpRequest({\n url: `/api/products/allproducts`,\n method: `GET`,\n });\n}", "title": "" }, { "docid": "c56a247a7cc3ad598bbe40d5388403be", "score": "0.6714374", "text": "function fetchProductParameters() {\n const parametersPath = \"Products/GetParameters\"\n const parametersUrl = domain + parametersPath + format;\n\n const parametersParams = {\n Country: 'UA',\n Language: 'uk',\n SymbolList: ['DIGI-ME'],\n Token: token\n }\n\n const parametersSortedParams = sortKeys(parametersParams, { deep: true })\n const parametersQueryParams = httpBuildQuery(parametersSortedParams)\n\n const parametersSignatureRequest = 'POST&' + encodeURIComponent(parametersUrl) + \"&\" + encodeURIComponent(parametersQueryParams)\n const parametersSignature = crypto.createHmac('sha1', secret).update(parametersSignatureRequest, 'utf8').digest('base64')\n\n parametersParams['ApiSignature'] = parametersSignature\n\n const parametersAxiosSettings = {\n url: parametersUrl,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n data: parametersParams\n }\n\n axios.request(parametersAxiosSettings)\n .then((res) => { \n apiData.push(res.data)\n })\n .catch((error) => {\n console.error(error)\n })\n}", "title": "" }, { "docid": "7cda72c6bea470b0da222b078feaa132", "score": "0.67093265", "text": "async function getProduct(req, res, next) {\n let product;\n try {\n product = await Product.findById(req.params.productId);\n if (product == null) {\n return res.status(404).json({ message: \"Product not found\" });\n }\n } catch (err) {\n return res.status(500).json({ message: err.message });\n }\n res.product = product;\n next();\n}", "title": "" }, { "docid": "0bb5c78d0a3d81bae95109de807e0a32", "score": "0.6708395", "text": "function getProducts(id) {\n return new Promise(function(resolve, reject) {\n var xhr = new XMLHttpRequest();\n xhr.open('POST', 'http://localhost:3000/api/products');\n xhr.setRequestHeader('Content-Type', 'application/json');\n xhr.onload = function() {\n if (xhr.status === 200) {\n resolve(JSON.parse(xhr.responseText));\n }\n };\n xhr.send(JSON.stringify({\n videoID: id\n }));\n xhr.onerror = reject;\n });\n}", "title": "" }, { "docid": "90db70a4c7d840f0e3744bcb27458dcb", "score": "0.6700484", "text": "getProduct(id) {\n return this.storage.products.find(product => product.id === id);\n }", "title": "" }, { "docid": "dd442bdd587f86d56c64665a22bc8c8b", "score": "0.6698469", "text": "async function getProductVariant() {\n var self = this\n var nosql = new Agent()\n var opt = self.query\n nosql.select('getVariant', 'product').make(function (builder) {\n builder.where('id', opt.id)\n builder.first()\n })\n var getVariant = await nosql.promise('getVariant')\n var variants = getVariant.variant\n if (getVariant != null) {\n if (variants.length > 0) {\n self.json({\n status: true,\n data: variants\n })\n } else {\n self.json({\n status: false,\n message: 'Variants not yet added for this product'\n })\n }\n } else {\n self.json({\n status: false,\n message: 'Product not found'\n })\n }\n}", "title": "" }, { "docid": "69d0f3c7c197894a6a3f41f36c67a110", "score": "0.66940105", "text": "function getProductByPid(){\n $.ajax({\n type: 'GET',\n url: rootURL + '/products/3',\n dataType: \"json\",\n success: function(data, textStatus, jqXHR){\n console.log(data);\n },\n error: function(jqXHR, textStatus, errorThrown){\n console.log(textStatus);\n }\n });\n}", "title": "" }, { "docid": "8209c8653f32f4782bd8e02838c1e57e", "score": "0.66901654", "text": "async function getProduct(req, res){\n const url = 'https://api.danmurphys.com.au/apis/ui/Search/products';\n\n let searchParams = {\n Filters: [],\n PageSize: 20,\n PageNumber: 1,\n SortType: 'Relevance',\n Location: 'ListerFacet'\n }\n\n searchParams.SearchTerm = req.query.search;\n const search = JSON.stringify(searchParams);\n\n const store = req.query.store;\n const cookie = `w-aqwerhpi=adm-p,i-${store},p-${store},pk-${store},is-dCrSYXpuE58=;`;\n\n const data = await postData(url, search, cookie);\n res.send(data.data);\n}", "title": "" }, { "docid": "610224080b09146261fb974b88a4061d", "score": "0.66842115", "text": "function productInfo (){ \n\treturn $.ajax ({\n\t\turl:'https://json-data.herokuapp.com/darts/info'\n\t});\n}", "title": "" }, { "docid": "0abc8186938ff457a48602f0221f1a46", "score": "0.667984", "text": "function getSingleProduct(request, respond){\n \n productDB.getSingleProduct(request.params.productId, function(error, result){\n if(error){\n respond.json(error);\n }\n else{\n respond.json(result);\n }\n });\n}", "title": "" }, { "docid": "48a018c67d83dc7c86945a412b1d5ba5", "score": "0.6671978", "text": "async show({ request, response }) {\n const id = request.params.id;\n let redisKey = `Product_${id}`;\n let cached = await RedisHelper.get(redisKey);\n if (cached) {\n return response.status(200).send(cached);\n }\n const data = await Product.find(id);\n if (!data) {\n return response.status(400).send(ResponseParser.apiNotFound());\n }\n let parsed = ResponseParser.apiItem(data.toJSON());\n await RedisHelper.set(redisKey, parsed);\n return response.status(200).send(parsed);\n }", "title": "" }, { "docid": "250d6f5272688226bdba2acad4423e3f", "score": "0.6660842", "text": "async function getProductById(id) {\n try {\n const { rows: [product] } = await client.query(`\n SELECT *\n FROM products\n WHERE id=$1\n `, [id])\n\n return product\n } catch (error) {\n \n }\n}", "title": "" }, { "docid": "1a3a63d8b6b753e2f33f2722b0b04da1", "score": "0.6643395", "text": "function retrieveProducts(req, res, next) {\n getProducts(req, res)\n .then(result => res.json(result))\n .catch(error => next(error));\n}", "title": "" }, { "docid": "6df808c00368d7da82ae075cc6a4139d", "score": "0.66334367", "text": "function getById(req, res, next) {\n productService.getById(req.params.id)\n .then(results => {\n res.send(200, results);\n }).catch(function(err) {\n res.send(500);\n });\n\n next();\n }", "title": "" }, { "docid": "fe74df3fc5aa88c7d8aad6df80c883d3", "score": "0.6631422", "text": "async function loadProduct() {\n try {\n const response = await axios.get(\n \"https://api.unsplash.com/photos/?client_id=dsmoN-2CMH79HH2y9RMNpbzeabCGGuSNwiyW7rSK0rU&per_page=60\"\n );\n products = response.data;\n products.forEach((item) => {\n renderProduct(item);\n });\n } catch (error) {\n console.log(error);\n }\n}", "title": "" }, { "docid": "1bd2f9a688fe6422f04fc93847c9ccd2", "score": "0.66221446", "text": "async function getProducts() {\r\n\r\n let type = product_type.value\r\n \r\n // reset\r\n container3.innerHTML = ''\r\n\r\n product_type.value = ''\r\n\r\n\r\n // fetching the product from api\r\n const response = await fetch(`https://makeup-api.herokuapp.com/api/v1/products.json?product_type=${type}`)\r\n\r\n const data = await response.json()\r\n\r\n\r\n console.log(data)\r\n\r\n appendData(data)\r\n\r\n}", "title": "" }, { "docid": "afd9af5fade8ffe48b7531203a646eb0", "score": "0.6608415", "text": "getProducts() {\n axios.get('/api/v1/products')\n .then(response => {\n console.log(response);\n this.products = response.data.products;\n });\n }", "title": "" }, { "docid": "961f177b63b7e05f0daf815af9f171d8", "score": "0.6595326", "text": "function findProductDetails() {\n CrudService.findItemDetailsById(CrudService.endpoints.PRODUCTS_ENDPOINT, $scope.product.id).success(function (data) {\n var json = JSON.parse(JSON.stringify(data));\n $scope.product = json.product;\n if ($scope.product.amount || $scope.product.simpleProduct) {\n $scope.product.isPack = true;\n }\n //Addapting data\n CrudService.response.suppliers = {items: json.suppliers, count: json.suppliers.length};\n CrudService.response.pAlerts = {items: json.alerts, count: json.alerts.length};\n CrudService.response.bills = {items: json.bills, count: json.bills.length};\n CrudService.response.orders = json.orders;\n }).error(function (data) {\n Flash.clear();\n Flash.create('danger', $translate.instant('error.loading'), 3000);\n });\n }", "title": "" }, { "docid": "3508bde27e3ce03c63febb5798dbe337", "score": "0.659515", "text": "fetchProducts () {\n axios.get(`${url_cat}/catalog`)\n .then((res) => {\n products = this.formatProducts(res.data.output)\n this.setProducts(products)\n })\n .catch((error) => {\n console.error(error.message)\n })\n }", "title": "" }, { "docid": "3c5f4fde9183463a637f357b8b6aa33a", "score": "0.65668356", "text": "getProducts() {\n axios\n .get(`${productsAPI}${this.state.productIds}&summary=true`)\n .then(response => {\n this.setState({ products: response.data.productinfo || [] });\n })\n .catch(err => err);\n }", "title": "" }, { "docid": "801b7c4937ff99dce530b0644c856dab", "score": "0.6565073", "text": "getById(prodObject, res, product_id) {\n \n ProductModel.find({ productid: product_id })\n .then(product => {\n if (product.length == 0) {\n res.status(appCodes.RESOURCE_NOT_FOUND).json({\n status: appCodes.ERROR,\n msg: \"No product found\"\n });\n } else {\n res.status(appCodes.OK).json({\n status: appCodes.SUCCESS,\n msg: \"Display Product with product id \",\n product_id: product_id,\n product: product\n });\n }\n })\n .catch(err =>\n res.status(appCodes.SERVER_ERROR).json({\n status: appCodes.FAIL,\n msg: \"Error in DB During Find Operation\",\n error: err\n })\n );\n }", "title": "" }, { "docid": "6e9351ceef430649b3c2800ce0647359", "score": "0.65512466", "text": "async loadProducts() {\n const productsResponse = await fetch(`${this.urlPrefix}/products`, {mode: 'cors'}); // {mode: 'cors'}\n const products = (await productsResponse.json()).data;\n products.forEach(product => this.products[product.name] = product);\n }", "title": "" }, { "docid": "5377f8dd97cec3a8cb3b614a6d5cb35d", "score": "0.6550588", "text": "getProducts(active) {\n\n return axios.get(API_URL + '?active=' + active, {\n });\n\n }", "title": "" }, { "docid": "ef510021b6b5dd19479073e7e4b0f67e", "score": "0.65489054", "text": "async getProducts() {\n this.ctx.body = await this.service.products.query({});\n }", "title": "" }, { "docid": "4944b739128debf8be32604fb181d9f8", "score": "0.6548014", "text": "static returnSingleProduct(){\n productsLib.returnSingleProduct({_id: arguments[0].id})\n .then(result => {\n arguments[1].status(200).send({success:result});\n })\n .catch(err => {\n arguments[1].status(400).send({error: err.message});\n });\n }", "title": "" }, { "docid": "ae01148fedd5a2eca6e7d6b28f16315b", "score": "0.6547761", "text": "static getProduct(id){\n let products = JSON.parse(localStorage.getItem('products'));\n return products.find(product => product.id == id)\n }", "title": "" }, { "docid": "d636d33aa3cd39a1459b93b905849365", "score": "0.6546524", "text": "function GetProductData() {\n try {\n var url = vrtlDirr +'/T12246/GetProductData';\n return $http({\n url: url,\n method: \"POST\",\n data: {}\n }).then(function (results) {\n return results.data;\n }).catch(function (ex) {\n throw ex;\n });\n } catch (ex) {\n throw ex;\n }\n }", "title": "" }, { "docid": "846fe5ca45c0cb52e061dbbcfa381206", "score": "0.6539456", "text": "function getProduct(req, res, next) {\n db.get(\"SELECT * FROM item WHERE id = ?\", req.query.id, function(err, row) {\n if (err) {\n console.log(\"could not retrieve product: \" + err);\n sendStatus(500);\n } else {\n res.status(200).send(row);\n }\n });\n}", "title": "" }, { "docid": "ff8864a939b94a48fcab92079c24f800", "score": "0.65386057", "text": "async function getCategoryByProductId(id){\r\n\r\n //Product Detail API Call\r\n let request = {\r\n method: 'GET',\r\n headers: {'Content-Type': 'application/json',\r\n 'x-access-token': token},\r\n redirect: 'follow'\r\n }\r\n \r\n var serverReturn = await fetch(ENDPOINT_URL + '/products/' + id,request)\r\n var serverResponse = await serverReturn.json()\r\n details = serverResponse;\r\n return details.category;\r\n }", "title": "" }, { "docid": "4a01abe62185a681a0a70e86a9e59868", "score": "0.65375626", "text": "async function getProduct(req,res,id) {\n Goods.findById(id)\n .then(goods => res.end(JSON.stringify(goods)))\n .catch(err => res.end(JSON.stringify(err)))\n }", "title": "" }, { "docid": "1a9732126f58f7d87fdbb91dc372733d", "score": "0.6514106", "text": "findOne(req, res) {\r\n\r\n let productId = req.params.id;\r\n console.log(productId);\r\n productService.findOne(productId).then(result => {\r\n let product = result;\r\n console.log(product);\r\n res.status(200).json(product);\r\n }).catch(err => {\r\n console.log(err);\r\n console.error(\"Error\", err.message);\r\n res.status(404).json({ errorMessage: err.message });\r\n });\r\n }", "title": "" }, { "docid": "60a6063206cf9fd06caac68961eeaf5c", "score": "0.6514045", "text": "function getProducts() {\n\n $.get(\"/api/products\", function (data) {\n displayProducts(data);\n });\n }", "title": "" }, { "docid": "375edb63a6f9fc75776f70b5ff1b5198", "score": "0.6511665", "text": "getProductInfo(id) {\n axios.get(`/products/${id}`)\n .then((data) => {\n console.log(id, data)\n this.setState({\n productData: data.data,\n showingStylePrice: data.data.default_price\n });\n })\n .catch((err) => {\n console.log('ERR Axios get product from client', err);\n });\n }", "title": "" }, { "docid": "00b99edcb12ecec99dae7b4952b38846", "score": "0.6507567", "text": "async show(req, res){\n const product = await Product.findById(req.params.id);\n \n return res.json(product);\n }", "title": "" }, { "docid": "014a27aef87387d12f5abe4467fb30ec", "score": "0.6500342", "text": "function getProductById(req, res){\n const { id } = req.params;\n sequelize.query('SELECT * FROM products WHERE id = :id',\n {\n replacements: {id: id},\n type: sequelize.QueryTypes.SELECT\n })\n .then((response)=> res.status(200).send(response));\n}", "title": "" }, { "docid": "1ff058837ea55d5743f3f4f60fbf99d8", "score": "0.6497687", "text": "static getProduct(id) {\n let products = JSON.parse(localStorage.getItem('products'));\n return products.find(product => product.id === id);\n // then i will use it in get bag function when button clickec\n }", "title": "" }, { "docid": "ba7e67f33d0453d5dc43a1696da5337f", "score": "0.64932334", "text": "function getProduct (productId, callback) {\n var filePath = UtilsService.paths.filePath + productId + '.json';\n\n fs.readFile(filePath, function (err, data) {\n if (err) {\n sails.log.error('error read file ' + filePath);\n getProduct(1, callback);\n return;\n }\n\n try {\n var productInfo = JSON.parse(data);\n // TODO validate productInfo\n }\n catch (e) {\n sails.log.error('error parse json ' + filePath);\n getProduct(1, callback);\n }\n\n callback(productInfo);\n });\n}", "title": "" }, { "docid": "e7b1060e4148c415d5d525f86c5d27db", "score": "0.6491196", "text": "getProduct(id) {\n let found = this.state.products.find(oneProduct => {\n return (oneProduct._id === id);\n })\n return found;\n }", "title": "" }, { "docid": "b97969b1bfb06d10b2ecc9e783300e49", "score": "0.6487588", "text": "function getProducts() {\n\tfetch('json/produkter.json')\n\t .then(function(response) {\n\t return response.json();\n\t})\n\t .then(function(products) {\n\t\t console.log(products);\n\t\t renderProduct(products);\n\t\t renderFunctionBar(products);\n\n\t});\n}", "title": "" }, { "docid": "4d94561b5fc68bc0428d02e4b48a857b", "score": "0.64858335", "text": "function getProductById(req,res){\n const ID = req.params.id\n\n Product.findById(ID).then((productFinded)=>{\n if(productFinded){\n return res.status(200).send(productFinded)\n }else{\n return res.status(200).send({\"Not Founded\": \"404\"})\n }\n }).catch((err)=>{return res.status(500).send({\"error\":err})})\n\n}", "title": "" }, { "docid": "21e7f1d1f2c814f474c23649b56cd783", "score": "0.6475898", "text": "async function getProductById(req, res, next) {\n const id = req.params.id;\n\n try {\n const product = await Product.findById(id);\n\n if (!product) {\n return next({\n status: HttpStatus.NOT_FOUND,\n message: \"Product is not found\"\n });\n }\n\n return res.json(doc);\n } catch (e) {\n next(e);\n }\n}", "title": "" }, { "docid": "3ad961870e003ed358b17b15c1735ea0", "score": "0.64726096", "text": "function getProducts(callback){\n var Headers = {\n 'Accept' : 'application/json'\n }\n $http.get('http://127.0.0.1:8000/products', { headers : Headers }).then(function success(response){\n callback(response.data);\n },function error(response){ console.log(\"no products\")});\n }", "title": "" }, { "docid": "8b16674822930de426e23146231afa59", "score": "0.6465941", "text": "async function show(req, res) {\n try {\n const product = await Product.findOne({ where: { id: req.params.productId } });\n res.json(product);\n } catch (error) {\n console.log(error);\n }\n}", "title": "" }, { "docid": "1708dd756e6eb5feecd5362a8f9e22d7", "score": "0.64645684", "text": "show(request, response) {\n Product.findById(request.params.product_id)\n .then(product => response.json(product))\n .catch(console.log);\n }", "title": "" }, { "docid": "bdd34d3fcd0a73356d4c9948d0f89344", "score": "0.64484274", "text": "getAllProduct() {\n axios.get(apiRootUrl + \"/admin/products/getAllProducts\", {\n headers: {\n Authorization: \"Bearer \" + localStorage.getItem(\"token_admin\"),\n },\n })\n //responds with the product data\n .then((res) => {\n\n this.setState({\n products: res.data.data,\n });\n })\n \n //error message if any errors occur\n .catch((err) => {\n notification(\"error\", \"Error\", err.response.data.error)\n });\n }", "title": "" }, { "docid": "ad9194ae91c5bea34b8a2c6f234ed126", "score": "0.6441132", "text": "async function fetchProductWithID(id) {\n try {\n const Product = await models.product;\n const res = await Product.findAll({ where: { product_barcode: id } });\n return res;\n } catch (error) {\n console.log(error.message);\n }\n }", "title": "" }, { "docid": "d85a7bb8dd3e11bedab64229ccbc26a8", "score": "0.6425462", "text": "function get_product_object(productId) {\n for(var i = 0; i < mockData.length; ++i) {\n var data_obj = mockData[i];\n if(data_obj.product_id == productId){\n return data_obj\n }\n }\n return null;\n }", "title": "" }, { "docid": "49302b46543982da65be8cd2b458efb8", "score": "0.64139843", "text": "function loadProducts() {\n productAPI\n .getProducts()\n .then((res) => setProducts(res.data))\n .catch((err) => console.log(err));\n }", "title": "" }, { "docid": "535030729351ded68e04206978f2e614", "score": "0.64080644", "text": "function step2GetProducts(){\n\n\tdebugDev('Step2GetProducts starts!');\n\n\tvar optionsProductsByCategory = {\t\n\t host : conf.host,\n\t port : conf.port,\n\t method : 'GET',\n\t headers: conf.headers\n\t};\n\n\tvar jsonProducts = { \"products\":[] };\n\tvar jsonProductsFromXml = { \"products\":[] };\n\tvar queryParam = '/products/marketplace';\n\tvar tmpArrayCategoriesCount = 1;\n\tvar tmpArrayCategoriesCount4Xml = 1;\n\n\toptionsProductsByCategory.path = conf.path + queryParam + '?apiKey=' + conf.apiKey + '&category=' + arrayJsonCategories.id;\n\tdebugDev('optionsProductsByCategory.path = ' + optionsProductsByCategory.path);\n\n\tvar getProductsByCategory = https.request(optionsProductsByCategory, function(res) {\n\n\t\tvar tmpRawProducts = '';\n\t\tvar tmpJsonProducts;\n\n\t res.on('data', (d) => {\n\t tmpRawProducts += d;\n\t });\n\n\t res.on('end', () => {\n\t \ttmpJsonProducts = JSON.parse(tmpRawProducts);\n\t \tdebugDev('request status success = ' + tmpJsonProducts.requestStatus.success);\n\n\t \tif (tmpJsonProducts.requestStatus.success === true) {\t \t\t\n\t \t\tdebugDev('Products Count = ' + tmpJsonProducts.products.length);\n\n\t\t \tdelete tmpJsonProducts.requestStatus;\n\n\t\t \tjsonProducts.products = tmpJsonProducts.products;\n\t \t}\n\t \twait4ApiCallComplete();\n\t });\n\n\t});\n\n\tgetProductsByCategory.end();\n\tgetProductsByCategory.on('error', (e) => {\n\t console.error(e);\n\t});\n\n\tlet xmlProductGetByCategoryUrl = 'https://bookur.rezdy.com/catalog/' + arrayJsonCategories.id + '/' + arrayJsonCategories.name.toLowerCase() + '?format=xml';\n\tdebugDev('xmlProductGetByCategoryUrl = ' + xmlProductGetByCategoryUrl);\n\n\thttps.get(xmlProductGetByCategoryUrl, (res) => {\n\t const statusCode = res.statusCode;\n\t const contentType = res.headers['content-type'];\n\n\t let error;\n\t if (statusCode !== 200) {\n\t error = new Error(`XML Request Failed.\\n` +\n\t `Status Code: ${statusCode}`);\n\t } else if (!/^text\\/xml/.test(contentType)) {\n\t error = new Error(`Invalid content-type.\\n` +\n\t `Expected text/xml but received ${contentType}`);\n\t }\n\t if (error) {\n\t console.log(error.message);\n\t // consume response data to free up memory\n\t res.resume();\n\t return;\n\t }\n\n\t res.setEncoding('utf8');\n\t let rawData = '';\n\t //let tmpJsonProductsFromXml;\n\n\t res.on('data', (chunk) => rawData += chunk);\n\t res.on('end', () => {\n\t try {\n\t\t\tparseString(rawData, {explicitArray:false}, function (err, result) {\n\t\t\t if(Array.isArray(result.products.product)){\t\t\t \t\n\t\t\t \tresult.products.product.forEach( (item,index) => {\n\t\t\t \t\tjsonProductsFromXml.products.push(item);\n\t\t \t\t});\t\t\t\t \n\t\t\t } else {\n\t\t\t \tjsonProductsFromXml.products.push(result.products.product);\n\t\t\t }\n\t\t\t});\n\t\t\twait4XmlProductsGetComplete();\n\t } catch (e) {\n\t console.log(e.message);\n\t }\n\t });\n\t}).on('error', (e) => {\n\t console.log(`Got error: ${e.message}`);\n\t});\n\n\tfunction wait4XmlProductsGetComplete(){\n\t\tdebugDev('Enter Step2 wait4XmlProductsGetComplete');\n\t\ttmpArrayCategoriesCount4Xml--;\n\t\tdebugDev('incompleted category/products xml count = ' + tmpArrayCategoriesCount4Xml);\n\t\tif (tmpArrayCategoriesCount4Xml === 0) {\n\t\t\twait4BothComplete();\n\t\t}\n\t}\n\n\tfunction wait4ApiCallComplete(){\n\t\tdebugDev('Enter Step2 wait4ApiCallComplete');\n\t\ttmpArrayCategoriesCount--;\n\t\tdebugDev('incompleted category/products count = ' + tmpArrayCategoriesCount);\n\t\tif (tmpArrayCategoriesCount === 0) {\n\t\t\twait4BothComplete();\n\t\t}\n\t}\n\n\tfunction wait4BothComplete(){\n\t\tif(tmpArrayCategoriesCount4Xml === 0 && tmpArrayCategoriesCount === 0){\n\t\t\thandleProductsResult();\n\t\t}\n\t}\n\n\tfunction handleProductsResult(){\n \tfs.writeFileSync('./jsonProducts.json', JSON.stringify(jsonProducts.products));\t\t\n\t\tjsonProducts.products.forEach( (jsonProductsItem, jsonProductsIndex) => {\n\t\t\tjsonProductsFromXml.products.forEach( (jsonProductsFromXmlItem, jsonProductsFromXmlIndex) => {\n\t\t\t\tif(jsonProductsFromXmlItem.productCode === jsonProductsItem.productCode){\n\t\t\t\t\tjsonProductsItem.rzdId = jsonProductsFromXmlItem.id;\n\t\t\t\t\tjsonProductsItem.productPageUrl = jsonProductsFromXmlItem.productPageUrl;\n\t\t\t\t\tjsonProductsItem.calendarWidgetUrl = jsonProductsFromXmlItem.calendarWidgetUrl;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n \tvar rawProducts = JSON.stringify(jsonProducts);\n \tfs.writeFileSync('./datafiles/products.json', rawProducts);\n arrayJsonProducts = jsonProducts.products;\n\n var supplierAliasFromProducts = [];\n arrayJsonProducts.forEach( (item1,index1) => {\n \tvar newFlag = true;\n \tsupplierAliasFromProducts.forEach( (item2,index2) => { \t\t\n \t\tif(item1.supplierAlias === item2.supplierAlias){\n \t\t\tnewFlag = false;\n \t\t}\n \t});\n \tif (newFlag) {\n \t\tvar supplierInfo = {};\n \t\tsupplierInfo.supplierId = item1.supplierId.toString();\n \t\tsupplierInfo.supplierAlias = item1.supplierAlias;\n\t \tsupplierAliasFromProducts.push(supplierInfo);\n \t}\n });\n debugDev('step2GetProducts Ended!');\n step3GetSuppliersByProducts(supplierAliasFromProducts);\n\n\t}\n}", "title": "" }, { "docid": "1e73545993f780cf4fe9435a99e735b9", "score": "0.64024407", "text": "async function fetchProduct(itemUrl) {\n const response = await fetch(itemUrl); // REQUETE\n if (response.ok) {\n const item = await response.json();\n return item; // REPONSE AU FORMAT JSON\n }\n}", "title": "" }, { "docid": "76f5bfb2803c9187c176413b893063a4", "score": "0.64008605", "text": "function getProducto () {\n fetch(\"http://localhost:3000/api/product/\", {\n method: \"get\",\n mode:\"no-cors\",\n headers: {\"Content-Type\": \"application/x-www-form-urlencoded; charset=utf-8\", \"Access-Control-Allow-Origin\": true},\n })\n .then(response => response.json())\n .then(response => console.log(response))\n}", "title": "" }, { "docid": "13f872d79228d53a4cf831a73b86809b", "score": "0.6398", "text": "async getOne(req, res) {\n try {\n // \n const { id } = req.params;\n const product = await Product.findById({_id: id});\n // if(!isNumber(id)){\n // return res.status(404).json({ err: `make sure id:${id} is a number` }); \n // }\n if(!product){\n return res.status(404).json({err:`could not find product with id:${id}`});\n }\n return res.json(product)\n // .populate('artist', 'firstName lastName');\n } catch (err) {\n console.error(err);\n return res.status(500).send(err);\n }\n }", "title": "" } ]
31ea4e0fee6b6823f1f39f5e6215c95e
Convenience component with default shallow equality check for sCU.
[ { "docid": "a93ff46cb87b62baafea919eddb932fa", "score": "0.0", "text": "function PureComponent(props, context, updater) {\n this.props = props;\n this.context = context; // If a component has string refs, we will assign a different object later.\n\n this.refs = emptyObject;\n this.updater = updater || ReactNoopUpdateQueue;\n }", "title": "" } ]
[ { "docid": "9bd42234859d52d5f416f2f235e9bcf5", "score": "0.61371845", "text": "function defaultEqualityCheck(a, b) {\n return a === b\n }", "title": "" }, { "docid": "6c5680b86c2be136fb41a85ea47fbf21", "score": "0.58184475", "text": "function defaultEqualityCheck(a, b) {\n return a === b;\n}", "title": "" }, { "docid": "f3e736eff262bb48ed08d2fccca72132", "score": "0.5669391", "text": "function defaultEqualityCheck(a, b) {\n return !a && !b || a === b;\n }", "title": "" }, { "docid": "be42c4a5dfec0f7cf58f9f4f15b748a6", "score": "0.56581414", "text": "equals() {\n return false;\n }", "title": "" }, { "docid": "be42c4a5dfec0f7cf58f9f4f15b748a6", "score": "0.56581414", "text": "equals() {\n return false;\n }", "title": "" }, { "docid": "6f5be476546b33128a1db1402c2afff5", "score": "0.56011873", "text": "equalWithoutSessionForTesting(id) {\n if (id._components.length !== this._components.length)\n return false;\n for (let i = 0; i < id._components.length; i++)\n if (id._components[i] !== this._components[i])\n return false;\n\n return true;\n }", "title": "" }, { "docid": "43c0542819b88f15ff0eebcc29c236d0", "score": "0.5561489", "text": "function useStrictEquality( b, a ) {\n\n\t\t\t\t/*jshint eqeqeq:false */\n\t\t\t\tif ( b instanceof a.constructor || a instanceof b.constructor ) {\n\n\t\t\t\t\t// to catch short annotation VS 'new' annotation of a\n\t\t\t\t\t// declaration\n\t\t\t\t\t// e.g. var i = 1;\n\t\t\t\t\t// var j = new Number(1);\n\t\t\t\t\treturn a == b;\n\t\t\t\t} else {\n\t\t\t\t\treturn a === b;\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "9c2010b51c941e12c0bbe4a3bacfb494", "score": "0.5558547", "text": "function useStrictEquality(b, a) {\n\t\t\t\t\tif (b instanceof a.constructor || a instanceof b.constructor) {\n\t\t\t\t\t\t// to catch short annotaion VS 'new' annotation of a\n\t\t\t\t\t\t// declaration\n\t\t\t\t\t\t// e.g. var i = 1;\n\t\t\t\t\t\t// var j = new Number(1);\n\t\t\t\t\t\treturn a == b;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t}\n\t\t\t\t}", "title": "" }, { "docid": "8894a8627cb324c425378e666853345e", "score": "0.55487525", "text": "function useStrictEquality(b, a) {\n\t if (b instanceof a.constructor || a instanceof b.constructor) {\n\t // to catch short annotaion VS 'new' annotation of a declaration\n\t // e.g. var i = 1;\n\t // var j = new Number(1);\n\t return a == b;\n\t } else {\n\t return a === b;\n\t }\n\t }", "title": "" }, { "docid": "14a5224bb748672e7f18cab5e0de2227", "score": "0.5506923", "text": "function useStrictEquality(b, a) {\r\n if (b instanceof a.constructor || a instanceof b.constructor) {\r\n // to catch short annotaion VS 'new' annotation of a declaration\r\n // e.g. var i = 1;\r\n // var j = new Number(1);\r\n return a == b;\r\n } else {\r\n return a === b;\r\n }\r\n }", "title": "" }, { "docid": "c57ba54aed11ad6c761637b3c69b3530", "score": "0.5497118", "text": "function isEqual() {\n\n}", "title": "" }, { "docid": "f32854f1fccaeba27552d16f8da1aee3", "score": "0.5481716", "text": "function useStrictEquality(b, a) {\n if (b instanceof a.constructor || a instanceof b.constructor) {\n // to catch short annotaion VS 'new' annotation of a declaration\n // e.g. var i = 1;\n // var j = new Number(1);\n return a == b;\n } else {\n return a === b;\n }\n }", "title": "" }, { "docid": "121aa04d7eee8818b67121de6e0564cb", "score": "0.54722977", "text": "function looseEqual (a, b) {\n\t /* eslint-disable eqeqeq */\n\t return a == b || (\n\t isObject(a) && isObject(b)\n\t ? JSON.stringify(a) === JSON.stringify(b)\n\t : false\n\t )\n\t /* eslint-enable eqeqeq */\n\t}", "title": "" }, { "docid": "121aa04d7eee8818b67121de6e0564cb", "score": "0.54722977", "text": "function looseEqual (a, b) {\n\t /* eslint-disable eqeqeq */\n\t return a == b || (\n\t isObject(a) && isObject(b)\n\t ? JSON.stringify(a) === JSON.stringify(b)\n\t : false\n\t )\n\t /* eslint-enable eqeqeq */\n\t}", "title": "" }, { "docid": "5fdca0d403ca6c7cdc7338c9b8919aed", "score": "0.54580516", "text": "function looseEqual(a, b) {\n // eslint-disable-next-line eqeqeq\n return a == b || (isObject(a) && isObject(b) ? JSON.stringify(a) === JSON.stringify(b) : false);\n}", "title": "" }, { "docid": "ce021e0aefbad7e204006b4fa78c128a", "score": "0.5451884", "text": "function looseEqual (a, b) {\n /* eslint-disable eqeqeq */\n return a == b || (\n isObject(a) && isObject(b)\n ? JSON.stringify(a) === JSON.stringify(b)\n : false\n )\n /* eslint-enable eqeqeq */\n}", "title": "" }, { "docid": "82c0d6ada8f0e1d9221af493c02ffc6f", "score": "0.5441116", "text": "function shallowCompare(instance,nextProps,nextState){return!shallowEqual(instance.props,nextProps)||!shallowEqual(instance.state,nextState);}", "title": "" }, { "docid": "efb13e6d79a1cd827a50d8799a12a875", "score": "0.53545064", "text": "equals(value) {\n const other = value;\n if (!other) {\n return false;\n }\n if (this._isIdentity || other._isIdentity) {\n if (!this._isIdentityDirty && !other._isIdentityDirty) {\n return this._isIdentity && other._isIdentity;\n }\n }\n const m = this.m;\n const om = other.m;\n return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&\n m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&\n m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&\n m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);\n }", "title": "" }, { "docid": "62edb40c3e3a7be769f0bdc4ce2a0bf7", "score": "0.5349228", "text": "function isCoerced (a,b){\n if (a == b)\n{\nreturn true;\n}\n return false;\n\n}", "title": "" }, { "docid": "39ee08bb536945ba1c13886d06785bf7", "score": "0.53444856", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t\t}", "title": "" }, { "docid": "959ac722ae26debeda6e7fc0fdc16efd", "score": "0.5341108", "text": "function strictEqual(value, other) {\n return value === other;\n}", "title": "" }, { "docid": "b2230073e4100df890d83a7b49b4dc40", "score": "0.5313085", "text": "function shallowCompare(a, b) {\n\t return checkProperties(a, b) && checkProperties(b, a);\n\t}", "title": "" }, { "docid": "b2230073e4100df890d83a7b49b4dc40", "score": "0.5313085", "text": "function shallowCompare(a, b) {\n\t return checkProperties(a, b) && checkProperties(b, a);\n\t}", "title": "" }, { "docid": "6d542a313c5093812f13c365241ec932", "score": "0.5294243", "text": "copy() {\n let shallowCopy = this;\n return shallowCopy;\n }", "title": "" }, { "docid": "bd7d8e8f474af1dcb746b755d32a100f", "score": "0.52883065", "text": "function ya(a,b){return a||b?a&&b?a.component===b.component&&za(a,b)&&za(b,a):!1:!0}", "title": "" }, { "docid": "5c394899a9a382bb36be4fb7fc28ced4", "score": "0.52617186", "text": "function looseEqual (a, b) {\n\t var isObjectA = isObject(a);\n\t var isObjectB = isObject(b);\n\t if (isObjectA && isObjectB) {\n\t try {\n\t return JSON.stringify(a) === JSON.stringify(b)\n\t } catch (e) {\n\t // possible circular reference\n\t return a === b\n\t }\n\t } else if (!isObjectA && !isObjectB) {\n\t return String(a) === String(b)\n\t } else {\n\t return false\n\t }\n\t}", "title": "" }, { "docid": "5c394899a9a382bb36be4fb7fc28ced4", "score": "0.52617186", "text": "function looseEqual (a, b) {\n\t var isObjectA = isObject(a);\n\t var isObjectB = isObject(b);\n\t if (isObjectA && isObjectB) {\n\t try {\n\t return JSON.stringify(a) === JSON.stringify(b)\n\t } catch (e) {\n\t // possible circular reference\n\t return a === b\n\t }\n\t } else if (!isObjectA && !isObjectB) {\n\t return String(a) === String(b)\n\t } else {\n\t return false\n\t }\n\t}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "4541413d4b7aa45c238fc8c58b6b3ca1", "score": "0.52481365", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b)\n } catch (e) {\n // possible circular reference\n return a === b\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "494d3f1b51704023595ebe568b695c9f", "score": "0.5233564", "text": "function looseEqual (a, b) {\n\t var isObjectA = isObject(a);\n\t var isObjectB = isObject(b);\n\t if (isObjectA && isObjectB) {\n\t return JSON.stringify(a) === JSON.stringify(b)\n\t } else if (!isObjectA && !isObjectB) {\n\t return String(a) === String(b)\n\t } else {\n\t return false\n\t }\n\t}", "title": "" }, { "docid": "07b51e38163731674e3845a3854f18ff", "score": "0.5227296", "text": "function looseEqual(a, b) {\n\t var isObjectA = isObject(a);\n\t var isObjectB = isObject(b);\n\t if (isObjectA && isObjectB) {\n\t try {\n\t return JSON.stringify(a) === JSON.stringify(b);\n\t } catch (e) {\n\t // possible circular reference\n\t return a === b;\n\t }\n\t } else if (!isObjectA && !isObjectB) {\n\t return String(a) === String(b);\n\t } else {\n\t return false;\n\t }\n\t}", "title": "" }, { "docid": "bc6cb76a2eece1d5e527ebb2695f71a6", "score": "0.5219417", "text": "strictEquals(other) {\n return this.x === other.x && this.y === other.y;\n }", "title": "" }, { "docid": "00bb2a17901231c4b685827fc43159ee", "score": "0.52132595", "text": "function looseEqual(a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n try {\n return JSON.stringify(a) === JSON.stringify(b);\n } catch (e) {\n // possible circular reference\n return a === b;\n }\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b);\n } else {\n return false;\n }\n}", "title": "" }, { "docid": "2c375bd9776493554ab705b12a713542", "score": "0.520813", "text": "function shallowCompare(cur, next) {\n return React.addons.shallowCompare({props:cur}, next);\n}", "title": "" }, { "docid": "995b41a8ac68b3647655104baf0c6b25", "score": "0.5204139", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n return JSON.stringify(a) === JSON.stringify(b)\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "995b41a8ac68b3647655104baf0c6b25", "score": "0.5204139", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n return JSON.stringify(a) === JSON.stringify(b)\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "995b41a8ac68b3647655104baf0c6b25", "score": "0.5204139", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n return JSON.stringify(a) === JSON.stringify(b)\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "995b41a8ac68b3647655104baf0c6b25", "score": "0.5204139", "text": "function looseEqual (a, b) {\n var isObjectA = isObject(a);\n var isObjectB = isObject(b);\n if (isObjectA && isObjectB) {\n return JSON.stringify(a) === JSON.stringify(b)\n } else if (!isObjectA && !isObjectB) {\n return String(a) === String(b)\n } else {\n return false\n }\n}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "cfc12c33e6e593db137d9aed727bca07", "score": "0.5194291", "text": "function shallowCompare(instance, nextProps, nextState) {\n\t return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n\t}", "title": "" }, { "docid": "85e1d065d6688b31bc6902b457a2a827", "score": "0.51496154", "text": "function defaultEquals(a, b) {\n return a === b;\n }", "title": "" }, { "docid": "85e1d065d6688b31bc6902b457a2a827", "score": "0.51496154", "text": "function defaultEquals(a, b) {\n return a === b;\n }", "title": "" }, { "docid": "9c5ef8c8e7b10b8238a397d1891216c7", "score": "0.51398665", "text": "function defaultCheckValueEquality(a, b) {\n\treturn a === b;\n}", "title": "" }, { "docid": "bcc7eb010d6688c638bf48f28c2922a7", "score": "0.51182693", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\nfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "ce1bd4c20f9636cd99cffe25001f69de", "score": "0.5114752", "text": "function looseEqual(a,b){if(a===b){return true;}var isObjectA=isObject(a);var isObjectB=isObject(b);if(isObjectA&&isObjectB){try{var isArrayA=Array.isArray(a);var isArrayB=Array.isArray(b);if(isArrayA&&isArrayB){return a.length===b.length&&a.every(function(e,i){return looseEqual(e,b[i]);});}else if(a instanceof Date&&b instanceof Date){return a.getTime()===b.getTime();}else if(!isArrayA&&!isArrayB){var keysA=Object.keys(a);var keysB=Object.keys(b);return keysA.length===keysB.length&&keysA.every(function(key){return looseEqual(a[key],b[key]);});}else{/* istanbul ignore next */return false;}}catch(e){/* istanbul ignore next */return false;}}else if(!isObjectA&&!isObjectB){return String(a)===String(b);}else{return false;}}", "title": "" }, { "docid": "d1188b2a66a46b66c665da4e6b484f1f", "score": "0.51095736", "text": "function deepEqual(lvalue, rvalue) {\n if (lvalue === rvalue) {\n return true;\n }\n // CloudFormation allows passing strings into boolean-typed fields\n if (((typeof lvalue === 'string' && typeof rvalue === 'boolean') ||\n (typeof lvalue === 'boolean' && typeof rvalue === 'string')) &&\n lvalue.toString() === rvalue.toString()) {\n return true;\n }\n // allows a numeric 10 and a literal \"10\" to be equivalent;\n // this is consistent with CloudFormation.\n if (((typeof lvalue === 'string') || (typeof rvalue === 'string')) && (parseFloat(lvalue) === parseFloat(rvalue))) {\n return true;\n }\n if (typeof lvalue !== typeof rvalue) {\n return false;\n }\n if (Array.isArray(lvalue) !== Array.isArray(rvalue)) {\n return false;\n }\n if (Array.isArray(lvalue) /* && Array.isArray(rvalue) */) {\n if (lvalue.length !== rvalue.length) {\n return false;\n }\n for (let i = 0; i < lvalue.length; i++) {\n if (!deepEqual(lvalue[i], rvalue[i])) {\n return false;\n }\n }\n return true;\n }\n if (typeof lvalue === 'object' /* && typeof rvalue === 'object' */) {\n if (lvalue === null || rvalue === null) {\n // If both were null, they'd have been ===\n return false;\n }\n const keys = Object.keys(lvalue);\n if (keys.length !== Object.keys(rvalue).length) {\n return false;\n }\n for (const key of keys) {\n if (!rvalue.hasOwnProperty(key)) {\n return false;\n }\n if (key === 'DependsOn') {\n if (!dependsOnEqual(lvalue[key], rvalue[key])) {\n return false;\n }\n ;\n // check differences other than `DependsOn`\n continue;\n }\n if (!deepEqual(lvalue[key], rvalue[key])) {\n return false;\n }\n }\n return true;\n }\n // Neither object, nor array: I deduce this is primitive type\n // Primitive type and not ===, so I deduce not deepEqual\n return false;\n}", "title": "" }, { "docid": "54545d36a556b66c589e1186e41076e2", "score": "0.5102109", "text": "eq(x, y) {\n return x === y;\n }", "title": "" }, { "docid": "c22ee1da0837a2b8be54fecfdd5333f7", "score": "0.5101927", "text": "function shallowEqual(objA,objB){if(is$1(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\nfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty$2.call(objB,keysA[i])||!is$1(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "a717e91c58d130209adc0c6762da4ae9", "score": "0.51008964", "text": "function shallowCompare(a, b) {\n return checkProperties(a, b) && checkProperties(b, a);\n}", "title": "" }, { "docid": "a717e91c58d130209adc0c6762da4ae9", "score": "0.51008964", "text": "function shallowCompare(a, b) {\n return checkProperties(a, b) && checkProperties(b, a);\n}", "title": "" }, { "docid": "a717e91c58d130209adc0c6762da4ae9", "score": "0.51008964", "text": "function shallowCompare(a, b) {\n return checkProperties(a, b) && checkProperties(b, a);\n}", "title": "" }, { "docid": "a717e91c58d130209adc0c6762da4ae9", "score": "0.51008964", "text": "function shallowCompare(a, b) {\n return checkProperties(a, b) && checkProperties(b, a);\n}", "title": "" }, { "docid": "a717e91c58d130209adc0c6762da4ae9", "score": "0.51008964", "text": "function shallowCompare(a, b) {\n return checkProperties(a, b) && checkProperties(b, a);\n}", "title": "" }, { "docid": "a717e91c58d130209adc0c6762da4ae9", "score": "0.51008964", "text": "function shallowCompare(a, b) {\n return checkProperties(a, b) && checkProperties(b, a);\n}", "title": "" }, { "docid": "b69cea94a12069a89aa08cce5fb5c7b2", "score": "0.50943255", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\nfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty$1.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "b69cea94a12069a89aa08cce5fb5c7b2", "score": "0.50943255", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\nfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty$1.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "91cf111448b3f6bf559f4679078484e5", "score": "0.5085106", "text": "$setEquals (obj, expr) {\n let args = computeValue(obj, expr, null)\n let xs = unique(args[0])\n let ys = unique(args[1])\n return xs.length === ys.length && xs.length === intersection(xs, ys).length\n }", "title": "" }, { "docid": "06f42bbcd52a7e7f06dc2bde868aa8f2", "score": "0.50824493", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\n\tfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "06f42bbcd52a7e7f06dc2bde868aa8f2", "score": "0.50824493", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\n\tfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "06f42bbcd52a7e7f06dc2bde868aa8f2", "score": "0.50824493", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\n\tfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "7f547083747de32d9f69b4033a1e9273", "score": "0.5075307", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA===\"undefined\"?\"undefined\":_typeof(objA))!=='object'||objA===null||(typeof objB===\"undefined\"?\"undefined\":_typeof(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\n\tfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "107fc12b81bd250a83781c82d1e2141d", "score": "0.5068589", "text": "equals(o)\n {\n return o instanceof Coord && this.x === o.x && this.y === o.y;\n }", "title": "" }, { "docid": "fd47b4045584c65adcee18b7c5a7fa86", "score": "0.50648123", "text": "static inSameState({ from, to }) {\n\n return from.uf === to.uf;\n\n }", "title": "" }, { "docid": "541e619f524e9ca793d1ef7b6da306b5", "score": "0.506331", "text": "function shallowCompare(obj1, obj2) {\n\t\t\t\t\t\tfor (var attr in obj1) {\n\t\t\t\t\t\t\tif(obj1[attr] !== obj2[attr] && attr !== 'uniq' && attr !== 'generated') {\n\t\t\t\t\t\t\t\tif(attr === 'uniq') console.log(attr + \":\" + obj1[attr] + \":\" + obj2[attr]);\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}", "title": "" }, { "docid": "6f58c7847b6b6abf971338a1507d3b80", "score": "0.5061051", "text": "function shallowEqualObjects(a, b) {\n if (a && !b || b && !a) {\n return false;\n }\n\n for (var key in a) {\n if (a[key] !== b[key]) {\n return false;\n }\n }\n\n return true;\n } // Copied from: https://github.com/jonschlinkert/is-plain-object", "title": "" }, { "docid": "6e333e74d98a4903f25c4d5a4abe75f0", "score": "0.50565094", "text": "function same(a, b) {\n return a === b || a !== a && b !== b;\n }", "title": "" }, { "docid": "ade7a4d9c35c2d489d246dde1cc87a04", "score": "0.5052919", "text": "function isEqual(a, b) {\n return eq(a, b);\n }", "title": "" }, { "docid": "1c3b9f94dfd53c36097d9232a45f719c", "score": "0.5051227", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if((typeof objA==='undefined'?'undefined':_typeof2(objA))!=='object'||objA===null||(typeof objB==='undefined'?'undefined':_typeof2(objB))!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\r\n\tfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "f87d07e20c00662ff88bcb36e429bac6", "score": "0.50328696", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if(typeof objA!=='object'||objA===null||typeof objB!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\nfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty$1.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "f87d07e20c00662ff88bcb36e429bac6", "score": "0.50328696", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if(typeof objA!=='object'||objA===null||typeof objB!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\nfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty$1.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "f87d07e20c00662ff88bcb36e429bac6", "score": "0.50328696", "text": "function shallowEqual(objA,objB){if(is(objA,objB)){return true;}if(typeof objA!=='object'||objA===null||typeof objB!=='object'||objB===null){return false;}var keysA=Object.keys(objA);var keysB=Object.keys(objB);if(keysA.length!==keysB.length){return false;}// Test for A's keys different from B.\nfor(var i=0;i<keysA.length;i++){if(!hasOwnProperty$1.call(objB,keysA[i])||!is(objA[keysA[i]],objB[keysA[i]])){return false;}}return true;}", "title": "" }, { "docid": "a231a26961b5d290f5fdf5ae9f80680e", "score": "0.5032214", "text": "function C(S){if(null===S||S===void 0)throw new TypeError('Object.assign cannot be called with null or undefined');return Object(S)}", "title": "" }, { "docid": "fd22540254a397093eee0a94bb5e0840", "score": "0.50300545", "text": "addComponent(componentMap, path, props) {\n const component = utils.getComponent(path, componentMap) || new Component(path);\n return utils.updateComponent(componentMap, component, props, \"DO_DEEP_EQUAL_CHECK\");\n }", "title": "" }, { "docid": "b0306a36294b6d52b1b2c469e32f55e4", "score": "0.50271976", "text": "function shallowCompare(instance, nextProps, nextState) {\n return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n}", "title": "" }, { "docid": "b0306a36294b6d52b1b2c469e32f55e4", "score": "0.50271976", "text": "function shallowCompare(instance, nextProps, nextState) {\n return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n}", "title": "" }, { "docid": "b0306a36294b6d52b1b2c469e32f55e4", "score": "0.50271976", "text": "function shallowCompare(instance, nextProps, nextState) {\n return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n}", "title": "" }, { "docid": "b0306a36294b6d52b1b2c469e32f55e4", "score": "0.50271976", "text": "function shallowCompare(instance, nextProps, nextState) {\n return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);\n}", "title": "" } ]
412363073166c2985d737ab6b119ffdb
Report a message that an unexpected character was encountered.
[ { "docid": "127db547ef3d343c2b67957a220ab071", "score": "0.68689543", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" } ]
[ { "docid": "161918c90a0ba7b02962a82125b430ce", "score": "0.708676", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n }", "title": "" }, { "docid": "161918c90a0ba7b02962a82125b430ce", "score": "0.708676", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n }", "title": "" }, { "docid": "8326f3e58eec64575db42ab21ead9616", "score": "0.70687723", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n }", "title": "" }, { "docid": "2a2a20fdc8cfe4ca60e52a84704666ec", "score": "0.6981053", "text": "function unexpectedCharacterMessage(code) {\n\t if (code === 39) {\n\t // '\n\t return 'Unexpected single quote character (\\'), did you mean to use ' + 'a double quote (\")?';\n\t }\n\n\t return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n\t}", "title": "" }, { "docid": "a2e25a8cee3c5795d325fa0fbfcacb50", "score": "0.6938613", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" }, { "docid": "a2e25a8cee3c5795d325fa0fbfcacb50", "score": "0.6938613", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" }, { "docid": "a2e25a8cee3c5795d325fa0fbfcacb50", "score": "0.6938613", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" }, { "docid": "a2e25a8cee3c5795d325fa0fbfcacb50", "score": "0.6938613", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" }, { "docid": "a2e25a8cee3c5795d325fa0fbfcacb50", "score": "0.6938613", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" }, { "docid": "a2e25a8cee3c5795d325fa0fbfcacb50", "score": "0.6938613", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" }, { "docid": "a2e25a8cee3c5795d325fa0fbfcacb50", "score": "0.6938613", "text": "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return \"Cannot parse the unexpected character \".concat(printCharCode(code), \".\");\n}", "title": "" }, { "docid": "32956dae012024a3a9f239b596dade99", "score": "0.6818663", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use ' + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "32956dae012024a3a9f239b596dade99", "score": "0.6818663", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use ' + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "32956dae012024a3a9f239b596dade99", "score": "0.6818663", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use ' + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "32956dae012024a3a9f239b596dade99", "score": "0.6818663", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return 'Unexpected single quote character (\\'), did you mean to use ' + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "3aa2a983f78edeb676393aefb87dc762", "score": "0.6795637", "text": "expectCharacter(code) {\n if (this.consumeOptionalCharacter(code))\n return;\n this.error(`Missing expected ${String.fromCharCode(code)}`);\n }", "title": "" }, { "docid": "07621b607eb7221b76b9ad579fd6b7fe", "score": "0.6725418", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "07621b607eb7221b76b9ad579fd6b7fe", "score": "0.6725418", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "07621b607eb7221b76b9ad579fd6b7fe", "score": "0.6725418", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "07621b607eb7221b76b9ad579fd6b7fe", "score": "0.6725418", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "07621b607eb7221b76b9ad579fd6b7fe", "score": "0.6725418", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "07621b607eb7221b76b9ad579fd6b7fe", "score": "0.6725418", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "07621b607eb7221b76b9ad579fd6b7fe", "score": "0.6725418", "text": "function unexpectedCharacterMessage(code) {\n if (code === 39) {\n // '\n return \"Unexpected single quote character ('), did you mean to use \" + 'a double quote (\")?';\n }\n\n return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';\n}", "title": "" }, { "docid": "815afdf279b2b73b4158971c4ea7df4c", "score": "0.6474487", "text": "function unexpected() {\n raise(tokStart, \"Unexpected token\");\n }", "title": "" }, { "docid": "815afdf279b2b73b4158971c4ea7df4c", "score": "0.6474487", "text": "function unexpected() {\n raise(tokStart, \"Unexpected token\");\n }", "title": "" }, { "docid": "815afdf279b2b73b4158971c4ea7df4c", "score": "0.6474487", "text": "function unexpected() {\n raise(tokStart, \"Unexpected token\");\n }", "title": "" }, { "docid": "815afdf279b2b73b4158971c4ea7df4c", "score": "0.6474487", "text": "function unexpected() {\n raise(tokStart, \"Unexpected token\");\n }", "title": "" }, { "docid": "815afdf279b2b73b4158971c4ea7df4c", "score": "0.6474487", "text": "function unexpected() {\n raise(tokStart, \"Unexpected token\");\n }", "title": "" }, { "docid": "815afdf279b2b73b4158971c4ea7df4c", "score": "0.6474487", "text": "function unexpected() {\n raise(tokStart, \"Unexpected token\");\n }", "title": "" }, { "docid": "a0809cdc286c48f05653cad7a80fe7d3", "score": "0.6471246", "text": "function unrecognizedChar(name, value, errorJSON, errorArray) {\n //Primarily unrecognized special characters\n reUnrecChar = /[!@#$%^&*;'\"{}[\\]+`~]/g;\n //Special characters flag test\n var unrecFlag = reUnrecChar.test(value);\n //If the input value contains unrecognized special characters the error is stored into the errorJSON\n if(unrecFlag) {\n var ems = 'The ' + name + ' contains unrecognized special characters';\n highlight(name);\n errorObjects(name, ems, errorJSON, errorArray)\n }\n else\n errorArray.push(false);\n}", "title": "" }, { "docid": "616bfbf51961620a8fec78b5bd2c87f0", "score": "0.6078754", "text": "function ce(string) {\n\tconsole.error(string);\n}", "title": "" }, { "docid": "8b3fe321bdbce268f0583d49975d0055", "score": "0.59270006", "text": "function consumeChar(char, errorClass) {\n if (source[cursor] === char) {\n cursor++;\n return true;\n }\n if (errorClass) {\n throw new errorClass(`Expected ${char}`);\n }\n return false;\n }", "title": "" }, { "docid": "8b3fe321bdbce268f0583d49975d0055", "score": "0.59270006", "text": "function consumeChar(char, errorClass) {\n if (source[cursor] === char) {\n cursor++;\n return true;\n }\n if (errorClass) {\n throw new errorClass(`Expected ${char}`);\n }\n return false;\n }", "title": "" }, { "docid": "8385a0074649abb1c3cf69254cd99dab", "score": "0.5886338", "text": "function quit(message, line, chr) {\n var percentage = Math.floor((line / lines.length) * 100);\n\n throw {\n name: \"JSHintError\",\n line: line,\n character: chr,\n message: message + \" (\" + percentage + \"% scanned).\",\n raw: message\n };\n }", "title": "" }, { "docid": "33d7b3bee9e83db5098123683e4468c7", "score": "0.5811693", "text": "get charIndexOfError() {\n return this._c;\n }", "title": "" }, { "docid": "b9c1b71688647607e0f25a3a5930b3b8", "score": "0.58027554", "text": "throwUnexpectedToken(symbol, line, column) {\n const lineSource = this._string.split('\\n')[line - 1];\n let lineData = '';\n\n if (lineSource) {\n const pad = ' '.repeat(column);\n lineData = '\\n\\n' + lineSource + '\\n' + pad + '^\\n';\n }\n\n throw new SyntaxError(\n `${lineData}Unexpected token: \"${symbol}\" ` +\n `at ${line}:${column}.`\n );\n }", "title": "" }, { "docid": "b9c1b71688647607e0f25a3a5930b3b8", "score": "0.58027554", "text": "throwUnexpectedToken(symbol, line, column) {\n const lineSource = this._string.split('\\n')[line - 1];\n let lineData = '';\n\n if (lineSource) {\n const pad = ' '.repeat(column);\n lineData = '\\n\\n' + lineSource + '\\n' + pad + '^\\n';\n }\n\n throw new SyntaxError(\n `${lineData}Unexpected token: \"${symbol}\" ` +\n `at ${line}:${column}.`\n );\n }", "title": "" }, { "docid": "a47691d2c12b037eace6f473b28ee57c", "score": "0.57932603", "text": "throwUnexpectedToken(symbol, line, column) {\n const lineSource = this._string.split('\\n')[line - 1];\n let lineData = '';\n\n if (lineSource) {\n const pad = ' '.repeat(column);\n lineData = '\\n\\n' + lineSource + '\\n' + pad + '^\\n';\n }\n\n throw new SyntaxError(\n `${lineData}Unexpected token: \"${symbol}\" ` + `at ${line}:${column}.`\n );\n }", "title": "" }, { "docid": "3f0864f93ca88175664026a2f6112bc8", "score": "0.5778351", "text": "unexpectedTokenError(token, message) {\n let msg = message || messages_1.Messages.UnexpectedToken;\n let value;\n if (token) {\n if (!message) {\n msg = (token.type === 2 /* EOF */) ? messages_1.Messages.UnexpectedEOS :\n (token.type === 3 /* Identifier */) ? messages_1.Messages.UnexpectedIdentifier :\n (token.type === 6 /* NumericLiteral */) ? messages_1.Messages.UnexpectedNumber :\n (token.type === 8 /* StringLiteral */) ? messages_1.Messages.UnexpectedString :\n (token.type === 10 /* Template */) ? messages_1.Messages.UnexpectedTemplate :\n messages_1.Messages.UnexpectedToken;\n if (token.type === 4 /* Keyword */) {\n if (this.scanner.isFutureReservedWord(token.value)) {\n msg = messages_1.Messages.UnexpectedReserved;\n }\n else if (this.context.strict && this.scanner.isStrictModeReservedWord(token.value)) {\n msg = messages_1.Messages.StrictReservedWord;\n }\n }\n }\n value = token.value;\n }\n else {\n value = 'ILLEGAL';\n }\n msg = msg.replace('%0', value);\n if (token && typeof token.lineNumber === 'number') {\n const index = token.start;\n const line = token.lineNumber;\n const lastMarkerLineStart = this.lastMarker.index - this.lastMarker.column;\n const column = token.start - lastMarkerLineStart + 1;\n return this.errorHandler.createError(index, line, column, msg);\n }\n else {\n const index = this.lastMarker.index;\n const line = this.lastMarker.line;\n const column = this.lastMarker.column + 1;\n return this.errorHandler.createError(index, line, column, msg);\n }\n }", "title": "" }, { "docid": "7a1608336f966b75b724864cdfd131a0", "score": "0.57713336", "text": "function expect(c) {\n if (!accept(c)) {\n if (pos >= input.length)\n throw errorMsg(\"Expected \" + c + \", found end of input\");\n throw errorMsg(\"Expected \" + c + \", found \" + input[pos]);\n }\n }", "title": "" }, { "docid": "a073de1e259c781c01e91a5122d70b05", "score": "0.56916636", "text": "function unexpectedTokenError(token, message) {\n\t var value, msg = message || Messages.UnexpectedToken;\n\n\t if (token) {\n\t if (!message) {\n\t msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n\t (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n\t (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n\t (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n\t (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n\t Messages.UnexpectedToken;\n\n\t if (token.type === Token.Keyword) {\n\t if (isFutureReservedWord(token.value)) {\n\t msg = Messages.UnexpectedReserved;\n\t } else if (strict && isStrictModeReservedWord(token.value)) {\n\t msg = Messages.StrictReservedWord;\n\t }\n\t }\n\t }\n\n\t value = (token.type === Token.Template) ? token.value.raw : token.value;\n\t } else {\n\t value = 'ILLEGAL';\n\t }\n\n\t msg = msg.replace('%0', value);\n\n\t return (token && typeof token.lineNumber === 'number') ?\n\t createError(token.lineNumber, token.start, msg) :\n\t createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n\t }", "title": "" }, { "docid": "a073de1e259c781c01e91a5122d70b05", "score": "0.56916636", "text": "function unexpectedTokenError(token, message) {\n\t var value, msg = message || Messages.UnexpectedToken;\n\n\t if (token) {\n\t if (!message) {\n\t msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n\t (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n\t (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n\t (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n\t (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n\t Messages.UnexpectedToken;\n\n\t if (token.type === Token.Keyword) {\n\t if (isFutureReservedWord(token.value)) {\n\t msg = Messages.UnexpectedReserved;\n\t } else if (strict && isStrictModeReservedWord(token.value)) {\n\t msg = Messages.StrictReservedWord;\n\t }\n\t }\n\t }\n\n\t value = (token.type === Token.Template) ? token.value.raw : token.value;\n\t } else {\n\t value = 'ILLEGAL';\n\t }\n\n\t msg = msg.replace('%0', value);\n\n\t return (token && typeof token.lineNumber === 'number') ?\n\t createError(token.lineNumber, token.start, msg) :\n\t createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n\t }", "title": "" }, { "docid": "ba07ce4c759ed128af3e8fa3cb8e6aae", "score": "0.568915", "text": "function quit(code, line, chr) {\n\t\tvar percentage = Math.floor((line / state.lines.length) * 100);\n\t\tvar message = messages.errors[code].desc;\n\n\t\tthrow {\n\t\t\tname: \"JSHintError\",\n\t\t\tline: line,\n\t\t\tcharacter: chr,\n\t\t\tmessage: message + \" (\" + percentage + \"% scanned).\",\n\t\t\traw: message,\n\t\t\tcode: code\n\t\t};\n\t}", "title": "" }, { "docid": "72fdbf48d863be2af8b10d6441d8bc4e", "score": "0.56815845", "text": "function catchErrors(error){\nconsole.log(\"\\007\");\nconsole.log(error);\n}", "title": "" }, { "docid": "84d2008d6511ab45796fd011a3c89996", "score": "0.5645348", "text": "function unexpected(lexer, atToken) {\n\t var token = atToken || lexer.token;\n\t return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n\t}", "title": "" }, { "docid": "61312e73d14a7fdf57d6891a460433d2", "score": "0.56191045", "text": "function throwUnexpected(token, expected) {\n\n\t\tif (expected === undefined)\n\t\t\texpected = '';\n\t\telse\n\t\t\texpected = ', expected ' + expected;\n\t\tif (token.type === Token.EOF)\n\t\t\tthrowError(token, Messages.UnexpectedEOS + expected);\n\n\t\tif (token.type === Token.NumericLiteral)\n\t\t\tthrowError(token, Messages.UnexpectedNumber + expected);\n\n\t\tif (token.type === Token.StringLiteral)\n\t\t\tthrowError(token, Messages.UnexpectedString + expected);\n\n\t\tif (token.type === Token.Identifier)\n\t\t\tthrowError(token, Messages.UnexpectedIdentifier + expected);\n\n\t\tif (token.type === Token.Keyword) {\n\t\t\tif (isFutureReservedWord(token.value))\n\t\t\t\tthrowError(token, Messages.UnexpectedReserved + expected);\n\t\t\tthrowError(\n\t\t\t\ttoken, Messages.UnexpectedToken + expected, token.value\n\t\t\t);\n\t\t}\n\n\t\tif (token.type === Token.Template)\n\t\t\tthrowError(\n\t\t\t\ttoken, Messages.UnexpectedTemplate + expected, token.value.raw\n\t\t\t);\n\n\t\tif (token.type === Token.SymbolLiteral)\n\t\t\tthrowError(token, Messages.UnexpectedSymbol + expected);\n\n\t\t// BooleanLiteral, NilLiteral, or Punctuator.\n\t\tthrowError(token, Messages.UnexpectedToken + expected, token.value);\n\n\t}", "title": "" }, { "docid": "f49a02226cd5d9fe9f9346bd2c177178", "score": "0.5611609", "text": "function quit(code, line, chr) {\r\t\tvar percentage = Math.floor((line / state.lines.length) * 100);\r\t\tvar message = messages.errors[code].desc;\r\r\t\tthrow {\r\t\t\tname: \"JSHintError\",\r\t\t\tline: line,\r\t\t\tcharacter: chr,\r\t\t\tmessage: message + \" (\" + percentage + \"% scanned).\",\r\t\t\traw: message,\r\t\t\tcode: code\r\t\t};\r\t}", "title": "" }, { "docid": "6be7d4f1ec5a3a31dc0ea2832ba86865", "score": "0.5608026", "text": "function throwUnexpected(token) {\n\t if (token.type === Token.EOF) {\n\t throwError(token, Messages.UnexpectedEOS);\n\t }\n\t\n\t if (token.type === Token.NumericLiteral) {\n\t throwError(token, Messages.UnexpectedNumber);\n\t }\n\t\n\t if (token.type === Token.StringLiteral) {\n\t throwError(token, Messages.UnexpectedString);\n\t }\n\t\n\t if (token.type === Token.Identifier) {\n\t throwError(token, Messages.UnexpectedIdentifier);\n\t }\n\t\n\t if (token.type === Token.Keyword) {\n\t if (isFutureReservedWord(token.value)) {\n\t throwError(token, Messages.UnexpectedReserved);\n\t } else if (strict && isStrictModeReservedWord(token.value)) {\n\t throwErrorTolerant(token, Messages.StrictReservedWord);\n\t return;\n\t }\n\t throwError(token, Messages.UnexpectedToken, token.value);\n\t }\n\t\n\t // BooleanLiteral, NullLiteral, or Punctuator.\n\t throwError(token, Messages.UnexpectedToken, token.value);\n\t }", "title": "" }, { "docid": "6be7d4f1ec5a3a31dc0ea2832ba86865", "score": "0.5608026", "text": "function throwUnexpected(token) {\n\t if (token.type === Token.EOF) {\n\t throwError(token, Messages.UnexpectedEOS);\n\t }\n\t\n\t if (token.type === Token.NumericLiteral) {\n\t throwError(token, Messages.UnexpectedNumber);\n\t }\n\t\n\t if (token.type === Token.StringLiteral) {\n\t throwError(token, Messages.UnexpectedString);\n\t }\n\t\n\t if (token.type === Token.Identifier) {\n\t throwError(token, Messages.UnexpectedIdentifier);\n\t }\n\t\n\t if (token.type === Token.Keyword) {\n\t if (isFutureReservedWord(token.value)) {\n\t throwError(token, Messages.UnexpectedReserved);\n\t } else if (strict && isStrictModeReservedWord(token.value)) {\n\t throwErrorTolerant(token, Messages.StrictReservedWord);\n\t return;\n\t }\n\t throwError(token, Messages.UnexpectedToken, token.value);\n\t }\n\t\n\t // BooleanLiteral, NullLiteral, or Punctuator.\n\t throwError(token, Messages.UnexpectedToken, token.value);\n\t }", "title": "" }, { "docid": "b39311764ac7d8e60477aa734be2ce98", "score": "0.5607048", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "b39311764ac7d8e60477aa734be2ce98", "score": "0.5607048", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "b39311764ac7d8e60477aa734be2ce98", "score": "0.5607048", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "b39311764ac7d8e60477aa734be2ce98", "score": "0.5607048", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "b39311764ac7d8e60477aa734be2ce98", "score": "0.5607048", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "b39311764ac7d8e60477aa734be2ce98", "score": "0.5607048", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "b39311764ac7d8e60477aa734be2ce98", "score": "0.5607048", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "1c090153cab93029926182bb25ad5511", "score": "0.560384", "text": "function quit(code, line, chr) {\n var percentage = Math.floor((line / state.lines.length) * 100);\n var message = messages.errors[code].desc;\n\n throw {\n name: \"JSHintError\",\n line: line,\n character: chr,\n message: message + \" (\" + percentage + \"% scanned).\",\n raw: message,\n code: code\n };\n }", "title": "" }, { "docid": "1c090153cab93029926182bb25ad5511", "score": "0.560384", "text": "function quit(code, line, chr) {\n var percentage = Math.floor((line / state.lines.length) * 100);\n var message = messages.errors[code].desc;\n\n throw {\n name: \"JSHintError\",\n line: line,\n character: chr,\n message: message + \" (\" + percentage + \"% scanned).\",\n raw: message,\n code: code\n };\n }", "title": "" }, { "docid": "f2238170d5d8d6a00e016e43052cf550", "score": "0.55901885", "text": "function unexpectedTokenError(token, message) {\n var value, msg = message || Messages.UnexpectedToken;\n\n if (token) {\n if (!message) {\n msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS :\n (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier :\n (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber :\n (token.type === Token.StringLiteral) ? Messages.UnexpectedString :\n (token.type === Token.Template) ? Messages.UnexpectedTemplate :\n Messages.UnexpectedToken;\n\n if (token.type === Token.Keyword) {\n if (future && isFutureReservedWord(token.value)) {\n msg = Messages.UnexpectedReserved;\n } else if (strict && isStrictModeReservedWord(token.value)) {\n msg = Messages.StrictReservedWord;\n }\n }\n }\n\n value = (token.type === Token.Template) ? token.value.raw : token.value;\n } else {\n value = 'ILLEGAL';\n }\n\n msg = msg.replace('%0', value);\n\n return (token && typeof token.lineNumber === 'number') ?\n createError(token.lineNumber, token.start, msg) :\n createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);\n }", "title": "" }, { "docid": "3c1f2685705eafc279e5e5e3e25f32c5", "score": "0.5589681", "text": "function quit(code, line, chr) {\n\t var percentage = Math.floor((line / state.lines.length) * 100);\n\t var message = messages.errors[code].desc;\n\n\t throw {\n\t name: \"JSHintError\",\n\t line: line,\n\t character: chr,\n\t message: message + \" (\" + percentage + \"% scanned).\",\n\t raw: message,\n\t code: code\n\t };\n\t }", "title": "" }, { "docid": "0fa303499fa97d817f9e4857974e1bd1", "score": "0.5588403", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return syntaxError(lexer.source, token.start, \"Unexpected \".concat(getTokenDesc(token)));\n }", "title": "" }, { "docid": "eaf81f7eeece4caca06f21bfa796a865", "score": "0.55474335", "text": "function throwUnexpected(token) {\n\t if (token.type === Token.EOF) {\n\t throwError(token, Messages.UnexpectedEOS);\n\t }\n\n\t if (token.type === Token.NumericLiteral) {\n\t throwError(token, Messages.UnexpectedNumber);\n\t }\n\n\t if (token.type === Token.StringLiteral || token.type === Token.JSXText) {\n\t throwError(token, Messages.UnexpectedString);\n\t }\n\n\t if (token.type === Token.Identifier) {\n\t throwError(token, Messages.UnexpectedIdentifier);\n\t }\n\n\t if (token.type === Token.Keyword) {\n\t if (isFutureReservedWord(token.value)) {\n\t throwError(token, Messages.UnexpectedReserved);\n\t } else if (strict && isStrictModeReservedWord(token.value)) {\n\t throwErrorTolerant(token, Messages.StrictReservedWord);\n\t return;\n\t }\n\t throwError(token, Messages.UnexpectedToken, token.value);\n\t }\n\n\t if (token.type === Token.Template) {\n\t throwError(token, Messages.UnexpectedTemplate, token.value.raw);\n\t }\n\n\t // BooleanLiteral, NullLiteral, or Punctuator.\n\t throwError(token, Messages.UnexpectedToken, token.value);\n\t }", "title": "" }, { "docid": "dcff21afb435bf4dece779d91e46ab16", "score": "0.5541314", "text": "function reportSyntaxError(self) {\n callback(self._syntaxError(/^\\S*/.exec(input)[0]));\n }", "title": "" }, { "docid": "dcff21afb435bf4dece779d91e46ab16", "score": "0.5541314", "text": "function reportSyntaxError(self) {\n callback(self._syntaxError(/^\\S*/.exec(input)[0]));\n }", "title": "" }, { "docid": "6d8c2b397fe447107b100c880060fb8f", "score": "0.5540009", "text": "function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }", "title": "" }, { "docid": "6d8c2b397fe447107b100c880060fb8f", "score": "0.5540009", "text": "function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }", "title": "" }, { "docid": "6d8c2b397fe447107b100c880060fb8f", "score": "0.5540009", "text": "function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }", "title": "" }, { "docid": "6d8c2b397fe447107b100c880060fb8f", "score": "0.5540009", "text": "function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }", "title": "" }, { "docid": "6d8c2b397fe447107b100c880060fb8f", "score": "0.5540009", "text": "function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }", "title": "" }, { "docid": "6d8c2b397fe447107b100c880060fb8f", "score": "0.5540009", "text": "function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }", "title": "" }, { "docid": "6d8c2b397fe447107b100c880060fb8f", "score": "0.5540009", "text": "function reportSyntaxError(self) { callback(self._syntaxError(/^\\S*/.exec(input)[0])); }", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "6d49967d893d55c6da042ae6b0fc8166", "score": "0.5519573", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n}", "title": "" }, { "docid": "a20b2daeef75ad59c9fa692da5fca01f", "score": "0.5513736", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, \"Unexpected \".concat((0, _lexer.getTokenDesc)(token)));\n}", "title": "" }, { "docid": "a20b2daeef75ad59c9fa692da5fca01f", "score": "0.5513736", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, \"Unexpected \".concat((0, _lexer.getTokenDesc)(token)));\n}", "title": "" }, { "docid": "a20b2daeef75ad59c9fa692da5fca01f", "score": "0.5513736", "text": "function unexpected(lexer, atToken) {\n var token = atToken || lexer.token;\n return (0, _error.syntaxError)(lexer.source, token.start, \"Unexpected \".concat((0, _lexer.getTokenDesc)(token)));\n}", "title": "" }, { "docid": "caad3105a691b6e238e9888fee352807", "score": "0.5504611", "text": "function raiseUnexpectedToken(type, token) {\n raise(token, errors.expectedToken, type, token.value);\n }", "title": "" }, { "docid": "a0472bf3c47b39eb0a735ab213a104fa", "score": "0.5472269", "text": "function unexpected(parser, atToken) {\n\t var token = atToken || parser.token;\n\t return (0, _error.syntaxError)(parser.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));\n\t}", "title": "" }, { "docid": "4f7f6666617679f9386239d3923cecb5", "score": "0.5470737", "text": "function throwUnexpected(token) {\n if (token.type === Token.EOF) {\n throwError(token, Messages.UnexpectedEOS);\n }\n\n if (token.type === Token.NumericLiteral) {\n throwError(token, Messages.UnexpectedNumber);\n }\n\n if (token.type === Token.StringLiteral) {\n throwError(token, Messages.UnexpectedString);\n }\n\n if (token.type === Token.Identifier) {\n throwError(token, Messages.UnexpectedIdentifier);\n }\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n throwError(token, Messages.UnexpectedReserved);\n } else if (strict && isStrictModeReservedWord(token.value)) {\n throwErrorTolerant(token, Messages.StrictReservedWord);\n return;\n }\n throwError(token, Messages.UnexpectedToken, token.value);\n }\n\n // BooleanLiteral, NullLiteral, or Punctuator.\n throwError(token, Messages.UnexpectedToken, token.value);\n }", "title": "" }, { "docid": "20eac7804fb534a33bb1795b4d3da3cb", "score": "0.545007", "text": "function throwUnexpected(token) {\n if (token.type === Token.EOF) {\n throwError(token, Messages.UnexpectedEOS);\n }\n\n if (token.type === Token.NumericLiteral) {\n throwError(token, Messages.UnexpectedNumber);\n }\n\n if (token.type === Token.StringLiteral || token.type === Token.JSXText) {\n throwError(token, Messages.UnexpectedString);\n }\n\n if (token.type === Token.Identifier) {\n throwError(token, Messages.UnexpectedIdentifier);\n }\n\n if (token.type === Token.Keyword) {\n if (isFutureReservedWord(token.value)) {\n throwError(token, Messages.UnexpectedReserved);\n } else if (strict && isStrictModeReservedWord(token.value)) {\n throwErrorTolerant(token, Messages.StrictReservedWord);\n return;\n }\n throwError(token, Messages.UnexpectedToken, token.value);\n }\n\n if (token.type === Token.Template) {\n throwError(token, Messages.UnexpectedTemplate, token.value.raw);\n }\n\n // BooleanLiteral, NullLiteral, or Punctuator.\n throwError(token, Messages.UnexpectedToken, token.value);\n }", "title": "" } ]
5fa7db9c09d8c01644c3888d051ff5c2
Fixes a Gecko bug where the style attribute gets added to the wrong element when deleting between two block elements. Fixes do backspace/delete on this: bla[ckr]ed Would become: bla|ed Instead of: bla|ed
[ { "docid": "6cec888b46ab73b38eb08bb155606955", "score": "0.65652734", "text": "function removeStylesWhenDeletingAcrossBlockElements() {\n\t\t\tfunction getAttributeApplyFunction() {\n\t\t\t\tvar template = dom.getAttribs(selection.getStart().cloneNode(false));\n\n\t\t\t\treturn function() {\n\t\t\t\t\tvar target = selection.getStart();\n\n\t\t\t\t\tif (target !== editor.getBody()) {\n\t\t\t\t\t\tdom.setAttrib(target, \"style\", null);\n\n\t\t\t\t\t\teach(template, function(attr) {\n\t\t\t\t\t\t\ttarget.setAttributeNode(attr.cloneNode(true));\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tfunction isSelectionAcrossElements() {\n\t\t\t\treturn !selection.isCollapsed() &&\n\t\t\t\t\tdom.getParent(selection.getStart(), dom.isBlock) != dom.getParent(selection.getEnd(), dom.isBlock);\n\t\t\t}\n\n\t\t\teditor.on('keypress', function(e) {\n\t\t\t\tvar applyAttributes;\n\n\t\t\t\tif (!isDefaultPrevented(e) && (e.keyCode == 8 || e.keyCode == 46) && isSelectionAcrossElements()) {\n\t\t\t\t\tapplyAttributes = getAttributeApplyFunction();\n\t\t\t\t\teditor.getDoc().execCommand('delete', false, null);\n\t\t\t\t\tapplyAttributes();\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdom.bind(editor.getDoc(), 'cut', function(e) {\n\t\t\t\tvar applyAttributes;\n\n\t\t\t\tif (!isDefaultPrevented(e) && isSelectionAcrossElements()) {\n\t\t\t\t\tapplyAttributes = getAttributeApplyFunction();\n\n\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\tapplyAttributes();\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" } ]
[ { "docid": "f6012be3c87213df516f1b6ed5eb86a4", "score": "0.65620387", "text": "function removeStylesWhenDeletingAcrossBlockElements() {\n\t\t\tfunction getAttributeApplyFunction() {\n\t\t\t\tvar template = dom.getAttribs(selection.getStart().cloneNode(false));\n\n\t\t\t\treturn function() {\n\t\t\t\t\tvar target = selection.getStart();\n\n\t\t\t\t\tif (target !== editor.getBody()) {\n\t\t\t\t\t\tdom.setAttrib(target, \"style\", null);\n\n\t\t\t\t\t\teach(template, function(attr) {\n\t\t\t\t\t\t\ttarget.setAttributeNode(attr.cloneNode(true));\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tfunction isSelectionAcrossElements() {\n\t\t\t\treturn !selection.isCollapsed() &&\n\t\t\t\t\tdom.getParent(selection.getStart(), dom.isBlock) != dom.getParent(selection.getEnd(), dom.isBlock);\n\t\t\t}\n\n\t\t\teditor.on('keypress', function(e) {\n\t\t\t\tvar applyAttributes;\n\n\t\t\t\tif (!isDefaultPrevented(e) && (e.keyCode == 8 || e.keyCode == 46) && isSelectionAcrossElements()) {\n\t\t\t\t\tapplyAttributes = getAttributeApplyFunction();\n\t\t\t\t\teditor.getDoc().execCommand('delete', false, null);\n\t\t\t\t\tapplyAttributes();\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdom.bind(editor.getDoc(), 'cut', function(e) {\n\t\t\t\tvar applyAttributes;\n\n\t\t\t\tif (!isDefaultPrevented(e) && isSelectionAcrossElements()) {\n\t\t\t\t\tapplyAttributes = getAttributeApplyFunction();\n\n\t\t\t\t\tDelay.setEditorTimeout(editor, function() {\n\t\t\t\t\t\tapplyAttributes();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "f6012be3c87213df516f1b6ed5eb86a4", "score": "0.65620387", "text": "function removeStylesWhenDeletingAcrossBlockElements() {\n\t\t\tfunction getAttributeApplyFunction() {\n\t\t\t\tvar template = dom.getAttribs(selection.getStart().cloneNode(false));\n\n\t\t\t\treturn function() {\n\t\t\t\t\tvar target = selection.getStart();\n\n\t\t\t\t\tif (target !== editor.getBody()) {\n\t\t\t\t\t\tdom.setAttrib(target, \"style\", null);\n\n\t\t\t\t\t\teach(template, function(attr) {\n\t\t\t\t\t\t\ttarget.setAttributeNode(attr.cloneNode(true));\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tfunction isSelectionAcrossElements() {\n\t\t\t\treturn !selection.isCollapsed() &&\n\t\t\t\t\tdom.getParent(selection.getStart(), dom.isBlock) != dom.getParent(selection.getEnd(), dom.isBlock);\n\t\t\t}\n\n\t\t\teditor.on('keypress', function(e) {\n\t\t\t\tvar applyAttributes;\n\n\t\t\t\tif (!isDefaultPrevented(e) && (e.keyCode == 8 || e.keyCode == 46) && isSelectionAcrossElements()) {\n\t\t\t\t\tapplyAttributes = getAttributeApplyFunction();\n\t\t\t\t\teditor.getDoc().execCommand('delete', false, null);\n\t\t\t\t\tapplyAttributes();\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tdom.bind(editor.getDoc(), 'cut', function(e) {\n\t\t\t\tvar applyAttributes;\n\n\t\t\t\tif (!isDefaultPrevented(e) && isSelectionAcrossElements()) {\n\t\t\t\t\tapplyAttributes = getAttributeApplyFunction();\n\n\t\t\t\t\tDelay.setEditorTimeout(editor, function() {\n\t\t\t\t\t\tapplyAttributes();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "6a425863da9801e7ec558a27e0ded5b5", "score": "0.61391664", "text": "function cleanupStylesWhenDeleting() {\n\t\t\tvar doc = editor.getDoc(), dom = editor.dom, selection = editor.selection;\n\t\t\tvar MutationObserver = window.MutationObserver, olderWebKit, dragStartRng;\n\n\t\t\t// Add mini polyfill for older WebKits\n\t\t\t// TODO: Remove this when old Safari versions gets updated\n\t\t\tif (!MutationObserver) {\n\t\t\t\tolderWebKit = true;\n\n\t\t\t\tMutationObserver = function() {\n\t\t\t\t\tvar records = [], target;\n\n\t\t\t\t\tfunction nodeInsert(e) {\n\t\t\t\t\t\tvar target = e.relatedNode || e.target;\n\t\t\t\t\t\trecords.push({target: target, addedNodes: [target]});\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction attrModified(e) {\n\t\t\t\t\t\tvar target = e.relatedNode || e.target;\n\t\t\t\t\t\trecords.push({target: target, attributeName: e.attrName});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.observe = function(node) {\n\t\t\t\t\t\ttarget = node;\n\t\t\t\t\t\ttarget.addEventListener('DOMSubtreeModified', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMNodeInsertedIntoDocument', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMNodeInserted', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMAttrModified', attrModified, false);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.disconnect = function() {\n\t\t\t\t\t\ttarget.removeEventListener('DOMSubtreeModified', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMNodeInsertedIntoDocument', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMNodeInserted', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMAttrModified', attrModified, false);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.takeRecords = function() {\n\t\t\t\t\t\treturn records;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tfunction isTrailingBr(node) {\n\t\t\t\tvar blockElements = dom.schema.getBlockElements(), rootNode = editor.getBody();\n\n\t\t\t\tif (node.nodeName != 'BR') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tfor (node = node; node != rootNode && !blockElements[node.nodeName]; node = node.parentNode) {\n\t\t\t\t\tif (node.nextSibling) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction isSiblingsIgnoreWhiteSpace(node1, node2) {\n\t\t\t\tvar node;\n\n\t\t\t\tfor (node = node1.nextSibling; node && node != node2; node = node.nextSibling) {\n\t\t\t\t\tif (node.nodeType == 3 && $.trim(node.data).length === 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (node !== node2) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn node === node2;\n\t\t\t}\n\n\t\t\tfunction findCaretNode(node, forward, startNode) {\n\t\t\t\tvar walker, current, nonEmptyElements;\n\n\t\t\t\tnonEmptyElements = dom.schema.getNonEmptyElements();\n\n\t\t\t\twalker = new TreeWalker(startNode || node, node);\n\n\t\t\t\twhile ((current = walker[forward ? 'next' : 'prev']())) {\n\t\t\t\t\tif (nonEmptyElements[current.nodeName] && !isTrailingBr(current)) {\n\t\t\t\t\t\treturn current;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (current.nodeType == 3 && current.data.length > 0) {\n\t\t\t\t\t\treturn current;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction deleteRangeBetweenTextBlocks(rng) {\n\t\t\t\tvar startBlock, endBlock, caretNodeBefore, caretNodeAfter, textBlockElements;\n\n\t\t\t\tif (rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tstartBlock = dom.getParent(RangeUtils.getNode(rng.startContainer, rng.startOffset), dom.isBlock);\n\t\t\t\tendBlock = dom.getParent(RangeUtils.getNode(rng.endContainer, rng.endOffset), dom.isBlock);\n\t\t\t\ttextBlockElements = editor.schema.getTextBlockElements();\n\n\t\t\t\tif (startBlock == endBlock) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!textBlockElements[startBlock.nodeName] || !textBlockElements[endBlock.nodeName]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (dom.getContentEditable(startBlock) === \"false\" || dom.getContentEditable(endBlock) === \"false\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trng.deleteContents();\n\n\t\t\t\tcaretNodeBefore = findCaretNode(startBlock, false);\n\t\t\t\tcaretNodeAfter = findCaretNode(endBlock, true);\n\n\t\t\t\tif (!dom.isEmpty(endBlock)) {\n\t\t\t\t\t$(startBlock).append(endBlock.childNodes);\n\t\t\t\t}\n\n\t\t\t\t$(endBlock).remove();\n\n\t\t\t\tif (caretNodeBefore) {\n\t\t\t\t\tif (caretNodeBefore.nodeType == 1) {\n\t\t\t\t\t\tif (caretNodeBefore.nodeName == \"BR\") {\n\t\t\t\t\t\t\trng.setStartBefore(caretNodeBefore);\n\t\t\t\t\t\t\trng.setEndBefore(caretNodeBefore);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStartAfter(caretNodeBefore);\n\t\t\t\t\t\t\trng.setEndAfter(caretNodeBefore);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trng.setStart(caretNodeBefore, caretNodeBefore.data.length);\n\t\t\t\t\t\trng.setEnd(caretNodeBefore, caretNodeBefore.data.length);\n\t\t\t\t\t}\n\t\t\t\t} else if (caretNodeAfter) {\n\t\t\t\t\tif (caretNodeAfter.nodeType == 1) {\n\t\t\t\t\t\trng.setStartBefore(caretNodeAfter);\n\t\t\t\t\t\trng.setEndBefore(caretNodeAfter);\n\t\t\t\t\t} else {\n\t\t\t\t\t\trng.setStart(caretNodeAfter, 0);\n\t\t\t\t\t\trng.setEnd(caretNodeAfter, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tselection.setRng(rng);\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction expandBetweenBlocks(rng, isForward) {\n\t\t\t\tvar caretNode, targetCaretNode, textBlock, targetTextBlock, container, offset;\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn rng;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\n\t\t\t\tif (container.nodeType == 3) {\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset < container.data.length) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset > 0) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcaretNode = RangeUtils.getNode(rng.startContainer, rng.startOffset);\n\t\t\t\ttextBlock = dom.getParent(caretNode, dom.isBlock);\n\t\t\t\ttargetCaretNode = findCaretNode(editor.getBody(), isForward, caretNode);\n\t\t\t\ttargetTextBlock = dom.getParent(targetCaretNode, dom.isBlock);\n\n\t\t\t\tif (!caretNode || !targetCaretNode) {\n\t\t\t\t\treturn rng;\n\t\t\t\t}\n\n\t\t\t\tif (targetTextBlock && textBlock != targetTextBlock) {\n\t\t\t\t\tif (!isForward) {\n\t\t\t\t\t\tif (!isSiblingsIgnoreWhiteSpace(targetTextBlock, textBlock)) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (targetCaretNode.nodeType == 1) {\n\t\t\t\t\t\t\tif (targetCaretNode.nodeName == \"BR\") {\n\t\t\t\t\t\t\t\trng.setStartBefore(targetCaretNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trng.setStartAfter(targetCaretNode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStart(targetCaretNode, targetCaretNode.data.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (caretNode.nodeType == 1) {\n\t\t\t\t\t\t\trng.setEnd(caretNode, 0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setEndBefore(caretNode);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!isSiblingsIgnoreWhiteSpace(textBlock, targetTextBlock)) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (caretNode.nodeType == 1) {\n\t\t\t\t\t\t\tif (caretNode.nodeName == \"BR\") {\n\t\t\t\t\t\t\t\trng.setStartBefore(caretNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trng.setStartAfter(caretNode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStart(caretNode, caretNode.data.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (targetCaretNode.nodeType == 1) {\n\t\t\t\t\t\t\trng.setEnd(targetCaretNode, 0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setEndBefore(targetCaretNode);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn rng;\n\t\t\t}\n\n\t\t\tfunction handleTextBlockMergeDelete(isForward) {\n\t\t\t\tvar rng = selection.getRng();\n\n\t\t\t\trng = expandBetweenBlocks(rng, isForward);\n\n\t\t\t\tif (deleteRangeBetweenTextBlocks(rng)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * This retains the formatting if the last character is to be deleted.\n\t\t\t *\n\t\t\t * Backspace on this: <p><b><i>a|</i></b></p> would become <p>|</p> in WebKit.\n\t\t\t * With this patch: <p><b><i>|<br></i></b></p>\n\t\t\t */\n\t\t\tfunction handleLastBlockCharacterDelete(isForward, rng) {\n\t\t\t\tvar path, blockElm, newBlockElm, clonedBlockElm, sibling,\n\t\t\t\t\tcontainer, offset, br, currentFormatNodes;\n\n\t\t\t\tfunction cloneTextBlockWithFormats(blockElm, node) {\n\t\t\t\t\tcurrentFormatNodes = $(node).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tnewBlockElm = blockElm.cloneNode(false);\n\n\t\t\t\t\tcurrentFormatNodes = Tools.map(currentFormatNodes, function(formatNode) {\n\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\tif (newBlockElm.hasChildNodes()) {\n\t\t\t\t\t\t\tformatNode.appendChild(newBlockElm.firstChild);\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\n\t\t\t\t\t\treturn formatNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tbr = dom.create('br');\n\t\t\t\t\t\tcurrentFormatNodes[0].appendChild(br);\n\t\t\t\t\t\tdom.replace(newBlockElm, blockElm);\n\n\t\t\t\t\t\trng.setStartBefore(br);\n\t\t\t\t\t\trng.setEndBefore(br);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\n\t\t\t\t\t\treturn br;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tfunction isTextBlock(node) {\n\t\t\t\t\treturn node && editor.schema.getTextBlockElements()[node.tagName];\n\t\t\t\t}\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\tblockElm = dom.getParent(container, dom.isBlock);\n\t\t\t\tif (!isTextBlock(blockElm)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (container.nodeType == 1) {\n\t\t\t\t\tcontainer = container.childNodes[offset];\n\t\t\t\t\tif (container && container.tagName != 'BR') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tsibling = blockElm.nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsibling = blockElm.previousSibling;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(blockElm) && isTextBlock(sibling) && dom.isEmpty(sibling)) {\n\t\t\t\t\t\tif (cloneTextBlockWithFormats(blockElm, container)) {\n\t\t\t\t\t\t\tdom.remove(sibling);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (container.nodeType == 3) {\n\t\t\t\t\tpath = NodePath.create(blockElm, container);\n\t\t\t\t\tclonedBlockElm = blockElm.cloneNode(true);\n\t\t\t\t\tcontainer = NodePath.resolve(clonedBlockElm, path);\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset >= container.data.length) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset, 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset <= 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(clonedBlockElm)) {\n\t\t\t\t\t\treturn cloneTextBlockWithFormats(blockElm, container);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction customDelete(isForward) {\n\t\t\t\tvar mutationObserver, rng, caretElement;\n\n\t\t\t\tif (handleTextBlockMergeDelete(isForward)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tTools.each(editor.getBody().getElementsByTagName('*'), function(elm) {\n\t\t\t\t\t// Mark existing spans\n\t\t\t\t\tif (elm.tagName == 'SPAN') {\n\t\t\t\t\t\telm.setAttribute('mce-data-marked', 1);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Make sure all elements has a data-mce-style attribute\n\t\t\t\t\tif (!elm.hasAttribute('data-mce-style') && elm.hasAttribute('style')) {\n\t\t\t\t\t\teditor.dom.setAttrib(elm, 'style', editor.dom.getAttrib(elm, 'style'));\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// Observe added nodes and style attribute changes\n\t\t\t\tmutationObserver = new MutationObserver(function() {});\n\t\t\t\tmutationObserver.observe(editor.getDoc(), {\n\t\t\t\t\tchildList: true,\n\t\t\t\t\tattributes: true,\n\t\t\t\t\tsubtree: true,\n\t\t\t\t\tattributeFilter: ['style']\n\t\t\t\t});\n\n\t\t\t\teditor.getDoc().execCommand(isForward ? 'ForwardDelete' : 'Delete', false, null);\n\n\t\t\t\trng = editor.selection.getRng();\n\t\t\t\tcaretElement = rng.startContainer.parentNode;\n\n\t\t\t\tTools.each(mutationObserver.takeRecords(), function(record) {\n\t\t\t\t\tif (!dom.isChildOf(record.target, editor.getBody())) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Restore style attribute to previous value\n\t\t\t\t\tif (record.attributeName == \"style\") {\n\t\t\t\t\t\tvar oldValue = record.target.getAttribute('data-mce-style');\n\n\t\t\t\t\t\tif (oldValue) {\n\t\t\t\t\t\t\trecord.target.setAttribute(\"style\", oldValue);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trecord.target.removeAttribute(\"style\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Remove all spans that isn't maked and retain selection\n\t\t\t\t\tTools.each(record.addedNodes, function(node) {\n\t\t\t\t\t\tif (node.nodeName == \"SPAN\" && !node.getAttribute('mce-data-marked')) {\n\t\t\t\t\t\t\tvar offset, container;\n\n\t\t\t\t\t\t\tif (node == caretElement) {\n\t\t\t\t\t\t\t\toffset = rng.startOffset;\n\t\t\t\t\t\t\t\tcontainer = node.firstChild;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tdom.remove(node, true);\n\n\t\t\t\t\t\t\tif (container) {\n\t\t\t\t\t\t\t\trng.setStart(container, offset);\n\t\t\t\t\t\t\t\trng.setEnd(container, offset);\n\t\t\t\t\t\t\t\teditor.selection.setRng(rng);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tmutationObserver.disconnect();\n\n\t\t\t\t// Remove any left over marks\n\t\t\t\tTools.each(editor.dom.select('span[mce-data-marked]'), function(span) {\n\t\t\t\t\tspan.removeAttribute('mce-data-marked');\n\t\t\t\t});\n\t\t\t}\n\n\t\t\teditor.on('keydown', function(e) {\n\t\t\t\tvar isForward = e.keyCode == DELETE, isMetaOrCtrl = e.ctrlKey || e.metaKey;\n\n\t\t\t\tif (!isDefaultPrevented(e) && (isForward || e.keyCode == BACKSPACE)) {\n\t\t\t\t\tvar rng = editor.selection.getRng(), container = rng.startContainer, offset = rng.startOffset;\n\n\t\t\t\t\t// Shift+Delete is cut\n\t\t\t\t\tif (isForward && e.shiftKey) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (handleLastBlockCharacterDelete(isForward, rng)) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ignore non meta delete in the where there is text before/after the caret\n\t\t\t\t\tif (!isMetaOrCtrl && rng.collapsed && container.nodeType == 3) {\n\t\t\t\t\t\tif (isForward ? offset < container.data.length : offset > 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif (isMetaOrCtrl) {\n\t\t\t\t\t\teditor.selection.getSel().modify(\"extend\", isForward ? \"forward\" : \"backward\", e.metaKey ? \"lineboundary\" : \"word\");\n\t\t\t\t\t}\n\n\t\t\t\t\tcustomDelete(isForward);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Handle case where text is deleted by typing over\n\t\t\teditor.on('keypress', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e) && !selection.isCollapsed() && e.charCode > 31 && !VK.metaKeyPressed(e)) {\n\t\t\t\t\tvar rng, currentFormatNodes, fragmentNode, blockParent, caretNode, charText;\n\n\t\t\t\t\trng = editor.selection.getRng();\n\t\t\t\t\tcharText = String.fromCharCode(e.charCode);\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t// Keep track of current format nodes\n\t\t\t\t\tcurrentFormatNodes = $(rng.startContainer).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tcustomDelete(true);\n\n\t\t\t\t\t// Check if the browser removed them\n\t\t\t\t\tcurrentFormatNodes = currentFormatNodes.filter(function(idx, node) {\n\t\t\t\t\t\treturn !$.contains(editor.getBody(), node);\n\t\t\t\t\t});\n\n\t\t\t\t\t// Then re-add them\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tfragmentNode = dom.createFragment();\n\n\t\t\t\t\t\tcurrentFormatNodes.each(function(idx, formatNode) {\n\t\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\t\tif (fragmentNode.hasChildNodes()) {\n\t\t\t\t\t\t\t\tformatNode.appendChild(fragmentNode.firstChild);\n\t\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcaretNode = formatNode;\n\t\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tcaretNode.appendChild(editor.getDoc().createTextNode(charText));\n\n\t\t\t\t\t\t// Prevent edge case where older WebKit would add an extra BR element\n\t\t\t\t\t\tblockParent = dom.getParent(rng.startContainer, dom.isBlock);\n\t\t\t\t\t\tif (dom.isEmpty(blockParent)) {\n\t\t\t\t\t\t\t$(blockParent).empty().append(fragmentNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.insertNode(fragmentNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trng.setStart(caretNode.firstChild, 1);\n\t\t\t\t\t\trng.setEnd(caretNode.firstChild, 1);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor.selection.setContent(charText);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\teditor.addCommand('Delete', function() {\n\t\t\t\tcustomDelete();\n\t\t\t});\n\n\t\t\teditor.addCommand('ForwardDelete', function() {\n\t\t\t\tcustomDelete(true);\n\t\t\t});\n\n\t\t\t// Older WebKits doesn't properly handle the clipboard so we can't add the rest\n\t\t\tif (olderWebKit) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\teditor.on('dragstart', function(e) {\n\t\t\t\tdragStartRng = selection.getRng();\n\t\t\t\tsetMceInteralContent(e);\n\t\t\t});\n\n\t\t\teditor.on('drop', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e)) {\n\t\t\t\t\tvar internalContent = getMceInternalContent(e);\n\n\t\t\t\t\tif (internalContent) {\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t// Safari has a weird issue where drag/dropping images sometimes\n\t\t\t\t\t\t// produces a green plus icon. When this happens the caretRangeFromPoint\n\t\t\t\t\t\t// will return \"null\" even though the x, y coordinate is correct.\n\t\t\t\t\t\t// But if we detach the insert from the drop event we will get a proper range\n\t\t\t\t\t\twindow.setTimeout(function() {\n\t\t\t\t\t\t\tvar pointRng = RangeUtils.getCaretRangeFromPoint(e.x, e.y, doc);\n\n\t\t\t\t\t\t\tif (dragStartRng) {\n\t\t\t\t\t\t\t\tselection.setRng(dragStartRng);\n\t\t\t\t\t\t\t\tdragStartRng = null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcustomDelete();\n\t\t\t\t\t\t\tselection.setRng(pointRng);\n\t\t\t\t\t\t\tinsertClipboardContents(internalContent.html);\n\t\t\t\t\t\t}, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\teditor.on('cut', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e) && e.clipboardData && !editor.selection.isCollapsed()) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.clipboardData.clearData();\n\t\t\t\t\te.clipboardData.setData('text/html', editor.selection.getContent());\n\t\t\t\t\te.clipboardData.setData('text/plain', editor.selection.getContent({format: 'text'}));\n\n\t\t\t\t\t// Needed delay for https://code.google.com/p/chromium/issues/detail?id=363288#c3\n\t\t\t\t\t// Nested delete/forwardDelete not allowed on execCommand(\"cut\")\n\t\t\t\t\t// This is ugly but not sure how to work around it otherwise\n\t\t\t\t\twindow.setTimeout(function() {\n\t\t\t\t\t\tcustomDelete(true);\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "dd2023352252a39b20d9d47f8383abc0", "score": "0.61275244", "text": "_removeBRinStyleText() {\n const afterRange = this.wwe.getRange();\n const { startContainer, startOffset } = afterRange;\n\n let styleNode;\n\n if (startContainer.nodeName === 'TD') {\n // This case is <i>TEST<br></i>|<br>\n styleNode = domUtils.getChildNodeByOffset(startContainer, startOffset - 1);\n } else {\n styleNode = domUtils.getParentUntil(startContainer, 'TD');\n }\n\n const brNode = styleNode.querySelector('br');\n\n if (!brNode) {\n return;\n }\n\n const { parentNode: tdNode, nodeName } = styleNode;\n\n if (nodeName === 'CODE' && !brNode.previousSibling) {\n // cursor is located in the start of text\n // Before Enter : <code>|TEST</code>\n // After Enter : <code><br>|TEST</code>\n // TO BE : <br><code>|TEST</code>\n tdNode.insertBefore(brNode, styleNode);\n afterRange.setStart(styleNode, 0);\n } else if (nodeName === 'CODE' && !brNode.nextSibling) {\n // cursor is located in the end of text\n // Before Enter : <code>TEST|</code>\n // After Enter : <code>TEST<br>|</code>\n // TO BE : <code>TEST</code><br>|\n tdNode.insertBefore(brNode, styleNode.nextSibling);\n afterRange.setStart(tdNode, domUtils.getNodeOffsetOfParent(brNode) + 1);\n } else {\n // [Case 1] cursor is located in the middle of text\n // Before Enter : <i>TE|ST</i>\n // After Enter : <i>TE<br>|ST</i>\n // TO BE : <i>TE</i><br><i>|ST</i>\n // [Case 2] cursor is located in the start of text\n // Before Enter : <i>|TEST</i>\n // After Enter : <i><br>|TEST</i>\n // TO BE : <i>|</i><br><i>TEST</i>\n // [Case 3] cursor is located in the end of text\n // Before Enter : <i>TEST|</i>\n // After Enter : <i>TEST<br>|</i>\n // TO BE : <i>TEST</i><br><i>|</i>\n const newNode = this._splitByBR(styleNode, brNode);\n\n afterRange.setStart(newNode, 0);\n }\n\n afterRange.collapse(true);\n this.wwe.getEditor().setSelection(afterRange);\n }", "title": "" }, { "docid": "c36fd1b0206101333dc933fa8d7ed4aa", "score": "0.6115894", "text": "function cleanupStylesWhenDeleting() {\n\t\t\tvar doc = editor.getDoc(), dom = editor.dom, selection = editor.selection;\n\t\t\tvar MutationObserver = window.MutationObserver, olderWebKit, dragStartRng;\n\n\t\t\t// Add mini polyfill for older WebKits\n\t\t\t// TODO: Remove this when old Safari versions gets updated\n\t\t\tif (!MutationObserver) {\n\t\t\t\tolderWebKit = true;\n\n\t\t\t\tMutationObserver = function() {\n\t\t\t\t\tvar records = [], target;\n\n\t\t\t\t\tfunction nodeInsert(e) {\n\t\t\t\t\t\tvar target = e.relatedNode || e.target;\n\t\t\t\t\t\trecords.push({target: target, addedNodes: [target]});\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction attrModified(e) {\n\t\t\t\t\t\tvar target = e.relatedNode || e.target;\n\t\t\t\t\t\trecords.push({target: target, attributeName: e.attrName});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.observe = function(node) {\n\t\t\t\t\t\ttarget = node;\n\t\t\t\t\t\ttarget.addEventListener('DOMSubtreeModified', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMNodeInsertedIntoDocument', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMNodeInserted', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMAttrModified', attrModified, false);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.disconnect = function() {\n\t\t\t\t\t\ttarget.removeEventListener('DOMSubtreeModified', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMNodeInsertedIntoDocument', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMNodeInserted', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMAttrModified', attrModified, false);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.takeRecords = function() {\n\t\t\t\t\t\treturn records;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tfunction isTrailingBr(node) {\n\t\t\t\tvar blockElements = dom.schema.getBlockElements(), rootNode = editor.getBody();\n\n\t\t\t\tif (node.nodeName != 'BR') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tfor (; node != rootNode && !blockElements[node.nodeName]; node = node.parentNode) {\n\t\t\t\t\tif (node.nextSibling) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction isSiblingsIgnoreWhiteSpace(node1, node2) {\n\t\t\t\tvar node;\n\n\t\t\t\tfor (node = node1.nextSibling; node && node != node2; node = node.nextSibling) {\n\t\t\t\t\tif (node.nodeType == 3 && $.trim(node.data).length === 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (node !== node2) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn node === node2;\n\t\t\t}\n\n\t\t\tfunction findCaretNode(node, forward, startNode) {\n\t\t\t\tvar walker, current, nonEmptyElements;\n\n\t\t\t\tnonEmptyElements = dom.schema.getNonEmptyElements();\n\n\t\t\t\twalker = new TreeWalker(startNode || node, node);\n\n\t\t\t\twhile ((current = walker[forward ? 'next' : 'prev']())) {\n\t\t\t\t\tif (nonEmptyElements[current.nodeName] && !isTrailingBr(current)) {\n\t\t\t\t\t\treturn current;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (current.nodeType == 3 && current.data.length > 0) {\n\t\t\t\t\t\treturn current;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction deleteRangeBetweenTextBlocks(rng) {\n\t\t\t\tvar startBlock, endBlock, caretNodeBefore, caretNodeAfter, textBlockElements;\n\n\t\t\t\tif (rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tstartBlock = dom.getParent(RangeUtils.getNode(rng.startContainer, rng.startOffset), dom.isBlock);\n\t\t\t\tendBlock = dom.getParent(RangeUtils.getNode(rng.endContainer, rng.endOffset), dom.isBlock);\n\t\t\t\ttextBlockElements = editor.schema.getTextBlockElements();\n\n\t\t\t\tif (startBlock == endBlock) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!textBlockElements[startBlock.nodeName] || !textBlockElements[endBlock.nodeName]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (dom.getContentEditable(startBlock) === \"false\" || dom.getContentEditable(endBlock) === \"false\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trng.deleteContents();\n\n\t\t\t\tcaretNodeBefore = findCaretNode(startBlock, false);\n\t\t\t\tcaretNodeAfter = findCaretNode(endBlock, true);\n\n\t\t\t\tif (!dom.isEmpty(endBlock)) {\n\t\t\t\t\t$(startBlock).append(endBlock.childNodes);\n\t\t\t\t}\n\n\t\t\t\t$(endBlock).remove();\n\n\t\t\t\tif (caretNodeBefore) {\n\t\t\t\t\tif (caretNodeBefore.nodeType == 1) {\n\t\t\t\t\t\tif (caretNodeBefore.nodeName == \"BR\") {\n\t\t\t\t\t\t\trng.setStartBefore(caretNodeBefore);\n\t\t\t\t\t\t\trng.setEndBefore(caretNodeBefore);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStartAfter(caretNodeBefore);\n\t\t\t\t\t\t\trng.setEndAfter(caretNodeBefore);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trng.setStart(caretNodeBefore, caretNodeBefore.data.length);\n\t\t\t\t\t\trng.setEnd(caretNodeBefore, caretNodeBefore.data.length);\n\t\t\t\t\t}\n\t\t\t\t} else if (caretNodeAfter) {\n\t\t\t\t\tif (caretNodeAfter.nodeType == 1) {\n\t\t\t\t\t\trng.setStartBefore(caretNodeAfter);\n\t\t\t\t\t\trng.setEndBefore(caretNodeAfter);\n\t\t\t\t\t} else {\n\t\t\t\t\t\trng.setStart(caretNodeAfter, 0);\n\t\t\t\t\t\trng.setEnd(caretNodeAfter, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tselection.setRng(rng);\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction expandBetweenBlocks(rng, isForward) {\n\t\t\t\tvar caretNode, targetCaretNode, textBlock, targetTextBlock, container, offset;\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn rng;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\n\t\t\t\tif (container.nodeType == 3) {\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset < container.data.length) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset > 0) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcaretNode = RangeUtils.getNode(rng.startContainer, rng.startOffset);\n\t\t\t\ttextBlock = dom.getParent(caretNode, dom.isBlock);\n\t\t\t\ttargetCaretNode = findCaretNode(editor.getBody(), isForward, caretNode);\n\t\t\t\ttargetTextBlock = dom.getParent(targetCaretNode, dom.isBlock);\n\n\t\t\t\tif (!caretNode || !targetCaretNode) {\n\t\t\t\t\treturn rng;\n\t\t\t\t}\n\n\t\t\t\tif (targetTextBlock && textBlock != targetTextBlock) {\n\t\t\t\t\tif (!isForward) {\n\t\t\t\t\t\tif (!isSiblingsIgnoreWhiteSpace(targetTextBlock, textBlock)) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (targetCaretNode.nodeType == 1) {\n\t\t\t\t\t\t\tif (targetCaretNode.nodeName == \"BR\") {\n\t\t\t\t\t\t\t\trng.setStartBefore(targetCaretNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trng.setStartAfter(targetCaretNode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStart(targetCaretNode, targetCaretNode.data.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (caretNode.nodeType == 1) {\n\t\t\t\t\t\t\trng.setEnd(caretNode, 0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setEndBefore(caretNode);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!isSiblingsIgnoreWhiteSpace(textBlock, targetTextBlock)) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (caretNode.nodeType == 1) {\n\t\t\t\t\t\t\tif (caretNode.nodeName == \"BR\") {\n\t\t\t\t\t\t\t\trng.setStartBefore(caretNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trng.setStartAfter(caretNode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStart(caretNode, caretNode.data.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (targetCaretNode.nodeType == 1) {\n\t\t\t\t\t\t\trng.setEnd(targetCaretNode, 0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setEndBefore(targetCaretNode);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn rng;\n\t\t\t}\n\n\t\t\tfunction handleTextBlockMergeDelete(isForward) {\n\t\t\t\tvar rng = selection.getRng();\n\n\t\t\t\trng = expandBetweenBlocks(rng, isForward);\n\n\t\t\t\tif (deleteRangeBetweenTextBlocks(rng)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * This retains the formatting if the last character is to be deleted.\n\t\t\t *\n\t\t\t * Backspace on this: <p><b><i>a|</i></b></p> would become <p>|</p> in WebKit.\n\t\t\t * With this patch: <p><b><i>|<br></i></b></p>\n\t\t\t */\n\t\t\tfunction handleLastBlockCharacterDelete(isForward, rng) {\n\t\t\t\tvar path, blockElm, newBlockElm, clonedBlockElm, sibling,\n\t\t\t\t\tcontainer, offset, br, currentFormatNodes;\n\n\t\t\t\tfunction cloneTextBlockWithFormats(blockElm, node) {\n\t\t\t\t\tcurrentFormatNodes = $(node).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tnewBlockElm = blockElm.cloneNode(false);\n\n\t\t\t\t\tcurrentFormatNodes = Tools.map(currentFormatNodes, function(formatNode) {\n\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\tif (newBlockElm.hasChildNodes()) {\n\t\t\t\t\t\t\tformatNode.appendChild(newBlockElm.firstChild);\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\n\t\t\t\t\t\treturn formatNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tbr = dom.create('br');\n\t\t\t\t\t\tcurrentFormatNodes[0].appendChild(br);\n\t\t\t\t\t\tdom.replace(newBlockElm, blockElm);\n\n\t\t\t\t\t\trng.setStartBefore(br);\n\t\t\t\t\t\trng.setEndBefore(br);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\n\t\t\t\t\t\treturn br;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tfunction isTextBlock(node) {\n\t\t\t\t\treturn node && editor.schema.getTextBlockElements()[node.tagName];\n\t\t\t\t}\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\tblockElm = dom.getParent(container, dom.isBlock);\n\t\t\t\tif (!isTextBlock(blockElm)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (container.nodeType == 1) {\n\t\t\t\t\tcontainer = container.childNodes[offset];\n\t\t\t\t\tif (container && container.tagName != 'BR') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tsibling = blockElm.nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsibling = blockElm.previousSibling;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(blockElm) && isTextBlock(sibling) && dom.isEmpty(sibling)) {\n\t\t\t\t\t\tif (cloneTextBlockWithFormats(blockElm, container)) {\n\t\t\t\t\t\t\tdom.remove(sibling);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (container.nodeType == 3) {\n\t\t\t\t\tpath = NodePath.create(blockElm, container);\n\t\t\t\t\tclonedBlockElm = blockElm.cloneNode(true);\n\t\t\t\t\tcontainer = NodePath.resolve(clonedBlockElm, path);\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset >= container.data.length) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset, 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset <= 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(clonedBlockElm)) {\n\t\t\t\t\t\treturn cloneTextBlockWithFormats(blockElm, container);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction customDelete(isForward) {\n\t\t\t\tvar mutationObserver, rng, caretElement;\n\n\t\t\t\tif (handleTextBlockMergeDelete(isForward)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tTools.each(editor.getBody().getElementsByTagName('*'), function(elm) {\n\t\t\t\t\t// Mark existing spans\n\t\t\t\t\tif (elm.tagName == 'SPAN') {\n\t\t\t\t\t\telm.setAttribute('mce-data-marked', 1);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Make sure all elements has a data-mce-style attribute\n\t\t\t\t\tif (!elm.hasAttribute('data-mce-style') && elm.hasAttribute('style')) {\n\t\t\t\t\t\teditor.dom.setAttrib(elm, 'style', editor.dom.getAttrib(elm, 'style'));\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// Observe added nodes and style attribute changes\n\t\t\t\tmutationObserver = new MutationObserver(function() {});\n\t\t\t\tmutationObserver.observe(editor.getDoc(), {\n\t\t\t\t\tchildList: true,\n\t\t\t\t\tattributes: true,\n\t\t\t\t\tsubtree: true,\n\t\t\t\t\tattributeFilter: ['style']\n\t\t\t\t});\n\n\t\t\t\teditor.getDoc().execCommand(isForward ? 'ForwardDelete' : 'Delete', false, null);\n\n\t\t\t\trng = editor.selection.getRng();\n\t\t\t\tcaretElement = rng.startContainer.parentNode;\n\n\t\t\t\tTools.each(mutationObserver.takeRecords(), function(record) {\n\t\t\t\t\tif (!dom.isChildOf(record.target, editor.getBody())) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Restore style attribute to previous value\n\t\t\t\t\tif (record.attributeName == \"style\") {\n\t\t\t\t\t\tvar oldValue = record.target.getAttribute('data-mce-style');\n\n\t\t\t\t\t\tif (oldValue) {\n\t\t\t\t\t\t\trecord.target.setAttribute(\"style\", oldValue);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trecord.target.removeAttribute(\"style\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Remove all spans that aren't marked and retain selection\n\t\t\t\t\tTools.each(record.addedNodes, function(node) {\n\t\t\t\t\t\tif (node.nodeName == \"SPAN\" && !node.getAttribute('mce-data-marked')) {\n\t\t\t\t\t\t\tvar offset, container;\n\n\t\t\t\t\t\t\tif (node == caretElement) {\n\t\t\t\t\t\t\t\toffset = rng.startOffset;\n\t\t\t\t\t\t\t\tcontainer = node.firstChild;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tdom.remove(node, true);\n\n\t\t\t\t\t\t\tif (container) {\n\t\t\t\t\t\t\t\trng.setStart(container, offset);\n\t\t\t\t\t\t\t\trng.setEnd(container, offset);\n\t\t\t\t\t\t\t\teditor.selection.setRng(rng);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tmutationObserver.disconnect();\n\n\t\t\t\t// Remove any left over marks\n\t\t\t\tTools.each(editor.dom.select('span[mce-data-marked]'), function(span) {\n\t\t\t\t\tspan.removeAttribute('mce-data-marked');\n\t\t\t\t});\n\t\t\t}\n\n\t\t\teditor.on('keydown', function(e) {\n\t\t\t\tvar isForward = e.keyCode == DELETE, isMetaOrCtrl = e.ctrlKey || e.metaKey;\n\n\t\t\t\tif (!isDefaultPrevented(e) && (isForward || e.keyCode == BACKSPACE)) {\n\t\t\t\t\tvar rng = editor.selection.getRng(), container = rng.startContainer, offset = rng.startOffset;\n\n\t\t\t\t\t// Shift+Delete is cut\n\t\t\t\t\tif (isForward && e.shiftKey) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (handleLastBlockCharacterDelete(isForward, rng)) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ignore non meta delete in the where there is text before/after the caret\n\t\t\t\t\tif (!isMetaOrCtrl && rng.collapsed && container.nodeType == 3) {\n\t\t\t\t\t\tif (isForward ? offset < container.data.length : offset > 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif (isMetaOrCtrl) {\n\t\t\t\t\t\teditor.selection.getSel().modify(\"extend\", isForward ? \"forward\" : \"backward\", e.metaKey ? \"lineboundary\" : \"word\");\n\t\t\t\t\t}\n\n\t\t\t\t\tcustomDelete(isForward);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Handle case where text is deleted by typing over\n\t\t\teditor.on('keypress', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e) && !selection.isCollapsed() && e.charCode > 31 && !VK.metaKeyPressed(e)) {\n\t\t\t\t\tvar rng, currentFormatNodes, fragmentNode, blockParent, caretNode, charText;\n\n\t\t\t\t\trng = editor.selection.getRng();\n\t\t\t\t\tcharText = String.fromCharCode(e.charCode);\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t// Keep track of current format nodes\n\t\t\t\t\tcurrentFormatNodes = $(rng.startContainer).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tcustomDelete(true);\n\n\t\t\t\t\t// Check if the browser removed them\n\t\t\t\t\tcurrentFormatNodes = currentFormatNodes.filter(function(idx, node) {\n\t\t\t\t\t\treturn !$.contains(editor.getBody(), node);\n\t\t\t\t\t});\n\n\t\t\t\t\t// Then re-add them\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tfragmentNode = dom.createFragment();\n\n\t\t\t\t\t\tcurrentFormatNodes.each(function(idx, formatNode) {\n\t\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\t\tif (fragmentNode.hasChildNodes()) {\n\t\t\t\t\t\t\t\tformatNode.appendChild(fragmentNode.firstChild);\n\t\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcaretNode = formatNode;\n\t\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tcaretNode.appendChild(editor.getDoc().createTextNode(charText));\n\n\t\t\t\t\t\t// Prevent edge case where older WebKit would add an extra BR element\n\t\t\t\t\t\tblockParent = dom.getParent(rng.startContainer, dom.isBlock);\n\t\t\t\t\t\tif (dom.isEmpty(blockParent)) {\n\t\t\t\t\t\t\t$(blockParent).empty().append(fragmentNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.insertNode(fragmentNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trng.setStart(caretNode.firstChild, 1);\n\t\t\t\t\t\trng.setEnd(caretNode.firstChild, 1);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor.selection.setContent(charText);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\teditor.addCommand('Delete', function() {\n\t\t\t\tcustomDelete();\n\t\t\t});\n\n\t\t\teditor.addCommand('ForwardDelete', function() {\n\t\t\t\tcustomDelete(true);\n\t\t\t});\n\n\t\t\t// Older WebKits doesn't properly handle the clipboard so we can't add the rest\n\t\t\tif (olderWebKit) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\teditor.on('dragstart', function(e) {\n\t\t\t\tdragStartRng = selection.getRng();\n\t\t\t\tsetMceInternalContent(e);\n\t\t\t});\n\n\t\t\teditor.on('drop', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e)) {\n\t\t\t\t\tvar internalContent = getMceInternalContent(e);\n\n\t\t\t\t\tif (internalContent) {\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t// Safari has a weird issue where drag/dropping images sometimes\n\t\t\t\t\t\t// produces a green plus icon. When this happens the caretRangeFromPoint\n\t\t\t\t\t\t// will return \"null\" even though the x, y coordinate is correct.\n\t\t\t\t\t\t// But if we detach the insert from the drop event we will get a proper range\n\t\t\t\t\t\tDelay.setEditorTimeout(editor, function() {\n\t\t\t\t\t\t\tvar pointRng = RangeUtils.getCaretRangeFromPoint(e.x, e.y, doc);\n\n\t\t\t\t\t\t\tif (dragStartRng) {\n\t\t\t\t\t\t\t\tselection.setRng(dragStartRng);\n\t\t\t\t\t\t\t\tdragStartRng = null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcustomDelete();\n\t\t\t\t\t\t\tselection.setRng(pointRng);\n\t\t\t\t\t\t\tinsertClipboardContents(internalContent.html);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\teditor.on('cut', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e) && e.clipboardData && !editor.selection.isCollapsed()) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.clipboardData.clearData();\n\t\t\t\t\te.clipboardData.setData('text/html', editor.selection.getContent());\n\t\t\t\t\te.clipboardData.setData('text/plain', editor.selection.getContent({format: 'text'}));\n\n\t\t\t\t\t// Needed delay for https://code.google.com/p/chromium/issues/detail?id=363288#c3\n\t\t\t\t\t// Nested delete/forwardDelete not allowed on execCommand(\"cut\")\n\t\t\t\t\t// This is ugly but not sure how to work around it otherwise\n\t\t\t\t\tDelay.setEditorTimeout(editor, function() {\n\t\t\t\t\t\tcustomDelete(true);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "6c8ec8b261eadbe1cbe259af0da25f8a", "score": "0.6115894", "text": "function cleanupStylesWhenDeleting() {\n\t\t\tvar doc = editor.getDoc(), dom = editor.dom, selection = editor.selection;\n\t\t\tvar MutationObserver = window.MutationObserver, olderWebKit, dragStartRng;\n\n\t\t\t// Add mini polyfill for older WebKits\n\t\t\t// TODO: Remove this when old Safari versions gets updated\n\t\t\tif (!MutationObserver) {\n\t\t\t\tolderWebKit = true;\n\n\t\t\t\tMutationObserver = function() {\n\t\t\t\t\tvar records = [], target;\n\n\t\t\t\t\tfunction nodeInsert(e) {\n\t\t\t\t\t\tvar target = e.relatedNode || e.target;\n\t\t\t\t\t\trecords.push({target: target, addedNodes: [target]});\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction attrModified(e) {\n\t\t\t\t\t\tvar target = e.relatedNode || e.target;\n\t\t\t\t\t\trecords.push({target: target, attributeName: e.attrName});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.observe = function(node) {\n\t\t\t\t\t\ttarget = node;\n\t\t\t\t\t\ttarget.addEventListener('DOMSubtreeModified', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMNodeInsertedIntoDocument', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMNodeInserted', nodeInsert, false);\n\t\t\t\t\t\ttarget.addEventListener('DOMAttrModified', attrModified, false);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.disconnect = function() {\n\t\t\t\t\t\ttarget.removeEventListener('DOMSubtreeModified', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMNodeInsertedIntoDocument', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMNodeInserted', nodeInsert, false);\n\t\t\t\t\t\ttarget.removeEventListener('DOMAttrModified', attrModified, false);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.takeRecords = function() {\n\t\t\t\t\t\treturn records;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tfunction isTrailingBr(node) {\n\t\t\t\tvar blockElements = dom.schema.getBlockElements(), rootNode = editor.getBody();\n\n\t\t\t\tif (node.nodeName != 'BR') {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tfor (; node != rootNode && !blockElements[node.nodeName]; node = node.parentNode) {\n\t\t\t\t\tif (node.nextSibling) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction isSiblingsIgnoreWhiteSpace(node1, node2) {\n\t\t\t\tvar node;\n\n\t\t\t\tfor (node = node1.nextSibling; node && node != node2; node = node.nextSibling) {\n\t\t\t\t\tif (node.nodeType == 3 && $.trim(node.data).length === 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (node !== node2) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn node === node2;\n\t\t\t}\n\n\t\t\tfunction findCaretNode(node, forward, startNode) {\n\t\t\t\tvar walker, current, nonEmptyElements;\n\n\t\t\t\t// Protect against the possibility we are asked to find a caret node relative\n\t\t\t\t// to a node that is no longer in the DOM tree. In this case attempting to\n\t\t\t\t// select on any match leads to a scenario where selection is completely removed\n\t\t\t\t// from the editor. This scenario is met in real world at a minimum on\n\t\t\t\t// WebKit browsers when selecting all and Cmd-X cutting to delete content.\n\t\t\t\tif (!dom.isChildOf(node, editor.getBody())) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tnonEmptyElements = dom.schema.getNonEmptyElements();\n\n\t\t\t\twalker = new TreeWalker(startNode || node, node);\n\n\t\t\t\twhile ((current = walker[forward ? 'next' : 'prev']())) {\n\t\t\t\t\tif (nonEmptyElements[current.nodeName] && !isTrailingBr(current)) {\n\t\t\t\t\t\treturn current;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (current.nodeType == 3 && current.data.length > 0) {\n\t\t\t\t\t\treturn current;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction deleteRangeBetweenTextBlocks(rng) {\n\t\t\t\tvar startBlock, endBlock, caretNodeBefore, caretNodeAfter, textBlockElements;\n\n\t\t\t\tif (rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tstartBlock = dom.getParent(RangeUtils.getNode(rng.startContainer, rng.startOffset), dom.isBlock);\n\t\t\t\tendBlock = dom.getParent(RangeUtils.getNode(rng.endContainer, rng.endOffset), dom.isBlock);\n\t\t\t\ttextBlockElements = editor.schema.getTextBlockElements();\n\n\t\t\t\tif (startBlock == endBlock) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!textBlockElements[startBlock.nodeName] || !textBlockElements[endBlock.nodeName]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (dom.getContentEditable(startBlock) === \"false\" || dom.getContentEditable(endBlock) === \"false\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trng.deleteContents();\n\n\t\t\t\tcaretNodeBefore = findCaretNode(startBlock, false);\n\t\t\t\tcaretNodeAfter = findCaretNode(endBlock, true);\n\n\t\t\t\tif (!dom.isEmpty(endBlock)) {\n\t\t\t\t\t$(startBlock).append(endBlock.childNodes);\n\t\t\t\t}\n\n\t\t\t\t$(endBlock).remove();\n\n\t\t\t\tif (caretNodeBefore) {\n\t\t\t\t\tif (caretNodeBefore.nodeType == 1) {\n\t\t\t\t\t\tif (caretNodeBefore.nodeName == \"BR\") {\n\t\t\t\t\t\t\trng.setStartBefore(caretNodeBefore);\n\t\t\t\t\t\t\trng.setEndBefore(caretNodeBefore);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStartAfter(caretNodeBefore);\n\t\t\t\t\t\t\trng.setEndAfter(caretNodeBefore);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trng.setStart(caretNodeBefore, caretNodeBefore.data.length);\n\t\t\t\t\t\trng.setEnd(caretNodeBefore, caretNodeBefore.data.length);\n\t\t\t\t\t}\n\t\t\t\t} else if (caretNodeAfter) {\n\t\t\t\t\tif (caretNodeAfter.nodeType == 1) {\n\t\t\t\t\t\trng.setStartBefore(caretNodeAfter);\n\t\t\t\t\t\trng.setEndBefore(caretNodeAfter);\n\t\t\t\t\t} else {\n\t\t\t\t\t\trng.setStart(caretNodeAfter, 0);\n\t\t\t\t\t\trng.setEnd(caretNodeAfter, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tselection.setRng(rng);\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction expandBetweenBlocks(rng, isForward) {\n\t\t\t\tvar caretNode, targetCaretNode, textBlock, targetTextBlock, container, offset;\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn rng;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\n\t\t\t\tif (container.nodeType == 3) {\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset < container.data.length) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset > 0) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcaretNode = RangeUtils.getNode(container, offset);\n\t\t\t\ttextBlock = dom.getParent(caretNode, dom.isBlock);\n\t\t\t\ttargetCaretNode = findCaretNode(editor.getBody(), isForward, caretNode);\n\t\t\t\ttargetTextBlock = dom.getParent(targetCaretNode, dom.isBlock);\n\t\t\t\tvar isAfter = container.nodeType === 1 && offset > container.childNodes.length - 1;\n\n\t\t\t\tif (!caretNode || !targetCaretNode) {\n\t\t\t\t\treturn rng;\n\t\t\t\t}\n\n\t\t\t\tif (targetTextBlock && textBlock != targetTextBlock) {\n\t\t\t\t\tif (!isForward) {\n\t\t\t\t\t\tif (!isSiblingsIgnoreWhiteSpace(targetTextBlock, textBlock)) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (targetCaretNode.nodeType == 1) {\n\t\t\t\t\t\t\tif (targetCaretNode.nodeName == \"BR\") {\n\t\t\t\t\t\t\t\trng.setStartBefore(targetCaretNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trng.setStartAfter(targetCaretNode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStart(targetCaretNode, targetCaretNode.data.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (caretNode.nodeType == 1) {\n\t\t\t\t\t\t\tif (isAfter) {\n\t\t\t\t\t\t\t\trng.setEndAfter(caretNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trng.setEndBefore(caretNode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setEndBefore(caretNode);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!isSiblingsIgnoreWhiteSpace(textBlock, targetTextBlock)) {\n\t\t\t\t\t\t\treturn rng;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (caretNode.nodeType == 1) {\n\t\t\t\t\t\t\tif (caretNode.nodeName == \"BR\") {\n\t\t\t\t\t\t\t\trng.setStartBefore(caretNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trng.setStartAfter(caretNode);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setStart(caretNode, caretNode.data.length);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (targetCaretNode.nodeType == 1) {\n\t\t\t\t\t\t\trng.setEnd(targetCaretNode, 0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.setEndBefore(targetCaretNode);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn rng;\n\t\t\t}\n\n\t\t\tfunction handleTextBlockMergeDelete(isForward) {\n\t\t\t\tvar rng = selection.getRng();\n\n\t\t\t\trng = expandBetweenBlocks(rng, isForward);\n\n\t\t\t\tif (deleteRangeBetweenTextBlocks(rng)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * This retains the formatting if the last character is to be deleted.\n\t\t\t *\n\t\t\t * Backspace on this: <p><b><i>a|</i></b></p> would become <p>|</p> in WebKit.\n\t\t\t * With this patch: <p><b><i>|<br></i></b></p>\n\t\t\t */\n\t\t\tfunction handleLastBlockCharacterDelete(isForward, rng) {\n\t\t\t\tvar path, blockElm, newBlockElm, clonedBlockElm, sibling,\n\t\t\t\t\tcontainer, offset, br, currentFormatNodes;\n\n\t\t\t\tfunction cloneTextBlockWithFormats(blockElm, node) {\n\t\t\t\t\tcurrentFormatNodes = $(node).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tnewBlockElm = blockElm.cloneNode(false);\n\n\t\t\t\t\tcurrentFormatNodes = Tools.map(currentFormatNodes, function(formatNode) {\n\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\tif (newBlockElm.hasChildNodes()) {\n\t\t\t\t\t\t\tformatNode.appendChild(newBlockElm.firstChild);\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\n\t\t\t\t\t\treturn formatNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tbr = dom.create('br');\n\t\t\t\t\t\tcurrentFormatNodes[0].appendChild(br);\n\t\t\t\t\t\tdom.replace(newBlockElm, blockElm);\n\n\t\t\t\t\t\trng.setStartBefore(br);\n\t\t\t\t\t\trng.setEndBefore(br);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\n\t\t\t\t\t\treturn br;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tfunction isTextBlock(node) {\n\t\t\t\t\treturn node && editor.schema.getTextBlockElements()[node.tagName];\n\t\t\t\t}\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\tblockElm = dom.getParent(container, dom.isBlock);\n\t\t\t\tif (!isTextBlock(blockElm)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (container.nodeType == 1) {\n\t\t\t\t\tcontainer = container.childNodes[offset];\n\t\t\t\t\tif (container && container.tagName != 'BR') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tsibling = blockElm.nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsibling = blockElm.previousSibling;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(blockElm) && isTextBlock(sibling) && dom.isEmpty(sibling)) {\n\t\t\t\t\t\tif (cloneTextBlockWithFormats(blockElm, container)) {\n\t\t\t\t\t\t\tdom.remove(sibling);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (container.nodeType == 3) {\n\t\t\t\t\tpath = NodePath.create(blockElm, container);\n\t\t\t\t\tclonedBlockElm = blockElm.cloneNode(true);\n\t\t\t\t\tcontainer = NodePath.resolve(clonedBlockElm, path);\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset >= container.data.length) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset, 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset <= 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(clonedBlockElm)) {\n\t\t\t\t\t\treturn cloneTextBlockWithFormats(blockElm, container);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction customDelete(isForward) {\n\t\t\t\tvar mutationObserver, rng, caretElement;\n\n\t\t\t\tif (handleTextBlockMergeDelete(isForward)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tTools.each(editor.getBody().getElementsByTagName('*'), function(elm) {\n\t\t\t\t\t// Mark existing spans\n\t\t\t\t\tif (elm.tagName == 'SPAN') {\n\t\t\t\t\t\telm.setAttribute('mce-data-marked', 1);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Make sure all elements has a data-mce-style attribute\n\t\t\t\t\tif (!elm.hasAttribute('data-mce-style') && elm.hasAttribute('style')) {\n\t\t\t\t\t\teditor.dom.setAttrib(elm, 'style', editor.dom.getAttrib(elm, 'style'));\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// Observe added nodes and style attribute changes\n\t\t\t\tmutationObserver = new MutationObserver(function() {});\n\t\t\t\tmutationObserver.observe(editor.getDoc(), {\n\t\t\t\t\tchildList: true,\n\t\t\t\t\tattributes: true,\n\t\t\t\t\tsubtree: true,\n\t\t\t\t\tattributeFilter: ['style']\n\t\t\t\t});\n\n\t\t\t\teditor.getDoc().execCommand(isForward ? 'ForwardDelete' : 'Delete', false, null);\n\n\t\t\t\trng = editor.selection.getRng();\n\t\t\t\tcaretElement = rng.startContainer.parentNode;\n\n\t\t\t\tTools.each(mutationObserver.takeRecords(), function(record) {\n\t\t\t\t\tif (!dom.isChildOf(record.target, editor.getBody())) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Restore style attribute to previous value\n\t\t\t\t\tif (record.attributeName == \"style\") {\n\t\t\t\t\t\tvar oldValue = record.target.getAttribute('data-mce-style');\n\n\t\t\t\t\t\tif (oldValue) {\n\t\t\t\t\t\t\trecord.target.setAttribute(\"style\", oldValue);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trecord.target.removeAttribute(\"style\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Remove all spans that aren't marked and retain selection\n\t\t\t\t\tTools.each(record.addedNodes, function(node) {\n\t\t\t\t\t\tif (node.nodeName == \"SPAN\" && !node.getAttribute('mce-data-marked')) {\n\t\t\t\t\t\t\tvar offset, container;\n\n\t\t\t\t\t\t\tif (node == caretElement) {\n\t\t\t\t\t\t\t\toffset = rng.startOffset;\n\t\t\t\t\t\t\t\tcontainer = node.firstChild;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tdom.remove(node, true);\n\n\t\t\t\t\t\t\tif (container) {\n\t\t\t\t\t\t\t\trng.setStart(container, offset);\n\t\t\t\t\t\t\t\trng.setEnd(container, offset);\n\t\t\t\t\t\t\t\teditor.selection.setRng(rng);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tmutationObserver.disconnect();\n\n\t\t\t\t// Remove any left over marks\n\t\t\t\tTools.each(editor.dom.select('span[mce-data-marked]'), function(span) {\n\t\t\t\t\tspan.removeAttribute('mce-data-marked');\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfunction transactCustomDelete(isForward) {\n\t\t\t\teditor.undoManager.transact(function () {\n\t\t\t\t\tcustomDelete(isForward);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\teditor.on('keydown', function(e) {\n\t\t\t\tvar isForward = e.keyCode == DELETE, isMetaOrCtrl = e.ctrlKey || e.metaKey;\n\n\t\t\t\tif (!isDefaultPrevented(e) && (isForward || e.keyCode == BACKSPACE)) {\n\t\t\t\t\tvar rng = editor.selection.getRng(), container = rng.startContainer, offset = rng.startOffset;\n\n\t\t\t\t\t// Shift+Delete is cut\n\t\t\t\t\tif (isForward && e.shiftKey) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (handleLastBlockCharacterDelete(isForward, rng)) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ignore non meta delete in the where there is text before/after the caret\n\t\t\t\t\tif (!isMetaOrCtrl && rng.collapsed && container.nodeType == 3) {\n\t\t\t\t\t\tif (isForward ? offset < container.data.length : offset > 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tif (isMetaOrCtrl) {\n\t\t\t\t\t\teditor.selection.getSel().modify(\"extend\", isForward ? \"forward\" : \"backward\", e.metaKey ? \"lineboundary\" : \"word\");\n\t\t\t\t\t}\n\n\t\t\t\t\tcustomDelete(isForward);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Handle case where text is deleted by typing over\n\t\t\teditor.on('keypress', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e) && !selection.isCollapsed() && e.charCode > 31 && !VK.metaKeyPressed(e)) {\n\t\t\t\t\tvar rng, currentFormatNodes, fragmentNode, blockParent, caretNode, charText;\n\n\t\t\t\t\trng = editor.selection.getRng();\n\t\t\t\t\tcharText = String.fromCharCode(e.charCode);\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t// Keep track of current format nodes\n\t\t\t\t\tcurrentFormatNodes = $(rng.startContainer).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tcustomDelete(true);\n\n\t\t\t\t\t// Check if the browser removed them\n\t\t\t\t\tcurrentFormatNodes = currentFormatNodes.filter(function(idx, node) {\n\t\t\t\t\t\treturn !$.contains(editor.getBody(), node);\n\t\t\t\t\t});\n\n\t\t\t\t\t// Then re-add them\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tfragmentNode = dom.createFragment();\n\n\t\t\t\t\t\tcurrentFormatNodes.each(function(idx, formatNode) {\n\t\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\t\tif (fragmentNode.hasChildNodes()) {\n\t\t\t\t\t\t\t\tformatNode.appendChild(fragmentNode.firstChild);\n\t\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcaretNode = formatNode;\n\t\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfragmentNode.appendChild(formatNode);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tcaretNode.appendChild(editor.getDoc().createTextNode(charText));\n\n\t\t\t\t\t\t// Prevent edge case where older WebKit would add an extra BR element\n\t\t\t\t\t\tblockParent = dom.getParent(rng.startContainer, dom.isBlock);\n\t\t\t\t\t\tif (dom.isEmpty(blockParent)) {\n\t\t\t\t\t\t\t$(blockParent).empty().append(fragmentNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trng.insertNode(fragmentNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trng.setStart(caretNode.firstChild, 1);\n\t\t\t\t\t\trng.setEnd(caretNode.firstChild, 1);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor.selection.setContent(charText);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\teditor.addCommand('Delete', function() {\n\t\t\t\tcustomDelete();\n\t\t\t});\n\n\t\t\teditor.addCommand('ForwardDelete', function() {\n\t\t\t\tcustomDelete(true);\n\t\t\t});\n\n\t\t\t// Older WebKits doesn't properly handle the clipboard so we can't add the rest\n\t\t\tif (olderWebKit) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\teditor.on('dragstart', function(e) {\n\t\t\t\tdragStartRng = selection.getRng();\n\t\t\t\tsetMceInternalContent(e);\n\t\t\t});\n\n\t\t\teditor.on('drop', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e)) {\n\t\t\t\t\tvar internalContent = getMceInternalContent(e);\n\n\t\t\t\t\tif (internalContent) {\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t// Safari has a weird issue where drag/dropping images sometimes\n\t\t\t\t\t\t// produces a green plus icon. When this happens the caretRangeFromPoint\n\t\t\t\t\t\t// will return \"null\" even though the x, y coordinate is correct.\n\t\t\t\t\t\t// But if we detach the insert from the drop event we will get a proper range\n\t\t\t\t\t\tDelay.setEditorTimeout(editor, function() {\n\t\t\t\t\t\t\tvar pointRng = RangeUtils.getCaretRangeFromPoint(e.x, e.y, doc);\n\n\t\t\t\t\t\t\tif (dragStartRng) {\n\t\t\t\t\t\t\t\tselection.setRng(dragStartRng);\n\t\t\t\t\t\t\t\tdragStartRng = null;\n\t\t\t\t\t\t\t\ttransactCustomDelete();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tselection.setRng(pointRng);\n\t\t\t\t\t\t\tinsertClipboardContents(internalContent.html);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\teditor.on('cut', function(e) {\n\t\t\t\tif (!isDefaultPrevented(e) && e.clipboardData && !editor.selection.isCollapsed()) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.clipboardData.clearData();\n\t\t\t\t\te.clipboardData.setData('text/html', editor.selection.getContent());\n\t\t\t\t\te.clipboardData.setData('text/plain', editor.selection.getContent({format: 'text'}));\n\n\t\t\t\t\t// Needed delay for https://code.google.com/p/chromium/issues/detail?id=363288#c3\n\t\t\t\t\t// Nested delete/forwardDelete not allowed on execCommand(\"cut\")\n\t\t\t\t\t// This is ugly but not sure how to work around it otherwise\n\t\t\t\t\tDelay.setEditorTimeout(editor, function() {\n\t\t\t\t\t\ttransactCustomDelete(true);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "e6d206f879e264b24be0072d63cd31b5", "score": "0.59957004", "text": "function fix_bug_01(code){\r\n\tr = /(style=[\"'][^\"']*?[\"'])/gi;\r\n\treturn code.replace(r,function(s1,s2){\r\n\t\t\ts2 = s2.replace(/(\\s*);(\\s*)/g,\";\");\r\n\t\t\ts2 = s2.replace(/(\\s*):(\\s*)/g,\":\");\r\n\t\t\treturn s2;\r\n\t});\r\n}", "title": "" }, { "docid": "a9c061168d82b228f76c8c37697d1f65", "score": "0.5993142", "text": "function refuseStyle(refStyle) {\n var selectedTag = getSelectedNode(); // the selected node\n\n // if the selected node have attribute of \"style\" and it have unwanted style\n if (selectedTag && selectedTag.is(\"[style]\") && selectedTag.css(refStyle) != \"\") {\n var refValue = selectedTag.css(refStyle); // first get key of unwanted style\n\n selectedTag.css(refStyle, \"\"); // clear unwanted style\n\n var cleanStyle = selectedTag.attr(\"style\"); // cleaned style\n\n selectedTag.css(refStyle, refValue); // add unwanted style to the selected node again\n\n return cleanStyle; // print cleaned style\n }\n else\n return \"\";\n }", "title": "" }, { "docid": "735b235524bb770c6b26956f5722e14b", "score": "0.59704095", "text": "function convertToOldElement(element) {\n var elem = element;\n var parentDiv = elem.parentNode;\n var val = elem.value\n var arrayPosition = element.getAttribute('style_array')\n var position = getPosition(parentDiv, elem)\n var para = document.createElement(oldStyleArray[arrayPosition].oldTag);\n\n // Same shit as above, the only difference is we reverse the whole operation\n // we give it the oldstyle which is tracked by 'style_array' and the 'oldTag'\n // from the removed element\n para.innerText = val;\n\n para.setAttribute('onkeydown', 'detectKeyPressed(this)')\n para.setAttribute('ondblclick', 'changeElement(this)')\n para.setAttribute('onmouseenter', 'toggleEditButton(this)')\n para.setAttribute('onmouseleave', 'toggleEditButton(this)')\n para.style.color = oldStyleArray[arrayPosition].oldStyle.color\n para.style.width = oldStyleArray[arrayPosition].oldStyle.width\n para.style.height = oldStyleArray[arrayPosition].oldStyle.height\n para.style.marginBottom = oldStyleArray[arrayPosition].oldStyle.marginBottom\n para.style.marginTop = oldStyleArray[arrayPosition].oldStyle.marginTop\n para.style.marginLeft = oldStyleArray[arrayPosition].oldStyle.marginLeft\n para.style.marginRight = oldStyleArray[arrayPosition].oldStyle.marginRight\n para.style.paddingBottom = oldStyleArray[arrayPosition].oldStyle.paddingBottom\n para.style.paddingTop = oldStyleArray[arrayPosition].oldStyle.paddingTop\n para.style.paddingLeft = oldStyleArray[arrayPosition].oldStyle.paddingLeft\n para.style.paddingRight = oldStyleArray[arrayPosition].oldStyle.paddingRight\n para.style.fontSize = oldStyleArray[arrayPosition].oldStyle.fontSize\n\n elem.remove()\n parentDiv.insertBefore(para, parentDiv.children[position]);\n\n // Safing the changes to an array which we can later use to call 'saveToClownfish()'\n // to save the changes to the backend\n saveToArray(parentDiv.children[position])\n}", "title": "" }, { "docid": "6998810b737cac84d88b34808436b0f5", "score": "0.587262", "text": "function clean() {\n $j('a, b, span, div, td').removeClass(change_odds_classes.down).removeClass(change_odds_classes.up);\n $j('b').attr('style', '');\n }", "title": "" }, { "docid": "b776868cc52e390869335315a412e1ae", "score": "0.5841972", "text": "function edt_cleanDeprecated()\n {\n var oEditor=eval(\"idContent\"+this.oName);\n\n var elements;\n \n elements=oEditor.document.body.getElementsByTagName(\"STRIKE\");\n this.cleanTags(elements,\"line-through\");\n elements=oEditor.document.body.getElementsByTagName(\"S\");\n this.cleanTags(elements,\"line-through\");\n \n elements=oEditor.document.body.getElementsByTagName(\"U\");\n this.cleanTags(elements,\"underline\");\n\n this.replaceTags(\"DIR\",\"DIV\");\n this.replaceTags(\"MENU\",\"DIV\"); \n this.replaceTags(\"CENTER\",\"DIV\");\n this.replaceTags(\"XMP\",\"PRE\");\n this.replaceTags(\"BASEFONT\",\"SPAN\");//will be removed by cleanEmptySpan()\n \n elements=oEditor.document.body.getElementsByTagName(\"APPLET\");\n var count=elements.length;\n while(count>0) \n {\n f=elements[0];\n f.removeNode(false); \n count--;\n }\n \n this.cleanFonts();\n this.cleanEmptySpan();\n\n return true;\n }", "title": "" }, { "docid": "cce9227f1fee03ea9e20b99403def2f2", "score": "0.5805202", "text": "clearCustomStyles(tr: Transform<any>, editorState: EditorState) {\n const { selection, doc } = editorState;\n const { from, to } = selection;\n let customStyleName = RESERVED_STYLE_NONE;\n doc.nodesBetween(from, to, (node, pos) => {\n if (node.attrs.styleName) {\n customStyleName = node.attrs.styleName;\n const storedmarks = getMarkByStyleName(\n customStyleName,\n editorState.schema\n );\n tr = this.removeMarks(storedmarks, tr, node);\n return tr;\n }\n return tr;\n });\n return tr;\n }", "title": "" }, { "docid": "118da0d95c081695f0e2c3a958503de1", "score": "0.5635751", "text": "function updateCursorStyle() {\n const selecter = getKeySelecter(lastCursorId, lastCursorIndent);\n cursorStyle.textContent = [\n selecter + ' {',\n ' border-left: 2px solid #4073d6;',\n ' margin-left: -2px;',\n '}',\n // Oh man, I can't believe I'm doing this...\n selecter + '[data-item-indent=\"2\"] {',\n ' margin-left: 26px;',\n '}',\n selecter + '[data-item-indent=\"3\"] {',\n ' margin-left: 54px;',\n '}',\n selecter + '[data-item-indent=\"4\"] {',\n ' margin-left: 82px;',\n '}',\n selecter + '[data-item-indent=\"5\"] {',\n ' margin-left: 110px;',\n '}',\n selecter + ' .sel_checkbox_td {',\n ' padding-left: 2px;',\n '}',\n ].join('\\n');\n }", "title": "" }, { "docid": "1ab8ca9209ee97c89bf42cc6d9145193", "score": "0.56289613", "text": "function clearBlockFormat(editor, tagsToUnwrap, tagsToStopUnwrap, attributesToPreserve) {\n if (tagsToUnwrap === void 0) { tagsToUnwrap = exports.TAGS_TO_UNWRAP; }\n if (tagsToStopUnwrap === void 0) { tagsToStopUnwrap = exports.TAGS_TO_STOP_UNWRAP; }\n if (attributesToPreserve === void 0) { attributesToPreserve = exports.ATTRIBUTES_TO_PRESERVE; }\n editor.focus();\n editor.addUndoSnapshot(function (start, end) {\n var groups = [{}];\n var stopUnwrapSelector = tagsToStopUnwrap.join(',');\n // 1. Collapse the selected blocks and get first and last element\n collapseSelectedBlocks_1.default(editor, function (element) {\n var group = groups[groups.length - 1];\n var td = editor.getElementAtCursor(stopUnwrapSelector, element);\n if (td != group.td && group.first) {\n groups.push((group = {}));\n }\n group.td = td;\n group.first = group.first || element;\n group.last = element;\n });\n groups\n .filter(function (group) { return group.first; })\n .forEach(function (group) {\n // 2. Collapse with first and last element to make them under same parent\n var nodes = editor.collapseNodes(group.first, group.last, true /*canSplitParent*/);\n // 3. Continue collapse until we can't collapse any more (hit root node, or a table)\n if (canCollapse(tagsToStopUnwrap, nodes[0])) {\n while (editor.contains(nodes[0].parentNode) &&\n canCollapse(tagsToStopUnwrap, nodes[0].parentNode)) {\n nodes = [roosterjs_editor_dom_1.splitBalancedNodeRange(nodes)];\n }\n }\n // 4. Clear formats of the nodes\n nodes.forEach(function (node) {\n return clearNodeFormat(node, tagsToUnwrap, tagsToStopUnwrap, attributesToPreserve);\n });\n // 5. Clear CSS of container TD if exist\n if (group.td) {\n var styles = group.td.getAttribute('style') || '';\n var styleArray = styles.split(';');\n styleArray = styleArray.filter(function (style) {\n return style\n .trim()\n .toLowerCase()\n .indexOf('border') == 0;\n });\n styles = styleArray.join(';');\n if (styles) {\n group.td.setAttribute('style', styles);\n }\n else {\n group.td.removeAttribute('style');\n }\n }\n });\n editor.select(start, end);\n }, \"Format\" /* Format */);\n}", "title": "" }, { "docid": "420cb2dadade1bb8c136fc5e28dad66d", "score": "0.5610315", "text": "function fixSyntaxHighlighting () {\n var sts = document.querySelectorAll('.err');\n Array.prototype.forEach.call(sts, function (st) {\n if (st.textContent === '`' || st.textContent === ':') {\n st.classList.remove('err');\n }\n })\n}", "title": "" }, { "docid": "461d51fafd6b303f5229d6299de0e32a", "score": "0.5592616", "text": "function cleanupStyles(item) {\n var prop;\n var reactProps;\n if (item.props.style) {\n reactProps = {};\n for(prop in item.props.style) {\n reactProps[prop] = item._node.style[prop];\n }\n }\n item._node.removeAttribute('style');\n if (reactProps) {\n for(prop in reactProps) {\n item._node.style[prop] = reactProps[prop];\n }\n }\n if (item._prevStyles) {\n for(prop in item._prevStyles) {\n item._node.style[prop] = item._prevStyles[prop];\n }\n }\n}", "title": "" }, { "docid": "ee13e17ee2e253ad7bff2448d9efa502", "score": "0.5566206", "text": "testDeleteBrNormal() {\n setUpFields(true);\n\n // This test only works on Gecko, because it's testing for manual deletion\n // of BR tags, which is done only for Gecko. For other browsers we fall\n // through and let the browser do the delete, which can only be tested with\n // a robot test (see javascript/apps/editor/tests/delete_br_robot.html).\n if (userAgent.GECKO) {\n field1.setSafeHtml(\n false, testing.newSafeHtmlForTest('one<br><br><br>two'));\n const helper = new TestHelper(field1.getElement());\n helper.select(\n field1.getElement(), 2); // Between the first and second BR's.\n field1.getElement().focus();\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);\n assertEquals(\n 'Should have deleted exactly one <br>', 'one<br><br>two',\n field1.getElement().innerHTML);\n\n } // End if GECKO\n }", "title": "" }, { "docid": "44b8c8c511163b2051c7e0f319133e35", "score": "0.55453664", "text": "addHorizontalRuleRemovingSelection(editorState) {\n const contentState = editorState.getCurrentContent();\n const contentStateWithEntity = contentState.createEntity(\n ENTITY_TYPE.HORIZONTAL_RULE,\n 'IMMUTABLE',\n {},\n );\n const entityKey = contentStateWithEntity.getLastCreatedEntityKey();\n\n return AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');\n }", "title": "" }, { "docid": "8acb7e5afb3d6a8a018b9aacf090abdb", "score": "0.55442905", "text": "function patchDivElement(element) {\n element.setAttribute(\n 'style',\n 'margin-top: 0.5rem; margin-bottom: 0.5rem; \\\n padding-left: 0.5rem; padding-right: 0.5rem; border: solid 1px red;'\n );\n }", "title": "" }, { "docid": "23eb0785ba6cb1b7547f02553db2e14f", "score": "0.5500342", "text": "testDeleteBrBeforeBlock() {\n setUpFields(true);\n\n // This test only works on Gecko, because it's testing for manual deletion\n // of BR tags, which is done only for Gecko. For other browsers we fall\n // through and let the browser do the delete, which can only be tested with\n // a robot test (see javascript/apps/editor/tests/delete_br_robot.html).\n if (userAgent.GECKO) {\n field1.setSafeHtml(\n false, testing.newSafeHtmlForTest('one<br><br><div>two</div>'));\n const helper = new TestHelper(field1.getElement());\n helper.select(field1.getElement(), 2); // Between the two BR's.\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);\n assertEquals(\n 'Should have deleted exactly one <br>', 'one<br><div>two</div>',\n field1.getElement().innerHTML);\n\n // We test the case where the BR has a previous sibling which is not\n // a block level element.\n field1.setSafeHtml(\n false, testing.newSafeHtmlForTest('one<br><ul><li>two</li></ul>'));\n helper.select(field1.getElement(), 1); // Between one and BR.\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);\n assertEquals(\n 'Should have deleted the <br>', 'one<ul><li>two</li></ul>',\n field1.getElement().innerHTML);\n // Verify that the cursor is placed at the end of the text node \"one\".\n let range = field1.getRange();\n let focusNode = range.getFocusNode();\n assertTrue('The selected range should be collapsed', range.isCollapsed());\n assertTrue(\n 'The focus node should be the text node \"one\"',\n focusNode.nodeType == NodeType.TEXT && focusNode.data == 'one');\n assertEquals(\n 'The focus offset should be at the end of the text node \"one\"',\n focusNode.length, range.getFocusOffset());\n assertTrue(\n 'The next sibling of the focus node should be the UL',\n focusNode.nextSibling && focusNode.nextSibling.tagName == TagName.UL);\n\n // We test the case where the previous sibling of the BR is a block\n // level element.\n field1.setSafeHtml(\n false,\n testing.newSafeHtmlForTest(\n '<div>foo</div><br><div><span>bar</span></div>'));\n helper.select(field1.getElement(), 1); // Before the BR.\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);\n assertEquals(\n 'Should have deleted the <br>',\n '<div>foo</div><div><span>bar</span></div>',\n field1.getElement().innerHTML);\n range = field1.getRange();\n assertEquals(\n 'The selected range should be contained within the <span>',\n String(TagName.SPAN), range.getContainerElement().tagName);\n assertTrue('The selected range should be collapsed', range.isCollapsed());\n // Verify that the cursor is placed inside the span at the beginning of\n // bar.\n focusNode = range.getFocusNode();\n assertTrue(\n 'The focus node should be the text node \"bar\"',\n focusNode.nodeType == NodeType.TEXT && focusNode.data == 'bar');\n assertEquals(\n 'The focus offset should be at the beginning ' +\n 'of the text node \"bar\"',\n 0, range.getFocusOffset());\n\n // We test the case where the BR does not have a previous sibling.\n field1.setSafeHtml(\n false, testing.newSafeHtmlForTest('<br><ul><li>one</li></ul>'));\n helper.select(field1.getElement(), 0); // Before the BR.\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);\n assertEquals(\n 'Should have deleted the <br>', '<ul><li>one</li></ul>',\n field1.getElement().innerHTML);\n range = field1.getRange();\n // Verify that the cursor is placed inside the LI at the text node \"one\".\n assertEquals(\n 'The selected range should be contained within the <li>',\n String(TagName.LI), range.getContainerElement().tagName);\n assertTrue('The selected range should be collapsed', range.isCollapsed());\n focusNode = range.getFocusNode();\n assertTrue(\n 'The focus node should be the text node \"one\"',\n (focusNode.nodeType == NodeType.TEXT && focusNode.data == 'one'));\n assertEquals(\n 'The focus offset should be at the beginning of ' +\n 'the text node \"one\"',\n 0, range.getFocusOffset());\n\n // Testing deleting a BR followed by a block level element and preceded\n // by a BR.\n field1.setSafeHtml(\n false, testing.newSafeHtmlForTest('<br><br><ul><li>one</li></ul>'));\n helper.select(field1.getElement(), 1); // Between the BR's.\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);\n assertEquals(\n 'Should have deleted the <br>', '<br><ul><li>one</li></ul>',\n field1.getElement().innerHTML);\n // Verify that the cursor is placed inside the LI at the text node \"one\".\n range = field1.getRange();\n assertEquals(\n 'The selected range should be contained within the <li>',\n String(TagName.LI), range.getContainerElement().tagName);\n assertTrue('The selected range should be collapsed', range.isCollapsed());\n focusNode = range.getFocusNode();\n assertTrue(\n 'The focus node should be the text node \"one\"',\n (focusNode.nodeType == NodeType.TEXT && focusNode.data == 'one'));\n assertEquals(\n 'The focus offset should be at the beginning of ' +\n 'the text node \"one\"',\n 0, range.getFocusOffset());\n } // End if GECKO\n }", "title": "" }, { "docid": "9757fa2f070d2147bc36d9b0f7febf37", "score": "0.54579306", "text": "function fixMarkup() {\r\n // Put the upload link and the associated divider in a div container.\r\n\t$('div#tt-upload').addClass('saj-block');\r\n\tif (grayBackground) {\r\n\t\t$('#tt-upload .tt-divider').css('margin', '');\r\n\t}\r\n\r\n\t// Fix padding for closed sections in the right column.\r\n\tGM_addStyle(\r\n\t\t'.tt-col2 .tt-block .tt-closed-wrapper { padding: 8px ! important; }\\n'\r\n\t);\r\n}", "title": "" }, { "docid": "405e27ec0a1b7b8abc51a069eaefaf9a", "score": "0.5451247", "text": "function wrapOrReplaceSelectionInDocRemoveNBSP(codeBeforeSel, codeAfterSel, defaultCodeForEmptySel, codeToReplaceSel)\n{\n var dom = dw.getDocumentDOM();\n\tif( dom )\n\t{\n\t\tvar sel = dwscripts.getBalancedSelection(dom);\n\t\tvar docHTML = dom.documentElement.outerHTML;\n\t\tvar preCode = docHTML.substring(0,sel[0]);\n\t\tvar nbspStr = dom.getNBSPChar();\n\t\tif (preCode.length > nbspStr.length)\n\t\t{\n\t\t\tvar nbspIndex = preCode.lastIndexOf(nbspStr); \n\t\t\tif (nbspIndex != -1)\n\t\t\t{\n\t\t\t\tif (nbspIndex == preCode.length-nbspStr.length)\n\t\t\t\t{\n\t\t\t\t\t//we have a &nbsp; preceeding us we can remove\n\t\t\t\t\tpreCode = preCode.substring(0,preCode.length - nbspStr.length);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvar postCode = docHTML.substring(sel[sel.length-1]);\n\t\tif (postCode.length > nbspStr.length)\n\t\t{\n\t\t //we have a &nbsp; following us we can remove\n\t\t\tvar nbspIndex = postCode.indexOf(nbspStr); \n\t\t\tif (nbspIndex != -1)\n\t\t\t{\n\t\t\t\tif (nbspIndex == 0)\n\t\t\t\t{\n\t\t\t\t\t//we have a &nbsp; preceeding us\n\t\t\t\t\tpostCode = postCode.substring(nbspStr.length,postCode.length);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tvar selectedCode;\n\t\tif( codeToReplaceSel )\n\t\t{\n\t\t\tselectedCode = codeToReplaceSel;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tselectedCode = docHTML.substring(sel[0], sel[sel.length-1]);\n\t\t\tif (!selectedCode || selectedCode.length == 0 || selectedCode == nbspStr)\n\t\t\t\tselectedCode = defaultCodeForEmptySel;\n\t\t}\n\t\t\n\t\tif( !codeBeforeSel )\n\t\t\tcodeBeforeSel = \"\";\n\t\tif( !codeAfterSel )\n\t\t\tcodeAfterSel = \"\";\n\t\t\t\t\n\t\tvar newDocHTML = preCode + codeBeforeSel + selectedCode + codeAfterSel + postCode;\n\t\tdom.documentElement.outerHTML = newDocHTML;\n\t}\n}", "title": "" }, { "docid": "1f08c94a1da0f9b0fdb116eff2560d15", "score": "0.5446617", "text": "function editEmbeddedStyle(word){\n var length = word.length * 8;\n document.getElementsByTagName('style')[0].innerHTML=\n \".np-current:after {width: \"+length+\"px;height: \"+length+\"px;margin-left: -\"+length+\"px;}\";\n}", "title": "" }, { "docid": "84e0516117d72ac005bf4e596d510753", "score": "0.5442188", "text": "function resetOldStyles() {\n if (lastElem) {\n setStyleList(lastElem, lastElemStyle);\n lastElem = null;\n lastElemStyle = null;\n }\n}", "title": "" }, { "docid": "8741be094d30001540cdc724d5ac46f2", "score": "0.5434178", "text": "function patchStyle(lastAttrValue, nextAttrValue, dom) {\n if (isNullOrUndef$3(nextAttrValue)) {\n dom.removeAttribute('style');\n return;\n }\n\n var domStyle = dom.style;\n var style;\n var value;\n\n if (isString$2(nextAttrValue)) {\n domStyle.cssText = nextAttrValue;\n return;\n }\n\n if (!isNullOrUndef$3(lastAttrValue) && !isString$2(lastAttrValue)) {\n for (style in nextAttrValue) {\n // do not add a hasOwnProperty check here, it affects performance\n value = nextAttrValue[style];\n\n if (value !== lastAttrValue[style]) {\n domStyle.setProperty(style, value);\n }\n }\n\n for (style in lastAttrValue) {\n if (isNullOrUndef$3(nextAttrValue[style])) {\n domStyle.removeProperty(style);\n }\n }\n } else {\n for (style in nextAttrValue) {\n value = nextAttrValue[style];\n domStyle.setProperty(style, value);\n }\n }\n }", "title": "" }, { "docid": "d30de2e71682d282fa409019473d1960", "score": "0.5418589", "text": "function regularSyntaxColoringAndAutoIndent(event){\n\n \t\tvar sbwin = Chickenfoot.getSidebarWindow(chromeWindow);\n \tvar ed = sbwin.getSelectedBuffer().editor;\n \tvar doc = ed.contentDocument;\n \tvar pre = doc.getElementById(\"pre\"); \n \tvar anchorNodeCaret = sbwin.getSelectedBuffer().api.selection.anchorNode;\n \tvar anchorOffsetCaret = sbwin.getSelectedBuffer().api.selection.anchorOffset;\n \t\n \t//count characters\n \tvar chars=0;\n \t/*\n \tif (event.keyCode ==13 & anchorNodeCaret.nodeName==\"SPAN\") {\n \t\tdebug(\"charCount SPAN BR\");\n \t\tchars=charCountSpanBr(anchorNodeCaret,pre.childNodes);\n \t}else{\n \t\tchars=charCount(anchorNodeCaret,anchorOffsetCaret,pre.childNodes);\n \t}*/\n \tchars=charCount(anchorNodeCaret,anchorOffsetCaret,pre.childNodes);\n \t\n \t//eliminate spans, specifically:\n \t//<span style=\"color: blue;\">\n \t//<span style=\"color: purple;\">\n\t\t//<span style=\"color: green;\">\n\t\t//</span>\n\t\t\n\t\tvar spanRegEx = /(<span style=\"color: purple;\">|<span style=\"color: blue;\">|<span style=\"color: green;\">|<\\/span>)/gm;\n \t\n \tpre.innerHTML=pre.innerHTML.replace(spanRegEx,\"\");\n \t//recolor\n \tsyntaxColor(pre, CF_JAVASCRIPT_RULES); \n \t\n\t\t//replace caret\n\t\tcaretPlacement(chars,pre,sbwin);\n\t\t\n\t\t//autoIndent : only on return, } , and ctrl+tab\n \tvar pre2 = doc.getElementById(\"pre\"); \n \t//debug('event.keyCode');\n \t//debug(event.keyCode);\n \t//if(false){\n \tif(event.keyCode==13||event.keyCode==221||(event.ctrlKey && event.keyCode==9)){\n \t\tvar lines = makeLines(pre2);\n \t\t//debug('lines');\n \t\t//debug(lines);\n \t\tfor (i in lines){\n \t\t//debug(lines[i]);\n \t\t}\n \t\tvar anchorNodeCaret2 = sbwin.getSelectedBuffer().api.selection.focusNode;\n \t\tvar anchorOffsetCaret2 = sbwin.getSelectedBuffer().api.selection.focusOffset;\n \t\t\tvar lineNum=findNodeInLines(lines,anchorNodeCaret2,anchorOffsetCaret2);\n \t\t\t//debug('lineNum= '+lineNum);\n\t\t\t//this is how many spaces we need to indent our line by\n\t\t\t\n\t\t\tif (lines[lineNum][0].parentNode.nodeName==\"SPAN\"){\n\t\t\t\t//do nothing\n\t\t\t\t//debug('inside a span node, dont change indent');\n\t\t\t}else{\n\t\t\t\tvar indents=calculateIndents(lines,lineNum);\n\t\t\t\t\n\t\t\t\t//debug('INDENTS: '+indents)\n\t\t\t\t/*\n\t\t\t\tdebug(\"event.keycode\");\n\t\t\t\tdebug(lines[lineNum]);\n\t\t\t\tdebug(doc);\n\t\t\t\tdebug(pre);\n\t\t\t\tdebug(sbwin);\n\t\t\t\tdebug(anchorNodeCaret2);\n\t\t\t\tdebug(anchorOffsetCaret2);\n\t\t\t\tdebug(\"event.keycode\");\n\t\t\t\t*/\n\t\t\t\t//debug(\"changeIndent\");\n\t\t\t\tchangeIndent(lines[lineNum],indents,doc,pre,sbwin,anchorNodeCaret2,anchorOffsetCaret2);\n\t\t\t}\n\t\t}\n\t\t/*\n\t\tvar pre2 = doc.getElementById(\"pre\"); \n \tvar anchorNodeCaret2 = sbwin.getSelectedBuffer().api.selection.focusNode;\n \tvar anchorOffsetCaret2 = sbwin.getSelectedBuffer().api.selection.focusOffset;\n\t\t\n\t\tdebug('pre');\n \tdebug(pre.childNodes);\n \tdebug(anchorNodeCaret2.data+\"+end\");\n \tdebug(anchorNodeCaret2);\n \tdebug(anchorOffsetCaret2);\n \t//debug(pre.innerHTML)\n \t*/\n \t//debug(\"FINISHED\");\n \t\n \t\n}", "title": "" }, { "docid": "ac982047499c34616f66c5a381e41548", "score": "0.5389868", "text": "_strip(e) {\n\t\te.preventDefault();\n let text = e.clipboardData.getData(\"text/plain\");\n text = text.substring(0, 70);\n document.execCommand(\"insertHTML\", false, text);\n\t}", "title": "" }, { "docid": "52ae4c9cb2e4a467a601390f740f9b68", "score": "0.5369414", "text": "_removeDragStyles() {\n const that = this;\n that._supportCSSVariables ? that.$.innerContainer.removeAttribute('style') : that.$.innerContainer.style.left = '';\n that._supportCSSVariables ? that.$.innerContainer.removeAttribute('style') : that.$.innerContainer.style.top = '';\n that._mouseDown = false;\n }", "title": "" }, { "docid": "c6bf2984d7a8b5b2450d4f2f4a3bbabb", "score": "0.5368746", "text": "function fixUpInsertionPoint() {\n moveIPToOutsideOfParagraphToPreventInvalidHTML();\n backUpCursorIfAfterNonBreakingSpaceInTableCell();\n}", "title": "" }, { "docid": "c342466b8a5e631a56b7fe05b520f4b1", "score": "0.5351832", "text": "function removeFromInsideElement(style, element) {\n var //def = style._.definition,\n //attribs = def.attributes,\n //styles = def.styles,\n overrides = getOverrides(style),\n innerElements = element.all(style[\"element\"]);\n\n for (var i = innerElements.length; --i >= 0;)\n removeFromElement(style, new Node(innerElements[i]));\n\n // Now remove any other element with different name that is\n // defined to be overriden.\n for (var overrideElement in overrides) {\n if (overrides.hasOwnProperty(overrideElement)) {\n if (overrideElement != style[\"element\"]) {\n innerElements = element.all(overrideElement);\n for (i = innerElements.length - 1; i >= 0; i--) {\n var innerElement = new Node(innerElements[i]);\n removeOverrides(innerElement,\n overrides[ overrideElement ]);\n }\n }\n }\n }\n\n }", "title": "" }, { "docid": "27c4369695537a980b0f4d13f8abca24", "score": "0.53472424", "text": "function removeBlockQuoteOnBackSpace() {\n\t\t\t// Add block quote deletion handler\n\t\t\teditor.on('keydown', function(e) {\n\t\t\t\tvar rng, container, offset, root, parent;\n\n\t\t\t\tif (isDefaultPrevented(e) || e.keyCode != VK.BACKSPACE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trng = selection.getRng();\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\troot = dom.getRoot();\n\t\t\t\tparent = container;\n\n\t\t\t\tif (!rng.collapsed || offset !== 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\twhile (parent && parent.parentNode && parent.parentNode.firstChild == parent && parent.parentNode != root) {\n\t\t\t\t\tparent = parent.parentNode;\n\t\t\t\t}\n\n\t\t\t\t// Is the cursor at the beginning of a blockquote?\n\t\t\t\tif (parent.tagName === 'BLOCKQUOTE') {\n\t\t\t\t\t// Remove the blockquote\n\t\t\t\t\teditor.formatter.toggle('blockquote', null, parent);\n\n\t\t\t\t\t// Move the caret to the beginning of container\n\t\t\t\t\trng = dom.createRng();\n\t\t\t\t\trng.setStart(container, 0);\n\t\t\t\t\trng.setEnd(container, 0);\n\t\t\t\t\tselection.setRng(rng);\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "27c4369695537a980b0f4d13f8abca24", "score": "0.53472424", "text": "function removeBlockQuoteOnBackSpace() {\n\t\t\t// Add block quote deletion handler\n\t\t\teditor.on('keydown', function(e) {\n\t\t\t\tvar rng, container, offset, root, parent;\n\n\t\t\t\tif (isDefaultPrevented(e) || e.keyCode != VK.BACKSPACE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trng = selection.getRng();\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\troot = dom.getRoot();\n\t\t\t\tparent = container;\n\n\t\t\t\tif (!rng.collapsed || offset !== 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\twhile (parent && parent.parentNode && parent.parentNode.firstChild == parent && parent.parentNode != root) {\n\t\t\t\t\tparent = parent.parentNode;\n\t\t\t\t}\n\n\t\t\t\t// Is the cursor at the beginning of a blockquote?\n\t\t\t\tif (parent.tagName === 'BLOCKQUOTE') {\n\t\t\t\t\t// Remove the blockquote\n\t\t\t\t\teditor.formatter.toggle('blockquote', null, parent);\n\n\t\t\t\t\t// Move the caret to the beginning of container\n\t\t\t\t\trng = dom.createRng();\n\t\t\t\t\trng.setStart(container, 0);\n\t\t\t\t\trng.setEnd(container, 0);\n\t\t\t\t\tselection.setRng(rng);\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "27c4369695537a980b0f4d13f8abca24", "score": "0.53472424", "text": "function removeBlockQuoteOnBackSpace() {\n\t\t\t// Add block quote deletion handler\n\t\t\teditor.on('keydown', function(e) {\n\t\t\t\tvar rng, container, offset, root, parent;\n\n\t\t\t\tif (isDefaultPrevented(e) || e.keyCode != VK.BACKSPACE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\trng = selection.getRng();\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\troot = dom.getRoot();\n\t\t\t\tparent = container;\n\n\t\t\t\tif (!rng.collapsed || offset !== 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\twhile (parent && parent.parentNode && parent.parentNode.firstChild == parent && parent.parentNode != root) {\n\t\t\t\t\tparent = parent.parentNode;\n\t\t\t\t}\n\n\t\t\t\t// Is the cursor at the beginning of a blockquote?\n\t\t\t\tif (parent.tagName === 'BLOCKQUOTE') {\n\t\t\t\t\t// Remove the blockquote\n\t\t\t\t\teditor.formatter.toggle('blockquote', null, parent);\n\n\t\t\t\t\t// Move the caret to the beginning of container\n\t\t\t\t\trng = dom.createRng();\n\t\t\t\t\trng.setStart(container, 0);\n\t\t\t\t\trng.setEnd(container, 0);\n\t\t\t\t\tselection.setRng(rng);\n\t\t\t\t}\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "de44b2770db377b3e614c1a07bf0e1fc", "score": "0.53466576", "text": "function _ClearStyle(txt){\n let re = /<[\\w\\d =-]*>|<\\/span>/;\n let regexp = new RegExp(re, \"gim\");\n return txt.replace(regexp,'');\n }", "title": "" }, { "docid": "0e913be89afe65850d030eef4dd6fd26", "score": "0.5343594", "text": "function fixIndent(editor, spaces) {\n\t\tfor (var i = 0; i < spaces; i++) {\n\t\t\teditor.document.replaceRange(' ', editor.getCursorPos());\n\t\t}\n\t}", "title": "" }, { "docid": "8f6379b727dcf391d187b1e381fe6ffe", "score": "0.53166485", "text": "function removeAndPrintInlineStyles(node){//f \n //console.log(node.getAttribute(\"style\"));\n if(node.getAttribute(\"style\")!=null){\n let properties = node2properties(node);\n let hash = object2hash(properties);\n let className = \"ERR\"; \n if(!(hash in classes)){\n //add\n classes[hash] = classNameCreator();\n }\n className = classes[hash];\n node.removeAttribute(\"style\"); //remove style.\n node.className = className;\n }\n for(let child of node.children){\n removeAndPrintInlineStyles(child);\n } \n\n}", "title": "" }, { "docid": "92058c5f49427c5bd25c196cb15e0ed6", "score": "0.53111225", "text": "function cleanEdit(container){\n\tvar text = container.text();\n\tvar punctuation = [\",\",\".\",\":\",\";\",\"-\",\"[\",\"]\",\"/\",\"\\\\\",\"?\",\"!\",\"@\",\"#\",\"$\",\"%\",\"^\",\"&\",\"*\",\"(\",\")\",\"=\",\"+\"]\n\tvar leftBoundary = text[0];\n\tvar rightBoundary = text[text.length-1];\n}", "title": "" }, { "docid": "c33fc9abf6f48431632185822bbdce5b", "score": "0.5308029", "text": "function backUpCursorIfAfterNonBreakingSpaceInTableCell()\n{\n var dom = dw.getDocumentDOM();\n var selNode = dom.getSelectedNode();\n if (selNode.tagName && selNode.tagName == \"TD\" && selNode.outerHTML.indexOf(\"&nbsp\") != -1 \n && selNode.innerHTML == \"&nbsp;\") \n {\n var selArr = dom.nodeToOffsets(selNode);\n var cellOuterHTML = selNode.outerHTML;\n var nbspInd = cellOuterHTML.indexOf(\"&nbsp\");\n var newIP = selArr[0] + nbspInd - 1;\n dom.setSelection(newIP,newIP);\n }\n\n}", "title": "" }, { "docid": "efb723b6a74ecbe7682effcd2dbf4b3f", "score": "0.5304721", "text": "_removeInlineStyle() {\n const that = this,\n tabStrip = that.$.tabStrip;\n\n if (that._inlineStyleTabStripChildren) {\n const tabStripChildren = tabStrip.children;\n\n for (let i = 0; i < tabStripChildren.length; i++) {\n tabStripChildren[i].removeAttribute('style');\n tabStripChildren[i].firstElementChild.firstElementChild.classList.remove('jqx-tab-label-text-container-full-height');\n }\n\n delete that._inlineStyleTabStripChildren;\n }\n\n if (that._inlineStyleTabStrip) {\n tabStrip.removeAttribute('style');\n delete that._inlineStyleTabStrip;\n }\n\n tabStrip.$.removeClass('shrink-tabs');\n tabStrip.$.removeClass('shrink-tabs-vertical');\n }", "title": "" }, { "docid": "c5968e6e5ad22b9210ddce25cecfa941", "score": "0.5291127", "text": "remove() {\r\n manipulation_1.removeChildrenWithFormatting({\r\n children: [this],\r\n getSiblingFormatting: () => manipulation_1.FormattingKind.Newline\r\n });\r\n }", "title": "" }, { "docid": "cb0e09b09d5510639b06cf2af177306d", "score": "0.5268762", "text": "function cleanStyles(e) {\n if (!e) return;\n\n\n // Remove any root styles, if we're able.\n if (typeof e.removeAttribute == 'function' && e.className != 'readability-styled') e.removeAttribute('style');\n\n // Go until there are no more child nodes\n var cur = e.firstChild;\n while (cur) {\n if (cur.nodeType == 1) {\n // Remove style attribute(s) :\n if (cur.className != \"readability-styled\") {\n cur.removeAttribute(\"style\");\n }\n cleanStyles(cur);\n }\n cur = cur.nextSibling;\n }\n}", "title": "" }, { "docid": "70bf081dabdbdb9c51486bcf824bf44c", "score": "0.5240411", "text": "function _cleanupStyles(target) {\n\t for (var n in this.properties) {\n\t target.style[n] = '';\n\t }\n\t }", "title": "" }, { "docid": "4e9c825113c6fcdf4db9ab347a641020", "score": "0.5233293", "text": "testEnterInBlockquoteRemovesExtraNodes() {\n setUpFields(true);\n\n // Let's assume we have the following DOM structure and the\n // cursor is placed after the first numbered list item \"one\".\n //\n // <blockquote class=\"tr_bq\">\n // <div><div>a</div><ol><li>one|</li></div>\n // <div>two</div>\n // </blockquote>\n //\n // After pressing enter, we have the following structure.\n //\n // <blockquote class=\"tr_bq\">\n // <div><div>a</div><ol><li>one|</li></div>\n // </blockquote>\n // <div>&nbsp;</div>\n // <blockquote class=\"tr_bq\">\n // <div><ol><li><span id=\"\"></span></li></ol></div>\n // <div>two</div>\n // </blockquote>\n //\n // This appears to the user as an empty list. After the fix, the HTML\n // will be\n //\n // <blockquote class=\"tr_bq\">\n // <div><div>a</div><ol><li>one|</li></div>\n // </blockquote>\n // <div>&nbsp;</div>\n // <blockquote class=\"tr_bq\">\n // <div>two</div>\n // </blockquote>\n //\n field1.setSafeHtml(\n false,\n testing.newSafeHtmlForTest(\n '<blockquote class=\"tr_bq\">' +\n '<div><div>a</div><ol><li id=\"cursor\">one</li></div>' +\n '<div>b</div>' +\n '</blockquote>'));\n const dom = field1.getEditableDomHelper();\n Range.createCaret(dom.getElement('cursor').firstChild, 3).select();\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.ENTER);\n const elem = field1.getElement();\n let secondBlockquote =\n dom.getElementsByTagNameAndClass(TagName.BLOCKQUOTE, null, elem)[1];\n assertHTMLEquals('<div>b</div>', secondBlockquote.innerHTML);\n\n // Ensure that we remove only unnecessary subtrees.\n field1.setSafeHtml(\n false,\n testing.newSafeHtmlForTest(\n '<blockquote class=\"tr_bq\">' +\n '<div><span>a</span><div id=\"cursor\">one</div><div>two</div></div>' +\n '<div><span>c</span></div>' +\n '</blockquote>'));\n Range.createCaret(dom.getElement('cursor').firstChild, 3).select();\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.ENTER);\n secondBlockquote =\n dom.getElementsByTagNameAndClass(TagName.BLOCKQUOTE, null, elem)[1];\n const expectedHTML = '<div><div>two</div></div>' +\n '<div><span>c</span></div>';\n assertHTMLEquals(expectedHTML, secondBlockquote.innerHTML);\n\n // Place the cursor in the middle of a line.\n field1.setSafeHtml(\n false,\n testing.newSafeHtmlForTest(\n '<blockquote id=\"quote\" class=\"tr_bq\">' +\n '<div>one</div><div>two</div>' +\n '</blockquote>'));\n Range.createCaret(dom.getElement('quote').firstChild.firstChild, 1)\n .select();\n testingEvents.fireKeySequence(field1.getElement(), KeyCodes.ENTER);\n const blockquotes =\n dom.getElementsByTagNameAndClass(TagName.BLOCKQUOTE, null, elem);\n assertEquals(2, blockquotes.length);\n assertHTMLEquals('<div>o</div>', blockquotes[0].innerHTML);\n assertHTMLEquals('<div>ne</div><div>two</div>', blockquotes[1].innerHTML);\n }", "title": "" }, { "docid": "964d8ec2e877ad25a997e4e63d8daa2a", "score": "0.51983637", "text": "function DevFeed_RemoveAllHighlightsForElement(element) {\n if (element) {\n if (element.nodeType == 1) {\n if (element.getAttribute(\"class\") == \"DevFeedHighlight\") {\n var text = element.removeChild(element.firstChild);\n element.parentNode.insertBefore(text,element);\n element.parentNode.removeChild(element);\n return true;\n } else {\n var normalize = false;\n for (var i=element.childNodes.length-1; i>=0; i--) {\n if (DevFeed_RemoveAllHighlightsForElement(element.childNodes[i])) {\n normalize = true;\n }\n }\n if (normalize) {\n element.normalize();\n }\n }\n }\n }\n return false;\n}", "title": "" }, { "docid": "62dcbfaf4cf73fde4d149b0688df0890", "score": "0.51905304", "text": "function fixHTML(html) {\n\t\treturn html.replace(/ /g, \"&nbsp;\").replace(/’/g, \"'\").replace(/-/g,\"&#8209;\"); \n\t}", "title": "" }, { "docid": "f9ec9d42d51e1c8b9f77ccd388995937", "score": "0.51604456", "text": "function renderEmptyBlocksFix() {\n\t\t\tvar emptyBlocksCSS;\n\n\t\t\t// IE10+\n\t\t\tif (getDocumentMode() >= 10) {\n\t\t\t\temptyBlocksCSS = '';\n\t\t\t\teach('p div h1 h2 h3 h4 h5 h6'.split(' '), function(name, i) {\n\t\t\t\t\temptyBlocksCSS += (i > 0 ? ',' : '') + name + ':empty';\n\t\t\t\t});\n\n\t\t\t\teditor.contentStyles.push(emptyBlocksCSS + '{padding-right: 1px !important}');\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "f9ec9d42d51e1c8b9f77ccd388995937", "score": "0.51604456", "text": "function renderEmptyBlocksFix() {\n\t\t\tvar emptyBlocksCSS;\n\n\t\t\t// IE10+\n\t\t\tif (getDocumentMode() >= 10) {\n\t\t\t\temptyBlocksCSS = '';\n\t\t\t\teach('p div h1 h2 h3 h4 h5 h6'.split(' '), function(name, i) {\n\t\t\t\t\temptyBlocksCSS += (i > 0 ? ',' : '') + name + ':empty';\n\t\t\t\t});\n\n\t\t\t\teditor.contentStyles.push(emptyBlocksCSS + '{padding-right: 1px !important}');\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "f9ec9d42d51e1c8b9f77ccd388995937", "score": "0.51604456", "text": "function renderEmptyBlocksFix() {\n\t\t\tvar emptyBlocksCSS;\n\n\t\t\t// IE10+\n\t\t\tif (getDocumentMode() >= 10) {\n\t\t\t\temptyBlocksCSS = '';\n\t\t\t\teach('p div h1 h2 h3 h4 h5 h6'.split(' '), function(name, i) {\n\t\t\t\t\temptyBlocksCSS += (i > 0 ? ',' : '') + name + ':empty';\n\t\t\t\t});\n\n\t\t\t\teditor.contentStyles.push(emptyBlocksCSS + '{padding-right: 1px !important}');\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "3ed1090636a46ac43046786fe512b735", "score": "0.51587886", "text": "function trimNbspAfterDeleteAndPaddValue() {\n\t\t\t\t\tvar rng, container, offset;\n\n\t\t\t\t\trng = selection.getRng(true);\n\t\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\t\toffset = rng.startOffset;\n\n\t\t\t\t\tif (container.nodeType == 3 && rng.collapsed) {\n\t\t\t\t\t\tif (container.data[offset] === '\\u00a0') {\n\t\t\t\t\t\t\tcontainer.deleteData(offset, 1);\n\n\t\t\t\t\t\t\tif (!/[\\u00a0| ]$/.test(value)) {\n\t\t\t\t\t\t\t\tvalue += ' ';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (container.data[offset - 1] === '\\u00a0') {\n\t\t\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\n\t\t\t\t\t\t\tif (!/[\\u00a0| ]$/.test(value)) {\n\t\t\t\t\t\t\t\tvalue = ' ' + value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}", "title": "" }, { "docid": "f9578f889e916be03a6f31107be9f36c", "score": "0.5154528", "text": "function removeWrap(c)\n{\n\tif (c){\n\n\t\tvar b = false;\n\t\tif (E.mode==\"edit\") {\n\t\t\tb = c.match(BodyContents);\n\t\t\tif (b) {\n\t\t\t\tc = b[2];\n\t\t\t}\n\t\t}\n\t\tc1 = wrap_tag_expr;\n\t\tc2 = wrap_end_tag_expr;\n\t\tvar count=0;var count2=0;\n\n\t\tedit_begin_tags\t= c.match(begin_edit_expr);\n\t\tedit_end_tags\t= c.match(end_edit_expr);\n\n\t\t//if (c1.test(code)){\n\t\t\tc = c.replace(c1,function(s1,s2){count++;return edit_begin_tags[count-1];});\n\t\t\tc = c.replace(c2,function(s1,s2){count2++;return edit_end_tags[count2-1];});\n\t\t//}\n\t\tc = removeBlock(c);\n\t\tif (b) {\n\t\t\treturn b[1] + c + b[3];\n\t\t} else {\n\t\t\treturn c;\n\t\t}\n\n\t} else {\n\t\treturn \"\";\n\t}\n}", "title": "" }, { "docid": "89c996055cbba8b14b2793f98c08ed93", "score": "0.51236314", "text": "function spanAffectsWrapping() { return false; }", "title": "" }, { "docid": "89c996055cbba8b14b2793f98c08ed93", "score": "0.51236314", "text": "function spanAffectsWrapping() { return false; }", "title": "" }, { "docid": "89c996055cbba8b14b2793f98c08ed93", "score": "0.51236314", "text": "function spanAffectsWrapping() { return false; }", "title": "" }, { "docid": "89c996055cbba8b14b2793f98c08ed93", "score": "0.51236314", "text": "function spanAffectsWrapping() { return false; }", "title": "" }, { "docid": "83c235444a3a26be095ea4e5faf240ab", "score": "0.5113676", "text": "function MyApp_RemoveAllHighlightsForElement(element) {\nif (element) {\n\tif (element.nodeType == 1) {\n\t\tif (element.getAttribute(\"class\") == \"highlight\") {\n\t\t\tvar text = element.removeChild(element.firstChild);\n\t\t\telement.parentNode.insertBefore(text, element);\n\t\t\telement.parentNode.removeChild(element);\n\t\t\treturn true;\n\t\t} else {\n\t\t\tvar normalize = false;\n\t\t\tfor (var i = element.childNodes.length - 1; i >= 0; i--) {\n\t\t\t\tif (MyApp_RemoveAllHighlightsForElement(\n\t\t\t\t\t\telement.childNodes[i])) {\n\t\t\t\t\tnormalize = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (normalize) {\n\t\t\t\telement.normalize();\n\t\t\t}\n\t\t}\n\t}\n}\nreturn false;\n}", "title": "" }, { "docid": "d845bb9f4ac824e84cdc06ba44e7bea7", "score": "0.5112663", "text": "function affectStyleAround(element, style) {\n var selectedTag = getSelectedNode(); // the selected node\n\n selectedTag = selectedTag ? selectedTag : element;\n\n // (for replacement with execCommand) affect to child tags with parent tag's styles\n if (selectedTag && style == false) {\n // apply to the selected node with parent tag's styles\n if (selectedTag.parent().is(\"[style]\"))\n selectedTag.attr(\"style\", selectedTag.parent().attr(\"style\"));\n\n // apply to child tags with parent tag's styles\n if (selectedTag.is(\"[style]\"))\n selectedTag.find(\"*\").attr(\"style\", selectedTag.attr(\"style\"));\n }\n // (for replacement with html changing method)\n else if (element && style && element.is(\"[style]\")) {\n var styleKey = style.split(\";\"); // split the styles\n\n styleKey = styleKey[0].split(\":\") // get the key of first style feature\n\n // apply to child tags with parent tag's styles\n if (element.is(\"[style*=\" + styleKey[0] + \"]\"))\n element.find(\"*\").css(styleKey[0], styleKey[1]);\n\n // select to the selected node again\n selectText(element);\n }\n }", "title": "" }, { "docid": "9e7a387cd1ad3380c6a904ff454055e0", "score": "0.5106854", "text": "function removeCSS(Element, Attribute) {\r\n if (typeof Element == \"string\") {\r\n Element = document.getElementById(Element);\r\n }\r\n\r\n var OriginalStyle = Element.getAttribute(\"style\").split(\"; \");\r\n\r\n OriginalStyle.pop();\r\n for (i = 0; i < OriginalStyle.length; i += 1) {\r\n CurrentCheck = \"|| \" + OriginalStyle[i] + \" ||\";\r\n FirstPart = CurrentCheck.split(\"|| \").pop().split(\": \")[0];\r\n SecondPart = CurrentCheck.split(\": \").pop().split(\" ||\")[0];\r\n\r\n if (FirstPart === Attribute) {\r\n OriginalStyle[i] = \"\";\r\n }\r\n }\r\n var ReapplyStyle = \"\";\r\n for (p = 0; p < OriginalStyle.length; p += 1) {\r\n if (OriginalStyle[p] != \"\") {\r\n ReapplyStyle = ReapplyStyle + OriginalStyle[p] + \"; \";\r\n }\r\n }\r\n Element.setAttribute(\"style\", ReapplyStyle);\r\n\r\n //Element.style.removeProperty(Attribute);\r\n}", "title": "" }, { "docid": "9b9e5f5f68c4df129a7e81e3ff9c1c9b", "score": "0.50985044", "text": "function sanitizeListItemContainer(doc) {\n var listItemContainerListEl = doc.querySelectorAll(constants_1.WORD_ORDERED_LIST_SELECTOR + \", \" + constants_1.WORD_UNORDERED_LIST_SELECTOR);\n listItemContainerListEl.forEach(function (el) {\n var replaceRegex = new RegExp(\"\\\\b\" + constants_1.LIST_CONTAINER_ELEMENT_CLASS_NAME + \"\\\\b\", 'g');\n if (el.previousSibling) {\n var prevParent = roosterjs_editor_dom_1.splitParentNode(el, true);\n prevParent.className = prevParent.className.replace(replaceRegex, '');\n }\n if (el.nextSibling) {\n var nextParent = roosterjs_editor_dom_1.splitParentNode(el, false);\n nextParent.className = nextParent.className.replace(replaceRegex, '');\n }\n });\n}", "title": "" }, { "docid": "b0c752eead383a6b4afdcb7dc01f5934", "score": "0.5096149", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\r\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\r\n token = formattingElementEntry.token,\r\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\r\n\r\n p._adoptNodes(furthestBlock, newElement);\r\n p.treeAdapter.appendChild(furthestBlock, newElement);\r\n\r\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\r\n p.activeFormattingElements.removeEntry(formattingElementEntry);\r\n\r\n p.openElements.remove(formattingElementEntry.element);\r\n p.openElements.insertAfter(furthestBlock, newElement);\r\n}", "title": "" }, { "docid": "e2db9094b538bd27fe006a2e622efbaf", "score": "0.5086033", "text": "function autoEdExtraBreaks(str) { //MAIN FUNCTION describes list of fixes\n \n//Usually unneeded BR tags from ends of image descriptions and wikilinks (]]), templates (}}), template parameters (|)\nstr = str.replace(/[\\t ]*<[\\s\\/\\.]*br[\\s\\/\\.]*>[\\t ]*([\\t\\n ]*?)(\\]\\]|}}|\\|)/gim, '$1$2');\n//BR tag before a list item\nstr = str.replace(/[\\t ]*<[\\s\\/\\.]*br[\\s\\/\\.]*>[\\t ]*([\\s]*?[\\n]\\*)/gim, '$1');\n//BR tag followed by at least two newlines\nstr = str.replace(/[\\t ]*<[\\s\\/\\.]*br[\\s\\/\\.]*>[\\t ]*([\\n])[\\t ]*([\\n])/gim, '$1$2');\n \nreturn str;\n}", "title": "" }, { "docid": "b97d4ae92554cf8ad11c76739258670b", "score": "0.5083863", "text": "function removeBlock(pos) {\n process.stdout.write('\\x1B[?25h');\n cursor.bg.black();\n cursor.goto(pos[0] * 2 + 1, pos[1] + 1).write(' ');\n cursor.goto(pos[0] * 2 + 2, pos[1] + 1).write(' ');\n cursor.reset();\n process.stdout.write('\\x1B[?25l');\n}", "title": "" }, { "docid": "4f8aa4770c2474fd82b496693b3e4262", "score": "0.5083614", "text": "function handleLastBlockCharacterDelete(isForward, rng) {\n\t\t\t\tvar path, blockElm, newBlockElm, clonedBlockElm, sibling,\n\t\t\t\t\tcontainer, offset, br, currentFormatNodes;\n\n\t\t\t\tfunction cloneTextBlockWithFormats(blockElm, node) {\n\t\t\t\t\tcurrentFormatNodes = $(node).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tnewBlockElm = blockElm.cloneNode(false);\n\n\t\t\t\t\tcurrentFormatNodes = Tools.map(currentFormatNodes, function(formatNode) {\n\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\tif (newBlockElm.hasChildNodes()) {\n\t\t\t\t\t\t\tformatNode.appendChild(newBlockElm.firstChild);\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\n\t\t\t\t\t\treturn formatNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tbr = dom.create('br');\n\t\t\t\t\t\tcurrentFormatNodes[0].appendChild(br);\n\t\t\t\t\t\tdom.replace(newBlockElm, blockElm);\n\n\t\t\t\t\t\trng.setStartBefore(br);\n\t\t\t\t\t\trng.setEndBefore(br);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\n\t\t\t\t\t\treturn br;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tfunction isTextBlock(node) {\n\t\t\t\t\treturn node && editor.schema.getTextBlockElements()[node.tagName];\n\t\t\t\t}\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\tblockElm = dom.getParent(container, dom.isBlock);\n\t\t\t\tif (!isTextBlock(blockElm)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (container.nodeType == 1) {\n\t\t\t\t\tcontainer = container.childNodes[offset];\n\t\t\t\t\tif (container && container.tagName != 'BR') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tsibling = blockElm.nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsibling = blockElm.previousSibling;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(blockElm) && isTextBlock(sibling) && dom.isEmpty(sibling)) {\n\t\t\t\t\t\tif (cloneTextBlockWithFormats(blockElm, container)) {\n\t\t\t\t\t\t\tdom.remove(sibling);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (container.nodeType == 3) {\n\t\t\t\t\tpath = NodePath.create(blockElm, container);\n\t\t\t\t\tclonedBlockElm = blockElm.cloneNode(true);\n\t\t\t\t\tcontainer = NodePath.resolve(clonedBlockElm, path);\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset >= container.data.length) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset, 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset <= 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(clonedBlockElm)) {\n\t\t\t\t\t\treturn cloneTextBlockWithFormats(blockElm, container);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "4f8aa4770c2474fd82b496693b3e4262", "score": "0.5083614", "text": "function handleLastBlockCharacterDelete(isForward, rng) {\n\t\t\t\tvar path, blockElm, newBlockElm, clonedBlockElm, sibling,\n\t\t\t\t\tcontainer, offset, br, currentFormatNodes;\n\n\t\t\t\tfunction cloneTextBlockWithFormats(blockElm, node) {\n\t\t\t\t\tcurrentFormatNodes = $(node).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tnewBlockElm = blockElm.cloneNode(false);\n\n\t\t\t\t\tcurrentFormatNodes = Tools.map(currentFormatNodes, function(formatNode) {\n\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\tif (newBlockElm.hasChildNodes()) {\n\t\t\t\t\t\t\tformatNode.appendChild(newBlockElm.firstChild);\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\n\t\t\t\t\t\treturn formatNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tbr = dom.create('br');\n\t\t\t\t\t\tcurrentFormatNodes[0].appendChild(br);\n\t\t\t\t\t\tdom.replace(newBlockElm, blockElm);\n\n\t\t\t\t\t\trng.setStartBefore(br);\n\t\t\t\t\t\trng.setEndBefore(br);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\n\t\t\t\t\t\treturn br;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tfunction isTextBlock(node) {\n\t\t\t\t\treturn node && editor.schema.getTextBlockElements()[node.tagName];\n\t\t\t\t}\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\tblockElm = dom.getParent(container, dom.isBlock);\n\t\t\t\tif (!isTextBlock(blockElm)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (container.nodeType == 1) {\n\t\t\t\t\tcontainer = container.childNodes[offset];\n\t\t\t\t\tif (container && container.tagName != 'BR') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tsibling = blockElm.nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsibling = blockElm.previousSibling;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(blockElm) && isTextBlock(sibling) && dom.isEmpty(sibling)) {\n\t\t\t\t\t\tif (cloneTextBlockWithFormats(blockElm, container)) {\n\t\t\t\t\t\t\tdom.remove(sibling);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (container.nodeType == 3) {\n\t\t\t\t\tpath = NodePath.create(blockElm, container);\n\t\t\t\t\tclonedBlockElm = blockElm.cloneNode(true);\n\t\t\t\t\tcontainer = NodePath.resolve(clonedBlockElm, path);\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset >= container.data.length) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset, 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset <= 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(clonedBlockElm)) {\n\t\t\t\t\t\treturn cloneTextBlockWithFormats(blockElm, container);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "4f8aa4770c2474fd82b496693b3e4262", "score": "0.5083614", "text": "function handleLastBlockCharacterDelete(isForward, rng) {\n\t\t\t\tvar path, blockElm, newBlockElm, clonedBlockElm, sibling,\n\t\t\t\t\tcontainer, offset, br, currentFormatNodes;\n\n\t\t\t\tfunction cloneTextBlockWithFormats(blockElm, node) {\n\t\t\t\t\tcurrentFormatNodes = $(node).parents().filter(function(idx, node) {\n\t\t\t\t\t\treturn !!editor.schema.getTextInlineElements()[node.nodeName];\n\t\t\t\t\t});\n\n\t\t\t\t\tnewBlockElm = blockElm.cloneNode(false);\n\n\t\t\t\t\tcurrentFormatNodes = Tools.map(currentFormatNodes, function(formatNode) {\n\t\t\t\t\t\tformatNode = formatNode.cloneNode(false);\n\n\t\t\t\t\t\tif (newBlockElm.hasChildNodes()) {\n\t\t\t\t\t\t\tformatNode.appendChild(newBlockElm.firstChild);\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewBlockElm.appendChild(formatNode);\n\n\t\t\t\t\t\treturn formatNode;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (currentFormatNodes.length) {\n\t\t\t\t\t\tbr = dom.create('br');\n\t\t\t\t\t\tcurrentFormatNodes[0].appendChild(br);\n\t\t\t\t\t\tdom.replace(newBlockElm, blockElm);\n\n\t\t\t\t\t\trng.setStartBefore(br);\n\t\t\t\t\t\trng.setEndBefore(br);\n\t\t\t\t\t\teditor.selection.setRng(rng);\n\n\t\t\t\t\t\treturn br;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tfunction isTextBlock(node) {\n\t\t\t\t\treturn node && editor.schema.getTextBlockElements()[node.tagName];\n\t\t\t\t}\n\n\t\t\t\tif (!rng.collapsed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontainer = rng.startContainer;\n\t\t\t\toffset = rng.startOffset;\n\t\t\t\tblockElm = dom.getParent(container, dom.isBlock);\n\t\t\t\tif (!isTextBlock(blockElm)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (container.nodeType == 1) {\n\t\t\t\t\tcontainer = container.childNodes[offset];\n\t\t\t\t\tif (container && container.tagName != 'BR') {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tsibling = blockElm.nextSibling;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsibling = blockElm.previousSibling;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(blockElm) && isTextBlock(sibling) && dom.isEmpty(sibling)) {\n\t\t\t\t\t\tif (cloneTextBlockWithFormats(blockElm, container)) {\n\t\t\t\t\t\t\tdom.remove(sibling);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (container.nodeType == 3) {\n\t\t\t\t\tpath = NodePath.create(blockElm, container);\n\t\t\t\t\tclonedBlockElm = blockElm.cloneNode(true);\n\t\t\t\t\tcontainer = NodePath.resolve(clonedBlockElm, path);\n\n\t\t\t\t\tif (isForward) {\n\t\t\t\t\t\tif (offset >= container.data.length) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset, 1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset <= 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dom.isEmpty(clonedBlockElm)) {\n\t\t\t\t\t\treturn cloneTextBlockWithFormats(blockElm, container);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "b6179054818ebf5dc948107d1aedaa71", "score": "0.5082276", "text": "function removeUnderlineSelection() {\n\n var sel = window.getSelection();\n var range = sel.getRangeAt(0);\n\n var nodes = getRangeTextNodes(range);\n\n for (var i = 0; i < nodes.length; i++) {\n var node = nodes[i];\n// unhighlight(node);\n var parent = node.parentNode;\n// window.TextSelection.jsLog(\"====\\n!@@@@@@@@@@! span= \" + parent.getElementsByTagName(\"span\").length);\n if (parent.nodeName != \"SPAN\") {\n unhighlight(node);\n// window.TextSelection.jsLog(\"1111\");\n } else {\n// window.TextSelection.jsLog(\"2222\");\n unhighlight(parent);\n }\n\n// window.TextSelection.jsError(\"!@@@@@@@@@@! = \" + parent.nodeType);\n// window.TextSelection.jsError(\"!@@@@@@@@@@! = \" + parent.textContent);\n// window.TextSelection.jsError(\"!@@@@@@@@@@! = \" + parent.nodeName);\n// continue;\n//\n// var r = document.createRange();\n// r.setStart(node, 0);\n// r.setEnd(node, node.textContent.length);\n// setRangeTextDecoration(r, \"none\");\n//\n//\n//// r.setStart(node, )\n// if (node.style) {\n// node.style.textDecoration = \"none\";\n// }\n }\n}", "title": "" }, { "docid": "f632b127f8232698aada73e6a4ae21de", "score": "0.5074082", "text": "clean(html) {\n\t\treturn html\n\t\t\t.replace(/(&#xA0;)+/g, ' ')\n\t\t\t.replace(' ', ' ')\n\t\t\t.replace(/\\s*([<>])\\s*/g, '$1');\n\t}", "title": "" }, { "docid": "083bba32aaf9d1f157b2b5bac5265916", "score": "0.50731266", "text": "function _cleanupStyles(target) {\n for (var n in this.properties) {\n target.style[n] = '';\n }\n }", "title": "" }, { "docid": "bec0e204d14b894fa217e9e32c18457f", "score": "0.50725275", "text": "function handleBrokenWordDelete( elem ) {\n elem = $(elem).closest('g');\n if ( elem.length > 0 && elem.hasClass('Word') && elem.attr('id').match(/_part[12]$/) ) {\n var\n deltext = self.cfg.textFormatter(elem.find('> .TextEquiv').html()).replace(/\\u00AD/g,''),\n wpart = elem.attr('id').replace(/.*(_w[^_]+_part[12])$/,'$1');\n if ( wpart.match(/1$/) )\n wpart = wpart.replace(/1$/,'2');\n else\n wpart = wpart.replace(/2$/,'1');\n elem = elem.closest('g.TextRegion').find('g[id$=\"'+wpart+'\"].wordpart');\n var\n keeptext = self.cfg.textFormatter(elem.find('> .TextEquiv').html()).replace(/\\u00AD/g,''),\n newtext = wpart.match(/1$/) ? keeptext+deltext : deltext+keeptext,\n newid = elem.attr('id').replace(/_part[12]$/,'');\n alert('WARNING: Due to part of broken word deletion, the other part will be updated.\\nid: '+elem.attr('id')+' => '+newid+'\\ntext: \"'+keeptext+'\" => \"'+newtext+'\"');\n elem.attr( 'id', newid );\n elem.find('> .TextEquiv').html( self.cfg.textParser(newtext) );\n }\n }", "title": "" }, { "docid": "6ff16da1d0d2e83b93f5bcdb77acb421", "score": "0.5069435", "text": "function trimNbspAfterDeleteAndPaddValue() {\n\t\t\tvar rng, container, offset;\n\n\t\t\trng = selection.getRng(true);\n\t\t\tcontainer = rng.startContainer;\n\t\t\toffset = rng.startOffset;\n\n\t\t\tif (container.nodeType == 3 && rng.collapsed) {\n\t\t\t\tif (container.data[offset] === '\\u00a0') {\n\t\t\t\t\tcontainer.deleteData(offset, 1);\n\n\t\t\t\t\tif (!/[\\u00a0| ]$/.test(value)) {\n\t\t\t\t\t\tvalue += ' ';\n\t\t\t\t\t}\n\t\t\t\t} else if (container.data[offset - 1] === '\\u00a0') {\n\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\n\t\t\t\t\tif (!/[\\u00a0| ]$/.test(value)) {\n\t\t\t\t\t\tvalue = ' ' + value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "6ff16da1d0d2e83b93f5bcdb77acb421", "score": "0.5069435", "text": "function trimNbspAfterDeleteAndPaddValue() {\n\t\t\tvar rng, container, offset;\n\n\t\t\trng = selection.getRng(true);\n\t\t\tcontainer = rng.startContainer;\n\t\t\toffset = rng.startOffset;\n\n\t\t\tif (container.nodeType == 3 && rng.collapsed) {\n\t\t\t\tif (container.data[offset] === '\\u00a0') {\n\t\t\t\t\tcontainer.deleteData(offset, 1);\n\n\t\t\t\t\tif (!/[\\u00a0| ]$/.test(value)) {\n\t\t\t\t\t\tvalue += ' ';\n\t\t\t\t\t}\n\t\t\t\t} else if (container.data[offset - 1] === '\\u00a0') {\n\t\t\t\t\tcontainer.deleteData(offset - 1, 1);\n\n\t\t\t\t\tif (!/[\\u00a0| ]$/.test(value)) {\n\t\t\t\t\t\tvalue = ' ' + value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "45c5d71a319e651dff2b585a1d404ab5", "score": "0.5068384", "text": "function keyCommandPlainBackspace(editorState){var afterRemoval=removeTextWithStrategy(editorState,function(strategyState){var selection=strategyState.getSelection();var content=strategyState.getCurrentContent();var key=selection.getAnchorKey();var offset=selection.getAnchorOffset();var charBehind=content.getBlockForKey(key).getText()[offset-1];return moveSelectionBackward(strategyState,charBehind?UnicodeUtils.getUTF16Length(charBehind,0):1);},'backward');if(afterRemoval===editorState.getCurrentContent()){return editorState;}var selection=editorState.getSelection();return EditorState.push(editorState,afterRemoval.set('selectionBefore',selection),selection.isCollapsed()?'backspace-character':'remove-range');}", "title": "" }, { "docid": "d544c4d1d201ebb3d24a4d903662e890", "score": "0.5066693", "text": "function fixMarkup(value) {\n\t if (options.tabReplace) {\n\t value = value.replace(/^((<[^>]+>|\\t)+)/gm, function(match, p1 /*..., offset, s*/) {\n\t return p1.replace(/\\t/g, options.tabReplace);\n\t });\n\t }\n\t if (options.useBR) {\n\t value = value.replace(/\\n/g, '<br>');\n\t }\n\t return value;\n\t }", "title": "" }, { "docid": "d544c4d1d201ebb3d24a4d903662e890", "score": "0.5066693", "text": "function fixMarkup(value) {\n\t if (options.tabReplace) {\n\t value = value.replace(/^((<[^>]+>|\\t)+)/gm, function(match, p1 /*..., offset, s*/) {\n\t return p1.replace(/\\t/g, options.tabReplace);\n\t });\n\t }\n\t if (options.useBR) {\n\t value = value.replace(/\\n/g, '<br>');\n\t }\n\t return value;\n\t }", "title": "" }, { "docid": "d544c4d1d201ebb3d24a4d903662e890", "score": "0.5066693", "text": "function fixMarkup(value) {\n\t if (options.tabReplace) {\n\t value = value.replace(/^((<[^>]+>|\\t)+)/gm, function(match, p1 /*..., offset, s*/) {\n\t return p1.replace(/\\t/g, options.tabReplace);\n\t });\n\t }\n\t if (options.useBR) {\n\t value = value.replace(/\\n/g, '<br>');\n\t }\n\t return value;\n\t }", "title": "" }, { "docid": "d544c4d1d201ebb3d24a4d903662e890", "score": "0.5066693", "text": "function fixMarkup(value) {\n\t if (options.tabReplace) {\n\t value = value.replace(/^((<[^>]+>|\\t)+)/gm, function(match, p1 /*..., offset, s*/) {\n\t return p1.replace(/\\t/g, options.tabReplace);\n\t });\n\t }\n\t if (options.useBR) {\n\t value = value.replace(/\\n/g, '<br>');\n\t }\n\t return value;\n\t }", "title": "" }, { "docid": "ec11953a15b34ef3e7cb4ffb579af375", "score": "0.5065621", "text": "function afterComparing(element) {\n $body.css('pointer-events', 'inherit');\n $(element).removeAttr('style').removeClass('selected').html('');\n }", "title": "" }, { "docid": "76fc2c6afd9aa4347f9eabcacb486a3e", "score": "0.5064044", "text": "function removeHighlights() {\n $(\".edit-box, .edit-box > p\").css({\n \"border\": \"\"\n });\n}", "title": "" }, { "docid": "9e4a077282d24a7197db44490955689f", "score": "0.5053884", "text": "function applyInlineStyle(editor, callback) {\n editor.focus();\n var range = editor.getSelectionRange();\n if (range && range.collapsed) {\n var node = range.startContainer;\n var isEmptySpan = roosterjs_editor_dom_1.getTagOfNode(node) == 'SPAN' &&\n (!node.firstChild ||\n (roosterjs_editor_dom_1.getTagOfNode(node.firstChild) == 'BR' && !node.firstChild.nextSibling));\n if (isEmptySpan) {\n editor.addUndoSnapshot();\n callback(node);\n }\n else {\n var isZWSNode = node &&\n node.nodeType == 3 /* Text */ &&\n node.nodeValue == ZERO_WIDTH_SPACE &&\n roosterjs_editor_dom_1.getTagOfNode(node.parentNode) == 'SPAN';\n if (!isZWSNode) {\n editor.addUndoSnapshot();\n // Create a new text node to hold the selection.\n // Some content is needed to position selection into the span\n // for here, we inject ZWS - zero width space\n node = editor.getDocument().createTextNode(ZERO_WIDTH_SPACE);\n range.insertNode(node);\n }\n roosterjs_editor_dom_1.applyTextStyle(node, callback);\n editor.select(node, -1 /* End */);\n }\n }\n else {\n // This is start and end node that get the style. The start and end needs to be recorded so that selection\n // can be re-applied post-applying style\n editor.addUndoSnapshot(function () {\n var firstNode;\n var lastNode;\n var contentTraverser = editor.getSelectionTraverser();\n var inlineElement = contentTraverser && contentTraverser.currentInlineElement;\n while (inlineElement) {\n var nextInlineElement = contentTraverser.getNextInlineElement();\n inlineElement.applyStyle(function (element, isInnerNode) {\n callback(element, isInnerNode);\n firstNode = firstNode || element;\n lastNode = element;\n });\n inlineElement = nextInlineElement;\n }\n if (firstNode && lastNode) {\n editor.select(firstNode, -2 /* Before */, lastNode, -3 /* After */);\n }\n }, \"Format\" /* Format */);\n }\n}", "title": "" }, { "docid": "105bdd41f833a40ac23fa69b72ccc043", "score": "0.5052928", "text": "function TagList_fixJsRefs(targetDOM, selection) {\r}", "title": "" }, { "docid": "bd340a9a4d3ec170e0918efd3608a884", "score": "0.50475436", "text": "function EditorCleanup() {\n SwitchInsertCharToAnotherEditorOrClose();\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "a55f9103f019351ead255c02a86277dd", "score": "0.5043472", "text": "function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {\n var ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element),\n token = formattingElementEntry.token,\n newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);\n\n p._adoptNodes(furthestBlock, newElement);\n p.treeAdapter.appendChild(furthestBlock, newElement);\n\n p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);\n p.activeFormattingElements.removeEntry(formattingElementEntry);\n\n p.openElements.remove(formattingElementEntry.element);\n p.openElements.insertAfter(furthestBlock, newElement);\n}", "title": "" }, { "docid": "ab6401c3abd18447dbc1d6a036bf067d", "score": "0.50432795", "text": "function undoHighlightLine(code_mirror_box, css) {\n var identifier = \"_\" + css\n if (identifier in code_mirror_box) {\n var lineHandle = code_mirror_box[identifier]\n code_mirror_box.removeLineClass(lineHandle, \"background\", css);\n }\n}", "title": "" }, { "docid": "ee80962d1d0e7d8991777ad6a55a0680", "score": "0.50411147", "text": "function remove()\n\t\t{\n\t\t\t\n\t\t\tvar a1=$(element).find(\"#\"+lastid).get(0);\n\t\t\tvar a2=$(element).find(\"#\"+lastid.replace(\"g\",\"s\")).get(0);\n\t\t\ta2.innerHTML = \"\";\n\t\t\ta1.removeAttribute(\"style\");\n\t\t\ta1.removeAttribute(\"src\");\n\t\t\ta1.removeAttribute(\"type\");\n\t\t\ta1.removeAttribute(\"readonly\");\n\t\t\ta1.setAttribute(\"type\",\"text\");\t\n\t\t\ta1.setAttribute(\"value\",\"\");\n\t\t\ta1.value=\"\";\n\t\t\n\t\t}", "title": "" }, { "docid": "936544b1cd6d14f80310a1cee1ef22d2", "score": "0.50370646", "text": "function Calendar_fixupTags( wtext )\n{\norig = new String( wtext )\norig = this.replaceStr( orig, \"<br>\", \"*br*\" )\norig = this.replaceStr( orig, \" \", \"&nbsp\" )\norig = this.replaceStr( orig, \"<\", \"<\" )\norig = this.replaceStr( orig, \">\", \">\" )\norig = this.replaceStr( orig, \"*br*\", \"<br>\" )\nreturn orig\n}", "title": "" }, { "docid": "a6f078485c9e85aa6c3fd5af65550013", "score": "0.5031674", "text": "function fixMarkup(value) {\n if (options.tabReplace) {\n value = value.replace(/^((<[^>]+>|\\t)+)/gm, function(match, p1, offset, s) {\n return p1.replace(/\\t/g, options.tabReplace);\n });\n }\n if (options.useBR) {\n value = value.replace(/\\n/g, '<br>');\n }\n return value;\n }", "title": "" }, { "docid": "a6f078485c9e85aa6c3fd5af65550013", "score": "0.5031674", "text": "function fixMarkup(value) {\n if (options.tabReplace) {\n value = value.replace(/^((<[^>]+>|\\t)+)/gm, function(match, p1, offset, s) {\n return p1.replace(/\\t/g, options.tabReplace);\n });\n }\n if (options.useBR) {\n value = value.replace(/\\n/g, '<br>');\n }\n return value;\n }", "title": "" }, { "docid": "a6f078485c9e85aa6c3fd5af65550013", "score": "0.5031674", "text": "function fixMarkup(value) {\n if (options.tabReplace) {\n value = value.replace(/^((<[^>]+>|\\t)+)/gm, function(match, p1, offset, s) {\n return p1.replace(/\\t/g, options.tabReplace);\n });\n }\n if (options.useBR) {\n value = value.replace(/\\n/g, '<br>');\n }\n return value;\n }", "title": "" } ]
7dddf3f4c1cb8a6b38c550f35e25c86f
Description This file implements `StaveLine` which are simply lines that connect two notes. This object is highly configurable, see the `render_options`. A simple line is often used for notating glissando articulations, but you can format a `StaveLine` with arrows or colors for more pedagogical purposes, such as diagrams. Attribution: Arrow rendering implementations based off of Patrick Horgan's article, "Drawing lines and arcs with arrow heads on HTML5 Canvas" Draw an arrow head that connects between 3 coordinates
[ { "docid": "409fbdccc1ab191cb1019d92969d5aa7", "score": "0.0", "text": "function drawArrowHead(ctx, x0, y0, x1, y1, x2, y2) {\n\t\t // all cases do this.\n\t\t ctx.beginPath();\n\t\t ctx.moveTo(x0, y0);\n\t\t ctx.lineTo(x1, y1);\n\t\t ctx.lineTo(x2, y2);\n\t\t ctx.lineTo(x0, y0);\n\t\t ctx.closePath();\n\t\t\n\t\t ctx.fill();\n\t\t}", "title": "" } ]
[ { "docid": "72629dfbd542aedeed347a48f30ff464", "score": "0.69247943", "text": "function Line() {}", "title": "" }, { "docid": "e8b4500d1b58211660b44cec4e622a78", "score": "0.68670243", "text": "function Line(){}", "title": "" }, { "docid": "621f04eedc044b2e9953d4e5b30d839a", "score": "0.6771977", "text": "function EditorLine(point0, point1, adjacent0, adjacent1) {\n this.p0 = point0;\n this.p1 = point1;\n this.normal;\n this.adjacent0 = adjacent0;\n this.adjacent1 = adjacent1;\n this.id = generateID(this);\n}", "title": "" }, { "docid": "eb11ed5a3c7901b21865d5a3e7936559", "score": "0.66803694", "text": "function Line( color, name ){\n // the Line object creates a subway line. \n // color: must be a paper.js RgbColor or a keyword color, eg: 'black', 'green'.\n // name: the unique name of the line. \n\n this['color'] = color;\n this['path'] = new Path();\n this['path'].strokeWidth = LINE_WIDTH;\n this['path'].strokeColor = this['color'];\n this['name'] = name;\n\t\n}", "title": "" }, { "docid": "9f412e60ecb2dcead868219a63a292ee", "score": "0.6614311", "text": "function Line ( text, styles ) {\n this.styles = styles || [ text, null ];\n this.text = text;\n this.height = 1;\n this.marked = this.gutterMarker = this.className = this.handlers = null;\n this.stateAfter = this.parent = this.hidden = null;\n }", "title": "" }, { "docid": "3f36e9ca9496a12da6dcf597c564ee18", "score": "0.6588623", "text": "function line() {\n let x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0;\n \n function draw(datum) {\n const x10 = typeof x1 === \"function\" ? x1(datum) : x1,\n y10 = typeof y1 === \"function\" ? y1(datum) : y1,\n x20 = typeof x2 === \"function\" ? x2(datum) : x2,\n y20 = typeof y2 === \"function\" ? y2(datum) : y2;\n \n return `M${x10},${y10}L${x20},${y20}`;\n }\n \n draw.x1 = function(_) {\n return arguments.length ? ((x1 = _), draw) : x1;\n };\n draw.y1 = function(_) {\n return arguments.length ? ((y1 = _), draw) : y1;\n };\n draw.x2 = function(_) {\n return arguments.length ? ((x2 = _), draw) : x2;\n };\n draw.y2 = function(_) {\n return arguments.length ? ((y2 = _), draw) : y2;\n };\n \n return draw;\n }", "title": "" }, { "docid": "56e27b6ecee98bf60f0c7e093c8c014b", "score": "0.65342677", "text": "function Line(text, styles) {\n this.styles = styles || [text, null];\n this.text = text;\n this.height = 1;\n this.marked = this.gutterMarker = this.className = null;\n this.stateAfter = this.parent = this.hidden = null;\n }", "title": "" }, { "docid": "8bee4571259d6d82cf915e3ee1161047", "score": "0.6444705", "text": "line(id, s1, s2, style){\n let p = (this.paths[id]) \n ? this.paths[id].update(s1.x,s1.y,s2.x,s2.y, style) \n : new Path(this.ctx,id,s1.x,s1.y,s2.x,s2.y, style);\n this.paths[id] = p;\n p.draw();\n }", "title": "" }, { "docid": "0dccc7e06c49bfcdc0f2e6d5b37a6e10", "score": "0.6410954", "text": "function LineElement() {\n var _this = _super.call(this, 'line') || this;\n _this.getP1 = _this.getP1.bind(_this);\n _this.setP1 = _this.setP1.bind(_this);\n _this.getP2 = _this.getP2.bind(_this);\n _this.setP2 = _this.setP2.bind(_this);\n return _this;\n }", "title": "" }, { "docid": "5314317224c39e1d3954c77709c96d89", "score": "0.6408584", "text": "function snakeline(shape, options) {\n if (shape && shape.getType() === 'LineString') {\n return new PathAnimation(shape.getCoordinates().slice(0), shape, options);\n }\n throw 'Specified shape is not a LineString type, or no map specified.';\n }", "title": "" }, { "docid": "b9c6b0172b1ce74254f9aee6773027a6", "score": "0.63877404", "text": "function renderLine() \n{\n // If we're not drawing a line, don't bother running this function\n if (!isDrawing)\n return;\n \n var program = changeProgram(programDefault);\n \n // Define the line array\n var line_array = [\n mouseStartPos[0], mouseStartPos[1], \n 1.0, 1.0, 0.0,\n \n mouseEndPos[0], mouseEndPos[1],\n 1.0, 1.0, 0.0,\n ];\n \n // Create a buffer and fill it with the line array\n createBuffer(line_array);\n \n // Explain how the data is packed\n var vPosition = gl.getAttribLocation(program, \"vPosition\");\n gl.vertexAttribPointer(vPosition, SIZE_POS, gl.FLOAT, false, FLOATSIZE*SIZE_VERT, 0);\n gl.enableVertexAttribArray(vPosition);\n var vColor = gl.getAttribLocation(program, \"vColor\");\n gl.vertexAttribPointer(vColor, SIZE_COL, gl.FLOAT, false, FLOATSIZE*SIZE_VERT, FLOATSIZE*SIZE_POS);\n gl.enableVertexAttribArray(vColor);\n \n // Render the line\n gl.drawArrays(gl.LINES, 0, 2);\n}", "title": "" }, { "docid": "bfc160761805fe25831fc885b6ad5a37", "score": "0.6349097", "text": "function Line(options) {\n\t\tLineBase.call(this);\n\t\tthis.type = 'line';\n\t\tvar opts = {\n\t\t\t// prop: start\n\t\t\t// [x, y] coordinates for the start of the line.\n\t\t\tstart : [],\n\t\t\t// prop: stop\n\t\t\t// [x, y] coordinates for the end of the line.\n\t\t\tstop : []\n\t\t};\n\t\t$.extend(true, this.options, opts, options);\n\n\t\tif (this.options.showTooltipPrecision < 0.01) {\n\t\t\tthis.options.showTooltipPrecision = 0.01;\n\t\t}\n\t}", "title": "" }, { "docid": "bfc160761805fe25831fc885b6ad5a37", "score": "0.6349097", "text": "function Line(options) {\n\t\tLineBase.call(this);\n\t\tthis.type = 'line';\n\t\tvar opts = {\n\t\t\t// prop: start\n\t\t\t// [x, y] coordinates for the start of the line.\n\t\t\tstart : [],\n\t\t\t// prop: stop\n\t\t\t// [x, y] coordinates for the end of the line.\n\t\t\tstop : []\n\t\t};\n\t\t$.extend(true, this.options, opts, options);\n\n\t\tif (this.options.showTooltipPrecision < 0.01) {\n\t\t\tthis.options.showTooltipPrecision = 0.01;\n\t\t}\n\t}", "title": "" }, { "docid": "903897ea8519869e2f0014fae26771fd", "score": "0.63341105", "text": "lineDrag (event) {\n // remove if it exists, so that one line is only\n // visible at a time\n if (this.line != null) {\n this.line.remove()\n }\n\n // draw the\n this.line = new paper.Path()\n this.line.strokeColor = 'black'\n this.line.add(event.downPoint)\n this.line.add(event.point)\n this.line.strokeWidth = (this.toolOption.toolSize * grid.squareWidth)\n }", "title": "" }, { "docid": "b1f785a815f5555eedf7b29331a14cf9", "score": "0.63195306", "text": "static render(lineObject, ctx, color, path, width) {\n /**\n * Round number values because decimal points significantly affects canvas performance.\n */\n const internalPath = path.map(([x, y]) => {\n return [Math.round(x), Math.round(y)];\n });\n const internalWidth = Math.round(width);\n\n /**\n * Persist render properties. Render properties are processed via use defined properties, i.e.\n * rounding decimal points, and are passed to canvas render APIs directly.\n */\n const renderProps = {\n color,\n path: internalPath,\n width: internalWidth,\n };\n lineObject.renderProps = renderProps;\n\n /**\n * Skip if it doesn't have a line width.\n */\n if (renderProps.width === 0) return;\n /**\n * Skip if it cannot become a line.\n */\n if (renderProps.path.length <= 1) return;\n\n /**\n * Create a path 2D instance to simplify finding whether a given point is on the polyline.\n * See findByPosition function for more details.\n */\n const path2D = new Path2D();\n\n /**\n * Move pointer to the line starting point.\n */\n const [startingX, startingY] = renderProps.path[0];\n path2D.moveTo(startingX, startingY);\n /**\n * Go through all points on line path to complete a polyline.\n */\n renderProps.path.slice(1).forEach(([x, y]) => {\n path2D.lineTo(x, y);\n });\n\n /**\n * Begin a new line.\n */\n ctx.beginPath();\n /**\n * Set line colour and width.\n */\n ctx.strokeStyle = renderProps.color;\n ctx.lineWidth = renderProps.width;\n\n /**\n * Persist render properties. It will be used in mouse events to find whether a mouse pointer is\n * on a polyline.\n */\n lineObject.renderProps.path2D = path2D;\n\n ctx.stroke(path2D);\n }", "title": "" }, { "docid": "8c7bb3dc027b29ecc23540b9c04f53ae", "score": "0.63031924", "text": "renderLine(points, args) {\n const spark = this.sparkline;\n const g = this.sparkline.renderer.createGroup({\n id: spark.element.id + '_sparkline_g',\n 'clip-path': 'url(#' + this.clipId + ')'\n });\n let color = this.sparkline.fill;\n color = (this.sparkline.fill === '#00bdae' && this.sparkline.theme === 'Bootstrap4')\n ? this.sparkline.sparkTheme.axisLineColor : color;\n const pathOption = new PathOption$2(spark.element.id + '_sparkline_line', 'transparent', args.lineWidth, color, spark.opacity);\n let d = '';\n for (let i = 0, len = points.length; i < len; i++) {\n if (i === 0) {\n d = 'M ' + points[0].x + ' ' + points[i].y + ' ';\n }\n d += 'L ' + points[i].x + ' ' + points[i].y + ' ';\n }\n pathOption.d = d;\n drawPath(this.sparkline, pathOption, g);\n this.sparkline.svgObject.appendChild(g);\n }", "title": "" }, { "docid": "049caa9d4395890ae66b420775970a52", "score": "0.62940013", "text": "function Line(x1,y1,x2,y2){\n this.x1=x1;\n this.y1=y1;\n this.x2=x2;\n this.y2=y2;\n }", "title": "" }, { "docid": "d5b738693b4a64c527d5676590af3686", "score": "0.62844", "text": "function Line(x1, y1, x2, y2) {\n\tthis.x1 = x1;\n\tthis.y1 = y1;\n\tthis.x2 = x2;\n\tthis.y2 = y2;\n}", "title": "" }, { "docid": "723399282aed79c32631774aff457c6d", "score": "0.62769586", "text": "function LineSegment(x1, y1, x2, y2) {\n this.x1 = x1;\n this.y1 = y1;\n this.x2 = x2;\n this.y2 = y2;\n}", "title": "" }, { "docid": "94dc2bc5252dca0a70b1472b92b80eba", "score": "0.6257738", "text": "function Line(x1, y1, x2, y2, i, wig) {\n this.x1 = x1;\n this.y1 = y1;\n this.x2 = x2;\n this.y2 = y2;\n this.i = i;\n this.wig = wig;\n this.draw = function() {\n c.beginPath();\n c.moveTo(this.x1, this.y1);\n for (let j = 0; j < this.i; j++) {\n var wiggle = (Math.random() - 0.5) * this.wig;\n if (j == this.i - 1)\n wiggle = 0;\n if (x1 == x2) // if vert line\n c.lineTo(this.x1 + wiggle, this.y2 / this.i * (j + 1));\n else // if horizontal line\n c.lineTo(this.x2 / this.i * (j + 1), this.y1 + wiggle);\n }\n c.strokeStyle = \"#fa34a3\";\n c.stroke();\n };\n }", "title": "" }, { "docid": "99ae8a46492739471c0792831e388521", "score": "0.62422466", "text": "function Line(){\n this.initialize.apply(this, arguments);\n}", "title": "" }, { "docid": "1b72035ecf8ce1c12b2db6f897b0d3a1", "score": "0.6235338", "text": "_addLine(line) {\n //line.initProgram(this.webgl);\n line._vbuffer = this.webgl.createBuffer();\n this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);\n this.webgl.bufferData(this.webgl.ARRAY_BUFFER, line.xy, this.webgl.STREAM_DRAW);\n this.webgl.bindBuffer(this.webgl.ARRAY_BUFFER, line._vbuffer);\n line._coord = this.webgl.getAttribLocation(this.progThinLine, \"coordinates\");\n this.webgl.vertexAttribPointer(line._coord, 2, this.webgl.FLOAT, false, 0, 0);\n this.webgl.enableVertexAttribArray(line._coord);\n }", "title": "" }, { "docid": "4968b7e650656f43bb14ac578fe05a63", "score": "0.62334657", "text": "function Line() {\n var _this = _super.call(this) || this;\n _this._curve = \"linear\";\n _this._autorangeSmooth = false;\n _this._croppedRenderingEnabled = true;\n _this._collapseDenseVerticalLinesEnabled = false;\n _this._downsamplingEnabled = false;\n _this.addClass(\"line-plot\");\n var animator = new Animators.Easing();\n animator.stepDuration(plot_1.Plot._ANIMATION_MAX_DURATION);\n animator.easingMode(\"expInOut\");\n animator.maxTotalDuration(plot_1.Plot._ANIMATION_MAX_DURATION);\n _this.animator(Plots.Animator.MAIN, animator);\n _this.attr(\"stroke\", new Scales.Color().range()[0]);\n _this.attr(\"stroke-width\", \"2px\");\n return _this;\n }", "title": "" }, { "docid": "af97497f5b39184005251dc71d43294c", "score": "0.62282205", "text": "function wire_line(snap_scr, opts) {\n\n var o = {};\n o.points = opts.points || [0, 0];\n o.stroke = opts.stroke || 'black';\n o.fill = opts.fill || 'none';\n\n function left(x, y) {\n o.arrow = snap_scr.polyline(x + 10, y + 4, x, y, x + 10, y - 4);\n }\n\n function up(x, y) {\n o.arrow = snap_scr.polyline(x - 4, y + 10, x, y, x + 4, y + 10);\n }\n\n function right(x, y) {\n o.arrow = snap_scr.polyline(x - 10, y - 4, x, y, x - 10, y + 4);\n }\n\n function down(x, y) {\n o.arrow = snap_scr.polyline(x - 4, y - 10, x, y, x + 4, y - 10);\n }\n\n o.line = snap_scr.polyline(o.points).attr({\n stroke: o.stroke,\n fill: o.fill\n });\n\n var l = o.points.length;\n\n if (opts.arrow === 'left') left(o.points[0], o.points[1]);\n if (opts.arrow === 'up') up(o.points[0], o.points[1]);\n if (opts.arrow === 'right') right(o.points[l - 2], o.points[l - 1]);\n if (opts.arrow === 'down') down(o.points[l - 2], o.points[l - 1]);\n\n return o;\n\n}", "title": "" }, { "docid": "2cb9529efe107d6c4360bb4148d1b6b4", "score": "0.62140524", "text": "function Line(theX0, theY0, theX1, theY1, theColor, theSize, theTooltipText, theAction)\n{ this.ID=\"Line\"+_N_Line; _N_Line++; _zIndex++;\nthis.X0=theX0;\nthis.Y0=theY0;\nthis.X1=theX1;\nthis.Y1=theY1;\nthis.Color=theColor;\nif ((theColor!=\"\")&&(theColor.length==6)) this.Color=\"#\"+theColor;\nthis.Size=Number(_nvl(theSize,1));\nthis.Action=theAction;\nthis.SetVisibility=_SetVisibility;\nthis.SetColor=_SetColor;\nthis.SetTitle=_SetTitle;\nthis.MoveTo=_LineMoveTo;\nthis.ResizeTo=_LineResizeTo;\nthis.Delete=_Delete;\nvar xx0, yy0, xx1, yy1, ll, rr, tt, bb, ww, hh, ccl, ccr, cct, ccb;\nvar ss2=Math.floor(this.Size/2), nbsp=\"\";//(_IE)? \"&nbsp;\" : \"\";\nvar ddir=(((this.Y1>this.Y0)&&(this.X1>this.X0))||((this.Y1<this.Y0)&&(this.X1<this.X0))) ? true : false;\nif (theX0<=theX1) { ll=theX0; rr=theX1; }\nelse { ll=theX1; rr=theX0; }\nif (theY0<=theY1) { tt=theY0; bb=theY1; }\nelse { tt=theY1; bb=theY0; }\nww=rr-ll; hh=bb-tt;\n_DiagramTarget.document.write(\"<div id='\"+this.ID+\"' style='position:absolute;left:\"+eval(ll-ss2)+\"px;top:\"+eval(tt-ss2)+\"px; width:\"+eval(ww+this.Size)+\"px; height:\"+eval(hh+this.Size)+\"px; z-index:\"+_zIndex+\";' title='\"+_nvl(theTooltipText,\"\")+\"'>\");\nif ((ww==0)||(hh==0))\n_DiagramTarget.document.write(\"<div onClick='\"+_nvl(theAction,\"\")+\"' style='\"+_cursor(theAction)+\"position:absolute;left:0px;top:0px;width:\"+eval(ww+this.Size)+\"px;height:\"+eval(hh+this.Size)+\"px;background-color:\"+this.Color+\";font-size:1pt;line-height:1pt;'>\"+nbsp+\"</div>\");\nelse\n{ if (ww>hh)\n{ ccr=0;\ncct=0;\nwhile (ccr<ww)\n{ ccl=ccr;\nwhile ((Math.round(ccr*hh/ww)==cct)&&(ccr<=ww)) ccr++;\nif (ddir)\n_DiagramTarget.document.write(\"<div onClick='\"+_nvl(theAction,\"\")+\"' style='\"+_cursor(theAction)+\"position:absolute;left:\"+ccl+\"px;top:\"+cct+\"px;width:\"+eval(ccr-ccl+this.Size)+\"px;height:\"+this.Size+\"px;background-color:\"+this.Color+\";font-size:1pt;line-height:1pt;'>\"+nbsp+\"</div>\");\nelse\n_DiagramTarget.document.write(\"<div onClick='\"+_nvl(theAction,\"\")+\"' style='\"+_cursor(theAction)+\"position:absolute;left:\"+eval(ww-ccr)+\"px;top:\"+cct+\"px;width:\"+eval(ccr-ccl+this.Size)+\"px;height:\"+this.Size+\"px;background-color:\"+this.Color+\";font-size:1pt;line-height:1pt;'>\"+nbsp+\"</div>\");\ncct++;\n}\n}\nelse\n{ ccb=0;\nccl=0;\nwhile (ccb<hh)\n{ cct=ccb;\nwhile ((Math.round(ccb*ww/hh)==ccl)&&(ccb<hh)) ccb++;\nif (ddir)\n_DiagramTarget.document.write(\"<div onClick='\"+_nvl(theAction,\"\")+\"' style='\"+_cursor(theAction)+\"position:absolute;left:\"+ccl+\"px;top:\"+cct+\"px;width:\"+this.Size+\"px;height:\"+eval(ccb-cct+this.Size)+\"px;background-color:\"+this.Color+\";font-size:1pt;line-height:1pt;'>\"+nbsp+\"</div>\");\nelse\n_DiagramTarget.document.write(\"<div onClick='\"+_nvl(theAction,\"\")+\"' style='\"+_cursor(theAction)+\"position:absolute;left:\"+eval(ww-ccl)+\"px;top:\"+cct+\"px;width:\"+this.Size+\"px;height:\"+eval(ccb-cct+this.Size)+\"px;background-color:\"+this.Color+\";font-size:1pt;line-height:1pt;'>\"+nbsp+\"</div>\");\nccl++;\n}\n}\n}\n_DiagramTarget.document.writeln(\"</div>\");\nreturn(this);\n}", "title": "" }, { "docid": "e5411deaa464dda3e56d3b1f1885bbe7", "score": "0.6201284", "text": "function Line(svgId, segmentWidth, curvature, heightArr, sphereOfInfluence, svgAttr, isStatic) {\n \n if (!document.getElementById(svgId)){\n return;\n }\n\n this.svgEl = SVG(svgId);//initialize the svg\n\n\n this.svgPath = this.svgEl.path(\"M0,0\");\n \n //Pass the properties to the svgpath\n this.svgPath.attr(svgAttr);\n this.isStatic = isStatic; //boolean, true makes it not interactive\n this.domNode = document.getElementById(svgId);\n this.width = this.domNode.getBoundingClientRect().width;\n this.height = this.domNode.getBoundingClientRect().height;\n this.nodes = [];\n this.soi = sphereOfInfluence;\n this.curvature = curvature;\n this.segmentWidth = segmentWidth;\n this.heightArr = heightArr;\n\n this.mouseX = null;\n this.mouseY = null;\n \n this.isMovable = true; //this gets toggled when resizing to temporarily stop the frames.\n\n \n}", "title": "" }, { "docid": "6aba05677bb2658db5169a2dee00f429", "score": "0.61953884", "text": "function createLine(points){\n var line = new Konva.Line({\n points: points,\n stroke: 'cyan',\n strokeWidth: 1,\n opacity: .5,\n listening: 'true',\n lineJoin: 'round',\n });\n return line;\n }", "title": "" }, { "docid": "87f2101b4b644e23299115b6adc0cf96", "score": "0.6178658", "text": "function renderLine(\n startX,\n startY,\n endX,\n endY,\n lineColor,\n lineWidth,\n contentsDiv,\n graphicalEffects\n) {\n let contents = document.getElementById(contentsDiv);\n // Renders from to - equivalent to css styling top: endY.\n let canvas = contents.getElementsByClassName(\n `canvasID${graphicalEffects.x_hash}`\n );\n let ctx = canvas[0].getContext(\"2d\");\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = lineWidth;\n ctx.beginPath();\n ctx.moveTo(startX, startY);\n ctx.lineTo(endX, endY);\n ctx.stroke();\n}", "title": "" }, { "docid": "763b66fdd32d0b19f14be062baf08746", "score": "0.61737037", "text": "function RenderedLine(lineWidth, lineColor, fillColor, element) {\n var _this = _super.call(this, element) || this;\n /**\n * Line stroke cap (eg. round)\n */\n _this.StrokeCap = null;\n _this.Points = [];\n _this.LineWidth = lineWidth;\n _this.LineColor = lineColor;\n _this.FillColor = fillColor;\n return _this;\n }", "title": "" }, { "docid": "210272aee783de3454e5e16140f03d8e", "score": "0.6168948", "text": "function line(statement,reason) {\n this.statement = statement\n this.reason = reason\n}", "title": "" }, { "docid": "c93a37b1656efaaba20186b36176ff4b", "score": "0.6158837", "text": "function LineView(doc, line, lineN) {\n\t // The starting line\n\t this.line = line\n\t // Continuing lines, if any\n\t this.rest = visualLineContinued(line)\n\t // Number of logical lines in this visual line\n\t this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1\n\t this.node = this.text = null\n\t this.hidden = lineIsHidden(doc, line)\n\t}", "title": "" }, { "docid": "746bd4d4f9834981203d777c897a2a8f", "score": "0.61536866", "text": "function Line(Y) {\n this.Y = Y;\n this.Persons = [];\n this.isArriving = false;\n this.isServicing = false;\n}", "title": "" }, { "docid": "dfba7bef6c00f4c9638d1733728d22fa", "score": "0.6139716", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line\n // Continuing lines, if any\n this.rest = visualLineContinued(line)\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1\n this.node = this.text = null\n this.hidden = lineIsHidden(doc, line)\n}", "title": "" }, { "docid": "dfba7bef6c00f4c9638d1733728d22fa", "score": "0.6139716", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line\n // Continuing lines, if any\n this.rest = visualLineContinued(line)\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1\n this.node = this.text = null\n this.hidden = lineIsHidden(doc, line)\n}", "title": "" }, { "docid": "dfba7bef6c00f4c9638d1733728d22fa", "score": "0.6139716", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line\n // Continuing lines, if any\n this.rest = visualLineContinued(line)\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1\n this.node = this.text = null\n this.hidden = lineIsHidden(doc, line)\n}", "title": "" }, { "docid": "f3b7646e3a9f3a8c30be0bdeca8458ab", "score": "0.61387855", "text": "function drawLine(style, pt1, pt2) {\r\n\t\tcontext.strokeStyle = style;\r\n\t\tcontext.beginPath();\r\n\t\tcontext.moveTo(\r\n\t\t\t0.5 + world.left + (pt1.x * world.size),\r\n\t\t\t0.5 + world.top + (pt1.y * world.size));\r\n\t\tcontext.lineTo(\r\n\t\t\t0.5 + world.left + (pt2.x * world.size),\r\n\t\t\t0.5 + world.top + (pt2.y * world.size));\r\n\t\tcontext.stroke();\r\n\t}", "title": "" }, { "docid": "16f53f486a86f562842bd2c0277e529f", "score": "0.6138054", "text": "function line(x1, y1, x2, y2, svgCanvas, elementClass){\n\tthis.x1=x1;\n\tthis.x2=x2;\n\tthis.y1=y1;\n\tthis.y2=y2;\n\tthis.stroke=4;\n\t\n\tthis.element = document.createElementNS(svgNS, 'line');\n\t//unique identifier for this line\n\tthis.element.setAttribute('data-index', uniqueDataIndex);\n\tthis.element.setAttribute('class', elementClass);\n\t\n\tthis.draw();\n\tsvgCanvas.appendChild(this.element);\n}", "title": "" }, { "docid": "da0e0a2a431a4cf6d4fddb8c74f9cbb3", "score": "0.6136899", "text": "function Line(svgNode) {\n if (arguments.length > 0) {\n this.init(svgNode);\n }\n}", "title": "" }, { "docid": "a56ea00168c695e6837e5d95691696be", "score": "0.61364", "text": "function iLine(){\r\r\n mode=\"line\";\t\t//sets the drawmode to line\r\r\n console.log(\"Tool changes to \"+ mode); \r\r\n}", "title": "" }, { "docid": "e766bd254120479b27f3bcdffcace53f", "score": "0.61331123", "text": "function Line() {\n\t\tvar l = {};\n\t\tl.x1 = ex.width() - 420;\n\t\tl.y1 = 0;\n\t\tl.x2 = l.x1;\n\t\tl.y2 = ex.height() / 2 - 75;\n\t\tl.x3 = ex.width();\n\t\tl.y3 = l.y2;\n\t\tl.draw = function () {\n\t\t\t\t\tex.graphics.ctx.moveTo(l.x1,l.y1);\n\t\t\t\t\tex.graphics.ctx.lineTo(l.x2,l.y2);\n\t\t\t\t\tex.graphics.ctx.moveTo(l.x2,l.y2);\n\t\t\t\t\tex.graphics.ctx.lineTo(l.x3,l.y3);\n\t\t\t\t\tex.graphics.ctx.stroke();\n\t\t};\n\t\treturn l;\n\t}", "title": "" }, { "docid": "4acc1b0383f827ddaa669e3b75f40e10", "score": "0.61327124", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0cbb4294938cbb2b5d83d8f06a1d0dfd", "score": "0.613223", "text": "drawLine(startPoint, endPoint) {\n \n // declares new OctLine to be drawn\n let validLine = new OctLine(startPoint, endPoint);\n \n if (this.startingPoint === null) {// this is first line drawn in game\n \n /* assigns starting and ending point of game as\n starting and ending point of current line */\n this.startingPoint = new Point(startPoint.x, startPoint.y);\n this.endingPoint = new Point(endPoint.x, endPoint.y);\n\n } else if (startPoint.equals(this.startingPoint)) { /* line drawn from\n startingPoint */\n this.startingPoint = new Point(endPoint.x, endPoint.y);\n\n } else { // line drawn from endingPoint\n this.endingPoint = new Point(endPoint.x, endPoint.y);\n }\n\n // stores new line\n this.lines.push(new OctLine(startPoint, endPoint));\n\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "0ecaf1fba8d60bb43a6999c8a5ec69f0", "score": "0.6115903", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "c454bcaf1c13f3d26f583c3effbe3512", "score": "0.61143124", "text": "function primitive(options) {\n // The following points define lines by being taken in pairs.\n var values = transform([CENTER, LEFT, CENTER, TAIL, NOSE, LLEG, NOSE, RLEG, LLEG, RLEG], options).reduce(concat);\n var result = {\n mode: exports.BeginMode.LINES,\n attributes: {}\n };\n result.attributes[GraphicsProgramSymbols.ATTRIBUTE_POSITION] = { values: values, size: 3 };\n return result;\n }", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "3e971c51cba4b0f881ab03198b3d5d9b", "score": "0.6108353", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n}", "title": "" }, { "docid": "d1a1c0869e2178054a52d68fda2e69e0", "score": "0.61044246", "text": "function Line(props) {\n _classCallCheck(this, Line);\n\n var _this = _possibleConstructorReturn(this, (Line.__proto__ || Object.getPrototypeOf(Line)).call(this, props));\n\n _this.state = {\n hovered: false,\n height: props.height,\n active: true\n };\n return _this;\n }", "title": "" }, { "docid": "a4f1e1e8b9102d16796b24da91e2a180", "score": "0.61030746", "text": "drawStave(){\n //draw treble Lines\n this.context.strokeStyle = \"black\";\n this.drawLine(this.x,this.yFirstLine,this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+this.gap,this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+(this.gap*2),this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+(this.gap*3),this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+(this.gap*4),this.x+this.length);\n\n //draw Bass Lines\n this.drawLine(this.x,this.yFirstLine+(this.gap*10),this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+(this.gap*11),this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+(this.gap*12),this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+(this.gap*13),this.x+this.length);\n this.drawLine(this.x,this.yFirstLine+(this.gap*14),this.x+this.length);\n\n }", "title": "" }, { "docid": "e8939b3e2f428dd81f3eddfc104fd2a7", "score": "0.60940164", "text": "function LineView(doc, line, lineN) {\n\t // The starting line\n\t this.line = line;\n\t // Continuing lines, if any\n\t this.rest = visualLineContinued(line);\n\t // Number of logical lines in this visual line\n\t this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n\t this.node = this.text = null;\n\t this.hidden = lineIsHidden(doc, line);\n\t }", "title": "" }, { "docid": "e8939b3e2f428dd81f3eddfc104fd2a7", "score": "0.60940164", "text": "function LineView(doc, line, lineN) {\n\t // The starting line\n\t this.line = line;\n\t // Continuing lines, if any\n\t this.rest = visualLineContinued(line);\n\t // Number of logical lines in this visual line\n\t this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n\t this.node = this.text = null;\n\t this.hidden = lineIsHidden(doc, line);\n\t }", "title": "" }, { "docid": "e8939b3e2f428dd81f3eddfc104fd2a7", "score": "0.60940164", "text": "function LineView(doc, line, lineN) {\n\t // The starting line\n\t this.line = line;\n\t // Continuing lines, if any\n\t this.rest = visualLineContinued(line);\n\t // Number of logical lines in this visual line\n\t this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n\t this.node = this.text = null;\n\t this.hidden = lineIsHidden(doc, line);\n\t }", "title": "" }, { "docid": "e8939b3e2f428dd81f3eddfc104fd2a7", "score": "0.60940164", "text": "function LineView(doc, line, lineN) {\n\t // The starting line\n\t this.line = line;\n\t // Continuing lines, if any\n\t this.rest = visualLineContinued(line);\n\t // Number of logical lines in this visual line\n\t this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n\t this.node = this.text = null;\n\t this.hidden = lineIsHidden(doc, line);\n\t }", "title": "" }, { "docid": "e8939b3e2f428dd81f3eddfc104fd2a7", "score": "0.60940164", "text": "function LineView(doc, line, lineN) {\n\t // The starting line\n\t this.line = line;\n\t // Continuing lines, if any\n\t this.rest = visualLineContinued(line);\n\t // Number of logical lines in this visual line\n\t this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n\t this.node = this.text = null;\n\t this.hidden = lineIsHidden(doc, line);\n\t }", "title": "" }, { "docid": "664736a026e62e75689af978c1308524", "score": "0.60840434", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line;\n // Continuing lines, if any\n this.rest = visualLineContinued(line);\n // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;\n this.node = this.text = null;\n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "7c6bc346a4e50e8c60be5c44cdfedc8e", "score": "0.6070147", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line, // Continuing lines, if any\n this.rest = visualLineContinued(line), // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1, this.node = this.text = null, \n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "7c6bc346a4e50e8c60be5c44cdfedc8e", "score": "0.6070147", "text": "function LineView(doc, line, lineN) {\n // The starting line\n this.line = line, // Continuing lines, if any\n this.rest = visualLineContinued(line), // Number of logical lines in this visual line\n this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1, this.node = this.text = null, \n this.hidden = lineIsHidden(doc, line);\n }", "title": "" }, { "docid": "37d5e8a5be23ea29a13428a829db2ff0", "score": "0.6058241", "text": "function drawStraighLine(straightLine){\n context.beginPath();\n var x = straightLine.startPosition.x * width;\n var y = straightLine.startPosition.y * height;\n var b = straightLine.endPosition.x * width;\n var c = straightLine.endPosition.y * height;\n context.moveTo(x ,y);\n context.lineTo(b ,c);\n\n context.lineWidth = straightLine.width;\n context.strokeStyle = straightLine.color;\n context.stroke();\n }", "title": "" }, { "docid": "72821feb5a846e1e964fe0792aeb1c20", "score": "0.60393834", "text": "function line(id) {\n\tthis.id = id;\n\tif (colors[id]) {\n\t\tvar lineColor = colors[id];\n\t} else {\n\t\tvar lineColor = \"#575757\";\n\t}\n\tthis.polyline = L.polyline([], { color:lineColor, weight: 5.5, opacity: 0.8 }).addTo(map);\n\tthis.waypoints = [];\n\tthis.elePoints = null;\n\tthis.elevation = null;\n\tthis.eGain = null;\n\tthis.eLoss = null;\n\tthis.distance = null;\n\tthis.mostDirectDistance = null;\n\tthis.averageSpeed = null;\n\tthis.leftTurns = null;\n\tthis.coordinates = [];\n\tthis.sElevation = null;\n\tthis.sDistance = null;\n\tthis.sLeftTurns = null;\n\tthis.sAverageSpeed = null;\n}", "title": "" }, { "docid": "908bda860be45a0cbe7d57df91bec266", "score": "0.6031827", "text": "function MdLine() {\n }", "title": "" }, { "docid": "30f7e2d2a053bdc3c17a5bb6da9acef5", "score": "0.60251045", "text": "function drawLine(v1, v2) {\n\n // Generic blue line\n var lineMat = new THREE.LineBasicMaterial({ color: 0x0000ff }),\n lineGeo = new THREE.Geometry();\n\n // Push start and end vectors to the line's geometry\n lineGeo.vertices.push(v1);\n lineGeo.vertices.push(v2);\n\n // Create the line mesh\n var line = new THREE.Line(lineGeo, lineMat);\n\n // Add the line to the scene\n scene.add(line);\n}", "title": "" }, { "docid": "d423b91e038c38e60635d764518a3b6d", "score": "0.6011686", "text": "static line(spec) {\n return new LineDecoration(spec);\n }", "title": "" }, { "docid": "6a9f4c150ea9695162bb225d58f7657f", "score": "0.59936976", "text": "function LineSegment (x1, y1, x2, y2) {\n\t// line coordinates in the range [0,1]\n\tthis.x1 = x1;\n\tthis.x2 = x2;\n\tthis.y1 = y1;\n\tthis.y2 = y2;\n\t\n\t//integer coordinates for drawing\n\tthis.m1 = round(this.x1*N);\n\tthis.n1 = N - round(this.y1*N);\n\tthis.m2 = round(this.x2*N);\n\tthis.n2 = N - round(this.y2*N);\n\n\t// transform the line under rotation F\n\tthis.image = function() {\n\t\tvar F1 = F(this.x1, this.y1);\n\t\tthis.x1 = F1[0]; this.y1 = F1[1];\n\t\tvar F2 = F(this.x2, this.y2);\n\t\tthis.x2 = F2[0]; this.y2 = F2[1];\n\t\tthis.set_pixel_coords();\n\t}\n\t// transform the line under inverse rotation F^{-1}\n\tthis.inverse_image = function() {\n\t\tvar F1 = F_inv(this.x1, this.y1);\n\t\tthis.x1 = F1[0]; this.y1 = F1[1];\n\t\tvar F2 = F_inv(this.x2, this.y2);\n\t\tthis.x2 = F2[0]; this.y2 = F2[1];\n\t\tthis.set_pixel_coords();\n\t}\n\t// calculate the integer corrdinates (to be used for drawing)\n\tthis.set_pixel_coords = function() {\n\t\tthis.m1 = round(this.x1*N);\n\t\tthis.n1 = N - round(this.y1*N);\n\t\tthis.m2 = round(this.x2*N);\n\t\tthis.n2 = N - round(this.y2*N);\n\t}\n\tthis.length = function() {\n\t\treturn sqrt((this.x2-this.x1)*(this.x2-this.x1) + (this.y2-this.y1)*(this.y2-this.y1));\n\t}\n\tthis.print_coords = function() {\n\t\tconsole.log(this.x1, this.y1, this.x2, this.y2);\n\t}\n\t\n\tthis.print_pixel_coords = function() {\n\t\tconsole.log(this.m1, this.n1, this.m2, this.n2);\n\t}\n\t\n\tthis.mod_one = function() {\n\t\tvar floor = min(Math.floor(this.x1),Math.floor(this.x2));\n\t\tthis.x1 = this.x1-floor;\n\t\tthis.x2 = this.x2-floor;\n\t\tif (this.x1 < 0 || this.x1>1 || this.x2<0 || this.x2>1){\n\t\t\tprintln(\"mod one error\");\n\t\t\tnoLoop();\n\t\t}\n\t}\n\t\n\tthis.equals = function(that) {\n\t\treturn (this.m1 == that.m1 && this.m2 == that.m2 && this.n1 == that.n1 && this.n2 == that.n2);\n\t}\n}", "title": "" }, { "docid": "4acaefddc73344eba6f9ef33ac85171b", "score": "0.59780246", "text": "function drawNewLineSegment(){\n var vertices = lineGeometry.vertices;\n vertices.pop();\n vertices.push(new THREE.Vector3( drone.position.x, drone.position.y, drone.position.z));\n\n lineGeometry = new THREE.Geometry();\n\tlineGeometry.vertices = vertices;\n\n scene.remove( line );\n\tline = new THREE.Line( lineGeometry, lineMaterial )\n\tscene.add( line );\n}", "title": "" }, { "docid": "3bb25fb7ccf4a385eef3c64bc12e5385", "score": "0.5971493", "text": "function drawLine( lat, lng ) {\n\t\t\t\treturn viewer.entities.add({\n\t\t\t\t\tposition: Cesium.Cartesian3.fromDegrees( lng, lat, LINE_TOP, ellipsoid ),\n\t\t\t\t\tpolyline: {\n\t\t\t\t\t\tpositions: Cesium.Cartesian3.fromDegreesArrayHeights(\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tlng, lat, LINE_BOTTOM,\n\t\t\t\t\t\t\t\tlng, lat, LINE_TOP\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tellipsoid\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmaterial: LINE_COLOR,\n\t\t\t\t\t\twidth: 1\n\t\t\t\t\t},\n\t\t\t\t\tlabel: {\n\t\t\t\t\t\ttext: \"Lat: \" + lat + \", Lng: \" + lng,\n\t\t\t\t\t\tfont: \"24px sans-serif\",\n\t\t\t\t\t\teyeOffset: new Cesium.Cartesian3(0, 0, -100)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}", "title": "" }, { "docid": "5aa64b6fc56fcb235e2aa736c664eba9", "score": "0.5970662", "text": "function line (u1, v1, u2, v2) {\n newPath(); // Neuer Pfad (Standardwerte)\n ctx.moveTo(u1,v1); ctx.lineTo(u2,v2); // Linie vorbereiten\n ctx.stroke(); // Linie zeichnen\n }", "title": "" }, { "docid": "5750fb206741ceca96aa568001aa2681", "score": "0.5967194", "text": "function Line(origin, origineHandle, destination) {\n this.origin = origin;\n this.origineHandle = origineHandle;\n this.destination = destination;\n\n this.origin.children.push(destination);\n this.destination.parents.push(origin);\n\n // destinationHandle is always top\n\tthis.origin.addLine(this);\n\tthis.destination.addLine(this);\n\t\n\tthis.showBtn = false;\n\t\n\tthis.margin = 15;\n\tthis.arrowSize = 8;\n}", "title": "" }, { "docid": "4451464d15e709ea16e223bcadaa969c", "score": "0.5954725", "text": "function makeLine(svg, attrs) {\n\n // We create the text element first so our hand-rolled word wrapping\n // works with the correct font parameters\n let t = svg.text('').attr({\"fill\":\"black\",\"font-weight\":\"bold\"});\n t.addClass('text');\n let text = wrapText(t, attrs.width, attrs.text).join(\"\\n\");\n t.text(text);\n let color = attrs.color || '#ffef40';\n let leftUpper = {\n x : Math.min(attrs.startX, attrs.endX),\n y : Math.min(attrs.startY, attrs.endY),\n };\n let l = svg.line(\n attrs.startX-leftUpper.x,\n attrs.startY-leftUpper.y,\n attrs.endX-leftUpper.x,\n attrs.endY-leftUpper.y\n ).stroke({ width: 1, \"color\":color });\n l.addClass('main');\n let bb = l.bbox();\n\n var g = svg.group();\n g.addClass('userElement');\n g.addClass('typeLine'); // Maybe as data element instead?!\n g.add(l);\n g.add(t);\n g.move(leftUpper.x, leftUpper.y);\n\n // Text is allowed to bleed out of the \"paper\"\n t.center(bb.cx,bb.cy);\n\n // t.on('click', startTextEditing);\n\n g.on(\"mousedown\", (event) => {\n // We only want to select with the (primary) mouse button\n if( event.which === 1 ) {\n let overlay = addSelectionOverlay(svg, g.attr('id'));\n };\n });\n\n g.draggy();\n g.beforedrag = (e) => {\n // We only want to drag with the (primary) mouse button\n return e.which === 1\n };\n let dragging;\n let oldShapeState = attrs;\n g.on(\"dragstart\", (event) => {\n dragging = true;\n });\n g.on(\"dragend\", (event) => {\n if( dragging ) {\n let id = event.target.instance.attr('id');\n addSelectionOverlay(svg, id);\n let shapeInfo = getShapeInfo(event.target.instance);\n\n if( shapeInfo.startX != attrs.startX\n || shapeInfo.startY != attrs.startY\n || shapeInfo.endX != attrs.endX\n || shapeInfo.endY != attrs.endY\n ) {\n addAction('move/scale',\n () => { updateShape(svg, shapeInfo ); },\n () => { updateShape(svg, attrs )},\n );\n\n // broadcastShapeState(getShapeInfo(newShape),'dragend');\n updateUIControls(svg);\n };\n };\n });\n g.on(\"dragmove\", (event) => {\n if( dragging ) {\n addSelectionOverlay(svg, event.target.instance.attr('id'));\n let shapeInfo = getShapeInfo(event.target.instance);\n broadcastShapeState(shapeInfo,'dragmove');\n updateUIControls(svg);\n };\n });\n\n if( attrs.id ) {\n let oldNode = SVG.get(attrs.id);\n if( oldNode && oldNode.parent() ) {\n if( oldNode === g ) {\n console.log(\"Old and new node are identical?!\");\n } else {\n // console.log(\"Replacing old item\", oldNode, g);\n oldNode.replace( g );\n };\n };\n g.attr('id', attrs.id);\n } else {\n // Assign our prefix here to prevent collisions with other clients\n g.id(config.connection_prefix+\"-\"+g.id());\n };\n\n let layer = SVG.get('displayLayerNotes');\n layer.add(g);\n\n updateUIControls(svg);\n\n return g\n}", "title": "" }, { "docid": "d6548fa3f048bb5449aecf2a69afcb21", "score": "0.5943574", "text": "function drawLine(startX, startY, endX, endY, strokeStyle, lineWidth) {\n\t\t\tctx.save()\n\t\t if (strokeStyle != null) ctx.strokeStyle = strokeStyle;\n\t\t if (lineWidth != null) ctx.lineWidth = lineWidth;\n\t\t ctx.beginPath();\n\t\t ctx.moveTo(startX, startY);\n\t\t ctx.lineTo(endX, endY);\n\t\t ctx.stroke();\n\t\t ctx.closePath(); \n\t\t ctx.restore()\n\t\t}", "title": "" }, { "docid": "81c227e48a0f1d745958f125b3108012", "score": "0.5942296", "text": "function drawLine(line) {\n context.beginPath();\n context.moveTo(line.startPosition.x * width, line.startPosition.y * height);\n context.lineTo(line.endPosition.x * width, line.endPosition.y * height);\n context.lineWidth = line.width;\n context.strokeStyle = line.color;\n context.stroke();\n }", "title": "" }, { "docid": "e155a9a4583585b2402f87c6b44e7b13", "score": "0.5925193", "text": "function drawLine(doc, length) {\n var line = {\n x: pdf.xAxisValue,\n y: pdf.yAxisValue + 7,\n length: length\n };\n doc.setDrawColor(100);\n doc.line(line.x, line.y, line.length, line.y);\n return doc;\n}", "title": "" }, { "docid": "48ea09266209d77c13c7e8a5c5eb416d", "score": "0.592261", "text": "display(){\n var pointA= this.chain.bodyA.position;\n var pointB= this.chain.bodyB.position;\n\n strokeWeight(4);\n line(pointA.x, pointA.y, pointB.x, pointB.y);\n }", "title": "" }, { "docid": "c491f8575393ec2be1dce2ce27d2ee93", "score": "0.5921543", "text": "function TSMT$DashedLineDecorator() {\n var _this = _super.call(this) || this;\n _this.__radius = 3; // dot radius\n _this.__spacing = 4; // spacing between dots\n _this.__dotX = 0; // x-center of most recent dot\n _this.__dotY = 0; // y-center of most recent dot\n _this.__refX = 0; // reference x-coordinate from most recent moveTo or lineTo\n _this.__refY = 0; // reference y-coordinate from most recent moveTo or lineTo\n _this.__length = 2 * _this.__radius + _this.__spacing; // total length to move between center of prior dot and mouse position\n _this.__lSq = _this.__length * _this.__length; // test value\n _this.__unused = 0; // unused (squared) distance between last dot and reference coordinates\n // normalized arc-length and natural parameter as dot distribution progresses\n _this.__s = 0;\n _this.__t = 0;\n // quad control points (not used in V1.0)\n _this.__x0 = 0;\n _this.__y0 = 0;\n _this.__cx = 0;\n _this.__cy = 0;\n _this.__x1 = 0;\n _this.__y1 = 0;\n return _this;\n }", "title": "" }, { "docid": "4134272e186a6cd7697d8333cad1ed6b", "score": "0.5892292", "text": "function startLine (e) {\n e.preventDefault();\n\n var width = that.canvas.width;\n var height = that.canvas.height;\n\n strokes = that.strokes;\n sketching = true;\n that.undos = [];\n\n strokes.push({\n stroke: [],\n lineColor: opts.lineColor,\n lineSize: opts.lineSize / width,\n lineCap: opts.lineCap,\n lineJoin: opts.lineJoin,\n lineMiterLimit: opts.lineMiterLimit\n });\n\n var cursor = getCursor(e);\n strokes[strokes.length - 1].stroke.push({\n x: cursor.x / width,\n y: cursor.y / height\n });\n }", "title": "" }, { "docid": "e4aa59d3098b7f203c5d2eca47306fda", "score": "0.58698064", "text": "function Line(text, markedSpans, estimateHeight) {\n this.text = text\n attachMarkedSpans(this, markedSpans)\n this.height = estimateHeight ? estimateHeight(this) : 1\n}", "title": "" }, { "docid": "e4aa59d3098b7f203c5d2eca47306fda", "score": "0.58698064", "text": "function Line(text, markedSpans, estimateHeight) {\n this.text = text\n attachMarkedSpans(this, markedSpans)\n this.height = estimateHeight ? estimateHeight(this) : 1\n}", "title": "" } ]
43065a8ab3fca2292c71670a346d8d67
Matches Won by each Team
[ { "docid": "36bc72ae2153b2102648366003e78ef9", "score": "0.0", "text": "function fetchAndVisualizeDataWon() { \r\n fetch(\"./data_won.json\")\r\n .then(r => r.json())\r\n .then(visualizeWonData);\r\n}", "title": "" } ]
[ { "docid": "1c0cb6c7434a23cf1b6b4506fdc4ebf9", "score": "0.6582289", "text": "function getWinners(finalsGames) {\n let winners = finalsGames.map(match => {if (match[\"Home Team Goals\"] > match[\"Away Team Goals\"]){\n return match[\"Home Team Name\"];\n } else if (match[\"Home Team Goals\"] < match[\"Away Team Goals\"]) {\n return match[\"Away Team Name\"];\n } else if (match[\"Win Conditions\"] !== \"\") {\n return `******* ${match['Win conditions'].split(' ')[0]} *******`;\n }\n });\n return winners;\n}", "title": "" }, { "docid": "7a14e31f28440e0c5d09061b0b0a7558", "score": "0.6507939", "text": "function getCountryWins(data, teamInitials) {\n const winnersInitials = [];\n getFinals(data).forEach((match) => {\n if (match[\"Home Team Goals\"] > match[\"Away Team Goals\"])\n winnersInitials.push(match[\"Home Team Initials\"]);\n else if (match[\"Home Team Goals\"] < match[\"Away Team Goals\"])\n winnersInitials.push(match[\"Away Team Initials\"]);\n else {\n const winner = match[\"Win conditions\"].split(\" \")[0];\n const initials =\n match[\"Home Team Name\"] === winner\n ? match[\"Home Team Initials\"]\n : match[\"Away Team Initials\"];\n winnersInitials.push(initials);\n }\n });\n console.log(winnersInitials);\n return winnersInitials.reduce((total, winnerInitial) => {\n return winnerInitial === teamInitials ? total + 1 : total;\n }, 0);\n}", "title": "" }, { "docid": "c279122b268362e14f79caec5af348ca", "score": "0.6393491", "text": "function getWinners(getFinals) {\n const winners = [];\n getFinals(fifaData).forEach((match) => {\n if (match[\"Home Team Goals\"] > match[\"Away Team Goals\"])\n winners.push(match[\"Home Team Name\"]);\n else if (match[\"Home Team Goals\"] < match[\"Away Team Goals\"])\n winners.push(match[\"Away Team Name\"]);\n else winners.push(match[\"Win conditions\"].split(\" \")[0]);\n });\n return winners;\n}", "title": "" }, { "docid": "81bcc017c73b078a74a4b82817ccb1a3", "score": "0.63608265", "text": "function Get_list_of_matches_by_team(name){\n let team_type = t=>t.home_team == name || t.away_team == name;\n // The filter() method creates a new array with all elements \n // that pass the test implemented by the provided function.\n // callbackFn\n let playedGamesByTeam = playedGamesData[0].filter(team_type);\n let upcomingGamesByTeam = upcomingGamesData[0].filter(team_type);\n // The concat() method is used to merge two or more arrays. \n // This method does not change the existing arrays, but instead returns a new array\n let matchByTeam = playedGamesByTeam.concat(upcomingGamesByTeam);\n return matchByTeam;\n}", "title": "" }, { "docid": "15d61ef34306d32fd6276bb2bc9f59ca", "score": "0.6333249", "text": "function getWinners(data) {\n\n let awayTeam = data[`Away Team Goals`];\n let homeTeam = data[`Home Team Goals`];\n\n let winner = data.map(data => awayTeam > homeTeam? `${data[`Away Team Name`]}` : `${data[`Home Team Name`]}`)\n\n return winner;\n}", "title": "" }, { "docid": "daf00723d07c4fddb1902898c6af9822", "score": "0.6331252", "text": "function leaguesWithTeamWithLestWins() {\n // CODE HERE\n let result = {};\n for (let team of winsByTeams) {\n let leagueId = getLeagueId(team.teamId);\n let leagueName = getLeagueName(leagueId);\n if (result.hasOwnProperty(leagueName)) {\n if (team.wins < result[leagueName].wins) {\n result[leagueName] = {\n team: getTeamName(team.teamId),\n wins: team.wins\n };\n }\n } else {\n result[leagueName] = {\n team: getTeamName(team.teamId),\n wins: team.wins\n };\n }\n }\n return result;\n}", "title": "" }, { "docid": "fd2a3833fd6bee59e66afb5417f1c8db", "score": "0.62443936", "text": "function getTeamMatches(team) {\n return (matches_hash[team_group[team]])[team];\n}", "title": "" }, { "docid": "c16e27a535b0b7332b82e3518ceec77a", "score": "0.62104535", "text": "function pushDetailsInTeams(teams,matches){\n for(let i=0;i<teams.length;i++){\n let name=teams[i].name;\n for(let j=0;j<matches.length;j++){\n if(name==matches[j].t1 || name==matches[j].t2){\n if(name==matches[j].t1 ){\n teams[i].matches.push({\n opponenetTeam:matches[j].t2,\n teamScore:matches[j].team1Score,\n opponentScore:matches[j].team2Score,\n result:matches[j].result\n })\n }else{\n teams[i].matches.push({\n opponenetTeam:matches[j].t1,\n teamScore:matches[j].team2Score,\n opponentScore:matches[j].team1Score,\n result:matches[j].result\n })\n }\n }\n }\n }\n}", "title": "" }, { "docid": "1e37fcb8ad896a56097784abd8215e28", "score": "0.6186848", "text": "function determineIfClinched(teamIndex, matches, teams) {\n var leagueTable = teams.slice(0);\n var teamID = leagueTable[teamIndex].id;\n var alreadyPlayed = [];\n var result;\n if (matches[0].team1.id === teamID) { //First, if the team has a match remaining, make it a landslide loss. \n matches[0].play(0, 99);\n alreadyPlayed.push(matches.shift());\n }\n else if (matches[0].team2.id === teamID) {\n matches[0].play(99,0);\n alreadyPlayed.push(matches.shift());\n }\n for (var m = 0; m < matches.length; m++) { //Next, make any non-contending teams lose 99-0 to maximize threat from their opponents.\n if (!threat(matches[m].team1, leagueTable[teamIndex])) {\n matches[m].play(0,99);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--; //since we have removed the match at this index, need to retry this index on next iteration.\n }\n else if (!threat(matches[m].team2, leagueTable[teamIndex])) {\n matches[m].play(99,0);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--;\n }\n }\n for (var m = 0; m < matches.length; m++) { //Finally, simulate remaining match(es) to maximize damage, per testClinchingMatch.\n if (matches[m].team1.getStat(\"played\") === 2) {\n result = testClinchingMatch(matches[m].team1, leagueTable[teamIndex]);\n matches[m].play(result[0], result[1]);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--;\n }\n else if (matches[m].team2.getStat(\"played\") === 2) {\n result = testClinchingMatch(matches[m].team2, leagueTable[teamIndex]);\n matches[m].play(result[1], result[0]);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--;\n }\n }\n if (matches.length !== 0) {\t//If all other teams have 2 games remaining and this team does not have 7 pts, they cannot have clinched \n return false;\n }\n leagueTable.sort(teamCompare);\n var finalStatus = false;\n for (var t = 0; t < 2; t++) {\n if (leagueTable[t].id === teamID) {\n if (leagueTable[t].requiresAdvancedTiebreak === leagueTable[2].requiresAdvancedTiebreak && leagueTable[t].requiresAdvancedTiebreak > -1) {\n break; //Do not want to mark teams relying on lot-drawing as clinched.\n }\n finalStatus = true;\n }\n }\n //We used shallow copy of the league table because the matches' 'play' method would not affect a deep one , so we need to\n //unplay the matches and reset rAT from the array sort, so when we return, the teams will be in the condition they came in\n for (var t = 0; t < leagueTable.length; t++) {\n \tleagueTable[t].requiresAdvancedTiebreak = -1;\n }\n for (var m = 0; m < alreadyPlayed.length; m++) {\n alreadyPlayed[m].unplay();\n matches.push(alreadyPlayed[m]);\n }\n return finalStatus;\n }", "title": "" }, { "docid": "6704d690337ff3daaa6844578be45406", "score": "0.6116701", "text": "function getCountryWins(data, initials) {\n\n let finalsTeam = getFinals(fifaData);\n //console.log(finalsTeam)\n\n let winningTeams = getWinners(getFinals(fifaData));\n //console.log(winningTeams);\n\n //let teamInitial = winningTeams.forEach(team => team === finalsTeam[`Home Team Name`] ? console.log(finalsTeam[`Away Team Initials`]) : console.log(finalsTeam[`Home Team Initials`]));\n\n \n //let team = if( initials === )\n\n //let wins = data.reduce((total, initials) => total++, 0);\n //console.log(wins);\n \n}", "title": "" }, { "docid": "8b3d1c0f7232b7f10140252794e77e95", "score": "0.6096837", "text": "function showCollectedMatches() {\n // loop through teams\n for (let team_index in teams) {\n let team = teams[team_index];\n // loop through stand data\n for (let stand_index in stand_data[team]) {\n let data = stand_data[team][stand_index];\n $(\".m\" + data[\"info\"][\"match\"] + \"-\" + team).append(\"<span class='match-dot'></span>\");\n }\n }\n}", "title": "" }, { "docid": "b4f5e75994f7c7ef1ca232b076ce5bce", "score": "0.6032114", "text": "function getWinners(cb) {\n let arr = getFinals(cb)\n const y = arr.map((ww) => {\n return {'Home Team Goals': ww[\"Home Team Goals\"] ,'Away Team Goals' : ww[\"Away Team Goals\"],'Home Team Name': ww[\"Home Team Name\"] ,'Away Team Name' : ww[\"Away Team Name\"], 'Win conditions': ww[\"Win conditions\"] };\n });\n const x = y.map((zz) => {\n if (zz[\"Home Team Goals\"] > zz[\"Away Team Goals\"]) {\n return {'Home Team Name': zz[\"Home Team Name\"]};\n } else if (zz[\"Away Team Goals\"] > zz[\"Home Team Goals\"]) {\n return {'Away Team Name': zz[\"Away Team Name\"]};\n } else {\n return {'Win conditions': zz[\"Win conditions\"]};\n }\n });\n return x;\n}", "title": "" }, { "docid": "36a6ae88a0c7f3c0aa4713c65545bc52", "score": "0.6006927", "text": "function leaguesWithWins() {\n // CODE HERE\n let leaguesCount = {};\n for (let team of winsByTeams) {\n let leagueId = getLeagueId(team.teamId);\n if (leaguesCount.hasOwnProperty(leagueId)) {\n leaguesCount[leagueId] += team.wins;\n } else {\n leaguesCount[leagueId] = team.wins;\n }\n }\n let result = [];\n for (let leagueId in leaguesCount) {\n if (leaguesCount.hasOwnProperty(leagueId)) {\n result.push({\n name: getLeagueName(leagueId),\n count: leaguesCount[leagueId]\n })\n }\n }\n return result;\n\n}", "title": "" }, { "docid": "15d93a4ac163b1b1050c95dbdf1c88d2", "score": "0.5997185", "text": "function determineTeams() {\n let matches = Object.keys(schedule);\n // loops through each match\n for (let match_id in matches) {\n let match = schedule[match_id];\n for (let team_id in match) {\n // checks to see if team is already in array\n if (teams.indexOf(match[team_id]) < 0) {\n // adds it to team list\n teams.push(match[team_id]);\n }\n }\n }\n}", "title": "" }, { "docid": "a663f918d0f2744cb0c08e928277e6d4", "score": "0.5996988", "text": "function displayMatchesForTeam(team) {\n if (alliances_selected) {\n displayElimsMatches();\n }\n let matches_to_display = [];\n let schedule_keys = Object.keys(schedule);\n // if team is undefined, go through each match\n if (team === undefined) {\n for (let x in schedule_keys) {\n matches_to_display.push(parseInt(x)+1);\n }\n } else {\n // go through each match\n for (let match_index in schedule_keys) {\n let match_number = schedule_keys[match_index];\n let match = schedule[match_number];\n // checks to see if match contains team\n if (match.indexOf(team) >= 0) {\n matches_to_display.push(match_number);\n }\n }\n }\n // display match for each match in matches_to_display\n for (let match_index in matches_to_display) {\n // \".match-col-\"+match_index%3 is where the match will be appended, in one of three columns\n createMatch(\".match-col-\" + match_index % 3, matches_to_display[match_index], team, \"quals\");\n }\n showCollectedMatches();\n}", "title": "" }, { "docid": "e860d7d09186928d74b9494db7d60ac6", "score": "0.59962404", "text": "function tournamentWinner(competitions, results) {\r\n const WIN_POINT = 3;\r\n const winers = new Map();\r\n // varro as competições\r\n for (let idx = 0; idx < competitions.length; idx++) {\r\n // pego uma competição\r\n const competition = competitions[idx];\r\n // pego um resultado\r\n const result = results[idx];\r\n // determino o vencedor\r\n const winer = competition[1-result];\r\n // salvo o vencedor e sua pontuação\r\n if (winers.has(winer)) { // se o vencedor já ganhou outras vezes\r\n // acrescento 3 pontos\r\n const actualPoints = winers.get(winer);\r\n const newPoints = actualPoints + WIN_POINT;\r\n winers.set(winer, newPoints);\r\n } else { // o vencedor não ganhou nenhuma vez\r\n // salvo o vencedor e sua pontuação\r\n winers.set(winer, WIN_POINT);\r\n }\r\n }\r\n // varro winers e determino o vencedor\r\n let maxPoints = 0;\r\n let winer = '';\r\n for (let [team, points] of winers) {\r\n if (points > maxPoints) {\r\n maxPoints = points;\r\n winer = team;\r\n }\r\n }\r\n return winer;\r\n}", "title": "" }, { "docid": "c9965808150e5ab995e00fe70743c3db", "score": "0.5988891", "text": "function getWinners(getFinals) {\n const winners = [];\n getFinals(fifaData).forEach(function (data) {\n if (data[\"Home Team Goals\"] > data[\"Away Team Goals\"]) {\n winners.push(data[\"Home Team Name\"]);\n }\n else if (data[\"Away Team Goals\"] > data[\"Away Team Goals\"]) {\n winners.push(data[\"Away Team Name\"]);\n }else {\n winners.push(data[\"Win conditions\"].split(\" \")[0]);\n }\n});\n return winners;\n\n}", "title": "" }, { "docid": "cac45d84fd7d7bda34d0d767f047f4b5", "score": "0.5987888", "text": "function determineWinner(team_1_data, team_2_data) {\r\n\treturn ((team_1_data.team_kills + team_1_data.team_assists) / team_1_data.team_deaths) > ((team_2_data.team_kills + team_2_data.team_assists) / team_2_data.team_deaths)? 1 : 2;\r\n}", "title": "" }, { "docid": "4dcc9d24dca033bb621904eb27469b24", "score": "0.595731", "text": "function makeTeams() {\n for (var i = 0; i < data.players.length; i++) {\n if (data.players[i].team_name === team1Name) {\n team1 = team1.concat(data.players[i]);\n } else {\n team2 = team2.concat(data.players[i]);\n }\n }\n}", "title": "" }, { "docid": "f5dae3fe79b63ad449e8f73372a8704e", "score": "0.5951034", "text": "async triggerMatch(){\n const teams = this.teams;\n\n let fetchTeamsPromises = [];\n teams.forEach((teamId) => {\n let team = new Team(teamId, this.tournamentId);\n fetchTeamsPromises.push(team.fetchTeamDetails());\n });\n\n // 1. Get individual Team info.\n let teamsInfo = await Promise.all(fetchTeamsPromises);\n console.log(\"RS\", teamsInfo);\n\n // 2. get winning Match Score \n let payload = { tournamentId: this.tournamentId , round: this.round, match: this.match};\n let matchScore = await this.getMatchScore(payload);\n\n\n // 3. Get the Winning Score\n let teamScores = teamsInfo.map( (team) => {\n return team.score;\n });\n\n let winnerPayload = {tournamentId: this.tournamentId, teamScores: teamScores, matchScore: matchScore};\n let winningScore = await this.getWinnerScore(winnerPayload);\n\n //4. Find the teams which has the Winning Score\n let winnerTeams = teamsInfo.filter((team) => {\n return ( winningScore === team.score );\n });\n\n //5. If WinnerTeams more than one , with lowest teamId wins.\n if(winnerTeams.length>1){\n winnerTeams.sort((a,b) => a.teamId-b.teamId);\n }\n\n //6. Set the progress of the match in the DOM.\n this.setIndicatorLoading(this.round, this.match);\n return winnerTeams[0];\n }", "title": "" }, { "docid": "ae2f18a8973b20d4be5eef5d2db1a41f", "score": "0.59369165", "text": "function sortTeamsByWins() {\n // CODE HERE\n let sortedWins = winsByTeams.sort((team1, team2) => team2.wins - team1.wins);\n return sortedWins.map((team) => getTeamName(team.teamId))\n}", "title": "" }, { "docid": "2e78a7a49b725aa2df535602846e8fd5", "score": "0.592053", "text": "function getCountryWins( fifaData, initials ) \n{\n let countryName = \"\";\n let finals = getFinals( fifaData );\n\n console.log( finals );\n let winners = getWinners( getFinals );\n console.log( winners );\n \n for( let i = 0; i < finals.length; i++ )\n if( finals[ i ][ 'Home Team Initials' ] === initials || finals[ i ][ 'Away Team Initials' ] === initials )\n {\n countryName = ( finals[ i ][ 'Home Team Initials' ] === initials ? finals[ i ][ 'Home Team Name' ] : finals[ i ][ \"Away Team Name\" ] );\n break;\n }\n \n return winners.reduce( ( val, winner ) => winner === countryName ? val + 1 : val, 0 );\n}", "title": "" }, { "docid": "17d6971b3403452dc79d0177336cb857", "score": "0.58995676", "text": "function winTossWinMatchSummary(match,team1){\n if(match[\"toss_winner\"]===team1){\n if(match[\"winner\"]===team1){\n return 2;\n }\n return 1;\n }\n return 0;\n }", "title": "" }, { "docid": "bae3e72cf9aa6d2de1cdd76e63384a95", "score": "0.58854985", "text": "createMatchUps(winTeams, callback) {\n\n const self = this;\n let newMatchUps = [];\n let elem = {};\n elem.teamIds = [];\n\n for (let i = 0; i < winTeams.length; i++) {\n elem.teamIds.push(winTeams[i].teamId);\n if (i % self.teamsPerMatchVal == 0) {\n elem.match = (i / self.teamsPerMatchVal)\n }\n if (i % self.teamsPerMatchVal == (self.teamsPerMatchVal - 1)) {\n newMatchUps.push(elem);\n elem = {};\n elem.teamIds = [];\n }\n }\n\n callback(newMatchUps);\n }", "title": "" }, { "docid": "65c062ff6d19920126ff50ededb71d31", "score": "0.5829411", "text": "function winnersPerYearPerTeam(matches) {\n const years = matches.map(match => match.season);\n const year = new Set(years);\n const winnerPerYear = matches.reduce((winnersPerYear, match) => {\n if (match['winner'] !== '') {\n if (!winnersPerYear[match.winner]) {\n //checking whether the season is already present or not\n winnersPerYear[match['winner']] = {}; //create object if not present\n }\n if (!winnersPerYear[match.winner][match['season']]) {\n winnersPerYear[match['winner']][match['season']] = 1;\n } else {\n winnersPerYear[match['winner']][match['season']] += 1;\n }\n }\n\n return winnersPerYear;\n }, {});\n\n Object.values(winnerPerYear).forEach((element) => {\n year.forEach((item) => {\n if (!element[item]) {\n element[item] = 0;\n }\n });\n });\n return winnerPerYear;\n}", "title": "" }, { "docid": "008fa4fc8a9ab44f61a5fb5953957726", "score": "0.5826376", "text": "function getCountryWins(data, teamInitials) {\n const myTeamWins = []\n data.forEach(function(element){\n if((teamInitials === element[\"Home Team Initials\"]) && (element[\"Home Team Goals\"] > (element[\"Away Team Goals\"]))) {\n myTeamWins.push(element);\n } else if((teamInitials === element[\"Away Team Initials\"]) && (element[\"Away Team Goals\"] > (element[\"Home Team Goals\"]))){\n myTeamWins.push(element);\n }\n })\n console.log(myTeamWins);\n\n const numberMyTeamWins = myTeamWins.reduce(function(accumulator, item, index){\n return accumulator + index;\n },0)\n \n return numberMyTeamWins;\n}", "title": "" }, { "docid": "63bb9203998ba46784ac704fabbf1417", "score": "0.58255404", "text": "function setMatches(numbPlayers,round,players){\n var html = \"\";\n for (var i = 0; i < numbPlayers; i++) {\n html = html + \"<div id=\" + round + \"m\" + i + i +\">\";\n if (numbPlayers == 1) {\n html = html + \"<span id=\" + round + \"m\" + i + \">Winner: </span><span>\" + \"____\" + \"</span>\";\n } else {\n html = html + matchInput(round,i,players);\n }\n html = html + \"</div>\";\n };\n return html;\n}", "title": "" }, { "docid": "b5fc16b006aa8ecd666194486f799859", "score": "0.58095396", "text": "function getMatchDay() {\n const home = teams[Math.floor(Math.random() * teams.length)];\n let away = teams[Math.floor(Math.random() * teams.length)];\n while (home === away) { // change the away team if the away team is also the home team\n away = teams[Math.floor(Math.random() * teams.length)];\n }\n return [home, away];\n}", "title": "" }, { "docid": "df16b284fe24e379e899043ba8125d30", "score": "0.5809507", "text": "function determineIfEliminated(teamIndex, matches, teams) {\n var leagueTable = teams.slice(0);\n var teamID = leagueTable[teamIndex].id;\n var alreadyPlayed = [];\n var result;\n if (matches[0].team1.id === teamID) { //First, if the team has a match remaining, make it a landslide win. \n matches[0].play(99,0);\n alreadyPlayed.push(matches.shift());\n }\n else if (matches[0].team2.id === teamID) {\n matches[0].play(0,99);\n alreadyPlayed.push(matches.shift());\n }\n for (var m = 0; m < matches.length; m++) { //Next, make any non-contending teams win 99-0 to limit threat from their opponents.\n if (!threat(matches[m].team1, leagueTable[teamIndex])) {\n matches[m].play(99,0);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--; //since we have removed the match at this index, need to retry this index on next iteration.\n }\n else if (!threat(matches[m].team2, leagueTable[teamIndex])) {\n matches[m].play(0,99);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--;\n }\n }\n for (var m = 0; m < matches.length; m++) { //Finally, simulate remaining match(es) to minimize damage, per testEliminationMatch.\n if (matches[m].team1.getStat(\"played\") === 2) {\n result = testEliminationMatch(matches[m].team1, leagueTable[teamIndex]);\n matches[m].play(result[0], result[1]);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--;\n }\n else if (matches[m].team2.getStat(\"played\") === 2) {\n result = testEliminationMatch(matches[m].team2, leagueTable[teamIndex]);\n matches[m].play(result[1], result[0]);\n alreadyPlayed.push(matches[m]);\n matches.splice(m,1);\n m--;\n }\n }\n if (matches.length !== 0) {\t//If all other teams have 2 games remaining and this team does not have <=1 pt, they cannot be eliminated \n return false;\n }\n leagueTable.sort(teamCompare);\n var finalStatus = false;\n for (var t = 2; t < leagueTable.length; t++) {\n if (leagueTable[t].id === teamID) {\n if (leagueTable[t].requiresAdvancedTiebreak === leagueTable[1].requiresAdvancedTiebreak && leagueTable[t].requiresAdvancedTiebreak > -1) {\n break; //Do not want to mark teams relying on lot-drawing as eliminated.\n }\n finalStatus = true;\n }\n }\n //We used shallow copy of the league table because the matches' 'play' method would not affect a deep one , so we need to\n //unplay the matches and reset rAT from the array sort, so when we return, the teams will be in the condition they came in\n for (var t = 0; t < leagueTable.length; t++) {\n \tleagueTable[t].requiresAdvancedTiebreak = -1;\n }\n for (var m = 0; m < alreadyPlayed.length; m++) {\n alreadyPlayed[m].unplay();\n matches.push(alreadyPlayed[m]);\n }\n return finalStatus;\n }", "title": "" }, { "docid": "cbe1804b80b3d13e077db7fc13b43aa8", "score": "0.58071125", "text": "function getWinners(callback) {\n let winners = [];\n\n let homeWinners = callback.filter(\n (w) => w[`Home Team Goals`] > w[`Away Team Goals`]\n );\n let awayWinners = callback.filter(\n (w) => w[`Away Team Goals`] > w[`Home Team Goals`]\n );\n let tiedGame = callback.filter(\n (t) => t[`Home Team Goals`] === t[`Away Team Goals`]\n );\n\n let hNames = homeWinners.map((mh) => mh[`Home Team Name`]);\n let aNames = awayWinners.map((ma) => ma[`Away Team Name`]);\n let tNames = tiedGame.map((mt) => mt[`Home Team Name`]);\n\n winners = hNames.concat(aNames, tNames);\n return winners;\n}", "title": "" }, { "docid": "c4dc7a6b283ff251c20522faec74c24b", "score": "0.5794817", "text": "function getWinners(getFinals) {\n let winners = [];\n getFinals.forEach(function(element) {\n let winner = '';\n let homeScore = (element['Home Team Goals']) + (element['Half-time Home Goals']);\n let awayScore = (element['Away Team Goals']) + (element['Half-time Away Goals']);\n if (homeScore > awayScore) {\n winner = element['Home Team Name'];\n } else if (homeScore < awayScore) {\n winner = element['Away Team Name'];\n } else {\n // This is part of the stretch goal listed in the readMe\n winner = element['Win conditions'].split(' win ')[0];\n }\n winners.push(winner);\n });\n return winners;\n}", "title": "" }, { "docid": "2d2c652309ceff6d0dc6f1cad951bccc", "score": "0.57685906", "text": "function makeTeams(data){\n var teams = new Array;\n for (var j = 0; j < data.bundesliga.length; j++) {\n for (var name in data.bundesliga[j]) {\n if (data.bundesliga[j].hasOwnProperty(name)) {\n let current = data.bundesliga[j];\n current[name].forEach((e, i) => {\n if(!teams.includes(e[\"AwayTeam\"])){\n teams.push(current[name][i][\"AwayTeam\"])\n }\n });\n }\n }\n }\n return teams.sort();\n }", "title": "" }, { "docid": "864cf2accf0104fff2576c66dc029bd2", "score": "0.5766061", "text": "function matchingOpportunities() {\n const allOpportunities = availableOpps();\n const matching = [];\n const profile = Users.getProfile(getRouteUserName());\n const userInterests = [];\n let opportunityInterests = [];\n _.forEach(Users.getInterestIDs(profile.userID), (id) => {\n userInterests.push(Interests.findDoc(id));\n });\n _.forEach(allOpportunities, (opp) => {\n opportunityInterests = [];\n _.forEach(opp.interestIDs, (id) => {\n opportunityInterests.push(Interests.findDoc(id));\n _.forEach(opportunityInterests, (oppInterest) => {\n _.forEach(userInterests, (userInterest) => {\n if (_.isEqual(oppInterest, userInterest)) {\n if (!_.includes(matching, opp)) {\n matching.push(opp);\n }\n }\n });\n });\n });\n });\n // Only display up to the first six matches.\n return (matching < 7) ? matching : matching.slice(0, 6);\n}", "title": "" }, { "docid": "7b3368514077b2c9534f8e6864d09c06", "score": "0.5742597", "text": "hasTeams() {\n let has = false;\n this.entrants.forEach((entrant) => {\n if (entrant.team !== \"\") {\n has = true;\n }\n });\n return has;\n }", "title": "" }, { "docid": "fee20de220c0a66806c8d5b483544334", "score": "0.5732226", "text": "function leaguesWithTeamWithMostWins() {\n // CODE HERE\n let result = {};\n for (let team of winsByTeams) {\n let leagueId = getLeagueId(team.teamId);\n let leagueName = getLeagueName(leagueId);\n if (result.hasOwnProperty(leagueName)) {\n if (team.wins > result[leagueName].wins) {\n result[leagueName] = {\n team: getTeamName(team.teamId),\n wins: team.wins\n };\n }\n } else {\n result[leagueName] = {\n team: getTeamName(team.teamId),\n wins: team.wins\n };\n }\n }\n return result;\n}", "title": "" }, { "docid": "7b5f53248ed8d5ffd7f8902b05bcc245", "score": "0.5731374", "text": "function doesMatchupExist(team1,team2,scheduleObj)\n{\n var rooms = scheduleObj.rooms;\n\n //check every room\n //console.log(rooms);\n for(var i=0;i<rooms.length;i++)\n {\n var rounds = rooms[i].rounds;\n for(var e=0;e<rounds.length;e++)\n {\n\n //checks the selected matchup and if it is the same as the once provided responds true\n //console.log(\"check\"+team1.getFormatedName()+\" \"+team2.getFormatedName());\n if(rounds[e].isSameMatchup(team1,team2))\n {\n return true;\n }\n }\n\n }\n\n return false;\n}", "title": "" }, { "docid": "d79668c5e23107e05c3172369a5f6891", "score": "0.5702857", "text": "function playerWon(){ \n for (const positions of _winningPositions){\n if (_placed[positions[0]] != -1 \n && _placed[positions[0]] == _placed[positions[1]] \n && _placed[positions[1]] == _placed[positions[2]]){\n return _placed[positions[0]];\n }\n }\n return 0;\n }", "title": "" }, { "docid": "bee0550e6dadec6d46d0ab8821d5123c", "score": "0.5698096", "text": "checkWinners(chalId){\n let contest = this.challenges[chalId];\n for(var i = 0; i<contest.contestants.length; i++){\n let player = this.users[contest.contestants[i].id];\n if(this.won(player,contest))\n {\n player.challengesWon.push({contest: contest.title});\n player.challengeNotifications.push({message: \"You won the \"+contest.title+ \" challenge! Great job!\"});\n contest.winners.push(player);\n }else{\n if(contest.end < new Date()){\n player.challengeNotifications.push({message: \"You lost the \"+contest.title+ \" challenge, but I'm sure you'll do better on your next challenge!\"});\n contest.contestants.splice(i,1);\n i--;\n }\n }\n }\n contest.setChecked(true);\n return contest.winners;\n }", "title": "" }, { "docid": "dbb6632ee332b1a90443c1b59020701d", "score": "0.5690277", "text": "function advancedTiebreak(minigroup, matches) {\n for (var m = 0; m < matches.length; m++) {\n var matched1 = -1;\n var matched2 = -1;\n for (var t = 0; t < minigroup.length; t++) {\n if (matches[m].team1.id === minigroup[t].id) {\n matched1 = t;\n }\n if (matches[m].team2.id === minigroup[t].id) {\n matched2 = t;\n }\n }\n if (matched1 !== -1 && matched2 !== -1) {\n minigroup[matched1].play(matches[m].getScore(1), matches[m].getScore(2));\n minigroup[matched2].play(matches[m].getScore(2), matches[m].getScore(1));\n }\n }\n return minigroup.sort(teamCompare);\n }", "title": "" }, { "docid": "9200ba08b6887073873aa664c01aac43", "score": "0.56834286", "text": "function getWinners(cb) {\n const winners = cb.map(item => {\n let homeScore = item[\"Home Team Goals\"]\n let awayScore = item[\"Away Team Goals\"]\n if(homeScore > awayScore){\n return item[\"Home Team Name\"]\n } else {\n return item[\"Away Team Name\"]\n }\n });\n\n return winners\n}", "title": "" }, { "docid": "de0cf5a8c52d7c5834e69f62a032d4e0", "score": "0.5673194", "text": "function testClinchingMatch(threatener, evalTeam) {\n if (!threat(threatener, evalTeam)) { //\"Threatener\" doesn't actually threaten evalTeam. Return heavy win for opponent.\n return [0,99];\n }\n var ptsBetween = evalTeam.getStat(\"points\") - threatener.getStat(\"points\");\n var goalDifferenceBetween = evalTeam.getStat(\"goalDifference\") - threatener.getStat(\"goalDifference\");\n //use of unrealistically high scores means no need for goalsForBetween variable -- both competitors will always pass evalTeam\n var winBy, loseBy;\n switch (ptsBetween) {\n case 3: //If the threatener trails by 3 points, have them win by enough to win the GD tiebreak, while allowing tons of goals.\n winBy = (goalDifferenceBetween < 1) ? 1 : goalDifferenceBetween;\n return [99+winBy, 99];\n break;\n case 2: //If the threatener trails by 2 points, have them win by one and allow tons of goals.\n return [99, 98];\n break; \n case 1: //If the threatener trails by 1 point, have them tie if they're winning the goal difference tiebreak, or win if not.\n if (goalDifferenceBetween <= 0) {\n return [99, 99];\n }\n else {\n return [99, 98];\n }\n break;\n case 0: //If the threatener is tied, have them lose by enough to just win the tiebreak, or tie if that's not possible.\n loseBy = (goalDifferenceBetween < 0) ? 0 - goalDifferenceBetween : 0;\n return [99, 99+loseBy];\n break;\n }\n }", "title": "" }, { "docid": "7247c33b8fe2f565a75a5fc3507b72fb", "score": "0.5667177", "text": "compare() {\n let result1 = this.state.gameplayOne;\n let result2 = this.state.gameplayTwo;\n let win = [...this.state.win];\n\n // Setting arrays which will be filled by true or false since a winning combination is detected in the player's game.\n let tabTrueFalse1 = [];\n let tabTrueFalse2 = [];\n // winningLine may help to know which winning combination is on the set and then have an action on it. To think.\n let winningLine = [];\n\n if (this.state.gameplayOne.length >= 3) {\n tabTrueFalse1 = win.map(elt =>\n elt.every(element => result1.includes(element))\n );\n }\n if (this.state.gameplayTwo.length >= 3) {\n tabTrueFalse2 = win.map(elt =>\n elt.every(element => result2.includes(element))\n );\n }\n\n //Launching youWon()\n tabTrueFalse1.includes(true) ? this.youWon(1) : null;\n tabTrueFalse2.includes(true) ? this.youWon(2) : null;\n }", "title": "" }, { "docid": "5d5136d6c986f20859d027ebc14f18f1", "score": "0.5650028", "text": "function makeMatches(){\n//\tWave in progress\n\tif (!canPlaceTower){\n\t\ttowerArr.forEach(function(tower){\n//\t\t\tGet sprites in the towers quad\n\t\t\tbool = false;\n\t\t\tspriteArr.forEach(function(sprite){\n//\t\t\t\tSprite is in range of the tower and it has gone through its reload period\n\t\t\t\tif (tower.canAttack(sprite)){\n\t\t\t\t\ttower.spriteChooseMethod(sprite);\n\t\t\t\t\tbool = true;\n\t\t\t\t}\n\t\t\t});\n//\t\t\tif a target has been assigned then attack it\t\t\t\n\t\t\tif (bool) tower.attackSprite();\n\t\t});\n\t}\n}", "title": "" }, { "docid": "07e4c96f5d59ef6e01ad5f7e32f27705", "score": "0.5635983", "text": "function addTeams(teams) {\n console.log(teams);\n //loop through team data from db\n for (t in teams) {\n\n //create a new team object\n let newTeam = new Team(teams[t].code, teams[t].name, teams[t].strength_attack_home,\n teams[t].strength_attack_away, teams[t].strength_defence_home, teams[t].strength_defence_away, teams[t].points, teams[t].w, teams[t].l, teams[t].d, teams[t].scored, teams[t].conceeded, teams[t].played);\n //Gets the teams players\n for (player in teams[t].players) {\n console.log();\n if (teams[t].players[player].element_type == 1) {\n //creates a new player object for the current player\n const keeper = new GoalKeeper(teams[t].players[player].team_code, teams[t].players[player].code, teams[t].players[player].web_name,\n teams[t].players[player].first_name, teams[t].players[player].second_name, teams[t].players[player].squad_number,\n teams[t].players[player].assists, teams[t].players[player].goals_scored,\n teams[t].players[player].goals_conceded, teams[t].players[player].own_goals,\n teams[t].players[player].yellow_cards, teams[t].players[player].red_cards, teams[t].players[player].influence,\n teams[t].players[player].creativity, teams[t].players[player].threat, teams[t].players[player].cost,\n teams[t].players[player].ict_index, teams[t].players[player].minutes, teams[t].players[player].element_type, teams[t].players[player].clean_sheets)\n //adds te player to its team\n newTeam.addPlayer(keeper);\n } else {\n //creates a new player object for the current player\n const p = new Player(teams[t].players[player].team_code, teams[t].players[player].code, teams[t].players[player].web_name,\n teams[t].players[player].first_name, teams[t].players[player].second_name, teams[t].players[player].squad_number,\n teams[t].players[player].assists, teams[t].players[player].goals_scored,\n teams[t].players[player].goals_conceded, teams[t].players[player].own_goals,\n teams[t].players[player].yellow_cards, teams[t].players[player].red_cards, teams[t].players[player].influence,\n teams[t].players[player].creativity, teams[t].players[player].threat, teams[t].players[player].cost,\n teams[t].players[player].ict_index, teams[t].players[player].minutes, teams[t].players[player].element_type)\n //adds te player to its team\n newTeam.addPlayer(p);\n }\n\n }\n //add the new team to teams array\n clubs.push(newTeam);\n //newTeam.print();\n }\n //loads the select team menu\n selectTeamMenu();\n}", "title": "" }, { "docid": "07666d187684615a5d4d28e15f526424", "score": "0.56219226", "text": "function whoIsWinner() {\n\n if (team01_countScore > team02_countScore) {\n \n winner = \"Team 1 won the Game\";\n\n } else if (team01_countScore < team02_countScore) {\n\n winner = \"Team 2 won the Game\";\n\n } else {\n\n winner = \"Dead heat!!! Team 1 and Team 2 won the Game\"\n }\n\n return winner;\n}", "title": "" }, { "docid": "6c98769c3b3b299ac475666c00f19b97", "score": "0.5596314", "text": "async function winPercantageTwoTeams(dbo, team1, team2, callback, log, earliest = 1979, latest = 2019){\r\n const collection = dbo.collection('ball');\r\n const justWins = (await collection.find({schedule_season: {$gte: earliest, $lte: latest},\r\n schedule_playoff: false,\r\n $or: [{team_home: team1, team_away: team2, $where: \"this.score_home > this.score_away\"},\r\n {team_home: team2, team_away: team1, $where: \"this.score_away > this.score_home\"}]\r\n }).toArray());\r\n const allGames = (await collection.find({schedule_season: {$gte: earliest, $lte: latest},\r\n schedule_playoff: false,\r\n $or: [{team_home: team1, team_away: team2},\r\n {team_home: team2, team_away: team1}]\r\n }).toArray());\r\n let pct = (justWins.length / allGames.length) * 100;\r\n winPct = pct;\r\n pct = Math.round(pct * 100) / 100;\r\n if(log)\r\n console.log(\"The \" + team1 + \" have won \" + pct + \"% of their regular season games against the \" + team2 + \" between \" + earliest + \" and \" + latest + \"\\n\");\r\n callback();\r\n}", "title": "" }, { "docid": "9a439ce4165e8701387e1bc53d2d9548", "score": "0.5593427", "text": "async function compareLineups(teams) {\n \n //Get the LineUps from other sites\n let team1 = await ffscoutScrape(teams);\n let team2 = await ffpunditScrape(teams);\n let team3 = await ffscoutScrape(teams);\n let players = [];\n let teamANDplayers = new Map();\n\n for (const key in teams) {\n for (var k = 0; k < 11; k++){\n \n //2:1 ratio - if a players predicted in at least 2 sites, its added\n //compare team1 to team2 and team3, add player to array if is found in team lineUps and not already in the array\n if (Object.values(team2.get(teams[key])).includes(Object.values(team1.get(teams[key]))[k]) && !(players.includes(Object.values(team1.get(teams[key]))[k]))) {\n players.push(Object.values(team1.get(teams[key]))[k]);\n } else if (Object.values(team3.get(teams[key])).includes(Object.values(team1.get(teams[key]))[k]) && !(players.includes(Object.values(team1.get(teams[key]))[k]))) {\n players.push(Object.values(team1.get(teams[key]))[k]);\n }\n \n //compare team2 to team1 and team3, add player to array if is found in team lineUps and not already in the array\n if (Object.values(team1.get(teams[key])).includes(Object.values(team2.get(teams[key]))[k]) && !(players.includes(Object.values(team2.get(teams[key]))[k]))) {\n players.push(Object.values(team2.get(teams[key]))[k]);\n } else if (Object.values(team3.get(teams[key])).includes(Object.values(team2.get(teams[key]))[k]) && !(players.includes(Object.values(team2.get(teams[key]))[k]))) {\n players.push(Object.values(team2.get(teams[key]))[k]);\n }\n }\n\n //each lineUp is assigned to the corresponding team and put in the map, clear array to get next teams predicted 11\n teamANDplayers.set(teams[key], {1: players[0], 2: players[1], 3: players[2], 4: players[3], 5: players[4], 6: players[5], 7: players[6], 8: players[7], 9: players[8], 10: players[9], 11: players[10]});\n players =[];\n }\n return teamANDplayers;\n}", "title": "" }, { "docid": "a8da64cd6cbeb2456668e41911f481bf", "score": "0.55887944", "text": "function getSpecificMatches(matchData, teamNum) {\n// console.log('Event: ' + matchData[0].event_key);\n for (var matchNum = 0; matchNum < matchData.length; matchNum++) {\n\n var currentMatchAlliances = matchData[matchNum].alliances;\n if (currentMatchAlliances.red.teams.indexOf(teamNum) >= 0 || currentMatchAlliances.blue.teams.indexOf(teamNum) >= 0) {\n\n setMatchesGlobal(matchData[matchNum]);\n\n /*\n console.log(matchData[matchNum].comp_level + \" \" + matchData[matchNum].match_number)\n console.log(currentMatchAlliances);\n console.log(matchData[matchNum].score_breakdown);\n */\n\n }\n }\n //console.log();\n console.log('.');\n}", "title": "" }, { "docid": "68e36fe46d57a04d71369fde5a02b123", "score": "0.55811846", "text": "winningTeam() {\n if (Math.random() < 0.50) {\n return(nameWest);\n } else {\n return(nameEast);\n }\n }", "title": "" }, { "docid": "79e920dd045eab2db8da81d13921a4b7", "score": "0.5568923", "text": "function fillElimsMatches() {\n setElimsMatchDefault();\n $(\".node\").each(function() {\n let node = $(this)[0].__data__;\n if (node.round !== \"alliance\") {\n if (node.children[0].name !== \"?\" && node.children[1].name !== \"?\") {\n for (let childNodeID in node.children) {\n let childNode = node.children[childNodeID];\n // checks to see if it already has an alliance\n if (childNode.alliance != 0) {\n if (!(node.number in elims_matches[node.round])) { elims_matches[node.round][node.number] = [] }\n // creates a shallow copy of the teams - e.g. [1540, 2471, 4488]\n let alliance_teams = Object.assign([], elims_alliances[childNode.alliance]);\n // reverses the list so that prepended will add them in order\n if (childNode.winnerColor === \"red\") {\n alliance_teams = alliance_teams.reverse();\n }\n for (let alliance_team_id in alliance_teams) {\n // e.g. 1540\n let alliance_team = alliance_teams[alliance_team_id];\n // finally actually adds it to the list\n if (childNode.winnerColor === \"red\") {\n // puts value in at beginning of array\n elims_matches[node.round][node.number].unshift(alliance_team);\n } else {\n // puts value in at end of array\n elims_matches[node.round][node.number].push(alliance_team);\n }\n }\n }\n }\n }\n }\n });\n}", "title": "" }, { "docid": "31a542e16d8d614a027ea574e7b0376b", "score": "0.5562499", "text": "function defineDrawWinner(team1,team2){\n\n var teamOrder = [team1, team2];\n var t1acr = team1[\"team\"];\n var t2acr = team2[\"team\"];\n var match = t1acr+\"-\"+t2acr;\n \n var t1_goals = getTeamGoals(match + \"-g1\");\n var t2_goals = getTeamGoals(match + \"-g2\");\n \n // in case of wrong order assignment\n if((typeof t1_goals == \"undefined\") || (typeof t2_goals ==\"undefined\")){\n match = t2acr+\"-\"+t1acr;\n // invert the goals order\n t1_goals = getTeamGoals(match + \"-g2\");\n t2_goals = getTeamGoals(match + \"-g1\");\n }\n\n if (isPosInt(t1_goals) && isPosInt(t2_goals)) {\n var t1_goals_int = parseInt(t1_goals);\n var t2_goals_int = parseInt(t2_goals);\n //alert(\"DRAW DEFINITION: \"+team1[\"team\"]+\"-\"+t1_goals+\" \"+team2[\"team\"]+\"-\"+t2_goals);\n if(t2_goals_int > t1_goals_int){\n teamOrder = [team2,team1];\n }\n }\n return teamOrder; \n}", "title": "" }, { "docid": "055e26486321b440e27c509146b89195", "score": "0.55580217", "text": "function matchResults() {\n\n\n\n if(opponent.value == 1 /*psg*/){\n goalsLiverpoolTrue = 3;\n goalsOpponentTrue = 2;\n goalMinuteTrue = 30;\n yellowsTrue = 2;\n firstGoalscorerTrue = 8;\n RedTrue = 0;\n\n lineupTrue = [4, 25, 16, 26, 5, 12, 15, 13, 18, 7, 23];\n\n }\n else if(opponent.value == 2 /*everton*/){\n goalsLiverpoolTrue = 0;\n goalsOpponentTrue = 0;\n goalMinuteTrue = 100;\n yellowsTrue = 0;\n firstGoalscorerTrue = 1;\n RedTrue = 0;\n\n lineupTrue = [4, 25, 16, 26, 5, 12, 15, 13, 18, 7, 23];\n\n }\n\n else if(opponent.value == 3 /*burnley*/){\n goalsLiverpoolTrue = 2;\n goalsOpponentTrue = 1;\n goalMinuteTrue = 61;\n yellowsTrue = 0;\n firstGoalscorerTrue = 24;\n RedTrue = 0;\n\n lineupTrue = [24, 25, 8, 26, 5, 12, 15, 13, 3, 10, 23];\n\n }\n\n else if(opponent.value == 4 /*leicester*/){\n goalsLiverpoolTrue = 2;\n goalsOpponentTrue = 1;\n goalMinuteTrue = 10;\n yellowsTrue = 5;\n firstGoalscorerTrue = 24;\n RedTrue = 0;\n\n lineupTrue = [4, 25, 16, 26, 5, 12, 15, 13, 18, 22, 23];\n\n }\n\n else if(opponent.value == 5 /*southampton*/){\n goalsLiverpoolTrue = 3;\n goalsOpponentTrue = 0;\n goalMinuteTrue = 10;\n yellowsTrue = 2;\n firstGoalscorerTrue = 29;\n RedTrue = 0;\n\n lineupTrue = [4, 25, 14, 26, 5, 12, 27, 13, 18, 7, 23];\n\n }\n}", "title": "" }, { "docid": "69446c7389a0b701d00bea49dd5ebbb4", "score": "0.5550998", "text": "function makeTeams2And2(allTeams) {\n console.log(\" Game LEVEL Is : \" + gameLevel);\n shuffle(allTeams);\n for ( let i = 0; i < allTeams.length; i++){\n if ( teams[i].level === gameLevel ){\n if (i % 2 === 0)\n allTeams[i].competitor = i + 1;\n else\n allTeams[i].competitor = i;\n }\n }\n console.log( \"*----------------\\\\The Competitors/--------------*\");\n let index = 0;\n for ( let i = 1; i < allTeams.length; i+=2) {\n if ( allTeams[i].competitor === i && teams[i-1].level === gameLevel )\n console.log( allTeams[index].name + \" VS \" + allTeams[index+1].name );\n index += 2;\n }\n if ( allTeams.length % 2 === 1 )\n console.log(\" And \" + allTeams[allTeams.length-1].name + \" Will Ascends In The League ! \");\n console.log(\"*----------*----------*----------*---------*\");\n console.log(\"\");\n\n}", "title": "" }, { "docid": "ea820b158f0d3daa516f0c420e25969e", "score": "0.55451834", "text": "function _calc_match_players(matches_by_pid, entries, players, bm, is_league) {\n\tif (bm.bts_winners) {\n\t\treturn;\n\t}\n\n\tif (bm.EntryID) { // Either placeholder match or match won\n\t\tconst e = entries.get(bm.EntryID[0]);\n\t\tif (!e) {\n\t\t\tthrow new Error('Cannot find entry ' + bm.EntryID[0]);\n\t\t}\n\n\t\tconst p1 = players.get(e.Player1ID[0]);\n\t\tassert(p1);\n\t\tconst res = [p1];\n\t\tif (e.Player2ID) {\n\t\t\tconst p2 = players.get(e.Player2ID[0]);\n\t\t\tassert(p2);\n\t\t\tres.push(p2);\n\t\t}\n\t\tbm.bts_winners = res;\n\t\tif (! bm.IsMatch) {\n\t\t\t// Placeholder for one entry, we're done here\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// Normal match\n\tlet p1ar, p2ar;\n\tif (is_league) {\n\t\tif (!bm.Team1Player1ID) return;\n\n\t\tp1ar = [players.get(bm.Team1Player1ID[0])];\n\t\tif (bm.Player2ID) {\n\t\t\tp1ar.push(players.get(bm.Team1Player2ID[0]));\n\t\t}\n\t\tp2ar = [players.get(bm.Team2Player1ID[0])];\n\t\tif (bm.Player2ID) {\n\t\t\tp2ar.push(players.get(bm.Team2Player2ID[0]));\n\t\t}\n\t} else {\n\t\tassert(bm.DrawID);\n\t\tassert(bm.DrawID[0]);\n\t\tif (!bm.From1) {\n\t\t\treturn;\n\t\t}\n\t\tassert(bm.From1);\n\t\tassert(bm.From1[0]);\n\t\tconst m1 = matches_by_pid.get(bm.DrawID[0] + '_' + bm.From1[0], is_league);\n\t\tassert(m1);\n\t\t_calc_match_players(matches_by_pid, entries, players, m1);\n\t\tp1ar = m1.bts_winners;\n\t\tassert(bm.From2);\n\t\tassert(bm.From2[0]);\n\t\tconst m2 = matches_by_pid.get(bm.DrawID[0] + '_' + bm.From2[0], is_league);\n\t\tassert(m2);\n\t\t_calc_match_players(matches_by_pid, entries, players, m2, is_league);\n\t\tp2ar = m2.bts_winners;\n\t}\n\n\tbm.bts_players = [p1ar, p2ar];\n\tif (p1ar && p2ar) {\n\t\tbm.bts_complete = true;\n\t\tif (bm.Winner) {\n\t\t\t//if (! bm.bts_winners) {\n\t\t\t\t// TODO: happened at DM O 35\n\t\t\t\t//serror.silent(\n\t\t\t\t//\t'Strange match (num ' + bm.MatchNr + ') with Winner = ' + bm.Winner + ', '+\n\t\t\t\t//\t'but no winning players');\n\t\t\t//}\n\t\t\treturn;\n\t\t}\n\t}\n\treturn;\n}", "title": "" }, { "docid": "54c9db315f2aea6588aaf91bf14e8c75", "score": "0.55386555", "text": "function afterFindTeams(err, teamData){\n\t\t\tvar teamList = {};\n\n\t\t\t// Load teams and assing it's key as it's id\n\t\t\tteamData.forEach(function(team){\n\t\t\t\tteamList[team.id] = team;\n\t\t\t});\n\n\t\t\t// Includes team object in 'table' data\n\t\t\tdata.forEach(function(group){\n\n\t\t\t\t// console.log(group);\n\t\t\t\t// Go trough all the table adding key 'team' with team data\n\t\t\t\t_.forEach(group.table, function(row){\n\t\t\t\t\trow.team = teamList[row.teamId];\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// Includes team object in 'match' data\n\t\t\tdata.forEach(function(group){\n\n\t\t\t\t// console.log(group);\n\t\t\t\t// Go trough all the table adding key 'team' with team data\n\t\t\t\t_.forEach(group.matches, function(row){\n\t\t\t\t\trow.teamA = teamList[row.teamAId];\n\t\t\t\t\trow.teamB = teamList[row.teamBId];\n\t\t\t\t});\n\t\t\t});\n\n\t\t\t// console.log(data);\n\t\t\tfinishRendering();\n\t\t}", "title": "" }, { "docid": "f2f5c90c58ebc15fb192eafa160103f7", "score": "0.5538144", "text": "function teamCompare(a, b) {\n if (a.getStat(\"points\") > b.getStat(\"points\")) {\n return -1;\n }\n else if (b.getStat(\"points\") > a.getStat(\"points\")) {\n return 1;\n }\n else if (a.getStat(\"goalDifference\") > b.getStat(\"goalDifference\")) {\n return -1;\n }\n else if (b.getStat(\"goalDifference\") > a.getStat(\"goalDifference\")) {\n return 1; \n }\n else if (a.getStat(\"goalsFor\") > b.getStat(\"goalsFor\")) {\n return -1;\n }\n else if (b.getStat(\"goalsFor\") > a.getStat(\"goalsFor\")) {\n return 1;\n }\n else if (a.getStat(\"played\") > 0) {\n a.requiresAdvancedTiebreak = a.getStat(\"points\");\n b.requiresAdvancedTiebreak = b.getStat(\"points\");\n }\n return 0;\n }", "title": "" }, { "docid": "5f7928ceaa7916f5308fdf55bb85ae3d", "score": "0.55206347", "text": "serverWins() {\n if (this.servingTeam() == nameWest) {\n this.west_score++;\n this.setCheers(this.win_cheer, this.loss_cheer);\n this.msg = this.msgWin(this.servingTeam(), this.serving);\n if (this.gameOver()) {\n this.animateMeetAtNet(true);\n } else {\n this.swapPosition(this.players[0],\n this.players[1],\n this.servingTeam());\n }\n } else if (this.servingTeam() == nameEast) {\n this.east_score++;\n this.setCheers(this.loss_cheer, this.win_cheer);\n this.msg = this.msgWin(this.servingTeam(), this.serving);\n if (this.gameOver()) {\n this.animateMeetAtNet(true);\n } else {\n this.swapPosition(this.players[2],\n this.players[3],\n this.servingTeam());\n }\n }\n }", "title": "" }, { "docid": "c8fc4f32545af9676e37687b865d46eb", "score": "0.55176276", "text": "function getOtherTeam(team) {\n return 1 - team;\n }", "title": "" }, { "docid": "318789091afd19822de10ec5db6b617c", "score": "0.5516971", "text": "function getWinners(data, cb) {\n const finalsData = cb(data);\n const winner = []\n finalsData.forEach(data => {\n const homeTeam = {\n name: data[\"Home Team Name\"],\n finalScore: data[\"Home Team Goals\"]\n }\n const awayTeam = {\n name: data[\"Away Team Name\"],\n finalScore: data[\"Away Team Goals\"]\n }\n const winCon = data[\"Win conditions\"].split(\" \");\n\n if(homeTeam.finalScore > awayTeam.finalScore){\n winner.push(homeTeam.name);\n }else if(homeTeam.finalScore < awayTeam.finalScore){\n winner.push(awayTeam.name);\n }else{\n winner.push(winCon[0]);\n }\n });\n return winner; \n}", "title": "" }, { "docid": "1d47d5038eab35e187fab28142e27eaf", "score": "0.5488953", "text": "function giveMatches(myFarm){\n\tfor(i=0;i<myFarm.length;i++)\n\t\tmyFarm[i].matches.push(myFarm[i].friends[myFarm[i].friends.length-1]);\n\t}", "title": "" }, { "docid": "8bb98cfa07ad67931ed867c953444de1", "score": "0.5487346", "text": "function predictMatch(match_teams) {\n let red_alliance = 0;\n let blue_alliance = 0;\n for (let team_index in match_teams) {\n let team = match_teams[team_index];\n if (team === undefined) {continue;}\n // ignores backup robots from predicted score\n if (match_teams.length == 8 && team_index % 4 == 3) { continue; }\n // a list of scores\n let scores = allScoresForTeam(team, gameScript.general.calculateScore);\n // mean score\n let mean = roundto100th(jStat.mean(scores));\n // adds it to correct alliance\n if (team_index < (match_teams.length / 2)) {\n red_alliance += mean;\n } else {\n blue_alliance += mean;\n }\n }\n return [roundto100th(red_alliance), roundto100th(blue_alliance)];\n}", "title": "" }, { "docid": "79b2e35d8382fcca06e04eb84417a553", "score": "0.5461729", "text": "function determineWinnerOfTopLane(data) {\n\t\t\t//should be a constructor for player objects like this\n\t\t\tvar topramen = {\n\t\t\t\tidentity: data.participantIdentities[9],\n\t\t\t\tparticipant: data.participants[9],\n\t\t\t\tlane: data.participants[9].timeline.lane,\n\t\t\t\trole: data.participants[9].timeline.role,\n\t\t\t\tdeaths: [],\n\t\t\t\ttowerKills: []\n\t\t\t};\n\n\t\t\t//finding deaths of a champion is more efficient than finding everyone's kills \n\t\t\t//for determining how much other players influence a single lane.\n\t\t\ttopramen.deaths = findChampionDeaths(data,10);\n\t\t\t//console.log(topramen.deaths);\n\t\t\t\n\t\t\tvar teamBlue = {};\n\t\t\tteamBlue.players = [];\n\t\t\tteamBlue.players.push(createPlayer(data,0));\n\t\t\tteamBlue.players.push(createPlayer(data,1));\n\t\t\tteamBlue.players.push(createPlayer(data,2));\n\t\t\tteamBlue.players.push(createPlayer(data,3));\n\t\t\tteamBlue.players.push(createPlayer(data,4));\n\n\t\t\ttopramen.deaths.forEach(function(cv) {\n\t\t\t\tteamBlue.players[(cv.killerId-1)].kills++;\n\t\t\t});\n\n\t\t\tteamBlue.players.sort(function(a,b) {\n\t\t\t\tif(a.kills < b.kills) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tif(a.kills > b.kills) {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t});\n\t\t\tteamBlue.players.reverse();\n\t\t\t\n\t\t\tteamBlueColors = [\"#435ee8\",\"#5f75e8\",\"#7b8de8\",\"#96a4e8\",\"#a5b4ff\"];\n\n\t\t\t//console.log(teamBlue);\n\n\t\t\tvar cvsBlue = document.getElementById('cvsTeamBlue');\n\t\t\tvar ctxBlue = cvsBlue.getContext('2d');\n\t\t\tvar data = {\n\t\t\t labels: [\n\t\t\t teamBlue.players[0].name,\n\t\t\t teamBlue.players[1].name,\n\t\t\t teamBlue.players[2].name,\n\t\t\t teamBlue.players[3].name,\n\t\t\t teamBlue.players[4].name\n\t\t\t ],\n\t\t\t datasets: [\n\t\t\t {\n\t\t\t data: [\n\t\t\t\t teamBlue.players[0].kills,\n\t\t\t\t teamBlue.players[1].kills,\n\t\t\t\t teamBlue.players[2].kills,\n\t\t\t\t teamBlue.players[3].kills,\n\t\t\t\t teamBlue.players[4].kills\n\t\t\t ],\n\t\t\t backgroundColor: teamBlueColors,\n\t\t\t hoverBackgroundColor: teamBlueColors\n\t\t\t }]\n\t\t\t};\n\n\t\t\tvar showPercentAndValueOptions = \n\t\t\t\t{\n\t\t\t\t\ttooltips: {\n\t\t\t\t\t\tcallbacks: {\n\t\t\t\t\t\t\tlabel: function(tooltipItem, data) {\n\t\t\t\t\t\t\t\tvar allData = data.datasets[tooltipItem.datasetIndex].data;\n\t\t\t\t\t\t\t\tvar tooltipLabel = data.labels[tooltipItem.index];\n\t\t\t\t\t\t\t\tvar tooltipData = allData[tooltipItem.index];\n\t\t\t\t\t\t\t\tvar total = 0;\n\t\t\t\t\t\t\t\tfor (var i in allData) {\n\t\t\t\t\t\t\t\t\ttotal += allData[i];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tvar tooltipPercentage = Math.round((tooltipData / total) * 100);\n\t\t\t\t\t\t\t\treturn tooltipLabel + ': ' + tooltipData + ' (' + tooltipPercentage + '%)';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\tvar deathByPlayerPieChart = new Chart(ctxBlue, {\n\t\t\t\ttype: 'pie',\n\t\t\t\tdata: data,\n\t\t\t\toptions: showPercentAndValueOptions\n\t\t\t});\n\n\t\t\tvar soloOrAssist = [0,0];\n\n\t\t\ttopramen.deaths.forEach(function(cv) {\n\t\t\t\tif(cv.killerId == 5) {\n\t\t\t\t\tif(cv.assistingParticipantIds) {\n\t\t\t\t\t\tsoloOrAssist[0]++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsoloOrAssist[1]++;\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(cv);\n\t\t\t\t}\n\t\t\t});\n\t\t\tsoloOrAssist.sort();\n\n\t\t\tvar cvsTop = document.getElementById('cvsTopLane');\n\t\t\tvar ctxTop = cvsTop.getContext('2d');\n\t\t\tvar deathByTopLane = new Chart(ctxTop, {\n\t\t\t\ttype: 'pie',\n\t\t\t\tdata: {\n\t\t\t\t\tlabels: [\n\t\t\t\t\t\t\"Solo Kills\",\n\t\t\t\t\t\t\"Assisted Kills\"\n\t\t\t\t\t],\n\t\t\t\t\tdatasets: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdata: [\n\t\t\t\t\t\t\t\tsoloOrAssist[0],\n\t\t\t\t\t\t\t\tsoloOrAssist[1]\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tbackgroundColor: [\"#435ee8\", \"#a5b4ff\"],\n\t\t\t \thoverBackgroundColor: [\"#435ee8\", \"#a5b4ff\"]\n\t\t\t \t}]\n\t\t\t\t\t},\n\t\t\t\toptions: showPercentAndValueOptions\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "eace1f8075ca1b6c9bdfb5b135bf10ff", "score": "0.5444914", "text": "function sortLeaguesByTeamsByWins() {\n // CODE HERE\n return leaguesWithWins()\n .sort((league1, league2) => league2.count - league1.count)\n .map((league) => league.name)\n}", "title": "" }, { "docid": "50c8553318749045661ea5197b1894e8", "score": "0.54327106", "text": "function Off_Teams(a_team){\n\tthis.against = a_team; // This is the team that the offense is built against\n\tthis.num = 0;\n\t\n\tthis.addTeam = function(team, score, version, comment = \"\"){\n\t\tif(comment === null) comment = \"\";\n\t\tthis[this.num] = {team: team, score: score, version: version, comment: comment};\n\t\tthis.num++;\n\t}\n\t\n\tthis.getDefStr = function(){\n\t\treturn this.against.unitsStr();\n\t}\n\t\n\tthis.getTeam = function(num){\n\t\treturn this[num].team.unitsStr();\n\t}\n\t\n\tthis.getScore = function(num){\n\t\treturn this[num].score;\n\t}\n\t\n\tthis.getVersion = function(num){\n\t\treturn this[num].version;\n\t}\n\t\n\tthis.getComment = function(num){\n\t\treturn this[num].comment;\n\t}\n\t\n\t// example properties\n\t// this[0] = Jun_Miyako_Kuka_Ilya_Hiyori\n\t// this[\"Jun_Miyako_Kuka_Ilya_Hiyori\"] = 512\n\t\n\tthis.teamStr = function(num){\n\t\tlet data = this[num];\n\t\tlet team = data.team.split(\"_\");\n\t\tlet main = \":\" + team.join(\": :\") + \": \" + \"Score:\" + data.score + \" V\" + data.version;\n\t\tlet comm = data.comment;\n\t\tif(comm !== \"\"){\n\t\t\tmain = main + \"\\n\" + comm;\n\t\t}\n\t\treturn main;\n\t}\n\t\n\tthis.filtStr = function(){\n\t\tif(this.num == 1){\n\t\t\treturn [this.teamStr(0)];\n\t\t}else{\n\t\t\tlet arr = [];\n\t \t\tfor(let i = 0; i < this.num; i++){\n\t \t\t\tarr[i] = this.teamStr(i);\n\t \t\t}\n\t \t\treturn arr;\n\t \t}\n\t}\n}", "title": "" }, { "docid": "4a9a6a15954d7bba2890d823900423b4", "score": "0.54313546", "text": "static getNumberOfMatchUps (numberOfTeams, teamsPerMatch) {\n let match_count = 0;\n while (numberOfTeams != 1) {\n numberOfTeams = Math.floor(numberOfTeams / teamsPerMatch);\n match_count += numberOfTeams;\n\n // console.warn(\"numberOfTeams = \" + numberOfTeams);\n // console.warn(\"match_count = \" + match_count);\n }\n return match_count;\n }", "title": "" }, { "docid": "44be4982e35af207d22f03a4641256d3", "score": "0.5429373", "text": "function allAgainstAll(group){\n group.schedule = [];\n\n for (let i = 0; i < group.teams.length-1; i++){\n const matchesPerDay = matchScheme(group.teams.length/2);\n group.schedule.push(matchesPerDay);\n }\n}", "title": "" }, { "docid": "81297d7bf290d3d545f1aa9007a06bad", "score": "0.5425048", "text": "function sendWinner(connection, res, name1, name2, stat) {\n connection.query(\"SELECT name FROM team_stats \"+\n \"JOIN teams ON teams.id = team_stats.team_id \"+\n \"WHERE name='\"+name1+\"' OR name='\"+name2+\n \"' ORDER BY team_stats.\"+stat+\" DESC LIMIT 1\",\n function(err, result, fields) {\n if(err) {\n throw err;\n //Tell client that query ran into error\n res.sendStatus(500);\n } else {\n //Otherwise, send winning team's name to client\n res.send(JSON.stringify(result));\n }\n });\n }", "title": "" }, { "docid": "a464de2de5aa1f6dbe8b767f6e329711", "score": "0.542402", "text": "function bestScoreRecognizer() {\n let index = 0;\n console.log(\" *-------\\\\Who Ascends In This LEVEL/-----*\");\n for ( let i = 1; i < teams.length; i+=2 ) {\n if ( teams[i].competitor === i && teams[i].level === gameLevel){\n if ( teams[index].score >= teams[index+1].score ){\n teams[index].level++;\n console.log( \" Team : \" + teams[index].name);\n }\n else{\n teams[index+1].level++;\n console.log( \" Team : \" + teams[index+1].name);\n }\n }\n index += 2;\n }\n if ( teams.length % 2 === 1 ){\n teams[teams.length-1].level++;\n console.log(\" Team : \" + teams[teams.length-1].name);\n console.log(\" Will Ascends In The League ! \");\n }\n console.log(\"*----------*----------*----------*---------*\");\n console.log(\"\");\n gameLevel++;\n}", "title": "" }, { "docid": "41658cd23ed681c44f7cd03a26ee0445", "score": "0.54183316", "text": "function getWinners() {\n\t\t\t$scope.winners = filterFilter($scope.participants, {winner : 1});\n\t\t}", "title": "" }, { "docid": "3062aa566f7ce88efa23f4c7046e5948", "score": "0.5374595", "text": "function winner(arrayOfPlayers) {\n var firstPlace = arrayOfPlayers[0].total;\n for (var i = 1; i < arrayOfPlayers.length; i++) {\n if (firstPlace < arrayOfPlayers[i].total) {\n firstPlace = arrayOfPlayers[i].total;\n }\n }\n for (i = 0; i < arrayOfPlayers.length; i++) {\n if (firstPlace === arrayOfPlayers[i].total) {\n finalResult.push(arrayOfPlayers[i]);\n }\n }\n return finalResult;\n}", "title": "" }, { "docid": "c0d962262b15a432e6c1e608cfaef67e", "score": "0.53716797", "text": "function returnMatches() {\n var matches = [];\n for (var i = 0; i < likes.length; i++) {\n for (var j = 0; j < likers.length; j++) {\n if (likes[i].liked === likers[j].username) {\n\n matches.push(likes[i].liked);\n }\n }\n }\n return matches;\n }", "title": "" }, { "docid": "dc630fd1cac1e3659474c5e66127aa42", "score": "0.53613454", "text": "function TableShow(){\nvar html = \"<table border='1|1'>\";\n html+=\"<tr>\";\n html+=\"<td><b>Team Name</b></td>\";\n html+=\"<td><b>Win</b></td>\";\n html+=\"<td><b>Loss</b></td>\";\n html+=\"<td><b>Tie</b></td>\";\n html+=\"<td><b>Score</b></td>\";\n html+=\"</tr>\";\n for (var i = 0; i < TeamInfo.length; i++) {\n html+=\"<tr>\";\n html+=\"<td>\"+TeamInfo[i].name+\"</td>\";\n html+=\"<td>\"+TeamInfo[i].win+\"</td>\";\n html+=\"<td>\"+TeamInfo[i].loss+\"</td>\";\n html+=\"<td>\"+TeamInfo[i].tie+\"</td>\";\n html+=\"<td>\"+TeamInfo[i].score+\"</td>\";\n html+=\"</tr>\";\n }\n\n html+=\"</table>\";\n html+=\"<br><br>\";\n html+=\"<h3>Matchups</h3>\";\n\nif (EvenOrOdd==\"Even\"){\n for (var i = 0, d=1; i < Totalnumberofteams; i++, d++) {\n html+=\"<p><b>Matchup \"+[d]+\"</b></p>\";\n html+=\"<table>\";\n html+=\"<tr>\";\n html+=\"<td>\"+TeamInfo[i].name+\"</td>\";\n html+=\"<td>----VS----</td>\";\n html+=\"<td>\"+TeamInfo[i+1].name+\"</td>\";\n html+=\"</tr>\";\n html+=\"</table>\";\n html+=\"<br>\";\n i+=1\n }}\n //below makes makes the matchup based on even or odd amount of teams\nif (EvenOrOdd==\"Odd\"){\n html+=\"<p><b>Bye Week</b></p>\";\n html+=\"<p>\"+TeamInfo[0].name+\"</p><br>\";\n for (var i = 1, d=0; i < Totalnumberofteams; i++, d++) {\n html+=\"<p><b>Matchup \"+[d+1]+\"</b></p>\";\n html+=\"<table>\";\n html+=\"<tr>\";\n html+=\"<td>\"+TeamInfo[i].name+\"</td>\";\n html+=\"<td>----VS----</td>\";\n html+=\"<td>\"+TeamInfo[i+1].name+\"</td>\";\n html+=\"</tr>\";\n html+=\"</table>\";\n html+=\"<br>\";\n i+=1\n }\n\n}\n\ndocument.getElementById(\"box\").innerHTML = html;\n}", "title": "" }, { "docid": "9a4f771497ce87f237a8ab8c087d84de", "score": "0.5356872", "text": "function checkWinState() {\n winner = false;\n for (let i = 0; i < winningPlays.length; i++) {\n {\n let matchPlays = 0;\n let winningPlay = winningPlays[i];\n for (let y = 0; y < winningPlay.length; y++) {\n let play = winningPlay[y];\n if (currentPlayer.plays.includes(play)) {\n matchPlays++;\n }\n if (matchPlays === 3) {\n console.log('win');\n gameWon = true;\n winner = true;\n }\n }\n }\n }\n return winner;\n}", "title": "" }, { "docid": "3cd7f6f71b6571875fce47c7278d5b93", "score": "0.5356643", "text": "function findMatchLoop() {\n // Loop through all players looking for a match\n for (var playerId in playersLookingForMatch) {\n\n var player = playersLookingForMatch[playerId];\n\n // Timeout the player and continue to the next if they have been searching for too long\n if (nowTime > (player.startTime + matchSearchTimeout)) {\n\t\t\tfindMatchTimeout(playerId);\n\t\t\tcontinue;\n\t\t}\n\n if (player.matchFound) {\n continue;\n } else {\n // Find potentional opponents\n for (var opponentId in playersLookingForMatch) {\n\n var opponent = playersLookingForMatch[opponentId];\n\n\t\t\t\t// We treat the 'host' player as the player who first initiated the findMatch,\n\t\t\t\t// so the 'join' player must always come later in time.\n if (opponent.startMuTime < player.startMuTime\n\t\t\t\t\t&& opponent.matchFound == false) {\n\n\t\t\t\t\tplayer.matchFound = true;\n\t\t\t\t\topponent.matchFound = true;\n\n\t\t\t\t\t// match found, trigger it\n\t\t\t\t\tmatchFound(opponent, player);\n\n\t\t\t\t}\n }\n }\n }\n}", "title": "" }, { "docid": "cd052630857f6b5cfce86f171b81aa77", "score": "0.53470904", "text": "function Winner() {\n\t\tvar Key;\n\t\tvar Itm;\n\t\tvar Win = [];\n\n\t\tif (Players[MyIndex].Pick === Players[OgIndex].Pick) {\n\t\t\tPlayers[MyIndex].Ties++;\n\t\t\tWin.push(\"It's a Tie !!!\");\n\t\t\tWin.push(\"\");\n\t\t\tWin.push(RPSLS[Players[MyIndex].Pick]);\n\t\t\tWin.push(\"vs\");\n\t\t\tWin.push(RPSLS[Players[OgIndex].Pick]);\n\t\t} else {\n\t\t\tKey = Players[MyIndex].Pick.toString() + Players[OgIndex].Pick.toString();\n\t\t\tvar Test = Rules.find(Itm => Itm.Key === Key);\n\t\t\tif (Test === undefined) {\n\t\t\t\tKey = Players[OgIndex].Pick.toString() + Players[MyIndex].Pick.toString();\n\t\t\t\tTest = Rules.find(Itm => Itm.Key === Key);\n\t\t\t\tPlayers[MyIndex].Lost++;\n\t\t\t\tWin.push(\"You Lose !!!\");\n\t\t\t\tWin.push(\"\");\n\t\t\t\tWin.push(RPSLS[Players[OgIndex].Pick]);\n\t\t\t\tWin.push(Test.Act);\n\t\t\t\tWin.push(RPSLS[Players[MyIndex].Pick]);\n\t\t\t} else {\n\t\t\t\tPlayers[MyIndex].Wins++;\n\t\t\t\tWin.push(\"You Win !!!\");\n\t\t\t\tWin.push(\"\");\n\t\t\t\tWin.push(RPSLS[Players[MyIndex].Pick]);\n\t\t\t\tWin.push(Test.Act);\n\t\t\t\tWin.push(RPSLS[Players[OgIndex].Pick]);\n\t\t\t}\n\t\t}\n\t\treturn Win;\n\t}", "title": "" }, { "docid": "bf62a88fe723e9bde4cd955f8743b63f", "score": "0.5343971", "text": "tournamentWinner() {\n const tournamentSize = 3; //Math.max(2, this.genomes.length / 4 | 0);\n const tournamentBatch = [];\n\n while (tournamentBatch.length < tournamentSize) {\n tournamentBatch.push(this.genomes[Math.random() * this.genomes.length | 0]);\n }\n\n return this.sortByScores(tournamentBatch)[0];\n }", "title": "" }, { "docid": "d1419e04385ffb0457e3b27490fdbc82", "score": "0.5337673", "text": "determineNoMoves(player, targetSquare) {\r\n\r\n let players = this.players;\r\n let playerOneCheckers = players[0].checkersLeft;\r\n let playerTwoCheckers = players[1].checkersLeft;\r\n let playerCheckers = player.checkersLeft;\r\n let isStalemate = false;\r\n\r\n\r\n let possibleMoves = playerCheckers.filter(checker => {\r\n\r\n let moves = new Moves(player, this.squares);\r\n let possibleMoves = moves.possibleMoves(targetSquare);\r\n\r\n\r\n return possibleMoves.moves;\r\n });\r\n\r\n if(possibleMoves.length !== 0) {\r\n isStalemate = true;\r\n }\r\n this.determineWinner(\"noMoves\");\r\n\r\n \r\n }", "title": "" }, { "docid": "038ad0ad6b02aede9f3f7e559294a2f3", "score": "0.53369147", "text": "ready(team) {\n if (this.state.live && this.state.paused) {\n if (team === true) {\n this.state.unpause.TERRORIST = true;\n this.state.unpause.CT = true;\n } else {\n this.state.unpause[team] = true;\n }\n\n if (this.state.unpause.TERRORIST !== this.state.unpause.CT) {\n this.rcon(\n Rcons.READY.format(\n this.state.ready.TERRORIST ? Rcons.T : Rcons.CT,\n this.state.ready.TERRORIST ? Rcons.CT : Rcons.T\n )\n );\n } else if (this.state.unpause.TERRORIST === true && this.state.unpause.CT === true) {\n this.rcon(Rcons.MATCH_UNPAUSE);\n this.state.paused = false;\n this.state.unpause = {\n TERRORIST: false,\n CT: false\n };\n }\n } else if (!this.state.live) {\n if (team === true) {\n this.state.ready.TERRORIST = true;\n this.state.ready.CT = true;\n } else {\n this.state.ready[team] = true;\n }\n\n if (this.state.ready.TERRORIST !== this.state.ready.CT) {\n this.rcon(\n Rcons.READY.format(\n this.state.ready.TERRORIST ? Rcons.T : Rcons.CT,\n this.state.ready.TERRORIST ? Rcons.CT : Rcons.T\n )\n );\n } else if (this.state.ready.TERRORIST === true && this.state.ready.CT === true) {\n this.state.live = true;\n this.state.round = 0;\n const demo =\n \"matches/\" +\n new Date()\n .toISOString()\n .replace(/T/, \"_\")\n .replace(/:/g, \"-\")\n .replace(/\\..+/, \"\") +\n \"_\" +\n this.state.map +\n \"_\" +\n Utils.cleandemo(this.clantag(\"TERRORIST\")) +\n \"-\" +\n Utils.cleandemo(this.clantag(\"CT\")) +\n \".dem\";\n const that = this;\n if (this.state.knife) {\n this.rcon(Rcons.KNIFE_STARTING.format(demo));\n setTimeout(function() {\n that.rcon(Rcons.KNIFE_STARTED);\n }, 9000);\n } else {\n this.rcon(Rcons.MATCH_STARTING.format(demo));\n setTimeout(function() {\n that.rcon(Rcons.MATCH_STARTED);\n }, 9000);\n }\n const message =\n this.stats(false) +\n \"\\n\" +\n this.state.maps\n .join(\" \")\n .replace(this.state.map, \"*\" + this.state.map + \"*\")\n .replace(/de_/g, \"\") +\n \"\\n*Match started*\";\n this.cfg.bot.telegramBot.sendMessage(\n this.cfg.nconf.get(\"telegram:groupId\"),\n \"*Console@\" + this.cfg.ip + \":\" + this.cfg.port + \"*\\n\" + message,\n {\n parse_mode: \"Markdown\"\n }\n );\n const gotv = this.cfg.nconf.get(\"gotv\");\n if (gotv[this.cfg.ip][this.cfg.port] !== undefined && Object.keys(this.state.players).length >= 5) {\n const teams = this.clantag(\"TERRORIST\") + \" - \" + this.clantag(\"CT\");\n const channels = this.cfg.nconf.get(\"irc:channels\");\n for (const i in channels) {\n if (channels.hasOwnProperty(i)) {\n this.cfg.bot.ircClient.send(\n \"NOTICE\",\n this.cfg.nconf.get(\"irc:channels\")[i],\n \"Matsi alkaa! (\" + teams + \") GOTV osoitteessa \" + gotv[this.cfg.ip][this.cfg.port]\n );\n }\n }\n }\n setTimeout(function() {\n that.chat(\" \\x054...\");\n }, 1000);\n setTimeout(function() {\n that.chat(\" \\x063...\");\n }, 2000);\n setTimeout(function() {\n that.chat(\" \\x102...\");\n }, 3000);\n setTimeout(function() {\n that.chat(\" \\x0f1...\");\n }, 4000);\n setTimeout(function() {\n that.rcon(Rcons.LIVE);\n that.rcon('script ScriptPrintMessageCenterAll(\"Match is LIVE! GL HF!\")');\n }, 5000);\n }\n }\n }", "title": "" }, { "docid": "3c17d9164f3f188923f5ae3af7602d34", "score": "0.5325577", "text": "function determineLaneWinner(data) {\n\t\t\tvar championKillEvent = [];\n\t\t\tdata.timeline.frames.forEach(function(cv,i) {\n\t\t\t\tif(cv.events) {\n\t\t\t\t\t/*\n\t\t\t\t\tvar tmp = cv.events.find(function(cv, i) {\n\t\t\t\t\t\treturn cv.eventType == 'BUILDING_KILL' && cv.towerType == 'OUTER_TURRET';\n\t\t\t\t\t});\n\t\t\t\t\t*/\n\t\t\t\t\tvar tmp = cv.events.find(function(cv,i) {\n\t\t\t\t\t\treturn cv.eventType == 'CHAMPION_KILL';\n\t\t\t\t\t});\n\t\t\t\t\tif(typeof tmp !== 'undefined') {\n\t\t\t\t\t\tchampionKillEvent.push(tmp);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tconsole.log(championKillEvent);\n\t\t}", "title": "" }, { "docid": "ff6a51b5a25acd13f29b8858a89c766f", "score": "0.53159624", "text": "checkAll () {\n let match = false\n let player\n\n for (let b=0; b<this.span; b++) {\n for (let r=0; r<this.span; r++) {\n for (let c=0; c<this.span; c++) {\n\n if (this.gameState[b][r][c] !== \" \") {\n match = match || this.isWinningMove(b, r, c, this.gameState[b][r][c])\n if (match) {\n player = this.gameState[b][r][c]\n break\n }\n }\n }\n }\n }\n\n\n return player\n\n\n // if (match) {\n // playerNum.style.color = this.board.playerColours[player]\n // winsDisplay.style.display = \"inline-block\"\n // } else {\n // this.playerIndex = ++this.playerIndex % this.players.length\n // winsDisplay.style.display = \"none\"\n // playerNum.style.color = this.board.playerColours[this.playerIndex]\n // }\n }", "title": "" }, { "docid": "6a5461265fb05de2d54bc7a66f41cbf0", "score": "0.53158444", "text": "function testEliminationMatch(threatener, evalTeam) {\n if (!threat(threatener, evalTeam)) { //\"Threatener\" doesn't actually threaten evalTeam. Return heavy loss for opponent.\n return [99,0];\n }\n var ptsBetween = evalTeam.getStat(\"points\") - threatener.getStat(\"points\");\n var goalDifferenceBetween = evalTeam.getStat(\"goalDifference\") - threatener.getStat(\"goalDifference\");\n var goalsForBetween = evalTeam.getStat(\"goalsFor\") - threatener.getStat(\"goalsFor\");\n var winBy, loseBy;\n switch (ptsBetween) {\n case 3: //If the threatener trails by 3 points, they can safely win by as many points as they are behind in goal difference.\n winBy = (goalDifferenceBetween <= goalsForBetween) ? goalDifferenceBetween : goalDifferenceBetween - 1;\n winBy = (winBy > 0) ? winBy : 0; //If the threatener leads in goal difference, they cannot safely win. Return 0-0 draw.\n return [winBy, 0];\n break;\n case 2: //If the threatener trails by only 2 points, they cannot win without passing the evalTeam. Return 0-0 draw.\n return [0,0];\n break; \n case 1: //If the threatener trails by one point, return a 0-0 draw, unless they would win the tiebreak. Then return 0-1 loss.\n if (goalDifferenceBetween < 0 || (goalDifferenceBetween === 0 && goalsForBetween < 0)) {\n return [0,1];\n }\n else {\n return [0,0];\n }\n break;\n case 0: //If the threatener is tied, in order to not finish above the evalTeam, they must lose by enough to lose the tiebreak.\n if (goalDifferenceBetween < 0) {\n loseBy = 0 - goalDifferenceBetween;\n if (goalsForBetween < 0) {\n loseBy++;\n }\n }\n else { //If the threatener is already losing the tiebreak, just lose by 1.\n loseBy = 1;\n }\n return [0, loseBy];\n break;\n }\n }", "title": "" }, { "docid": "7b1572aa262be211628da3e7c60d347e", "score": "0.53150976", "text": "disbandTeam(teamName) {\n this.entrants.forEach((entrant) => {\n if (entrant.team === teamName) {\n entrant.team = \"\";\n }\n });\n }", "title": "" }, { "docid": "dd2e0bd6e16491a790a52d756d481823", "score": "0.5305534", "text": "function hasWon(player_squares) {\n for (var i = 0; i < player_squares.length; i++) {\n for (var j = i + 1; j < player_squares.length; j++) {\n for (var k = j + 1; k < player_squares.length; k++) {\n if (player_squares[i] + player_squares[j] + player_squares[k] === 15) {\n return true;\n }\n }\n }\n }\n return false;\n }", "title": "" }, { "docid": "1cde1d5079d1be698298094e0ea5250b", "score": "0.53055006", "text": "function teamsWithMoreThanThreePlayers () {\n\t\tlet teamsAux = []\n\t\tTEAMS.forEach( t => {\n\t\t\tif ( t.players.length >= 3 ) {\n\t\t\t\tteamsAux.push( t )\n\t\t\t}\n\t\t} )\n\t\tsetTeams( teamsAux )\n\t}", "title": "" }, { "docid": "a187b0489ba530f9f95d33c3b01577c7", "score": "0.53049624", "text": "function visualizeMatchesWon(yearTeamObj) {\n let years = Object.keys(yearTeamObj); // for plotting the x axis;\n // console.log(years);\n let Arr = [];\n let newArr = [];\n\n for (let arrPerYear of Object.values(yearTeamObj)) {\n let result = {};\n for (let team of arrPerYear) {\n if (result[team]) {\n result[team]++\n } else {\n result[team] = 1;\n }\n }\n Arr.push(result);\n }\n // Arr returns the array of [{team1..team n:countofteam1...countofteamn},{team1..team n:countofteam1...countofteamn}...] per year aggregation \n\n let teamArr = ['Sunrisers Hyderabad',\n 'Royal Challengers Bangalore',\n 'Mumbai Indians',\n 'Rising Pune Supergiant',\n 'Gujarat Lions',\n 'Kolkata Knight Riders',\n 'Kings XI Punjab',\n 'Delhi Daredevils',\n 'Chennai Super Kings',\n 'Rajasthan Royals',\n 'Deccan Chargers',\n 'Kochi Tuskers Kerala',\n 'Pune Warriors',\n 'Rising Pune Supergiants',\n 'Delhi Capitals', 'noResult'\n ];\n\n\n for (let team of teamArr) {\n for (let obj of Arr) {\n if (obj[team]) {\n newArr.push({\n name: team,\n data: obj[team]\n })\n } else {\n newArr.push({\n name: team,\n data: 0\n })\n };\n }\n }\n\n let dataArray = [];\n\n for (let j = 0; j < teamArr.length; j++) {\n let innerarray = [];\n for (let i = 0; i < newArr.length; i++) {\n if (newArr[i].name == teamArr[j]) {\n if (typeof newArr[i].data != 'undefined') {\n innerarray.push(newArr[i].data);\n }\n }\n }\n dataArray.push(innerarray);\n }\n\n Highcharts.chart(\"matches-won-by-each-time-alltime\", {\n chart: {\n type: 'column'\n },\n title: {\n text: '2. Number of matches won by each team over all the years of IPL'\n },\n subtitle: {\n text: 'Source: <a href=\"https://www.kaggle.com/nowke9/ipldata/data\">IPL Dataset</a>'\n },\n xAxis: {\n categories: years,\n crosshair: true\n },\n yAxis: {\n min: 0,\n title: {\n text: 'Matches Won'\n }\n },\n tooltip: {\n headerFormat: '<span style=\"font-size:10px\">{point.key}</span><table>',\n pointFormat: '<tr><td style=\"color:{series.color};padding:0\">{series.name}: </td>' +\n '<td style=\"padding:0\"><b>{point.y:f} </b></td></tr>',\n footerFormat: '</table>',\n shared: true,\n useHTML: true\n },\n plotOptions: {\n column: {\n pointPadding: 0.2,\n borderWidth: 0\n }\n },\n series: [{\n name: teamArr[0],\n data: dataArray[0]\n\n },\n {\n name: teamArr[1],\n data: dataArray[1]\n\n }, {\n name: teamArr[2],\n data: dataArray[2]\n\n }, {\n name: teamArr[3],\n data: dataArray[3]\n\n }, {\n name: teamArr[4],\n data: dataArray[4]\n\n }, {\n name: teamArr[5],\n data: dataArray[5]\n\n }, {\n name: teamArr[6],\n data: dataArray[6]\n\n }, {\n name: teamArr[7],\n data: dataArray[7]\n\n }, {\n name: teamArr[8],\n data: dataArray[8]\n\n }, {\n name: teamArr[9],\n data: dataArray[9]\n\n }, {\n name: teamArr[10],\n data: dataArray[10]\n\n }, {\n name: teamArr[11],\n data: dataArray[11]\n\n }, {\n name: teamArr[12],\n data: dataArray[12]\n\n }, {\n name: teamArr[12],\n data: dataArray[12]\n\n }, {\n name: teamArr[13],\n data: dataArray[13]\n\n }, {\n name: teamArr[14],\n data: dataArray[14]\n\n }, {\n name: teamArr[15],\n data: dataArray[15]\n\n }\n ]\n });\n}", "title": "" }, { "docid": "90ee896b781686f0323e6fc295703eeb", "score": "0.5300231", "text": "function findWinner(players) {\n return players.reduce((winner, p) => {\n const player = p;\n player.totalScore = p.scores.reduce((total, score) => total + score, 0);\n return winner.totalScore < player.totalScore ? player : winner;\n }, { totalScore: 0 }).name;\n}", "title": "" }, { "docid": "6777250a6302906460b11c33511330ee", "score": "0.5282804", "text": "function playCurrentFixtures() {\n //disable buttons\n fixtureBtn.disabled = true;\n loadTable.disabled = true;\n //local varibles\n let homeTeam;\n let awayTeam;\n let html = \"\"\n //hide unused divs\n $('#teamSelectView').hide();\n $('#playersSel').hide();\n //loops through each fixture\n for (fix in currentFixtures) {\n //fids the club for each fixture\n clubs.forEach(function (clubElement) {\n //gets the home team\n if (clubElement.name === currentFixtures[fix][0]) {\n homeTeam = clubElement;\n }\n //gets the away tema\n if (clubElement.name === currentFixtures[fix][1]) {\n awayTeam = clubElement;\n }\n });\n //gets the goals for each team\n let homeGoals = goalGenerator(getExpectedGoals(Math.max(homeTeam.strength_attack_home - awayTeam.strength_defence_away, -330)));\n let awayGoals = goalGenerator(getExpectedGoals(Math.max(awayTeam.strength_attack_away - homeTeam.strength_defence_home, -330)));\n //modifies the teams scored and conceded goals\n homeTeam.scored = homeTeam.scored + homeGoals;\n awayTeam.conceeded = awayTeam.conceeded + homeGoals;\n awayTeam.scored = awayTeam.scored + awayGoals;\n homeTeam.conceeded = homeTeam.conceeded + awayGoals;\n //increments the amount of matches the team has played\n awayTeam.played = awayTeam.played + 1;\n homeTeam.played = homeTeam.played + 1;\n //modifys the points of each team\n if (homeGoals === awayGoals) {\n //this is a draw so points and drawn matches modifed\n awayTeam.points = awayTeam.points + 1;\n homeTeam.points = homeTeam.points + 1;\n awayTeam.d = awayTeam.d + 1;\n homeTeam.d = homeTeam.d + 1;\n } else if (homeGoals > awayGoals) {\n //this is a home win so home points, w and away l modified\n homeTeam.points = homeTeam.points + 3;\n awayTeam.l = awayTeam.l + 1;\n homeTeam.w = homeTeam.w + 1;\n } else if (homeGoals < awayGoals) {\n //this is an away win so away points, w and home l modified\n awayTeam.points = awayTeam.points + 3;\n awayTeam.w = awayTeam.w + 1;\n homeTeam.l = homeTeam.l + 1;\n }\n //display each result\n html = html + `<div class = \"fixtures\">\n <table class =\"single\">\n <tr>\n <td> <img src='${homeTeam.getCrest()}' class=\"single img-responsive\"></td>\n <td>${homeTeam.name} </td>\n <td class=\"v\">${homeGoals} - ${awayGoals}</td>\n <td>${awayTeam.name} </td>\n <td> <img src='${awayTeam.getCrest()}' class=\" single img-responsive\"> </td>\n </tr>\n </table>\n </div>`;\n //display results\n $('#fixtureView').show();\n fixtureView.innerHTML = html;\n //log results\n console.log(`${homeTeam.name} ${homeGoals} - ${awayTeam.name} ${awayGoals}`);\n }\n //moves to the next week\n week = week + 1;\n messageBorad.getElementsByTagName(\"p\")[0].innerHTML = `Week ${week} results are now in`;\n //clears currentfitures array\n currentFixtures = {};\n //allows players to load again for the user to select\n playersLoaded = false;\n document.getElementById('playersSel').innerHTML = \"\";\n updateResults();\n}", "title": "" }, { "docid": "241605e30ae0f8d9d6c62a0c0a9f6981", "score": "0.5281379", "text": "updateWinners() {\n const winners = [...this.continuing]\n .filter(candidate => this.count[this.round][candidate] >= this.thresh[this.round]);\n if (!winners.length) return; // no winners\n\n const text = this.newWinners(winners);\n this.roundInfo[this.round].winners = text;\n }", "title": "" }, { "docid": "82111fdcedb0e65d08216adc8a7f9521", "score": "0.52726805", "text": "function hasWon() {\n if (matched === 16) {\n return true;\n } else {\n return false;\n }\n}", "title": "" }, { "docid": "70d97f54473aef59b66537d310ad7f2d", "score": "0.5266155", "text": "function addTeamDetails(team, lobbyTeam) {\n\tteam.ready = lobbyTeam.ready;\n\t_.each(lobbyTeam.players, function(lobbyPlayer) {\n\t\tvar found = false;\n\t\t_.each(team.players, function(player) {\n\t\t\tif (player.steamid == lobbyPlayer.steamid) {\n\t\t\t\tplayer.inGameRoster = true;\n\t\t\t\tfound = true;\n\t\t\t}\n\t\t});\n\n\t\t// Standin isn't on the normal roster\n\t\tif (!found) {\n\t\t\tteam.standin = lobbyPlayer;\n\t\t}\n\t});\n}", "title": "" }, { "docid": "1d0de64911f557e1504ef9951ca5fffb", "score": "0.5262608", "text": "function TeamStats(info) {\n (this.playerOne = info[0]),\n (this.playerTwo = info[1]),\n (this.wins = 0),\n (this.losses = 0),\n (this.winPercentage = 0);\n (this.addWin = function() {\n this.wins++;\n }),\n (this.addLoss = function() {\n this.losses++;\n }),\n (this.calcWinPercentage = function() {\n this.wins <= 0 ? '' : this.winPercentage = this.wins / (this.wins + this.losses);\n });\n }", "title": "" }, { "docid": "3b90e31dedde2db7f50e375bd3c7a6a3", "score": "0.525785", "text": "function getWinners(callBack) {\n const winners = [];\n const winnerFilter = callBack(fifaData).filter(function(item){\n if (item[\"Home Team Goals\"] > item[\"Away Team Goals\"]){\n winners.push(item[\"Home Team Name\"]);\n } else if(item[\"Away Team Goals\"] > item[\"Home Team Goals\"]) {\n winners.push(item[\"Away Team Name\"]);\n } else {\n winners.push(\"Teams Tied\")\n }\n })\n return winners;\n\n}", "title": "" }, { "docid": "432e05f341952b57c774be379b8910bd", "score": "0.52549154", "text": "function winProperty(winners) {\n for ( var idx = 0; idx < winners.length; idx++ ) {\n winners[idx].win = winners[idx].name + \" won the \" + winners[idx].eventWon;\n };\n console.log(winners);\n}", "title": "" }, { "docid": "41385a0f2971832c6e37281b66e8e560", "score": "0.52500176", "text": "function getTeamList(){\n\t\tdomo.get(\"/data/v1/teamList\").then(function(qaTeam){\n\t\t\tqaTeam.sort(directorSort);\n\t\t\tuNum = 0;\n\t\t\tvar temp_uNum = 0;\n\n\t\t\tfor(var t = 0; t < qaTeam.length; t++)\n\t\t\t{\n\n\t\t\t\tvar team = qaTeam[t].team;\n\t\t\t\tvar qa1 = qaTeam[t].qa1;\n\t\t\t\tvar qa2 = qaTeam[t].qa2;\n\t\t\t\tvar qa3 = qaTeam[t].qa3;\n\t\t\t\tvar i1 = qaTeam[t].i1;\n\t\t\t\tvar i2 = qaTeam[t].i2;\n\t\t\t\tvar director = qaTeam[t].director;\n\t\t\t\tvar features = qaTeam[t].features;\n\t\t\t\tvar uID = '';\n\n\t\t\t\tif (team.length <= 1) { team = tMiss; }\telse { team = team; } // team\n\t\t\t\tif (qa1 === undefined || qa1 === null || qa1 === \"\" || qa1 === 'TBH') { qa1 = uMiss; } else { qa1 = qa1; } // qa1\n\t\t\t\tif (qa2 === undefined || qa2 === null || qa2 === \"\" || qa2 === 'TBH') { qa2 = uMiss; } else { qa2 = qa2; } // qa2\n\t\t\t\tif (qa3 === undefined || qa3 === null || qa3 === \"\" || qa3 === 'TBH') { qa3 = uMiss; } else { qa3 = qa3; } // qa3\n\t\t\t\tif (i1 === undefined || i1 === null || i1 === \"\" || i1 === 'TBH') { i1 = uMiss; } else { i1 = i1; } // intern1\n\t\t\t\tif (i2 === undefined || i2 === null || i2 === \"\" || i2 === 'TBH') { i2 = uMiss; } else { i2 = i2; } // intern2\n\t\t\t\tif (director === undefined || director === null || director === \"\" || director === 'TBH') { director = uMiss; } else { director = director; } // intern2\n\t\t\t\tif (features === undefined || features === null || features === \"\") { features = fMiss; }\t// features\n\t\t\t\telse { \n\t\t\t\t\tif(features.indexOf(\", \")) {\n\t\t\t\t\t\tvar fRes = features.split(\",\");\n\t\t\t\t\t\tfeatures = fRes;\n\t\t\t\t\t}\n\t\t\t\t\telse {features = features;}\n\t\t\t\t}\n\n\t\t\t\tif (team !== 'Leadership') {\n\t\t\t\t\tteamList.push({team:team,qa1:qa1,qa2:qa2,qa3:qa3,i1:i1,i2:i2,director:director,features:features,uID:uID,uNum:uNum});\n\t\t\t\t\tuNum = uNum + 1;\n\t\t\t\t\tconsole.log(team + ' : ', teamList[t]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttemp_uNum = uNum;\n\t\t\t\t\tuNum = 99;\n\t\t\t\t\tconsole.log(uNum);\n\t\t\t\t\tteamList.push({team:team,qa1:qa1,qa2:qa2,qa3:qa3,i1:i1,i2:i2,director:director,features:features,uID:uID,uNum:uNum});\n\t\t\t\t\tteamLeader.push({team:team,qa1:qa1,qa2:qa2,qa3:qa3,i1:i1,i2:i2,director:director,features:features,uID:uID,uNum:uNum});\n\n\t\t\t\t\tuNum = temp_uNum;\n\t\t\t\t\tteamList = teamList;\n\t\t\t\t\tteamLeader = teamLeader;\n\t\t\t\t\tconsole.log(teamLeader[0].team + ' : ' + teamLeader[0].qa1 + ' : ', teamList[t]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tteamList.splice(temp_uNum, 1);\n\t\t\tdisplayTeamList();\n\t\t});\n\t}", "title": "" }, { "docid": "fb4f606f975bc9e0b3a241b5bbb96e5c", "score": "0.5249381", "text": "function getMultipleTogetherData(usrIds, oppIds) {\n\tvar bothIds = usrIds.concat(oppIds);\n\tconst matches = getData().filter(function(match) {\n\t\treturn bothIds.every(function(usrId){\n\t\t\treturn match.players.find(function(player){\n\t\t\t\tif(player.user.id === parseInt(usrId)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t})\n\n\tvar win = 0, loss = 0, tie = 0;\n\tvar matchesTogether = matches.filter(function(match){\n\t\tvar team = null;\n\t\tvar correctTeams = usrIds.every(function(usrId){ \n\t\t\tvar player = match.players.find(function(player){\n\t\t\t\treturn (player.user.id == usrId);\n\t\t\t})\n\t\t\tif (team == null) {\n\t\t\t\tteam = player.team;\n\t\t\t} \n\t\t\tvar corrOppTeam = oppIds.every(function(oppId){ \n\t\t\t\tvar opponent = match.players.find(function(opponent){\n\t\t\t\t\treturn (opponent.user.id == oppId);\n\t\t\t\t})\n\t\t\t\tif (team == opponent.team) {\n\t\t\t\t\treturn false\n\t\t\t\t} else {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn player.team == team && corrOppTeam;\n\t\t})\n\t\tif(correctTeams) {\n\t\t\tif(match.winningTeam == team) {\n\t\t\t\twin++;\n\t\t\t} else if (match.winningTeam != 0) {\n\t\t\t\tloss++; \n\t\t\t} else if (match.winningTeam == 0) {\n\t\t\t\ttie++;\n\t\t\t}\n\t\t}\n\t\treturn correctTeams;\n\t})\n\treturn { win: win, loss: loss, tie: tie}\n }", "title": "" }, { "docid": "d5363c9c05d2e7af9fade1b3af7ffb5b", "score": "0.52450645", "text": "function balanceTeams() {\n teams[0].player_amount = 0;\n teams[1].player_amount = 0;\n for (let i = 0; i < users.length; i++) {\n teams[users[i].team].player_amount++;\n }\n if (teams[0].player_amount - teams[1].player_amount > 1) {\n for (let i = 0; i < teams[0].player_amount - teams[1].player_amount; i++) {\n users[i].team = 1;\n users[i].hue = 0;\n teams[0].player_amount--;\n teams[1].player_amount++;\n }\n } else if (teams[1].player_amount - teams[0].player_amount > 1) {\n for (let i = 0; i < teams[1].player_amount - teams[0].player_amount; i++) {\n users[i].team = 0;\n users[i].hue = 220;\n teams[1].player_amount--;\n teams[0].player_amount++;\n }\n }\n teams[0].player_amount = 0;\n teams[1].player_amount = 0;\n for (let i = 0; i < users.length; i++) {\n teams[users[i].team].player_amount++;\n }\n}", "title": "" }, { "docid": "0a1853cfa3e591b0677768df359cc9b6", "score": "0.52445304", "text": "function secondFunction()\n {\n for (var i = 0; i < vm.second.length; i++)\n {\n for (var j = 0; j < vm.second[i].matches.length; j++)\n {\n main.mynewData.push(vm.second[i].matches[j]);\n }\n }\n //loop to check win status\n for (var i = 0; i < main.mynewData.length; i++)\n {\n if ((main.mynewData[i].team1.code === vm.teamcode || main.mynewData[i].team2.code === vm.teamcode) && (main.mynewData[i].team1.key === vm.teamkey || main.mynewData[i].team2.key === vm.teamkey))\n {\n\n\n vm.totalMatchesPlayed2.push(main.mynewData[i].team1.name);\n //team 1\n if (main.mynewData[i].team1.code === vm.teamcode && main.mynewData[i].team1.key === vm.teamkey)\n {\n vm.teamname2 = main.mynewData[i].team1.name;\n\n //totalgoals2 start\n vm.totalgoals2 = vm.totalgoals2 + main.myData[i].score1;\n //totalgoals2 end\n if (main.mynewData[i].score1 > main.mynewData[i].score2)\n {\n vm.totalWins2.push(main.mynewData[i].team2.code);\n\n }\n else if (main.mynewData[i].score1 < main.mynewData[i].score2)\n {\n vm.totalLost2.push(main.mynewData[i].team1.code);\n\n\n }\n else if (main.mynewData[i].score1 == main.mynewData[i].score2)\n {\n\n vm.totaltie2.push(main.mynewData[i].team1.code);\n\n\n }\n else\n {\n console.log(nothing);\n }\n\n }\n\n // team 2\n if (main.mynewData[i].team2.code === vm.teamcode && main.mynewData[i].team2.key === vm.teamkey)\n {\n\n vm.totalgoals2 = vm.totalgoals2 + main.myData[i].score2;\n if (main.mynewData[i].score1 < main.mynewData[i].score2)\n {\n vm.totalWins2.push(main.mynewData[i].team2.code);\n\n }\n else if (main.mynewData[i].score1 > main.mynewData[i].score2)\n {\n vm.totalLost2.push(main.mynewData[i].team1.code);\n\n\n }\n else if (main.mynewData[i].score1 == main.mynewData[i].score2)\n {\n\n vm.totaltie2.push(main.mynewData[i].team1.code);\n\n\n }\n else\n {\n console.log(nothing);\n }\n }\n\n }\n\n\n } // end for loop \n }", "title": "" }, { "docid": "0bfc2e635c0d285734c3d239dd97193c", "score": "0.52420974", "text": "function CheckTournamentRules() {\n\tvar state = level.arena.state;\n\n\t// Are there enough players for the match?\n\tvar enough = function () {\n\t\tif (level.arena.gametype >= GT.TEAM) {\n\t\t\tvar counts = new Array(TEAM.NUM_TEAMS);\n\t\t\tcounts[TEAM.BLUE] = TeamCount(TEAM.BLUE, ENTITYNUM_NONE);\n\t\t\tcounts[TEAM.RED] = TeamCount(TEAM.RED, ENTITYNUM_NONE);\n\n\t\t\tif (counts[TEAM.RED] < 1 || counts[TEAM.BLUE] < 1) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\tif (level.arena.numPlayingClients < 2) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t};\n\n\t//\n\tif (state.current === GS.WAITING) {\n\t\tif (!ScoreIsTied() && TimelimitHit()) {\n\t\t\tstate.end('Timelimit hit.');\n\t\t\treturn;\n\t\t}\n\n\t\t// Cycle spectators in tournament mode.\n\t\tif (level.arena.gametype === GT.TOURNAMENT) {\n\t\t\twhile (true) {\n\t\t\t\tif (enough()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Try to pull a client from the queue if we don't have enough.\n\t\t\t\tvar next = PopClientFromQueue();\n\t\t\t\tif (!next) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tSetTeam(next, 'f');\n\t\t\t}\n\t\t}\n\n\t\tif (enough()) {\n\t\t\t// Start countdown.\n\t\t\tstate.ready();\n\t\t}\n\t} else if (state.current === GS.COUNTDOWN) {\n\t\tif (!ScoreIsTied() && TimelimitHit()) {\n\t\t\tstate.end('Timelimit hit.');\n\t\t\treturn;\n\t\t}\n\n\t\t// If we don't have two players, go back to \"waiting for players\".\n\t\tif (!enough()) {\n\t\t\tstate.wait();\n\t\t\treturn;\n\t\t}\n\n\t\tif (level.time > level.arena.warmupTime) {\n\t\t\t// Start the match!\n\t\t\tstate.start();\n\t\t}\n\t} else if (state.current === GS.ACTIVE) {\n\t\tif (!ScoreIsTied() && TimelimitHit()) {\n\t\t\tstate.end('Timelimit hit.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (!enough()) {\n\t\t\t// Go back to waiting.\n\t\t\tstate.wait();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check for sudden death.\n\t\tif (ScoreIsTied()) {\n\t\t\t// Always wait for sudden death.\n\t\t\treturn;\n\t\t}\n\n\t\t// Check exit conditions.\n\t\tif (level.arena.gametype < GT.CTF && g_fraglimit.get()) {\n\t\t\tif (level.arena.teamScores[TEAM.RED] >= g_fraglimit.get()) {\n\t\t\t\tstate.end('Red hit the fraglimit.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (level.arena.teamScores[TEAM.BLUE] >= g_fraglimit.get()) {\n\t\t\t\tstate.end('Blue hit the fraglimit.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// See if a client has hit the frag limit (GT.FFA, GT.TOURNAMENT).\n\t\t\tfor (var i = 0; i < level.maxclients; i++) {\n\t\t\t\tvar client = level.clients[i];\n\n\t\t\t\tif (client.pers.connected !== CON.CONNECTED) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (client.sess.team !== TEAM.FREE) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (client.ps.persistant[PERS.SCORE] >= g_fraglimit.get()) {\n\t\t\t\t\tstate.end(client.pers.name + '^' + QS.COLOR.WHITE + 'hit the fraglimit.');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (level.arena.gametype >= GT.CTF && g_capturelimit.get()) {\n\t\t\tif (level.arena.teamScores[TEAM.RED] >= g_capturelimit.get()) {\n\t\t\t\tstate.end('Red hit the capturelimit.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (level.arena.teamScores[TEAM.BLUE] >= g_capturelimit.get()) {\n\t\t\t\tstate.end('Blue hit the capturelimit.');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t} else if (state.current === GS.OVER) {\n\t\tif (IntermissionStarted()) {\n\t\t\tstate.intermission();\n\t\t}\n\t} else if (state.current === GS.INTERMISSION) {\n\t\tif (CheckIntermissionExit()) {\n\t\t\tstate.restart();\n\t\t}\n\t}\n}", "title": "" }, { "docid": "c44eefec2eb2f65b5a6eea4179165822", "score": "0.52414006", "text": "function markWinner (winningArray) {\n for (const position of winningArray) {\n $playField.find(`[data-position='${position}']`).addClass('winning');\n }\n }", "title": "" }, { "docid": "5ef20c3fcf24fc17bda53aa3803fc2d8", "score": "0.5233463", "text": "function team_can_cover(mons, type) {\n for (let mon of mons) {\n if(can_cover(mon, type))\n return true\n }\n return false\n}", "title": "" }, { "docid": "b4d2c73c5aa75743301e629607f635ee", "score": "0.52330077", "text": "function madeteam(player) {\n return player.madeTeam === true;\n }", "title": "" } ]
2e9bfa3188fb09295659c28354485a35
Wait for the Quick View preview to load and display its content.
[ { "docid": "118e457aa59d18a8676a315503b86210", "score": "0.6045805", "text": "function checkPreviewTextLoaded(elements) {\n let haveElements = Array.isArray(elements) && elements.length === 1;\n if (haveElements) {\n haveElements = elements[0].styles.display.includes('block');\n }\n if (!haveElements || !elements[0].attributes.src) {\n return pending(caller, `Waiting for ${previewTag} to load.`);\n }\n return;\n }", "title": "" } ]
[ { "docid": "25021ba454f7f5fb141d91001931cf22", "score": "0.6666697", "text": "_enteredView() {\n this._ready.then(this._show.bind(this));\n }", "title": "" }, { "docid": "7381c9d2a9898009a10d4bfeb0e8b71c", "score": "0.6203576", "text": "function showContents() {\n\t$('#loading-placeholder').hide();\n\t$('#pageContents').show();\n}", "title": "" }, { "docid": "6d701b6bb7a042e0bb4b3f1bde233cdb", "score": "0.60812193", "text": "function checkPreviewHtmlLoaded(elements) {\n let haveElements = Array.isArray(elements) && elements.length === 1;\n if (haveElements) {\n haveElements = elements[0].styles.display.includes('block');\n }\n if (!haveElements || elements[0].attributes.loaded !== '') {\n return pending(caller, `Waiting for ${previewTag} to load.`);\n }\n return;\n }", "title": "" }, { "docid": "6d701b6bb7a042e0bb4b3f1bde233cdb", "score": "0.60812193", "text": "function checkPreviewHtmlLoaded(elements) {\n let haveElements = Array.isArray(elements) && elements.length === 1;\n if (haveElements) {\n haveElements = elements[0].styles.display.includes('block');\n }\n if (!haveElements || elements[0].attributes.loaded !== '') {\n return pending(caller, `Waiting for ${previewTag} to load.`);\n }\n return;\n }", "title": "" }, { "docid": "4304b9e1e16e6994e3e527ce3fa36e8f", "score": "0.60208786", "text": "async show() {\n // TODO: Seite anzeigen\n }", "title": "" }, { "docid": "d1ef7380af7ddf15ba961eea82e1795c", "score": "0.5969656", "text": "function pageLoad_fetchFeedOface(){\n CmdUtils.log(\"Starting \");\n ofaceObj.preview.call(ofaceObj);\n}", "title": "" }, { "docid": "542b4b7057619cc4d0460abf85c12d53", "score": "0.59511286", "text": "function runPreview() {\n\tgetIdVal();\n\tgetClsLocName(idVal);\n\tconvertLocName(clsLocName);\n\tupdatePreview();\n\t//test\n\ttestCode();\n}", "title": "" }, { "docid": "b203cea4a39c35d92e62ab02cca31136", "score": "0.5935493", "text": "function showPreviewButton() {\n previewButton.show();\n }", "title": "" }, { "docid": "d2787a8f3b0f81620dcbe07e154f9ae7", "score": "0.5910509", "text": "show() {\n this._loadPage('ask stories', API.showStories());\n }", "title": "" }, { "docid": "81900658fe9c12b3bec290f668c4d669", "score": "0.5894994", "text": "showPreview(delay) {\n\t\t\treturn this.togglePreview('show');\n\t\t}", "title": "" }, { "docid": "b8b0a57a291da7389175f51d0f11fec0", "score": "0.58926773", "text": "function showPage() {\n this._eventInput.on('route changed', function(name) {\n\n var view = this._pages[name]; // do we have that view\n\n var prev = this.getPage(); // get previous rendered view\n if (prev) {\n this._eventInput.unsubscribe(prev); // unsubscribe from its events\n prev.trigger('leave'); // inform that we are leaving to stop reactive stuffs\n }\n\n if (view) {\n this.content.show(view);\n this._currentPage = view;\n this._eventInput.subscribe(view); // subscribe main app for that views events\n\n // not very useful for now, simply checks\n // if it the first time that view renders\n if (!view.options.run) {\n view.trigger('ready');\n view.options.run = true;\n }\n\n // change header\n this.header.trigger('route changed', name)\n }\n\n }.bind(this));\n\n // is there any page waiting for data\n this._eventInput.on('load start', function() {\n this.content.show(this._pages['load']);\n }.bind(this));\n\n // after subscriptions ends, show actual view\n this._eventInput.on('load end', function() {\n this.content.show(this._currentPage);\n }.bind(this));\n}", "title": "" }, { "docid": "1cddca93d838657f7ba5c3e26737e5e8", "score": "0.5885695", "text": "function showPreview(){\n\tshowOverlay();\t\n}", "title": "" }, { "docid": "bb02adbd98ae28efe94a41de5baa1444", "score": "0.5848609", "text": "function previewLoading() {\n\t\tvar previewContent = $('#preview .wrap'),\n\t\t\tloader = $('#content .loading-wrap');\n\t\t\tTweenLite.set(previewContent, {opacity:0});\t\n\t\tTweenLite.to(loader, 0.25, {opacity: 0,display:'none',ease:Power1.easeInOut,delay:1.5});\n\t\tTweenLite.to(previewContent, 0.4, {opacity:1,ease:Power1.easeInOut,delay:1.5});\n\t}", "title": "" }, { "docid": "07629a5c590d5d02b072bfd11a0053ec", "score": "0.5842431", "text": "function prepareToShow() {}", "title": "" }, { "docid": "366cafd316f26913ea7225eb781713d2", "score": "0.58393896", "text": "waitFor_meetingExpertTips_1stContent() {\n if(!this.meetingExpertTips_1stContent.isVisible()){\n this.meetingExpertTips_1stContent.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "d114ceb77ad2e4aebc22f0a5c6733242", "score": "0.5829866", "text": "function showInitialContent() {\n sourcesParent.style.display = \"block\";\n contents[0].style.visibility = \"visible\";\n buttons[0].classList.add(\"js-active\");\n sources[0].style.display = \"inline\";\n images[0].style.visibility = \"visible\";\n }", "title": "" }, { "docid": "53e9f6653e6febf77bb3b6869f74c706", "score": "0.5817457", "text": "function loadViewDocumentPopup(){\n kony.print(\"loadViewDocumentPopup start----->>>> \"+htmlString);\n popupHTMLviewer.brwsWidget.evaluateJavaScript(\"showContent('\" + htmlString +\"');\");\n try{\n kony.timer.cancel(\"viewDocumentTimer\");\n }catch(err){\n kony.print(\"loadViewDocumentPopup error with timer cancellation::\"+err);\n }\n}", "title": "" }, { "docid": "24312e1345456b4bddc3231bdf87b89c", "score": "0.57930946", "text": "function waitLoad(){\n if (false&&!__.state.isViewLoaded()) {\n setTimeout(waitLoad,500);\n return;\n }\n next();\n __.INITIALIZED=true;\n delete __.INITIALIZING;\n console.log('__.inits._init_() completed');\n //$('body').css('opacity','1');\n $('body').addClass('fadein');\n 'onLoad'._bc&&'onLoad'._bc();\n }", "title": "" }, { "docid": "ce35eed40d106c9bbf808b2420ef2f58", "score": "0.5776567", "text": "static viewerReady(cb) {\n return PDFEvents._EVENTS['viewerReady'].on(cb);\n }", "title": "" }, { "docid": "8e43d97b2c110f6834fb1b59f26f1ac9", "score": "0.5772158", "text": "function preview_poll(){\r\n\tmypoll.display();\r\n}", "title": "" }, { "docid": "7cb6a3a418de1332ad20270e2ab4147f", "score": "0.5766448", "text": "async function peek(url) {\n\n // Google employs a redirect-url mechanism, \n // links on the page go to google.com/url?...url=xxx\n // For even lower latency we open the referred to page directly.\n var urlQueryParam = new URL(url).searchParams.get('url');\n if (urlQueryParam && urlQueryParam.match(/https?:\\/\\//)) {\n url = urlQueryParam;\n }\n\n var newTab = await browser.tabs.create({\n url: url,\n active: false\n });\n\n // Create the preview container on the CURRENT Page:\n browser.tabs.executeScript({\n code: `\n function close() {\n document.body.removeChild(container);\n }\n function abortTab() {\n browser.runtime.sendMessage({\n message: '${EVENT_CLOSE_NEWLY_OPENED_TAB}',\n tabId: ${newTab.id}\n });\n \n close();\n }\n\n function openTab() {\n browser.runtime.sendMessage({\n message: '${EVENT_SWITCH_TO_NEWLY_OPENED_TAB}',\n tabId: ${newTab.id}\n });\n \n close();\n }\n\n var existing = document.getElementById('peek-unit');\n existing && document.body.removeChild(existing);\n var container = document.createElement('div');\n container.id = 'peek-unit';\n container.style.position = 'fixed';\n container.style.zIndex = 1000;\n container.style.background = 'white';\n container.style.bottom = 0;\n container.style.right = 0;\n container.style.width = '60%';\n container.style.height = '70%';\n container.style.overflow = 'auto';\n container.style.boxShadow = '0 0 20px rgba(0,0,0,0.5)';\n container.addEventListener('click', e => {\n openTab()\n });\n\n var title = document.createElement('h1');\n title.style.fontSize = '14pt';\n title.style.padding = '10px';\n title.style.whiteSpace = 'nowrap';\n title.style.overflow = 'hidden';\n title.style.textOverflow = 'ellipsis';\n title.innerText = 'Loading..';\n container.append(title);\n\n document.body.append(container);\n document.body.addEventListener('keydown', e => {\n // ESCAPE or Q to abort the tab.\n if (e.which == 27 || e.which === 81) {\n abortTab();\n }\n });\n var closeListener = e => {\n close();\n document.body.removeEventListener('click', closeListener)\n };\n document.body.addEventListener('click', closeListener);\n\n // When peeking from a sidebar\n // we want the window that contains this popup \n // to gain focus so we can respond to keyboard signals.\n // window.focus() - does not work.\n\n `\n })\n\n // Clear the preview container, \n // but do keep the title element.\n var emptyContainer = () => {\n browser.tabs.executeScript({\n code: `\n var container = document.getElementById('peek-unit');\n\n container.innerHTML = '';\n\n var title = document.createElement('h1');\n title.style.fontSize = '14pt';\n title.style.padding = '10px';\n title.style.whiteSpace = 'nowrap';\n title.style.overflow = 'hidden';\n title.style.textOverflow = 'ellipsis';\n title.innerText = 'Loading..';\n container.append(title);\n `\n }); \n };\n\n // Add a screenshot to the preview container.\n var appendScreenshot = capturedData => {\n return browser.tabs.executeScript({\n code: `\n\n var container = document.getElementById('peek-unit');\n var img = document.createElement('img');\n img.src = \"${capturedData}\";\n img.style.width = '100%';\n img.style.border = 'none';\n img.style.padding = 0;\n img.style.margin = 0;\n img.style.float = 'left'; // fixes 1 px spacing\n\n container.append(img);\n `\n });\n }\n\n // Sets the preview container title.\n var setTitle = title => {\n return browser.tabs.executeScript({\n code: `\n\n var title = document.querySelector('#peek-unit h1');\n title.innerText = ${JSON.stringify(title)};\n `\n });\n }\n\n emptyContainer();\n\n setTitle(url);\n\n // In one peek the tab may load few urls\n // because of redirects, cookie walls, etc.\n // Whenever the a new page is loaded inside the\n // tab we need to capture its content again.\n\n var lastTabUrl = null;\n\n loadedListenerForTab[`${newTab.windowId}-${newTab.id}`] = async (data) => {\n\n emptyContainer();\n \n // console.log('inserting css');\n \n setTitle(data.url);\n\n await browser.tabs.insertCSS(newTab.id, {\n code: `\n body.zoom {\n -moz-transform: scale(1.5);\n -moz-transform-origin: 0 0;\n width:66%;\n }\n ` \n });\n\n // console.log('inserted css');\n\n await browser.tabs.executeScript(newTab.id, {\n code: `document.body.classList.add('zoom');`\n });\n \n // console.log(\"capturing screenshot\");\n\n // Above the FOLD capture:\n var capture = await browser.tabs.captureTab(newTab.id);\n\n appendScreenshot(capture);\n\n\n // Start to capture content below the fold.\n // but limit this to 10 iterations, because\n // we'll click on the preview if we deem it\n // interesting enough.\n\n \n var iterations = 0;\n while(true) { \n if (lastTabUrl && lastTabUrl !== data.url) {\n // abort, because the url was changed.\n return;\n }\n lastTabUrl = data.url;\n\n iterations++;\n \n // set scroll to bottom\n // console.log(\"Scrolling to bottom\");\n var [remainingPixelsOnPage] = await browser.tabs.executeScript(newTab.id, {\n code: `\n window.scrollTo(0, window.pageYOffset + window.innerHeight);\n \n var h = document.body.scrollHeight || document.body.clientHeight;\n \n var result = h - window.pageYOffset - window.innerHeight;\n /* return: */ result;\n `\n });\n \n // console.log('result', res);\n \n capture = await browser.tabs.captureTab(newTab.id);\n \n appendScreenshot(capture);\n \n if (iterations >= MAX_SCREENSHOTS) {\n console.log(`Bailing long page, ${iterations} screens should be enough to get the gist..`);\n break;\n }\n\n // Check if there is enough \n if (remainingPixelsOnPage < 100) {\n break;\n }\n }\n \n // Reset scroll to top.\n var res = await browser.tabs.executeScript(newTab.id, {\n code: `\n document.body.classList.remove('zoom');\n window.scrollTo(0, 0);\n `\n }); \n }\n}", "title": "" }, { "docid": "5b0a6b9535107594e0e14457db9fb359", "score": "0.5765709", "text": "waitFor_meetingOverview_TrackInformation() {\n if(!this.meetingOverview_TrackInformation.isVisible()){\n this.meetingOverview_TrackInformation.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "a4c89e2c33dacac790fa7c307454f846", "score": "0.57593066", "text": "function startQM_DocumentLoad() {\r\n\tdisplayLoadingScreen();\r\n\tregisterCollaborativeObjectTypes();\r\n\tloadQM_Document();\r\n\tloadShareDialog();\r\n}", "title": "" }, { "docid": "1c5dd35d89cd3b34821c02fa50b349fc", "score": "0.5736554", "text": "function openDisplayPreview(idx) {\n document.getElementById(\"displayPreview\").style.display = \"block\";\n document.getElementById(\"previewWindow\").src = document.getElementById(\"url_selected\"+idx).innerHTML;\n}", "title": "" }, { "docid": "9d2ee2306310ab17c913d8450ff2efdb", "score": "0.5731955", "text": "waitFor_raceReplayChannel_InterviewsTab() {\n if(!this.raceReplayChannel_InterviewsTab.isVisible()){\n this.raceReplayChannel_InterviewsTab.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "e128947ae74a0ced8d525fa77e2dfaae", "score": "0.5721772", "text": "function qvLoadSuccess(json_data) {\n var swatchesdesign1 = $('.tt-quickview-swatches-container-js').length && $('.tt-quickview-swatches-container-js').data('swatches-design1');\n var swatchesdesign2 = $('.tt-quickview-swatches-container-js').length && $('.tt-quickview-swatches-container-js').data('swatches-design2');\n var swatchesdesign3 = $('.tt-quickview-swatches-container-js').length && $('.tt-quickview-swatches-container-js').data('swatches-design3');\n var cur_opt = optionimages != null ? JSON.parse(optionimages) : '';\n var full_opt = cur_opt != '' ? $.extend(texture_obj, cur_opt) : texture_obj;\n var product_handle = json_data.handle;\n var show_unavailable_options = $('.show_unavailable_variants').length > 0;\n\n quickview_swatches = new SwatchesConstructor(json_data, {\n contentParent: '.tt-quickview-swatches-container-js',\n enableHistoryState: false,\n callback: quickViewVariant,\n externalImagesObject: full_opt,\n externalColors: colors_value,\n colorWithBorder: color_with_border,\n productHandle: product_handle,\n designOption1: swatchesdesign1,\n designOption2: swatchesdesign2,\n designOption3: swatchesdesign3,\n show_unavailable_options: show_unavailable_options\n });\n json_data = null;\n /* modal */\n _custom_loader.hide();\n modal_qv_content.fadeIn();//show content\n }", "title": "" }, { "docid": "00317e87b35be04bb74c80a51beda328", "score": "0.5710223", "text": "onLoadedPreview(event) {\n this.$emit('loaded', event);\n }", "title": "" }, { "docid": "2a2867c89dd86e179a01b2dba4df1237", "score": "0.569567", "text": "get Preview() {}", "title": "" }, { "docid": "9e43b7612df882b6562eb408dc1ca16a", "score": "0.5690344", "text": "function do_preview(site) {\n var msgs = document.getElementById('messages');\n if (msgs) {\n msgs.style.display = 'none';\n }\n\n var preview = document.getElementById('preview');\n var req = new XMLHttpRequest();\n req.onload = function() {\n if (this.status == 200) {\n preview = document.getElementById('preview');\n preview.innerHTML = this.responseText;\n preview.scrollIntoView({behavior: 'smooth', block: 'nearest'});\n } else {\n this.onerror();\n }\n };\n req.onerror = function() {\n preview.innerHTML =\n '<span title=\"Error\" class=\"glyphicon glyphicon-exclamation-sign\"></span> ' +\n this.responseText;\n preview.classList = 'row error';\n }\n\n preview.innerHTML = '<img src=\"/static/spinner.gif\" width=\"30\" />';\n params = new URLSearchParams(new FormData(document.getElementsByName('preview')[0]));\n req.open('post', '/publish/preview?' + params.toString());\n req.send();\n}", "title": "" }, { "docid": "c5df674f73d7cf623a0b4697fe5392d0", "score": "0.5689402", "text": "function checkPreviewPdfLoaded(elements) {\n let haveElements = Array.isArray(elements) && elements.length === 1;\n if (haveElements) {\n haveElements = elements[0].styles.display.includes('block');\n }\n if (!haveElements || !elements[0].attributes.src) {\n return pending(caller, `Waiting for ${previewTag} to load.`);\n }\n return;\n }", "title": "" }, { "docid": "c5df674f73d7cf623a0b4697fe5392d0", "score": "0.5689402", "text": "function checkPreviewPdfLoaded(elements) {\n let haveElements = Array.isArray(elements) && elements.length === 1;\n if (haveElements) {\n haveElements = elements[0].styles.display.includes('block');\n }\n if (!haveElements || !elements[0].attributes.src) {\n return pending(caller, `Waiting for ${previewTag} to load.`);\n }\n return;\n }", "title": "" }, { "docid": "c5df674f73d7cf623a0b4697fe5392d0", "score": "0.5689402", "text": "function checkPreviewPdfLoaded(elements) {\n let haveElements = Array.isArray(elements) && elements.length === 1;\n if (haveElements) {\n haveElements = elements[0].styles.display.includes('block');\n }\n if (!haveElements || !elements[0].attributes.src) {\n return pending(caller, `Waiting for ${previewTag} to load.`);\n }\n return;\n }", "title": "" }, { "docid": "8a9197a04cc2bb38c082da71fc45d6b0", "score": "0.5687234", "text": "waitForPageToLoad() {\n this.welcomePageUnderConstructTitle.waitForElementToRender();\n this.welcomePageTitle.waitForElementToRender();\n this.welcomePageCarousel.waitForElementToRender();\n }", "title": "" }, { "docid": "adf99023b82adcbbbb27cc7831111f5e", "score": "0.568066", "text": "function preview() {\n\t\t\t\n\t\t\t\tif (typeof options.previewHandler === 'function') {\n\t\t\t\t\tpreviewWindow = true;\n\t\t\t\t} else if (options.previewInElement) {\n\t\t\t\t\tpreviewWindow = $(options.previewInElement);\n\t\t\t\t} else if (!previewWindow || previewWindow.closed) {\n\t\t\t\t\n\t\t\t\t\tif (options.previewInWindow) {\n\t\t\t\t\t\tpreviewWindow = window.open('', 'preview', options.previewInWindow);\n\t\t\t\t\t\t$(window).unload(function() {\n\t\t\t\t\t\t\tpreviewWindow.close();\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tiFrame = $('<iframe class=\"markItUpPreviewFrame\"></iframe>');\n\t\t\t\t\t\tif (options.previewPosition == 'after') {\n\t\t\t\t\t\t\tiFrame.insertAfter(footer);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tiFrame.insertBefore(header);\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\tpreviewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t} else if (altKey === true) {\n\t\t\t\t\n\t\t\t\t\tif (iFrame) {\n\t\t\t\t\t\tiFrame.remove();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpreviewWindow.close();\n\t\t\t\t\t}\n\t\t\t\t\tpreviewWindow = iFrame = false;\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!options.previewAutoRefresh) {\n\t\t\t\t\trefreshPreview(); \n\t\t\t\t}\n\n\t\t\t\tif (options.previewInWindow) {\n\t\t\t\t\tpreviewWindow.focus();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}", "title": "" }, { "docid": "dc6dbc0638043db64481cb1ed8465965", "score": "0.5676736", "text": "async show() {\n // Anzuzeigenden Seiteninhalt nachladen\n let html = await fetch(\"page-menu-results/page-menu-results.html\");\n let css = await fetch(\"page-menu-results/page-menu-results.css\");\n\n if (html.ok && css.ok) {\n html = await html.text();\n css = await css.text();\n } else {\n console.error(\"Fehler beim Laden des HTML/CSS-Inhalts\");\n return;\n }\n\n // Seite zur Anzeige bringen\n this._pageDom = document.createElement(\"div\");\n this._pageDom.innerHTML = html;\n\n await this._renderReciepts(this._pageDom);\n\n this._app.setPageTitle(\"Startseite\", {isSubPage: true});\n this._app.setPageCss(css);\n this._app.setPageHeader(this._pageDom.querySelector(\"header\"));\n this._app.setPageContent(this._pageDom.querySelector(\"main\"));\n\n }", "title": "" }, { "docid": "7be7cd7a8036faa60c2c56f9999327a1", "score": "0.5675386", "text": "function showPreview(){\n\t$('#sbe-side-title, #sbe-side-content').show();\n\t$('.sbe-side-label, #sbe-title-edit, #sbe-content-edit, #sbe-img-edit, #sbe-category-edit, #sbe-active, #ip-open-btn').hide();\n}", "title": "" }, { "docid": "fea0c367061546c0b6ec11b9cb71bff3", "score": "0.56682205", "text": "function showPreparationEditor() {\n preparation_editor.updateAndShow();\n}", "title": "" }, { "docid": "bbc830041df87e58e8268b4a48155e9a", "score": "0.56569856", "text": "function onDocumentLoadSuccess(doc) {\n\n // A document contains references to 3D and 2D viewables.\n var viewables = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), { 'type': 'geometry' }, true);\n\n if (viewables.length === 0) {\n console.error('Document contains no viewables.');\n return;\n }\n\n // Choose any of the avialble viewables\n var initialViewable = viewables[0];\n var svfUrl = doc.getViewablePath(initialViewable);\n var modelOptions = {\n sharedPropertyDbPath: doc.getPropertyDbPath()\n };\n\n //var viewerDiv = document.getElementById('MyViewerDiv');\n var viewerDiv = document.getElementById(viewerDivId);\n viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv);\n viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);\n }", "title": "" }, { "docid": "1ae91c19d674f546682c20ea15d46f54", "score": "0.56365126", "text": "function show()\n{\n displayContent();\n}", "title": "" }, { "docid": "76b2c21fb249f22f3e434b9b2726db6d", "score": "0.5627564", "text": "function showPreviewImage() {\n previewImage.show();\n }", "title": "" }, { "docid": "c2875a0cc95a1c0d4f0df4c39c5e0867", "score": "0.56191194", "text": "async function getAndShowStoriesOnStart() {\n storyList = await StoryList.getStories();\n $storiesLoadingMsg.hide();\n\n putStoriesOnPage();\n}", "title": "" }, { "docid": "c7da311f4b300ba5f549390ab522451f", "score": "0.5607773", "text": "function addOnload() {\n userPageElement.onload = function () {\n var contextWindow = userPageElement.contentWindow;\n if (contextWindow.length < 1 && userPageElement.data != (urlArray[0] + \"//\" + urlArray[2] + \"/aiva-preview/\")) {\n userPageElement.data = urlArray[0] + \"//\" + urlArray[2] + \"/aiva-preview/\";\n }\n var previewScript = document.createElement(\"script\");\n previewScript.type = 'text/javascript';\n try {\n previewScript.appendChild(document.createTextNode(previewScriptCode));\n } catch(e) {\n previewScript.text = previewScriptCode;\n }\n previewElement.appendChild(previewScript);\n };\n }", "title": "" }, { "docid": "c7da311f4b300ba5f549390ab522451f", "score": "0.5607773", "text": "function addOnload() {\n userPageElement.onload = function () {\n var contextWindow = userPageElement.contentWindow;\n if (contextWindow.length < 1 && userPageElement.data != (urlArray[0] + \"//\" + urlArray[2] + \"/aiva-preview/\")) {\n userPageElement.data = urlArray[0] + \"//\" + urlArray[2] + \"/aiva-preview/\";\n }\n var previewScript = document.createElement(\"script\");\n previewScript.type = 'text/javascript';\n try {\n previewScript.appendChild(document.createTextNode(previewScriptCode));\n } catch(e) {\n previewScript.text = previewScriptCode;\n }\n previewElement.appendChild(previewScript);\n };\n }", "title": "" }, { "docid": "22a48a37350c8b938d39a5e0ebf057b6", "score": "0.5605045", "text": "function init(){\n setupResumeButtons();\n showContent(0);\n}", "title": "" }, { "docid": "4c6165c511994696fadbcae301d68e3a", "score": "0.5601262", "text": "function loadQAWeb()\r\n{\r\n initializeInitialView();\r\n initializejsPlumb();\r\n initializeQAWeb();\r\n initializeKineticJS($('#answer-reply-canvas').width(),$('#answer-reply-canvas').height());\r\n initializeDragScroll();\r\n initializeButtonFunctionality();\r\n initializeZoomFunctionality();\r\n qaweb.root.zoomResize(qaweb.root);\r\n setTimeout(function() {$(QAWEB_ID).scrollTop(offsety - ($(window).height()/2)+62);},150);\r\n setTimeout(function() {$(QAWEB_ID).scrollLeft(offsetx - ($(window).width()/2)+62);},150);\r\n}", "title": "" }, { "docid": "51c2aba1fe87c2eee116a4c1e4fc3dd0", "score": "0.5590785", "text": "show() {\n const self = this;\n const options = self.options;\n const element = self.element;\n\n if (options.inline || self.transitioning) {\n return self;\n }\n\n if (!self.ready) {\n self.build();\n }\n\n if ($.isFunction(options.show)) {\n $.addListener(element, 'show', options.show, true);\n }\n\n if ($.dispatchEvent(element, 'show') === false) {\n return self;\n }\n\n self.open();\n\n const viewer = self.viewer;\n\n $.removeClass(viewer, 'viewer-hide');\n $.addListener(element, 'shown', () => {\n self.view(self.target ? $.inArray(self.target, $.toArray(self.images)) : self.index);\n self.target = false;\n }, true);\n\n if (options.transition) {\n self.transitioning = true;\n $.addClass(viewer, 'viewer-transition');\n $.forceReflow(viewer);\n $.addListener(viewer, 'transitionend', $.proxy(self.shown, self), true);\n $.addClass(viewer, 'viewer-in');\n } else {\n $.addClass(viewer, 'viewer-in');\n self.shown();\n }\n\n return self;\n }", "title": "" }, { "docid": "f3acdd7ec0417fc9b7a2f393c5ffaa88", "score": "0.5561618", "text": "function showPage() {\n $('#loader').css('display', \"none\");\n $('#container-1').css('display', \"block\");\n $('.wait').css('display', \"none\");\n $('.ready').css('display', \"block\");\n\n //Draws the initial chart, when all queries have been cached.\n hmdaQuery();\n}", "title": "" }, { "docid": "333239cc1f5d319aa6db06bc099d5cc1", "score": "0.55495125", "text": "async function getAndShowStoriesOnStart () {\n\tconsole.debug('getAndShowStoriesOnStart');\n\tstoryList = await StoryList.getStories(); //located in models.js in the StoryList class\n\t$storiesLoadingMsg.remove(); //removes the loading message\n\tputStoriesOnPage(); //located below\n}", "title": "" }, { "docid": "4490953156fface13758ce8dee20db9a", "score": "0.5546105", "text": "function showPreview(a) {\n var previewBox = null;\n var preview = a.currentTarget.parentElement.getElementsByClassName(\"previewText\")[0].innerHTML;\n if (a.currentTarget.parentElement.parentElement.parentElement.parentElement == resourcesDivs[0]){\n previewBox = document.getElementById(\"javaPreview\");\n } else if (a.currentTarget.parentElement.parentElement.parentElement.parentElement == resourcesDivs[1]){\n previewBox = document.getElementById(\"htmlPreview\");\n } else if (a.currentTarget.parentElement.parentElement.parentElement.parentElement == resourcesDivs[2]){\n previewBox = document.getElementById(\"jsPreview\");\n }\n previewBox.innerHTML = preview;\n}", "title": "" }, { "docid": "38ae28c9fc6778627f7c46ef0cf0adc5", "score": "0.55330116", "text": "function showPreviews() {\n $('#previews-modal').modal('show');\n}", "title": "" }, { "docid": "007e17200b56b0c6ad94d788295c6654", "score": "0.5530594", "text": "function generatePreview(){\n prepareContent();\n var iframe = $(\"#preview\");\n iframe.attr('src', iframe.attr('src'));\n}", "title": "" }, { "docid": "248cbfc64d94a291b4084d4b587df573", "score": "0.55282396", "text": "function show(){\n\n\t//Add the actual view container\n\tAlloy.Globals.ActualContainer = $.viewSection2;\n\n\tTi.App.fireEvent('closeLoading');\n\n}", "title": "" }, { "docid": "c03b01df566804c93ded724961910bf8", "score": "0.552094", "text": "waitForPrizeTag() {\n if(!this.prizeTag.isVisible()){\n this.prizeTag.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "9d0626386681cbe13e6bfae90bcd2a52", "score": "0.5516518", "text": "async function getAndShowStoriesOnStart() {\n\tstoryList = await StoryList.getStories();\n\t$storiesLoadingMsg.remove();\n\n\tputStoriesOnPage();\n}", "title": "" }, { "docid": "b996ca583fdc12ec8177145cd3bff192", "score": "0.5514873", "text": "function loadScreen()\n\t{\n\t\treadQuickPlayLanguageFile(function ()\n\t\t{\n\t\t\tupdateUI();\n\t\t\tpushScreenCallback();\n\t\t}, readQuickPlayLanguageFileReadingFailed);\n\t}", "title": "" }, { "docid": "d35b0f07c9d8f33e2e8546bc8c509919", "score": "0.551359", "text": "function previewTheQuiz() {\n console.log(\"RAM: previewTheQuiz()\");\n if ( !isAnswerTypeSelected() ) {\n alert(\"You must first select a quiz type under the 'Quiz info' tab ... ignoring.\");\n window.parent.setupInfo();\n return;\n }\n\n if ( isInState(INIT) && getAnswerType() != EVAL_EXPR ) {\n alert(\"The quiz has not been properly set up...ignoring\");\n return;\n }\n\n // Save the workspace, depending on where the preview was entered\n if ( isInState(PROB) ) {\n saveProblemWorkspace();\n } else if ( isInState(SOLU) ) {\n saveSolutionWorkspace();\n }\n\n var qname = Blockly.Quizmaker.quiz.quizName;\n var builtins = Blockly.Quizmaker.quiz.built_ins;\n var components = Blockly.Quizmaker.quiz.components;\n\n // Generate the random values for variables for this Quiz instance\n Blockly.Quizmaker.quiz.VariableMappings = generateInstanceMappings(qname, Blockly.Quizmaker);\n\n // Set up the MAINDOCUMENT for previewing the quiz\n setView(PREV); \n\n customizeQuizmeLanguage(undefined, builtins, components); // undefined forces initialization\n\n // If this is a func_def problem, construct a function definition from the solutionWorkspace.\n\n if ( getAnswerType() == FUNC_DEF) {\n createFunctionDef(); \n }\n \n if ( getAnswerType() == PROC_DEF) {\n \t createProcedureDef();\n }\n\n // Set up the workspace\n setupPreviewWorkspace( getAnswerType() );\n}", "title": "" }, { "docid": "9246c48350dcd56433c601498e8b8392", "score": "0.55123454", "text": "async preview() {\n let [bufnr, cursor] = await this.nvim.eval('[bufnr(\"%\"),coc#util#cursor()]');\n let { nvim } = this;\n let diagnostics = this.getDiagnosticsAt(bufnr, cursor);\n if (diagnostics.length == 0) {\n nvim.command('pclose', true);\n workspace_1.default.showMessage(`Empty diagnostics`, 'warning');\n return;\n }\n let lines = [];\n for (let diagnostic of diagnostics) {\n let { source, code, severity, message } = diagnostic;\n let s = util_2.getSeverityName(severity)[0];\n lines.push(`[${source}${code ? ' ' + code : ''}] [${s}]`);\n lines.push(...message.split(/\\r?\\n/));\n lines.push('');\n }\n lines = lines.slice(0, -1);\n // let content = lines.join('\\n').trim()\n nvim.call('coc#util#preview_info', [lines, 'txt'], true);\n }", "title": "" }, { "docid": "df06b42fb3414a4f5783adfe925bf5a1", "score": "0.55071443", "text": "function show(){\n\n\t//Add the actual view container\n\tAlloy.Globals.ActualContainer = $.viewLines;\n\tAlloy.Globals.ActualSection = \"lines\";\n\t\n\tAlloy.Globals.Header.children[0].children[1].text = L('text_4');\n\t\n\tif (Ti.Platform.osname == \"android\"){\n\t\tpicker_dataOrigen.push(Titanium.UI.createPickerRow({title: L('text_23'), id: 0}));\n\t\tpicker_dataDestino.push(Titanium.UI.createPickerRow({title: L('text_24'), id: 0}));\n\t}\n\t\n\tAlloy.Collections.model__MetroStations.result.forEach(function (element, index, array) {\n\t\tpicker_dataOrigen.push(Titanium.UI.createPickerRow({title: element.title, id: element.id}));\n\t\tpicker_dataDestino.push(Titanium.UI.createPickerRow({title: element.title, id: element.id}));\n\t\t\n\t});\n\t\n\t$.viewHowArrivedTitle.addEventListener('click', handlerArrivedView);\n\n loadComboOrigen();\n loadComboDestino();\n \n\tTi.App.fireEvent('closeLoading');\n\t\n}", "title": "" }, { "docid": "65e8d5cc4e336e4b963d58e8f8e08486", "score": "0.55068105", "text": "function showLoad(){\n\t\t\tif(settings.loadElement != \"\"){\n\t\t\t\t$(settings.loadElement).show();\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "7c303dbfee4deef19aa94afe79e6fa24", "score": "0.5501113", "text": "waitFor_raceReplayChannel_DroneVisionTab() {\n if(!this.raceReplayChannel_DroneVisionTab.isVisible()){\n this.raceReplayChannel_DroneVisionTab.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "698b91dc6485445450fbc796d4c6e59e", "score": "0.54949516", "text": "function edgtfOnDocumentReady() {\n\t\tedgtfInitItemShowcase();\n\t}", "title": "" }, { "docid": "cface935eeaf7276202fd0c3c0dc99a0", "score": "0.5490333", "text": "function waitforQooxdoo() {\n if (window.qx.AppLoaded) {\n self.inlineIsle = globals.inlineIsle = new qx.ui.root.Inline(self.node, true, true).set({\n backgroundColor: 'transparent'\n });\n self.inlineIsle.setLayout(new qx.ui.layout.Canvas()); //QxPlayground's container will be resized to the inlineIsle's size if\n //added with globals.inlineIsle.add(self.container, { edge: 0});\n var d = self.callRemote('initQooxdoo', 'dummy');\n d.addCallback(startup);\n }\n else {\n self.callLater(dt, waitforQooxdoo);\n }\n }", "title": "" }, { "docid": "06a7ae4ce6041a3ed4c04205b13bb27e", "score": "0.5487248", "text": "function waitForShown(){\n\tvar allShown = true;\n\tfor ( var f = 0 ; f < linker.processWindow.currentcacheelt.fingerprints.length ; f++ ){\n\t\tif ( linker.processWindow.currentcacheelt.fingerprints[f].shown == false ){\n\t\t\tallShown = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif ( allShown ){\n\t\tcm.showRelations();\n\t\tlinker.highlighting.setColoring();\n\t\tcm.loadedFromDisk = false;\n\t}\n\telse {\n\t\tsetTimeout(waitForShown, 500);\n\t}\n}", "title": "" }, { "docid": "420563b303863542aab9e934d228f6a9", "score": "0.5485963", "text": "display() {\n if (this.sceneInited) {\n this.gameOrchestrator.orchestrate();\n\n // Picking objects\n this.gameOrchestrator.managePick(this.pickMode, this.pickResults);\n this.clearPickRegistration();\n\n // Displays scene\n this.render(this.camera);\n }\n }", "title": "" }, { "docid": "cb5a7f24fa7020c817f68abb603b841f", "score": "0.54838085", "text": "waitFor_meetingOverview_TrackImage() {\n if(!this.meetingOverview_TrackImage.isVisible()){\n this.meetingOverview_TrackImage.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "a6fc2bfa708630584e68650ec82e47b1", "score": "0.54809994", "text": "function show () {\n\t\t\n\t\tif ( _ready === true ) {\n\t\t\t\n\t\t\t// camera\n\t\t\t\n\t\t\t_Game.cameraControls.reset();\n\t\t\t_Game.cameraControls.enabled = true;\n\t\t\t_Game.cameraControls.controllable = true;\n\t\t\t\n\t\t\t// add world\n\t\t\t\n\t\t\tworld.show();\n\t\t\t\n\t\t\t// start player\n\t\t\t\n\t\t\t_Player.character.position.set( 35, 2200, 300 );\n\t\t\t\n\t\t\t_Player.show();\n\t\t\t\n\t\t\t_Player.enable();\n\t\t\t\n\t\t\t// signals\n\t\t\t\n\t\t\tshared.signals.onWindowResized.add( resize );\n\t\t\t\n\t\t\tshared.signals.onGameUpdated.add( update );\n\t\t\t\n\t\t}\n\t\telse {\n\t\t\t\n\t\t\twaitingToShow = true;\n\t\t\t\n\t\t}\n \n }", "title": "" }, { "docid": "a7520860aa6eb307598b567b3850f0b1", "score": "0.54776514", "text": "async display() {\n super.display();\n this.displayError();\n\n //\t\tif (!Controller.sessionOwner) {\n //\t\t\tlet loginButton = document.querySelector(\"header table.part1-table button.einloggen\");\n //\t\t\tloginButton.click();\n //\t\t\treturn;\n //\t\t}\n\n let articleElement = document.querySelector(\"main article\");\n while (articleElement.childElementCount > 0) articleElement.lastElementChild.remove();\n\n let sectionElement = document.querySelector(\"#rentArticle-template\").content.cloneNode(true).firstElementChild;\n articleElement.append(sectionElement);\n\n let buttonElements = sectionElement.querySelectorAll(\"section.rentArticle button\");\n\n //criteria query\n buttonElements[0].addEventListener(\"click\", event => {\n this.articlePosition = 0;\n this.displayArticles(0);\n });\n\n // query all\n buttonElements[1].addEventListener(\"click\", event => {\n this.articlePosition = 0;\n this.displayAllArticles(0);\n });\n\n // Backward-Paging\n // buttonElement[2].addEventListener(\"click\", event => this.displayAllArticles(-2 * PAGING_SIZE));\n buttonElements[1].click();\n }", "title": "" }, { "docid": "9933d78f414efc45cd86652e5450f642", "score": "0.5473253", "text": "function show() {\n\t\tinit();\n\t}", "title": "" }, { "docid": "df9585f7f9049d9f79ef66a3852dd4ca", "score": "0.5462533", "text": "displayBindOnLoad() {\n let self = this;\n $(document).ready(function () {\n self.getItems(API_PATH + '?page=1', '', 'min_price').then(function (data) {\n let temp = self.getProcessedData(data);\n $('.item-gallery').html(temp);\n self.paginate(data);\n self.displayOnClick();\n });\n })\n }", "title": "" }, { "docid": "9cea7c4aa20637933ad2f8cd1df30273", "score": "0.5454665", "text": "function webViewerLoad(evt) {\n PDFViewerApplication.initialize().then(function () {\n\twebViewerInitialized(\"\");\n });\n}", "title": "" }, { "docid": "24937b077c46c841988765c605b8bf56", "score": "0.5453181", "text": "function showpreview()\n {\n vm.training_titlepre = $('#TrainingTitle').val();\n vm.training_descpre = $scope.trainingckeditor;\n if (ifBlank(\"Title\", vm.training_titlepre) == false)\n return false;\n\n if (vm.training_descpre == \"\")\n {\n\n showError('Description Cannot be Empty');\n $timeout(function() {\n }, 1000);\n return false;\n }\n vm.trainingImgPre = vm.trainingimgsrc;\n console.log(vm.trainingImgPre);\n if (vm.trainingImgPre == \"\")\n {\n showError('Upload Image to show preview');\n $timeout(function() {\n }, 1000);\n return false;\n }\n\n\n $('#trainingPreview').modal({backdrop: 'static', keyboard: false});\n $('#trainingPreview').modal('show');\n\n\n\n\n\n }", "title": "" }, { "docid": "4a016bf7c68e94ab4b47813654ae8661", "score": "0.5451107", "text": "function wait() {\n if (r.pendingImages() === 0) {\n view.render(); // re-render with all images\n callback(null, extractCanvas(view));\n } else setTimeout(wait, 10);\n }", "title": "" }, { "docid": "9a51a725220c5faa3f907822043ef63d", "score": "0.54483163", "text": "function qjLoad() {\n var qj_local_content = localStorage.getItem(qj_local_key);\n $('#qj-master').html(qj_local_content);\n }", "title": "" }, { "docid": "9d8000993706f27347ef8b1fe5c33a13", "score": "0.54422325", "text": "function showPreview(contentType,id){\n\tconsole.log('ShowPreview function called');\n\t\n\tif(contentType == 'youtube'){\n\t\tgliiimAlias('.ytpreview').slideDown()\n\t\tdocument.getElementById('preview').innerHTML = \"<iframe id='ytplayer' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/\" + id + \"?autoplay=1' frameborder='0'/>\";\n\t\tgliiimAlias('html, body').animate({\n\t\t scrollTop: gliiimAlias(\"#ytplayer\").offset().top\n\t\t}, 2000);\n\t}\n\n}", "title": "" }, { "docid": "255f28cca7d9712d7cb3a1ea7595cc6b", "score": "0.5441983", "text": "function handleShow() {\n view._isShown = true;\n triggerDOMRefresh();\n }", "title": "" }, { "docid": "255f28cca7d9712d7cb3a1ea7595cc6b", "score": "0.5441983", "text": "function handleShow() {\n view._isShown = true;\n triggerDOMRefresh();\n }", "title": "" }, { "docid": "255f28cca7d9712d7cb3a1ea7595cc6b", "score": "0.5441983", "text": "function handleShow() {\n view._isShown = true;\n triggerDOMRefresh();\n }", "title": "" }, { "docid": "255f28cca7d9712d7cb3a1ea7595cc6b", "score": "0.5441983", "text": "function handleShow() {\n view._isShown = true;\n triggerDOMRefresh();\n }", "title": "" }, { "docid": "255f28cca7d9712d7cb3a1ea7595cc6b", "score": "0.5441983", "text": "function handleShow() {\n view._isShown = true;\n triggerDOMRefresh();\n }", "title": "" }, { "docid": "255f28cca7d9712d7cb3a1ea7595cc6b", "score": "0.5441983", "text": "function handleShow() {\n view._isShown = true;\n triggerDOMRefresh();\n }", "title": "" }, { "docid": "255f28cca7d9712d7cb3a1ea7595cc6b", "score": "0.5441983", "text": "function handleShow() {\n view._isShown = true;\n triggerDOMRefresh();\n }", "title": "" }, { "docid": "9df928ad0e39996b0b82ac1b4c11f44f", "score": "0.54343915", "text": "function showContent() {\n selectedIndex = this.getAttribute(\"selectionId\");\n playerLoad(selectedIndex);\n}", "title": "" }, { "docid": "dc5c2bf2a89ff222f845a02f870629bd", "score": "0.5431012", "text": "function loadSnippet() {\r\n setTimeout(function () {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//è legata a loadingData, hanno lo stesso tempo.\r\n \tdocument.getElementById(\"bottom\").setAttribute(\"style\", \"visibility: visible\");\r\n }, 2500);\r\n loadHTML();\r\n \r\n}", "title": "" }, { "docid": "7332b2e869a1e06633b7a1783fe61e1d", "score": "0.54294604", "text": "function initContent() {\n const msHide = document.querySelectorAll('.ms-hide');\n\n /**\n * Place the Yellow ribbon after the header.\n */\n $('#s4-workspace').prepend($('#DeltaPageStatusBar'));\n\n if (msHide.length > 0) {\n /**\n * Hide all right section web parts that are marked as \"hidden\".\n */\n if ($('.ms-hide').closest('.right-section')) {\n $('.right-section .ms-hide').parent().hide();\n }\n checkContentTypes();\n checkOrgChartZone();\n checkGatewayPage();\n }\n\n adjustArticleImageBlock();\n adjustWireStories();\n collapsibleList();\n customCheckboxes();\n howDoI();\n articleComments();\n startMyVMSNet();\n startUserControls();\n\n /**\n * Window Load Events.\n */\n window.addEventListener('load', () => {\n introText();\n wireStories();\n wireCatagory();\n updateMoreSearchText();\n });\n }", "title": "" }, { "docid": "6ad0090a14a233c16e53595f48ea7c39", "score": "0.5427244", "text": "getViewer() {\n if (this._viewer) {\n return Promise.resolve(this._viewer);\n }\n return new Promise((resolve, reject) => {\n let timeout;\n const returnOrWait = () => {\n // If our window has finished initializing...\n if (this._frame) {\n // If PDFjs has finished initializing...\n if (this._frame.contentWindow && this._frame.contentWindow['PDFViewerApplication']) {\n const viewer = this._frame.contentWindow['PDFViewerApplication'];\n resolve(viewer);\n return;\n }\n }\n // If any ifs fall through, try again in a few ms\n timeout = setTimeout(returnOrWait, 5);\n };\n returnOrWait();\n });\n }", "title": "" }, { "docid": "08696717c07700802e44b7794d366f01", "score": "0.54241174", "text": "waitForPlaceTag() {\n if(!this.placeTag.isVisible()){\n this.placeTag.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "74fae5c3e4541c2c6c609050a5431973", "score": "0.5423007", "text": "loadDemo() {\n\n\t\t\tconst nextDemo = this.demos.get(this.demo);\n\t\t\tconst currentDemo = this.currentDemo;\n\t\t\tconst renderer = this.renderer;\n\n\t\t\t// Update the URL.\n\t\t\twindow.location.hash = nextDemo.id;\n\n\t\t\tif(currentDemo !== null) {\n\n\t\t\t\tcurrentDemo.reset();\n\n\t\t\t}\n\n\t\t\t// Hide the menu.\n\t\t\tthis.menu.domElement.style.display = \"none\";\n\n\t\t\t// Update and dispatch the event.\n\t\t\tchange.previousDemo = currentDemo;\n\t\t\tchange.demo = nextDemo;\n\t\t\tthis.currentDemo = nextDemo;\n\t\t\tthis.dispatchEvent(change);\n\n\t\t\t// Clear the screen.\n\t\t\trenderer.clear();\n\n\t\t\tnextDemo.load().then(() => this.startDemo(nextDemo)).catch(console.error);\n\n\t\t}", "title": "" }, { "docid": "a41d079f2a49c666b96a8b9d53401573", "score": "0.54208726", "text": "async function getAndShowStoriesOnStart() {\n storyList = await StoryList.getStories();\n $storiesLoadingMsg.remove();\n\n putStoriesOnPage();\n}", "title": "" }, { "docid": "a41d079f2a49c666b96a8b9d53401573", "score": "0.54208726", "text": "async function getAndShowStoriesOnStart() {\n storyList = await StoryList.getStories();\n $storiesLoadingMsg.remove();\n\n putStoriesOnPage();\n}", "title": "" }, { "docid": "a41d079f2a49c666b96a8b9d53401573", "score": "0.54208726", "text": "async function getAndShowStoriesOnStart() {\n storyList = await StoryList.getStories();\n $storiesLoadingMsg.remove();\n\n putStoriesOnPage();\n}", "title": "" }, { "docid": "a41d079f2a49c666b96a8b9d53401573", "score": "0.54208726", "text": "async function getAndShowStoriesOnStart() {\n storyList = await StoryList.getStories();\n $storiesLoadingMsg.remove();\n\n putStoriesOnPage();\n}", "title": "" } ]
df4585f5f67b95821d4b2b68e68482c1
balance octree (cut empty leaves or go deeper if needed)
[ { "docid": "7a3587cd5a904eb338818f5892a2a505", "score": "0.7927973", "text": "balanceOctree() {\n ++__WEBPACK_IMPORTED_MODULE_3__math3d_OctreeCell__[\"a\" /* default */].FLAG;\n var leavesToUpdate = this._meshData._leavesToUpdate;\n var nbLeaves = leavesToUpdate.length;\n\n for (var i = 0; i < nbLeaves; ++i) {\n var leaf = leavesToUpdate[i];\n if (leaf._flag === __WEBPACK_IMPORTED_MODULE_3__math3d_OctreeCell__[\"a\" /* default */].FLAG)\n continue;\n\n if (leaf._iFaces.length === 0)\n leaf.pruneIfPossible();\n else if (leaf._iFaces.length > __WEBPACK_IMPORTED_MODULE_3__math3d_OctreeCell__[\"a\" /* default */].MAX_FACES && leaf._depth < __WEBPACK_IMPORTED_MODULE_3__math3d_OctreeCell__[\"a\" /* default */].MAX_DEPTH)\n leaf.build(this);\n\n leaf._flag = __WEBPACK_IMPORTED_MODULE_3__math3d_OctreeCell__[\"a\" /* default */].FLAG;\n }\n\n leavesToUpdate.length = 0;\n }", "title": "" } ]
[ { "docid": "7fa9c66b7714d1fd68fa890a283e0a96", "score": "0.65768325", "text": "function adjustTree(indexMapLeft,root){\n if(root.hasOwnProperty('children')){\n //console.log(root.data.name)\n var cL=root.children[0];\n var cR=root.children[1];\n //console.log(leavesL,leavesR)\n //console.log(bias0,bias1)\n\n var cross_result=optimizationFun_cross(cL,cR,indexMapLeft);\n if (cross_result<0){\n swapChildren(root);\n }\n else if(cross_result==0){\n if(optimizationFun_order(cL,cR,indexMapLeft)<0)\n swapChildren(root);\n }\n\n adjustTree(indexMapLeft,cL);\n adjustTree(indexMapLeft,cR);\n }\n }", "title": "" }, { "docid": "7fa9c66b7714d1fd68fa890a283e0a96", "score": "0.65768325", "text": "function adjustTree(indexMapLeft,root){\n if(root.hasOwnProperty('children')){\n //console.log(root.data.name)\n var cL=root.children[0];\n var cR=root.children[1];\n //console.log(leavesL,leavesR)\n //console.log(bias0,bias1)\n\n var cross_result=optimizationFun_cross(cL,cR,indexMapLeft);\n if (cross_result<0){\n swapChildren(root);\n }\n else if(cross_result==0){\n if(optimizationFun_order(cL,cR,indexMapLeft)<0)\n swapChildren(root);\n }\n\n adjustTree(indexMapLeft,cL);\n adjustTree(indexMapLeft,cR);\n }\n }", "title": "" }, { "docid": "5bba813aaf021973466f60cb529fd286", "score": "0.65332663", "text": "function balancedTree (root) {\n\n}", "title": "" }, { "docid": "e2d2dfce7fc51e7e770089c253707d70", "score": "0.65189844", "text": "balance(){\n\n function buildTree( arr ){\n if( arr.length === 1 ) return new Node( arr[0] );\n\n if( arr.length === 2 ){\n let newNode = new Node( arr[1] );\n newNode.left = arr[0];\n return newNode;\n }\n\n if( arr.length === 3 ){\n let newNode = new Node( arr[1] );\n newNode.left = arr[0];\n newNode.right = arr[2];\n return newNode;\n }\n\n let medianIndex = Math.ceil( arr.length / 2 ) - 1;\n\n let newNode = new Node( arr[medianIndex] );\n newNode.left = buildTree( arr.slice(0, medianIndex) );\n newNode.right = buildTree( arr.slice( medianIndex + 1 ) );\n return newNode;\n }\n if( this.root === null ) return true;\n if( this.root.left === null && this.root.right === null ) return true;\n\n let sorted = this.traverseDepthInOrder();\n\n this.root = buildTree( sorted );\n return this.validate();\n }", "title": "" }, { "docid": "865bd80fb5694b9e0b6b125976c978f9", "score": "0.6368019", "text": "update(node){ \n let leftHeight=node.left!==null?node.left.height:-1,rightHeight=node.right!==null?node.right.height:-1\n node.height=Math.max(leftHeight,rightHeight)+1\n node.bf=rightHeight-leftHeight\n node.SubTreeNodes=1+(node.left===null?0:node.left.SubTreeNodes )+(node.right===null?0:node.right.SubTreeNodes)\n }", "title": "" }, { "docid": "21524b8189a074956e15a53fefc6c7c2", "score": "0.63353354", "text": "calculateRoot(){\n let currentNumberOfChildrens = 0;\n this.nodes.forEach(node =>{\n if (!node.getId().includes(\"cut\") && currentNumberOfChildrens < node.getNeighbours().length){\n this.root = node;\n currentNumberOfChildrens = this.root.getNeighbours().length;\n }\n });\n }", "title": "" }, { "docid": "1ccbc4a7898af4be9fde0714ce903d86", "score": "0.62159884", "text": "balance(config = {}) {\n return this.children.length <= 8 /* Balance.BranchFactor */\n ? this\n : balanceRange(\n dist_NodeType.none,\n this.children,\n this.positions,\n 0,\n this.children.length,\n 0,\n this.length,\n (children, positions, length) =>\n new dist_Tree(\n this.type,\n children,\n positions,\n length,\n this.propValues\n ),\n config.makeTree ||\n ((children, positions, length) =>\n new dist_Tree(\n dist_NodeType.none,\n children,\n positions,\n length\n ))\n )\n }", "title": "" }, { "docid": "f2d9be918e40050d52afcbed85c21789", "score": "0.6179706", "text": "_deleteBlocks(node){\n let newNeighbours = [];\n node.setVisited();\n this.nodes.push(node);\n\n node.getNeighbours().forEach((children) => {\n if(children !== undefined && !children.getVisited()) {\n let secondNodeToInsert = children;\n if (!children.getId().includes(\"cut\")) {\n if (children.getSize() === 1) {\n if (children.getNeighbours().length === 1) {\n //leaf\n children.isBlack = true;\n children.children = []; // rimuovo il padre\n newNeighbours.push(children);\n }\n else {\n //ci sono due cutvertex, uno che è il padre ed uno il figlio, notare che il figlio contiene il pradre tra i vicini\n //quindi lo vado a rimuovere, però non so in che posizione sia\n secondNodeToInsert = this._removeAnElementFromAnArray(children.getNeighbours(),node)[0];// rimuovo il padre (node) dalla lista del figlio (children)\n secondNodeToInsert.children = this._removeAnElementFromAnArray(secondNodeToInsert.getNeighbours(), children); // rimuovo il padre (questa volta è children) dalla lista del suo figlio\n newNeighbours.push(secondNodeToInsert);\n }\n }\n else {//è un blocco non elementare, quindi gli rimuovo il padre\n children.children = this._removeAnElementFromAnArray(children.getNeighbours(), node); // se è una foglie ha solo il padre, se non è una foglie lui verrà tolto dai figli nelle iterazioni successive\n newNeighbours.push(children);\n }\n }\n this._removeAnElementFromAnArray(node.children,node);//mi rimuovo dai miei figli\n this.edges.push(new Edge(node,secondNodeToInsert));\n secondNodeToInsert.setVisitedValue(node.getVisitedValue());\n this._deleteBlocks(secondNodeToInsert);\n }\n });\n if (newNeighbours.length > 0) node.children = newNeighbours;\n }", "title": "" }, { "docid": "8188820bd21b85d1c238c7adf595888b", "score": "0.6129361", "text": "isTreeBalanced() {\n const current = this.root;\n\n if (!current) {\n return true;\n }\n return (\n this._isBalanced(current._left) &&\n this._isBalanced(current._right) &&\n Math.abs(\n this._getNodeHeight(current._left) - this._getNodeHeight(current._right)\n ) <= 1\n );\n }", "title": "" }, { "docid": "371b0e922a441a79a2c5d29077f7cbbc", "score": "0.60669714", "text": "keepHeightBalance(node, afterRemove) {\n let current = node;\n const traveledNodes = [];\n while (current !== null) {\n traveledNodes.push(current);\n current.height = this.getNodeHeight(current);\n if (!this.isNodeBalanced(current)) {\n const nodesToBeRestructured = afterRemove\n ? this.getNodesToRestructureAfterRemove(traveledNodes)\n : this.getNodesToRestructureAfterInsert(traveledNodes);\n this.restructure(nodesToBeRestructured);\n }\n current = current.parent;\n }\n }", "title": "" }, { "docid": "c99c4ad678324125bacee164463c29da", "score": "0.600759", "text": "function isBalanced(tree){\n if (!tree) {\n return 0\n }\n let leftCount = 1 + height(tree.left);\n let rightCount = 1 + height(tree.right);\n if (leftCount - rightCount > 1 || rightCount - leftCount > 1) {\n return false\n }\n return true;\n}", "title": "" }, { "docid": "353cc18339f1b122115d6a69900f448b", "score": "0.59843415", "text": "delete(root, data) {\n // STEP 1: PERFORM STANDARD BST DELETE \n if (root == null)\n return root;\n \n // If the data to be deleted is smaller than \n // the root's data, then it lies in left subtree \n if (data < root.data)\n root.left = this.delete(root.left, data);\n \n // If the data to be deleted is greater than the \n // root's data, then it lies in right subtree \n else if (data > root.data)\n root.right = this.delete(root.right, data);\n \n // if data is same as root's data, then this is the node \n // to be deleted \n else {\n \n // node with only one child or no child \n if ((root.left == null) || (root.right == null)) {\n let temp = null;\n if (temp == root.left)\n temp = root.right;\n else\n temp = root.left;\n \n // No child case \n if (temp == null) {\n temp = root;\n root = null;\n }\n else // One child case \n root = temp; // Copy the contents of \n // the non-empty child \n }\n else {\n \n // node with two children: Get the inorder \n // successor (smallest in the right subtree) \n let temp = this.getMinValueNode(root.right);\n \n // Copy the inorder successor's data to this node \n root.data = temp.data;\n \n // Delete the inorder successor \n root.right = this.delete(root.right, temp.data);\n }\n }\n \n // If the tree had only one node then return \n if (root == null)\n return root;\n \n // STEP 2: UPDATE HEIGHT OF THE CURRENT NODE \n root.height = this.max(this.height(root.left), this.height(root.right)) + 1;\n \n // STEP 3: GET THE BALANCE FACTOR OF THIS NODE (to check whether \n // this node became unbalanced) \n const balance = this.getBalance(root);\n \n // If this node becomes unbalanced, then there are 4 cases \n // Left Left Case \n if (balance > 1 && this.getBalance(root.left) >= 0)\n return this.rightRotate(root);\n \n // Left Right Case \n if (balance > 1 && this.getBalance(root.left) < 0) {\n root.left = this.leftRotate(root.left);\n return this.rightRotate(root);\n }\n \n // Right Right Case \n if (balance < -1 && this.getBalance(root.right) <= 0)\n return this.leftRotate(root);\n \n // Right Left Case \n if (balance < -1 && this.getBalance(root.right) > 0) {\n root.right = this.rightRotate(root.right);\n return this.leftRotate(root);\n }\n \n return root;\n }", "title": "" }, { "docid": "e414e6b400d530a5c24924c7de25e839", "score": "0.5937387", "text": "isBalanced() {\n\n const start = this.root;\n let bal = true;\n function _height(curr = start, h = 0) {\n if (!bal) return 0;\n if (!curr) return h;\n const h1 = _height(curr.left, h + 1);\n const h2 = _height(curr.right, h + 1);\n if (Math.abs(h1 - h2) > 1) bal = false;\n return Math.max(h1, h2);\n }\n\n _height();\n return bal;\n }", "title": "" }, { "docid": "b2f1ba7ab5aa1b1190106604a4288b30", "score": "0.5846353", "text": "balanceBinarySearchTree() {\r\n\t\tconst inOrderArr = this.Traversal(\"dfs\", \"in\", \"recur\");\r\n\t\tconst makeBST = (inOrderArr = []) => {\r\n\t\t\tif (!inOrderArr.length) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tconst midIdx = ~~(inOrderArr.length / 2);\r\n\t\t\tconst start = inOrderArr.slice(0, midIdx);\r\n\t\t\tconst end = inOrderArr.slice(midIdx + 1);\r\n\t\t\tconst node = new Node(inOrderArr[midIdx]);\r\n\t\t\tnode.left = makeBST(start);\r\n\t\t\tnode.right = makeBST(end);\r\n\t\t\treturn node;\r\n\t\t};\r\n\t\treturn makeBST(inOrderArr);\r\n\t}", "title": "" }, { "docid": "c58aa90d908a06fe044688a82fa924b9", "score": "0.58342415", "text": "function isBalanced(tree) {\n if (checkHeight(tree.root) === -1) {\n return false;\n }\n return true;\n }", "title": "" }, { "docid": "ab0b9ce59392ab7ff4b67d789632b863", "score": "0.5827299", "text": "_removeNode(node) {\n if (node.left === null && node.right === null) {\n this._replaceNodeInParent(node, null);\n } else if (node.right === null) {\n this._replaceNodeInParent(node, node.left);\n } else if (node.left === null) {\n this._replaceNodeInParent(node, node.right);\n } else {\n const balance = node.getBalance();\n let replacement;\n let temp = null;\n\n if (balance > 0) {\n if (node.left.right === null) {\n replacement = node.left;\n replacement.right = node.right;\n temp = replacement;\n } else {\n replacement = node.left.right;\n\n while (replacement.right !== null) {\n replacement = replacement.right;\n }\n\n if (replacement.parent) {\n replacement.parent.right = replacement.left;\n temp = replacement.parent;\n replacement.left = node.left;\n replacement.right = node.right;\n }\n }\n } else if (node.right.left === null) {\n replacement = node.right;\n replacement.left = node.left;\n temp = replacement;\n } else {\n replacement = node.right.left;\n\n while (replacement.left !== null) {\n replacement = replacement.left;\n }\n\n if (replacement.parent) {\n replacement.parent.left = replacement.right;\n temp = replacement.parent;\n replacement.left = node.left;\n replacement.right = node.right;\n }\n }\n\n if (node.parent !== null) {\n if (node.isLeftChild()) {\n node.parent.left = replacement;\n } else {\n node.parent.right = replacement;\n }\n } else {\n this._setRoot(replacement);\n }\n\n if (temp) {\n this._rebalance(temp);\n }\n }\n\n node.dispose();\n }", "title": "" }, { "docid": "23450d4b8824774e806df4070804931b", "score": "0.5825907", "text": "function AABBTree() {}", "title": "" }, { "docid": "b1886088285aa0f721359867a491d866", "score": "0.5737598", "text": "function UnBalancedBST() {\n var head = null;\n var numOfStepsForSearch = 0;\n\n this.displayNumOfStepsForSearch = function() {\n return numOfStepsForSearch;\n }\n\n this.getRoot = function() {\n return head;\n }\n\n /***************************************\n SEARCHING IN TREE\n ****************************************/\n\n // PRIVATE\n // O(n)\n function traverseSearch(number, node) {\n if (node == null) return null;\n numOfStepsForSearch++;\n\n if (number > node.data) {\n return traverseSearch(number, node.right);\n } else if (number < node.data ){\n return traverseSearch(number, node.left);\n } else if (number == node.data) {\n return node;\n }\n }\n\n // PUBLIC\n // returns you the node if found\n // null otherwise\n this.search = function(numberToFind) {\n numOfStepsForSearch = 0;\n\n if (head) {\n return traverseSearch(numberToFind, head);\n }\n }\n\n /***************************************\n INSERTING INTO THE TREE\n ****************************************/\n\n // PRIVATE\n function traverseInsertion(numberToInsert, node) {\n if (node == null) { return new treeNode(null, numberToInsert, null); }\n if (numberToInsert > node.data) {\n node.right = traverseInsertion(numberToInsert, node.right);\n return node;\n } else {\n node.left = traverseInsertion(numberToInsert, node.left);\n return node;\n }\n }\n\n // PUBLIC\n this.insert = function(number) {\n if (head == null) {\n head = new treeNode(null, number, null);\n } else {\n if (number > head.data) { head.right = traverseInsertion(number, head.right); }\n else { head.left = traverseInsertion(number, head.left); }\n }\n };\n\n /***************************************\n PRINTING THE TREE\n ****************************************/\n\n // PRIVATE\n function inOrderPrint(node) {\n if (node == null) return;\n inOrderPrint(node.left);\n if (head == node) {\n console.log(\"===============  HEAD  ==================\");\n }\n node.display();\n if (head == node) {\n console.log(\"=============================================\")\n }\n inOrderPrint(node.right);\n }\n\n // PRIVATE\n function preOrderPrint(node) {\n if (node == null) return;\n node.display();\n preOrderPrint(node.left);\n preOrderPrint(node.right);\n }\n\n // PRIVATE\n function postOrderPrint(node) {\n if (node == null) return;\n postOrderPrint(node.left);\n postOrderPrint(node.right);\n node.display();\n }\n\n // PUBLIC\n this.print = function(traversalType) {\n console.log(\" printing tree \");\n\n if (head) {\n console.log(\"Head is \" + head.data + \"..!\");\n switch (traversalType) {\n case TRAVERSAL.INORDER: inOrderPrint(head);\n break;\n case TRAVERSAL.PREORDER: preOrderPrint(head);\n break;\n case TRAVERSAL.POSTORDER: postOrderPrint(head);\n default:\n }\n } else {\n console.log(\"Tree is currently empty.\")\n }\n };\n\n\n /***************************************\n CREATING A BALANCED TREE\n ****************************************/\n\n // PRIVATE\n function inOrderToArray(node, array) {\n if (node == null) return;\n inOrderToArray(node.left, array);\n array.push(node.data);\n inOrderToArray(node.right, array);\n }\n\n // PUBLIC\n // Convert an inordered tree to a sorted array\n this.flattenInOrderToSortedArray = function() {\n var sortedArray = [];\n if (head) {\n inOrderToArray(head, sortedArray);\n }\n return sortedArray;\n }\n\n // PRIVATE\n // Build a balanced tree from the sorted array\n // where the left/right node takes on the mid of\n // the left/right sides of the array.\n function buildBalancedTree(array) {\n if (array.length == 0) { return null; }\n\n var mid = Math.floor((array.length)/2);\n var n = new treeNode(null, array[mid], null);\n\n var arrayOnLeft = array.slice(0, mid);\n n.left = buildBalancedTree(arrayOnLeft);\n\n var arrayOnRight= array.slice(mid+1);\n n.right = buildBalancedTree(arrayOnRight);\n\n return n;\n }\n\n // PUBLIC\n // convert the incoming array into a balanced tree\n this.sortedArrayToBalancedTree = function(array) {\n if (head) {\n return buildBalancedTree(array);\n }\n return null;\n };\n\n\n /***************************************\n BALANCENESS OF A TREE\n ***************************************/\n\n // PRIVATE\n // will send 'false' to callback for any unbalanceness\n function countBalance(node, balancedCallBack) {\n if (node == null) { return -1; }\n var leftCount = 1 + countBalance(node.left, balancedCallBack);\n var rightCount = 1 + countBalance(node.right, balancedCallBack);\n if (Math.abs(leftCount-rightCount) > 1) {\n balancedCallBack(false, node);\n }\n return (leftCount >= rightCount) ? leftCount : rightCount;\n }\n\n // PUBLIC\n // Checks to see if an unbalanceness exist in the tree\n this.checkForBalanceness = function(balancedTree) {\n var balancenessExist = true;\n countBalance(balancedTree, function(balanced = true, node) {\n if (balanced == false) {\n balancenessExist = balanced\n }\n });\n\n console.log(\"Does Balancess Exist? : \" + balancenessExist);\n }\n\n /***************************************\n REMOVING FROM THE TREE\n ***************************************/\n\n // PUBLIC\n // if we're removing the root, we take care of it here.\n // if we remove from anywhere else, we use traverseRemove\n this.remove = function(number) {\n console.log(\"Let's remove: \" + number);\n\n if (head) {\n if (head.data == number && rightChildOnly(head)) {\n var temp = head; head = head.right; temp.delete();\n return head;\n }\n else if (head.data == number && leftChildOnly(head)) {\n var temp = head; head = head.left; temp.delete();\n return head;\n }\n else if (head.data == number && noChildren(head)) {\n head.delete(); head = null;\n return head;\n }\n return this.traverseRemove(number, head);\n } else {\n console.log(\"Empty tree. Nothing to remove\");\n }\n };\n\n //PRIVATE\n // Finds the minimum of sub-tree and delete it\n function deleteMinimum(node, removeCallBack) {\n\n if (noChildren(node)) {\n removeCallBack(node);\n return null;\n }\n\n if (rightChildOnly(node)) {\n removeCallBack(node);\n return node.right;\n }\n\n if (node.left) {\n node.left = deleteMinimum(node.left, removeCallBack);\n return node;\n }\n }\n\n //PRIVATE UTILITY FOR CHECKING NODE'S CHILDREN EXISTENCE\n\n function noChildren(node) {\n return (node.left == null && node.right == null);\n }\n function leftChildOnly(node) {\n return (node.left != null && node.right == null);\n }\n function rightChildOnly(node) {\n return (node.left == null && node.right != null);\n }\n function bothChildExist(node) {\n return (node.left != null && node.right != null);\n }\n\n\n\n // PUBLIC\n //\n this.traverseRemove = function (number, node) {\n if (node == null) {\n console.log(\"You're at leaf end, null. Number \" + number + \" not found. :P )\");\n return null;\n }\n if (number > node.data) {\n node.right = this.traverseRemove(number, node.right);\n return node;\n } else if (number < node.data) {\n node.left = this.traverseRemove(number, node.left);\n return node;\n } else if (number == node.data) {\n if (noChildren(node)) {\n node.delete(); return null;\n }\n if (leftChildOnly(node)) {\n var leftNodeRef = node.left; node.delete(); return leftNodeRef;\n }\n if (rightChildOnly(node)) {\n var rightNodeRef = node.right; node.delete(); return rightNodeRef;\n }\n if (bothChildExist(node)) {\n var nodeToDelete;\n node.right = deleteMinimum(node.right, function(toRemove){\n node.data = toRemove.data;\n nodeToDelete = toRemove;\n });\n nodeToDelete.delete();\n return node;\n }\n } // FOUND\n } // traverseRemove function\n\n\n //The height of a binary tree is the number of edges between the tree's root\n // and its furthest leaf node. This means that a tree containing a single node has a height of 0.\n\n // inner function, cannot access parent scope's this\n function getHeight(node) {\n if (node == null) return 0;\n if (node.left == null && node.right == null) { return 0; }\n var leftCount, rightCount = 0; // at every node, we begin with 0\n\n // if the left exist, we count the edge\n if (node.left) { leftCount = getHeight(node.left) + 1; }\n\n // right right exist, we count the edge\n if (node.right) { rightCount = getHeight(node.right) + 1; }\n\n return (leftCount > rightCount) ? leftCount : rightCount;\n }\n\n // GET HEIGHT OF Tree\n this.height = function() {\n if (head) {\n return getHeight(head);\n }\n }\n}", "title": "" }, { "docid": "36ca156922ce93be0321e156909b5853", "score": "0.57049257", "text": "function cutTree(N, K, roads) {\n function createZeroArray(count) {\n let arr = [];\n for (let i = 0; i < count; i++)\n arr.push(0);\n\n return arr;\n }\n\n let edges = [];\n for (let i = 0; i < N; i++)\n edges.push([]);\n\n for (let e of roads) {\n let A = e[0] - 1, B = e[1] - 1;\n edges[A].push(B);\n edges[B].push(A);\n }\n\n let visited = []; // bool array\n for (let i = 0; i < N; i++)\n visited.push(false);\n\n let parent = createZeroArray(N), nchild = createZeroArray(N), childrenArr = [];\n for (let i = 0; i < N; i++)\n childrenArr.push([]);\n\n let queue = [], root = 0;\n parent[root] = -1;\n queue.push(root);\n while (queue.length > 0) {\n let a = queue.shift();\n if (visited[a] === true)\n continue;\n\n visited[a] = true;\n for (let b of edges[a]) {\n if (visited[b] === true)\n continue;\n\n parent[b] = a;\n nchild[a]++;\n childrenArr[a].push(b);\n queue.push(b);\n }\n }\n\n let vchild = createZeroArray(N), subnodes = [], zeros = [];\n for (let i = 0; i < N; i++)\n zeros.push(0n);\n\n for (let i = 0; i < N; i++)\n subnodes.push(zeros.slice());\n\n for (let i = 0; i < N; i++) {\n if (nchild[i] > 0)\n continue;\n\n subnodes[i][0] = 1n;\n for (let j = i; j >= 0; j = parent[j]) {\n var p = parent[j];\n if (p >= 0)\n vchild[p]++;\n\n if (nchild[j] > 0) {\n subnodes[j][0] = 1n;\n\n for (let c of childrenArr[j]) {\n for (let k = K; k >= 1; k--) {\n let combs = 0n;\n for (let l = 0; l < k; l++) {\n combs += subnodes[j][l] * subnodes[c][k - l];\n }\n combs += subnodes[j][k - 1];\n combs += subnodes[j][k];\n\n subnodes[j][k] = combs;\n }\n }\n }\n\n if (p < 0 || vchild[p] < nchild[p]) {\n break;\n }\n }\n }\n\n let total = 1n;\n for (let j = 0; j < N; j++) {\n let p = parent[j];\n for (let i = 0; i <= K; i++) {\n if (p < 0)\n total += subnodes[j][i];\n else if (i > 0)\n total += subnodes[j][i - 1];\n }\n }\n\n return total.toString();\n}", "title": "" }, { "docid": "e19069c37897078ec587b1c943e25877", "score": "0.5697217", "text": "_removeNode(node) {\n if (node.left === null && node.right === null) {\n this._replaceNodeInParent(node, null);\n }\n else if (node.right === null) {\n this._replaceNodeInParent(node, node.left);\n }\n else if (node.left === null) {\n this._replaceNodeInParent(node, node.right);\n }\n else {\n const balance = node.getBalance();\n let replacement;\n let temp = null;\n if (balance > 0) {\n if (node.left.right === null) {\n replacement = node.left;\n replacement.right = node.right;\n temp = replacement;\n }\n else {\n replacement = node.left.right;\n while (replacement.right !== null) {\n replacement = replacement.right;\n }\n if (replacement.parent) {\n replacement.parent.right = replacement.left;\n temp = replacement.parent;\n replacement.left = node.left;\n replacement.right = node.right;\n }\n }\n }\n else if (node.right.left === null) {\n replacement = node.right;\n replacement.left = node.left;\n temp = replacement;\n }\n else {\n replacement = node.right.left;\n while (replacement.left !== null) {\n replacement = replacement.left;\n }\n if (replacement.parent) {\n replacement.parent.left = replacement.right;\n temp = replacement.parent;\n replacement.left = node.left;\n replacement.right = node.right;\n }\n }\n if (node.parent !== null) {\n if (node.isLeftChild()) {\n node.parent.left = replacement;\n }\n else {\n node.parent.right = replacement;\n }\n }\n else {\n this._setRoot(replacement);\n }\n if (temp) {\n this._rebalance(temp);\n }\n }\n node.dispose();\n }", "title": "" }, { "docid": "e19069c37897078ec587b1c943e25877", "score": "0.5697217", "text": "_removeNode(node) {\n if (node.left === null && node.right === null) {\n this._replaceNodeInParent(node, null);\n }\n else if (node.right === null) {\n this._replaceNodeInParent(node, node.left);\n }\n else if (node.left === null) {\n this._replaceNodeInParent(node, node.right);\n }\n else {\n const balance = node.getBalance();\n let replacement;\n let temp = null;\n if (balance > 0) {\n if (node.left.right === null) {\n replacement = node.left;\n replacement.right = node.right;\n temp = replacement;\n }\n else {\n replacement = node.left.right;\n while (replacement.right !== null) {\n replacement = replacement.right;\n }\n if (replacement.parent) {\n replacement.parent.right = replacement.left;\n temp = replacement.parent;\n replacement.left = node.left;\n replacement.right = node.right;\n }\n }\n }\n else if (node.right.left === null) {\n replacement = node.right;\n replacement.left = node.left;\n temp = replacement;\n }\n else {\n replacement = node.right.left;\n while (replacement.left !== null) {\n replacement = replacement.left;\n }\n if (replacement.parent) {\n replacement.parent.left = replacement.right;\n temp = replacement.parent;\n replacement.left = node.left;\n replacement.right = node.right;\n }\n }\n if (node.parent !== null) {\n if (node.isLeftChild()) {\n node.parent.left = replacement;\n }\n else {\n node.parent.right = replacement;\n }\n }\n else {\n this._setRoot(replacement);\n }\n if (temp) {\n this._rebalance(temp);\n }\n }\n node.dispose();\n }", "title": "" }, { "docid": "07bd651bbc6d5bd4221523cfb4783542", "score": "0.56965816", "text": "isBalanced(node = this.root) {\n if (node == null) {\n return true; // or null\n }\n let leftHeight = this.findMaxHeight(node.left);\n let rightHeight = this.findMaxHeight(node.right);\n // let diff = Math.abs(leftHeight - rightHeight);\n\n if (\n Math.abs(leftHeight - rightHeight) <= 1 &&\n this.isBalanced(node.left) &&\n this.isBalanced(node.right)\n ) {\n return true;\n }\n return false;\n }", "title": "" }, { "docid": "b6154e66cc63a523cfa1072e4e58ed8d", "score": "0.5683458", "text": "function tightTree(t,g){function dfs(v){_.forEach(g.nodeEdges(v),function(e){var edgeV=e.v,w=v===edgeV?e.w:edgeV;if(!t.hasNode(w)&&!slack(g,e)){t.setNode(w,{});t.setEdge(v,w,{});dfs(w)}})}_.forEach(t.nodes(),dfs);return t.nodeCount()}", "title": "" }, { "docid": "b6154e66cc63a523cfa1072e4e58ed8d", "score": "0.5683458", "text": "function tightTree(t,g){function dfs(v){_.forEach(g.nodeEdges(v),function(e){var edgeV=e.v,w=v===edgeV?e.w:edgeV;if(!t.hasNode(w)&&!slack(g,e)){t.setNode(w,{});t.setEdge(v,w,{});dfs(w)}})}_.forEach(t.nodes(),dfs);return t.nodeCount()}", "title": "" }, { "docid": "b7eaf12669a1ccefe9ca5982f27cd5e7", "score": "0.5666602", "text": "function tightTree(t,g){function dfs(v){_.forEach(g.nodeEdges(v),function(e){var edgeV=e.v,w=v===edgeV?e.w:edgeV;if(!t.hasNode(w)&&!slack(g,e)){t.setNode(w,{});t.setEdge(v,w,{});dfs(w);}});}_.forEach(t.nodes(),dfs);return t.nodeCount()}", "title": "" }, { "docid": "8d799ff81ba32c0bb1a18655b3a4d9a3", "score": "0.56641316", "text": "function tree(){var separation=defaultSeparation$1,dx=1,dy=1,nodeSize=null;function tree(root){var t=treeRoot(root);\n// Compute the layout using Buchheim et al.’s algorithm.\nt.eachAfter(firstWalk),t.parent.m=-t.z;t.eachBefore(secondWalk);\n// If a fixed node size is specified, scale x and y.\nif(nodeSize)root.eachBefore(sizeNode);\n// If a fixed tree size is specified, scale x and y based on the extent.\n// Compute the left-most, right-most, and depth-most nodes for extents.\nelse{var left=root,right=root,bottom=root;root.eachBefore(function(node){if(node.x<left.x)left=node;if(node.x>right.x)right=node;if(node.depth>bottom.depth)bottom=node});var s=left===right?1:separation(left,right)/2,tx=s-left.x,kx=dx/(right.x+s+tx),ky=dy/(bottom.depth||1);root.eachBefore(function(node){node.x=(node.x+tx)*kx;node.y=node.depth*ky})}return root}\n// Computes a preliminary x-coordinate for v. Before that, FIRST WALK is\n// applied recursively to the children of v, as well as the function\n// APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the\n// node v is placed to the midpoint of its outermost children.\nfunction firstWalk(v){var children=v.children,siblings=v.parent.children,w=v.i?siblings[v.i-1]:null;if(children){executeShifts(v);var midpoint=(children[0].z+children[children.length-1].z)/2;if(w){v.z=w.z+separation(v._,w._);v.m=v.z-midpoint}else{v.z=midpoint}}else if(w){v.z=w.z+separation(v._,w._)}v.parent.A=apportion(v,w,v.parent.A||siblings[0])}\n// Computes all real x-coordinates by summing up the modifiers recursively.\nfunction secondWalk(v){v._.x=v.z+v.parent.m;v.m+=v.parent.m}\n// The core of the algorithm. Here, a new subtree is combined with the\n// previous subtrees. Threads are used to traverse the inside and outside\n// contours of the left and right subtree up to the highest common level. The\n// vertices used for the traversals are vi+, vi-, vo-, and vo+, where the\n// superscript o means outside and i means inside, the subscript - means left\n// subtree and + means right subtree. For summing up the modifiers along the\n// contour, we use respective variables si+, si-, so-, and so+. Whenever two\n// nodes of the inside contours conflict, we compute the left one of the\n// greatest uncommon ancestors using the function ANCESTOR and call MOVE\n// SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.\n// Finally, we add a new thread (if necessary).\nfunction apportion(v,w,ancestor){if(w){var vip=v,vop=v,vim=w,vom=vip.parent.children[0],sip=vip.m,sop=vop.m,sim=vim.m,som=vom.m,shift;while(vim=nextRight(vim),vip=nextLeft(vip),vim&&vip){vom=nextLeft(vom);vop=nextRight(vop);vop.a=v;shift=vim.z+sim-vip.z-sip+separation(vim._,vip._);if(shift>0){moveSubtree(nextAncestor(vim,v,ancestor),v,shift);sip+=shift;sop+=shift}sim+=vim.m;sip+=vip.m;som+=vom.m;sop+=vop.m}if(vim&&!nextRight(vop)){vop.t=vim;vop.m+=sim-sop}if(vip&&!nextLeft(vom)){vom.t=vip;vom.m+=sip-som;ancestor=v}}return ancestor}function sizeNode(node){node.x*=dx;node.y=node.depth*dy}tree.separation=function(x){return arguments.length?(separation=x,tree):separation};tree.size=function(x){return arguments.length?(nodeSize=false,dx=+x[0],dy=+x[1],tree):nodeSize?null:[dx,dy]};tree.nodeSize=function(x){return arguments.length?(nodeSize=true,dx=+x[0],dy=+x[1],tree):nodeSize?[dx,dy]:null};return tree}", "title": "" }, { "docid": "ff5f851a8821b8eb2d6f7232484bdbcb", "score": "0.5656039", "text": "function tree(trunks) {\n this.trunks = trunks;\n this.branches = trunks * 10;\n this.twigs = trunks * 100;\n this.leaves = trunks * 1000;\n\n this.chopTrunk = n => {\n this.trunks -= n;\n this.branches -= n * 10;\n this.twigs -= n * 100;\n this.leaves -= n * 1000;\n this.trunks >= 0 ? this.trunks : (this.trunks = 0);\n this.branches >= 0 ? this.branches : (this.branches = 0);\n this.twigs >= 0 ? this.twigs : (this.twigs = 0);\n this.leaves >= 0 ? this.leaves : (this.leaves = 0);\n };\n\n this.chopBranch = n => {\n this.branches -= n;\n this.twigs -= n * 10;\n this.leaves -= n * 100;\n\n this.branches >= 0 ? this.branches : (this.branches = 0);\n this.twigs >= 0 ? this.twigs : (this.twigs = 0);\n this.leaves >= 0 ? this.leaves : (this.leaves = 0);\n };\n this.chopTwig = n => {\n this.twigs -= n;\n this.leaves -= n * 10;\n this.twigs >= 0 ? this.twigs : (this.twigs = 0);\n this.leaves >= 0 ? this.leaves : (this.leaves = 0);\n };\n this.chopLeaf = n => {\n this.leaves -= n;\n this.leaves >= 0 ? this.leaves : (this.leaves = 0);\n };\n this.describe = () =>\n `This tree has ${this.trunks} trunks, ${this.branches} branches, ${\n this.twigs\n } twigs and ${this.leaves} leaves.`;\n}", "title": "" }, { "docid": "66606f79c87baac841f66f7e5ffc9aaa", "score": "0.564077", "text": "static of(nodes) {\n if (nodes.length == 1)\n return nodes[0];\n let i = 0, j = nodes.length, before = 0, after = 0;\n for (;;) {\n if (i == j) {\n if (before > after * 2) {\n let split = nodes[i - 1];\n if (split.break)\n nodes.splice(--i, 1, split.left, null, split.right);\n else\n nodes.splice(--i, 1, split.left, split.right);\n j += 1 + split.break;\n before -= split.size;\n }\n else if (after > before * 2) {\n let split = nodes[j];\n if (split.break)\n nodes.splice(j, 1, split.left, null, split.right);\n else\n nodes.splice(j, 1, split.left, split.right);\n j += 2 + split.break;\n after -= split.size;\n }\n else {\n break;\n }\n }\n else if (before < after) {\n let next = nodes[i++];\n if (next)\n before += next.size;\n }\n else {\n let next = nodes[--j];\n if (next)\n after += next.size;\n }\n }\n let brk = 0;\n if (nodes[i - 1] == null) {\n brk = 1;\n i--;\n }\n else if (nodes[i] == null) {\n brk = 1;\n j++;\n }\n return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));\n }", "title": "" }, { "docid": "758b3ca8f9b010130a59677ca13d0148", "score": "0.5635464", "text": "heightBalancedOptimized() {\r\n\t\tlet isBalanced = true;\r\n\t\tfunction _height(node) {\r\n\t\t\tif (!node) return 0;\r\n\r\n\t\t\tif (!balanced) {\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\r\n\t\t\tlet leftHeight = _height(node.left);\r\n\t\t\tlet rightHeight = _height(node.right);\r\n\t\t\tif (Math.abs(leftHeight - rightHeight) > 1) isBalanced = false;\r\n\t\t\treturn 1 + Math.max(leftHeight, rightHeight);\r\n\t\t}\r\n\t\t_height(this.root);\r\n\t\treturn isBalanced;\r\n\t}", "title": "" }, { "docid": "54647a09dfcfd467a5a4402a825a1e22", "score": "0.5627594", "text": "function balencedBST(tree) {\n\n\n let leftHeight = getHeight2(tree.left);\n// console.log('left height:', leftHeight);\n let rightHeight = getHeight2(tree.right);\n// console.log('right height:', rightHeight);\n\n let absVal = (Math.abs(leftHeight - rightHeight));\n\n// console.log('this is the ABSVAL of left and right:', absVal);\n\n if (absVal > 1) {\n return false;\n }\n return true;\n}", "title": "" }, { "docid": "8d10c06affe878715fbfd16c1a7b4178", "score": "0.56208813", "text": "static of(nodes) {\n if (nodes.length == 1) return nodes[0]\n let i = 0,\n j = nodes.length,\n before = 0,\n after = 0\n for (;;) {\n if (i == j) {\n if (before > after * 2) {\n let split = nodes[i - 1]\n if (split.break)\n nodes.splice(--i, 1, split.left, null, split.right)\n else nodes.splice(--i, 1, split.left, split.right)\n j += 1 + split.break\n before -= split.size\n } else if (after > before * 2) {\n let split = nodes[j]\n if (split.break) nodes.splice(j, 1, split.left, null, split.right)\n else nodes.splice(j, 1, split.left, split.right)\n j += 2 + split.break\n after -= split.size\n } else {\n break\n }\n } else if (before < after) {\n let next = nodes[i++]\n if (next) before += next.size\n } else {\n let next = nodes[--j]\n if (next) after += next.size\n }\n }\n let brk = 0\n if (nodes[i - 1] == null) {\n brk = 1\n i--\n } else if (nodes[i] == null) {\n brk = 1\n j++\n }\n return new HeightMapBranch(\n HeightMap.of(nodes.slice(0, i)),\n brk,\n HeightMap.of(nodes.slice(j))\n )\n }", "title": "" }, { "docid": "8f16085ce62940b30264d0a23b5cbc18", "score": "0.561615", "text": "isBalanced (root) {\n if(root === null) {\n return true;\n }\n let heightDifference = Math.abs(this.getHeight(root.left) - this.getHeight(root.right));\n if (heightDifference > 1) {\n return false;\n } else {\n return isBalanced(root.left) && isBalanced(root.right);\n }\n }", "title": "" }, { "docid": "8893bb4e296cafb3a9bc5e6137e891b2", "score": "0.5612895", "text": "pruneIfPossible() {\n var cell = this;\n while (cell._parent) {\n var parent = cell._parent;\n\n var children = parent._children;\n // means that the current cell has already pruned\n if (children.length === 0)\n return;\n\n // check if we can prune\n for (var i = 0; i < 8; ++i) {\n var child = children[i];\n if (child._iFaces.length > 0 || child._children.length === 8) {\n return;\n }\n }\n\n children.length = 0;\n cell = parent;\n }\n }", "title": "" }, { "docid": "b67cc325a6c5e678a9a0b014cb86ecbc", "score": "0.5606672", "text": "function deleteMin(bt,aux){\n if(bt){\n if(!bt.left){\n if(bt.isLeaf())\n aux.left = null;\n else{\n if(aux === undefined){ //Cuando es la raiz no me sale\n aux = bt.right;\n bt = aux;\n }\n else\n aux.left = bt.right;\n }\n }\n else\n deleteMin(bt.left,bt);\n }\n}", "title": "" }, { "docid": "7af9c7d6ddf7888f3675b82c94cb8f22", "score": "0.55967444", "text": "function forceBNtree() {\n bnBuildTree(); // Build BN tree based on current pos\n numChecks = 0;\n for (var i = 0; i < bods.N; i++) {\n // For each body\n doBNtree(i);\n }\n}", "title": "" }, { "docid": "c4ac3306f56232d7fd62f7a9bf667023", "score": "0.5579824", "text": "function pruneAndRecenter(min_prob) {\n\tvar path = [];\n\tvar current = global.stableTree.root;\n\tvar next;\n\n\twhile (true) {\n\n\t\t// keep track of current child branch we're searching\n\t\tif (current.child_index != undefined) {\n\t\t\tcurrent.child_index++;\n\t\t} else {\n\t\t\tcurrent.child_index = 0;\n\t\t}\n\n\t\t// recenter when first encountering a terminal node\n\t\tif (current.child_index == 0 && (current.probability > 0 || current.children.length == 0)) {\n\t\t\tcurrent.probability -= min_prob;\t// recenter probability\n\t\t}\n\n\t\t// get next child\n\t\tif (current.child_index < current.children.length) {\n\t\t\tnext = current.children[current.child_index];\n\t\t} else {\n\t\t\tnext = undefined;\n\t\t\tdelete current.child_index;\n\t\t}\n\n\t\tif (next) {\n\t\t\t// move to child\n\t\t\tpath.push(current);\n\t\t\tcurrent = next;\n\t\t} else if (path.length > 0) {\n\t\t\t// if dead leaf node\n\t\t\tif (current.probability <= 0 && current.children.length == 0) {\n\t\t\t\twhile (true) {\n\t\t\t\t\t// backtrack to last terminal node or last node with > 1 children\n\t\t\t\t\tcurrent = path.pop();\n\t\t\t\t\tif (current.probability != 0 || current.children.length > 1) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// remove child (and thus, dead branch)\n\t\t\t\tcurrent.children.splice(current.child_index, 1);\n\t\t\t\tcurrent.child_index--;\n\t\t\t} else {\n\t\t\t\t// if normal leaf node, backtrack\n\t\t\t\tcurrent = path.pop();\n\t\t\t}\n\t\t} else {\n\t\t\t// if no next child and path empty, break (back at root)\n\t\t\tbreak;\n\t\t}\n\t}\n\t// debug\n\tconsole.log(\"Finished pruning / recentering\");\n}", "title": "" }, { "docid": "b09429173be4d236dc4c0f2f782effa3", "score": "0.5569491", "text": "buildTree() {\n if (!this.drawnAnnotations.length && !this.annosToBeDrawnAsInsets.size) {\n // Remove all exlisting clusters\n this.areaClusterer.cleanUp(new KeySet());\n return;\n }\n\n // if (this.newAnno) this.tree.load(this.drawnAnnotations);\n\n this.createInsets();\n }", "title": "" }, { "docid": "0093d2f9a1645905868eb2547bc474df", "score": "0.5557001", "text": "prune() {\n this.currentNode.removeFromParent();\n this.previous();\n }", "title": "" }, { "docid": "06c40927119e081a8bb6b6a2a2ba5f8d", "score": "0.5537795", "text": "function computeTree(v) {\n var st = JSON.parse(JSON.stringify(basetree));\n buildAll(st, v, basedata);\n return st;\n }", "title": "" }, { "docid": "df6701c51122fe3e667b8bbe4da7c385", "score": "0.55310607", "text": "function splitNode( node, offset, count, centroidBoundingData = null, depth = 0 ) {\n\n\t\tif ( ! reachedMaxDepth && depth >= maxDepth ) {\n\n\t\t\treachedMaxDepth = true;\n\t\t\tif ( verbose ) {\n\n\t\t\t\tconsole.warn( `MeshBVH: Max depth of ${ maxDepth } reached when generating BVH. Consider increasing maxDepth.` );\n\t\t\t\tconsole.warn( geo );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// early out if we've met our capacity\n\t\tif ( count <= maxLeafTris || depth >= maxDepth ) {\n\n\t\t\ttriggerProgress( offset );\n\t\t\tnode.offset = offset;\n\t\t\tnode.count = count;\n\t\t\treturn node;\n\n\t\t}\n\n\t\t// Find where to split the volume\n\t\tconst split = getOptimalSplit( node.boundingData, centroidBoundingData, triangleBounds, offset, count, strategy );\n\t\tif ( split.axis === - 1 ) {\n\n\t\t\ttriggerProgress( offset );\n\t\t\tnode.offset = offset;\n\t\t\tnode.count = count;\n\t\t\treturn node;\n\n\t\t}\n\n\t\tconst splitOffset = partition( indexArray, triangleBounds, offset, count, split );\n\n\t\t// create the two new child nodes\n\t\tif ( splitOffset === offset || splitOffset === offset + count ) {\n\n\t\t\ttriggerProgress( offset );\n\t\t\tnode.offset = offset;\n\t\t\tnode.count = count;\n\n\t\t} else {\n\n\t\t\tnode.splitAxis = split.axis;\n\n\t\t\t// create the left child and compute its bounding box\n\t\t\tconst left = new MeshBVHNode();\n\t\t\tconst lstart = offset;\n\t\t\tconst lcount = splitOffset - offset;\n\t\t\tnode.left = left;\n\t\t\tleft.boundingData = new Float32Array( 6 );\n\n\t\t\tgetBounds( triangleBounds, lstart, lcount, left.boundingData, cacheCentroidBoundingData );\n\t\t\tsplitNode( left, lstart, lcount, cacheCentroidBoundingData, depth + 1 );\n\n\t\t\t// repeat for right\n\t\t\tconst right = new MeshBVHNode();\n\t\t\tconst rstart = splitOffset;\n\t\t\tconst rcount = count - lcount;\n\t\t\tnode.right = right;\n\t\t\tright.boundingData = new Float32Array( 6 );\n\n\t\t\tgetBounds( triangleBounds, rstart, rcount, right.boundingData, cacheCentroidBoundingData );\n\t\t\tsplitNode( right, rstart, rcount, cacheCentroidBoundingData, depth + 1 );\n\n\t\t}\n\n\t\treturn node;\n\n\t}", "title": "" }, { "docid": "c9730c5feef8fd45cc83e63dd623def2", "score": "0.5527161", "text": "function updateTree() {\n \n tree = d3.layout.tree()\n .separation(function(a, b) { \n return (a.parent == b.parent ? sep_sibling : sep_nonsibling); \n })\n .nodeSize([node_height, node_width]); // [height, width]\n // setting .nodeSize() means that tree.size() will be ignored.\n // using tree.size() sets the size of the whole tree, and the \n // content will automatically be squeezed inside this region.\n // tree.size() keeps the vis compact but for K > about 100, the nodes\n // typically start to overlap if the region is a single screen.\n // better to use nodeSize() to ensure good spacing between nodes, \n // even if the vis extends beyond 1 screen in width or height, requiring\n // the user to scroll to the right or down.\n \n // duration of transitions:\n var duration = d3.event && d3.event.altKey ? 5000 : 600;\n \n // Stash the incoming tree as the global variable old_tree:\n old_tree = current_tree;\n \n // Compute the new tree layout\n current_tree = computeTree(current_k);\n \n // add in the information for the root:\n current_tree.size = basedata[max_k + current_k - 1][\"1\"];\n if (print_weights) {\n current_tree.label = basedata[2*max_k + current_k - 1][\"1\"] + \" (\" + \n basedata[max_k + current_k - 1][\"1\"] + \")\";\n } else {\n current_tree.label = basedata[2*max_k + current_k - 1][\"1\"]\n }\n //debugger;\n \n // create the nodes and links objects:\n var nodes = tree.nodes(current_tree);\n var links = tree.links(nodes);\n \n // Shift everything down:\n var shift = 0;\n nodes.forEach(function(d) { \n if (d.x < shift) {\n shift = d.x;\n }\n });\n if (shift > -260) { shift = -260};\n \n nodes.forEach(function(d) {\n d.x = d.x - shift + node_height/2;\n });\n \n // stash the (x,y)-locations of the new nodes in an array:\n new_location = {};\n nodes.forEach(function(d) {\n new_location[d.name] = d;\n new_location[d.name].x = d.x;\n new_location[d.name].y = d.y;\n });\n \n // compute the locations of the old nodes:\n var old_nodes = tree.nodes(old_tree);\n \n // set an object to refer to the old nodes by name:\n var old_names = {};\n old_nodes.forEach(function(n) { old_names[n.name] = n;} );\n \n // manually set the old locations for all entering nodes:\n nodes.forEach( function(n) { \n var old_node = old_names[n.name];\n if (old_node != null) {\n n.x0 = old_node.x0;\n n.y0 = old_node.y0;\n }\n });\n \n // Update the nodes:\n var node = vis.selectAll(\"g.node\")\n .data(nodes, function(d) { return d.name; });\n \n // Enter any new nodes at the previous position of their \n // most recent ancestor in the old tree:\n var nodeEnter = node.enter().append(\"g\")\n .attr(\"class\", \"node\")\n .attr(\"transform\", function(d) {\n var ac = enterAncestor_xy(d);\n return \"translate(\" + ac[1] + \",\" + ac[0] + \")\"; \n });\n \n nodeEnter.append(\"rect\")\n .attr(\"height\", 1e-6)\n .attr(\"width\", 1e-6)\n .attr(\"x\", 0)\n .attr(\"y\", -node_height/2)\n .style(\"stroke\", function(d) {\n return (d.depth == 0 ? \"#ffffff\" : node_color[d.name]);\n })\n .style(\"fill\", function(d) {\n return (d.depth == 0 ? \"#ffffff\" : node_color[d.name]);\n })\n \n nodeEnter.append(\"text\")\n .attr(\"x\", function(d) {\n var adjust;\n if (d.size == 0 & d.depth != 0) {\n adjust = -3;\n } else {\n adjust = 0;\n }\n return adjust;\n })\n .attr(\"dy\", \".35em\")\n .attr(\"transform\", function(d) { return \"translate(0)\"; })\n .attr(\"text-anchor\", function(d) {\n var anchor;\n if (d.size == 0 & d.depth != 0) {\n anchor = \"end\";\n } else {\n anchor = \"start\";\n }\n return anchor;\n })\n .text(function(d) { return d.label; })\n .style(\"fill-opacity\", 1e-6);\n \n // get width of the text svg element that holds the root's label:\n // this relies on the root always being the 11th (index = 10)\n // text element on the page!\n root_text_width = d3.select(el).selectAll(\"text\")[0][12].getBBox().width;\n \n\n // Transition nodes to their new position.\n var nodeUpdate = node.transition()\n .duration(duration)\n .attr(\"transform\", function(d) { \n return \"translate(\" + d.y + \",\" + d.x + \")\"; \n });\n \n nodeUpdate.select(\"rect\")\n .attr(\"height\", node_height)\n .attr(\"width\", function(d) { \n return ((d.depth != 0 || current_k == 1) ? \n d.size/divisor[current_k - 1] : root_text_width); \n })\n .attr(\"x\", 0)\n .attr(\"y\", -node_height/2)\n .style(\"fill\", function(d) {\n return ((d.depth != 0 || current_k == 1) ? \n node_color[d.name] : \"#ffffff\")\n });\n \n nodeUpdate.select(\"text\")\n .attr(\"x\", function(d) {\n var adjust;\n if (d.size == 0 & d.depth != 0) {\n adjust = -3;\n } else {\n adjust = 0;\n }\n return adjust;\n })\n .attr(\"dy\", \".35em\")\n .attr(\"transform\", function(d) { return \"translate(0)\"; })\n .attr(\"text-anchor\", function(d) {\n var anchor;\n if (d.size == 0 & d.depth != 0) {\n anchor = \"end\";\n } else {\n anchor = \"start\";\n }\n return anchor;\n })\n .text(function(d) { return d.label; })\n .style(\"fill-opacity\", 1);\n \n // Transition exiting nodes to the new position of their most recent \n //ancestor in the new tree:\n var nodeExit = node.exit().transition()\n .duration(duration)\n .attr(\"transform\", function(d) { \n // this function calls the global variable new_locations\n var ac = exitAncestor_xy(d);\n return \"translate(\" + ac[1] + \",\" + ac[0] + \")\"; \n })\n .remove();\n \n nodeExit.select(\"rect\")\n .attr(\"height\", 1e-6)\n .attr(\"width\", 1e-6);\n \n nodeExit.select(\"text\")\n .style(\"fill-opacity\", 1e-6);\n \n // Update the links\n var link = vis.selectAll(\"path.link\")\n .data(tree.links(nodes), function(d) { return d.target.name; });\n \n // Enter any new links:\n link.enter().insert(\"path\", \"g\")\n .attr(\"class\", \"link\")\n .attr(\"d\", function(d) {\n var ac = enterAncestor_xy(d.target);\n var o = {x: ac[0], y: ac[1]};\n return diagonal({source: o, target: o});\n })\n .transition()\n .duration(duration)\n .attr(\"d\", diagonal);\n \n // Transition links to their new position.\n link.transition()\n .duration(duration)\n .attr(\"d\", diagonal);\n \n // Transition exiting links:\n link.exit().transition()\n .duration(duration)\n .attr(\"d\", function(d) {\n var ac = exitAncestor_xy(d.target);\n var o = {x: ac[0], y: ac[1]};\n return diagonal({source: o, target: o});\n })\n .remove();\n \n // Stash the old positions for transition.\n nodes.forEach(function(d) {\n d.x0 = d.x;\n d.y0 = d.y;\n });\n \n // print the value of the bar width in the legend:\n maxPrint.text(Math.round(Math.max(divisor[current_k - 1]*legend_width)));\n \n // get height of link from root to highest child\n // (might be used later to offset entropy profile plot)\n link_height = d3.select(el).select(\"path.link\")[0][0].getBBox().height;\n \n // scale entropy values:\n var entropyx = d3.scale.linear()\n .domain([1, max_k])\n .range([1, legend_width]);\n \n // From: http://stackoverflow.com/questions/4020796/\n // finding-the-max-value-of-an-attribute-in-an-array-of-objects\n var entropyy = d3.scale.linear()\n .domain([0, maxent])\n .range([legend_width, 0]);\n \n // http://stackoverflow.com/questions/25655372/d3-steady-horizontal-\n // transition-along-an-svg-path\n var lookup = [];\n var granularity = 1000;\n var l = lineGraph.node().getTotalLength();\n for(var i = 0; i <= granularity; i++) {\n var p = lineGraph.node().getPointAtLength(l * (i/granularity));\n lookup.push({\n x: p.x,\n y: p.y + 10\n })\n }\n \n // https://gist.github.com/mbostock/1313857\n // Returns an attrTween for translating along the specified path element.\n var xBisect = d3.bisector(function(d) { return d.x; }).left;\n \n function translateAlong(path, nw, old) {\n var l = path.getTotalLength();\n return function(d, i, a) {\n return function(t) {\n var scalar = (nw - old)/(max_k - 1);\n var start = (old - 1)/(max_k - 1);\n var index = xBisect(lookup, (t * scalar + start)*legend_width);\n var p = lookup[index];\n return \"translate(\" + p.x + \",\" + p.y + \")\";\n };\n };\n }\n \n // update the location of the point on the entropy profile plot:\n epcircle.transition()\n .duration(600)\n .attrTween(\"transform\", translateAlong(lineGraph.node(), current_k, old_k));\n \n // set the old_k to the current_k:\n old_k = current_k;\n \n \n var maxwidth = ( +d3.max(node.data(),function(d){return d.y}) + d3.max(node.select('text')[0].map(function(d){return d.getBoundingClientRect().width})) );\n var maxheight = ( +d3.max(node.data(),function(d){return d.x}) + 20 + 50 );\n \n // adjust viewBox to fit the bounds of our new tree\n d3.select(el).select(\"svg.svgplot\").transition().duration(1000)\n .attr(\n \"viewBox\",\n '0,-50,' + maxwidth + ',' + maxheight\n );\n \n d3.select(el).select(\".summarytree-zoomrect\")\n .attr(\"width\", maxwidth)\n .attr(\"height\", maxheight);\n \n \n }", "title": "" }, { "docid": "d33188c84eb19f9fdf3297867e64454d", "score": "0.5525715", "text": "static of(nodes) {\n if (nodes.length == 1)\n return nodes[0];\n let i = 0, j = nodes.length, before = 0, after = 0;\n for (;;) {\n if (i == j) {\n if (before > after * 2) {\n let split = nodes[i - 1];\n if (split.break)\n nodes.splice(--i, 1, split.left, null, split.right);\n else\n nodes.splice(--i, 1, split.left, split.right);\n j += 1 + split.break;\n before -= split.size;\n }\n else if (after > before * 2) {\n let split = nodes[j];\n if (split.break)\n nodes.splice(j, 1, split.left, null, split.right);\n else\n nodes.splice(j, 1, split.left, split.right);\n j += 2 + split.break;\n after -= split.size;\n }\n else {\n break;\n }\n }\n else if (before < after) {\n let next = nodes[i++];\n if (next)\n before += next.size;\n }\n else {\n let next = nodes[--j];\n if (next)\n after += next.size;\n }\n }\n let brk = 0;\n if (nodes[i - 1] == null) {\n brk = 1;\n i--;\n }\n else if (nodes[i] == null) {\n brk = 1;\n j++;\n }\n return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));\n }", "title": "" }, { "docid": "1b79607041c72f4b59d0534e47be40bc", "score": "0.5510034", "text": "function buildBalancedTree(array) {\n if (array.length == 0) { return null; }\n\n var mid = Math.floor((array.length)/2);\n var n = new treeNode(null, array[mid], null);\n\n var arrayOnLeft = array.slice(0, mid);\n n.left = buildBalancedTree(arrayOnLeft);\n\n var arrayOnRight= array.slice(mid+1);\n n.right = buildBalancedTree(arrayOnRight);\n\n return n;\n }", "title": "" }, { "docid": "0d51acebcc3c7e0a2afc30ec136ad779", "score": "0.5509808", "text": "function checkBalanced(root) {\n const checkHeight = (node) => {\n // recurse to the bottom returning -1 for null nodes\n if (!node) return -1\n\n // since we're going to check the height bottom up, post order so recursive calls before checking height\n const leftH = checkHeight(node.left),\n rightH = checkHeight(node.right)\n\n // if either one returns false pass false up\n if (leftH === false || rightH === false) return false\n\n // Otherwise, calc the height diff\n const heightDiff = Math.abs(leftH - rightH)\n\n //and pass up false if > 1\n if (heightDiff > 1) return false\n\n // otherwise pass the max height of the subtree + 1\n return Math.max(leftH, rightH) + 1\n }\n return checkHeight(root) === false ? false : true\n}", "title": "" }, { "docid": "a78ebaa617a5a523ea81ee88651b45b6", "score": "0.550019", "text": "function main3 () {\n const BST = new BinarySearchTree();\n\n BST.insert(4);\n BST.insert(2);\n BST.insert(6);\n BST.insert(1);\n BST.insert(3);\n BST.insert(5);\n BST.insert(7);\n\n console.log(balancedBST(BST));\n}", "title": "" }, { "docid": "0b1df3fa75be1bbac935d2be1187b3d8", "score": "0.5496088", "text": "getBalance(node) {\r\n if (node == null)\r\n return 0;\r\n\r\n return this.height(node.left) - this.height(node.right);\r\n }", "title": "" }, { "docid": "902ceb465cf46f18412794f89915315e", "score": "0.5480774", "text": "function trimDeadEndNodes(inputTree){\n\tvar treeCopy = copyTree(inputTree);\n\tfunction trimDeadEndInner(node){\n\t\tif(node.children && node.children.length){\n\t\t\tvar i = 0; //indexing variable\n\t\t\twhile(i<node.children.length){ //iterate over children\n\t\t\t\tvar child = node.children[i];\n\t\t\t\t//if child is a syntactic terminal that is not an x0, get rid of it\n\t\t\t\tif(!(child.children && child.children.length) && (child.cat != \"x0\" && child.cat != \"clitic\")){\n\t\t\t\t\tnode.children.splice(i, 1); //remove child from children array of node\n\t\t\t\t\tif(node.children.length === 0){/*if node doesn't have any children,\n\t\t\t\t\t\tnode.children shouldn't really be an array anymore */\n\t\t\t\t\t\tnode.children = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttrimDeadEndInner(child); //recursive function call\n\t\t\t\t \ti++; //iterate indexing variable, we only want to do this if node.children didn't change\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn node;\n\t}\n\treturn trimDeadEndInner(treeCopy);\n}", "title": "" }, { "docid": "74c4fad31ea9774c073b2ec5c81bba05", "score": "0.54771954", "text": "balanced(root=this.root) {\n\t\treturn this._checkHeight(root) != Number.MIN_SAFE_INTEGER;\n\t}", "title": "" }, { "docid": "002f1d64fc06b27d77001cfe8e5368d2", "score": "0.54694885", "text": "function __WEBPACK_DEFAULT_EXPORT__() {\n var separation = defaultSeparation,\n dx = 1,\n dy = 1,\n nodeSize = null;\n\n function tree(root) {\n var t = treeRoot(root);\n\n // Compute the layout using Buchheim et al.’s algorithm.\n t.eachAfter(firstWalk), t.parent.m = -t.z;\n t.eachBefore(secondWalk);\n\n // If a fixed node size is specified, scale x and y.\n if (nodeSize) root.eachBefore(sizeNode);\n\n // If a fixed tree size is specified, scale x and y based on the extent.\n // Compute the left-most, right-most, and depth-most nodes for extents.\n else {\n var left = root,\n right = root,\n bottom = root;\n root.eachBefore(function(node) {\n if (node.x < left.x) left = node;\n if (node.x > right.x) right = node;\n if (node.depth > bottom.depth) bottom = node;\n });\n var s = left === right ? 1 : separation(left, right) / 2,\n tx = s - left.x,\n kx = dx / (right.x + s + tx),\n ky = dy / (bottom.depth || 1);\n root.eachBefore(function(node) {\n node.x = (node.x + tx) * kx;\n node.y = node.depth * ky;\n });\n }\n\n return root;\n }\n\n // Computes a preliminary x-coordinate for v. Before that, FIRST WALK is\n // applied recursively to the children of v, as well as the function\n // APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the\n // node v is placed to the midpoint of its outermost children.\n function firstWalk(v) {\n var children = v.children,\n siblings = v.parent.children,\n w = v.i ? siblings[v.i - 1] : null;\n if (children) {\n executeShifts(v);\n var midpoint = (children[0].z + children[children.length - 1].z) / 2;\n if (w) {\n v.z = w.z + separation(v._, w._);\n v.m = v.z - midpoint;\n } else {\n v.z = midpoint;\n }\n } else if (w) {\n v.z = w.z + separation(v._, w._);\n }\n v.parent.A = apportion(v, w, v.parent.A || siblings[0]);\n }\n\n // Computes all real x-coordinates by summing up the modifiers recursively.\n function secondWalk(v) {\n v._.x = v.z + v.parent.m;\n v.m += v.parent.m;\n }\n\n // The core of the algorithm. Here, a new subtree is combined with the\n // previous subtrees. Threads are used to traverse the inside and outside\n // contours of the left and right subtree up to the highest common level. The\n // vertices used for the traversals are vi+, vi-, vo-, and vo+, where the\n // superscript o means outside and i means inside, the subscript - means left\n // subtree and + means right subtree. For summing up the modifiers along the\n // contour, we use respective variables si+, si-, so-, and so+. Whenever two\n // nodes of the inside contours conflict, we compute the left one of the\n // greatest uncommon ancestors using the function ANCESTOR and call MOVE\n // SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.\n // Finally, we add a new thread (if necessary).\n function apportion(v, w, ancestor) {\n if (w) {\n var vip = v,\n vop = v,\n vim = w,\n vom = vip.parent.children[0],\n sip = vip.m,\n sop = vop.m,\n sim = vim.m,\n som = vom.m,\n shift;\n while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {\n vom = nextLeft(vom);\n vop = nextRight(vop);\n vop.a = v;\n shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);\n if (shift > 0) {\n moveSubtree(nextAncestor(vim, v, ancestor), v, shift);\n sip += shift;\n sop += shift;\n }\n sim += vim.m;\n sip += vip.m;\n som += vom.m;\n sop += vop.m;\n }\n if (vim && !nextRight(vop)) {\n vop.t = vim;\n vop.m += sim - sop;\n }\n if (vip && !nextLeft(vom)) {\n vom.t = vip;\n vom.m += sip - som;\n ancestor = v;\n }\n }\n return ancestor;\n }\n\n function sizeNode(node) {\n node.x *= dx;\n node.y = node.depth * dy;\n }\n\n tree.separation = function(x) {\n return arguments.length ? (separation = x, tree) : separation;\n };\n\n tree.size = function(x) {\n return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);\n };\n\n tree.nodeSize = function(x) {\n return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);\n };\n\n return tree;\n}", "title": "" }, { "docid": "ee53c7fe42364611a15b778e58bc6479", "score": "0.5454673", "text": "function top2Optimization(){\n for (var i=0;i<5;i++){\n checkChange(1,0,function(){\n adjustTree(arrIndexMap[1],hierarchy_array[0])\n })\n checkChange(0,1,function(){\n adjustTree(arrIndexMap[0],hierarchy_array[1])\n })\n }\n }", "title": "" }, { "docid": "34610f81bc1f7899aa03af85a5d4a7bd", "score": "0.54494226", "text": "function isBalancedTree (node) {\n return balancedWeight(node) != -1;\n}", "title": "" }, { "docid": "bf423fa8890c0a0df552937b8553fbcc", "score": "0.54472804", "text": "function isBalanced(t) {\n let leftHeight = 0;\n let rightHeight = 0;\n\n if (t.left !== null) {\n leftHeight = height(t.left);\n if (t.left) {\n isBalanced(t.left);\n }\n }\n if (t.right !== null) {\n rightHeight = height(t.right);\n if (t.right) {\n isBalanced(t.right);\n }\n }\n let diff = Math.abs(leftHeight - rightHeight);\n\n return diff <= 1 ? true : false;\n}", "title": "" }, { "docid": "8b1056afd70786076971e8c9b26249be", "score": "0.54375356", "text": "function oc_update_fullbbox(node, child) {\n\t// entran: child.deltacorner, node.fullbbox\n\tvar x0 = 0, y0 = 0, x1 = node.fullbbox[0], y1 = node.fullbbox[1];\n\n\tif (child.deltacorner[0] < x0) x0 = child.deltacorner[0];\n\tif (child.deltacorner[0] + child.fullbbox[0] > x1) x1 = child.deltacorner[0] + child.fullbbox[0];\n\tif (child.deltacorner[1] + child.fullbbox[1] > y1) y1 = child.deltacorner[1] + child.fullbbox[1];\n\tif (x0 < node.deltacorner[0]) node.deltacorner[0] = x0;\n\n\tif (OC_DEBUG)\n\t\tconsole.log('updatefullbbox ' + node.title + ' <-- ' + child.title + ' x0=' + x0 + ' x1=' + x1 + ' y0=' + y0 + ' y1=' + y1);\n\n\tnode.fullbbox = [ x1 - x0, y1 - y0 ];\n}", "title": "" }, { "docid": "74ed02a059e43357918b26ce94114271", "score": "0.54370594", "text": "rebalancePath() {\n return;\n /* \n var x = this;\n while (x != null) {\n x.rebalance();\n x = x.parent;\n }\n */\n }", "title": "" }, { "docid": "5230e927ad8290b905a202669c9ae898", "score": "0.54145986", "text": "heightBalanced() {\r\n\t\tfunction _getHeight(node) {\r\n\t\t\tif (!node) return 0;\r\n\t\t\treturn 1 + Math.max(_getHeight(node.left), _getHeight(node.right));\r\n\t\t}\r\n\t\treturn (function _checkBalanced(node) {\r\n\t\t\tif (!node) return true;\r\n\t\t\tlet leftHeight = _getHeight(node.left);\r\n\t\t\tlet rightHeight = _getHeight(node.right);\r\n\t\t\tif (Math.abs(leftHeight - rightHeight) > 1) return false;\r\n\t\t\treturn _checkBalanced(node.left) && _checkBalanced(node.right);\r\n\t\t})(this.root);\r\n\t}", "title": "" }, { "docid": "3ddebc2990868dd0fcff9bf9fa27a247", "score": "0.5411847", "text": "isBinaryTreeBalanced (root) {\n if(typeof root === 'undefined') {\n return undefined;\n }\n return this.maxDepth(root) - this.minDepth(root) <= 1;\n }", "title": "" }, { "docid": "403787d231539d2944227397a40c7de1", "score": "0.5411695", "text": "rebalance(node){ //4 cases, 4 rotations\n if(node.bf==-2){\n if(node.left.bf<=0)\n return this.LL(node)\n else\n return this.LR(node)\n }\n else if(node.bf==2){\n if(node.right.bf>=0)\n return this.RR(node)\n else\n return this.RL(node)\n }\n return node\n }", "title": "" }, { "docid": "a636352f06909b580eab3732b0cd4b27", "score": "0.5410499", "text": "function isBalanced(root)\n{\n\t//base case. a tree with no nodes\n\tif (!root)\n\t{\n\t\treturn true;\n\t}\n\n\n\tlet depths = [];\n\tlet nodes = [];\n\n\tnodes.push([root, 0]);\n\n\twhile (nodes.length)\n\t{\n\t\t//pop node and its depth from the top of our stack\n\t\tlet nodePair = nodes.pop()\n\n\t\tlet node = nodePair[0];\n\t\tlet depth = nodePair[1];\n\n\t\t//case we found a node with no children ie: node leaf\n\t\tif (!node.left && !node.right)\n\t\t{\n\t\t\t//only keep if its a new depth\n\t\t\tif (depths.indexOf(depth) < 0)\n\t\t\t{\n\t\t\t\tdepths.push(depth);\n\t\t\t}\n\n\t\t\tif ((depths.length > 2) ||\n\t\t\t\t(depths.legnth === 2 && Math.abs(depths[0] - depths[1] > 1)))\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t//if this node has a child - keep going down \n\t\telse \n\t\t{\n\t\t\tif (node.left)\n\t\t\t{\n\t\t\t\tnodes.push([node.left, depth + 1]);\n\t\t\t}\n\t\t\tif (node.right)\n\t\t\t{\n\t\t\t\tnodes.push([node.right, depth + 1]);\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n\n}", "title": "" }, { "docid": "3e8710a958595e04498331cedf1558ca", "score": "0.5402432", "text": "depthFirstForEach(cb) {\n // cb(this.value);\n // if (this.left) {\n // this.left.depthFirstForEach(cb);\n // }\n // if (this.right) {\n // this.rigiht.depthFirstForEach(cb);\n // }\n const inOrder = (bst) => {\n cb.call(bst, bst.value);\n // if no left child,then go right\n if (bst.left !== null) {\n inOrder(bst.left);\n }\n\n if (bst.right !== null) {\n inOrder(bst.right);\n }\n };\n inOrder(this);\n }", "title": "" }, { "docid": "46519412dcad513304692d26ed7e0fc0", "score": "0.5401782", "text": "function tree() {\n var separation = defaultSeparation$1,\n dx = 1,\n dy = 1,\n nodeSize = null;\n\n function tree(root) {\n var t = treeRoot(root);\n\n // Compute the layout using Buchheim et al.’s algorithm.\n t.eachAfter(firstWalk), t.parent.m = -t.z;\n t.eachBefore(secondWalk);\n\n // If a fixed node size is specified, scale x and y.\n if (nodeSize) root.eachBefore(sizeNode);\n\n // If a fixed tree size is specified, scale x and y based on the extent.\n // Compute the left-most, right-most, and depth-most nodes for extents.\n else {\n var left = root,\n right = root,\n bottom = root;\n root.eachBefore(function(node) {\n if (node.x < left.x) left = node;\n if (node.x > right.x) right = node;\n if (node.depth > bottom.depth) bottom = node;\n });\n var s = left === right ? 1 : separation(left, right) / 2,\n tx = s - left.x,\n kx = dx / (right.x + s + tx),\n ky = dy / (bottom.depth || 1);\n root.eachBefore(function(node) {\n node.x = (node.x + tx) * kx;\n node.y = node.depth * ky;\n });\n }\n\n return root;\n }\n\n // Computes a preliminary x-coordinate for v. Before that, FIRST WALK is\n // applied recursively to the children of v, as well as the function\n // APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the\n // node v is placed to the midpoint of its outermost children.\n function firstWalk(v) {\n var children = v.children,\n siblings = v.parent.children,\n w = v.i ? siblings[v.i - 1] : null;\n if (children) {\n executeShifts(v);\n var midpoint = (children[0].z + children[children.length - 1].z) / 2;\n if (w) {\n v.z = w.z + separation(v._, w._);\n v.m = v.z - midpoint;\n } else {\n v.z = midpoint;\n }\n } else if (w) {\n v.z = w.z + separation(v._, w._);\n }\n v.parent.A = apportion(v, w, v.parent.A || siblings[0]);\n }\n\n // Computes all real x-coordinates by summing up the modifiers recursively.\n function secondWalk(v) {\n v._.x = v.z + v.parent.m;\n v.m += v.parent.m;\n }\n\n // The core of the algorithm. Here, a new subtree is combined with the\n // previous subtrees. Threads are used to traverse the inside and outside\n // contours of the left and right subtree up to the highest common level. The\n // vertices used for the traversals are vi+, vi-, vo-, and vo+, where the\n // superscript o means outside and i means inside, the subscript - means left\n // subtree and + means right subtree. For summing up the modifiers along the\n // contour, we use respective variables si+, si-, so-, and so+. Whenever two\n // nodes of the inside contours conflict, we compute the left one of the\n // greatest uncommon ancestors using the function ANCESTOR and call MOVE\n // SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.\n // Finally, we add a new thread (if necessary).\n function apportion(v, w, ancestor) {\n if (w) {\n var vip = v,\n vop = v,\n vim = w,\n vom = vip.parent.children[0],\n sip = vip.m,\n sop = vop.m,\n sim = vim.m,\n som = vom.m,\n shift;\n while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {\n vom = nextLeft(vom);\n vop = nextRight(vop);\n vop.a = v;\n shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);\n if (shift > 0) {\n moveSubtree(nextAncestor(vim, v, ancestor), v, shift);\n sip += shift;\n sop += shift;\n }\n sim += vim.m;\n sip += vip.m;\n som += vom.m;\n sop += vop.m;\n }\n if (vim && !nextRight(vop)) {\n vop.t = vim;\n vop.m += sim - sop;\n }\n if (vip && !nextLeft(vom)) {\n vom.t = vip;\n vom.m += sip - som;\n ancestor = v;\n }\n }\n return ancestor;\n }\n\n function sizeNode(node) {\n node.x *= dx;\n node.y = node.depth * dy;\n }\n\n tree.separation = function(x) {\n return arguments.length ? (separation = x, tree) : separation;\n };\n\n tree.size = function(x) {\n return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);\n };\n\n tree.nodeSize = function(x) {\n return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);\n };\n\n return tree;\n}", "title": "" }, { "docid": "bcd367ec1de2a769d773f0ac13720bd4", "score": "0.54014546", "text": "function isBalanced(tree) {\n if (!tree || !tree.root) {\n return true;\n }\n\n let node = tree.root,\n cache = {\n min: Number.MAX_SAFE_INTEGER,\n max: Number.MIN_SAFE_INTEGER\n };\n\n findDepth(cache, node, 0);\n return cache.max - cache.min <= 1;\n}", "title": "" }, { "docid": "3fc20b6be0766e516c3640da49463d81", "score": "0.5401066", "text": "function draw(){\n\tfill(139,69,19);\n\tstroke(139,69,19);\n\ttreeOne.grow();\n\n\tif(treeOne.treeGrown){\n\t\ttreeTwo.grow();\n\t\ttreeThree.grow();\n\t}\n}", "title": "" }, { "docid": "804e07984e8728ce9ba8ea2de510dd01", "score": "0.53926486", "text": "cut(at) {\n if (at >= this.length)\n return this;\n let children = [], positions = [];\n for (let i = 0; i < this.children.length; i++) {\n let from = this.positions[i];\n if (from >= at)\n break;\n let child = this.children[i], to = from + child.length;\n children.push(to <= at ? child : child.cut(at - from));\n positions.push(from);\n }\n return new Tree(this.type, children, positions, at);\n }", "title": "" }, { "docid": "28a3fd21b8354b062395327b2c8aaf18", "score": "0.53859013", "text": "balance(maxBufferLength = DefaultBufferLength) {\n return this.children.length <= BalanceBranchFactor ? this\n : balanceRange(this.type, NodeType.none, this.children, this.positions, 0, this.children.length, 0, maxBufferLength, this.length);\n }", "title": "" }, { "docid": "a4287e63715c8cba067207eade3bcb0a", "score": "0.53852296", "text": "function OctreeBlock(minPoint,maxPoint,capacity,depth,maxDepth,creationFunc){/**\n * Gets the content of the current block\n */this.entries=new Array();this._boundingVectors=new Array();this._capacity=capacity;this._depth=depth;this._maxDepth=maxDepth;this._creationFunc=creationFunc;this._minPoint=minPoint;this._maxPoint=maxPoint;this._boundingVectors.push(minPoint.clone());this._boundingVectors.push(maxPoint.clone());this._boundingVectors.push(minPoint.clone());this._boundingVectors[2].x=maxPoint.x;this._boundingVectors.push(minPoint.clone());this._boundingVectors[3].y=maxPoint.y;this._boundingVectors.push(minPoint.clone());this._boundingVectors[4].z=maxPoint.z;this._boundingVectors.push(maxPoint.clone());this._boundingVectors[5].z=minPoint.z;this._boundingVectors.push(maxPoint.clone());this._boundingVectors[6].x=minPoint.x;this._boundingVectors.push(maxPoint.clone());this._boundingVectors[7].y=minPoint.y;}", "title": "" }, { "docid": "a060e2465b6a8ad42dea8208d64510c6", "score": "0.53842187", "text": "splitNodes(editor) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Editor.withoutNormalizing(editor, () => {\n var {\n mode = 'lowest',\n voids = false\n } = options;\n var {\n match,\n at = editor.selection,\n height = 0,\n always = false\n } = options;\n\n if (match == null) {\n match = n => Editor.isBlock(editor, n);\n }\n\n if (Range.isRange(at)) {\n at = deleteRange(editor, at);\n } // If the target is a path, the default height-skipping and position\n // counters need to account for us potentially splitting at a non-leaf.\n\n\n if (Path.isPath(at)) {\n var path = at;\n var point = Editor.point(editor, path);\n var [parent] = Editor.parent(editor, path);\n\n match = n => n === parent;\n\n height = point.path.length - path.length + 1;\n at = point;\n always = true;\n }\n\n if (!at) {\n return;\n }\n\n var beforeRef = Editor.pointRef(editor, at, {\n affinity: 'backward'\n });\n var [highest] = Editor.nodes(editor, {\n at,\n match,\n mode,\n voids\n });\n\n if (!highest) {\n return;\n }\n\n var voidMatch = Editor.void(editor, {\n at,\n mode: 'highest'\n });\n var nudge = 0;\n\n if (!voids && voidMatch) {\n var [voidNode, voidPath] = voidMatch;\n\n if (Element.isElement(voidNode) && editor.isInline(voidNode)) {\n var after = Editor.after(editor, voidPath);\n\n if (!after) {\n var text = {\n text: ''\n };\n var afterPath = Path.next(voidPath);\n Transforms.insertNodes(editor, text, {\n at: afterPath,\n voids\n });\n after = Editor.point(editor, afterPath);\n }\n\n at = after;\n always = true;\n }\n\n var siblingHeight = at.path.length - voidPath.length;\n height = siblingHeight + 1;\n always = true;\n }\n\n var afterRef = Editor.pointRef(editor, at);\n var depth = at.path.length - height;\n var [, highestPath] = highest;\n var lowestPath = at.path.slice(0, depth);\n var position = height === 0 ? at.offset : at.path[depth] + nudge;\n\n for (var [node, _path2] of Editor.levels(editor, {\n at: lowestPath,\n reverse: true,\n voids\n })) {\n var split = false;\n\n if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Editor.isVoid(editor, node)) {\n break;\n }\n\n var _point = beforeRef.current;\n var isEnd = Editor.isEnd(editor, _point, _path2);\n\n if (always || !beforeRef || !Editor.isEdge(editor, _point, _path2)) {\n split = true;\n\n var properties = _objectWithoutProperties(node, [\"text\", \"children\"]);\n\n editor.apply({\n type: 'split_node',\n path: _path2,\n position,\n properties\n });\n }\n\n position = _path2[_path2.length - 1] + (split || isEnd ? 1 : 0);\n }\n\n if (options.at == null) {\n var _point2 = afterRef.current || Editor.end(editor, []);\n\n Transforms.select(editor, _point2);\n }\n\n beforeRef.unref();\n afterRef.unref();\n });\n }", "title": "" }, { "docid": "f56bf292b2f0eb416b8073731c43c286", "score": "0.5373004", "text": "function trimTrees (pearAmount, oakAmount) {\n PearTree.trim(pearAmount);\n OakTree.trim(oakAmount);\n}", "title": "" }, { "docid": "4f57a2caaedf4dd94e05c333724b9b55", "score": "0.53528064", "text": "function bvh_subdivide(bvh,\n nodeidx, /* current parent node to consider splitting */\n start, end, /* primitive sub-range to be considered at this recursion step */\n vb, /* bounding volume of the primitives' bounds in the sub-range */\n cb, /* bounding box of primitive centroids in this range */\n transparent, /* does the node contain opaque or transparent objects */\n depth /* recursion depth */)\n\n {\n box_get_size(cbdiag, 0, cb, 0);\n var nodes = bvh.nodes;\n var frags_per_leaf = transparent ? bvh.frags_per_leaf_node_transparent : bvh.frags_per_leaf_node;\n var frags_per_inner = transparent ? bvh.frags_per_inner_node_transparent : bvh.frags_per_inner_node;\n var polys_per_node = bvh.max_polys_per_node;\n\n //Decide which axis to split on.\n var axis = 0;\n if (cbdiag[1] > cbdiag[0])\n axis = 1;\n if (cbdiag[2] > cbdiag[axis])\n axis = 2;\n\n //Whether the node gets split or not, it gets\n //the same overall bounding box.\n nodes.setBox0(nodeidx, vb);\n\n //Check the expected polygon count of the node. This figures out the maximum number of fragments\n // we can put at the node as determined by polys_per_node\n var poly_count = 0;\n var poly_cut_off = 0;\n var prim_count = end - start + 1;\n\n // If we have the number of triangles in each mesh, limit the number of primitives in an inner node.\n if (bvh.finfo.hasPolygonCounts && bvh.frags_per_inner_node) {\n // Walk through primitives, add up the counts until we reach polys_per_node (10000), or run through\n // frags_per_inner_node (usually 32).\n // We know that later on we'll limit the number to frags_per_inner_node, so also do it here.\n var shorten_end = prim_count <= bvh.frags_per_inner_node ? end : start + bvh.frags_per_inner_node - 1;\n for (var i = start; i <= shorten_end; i++) {\n poly_count += bvh.finfo.getPolygonCount(bvh.primitives[i]);\n poly_cut_off++;\n if (poly_count > polys_per_node)\n break;\n }\n }\n\n var isSmall = prim_count <= frags_per_leaf && poly_count < polys_per_node ||\n prim_count === 1;\n\n //Decide whether to terminate recursion\n if (isSmall ||\n depth > MAX_DEPTH || //max recursion depth\n cbdiag[axis] < bvh.scene_epsilon) //node would be way too tiny for math to make sense (a point)\n {\n nodes.setLeftChild(nodeidx, -1);\n nodes.setPrimStart(nodeidx, start);\n nodes.setPrimCount(nodeidx, end - start + 1);\n nodes.setFlags(nodeidx, 0, 0, transparent ? 1 : 0);\n return;\n }\n\n //Pick the largest (first) primitives to live in this node\n //NOTE: this assumes primitives are sorted by size.\n //NOTE: This step is an optional departure from the original, and we also do a check for it above\n // to compute poly_cut_off.\n if (frags_per_inner) {\n axis = bvh_fatten_inner_node(bvh, nodes, nodeidx, start, end, cb, cbdiag, poly_cut_off);\n start = start + nodes.getPrimCount(nodeidx);\n }\n\n var split_info = new bvh_split_info();\n\n //Do the binning of the remaining primitives to go into child nodes\n bvh_bin_axis(bvh, start, end, axis, cb, cbdiag, split_info);\n\n if (split_info.num_bins < 0) {\n //Split was too costly, so add all objects to the current node and bail\n nodes.setPrimCount(nodeidx, nodes.getPrimCount(nodeidx) + end - start + 1);\n return;\n }\n\n bvh_partition(bvh, start, end, axis, cb, cbdiag, split_info);\n\n var child_idx = nodes.nextNodes(2);\n\n /* set info about split into the node */\n var cleft = (split_info.vb_left[3 + axis] + split_info.vb_left[axis]) * 0.5;\n var cright = (split_info.vb_right[3 + axis] + split_info.vb_right[axis]) * 0.5;\n\n nodes.setFlags(nodeidx, axis, cleft < cright ? 0 : 1, transparent ? 1 : 0);\n nodes.setLeftChild(nodeidx, child_idx);\n\n\n /* validate split */\n /*\n if (true) {\n for (var i=start; i< start+num_left; i++)\n {\n //int binid = (int)(k1 * (info->prim_info[info->bvh->iprims[i]].centroid.v[axis] - cb->min.v[axis]));\n var cen = primitives[i] * POINT_STRIDE;\n if ( centroids[cen] < split_info.cb_left[0]\n || centroids[cen] > split_info.cb_left[3]\n || centroids[cen+1] < split_info.cb_left[1]\n || centroids[cen+1] > split_info.cb_left[4]\n || centroids[cen+2] < split_info.cb_left[2]\n || centroids[cen+2] > split_info.cb_left[5])\n {\n debug (\"wrong centroid box\");\n }\n }\n for (i=start+num_left; i<=end; i++)\n {\n //int binid = (int)(k1 * (info->prim_info[info->bvh->iprims[i]].centroid.v[axis] - cb->min.v[axis]));\n var cen = primitives[i] * POINT_STRIDE;\n if ( centroids[cen] < split_info.cb_right[0]\n || centroids[cen] > split_info.cb_right[3]\n || centroids[cen+1] < split_info.cb_right[1]\n || centroids[cen+1] > split_info.cb_right[4]\n || centroids[cen+2] < split_info.cb_right[2]\n || centroids[cen+2] > split_info.cb_right[5])\n {\n debug (\"wrong centroid box\");\n }\n }\n }\n */\n\n\n /* recurse */\n //bvh_subdivide(bvh, child_idx, start, start + split_info.num_left - 1, split_info.vb_left, split_info.cb_left, transparent, depth+1);\n //bvh_subdivide(bvh, child_idx + 1, start + split_info.num_left, end, split_info.vb_right, split_info.cb_right, transparent, depth+1);\n\n //Iterative stack-based recursion for easier profiling\n bvh.recursion_stack.push([bvh, child_idx + 1, start + split_info.num_left, end, split_info.vb_right, split_info.cb_right, transparent, depth + 1]);\n bvh.recursion_stack.push([bvh, child_idx, start, start + split_info.num_left - 1, split_info.vb_left, split_info.cb_left, transparent, depth + 1]);\n\n }", "title": "" }, { "docid": "985182b638c2cc3aa29d0328ea70ce02", "score": "0.53516495", "text": "isNodeBalanced(node) {\n let isBalanced = true;\n\n if (node.left !== null && node.right !== null) {\n isBalanced = Math.abs(node.left.height - node.right.height) <= 1;\n } else if (node.right !== null && node.left === null) {\n isBalanced = node.right.height < 2;\n } else if (node.left !== null && node.right === null) {\n isBalanced = node.left.height < 2;\n }\n return isBalanced;\n }", "title": "" }, { "docid": "a7813f926bfdf65108557ad3911f26ce", "score": "0.53496635", "text": "function firstWalk(v) {\n var children = v.children,\n siblings = v.parent.children,\n w = v.i ? siblings[v.i - 1] : null;\n if (children.length) {\n d3_layout_treeShift(v);\n var midpoint = (children[0].z + children[children.length - 1].z) / 2;\n if (w) {\n v.z = w.z + separation(v._, w._);\n v.m = v.z - midpoint;\n } else {\n v.z = midpoint;\n }\n } else if (w) {\n v.z = w.z + separation(v._, w._);\n }\n v.parent.A = apportion(v, w, v.parent.A || siblings[0]);\n }", "title": "" }, { "docid": "e3d68d0e47cbe1e16519c675597010e1", "score": "0.5348913", "text": "splitNodes(editor) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Editor.withoutNormalizing(editor, () => {\n var {\n mode = 'lowest',\n voids = false\n } = options;\n var {\n match,\n at = editor.selection,\n height = 0,\n always = false\n } = options;\n\n if (match == null) {\n match = n => Editor.isBlock(editor, n);\n }\n\n if (Range.isRange(at)) {\n at = deleteRange(editor, at);\n } // If the target is a path, the default height-skipping and position\n // counters need to account for us potentially splitting at a non-leaf.\n\n\n if (Path.isPath(at)) {\n var path = at;\n var point = Editor.point(editor, path);\n var [parent] = Editor.parent(editor, path);\n\n match = n => n === parent;\n\n height = point.path.length - path.length + 1;\n at = point;\n always = true;\n }\n\n if (!at) {\n return;\n }\n\n var beforeRef = Editor.pointRef(editor, at, {\n affinity: 'backward'\n });\n var [highest] = Editor.nodes(editor, {\n at,\n match,\n mode,\n voids\n });\n\n if (!highest) {\n return;\n }\n\n var voidMatch = Editor.void(editor, {\n at,\n mode: 'highest'\n });\n var nudge = 0;\n\n if (!voids && voidMatch) {\n var [voidNode, voidPath] = voidMatch;\n\n if (Element$1.isElement(voidNode) && editor.isInline(voidNode)) {\n var after = Editor.after(editor, voidPath);\n\n if (!after) {\n var text = {\n text: ''\n };\n var afterPath = Path.next(voidPath);\n Transforms.insertNodes(editor, text, {\n at: afterPath,\n voids\n });\n after = Editor.point(editor, afterPath);\n }\n\n at = after;\n always = true;\n }\n\n var siblingHeight = at.path.length - voidPath.length;\n height = siblingHeight + 1;\n always = true;\n }\n\n var afterRef = Editor.pointRef(editor, at);\n var depth = at.path.length - height;\n var [, highestPath] = highest;\n var lowestPath = at.path.slice(0, depth);\n var position = height === 0 ? at.offset : at.path[depth] + nudge;\n\n for (var [node, _path2] of Editor.levels(editor, {\n at: lowestPath,\n reverse: true,\n voids\n })) {\n var split = false;\n\n if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Editor.isVoid(editor, node)) {\n break;\n }\n\n var _point = beforeRef.current;\n var isEnd = Editor.isEnd(editor, _point, _path2);\n\n if (always || !beforeRef || !Editor.isEdge(editor, _point, _path2)) {\n split = true;\n var properties = Node$1.extractProps(node);\n editor.apply({\n type: 'split_node',\n path: _path2,\n position,\n properties\n });\n }\n\n position = _path2[_path2.length - 1] + (split || isEnd ? 1 : 0);\n }\n\n if (options.at == null) {\n var _point2 = afterRef.current || Editor.end(editor, []);\n\n Transforms.select(editor, _point2);\n }\n\n beforeRef.unref();\n afterRef.unref();\n });\n }", "title": "" }, { "docid": "d59f2fce595af723003bb3572efc098e", "score": "0.53482103", "text": "split_() {\n let nextLevel = this.level_ + 1;\n let subWidth = Math.round(this.bounds_.width / 2);\n let subHeight = Math.round(this.bounds_.height / 2);\n let x = Math.round(this.bounds_.x);\n let y = Math.round(this.bounds_.y);\n\n //top right node\n this.nodes_[0] = new Quadtree(new Rectangle(\n x + subWidth,\n y,\n subWidth,\n subHeight\n ), this.maxObjects_, this.maxLevel_, nextLevel);\n\n //top left node\n this.nodes_[1] = new Quadtree(new Rectangle(\n x,\n y,\n subWidth,\n subHeight\n ), this.maxObjects_, this.maxLevel_, nextLevel);\n\n //bottom left node\n this.nodes_[2] = new Quadtree(new Rectangle(\n x,\n y + subHeight,\n subWidth,\n subHeight\n ), this.maxObjects_, this.maxLevel_, nextLevel);\n\n //bottom right node\n this.nodes_[3] = new Quadtree(new Rectangle(\n x + subWidth,\n y + subHeight,\n subWidth,\n subHeight\n ), this.maxObjects_, this.maxLevel_, nextLevel);\n\n }", "title": "" }, { "docid": "b35bb3aaa954ce42a6587eb84e1adfb4", "score": "0.53460616", "text": "getBalance() {\n let balance = 0;\n\n if (this.left !== null && this.right !== null) {\n balance = this.left.height - this.right.height;\n } else if (this.left !== null) {\n balance = this.left.height + 1;\n } else if (this.right !== null) {\n balance = -(this.right.height + 1);\n }\n\n return balance;\n }", "title": "" }, { "docid": "8b82df04cd5af1d3fb665ded82fee035", "score": "0.5339577", "text": "function test() {\n\n var root1 = { data: 10, left: null, right: null };\n var btree = new BinaryTree( root );\n\n btree.insert( root1, { data: 9, left: null, right: null } );\n btree.insert( root1, { data: 90, left: null, right: null } );\n btree.insert( root1, { data: 19, left: null, right: null } );\n btree.insert( root1, { data: 1, left: null, right: null } );\n\n\n console.assert( btree.search( root1, 14 ) === null, 'Failed to find item' );\n console.assert( btree.search( root1, 19 ).data === 19, 'Failed to find item' );\n\n console.assert( btree.search( root1, 1 ).data === 1, 'Failed to find item' );\n //deleting a non-existant node does nothing to the tree\n btree.delete( root1, 133 );\n //now delete an existant value from tree\n btree.delete( root1, 1 );\n console.assert( btree.search( root1, 1 ) === null, 'Failed to delete item' );\n console.assert( btree.findMin( root1 ) === 9,'Min should be 9' );\n console.assert( btree.findMax( root1 ) === 90,'Max should be 90' );\n\n}", "title": "" }, { "docid": "fbdafbd09577f7d8f92b2bfe6e81b663", "score": "0.5334301", "text": "minDepth() {\n if (!this.root) return 0\n let total = 0\n const toVisit = [this.root]\n while (toVisit.length) {\n let current = toVisit.pop()\n console.log(`CHILDREN OF CURRENT NODE ARE: ${current.left.val},${current.right.val} \\n CURRENT VAL IS ${current.val}`)\n }\n }", "title": "" }, { "docid": "9d10b0adfe2906a5289deb75c41365a5", "score": "0.53215027", "text": "function trimRedrawNodes(r) {\n doTrim(r, r.linelength - r.edgeTrim);\n if (r.children !== null) {\n for (var c of r.children) {\n if (!(typeof(c.rikCoords) === 'number' && isNaN(c.rikCoords))) { //if rikCoords are set\n trimRedrawNodes(c);\n }\n }\n }\n}", "title": "" }, { "docid": "05da6554db29f56bc9c51a1b0aab4bcb", "score": "0.5319606", "text": "function balanced(t, count = 0) {\n if (!t) {\n return count;\n }\n\n if (t !== null) {\n count++;\n let left = 0;\n let right = 0;\n //traverse right count nodes until null. return bounce\n right = balanced(t.right, count);\n if (right === false) {\n return false;\n }\n //traverse left counting nodes\n left = balanced(t.left, count);\n if (left === false) {\n return false;\n }\n //if left or right is greater by more than 1, true, else false\n return Math.abs(left - right) > 1 ? false : right + left;\n }\n\n //if the differnce between right and left is not greater than 1, return count.\n}", "title": "" }, { "docid": "3bb22afe23648fcf36b94bf4581d6f56", "score": "0.5316862", "text": "breadthFirst() {\n if (!this.root) {\n throw 'Empty tree';\n }\n\n const results = [];\n let saved = [];\n let counter = -1;\n\n results.push(this.root.value);\n const _walk = (node) => {\n if (node == undefined) {\n // console.log(results);\n return results;\n }\n counter++;\n if (node.left) {\n results.push(node.left.value);\n saved.push(node.left);\n }\n if (node.right) {\n results.push(node.right.value);\n saved.push(node.right);\n }\n _walk(saved[counter]);\n };\n\n _walk(this.root);\n return results;\n }", "title": "" }, { "docid": "53215cb016f30b4dfda277221910d48d", "score": "0.5309192", "text": "function checkBalanced(node) {\n\n if (node == null) return true;\n\n var leftHeight = getHeight(node.left);\n var rightHeight = getHeight(node.right);\n\n return (Math.abs(leftHeight-rightHeight) >1) && checkBalanced(node.left) && checkBalanced(node.right)\n\n}", "title": "" }, { "docid": "7a8d8f4a31b4fbdaba61b943953168e1", "score": "0.5306387", "text": "function _treeWithRoots(treeData, branchLength, depth, height, fullTreeDepth, maxBranchRad) {\n \n var body = _buildTree(treeData, branchLength, depth, height, fullTreeDepth, maxBranchRad, true);\n \n var numRoots = _r.randomInt(3,10); \n var startRot = _r.random(Math.PI*2);\n var rootColInt = colorHelper.parseHex(_options.COLOR_BTM);\n\n //console.log(numRoots+\" roots\\n\");\n for(var i=0; i<numRoots; i++){\n\n var rootRad = _r.random(maxBranchRad*0.3,maxBranchRad*0.7);\n var rootLength = _r.random(branchLength*0.02, branchLength*0.1);\n\n var cylGeom = new THREE.CylinderGeometry(rootRad, 0.01, rootLength, 8); \n for (var f = 0; f < cylGeom.faces.length; f ++) {\n cylGeom.faces[f].color.setHex(rootColInt);\n }\n\n var cylMat = new THREE.MeshBasicMaterial({\n vertexColors: THREE.FaceColors,\n overdraw: 0.5\n });\n\n var cone = new THREE.Mesh(cylGeom, cylMat); \n var newRoot = new THREE.Object3D();\n cone.rotation.x = -Math.PI/2.4;\n cone.position.z = rootLength/2 + (maxBranchRad/2)*0.9;\n \n newRoot.add(cone);\n newRoot.rotation.y = startRot + i*(Math.PI*2/numRoots);\n\n body.add(newRoot);\n }\n return body;\n }", "title": "" }, { "docid": "10fe810e7a1cb1f57026d0ba318b79a3", "score": "0.5295631", "text": "split() {\n let subWidth = (this.bounds.xMax - this.bounds.xMin) / 2;\n let subHeight = (this.bounds.yMax - this.bounds.yMin) / 2;\n let x = this.bounds.xMin;\n let y = this.bounds.yMin;\n // En bas à gauche\n this.nodes.push(new QuadTree(this.level + 1, new rectangle_2.Rectangle({\n x: x,\n y: y,\n width: subWidth,\n height: subHeight,\n })));\n // En haut à gauche\n this.nodes.push(new QuadTree(this.level + 1, new rectangle_2.Rectangle({\n x: x,\n y: y + subHeight,\n width: subWidth,\n height: subHeight,\n })));\n // En bas à droite\n this.nodes.push(new QuadTree(this.level + 1, new rectangle_2.Rectangle({\n x: x + subWidth,\n y: y,\n width: subWidth,\n height: subHeight,\n })));\n // En haut à droite\n this.nodes.push(new QuadTree(this.level + 1, new rectangle_2.Rectangle({\n x: x + subWidth,\n y: y + subHeight,\n width: subWidth,\n height: subHeight,\n })));\n }", "title": "" }, { "docid": "a3f5bc85d520388e43e07b18c33bf450", "score": "0.5295483", "text": "function constructTree(nodes, tree){\n\t\tif(isNaN(nodes[0].item))\n\t\t\treturn;\n\n\t\tlet space = 70;\n\t\tlet size = nodes.length;\n\t\tnodes[0].path.x = x;\n\t\tnodes[0].path.y = y;\n\t\ttree.root = nodes[0]; \n\t\tlet n = 0;\n\t\tfor(let i = 0; i < size; i++){\n\t\t\tlet node = nodes[i];\n\t\t\tif(isNaN(node.item)){\n\t\t\t\tn = n + 1;\n\t\t\t}\n\t\t\tif(!isNaN(node.item)){\n\n\t\t\t\tlet left = 2*i + 1 - 2*n;\n\t\t\t\tlet right = 2*i + 2 - 2*n;\n\n\t\t\t\tif(left < size){\n\t\t\t\t\tif(isNaN(nodes[left].item)){\n\t\t\t\t\t\tnode.left = null;\n\t\t\t\t\t}else{\n\t\t\t\t\t\tnodes[left].path.x = node.path.x - space;\n\t\t\t\t\t\tnodes[left].path.y = node.path.y + space;\n\t\t\t\t\t\tnode.left = nodes[left];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(right < size){\n\t\t\t\t\tif(isNaN(nodes[right].item)){\n\t\t\t\t\t\tnode.right = null;\n\t\t\t\t\t}else{\n\t\t\t\t\t\tnodes[right].path.x = node.path.x + space;\n\t\t\t\t\t\tnodes[right].path.y = node.path.y + space;\n\t\t\t\t\t\tnode.right = nodes[right];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tdrawTree(tree);\n\t}", "title": "" }, { "docid": "89f1197a309357ab567bab6ec667fedb", "score": "0.52929115", "text": "function run(g){var root=util.addDummyNode(g,\"root\",{},\"_root\");var depths=treeDepths(g);var height=_.max(_.values(depths))-1;// Note: depths is an Object not an array\nvar nodeSep=2*height+1;g.graph().nestingRoot=root;\n// Multiply minlen by nodeSep to align nodes on non-border ranks.\n_.forEach(g.edges(),function(e){g.edge(e).minlen*=nodeSep});\n// Calculate a weight that is sufficient to keep subgraphs vertically compact\nvar weight=sumWeights(g)+1;\n// Create border nodes and link them up\n_.forEach(g.children(),function(child){dfs(g,root,nodeSep,weight,height,depths,child)});\n// Save the multiplier for node layers for later removal of empty border\n// layers.\ng.graph().nodeRankFactor=nodeSep}", "title": "" }, { "docid": "89f1197a309357ab567bab6ec667fedb", "score": "0.52929115", "text": "function run(g){var root=util.addDummyNode(g,\"root\",{},\"_root\");var depths=treeDepths(g);var height=_.max(_.values(depths))-1;// Note: depths is an Object not an array\nvar nodeSep=2*height+1;g.graph().nestingRoot=root;\n// Multiply minlen by nodeSep to align nodes on non-border ranks.\n_.forEach(g.edges(),function(e){g.edge(e).minlen*=nodeSep});\n// Calculate a weight that is sufficient to keep subgraphs vertically compact\nvar weight=sumWeights(g)+1;\n// Create border nodes and link them up\n_.forEach(g.children(),function(child){dfs(g,root,nodeSep,weight,height,depths,child)});\n// Save the multiplier for node layers for later removal of empty border\n// layers.\ng.graph().nodeRankFactor=nodeSep}", "title": "" }, { "docid": "34453b71a383829d8937f37460b44865", "score": "0.5289724", "text": "function extUtils_getOffsetsAfterClimbingTree(theObj,currOffs)\n{\n var currObj = theObj;\n var objParent, parentOffs;\n var climbTree = true;\n\n // Note - don't walk all the way up to the document node. It has no offsets.\n while ( climbTree && currObj.parentNode\n && currObj.parentNode.nodeType != Node.DOCUMENT_NODE\n )\n {\n objParent = currObj.parentNode;\n parentOffs = dwscripts.getNodeOffsets(objParent);\n if ( (parentOffs[0] < currOffs[0] && parentOffs[1] < currOffs[1]) ||\n (parentOffs[0] > currOffs[0] && parentOffs[1] > currOffs[1]) )\n {\n currObj = objParent;\n }\n else\n {\n climbTree = false;\n }\n }\n return ( dwscripts.getNodeOffsets(currObj) );\n}", "title": "" }, { "docid": "5112e4eba9cff53ee4bc26204f8731fc", "score": "0.52878785", "text": "updateToRoot() {\n var x = this;\n while (x != null) {\n var rightHeight = (x.rightChild != null) ? x.rightChild.height : 0;\n var leftHeight = (x.leftChild != null) ? x.leftChild.height : 0;\n var rightSize = (x.rightChild != null) ? x.rightChild.size : 0;\n var leftSize = (x.leftChild != null) ? x.leftChild.size : 0;\n x.height = Math.max(rightHeight, leftHeight) + 1;\n x.size = rightSize + leftSize + 1;\n x.rebalance();\n x = x.parent;\n }\n }", "title": "" }, { "docid": "bb465e807e6fea6a251e1da3775502df", "score": "0.5272518", "text": "getBalance() {\n let balance = 0;\n if (this.left !== null && this.right !== null) {\n balance = this.left.height - this.right.height;\n }\n else if (this.left !== null) {\n balance = this.left.height + 1;\n }\n else if (this.right !== null) {\n balance = -(this.right.height + 1);\n }\n return balance;\n }", "title": "" }, { "docid": "bb465e807e6fea6a251e1da3775502df", "score": "0.5272518", "text": "getBalance() {\n let balance = 0;\n if (this.left !== null && this.right !== null) {\n balance = this.left.height - this.right.height;\n }\n else if (this.left !== null) {\n balance = this.left.height + 1;\n }\n else if (this.right !== null) {\n balance = -(this.right.height + 1);\n }\n return balance;\n }", "title": "" }, { "docid": "4fbf63b57976a510d487a7bb5267c12f", "score": "0.5264659", "text": "function filterByThreshold(nodeModel,totalArea,sum,orderBy,orderedChildren){// visibleMin is not supported yet when no option.sort.\nif(!orderBy){return sum;}var visibleMin=nodeModel.get('visibleMin');var len=orderedChildren.length;var deletePoint=len;// Always travel from little value to big value.\nfor(var i=len-1;i>=0;i--){var value=orderedChildren[orderBy==='asc'?len-i-1:i].getValue();if(value/sum*totalArea<visibleMin){deletePoint=i;sum-=value;}}orderBy==='asc'?orderedChildren.splice(0,len-deletePoint):orderedChildren.splice(deletePoint,len-deletePoint);return sum;}", "title": "" }, { "docid": "f75ae5b4f596d98ab79c442421049c52", "score": "0.52474433", "text": "function drawTree(root){\n arr = []\n // Used a queue\n let q = [];\n root.x = ix;\n root.y = iy;\n q.push(root);\n q.push(null);\n\n while(q.length){\n let t = q.shift();\n\n if(t){\n arr.push(t);\n\n let v0 = p5.Vector.fromAngle(radians(myDegrees), dis);\n let v1 = p5.Vector.fromAngle(radians(180-myDegrees), dis);\n if(t.lchild){\n t.lchild.x = t.x + v0.x;\n t.lchild.y = t.y + v0.y;\n q.push(t.lchild);\n\n }\n if(t.rchild){\n t.rchild.x = t.x + v1.x;\n t.rchild.y = t.y + v1.y;\n q.push(t.rchild);\n }\n if(t.lchild && t.rchild){\n let d = dist(t.lchild.x, t.lchild.y, t.rchild.x, t.rchild.y);\n if(d < 50){\n t.lchild.x -= 20;\n t.rchild.x += 20;\n }\n }\n }else{\n if(q.length){\n q.push(null);\n myDegrees += (90-myDegrees)*0.35;\n if(dis > 60)\n dis-= (dis)*0.30;\n }\n }\n }\n\n dis = oridis;\n myDegrees = degori;\n}", "title": "" }, { "docid": "40a2017abb9509f827f70535fa66293c", "score": "0.5242912", "text": "function btsHeight(tree) {\n if(!tree) {\n return 0;\n }\n\n else {\n let left = btsHeight(tree.left);\n let right = btsHeight(tree.right)\n\n if (left > right) {\n return(left + 1);\n }\n else return right + 1;\n }\n\n\n // let allLengths = [];\n // let count = 0;\n\n // if (tree.key !== null) {\n // count++;\n // }\n\n // if (tree.left && tree.right) {\n // console.log(tree.left);\n // return Math.max(btsHeight(tree.left.key), btsHeight(tree.right.key)) + 1;\n\n // }\n\n}", "title": "" }, { "docid": "528001d81a0dd445eab211037286811d", "score": "0.5237979", "text": "function recoverTreeRecursive(root) {\n let a = null,\n b = null,\n last = new TreeNode(-Infinity);\n inorderTraverse(root);\n //if (b===null) b = last;\n let tmp = a.val;\n a.val = b.val;\n b.val = tmp;\n\n function inorderTraverse(root) {\n if (root === null) return;\n inorderTraverse(root.left);\n if (root.val < last.val) {\n if (a === null) {\n a = last;\n }\n b = root;\n }\n last = root;\n inorderTraverse(root.right);\n }\n}", "title": "" }, { "docid": "c3a0719e273803fd20a08171e270ff1e", "score": "0.5236647", "text": "removeNode(node, key) \n{ \n \n // if the root is null then tree is \n // empty \n if(node === null) \n return null; \n \n // if data to be delete is less than \n // roots data then move to left subtree \n else if(key < node.data) \n { \n node.left = this.removeNode(node.left, key); \n return node; \n } \n \n // if data to be delete is greater than \n // roots data then move to right subtree \n else if(key > node.data) \n { \n node.right = this.removeNode(node.right, key); \n return node; \n } \n \n // if data is similar to the root's data \n // then delete this node \n else\n { \n // deleting node with no children \n if(node.left === null && node.right === null) \n { \n node = null; \n return node; \n } \n \n // deleting node with one children \n if(node.left === null) \n { \n node = node.right; \n return node; \n } \n \n else if(node.right === null) \n { \n node = node.left; \n return node; \n } \n \n // Deleting node with two children \n // minumum node of the rigt subtree \n // is stored in aux \n const aux = this.findMinNode(node.right); \n node.data = aux.data; \n \n node.right = this.removeNode(node.right, aux.data); \n return node; \n } \n \n}", "title": "" }, { "docid": "3f77c0f93ccc111cf4b775fc2ab16b20", "score": "0.5236132", "text": "construirDescendentes(staterecebido, jogador, jogada, depth, auxdepJogador, auxdepComputador) {\n\n //receber um estado + 1 jogada -- Fazer a jogada -- Procurar novas jogadas -- passar aos descedentes\n var nodo = new TreeNode();\n nodo.root = jogada;\n // Fazer copia das variaveis globais\n var copiaestado = [...staterecebido];\n\n var depJogadorcopy = auxdepJogador\n var depComputadorcopy = auxdepComputador\n nodo.estadoSimulado = this.simulaJogada(copiaestado, jogada, jogador, depJogadorcopy, depComputadorcopy);\n\n if (depth === 0 || nodo.estadoSimulado.over === 1) {\n return nodo;\n }\n\n //EstadoSimulado já tem a jogada feita e os deps calculados, e o jogador ANTIGO\n\n\n var jogPosNew = this.verificaJogadas(nodo.estadoSimulado.estado, (jogador % 2) + 1);\n\n for (var i = 0; i < jogPosNew.length; i++) {\n nodo.descendants.push(this.construirDescendentes(nodo.estadoSimulado.estado, (jogador % 2) + 1, jogPosNew[i], depth - 1, nodo.estadoSimulado.depJogador, nodo.estadoSimulado.depComputador));\n\n }\n return nodo;\n }", "title": "" }, { "docid": "76faf4c80d351ca5e2f64647c6da9892", "score": "0.5233759", "text": "rebalance() {\n // Rebalance only while |balance factor| is not <= 1:\n var factor = this.getBalanceFactor();\n if (!(Math.abs(factor) <= 1)) {\n // R and LR rotations\n if (factor > 1) {\n var heightA = (this.leftChild.leftChild != null) ? this.leftChild.leftChild.height : 0;\n var heightB = (this.leftChild.rightChild != null) ? this.leftChild.rightChild.height : 0;\n var heightC = (this.rightChild != null) ? this.rightChild.height : 0;\n // R:\n if (heightA >= heightB && heightA >= heightC) {\n this.rotateR();\n //this.parent = null;\n }\n // LR: \n else if (heightB >= heightA && heightB >= heightC) {\n this.rotateLR();\n //this.parent = null;\n }\n }\n // L and RL rotations\n else if (factor < -1) {\n var heightA = (this.rightChild.rightChild != null) ? this.rightChild.rightChild.height : 0;\n var heightB = (this.rightChild.leftChild != null) ? this.rightChild.leftChild.height : 0;\n var heightC = (this.leftChild != null) ? this.leftChild.height : 0;\n // L:\n if (heightA >= heightB && heightA >= heightC) {\n this.rotateL();\n //this.parent = null;\n }\n // RL:\n else if (heightB >= heightA && heightB >= heightC) {\n this.rotateRL();\n //this.parent = null;\n }\n }\n }\n }", "title": "" }, { "docid": "a2f873050b2992d25149e9ad627adfb5", "score": "0.52335495", "text": "deleteTheElementaryBlocks(vv){\n if(this._initGraph()){\n //segno la root come visitata\n this.root.setVisitedValue(vv);\n this.root.setVisited();\n this.root.getNeighbours().forEach((node) => {\n node.setVisitedValue(vv);\n this.edges.push(new Edge(this.root,node));\n node.children = this._removeAnElementFromAnArray(node.getNeighbours(), this.root);\n //this._deleteBlocks(node);\n this._removeCirclesHideBiconnectedBlocksWithOneEdgeAnd2CutVertex(node);\n });\n\n }\n }", "title": "" }, { "docid": "bb13373187f09364fbda13fe418397fa", "score": "0.5229434", "text": "bfs() {\n const result = [];\n if (!this.root) return result;\n const queue = [];\n queue.push(this.root)\n while(queue.length > 0) {\n const element = queue.shift();\n result.push(element.val);\n \n if (element.left) {\n queue.push(element.left);\n }\n if (element.right) {\n queue.push(element.right);\n }\n }\n // console.log(tree.bfs());\n // [10, 8, 14, 5, 9, 12, 17]\n return result;\n }", "title": "" }, { "docid": "d7c1819c493b1464e908cef45b682536", "score": "0.52251905", "text": "GetTreeBalance() {\n return this.m_contactManager.m_broadPhase.GetTreeBalance();\n }", "title": "" }, { "docid": "43f89f36b315b78de183ffdb561d4a77", "score": "0.5221479", "text": "function _cut(minimum, node, parent) {\n // remove node from parent children and decrement Degree[parent]\n node.left.right = node.right;\n node.right.left = node.left;\n parent.degree--; // reset y.child if necessary\n\n if (parent.child === node) {\n parent.child = node.right;\n } // remove child if degree is 0\n\n\n if (parent.degree === 0) {\n parent.child = null;\n } // add node to root list of heap\n\n\n node.left = minimum;\n node.right = minimum.right;\n minimum.right = node;\n node.right.left = node; // set parent[node] to null\n\n node.parent = null; // set mark[node] to false\n\n node.mark = false;\n }", "title": "" }, { "docid": "43f89f36b315b78de183ffdb561d4a77", "score": "0.5221479", "text": "function _cut(minimum, node, parent) {\n // remove node from parent children and decrement Degree[parent]\n node.left.right = node.right;\n node.right.left = node.left;\n parent.degree--; // reset y.child if necessary\n\n if (parent.child === node) {\n parent.child = node.right;\n } // remove child if degree is 0\n\n\n if (parent.degree === 0) {\n parent.child = null;\n } // add node to root list of heap\n\n\n node.left = minimum;\n node.right = minimum.right;\n minimum.right = node;\n node.right.left = node; // set parent[node] to null\n\n node.parent = null; // set mark[node] to false\n\n node.mark = false;\n }", "title": "" } ]
acfee58d11c1bb626ede0e791b519898
This API will tag the children with the sideeffect of the reconciliation itself. They will be added to the sideeffect list as we pass through the children and the parent.
[ { "docid": "f6406a3cbcdd14399813c029fbe0e069", "score": "0.0", "text": "function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }", "title": "" } ]
[ { "docid": "521f556b191e005fc127361e48b89dea", "score": "0.69898194", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element))) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function(child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function(child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element))) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "f87a83dcea16255dd078d16f7360b1b8", "score": "0.6979805", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created[\"return\"] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing[\"return\"] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing[\"return\"] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created[\"return\"] = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created[\"return\"] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing[\"return\"] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created[\"return\"] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing[\"return\"] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created[\"return\"] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created[\"return\"] = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2[\"return\"] = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3[\"return\"] = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren[\"delete\"](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren[\"delete\"](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing[\"return\"] = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created[\"return\"] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing[\"return\"] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created[\"return\"] = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4[\"return\"] = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing[\"return\"] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created[\"return\"] = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "8439bcba8c01cb855ac281c2f86050c5", "score": "0.695095", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n \n \n var last = returnFiber.lastEffect;\n \n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n \n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n \n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n \n \n var childToDelete = currentFirstChild;\n \n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n \n return null;\n }\n \n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n \n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n \n existingChild = existingChild.sibling;\n }\n \n return existingChildren;\n }\n \n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n \n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n \n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n \n var current = newFiber.alternate;\n \n if (current !== null) {\n var oldIndex = current.index;\n \n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n \n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n \n return newFiber;\n }\n \n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n \n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n \n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n \n return existing;\n }\n } // Insert\n \n \n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n \n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n \n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n \n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n \n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n \n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n \n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n \n _created2.return = returnFiber;\n return _created2;\n }\n }\n \n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n \n _created3.return = returnFiber;\n return _created3;\n }\n \n throwOnInvalidObjectType(returnFiber, newChild);\n }\n \n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n \n return null;\n }\n \n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n \n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n \n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n \n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n \n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n \n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n \n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n \n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n \n throwOnInvalidObjectType(returnFiber, newChild);\n }\n \n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n \n return null;\n }\n \n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n \n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n \n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n \n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n \n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n \n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n \n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n \n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n \n throwOnInvalidObjectType(returnFiber, newChild);\n }\n \n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n \n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n \n \n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n \n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n \n if (typeof key !== 'string') {\n break;\n }\n \n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n \n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n \n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n \n break;\n }\n }\n \n return knownKeys;\n }\n \n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n \n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n \n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n \n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n \n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n \n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n \n break;\n }\n \n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n \n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n \n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n \n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n \n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n \n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n \n if (_newFiber === null) {\n continue;\n }\n \n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n \n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n \n previousNewFiber = _newFiber;\n }\n \n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n \n \n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n \n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n \n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n \n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n \n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n \n previousNewFiber = _newFiber2;\n }\n }\n \n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n \n return resultingFirstChild;\n }\n \n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n \n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n \n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n \n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n \n \n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n \n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n \n \n var _newChildren = iteratorFn.call(newChildrenIterable);\n \n if (_newChildren) {\n var knownKeys = null;\n \n var _step = _newChildren.next();\n \n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n \n var newChildren = iteratorFn.call(newChildrenIterable);\n \n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n \n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n \n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n \n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n \n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n \n break;\n }\n \n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n \n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n \n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n \n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n \n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n \n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n \n if (_newFiber3 === null) {\n continue;\n }\n \n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n \n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n \n previousNewFiber = _newFiber3;\n }\n \n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n \n \n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n \n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n \n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n \n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n \n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n \n previousNewFiber = _newFiber4;\n }\n }\n \n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n \n return resultingFirstChild;\n }\n \n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n \n \n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n \n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n \n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n \n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n \n return existing;\n }\n \n break;\n }\n \n case Block:\n \n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n \n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n \n var _existing3 = useFiber(child, element.props);\n \n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n \n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n \n return _existing3;\n }\n \n break;\n }\n } // Didn't match.\n \n \n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n \n child = child.sibling;\n }\n \n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n \n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n \n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n \n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n \n child = child.sibling;\n }\n \n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n \n \n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n \n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n \n \n var isObject = typeof newChild === 'object' && newChild !== null;\n \n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n \n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n \n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n \n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n \n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n \n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n \n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n \n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n \n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n \n case FunctionComponent:\n {\n var Component = returnFiber.type;\n \n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n \n \n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n \n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "a73962e2b13a8db6f7ceab671cdf014d", "score": "0.6940482", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "1f47cd5ed6ebcd6c1ef19f9b52870816", "score": "0.69353807", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(\n fiber,\n pendingProps,\n expirationTime\n );\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(\n returnFiber,\n current,\n textContent,\n expirationTime\n ) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(\n textContent,\n returnFiber.internalContextTag,\n expirationTime\n );\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(\n returnFiber,\n current,\n element,\n expirationTime\n ) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(\n current,\n element.props,\n expirationTime\n );\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(\n element,\n returnFiber.internalContextTag,\n expirationTime\n );\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(\n call,\n returnFiber.internalContextTag,\n expirationTime\n );\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(\n returnFiber,\n current,\n returnNode,\n expirationTime\n ) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(\n returnNode,\n returnFiber.internalContextTag,\n expirationTime\n );\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(\n returnFiber,\n current,\n portal,\n expirationTime\n ) {\n if (\n current === null ||\n current.tag !== HostPortal ||\n current.stateNode.containerInfo !== portal.containerInfo ||\n current.stateNode.implementation !== portal.implementation\n ) {\n // Insert\n var created = createFiberFromPortal(\n portal,\n returnFiber.internalContextTag,\n expirationTime\n );\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(\n current,\n portal.children || [],\n expirationTime\n );\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(\n returnFiber,\n current,\n fragment,\n expirationTime,\n key\n ) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(\n fragment,\n returnFiber.internalContextTag,\n expirationTime,\n key\n );\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (\n typeof newChild === 'string' ||\n typeof newChild === 'number'\n ) {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText(\n '' + newChild,\n returnFiber.internalContextTag,\n expirationTime\n );\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE: {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(\n newChild.props.children,\n returnFiber.internalContextTag,\n expirationTime,\n newChild.key\n );\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(\n newChild,\n returnFiber.internalContextTag,\n expirationTime\n );\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE: {\n var _created3 = createFiberFromCall(\n newChild,\n returnFiber.internalContextTag,\n expirationTime\n );\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE: {\n var _created4 = createFiberFromReturn(\n newChild,\n returnFiber.internalContextTag,\n expirationTime\n );\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE: {\n var _created5 = createFiberFromPortal(\n newChild,\n returnFiber.internalContextTag,\n expirationTime\n );\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(\n newChild,\n returnFiber.internalContextTag,\n expirationTime,\n null\n );\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(\n returnFiber,\n oldFiber,\n newChild,\n expirationTime\n ) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (\n typeof newChild === 'string' ||\n typeof newChild === 'number'\n ) {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(\n returnFiber,\n oldFiber,\n '' + newChild,\n expirationTime\n );\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE: {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(\n returnFiber,\n oldFiber,\n newChild.props.children,\n expirationTime,\n key\n );\n }\n return updateElement(\n returnFiber,\n oldFiber,\n newChild,\n expirationTime\n );\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE: {\n if (newChild.key === key) {\n return updateCall(\n returnFiber,\n oldFiber,\n newChild,\n expirationTime\n );\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE: {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(\n returnFiber,\n oldFiber,\n newChild,\n expirationTime\n );\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE: {\n if (newChild.key === key) {\n return updatePortal(\n returnFiber,\n oldFiber,\n newChild,\n expirationTime\n );\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(\n returnFiber,\n oldFiber,\n newChild,\n expirationTime,\n null\n );\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(\n existingChildren,\n returnFiber,\n newIdx,\n newChild,\n expirationTime\n ) {\n if (\n typeof newChild === 'string' ||\n typeof newChild === 'number'\n ) {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(\n returnFiber,\n matchedFiber,\n '' + newChild,\n expirationTime\n );\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE: {\n var _matchedFiber =\n existingChildren.get(\n newChild.key === null ? newIdx : newChild.key\n ) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(\n returnFiber,\n _matchedFiber,\n newChild.props.children,\n expirationTime,\n newChild.key\n );\n }\n return updateElement(\n returnFiber,\n _matchedFiber,\n newChild,\n expirationTime\n );\n }\n\n case REACT_CALL_TYPE: {\n var _matchedFiber2 =\n existingChildren.get(\n newChild.key === null ? newIdx : newChild.key\n ) || null;\n return updateCall(\n returnFiber,\n _matchedFiber2,\n newChild,\n expirationTime\n );\n }\n\n case REACT_RETURN_TYPE: {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(\n returnFiber,\n _matchedFiber3,\n newChild,\n expirationTime\n );\n }\n\n case REACT_PORTAL_TYPE: {\n var _matchedFiber4 =\n existingChildren.get(\n newChild.key === null ? newIdx : newChild.key\n ) || null;\n return updatePortal(\n returnFiber,\n _matchedFiber4,\n newChild,\n expirationTime\n );\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(\n returnFiber,\n _matchedFiber5,\n newChild,\n expirationTime,\n null\n );\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(\n false,\n 'Encountered two children with the same key, `%s`. ' +\n 'Keys should be unique so that components maintain their identity ' +\n 'across updates. Non-unique keys may cause children to be ' +\n 'duplicated and/or omitted — the behavior is unsupported and ' +\n 'could change in a future version.%s',\n key,\n getCurrentFiberStackAddendum$1()\n );\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(\n returnFiber,\n currentFirstChild,\n newChildren,\n expirationTime\n ) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (\n ;\n oldFiber !== null && newIdx < newChildren.length;\n newIdx++\n ) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(\n returnFiber,\n oldFiber,\n newChildren[newIdx],\n expirationTime\n );\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(\n newFiber,\n lastPlacedIndex,\n newIdx\n );\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(\n returnFiber,\n newChildren[newIdx],\n expirationTime\n );\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(\n _newFiber,\n lastPlacedIndex,\n newIdx\n );\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(\n returnFiber,\n oldFiber\n );\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(\n existingChildren,\n returnFiber,\n newIdx,\n newChildren[newIdx],\n expirationTime\n );\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](\n _newFiber2.key === null ? newIdx : _newFiber2.key\n );\n }\n }\n lastPlacedIndex = placeChild(\n _newFiber2,\n lastPlacedIndex,\n newIdx\n );\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function(child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(\n returnFiber,\n currentFirstChild,\n newChildrenIterable,\n expirationTime\n ) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function')\n ? invariant(\n false,\n 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.'\n )\n : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(\n didWarnAboutMaps,\n 'Using Maps as children is unsupported and will likely yield ' +\n 'unexpected results. Convert it to a sequence/iterable of keyed ' +\n 'ReactElements instead.%s',\n getCurrentFiberStackAddendum$1()\n );\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null)\n ? invariant(false, 'An iterable object provided no iterator.')\n : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (\n ;\n oldFiber !== null && !step.done;\n newIdx++, step = newChildren.next()\n ) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(\n returnFiber,\n oldFiber,\n step.value,\n expirationTime\n );\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(\n newFiber,\n lastPlacedIndex,\n newIdx\n );\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(\n returnFiber,\n step.value,\n expirationTime\n );\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(\n _newFiber3,\n lastPlacedIndex,\n newIdx\n );\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(\n returnFiber,\n oldFiber\n );\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(\n existingChildren,\n returnFiber,\n newIdx,\n step.value,\n expirationTime\n );\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](\n _newFiber4.key === null ? newIdx : _newFiber4.key\n );\n }\n }\n lastPlacedIndex = placeChild(\n _newFiber4,\n lastPlacedIndex,\n newIdx\n );\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function(child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(\n returnFiber,\n currentFirstChild,\n textContent,\n expirationTime\n ) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (\n currentFirstChild !== null &&\n currentFirstChild.tag === HostText\n ) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(\n returnFiber,\n currentFirstChild.sibling\n );\n var existing = useFiber(\n currentFirstChild,\n textContent,\n expirationTime\n );\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(\n textContent,\n returnFiber.internalContextTag,\n expirationTime\n );\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(\n returnFiber,\n currentFirstChild,\n element,\n expirationTime\n ) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (\n child.tag === Fragment\n ? element.type === REACT_FRAGMENT_TYPE\n : child.type === element.type\n ) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(\n child,\n element.type === REACT_FRAGMENT_TYPE\n ? element.props.children\n : element.props,\n expirationTime\n );\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(\n element.props.children,\n returnFiber.internalContextTag,\n expirationTime,\n element.key\n );\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(\n element,\n returnFiber.internalContextTag,\n expirationTime\n );\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(\n returnFiber,\n currentFirstChild,\n call,\n expirationTime\n ) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(\n call,\n returnFiber.internalContextTag,\n expirationTime\n );\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(\n returnFiber,\n currentFirstChild,\n returnNode,\n expirationTime\n ) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(\n returnNode,\n returnFiber.internalContextTag,\n expirationTime\n );\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(\n returnFiber,\n currentFirstChild,\n portal,\n expirationTime\n ) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (\n child.tag === HostPortal &&\n child.stateNode.containerInfo === portal.containerInfo &&\n child.stateNode.implementation === portal.implementation\n ) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(\n child,\n portal.children || [],\n expirationTime\n );\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(\n portal,\n returnFiber.internalContextTag,\n expirationTime\n );\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(\n returnFiber,\n currentFirstChild,\n newChild,\n expirationTime\n ) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (\n typeof newChild === 'object' &&\n newChild !== null &&\n newChild.type === REACT_FRAGMENT_TYPE &&\n newChild.key === null\n ) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject =\n typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(\n reconcileSingleElement(\n returnFiber,\n currentFirstChild,\n newChild,\n expirationTime\n )\n );\n\n case REACT_CALL_TYPE:\n return placeSingleChild(\n reconcileSingleCall(\n returnFiber,\n currentFirstChild,\n newChild,\n expirationTime\n )\n );\n case REACT_RETURN_TYPE:\n return placeSingleChild(\n reconcileSingleReturn(\n returnFiber,\n currentFirstChild,\n newChild,\n expirationTime\n )\n );\n case REACT_PORTAL_TYPE:\n return placeSingleChild(\n reconcileSinglePortal(\n returnFiber,\n currentFirstChild,\n newChild,\n expirationTime\n )\n );\n }\n }\n\n if (\n typeof newChild === 'string' ||\n typeof newChild === 'number'\n ) {\n return placeSingleChild(\n reconcileSingleTextNode(\n returnFiber,\n currentFirstChild,\n '' + newChild,\n expirationTime\n )\n );\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(\n returnFiber,\n currentFirstChild,\n newChild,\n expirationTime\n );\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(\n returnFiber,\n currentFirstChild,\n newChild,\n expirationTime\n );\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent: {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent: {\n var Component = returnFiber.type;\n invariant(\n false,\n '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.',\n Component.displayName || Component.name || 'Component'\n );\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "6bd6ec51e3cc183b84163fe805695868", "score": "0.6933627", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n\n break;\n }\n\n case Block: // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "84831d440466f97d7fc3dbf747607528", "score": "0.6927816", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "84831d440466f97d7fc3dbf747607528", "score": "0.6927816", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "c37cb4ef922668fa35ab155a6be12d05", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && (current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element))) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n (function () {\n if (!(typeof iteratorFn === 'function')) {\n {\n throw ReactError(Error('An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.'));\n }\n }\n })();\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n (function () {\n if (!(newChildren != null)) {\n {\n throw ReactError(Error('An iterable object provided no iterator.'));\n }\n }\n })();\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n (function () {\n {\n {\n throw ReactError(Error((Component.displayName || Component.name || 'Component') + '(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.'));\n }\n }\n })();\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "38ac3c0a89ae171106cfd138e4b1abd5", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "c7af98fadc812e1592b2f967d8d09fa4", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.type === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n case ClassComponentLazy:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "38ac3c0a89ae171106cfd138e4b1abd5", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "38ac3c0a89ae171106cfd138e4b1abd5", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "c4068a4d7465013609216396096876ec", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "38ac3c0a89ae171106cfd138e4b1abd5", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "38ac3c0a89ae171106cfd138e4b1abd5", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "c4068a4d7465013609216396096876ec", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "c4068a4d7465013609216396096876ec", "score": "0.6927629", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (!_newFiber) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "145d2ba12737f5533f443a95163c12e2", "score": "0.6923651", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n return newFiber;\n }\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n }\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n _created3.return = returnFiber;\n return _created3;\n }\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n if (_newFiber === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n return resultingFirstChild;\n }\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n didWarnAboutGenerators = true;\n }\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n didWarnAboutMaps = true;\n }\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; (newIdx++, step = newChildren.next())) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; (newIdx++, step = newChildren.next())) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; (newIdx++, step = newChildren.next())) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n return resultingFirstChild;\n }\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n break;\n }\n case Block:\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var _existing3 = useFiber(child, element.props);\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n break;\n }\n }\n // Didn't match.\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n }\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "145d2ba12737f5533f443a95163c12e2", "score": "0.6923651", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n return newFiber;\n }\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element)) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n }\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n _created3.return = returnFiber;\n return _created3;\n }\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n }\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n }\n }\n return knownKeys;\n }\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n if (_newFiber === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n return resultingFirstChild;\n }\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n didWarnAboutGenerators = true;\n }\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n didWarnAboutMaps = true;\n }\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; (newIdx++, step = newChildren.next())) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; (newIdx++, step = newChildren.next())) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; (newIdx++, step = newChildren.next())) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n return resultingFirstChild;\n }\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n }\n break;\n }\n case Block:\n default:\n {\n if (child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var _existing3 = useFiber(child, element.props);\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n return _existing3;\n }\n break;\n }\n }\n // Didn't match.\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n }\n }\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error((getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n }\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "f0fb963860a544f67fc99dae84dbdb7f", "score": "0.69135743", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current$$1 = newFiber.alternate;\n\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && (current$$1.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element))) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error(\"An iterable object provided no iterator.\");\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n {\n {\n throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n }", "title": "" }, { "docid": "7c5c5dbc87f77e681e0d4a9cb5c0e804", "score": "0.6900002", "text": "function ChildReconciler(shouldTrackSideEffects) {\n\t function deleteChild(returnFiber, childToDelete) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return;\n\t }\n\t // Deletions are added in reversed order so we add it to the front.\n\t // At this point, the return fiber's effect list is empty except for\n\t // deletions, so we can just append the deletion to the list. The remaining\n\t // effects aren't added until the complete phase. Once we implement\n\t // resuming, this may not be true.\n\t var last = returnFiber.lastEffect;\n\t if (last !== null) {\n\t last.nextEffect = childToDelete;\n\t returnFiber.lastEffect = childToDelete;\n\t } else {\n\t returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n\t }\n\t childToDelete.nextEffect = null;\n\t childToDelete.effectTag = Deletion;\n\t }\n\t\n\t function deleteRemainingChildren(returnFiber, currentFirstChild) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return null;\n\t }\n\t\n\t // TODO: For the shouldClone case, this could be micro-optimized a bit by\n\t // assuming that after the first child we've already added everything.\n\t var childToDelete = currentFirstChild;\n\t while (childToDelete !== null) {\n\t deleteChild(returnFiber, childToDelete);\n\t childToDelete = childToDelete.sibling;\n\t }\n\t return null;\n\t }\n\t\n\t function mapRemainingChildren(returnFiber, currentFirstChild) {\n\t // Add the remaining children to a temporary map so that we can find them by\n\t // keys quickly. Implicit (null) keys get added to this set with their index\n\t var existingChildren = new Map();\n\t\n\t var existingChild = currentFirstChild;\n\t while (existingChild !== null) {\n\t if (existingChild.key !== null) {\n\t existingChildren.set(existingChild.key, existingChild);\n\t } else {\n\t existingChildren.set(existingChild.index, existingChild);\n\t }\n\t existingChild = existingChild.sibling;\n\t }\n\t return existingChildren;\n\t }\n\t\n\t function useFiber(fiber, pendingProps, expirationTime) {\n\t // We currently set sibling to null and index to 0 here because it is easy\n\t // to forget to do before returning it. E.g. for the single child case.\n\t var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n\t clone.index = 0;\n\t clone.sibling = null;\n\t return clone;\n\t }\n\t\n\t function placeChild(newFiber, lastPlacedIndex, newIndex) {\n\t newFiber.index = newIndex;\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return lastPlacedIndex;\n\t }\n\t var current = newFiber.alternate;\n\t if (current !== null) {\n\t var oldIndex = current.index;\n\t if (oldIndex < lastPlacedIndex) {\n\t // This is a move.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t } else {\n\t // This item can stay in place.\n\t return oldIndex;\n\t }\n\t } else {\n\t // This is an insertion.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t }\n\t }\n\t\n\t function placeSingleChild(newFiber) {\n\t // This is simpler for the single child case. We only need to do a\n\t // placement for inserting new children.\n\t if (shouldTrackSideEffects && newFiber.alternate === null) {\n\t newFiber.effectTag = Placement;\n\t }\n\t return newFiber;\n\t }\n\t\n\t function updateTextNode(returnFiber, current, textContent, expirationTime) {\n\t if (current === null || current.tag !== HostText) {\n\t // Insert\n\t var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, textContent, expirationTime);\n\t existing.return = returnFiber;\n\t return existing;\n\t }\n\t }\n\t\n\t function updateElement(returnFiber, current, element, expirationTime) {\n\t if (current !== null && current.type === element.type) {\n\t // Move based on index\n\t var existing = useFiber(current, element.props, expirationTime);\n\t existing.ref = coerceRef(returnFiber, current, element);\n\t existing.return = returnFiber;\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\t return existing;\n\t } else {\n\t // Insert\n\t var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\t created.ref = coerceRef(returnFiber, current, element);\n\t created.return = returnFiber;\n\t return created;\n\t }\n\t }\n\t\n\t function updatePortal(returnFiber, current, portal, expirationTime) {\n\t if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n\t // Insert\n\t var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, portal.children || [], expirationTime);\n\t existing.return = returnFiber;\n\t return existing;\n\t }\n\t }\n\t\n\t function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n\t if (current === null || current.tag !== Fragment) {\n\t // Insert\n\t var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, fragment, expirationTime);\n\t existing.return = returnFiber;\n\t return existing;\n\t }\n\t }\n\t\n\t function createChild(returnFiber, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t }\n\t\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\t _created.ref = coerceRef(returnFiber, null, newChild);\n\t _created.return = returnFiber;\n\t return _created;\n\t }\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\t _created2.return = returnFiber;\n\t return _created2;\n\t }\n\t }\n\t\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\t _created3.return = returnFiber;\n\t return _created3;\n\t }\n\t\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\t\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\t\n\t return null;\n\t }\n\t\n\t function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n\t // Update the fiber if the keys match, otherwise return null.\n\t\n\t var key = oldFiber !== null ? oldFiber.key : null;\n\t\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t if (key !== null) {\n\t return null;\n\t }\n\t return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n\t }\n\t\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n\t }\n\t return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\t case REACT_PORTAL_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\t }\n\t\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t if (key !== null) {\n\t return null;\n\t }\n\t\n\t return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n\t }\n\t\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\t\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\t\n\t return null;\n\t }\n\t\n\t function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys, so we neither have to check the old nor\n\t // new node for the key. If both are text nodes, they match.\n\t var matchedFiber = existingChildren.get(newIdx) || null;\n\t return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n\t }\n\t\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n\t }\n\t return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n\t }\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\t return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n\t }\n\t }\n\t\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\t return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n\t }\n\t\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\t\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\t\n\t return null;\n\t }\n\t\n\t /**\n\t * Warns if there is a duplicate or missing key\n\t */\n\t function warnOnInvalidKey(child, knownKeys) {\n\t {\n\t if (typeof child !== 'object' || child === null) {\n\t return knownKeys;\n\t }\n\t switch (child.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t case REACT_PORTAL_TYPE:\n\t warnForMissingKey(child);\n\t var key = child.key;\n\t if (typeof key !== 'string') {\n\t break;\n\t }\n\t if (knownKeys === null) {\n\t knownKeys = new Set();\n\t knownKeys.add(key);\n\t break;\n\t }\n\t if (!knownKeys.has(key)) {\n\t knownKeys.add(key);\n\t break;\n\t }\n\t warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t return knownKeys;\n\t }\n\t\n\t function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n\t // This algorithm can't optimize by searching from boths ends since we\n\t // don't have backpointers on fibers. I'm trying to see how far we can get\n\t // with that model. If it ends up not being worth the tradeoffs, we can\n\t // add it later.\n\t\n\t // Even with a two ended optimization, we'd want to optimize for the case\n\t // where there are few changes and brute force the comparison instead of\n\t // going for the Map. It'd like to explore hitting that path first in\n\t // forward-only mode and only go for the Map once we notice that we need\n\t // lots of look ahead. This doesn't handle reversal as well as two ended\n\t // search but that's unusual. Besides, for the two ended optimization to\n\t // work on Iterables, we'd need to copy the whole set.\n\t\n\t // In this first iteration, we'll just live with hitting the bad case\n\t // (adding everything to a Map) in for every insert/move.\n\t\n\t // If you change this code, also update reconcileChildrenIterator() which\n\t // uses the same algorithm.\n\t\n\t {\n\t // First, validate keys.\n\t var knownKeys = null;\n\t for (var i = 0; i < newChildren.length; i++) {\n\t var child = newChildren[i];\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\t\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\t\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\t for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\t var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (oldFiber === null) {\n\t oldFiber = nextOldFiber;\n\t }\n\t break;\n\t }\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\t\n\t if (newIdx === newChildren.length) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\t\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\t if (!_newFiber) {\n\t continue;\n\t }\n\t lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber;\n\t } else {\n\t previousNewFiber.sibling = _newFiber;\n\t }\n\t previousNewFiber = _newFiber;\n\t }\n\t return resultingFirstChild;\n\t }\n\t\n\t // Add all children to a key map for quick lookups.\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\t\n\t // Keep scanning and use the map to restore deleted items as moves.\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\t if (_newFiber2) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber2.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber2;\n\t } else {\n\t previousNewFiber.sibling = _newFiber2;\n\t }\n\t previousNewFiber = _newFiber2;\n\t }\n\t }\n\t\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\t\n\t return resultingFirstChild;\n\t }\n\t\n\t function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n\t // This is the same implementation as reconcileChildrenArray(),\n\t // but using the iterator instead.\n\t\n\t var iteratorFn = getIteratorFn(newChildrenIterable);\n\t !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\t\n\t {\n\t // Warn about using Maps as children\n\t if (newChildrenIterable.entries === iteratorFn) {\n\t !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n\t didWarnAboutMaps = true;\n\t }\n\t\n\t // First, validate keys.\n\t // We'll get a different iterator later for the main pass.\n\t var _newChildren = iteratorFn.call(newChildrenIterable);\n\t if (_newChildren) {\n\t var knownKeys = null;\n\t var _step = _newChildren.next();\n\t for (; !_step.done; _step = _newChildren.next()) {\n\t var child = _step.value;\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\t }\n\t\n\t var newChildren = iteratorFn.call(newChildrenIterable);\n\t !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\t\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\t\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\t\n\t var step = newChildren.next();\n\t for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\t var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (!oldFiber) {\n\t oldFiber = nextOldFiber;\n\t }\n\t break;\n\t }\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\t\n\t if (step.done) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\t\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\t if (_newFiber3 === null) {\n\t continue;\n\t }\n\t lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber3;\n\t } else {\n\t previousNewFiber.sibling = _newFiber3;\n\t }\n\t previousNewFiber = _newFiber3;\n\t }\n\t return resultingFirstChild;\n\t }\n\t\n\t // Add all children to a key map for quick lookups.\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\t\n\t // Keep scanning and use the map to restore deleted items as moves.\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\t if (_newFiber4 !== null) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber4.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber4;\n\t } else {\n\t previousNewFiber.sibling = _newFiber4;\n\t }\n\t previousNewFiber = _newFiber4;\n\t }\n\t }\n\t\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\t\n\t return resultingFirstChild;\n\t }\n\t\n\t function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n\t // There's no need to check for keys on text nodes since we don't have a\n\t // way to define them.\n\t if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n\t // We already have an existing node so let's just update it and delete\n\t // the rest.\n\t deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n\t var existing = useFiber(currentFirstChild, textContent, expirationTime);\n\t existing.return = returnFiber;\n\t return existing;\n\t }\n\t // The existing first child is not a text node so we need to create one\n\t // and delete the existing ones.\n\t deleteRemainingChildren(returnFiber, currentFirstChild);\n\t var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t }\n\t\n\t function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n\t var key = element.key;\n\t var child = currentFirstChild;\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n\t existing.ref = coerceRef(returnFiber, child, element);\n\t existing.return = returnFiber;\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\t child = child.sibling;\n\t }\n\t\n\t if (element.type === REACT_FRAGMENT_TYPE) {\n\t var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\t _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n\t _created4.return = returnFiber;\n\t return _created4;\n\t }\n\t }\n\t\n\t function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n\t var key = portal.key;\n\t var child = currentFirstChild;\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, portal.children || [], expirationTime);\n\t existing.return = returnFiber;\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\t child = child.sibling;\n\t }\n\t\n\t var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t }\n\t\n\t // This API will tag the children with the side-effect of the reconciliation\n\t // itself. They will be added to the side-effect list as we pass through the\n\t // children and the parent.\n\t function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n\t // This function is not recursive.\n\t // If the top level item is an array, we treat it as a set of children,\n\t // not as a fragment. Nested arrays on the other hand will be treated as\n\t // fragment nodes. Recursion happens at the normal flow.\n\t\n\t // Handle top level unkeyed fragments as if they were arrays.\n\t // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n\t // We treat the ambiguous cases above the same.\n\t if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n\t newChild = newChild.props.children;\n\t }\n\t\n\t // Handle object types\n\t var isObject = typeof newChild === 'object' && newChild !== null;\n\t\n\t if (isObject) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\t case REACT_PORTAL_TYPE:\n\t return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n\t }\n\t }\n\t\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n\t }\n\t\n\t if (isArray$1(newChild)) {\n\t return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\t\n\t if (getIteratorFn(newChild)) {\n\t return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\t\n\t if (isObject) {\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\t\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\t if (typeof newChild === 'undefined') {\n\t // If the new child is undefined, and the return fiber is a composite\n\t // component, throw an error. If Fiber return types are disabled,\n\t // we already threw above.\n\t switch (returnFiber.tag) {\n\t case ClassComponent:\n\t {\n\t {\n\t var instance = returnFiber.stateNode;\n\t if (instance.render._isMockFunction) {\n\t // We allow auto-mocks to proceed as if they're returning null.\n\t break;\n\t }\n\t }\n\t }\n\t // Intentionally fall through to the next case, which handles both\n\t // functions and classes\n\t // eslint-disable-next-lined no-fallthrough\n\t case FunctionalComponent:\n\t {\n\t var Component = returnFiber.type;\n\t invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n\t }\n\t }\n\t }\n\t\n\t // Remaining cases are all treated as empty.\n\t return deleteRemainingChildren(returnFiber, currentFirstChild);\n\t }\n\t\n\t return reconcileChildFibers;\n\t}", "title": "" }, { "docid": "51135e1275dedd79e1dc60aef8801c5f", "score": "0.68905693", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect\n if (last !== null) {\n last.nextEffect = childToDelete\n returnFiber.lastEffect = childToDelete\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete\n }\n childToDelete.nextEffect = null\n childToDelete.effectTag = Deletion\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete)\n childToDelete = childToDelete.sibling\n }\n return null\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map()\n\n var existingChild = currentFirstChild\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild)\n } else {\n existingChildren.set(existingChild.index, existingChild)\n }\n existingChild = existingChild.sibling\n }\n return existingChildren\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime)\n clone.index = 0\n clone.sibling = null\n return clone\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex\n }\n var current$$1 = newFiber.alternate\n if (current$$1 !== null) {\n var oldIndex = current$$1.index\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement\n return lastPlacedIndex\n } else {\n // This item can stay in place.\n return oldIndex\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement\n return lastPlacedIndex\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement\n }\n return newFiber\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime)\n created.return = returnFiber\n return created\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime)\n existing.return = returnFiber\n return existing\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.type === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime)\n existing.ref = coerceRef(returnFiber, current$$1, element)\n existing.return = returnFiber\n {\n existing._debugSource = element._source\n existing._debugOwner = element._owner\n }\n return existing\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime)\n created.ref = coerceRef(returnFiber, current$$1, element)\n created.return = returnFiber\n return created\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (\n current$$1 === null ||\n current$$1.tag !== HostPortal ||\n current$$1.stateNode.containerInfo !== portal.containerInfo ||\n current$$1.stateNode.implementation !== portal.implementation\n ) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime)\n created.return = returnFiber\n return created\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime)\n existing.return = returnFiber\n return existing\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key)\n created.return = returnFiber\n return created\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime)\n existing.return = returnFiber\n return existing\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime)\n created.return = returnFiber\n return created\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE: {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime)\n _created.ref = coerceRef(returnFiber, null, newChild)\n _created.return = returnFiber\n return _created\n }\n case REACT_PORTAL_TYPE: {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime)\n _created2.return = returnFiber\n return _created2\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null)\n _created3.return = returnFiber\n return _created3\n }\n\n throwOnInvalidObjectType(returnFiber, newChild)\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType()\n }\n }\n\n return null\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime)\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE: {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key)\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime)\n } else {\n return null\n }\n }\n case REACT_PORTAL_TYPE: {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime)\n } else {\n return null\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null)\n }\n\n throwOnInvalidObjectType(returnFiber, newChild)\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType()\n }\n }\n\n return null\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime)\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE: {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(\n returnFiber,\n _matchedFiber,\n newChild.props.children,\n expirationTime,\n newChild.key,\n )\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime)\n }\n case REACT_PORTAL_TYPE: {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime)\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null)\n }\n\n throwOnInvalidObjectType(returnFiber, newChild)\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType()\n }\n }\n\n return null\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child)\n var key = child.key\n if (typeof key !== 'string') {\n break\n }\n if (knownKeys === null) {\n knownKeys = new Set()\n knownKeys.add(key)\n break\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key)\n break\n }\n warning$1(\n false,\n 'Encountered two children with the same key, `%s`. ' +\n 'Keys should be unique so that components maintain their identity ' +\n 'across updates. Non-unique keys may cause children to be ' +\n 'duplicated and/or omitted — the behavior is unsupported and ' +\n 'could change in a future version.',\n key,\n )\n break\n default:\n break\n }\n }\n return knownKeys\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i]\n knownKeys = warnOnInvalidKey(child, knownKeys)\n }\n }\n\n var resultingFirstChild = null\n var previousNewFiber = null\n\n var oldFiber = currentFirstChild\n var lastPlacedIndex = 0\n var newIdx = 0\n var nextOldFiber = null\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber\n oldFiber = null\n } else {\n nextOldFiber = oldFiber.sibling\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime)\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber\n }\n break\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber)\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx)\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber\n }\n previousNewFiber = newFiber\n oldFiber = nextOldFiber\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber)\n return resultingFirstChild\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime)\n if (!_newFiber) {\n continue\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx)\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber\n } else {\n previousNewFiber.sibling = _newFiber\n }\n previousNewFiber = _newFiber\n }\n return resultingFirstChild\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber)\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(\n existingChildren,\n returnFiber,\n newIdx,\n newChildren[newIdx],\n expirationTime,\n )\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key)\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx)\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2\n } else {\n previousNewFiber.sibling = _newFiber2\n }\n previousNewFiber = _newFiber2\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function(child) {\n return deleteChild(returnFiber, child)\n })\n }\n\n return resultingFirstChild\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable)\n !(typeof iteratorFn === 'function')\n ? invariant(\n false,\n 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.',\n )\n : void 0\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (\n typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator'\n ) {\n !didWarnAboutGenerators\n ? warning$1(\n false,\n 'Using Generators as children is unsupported and will likely yield ' +\n 'unexpected results because enumerating a generator mutates it. ' +\n 'You may convert it to an array with `Array.from()` or the ' +\n '`[...spread]` operator before rendering. Keep in mind ' +\n 'you might need to polyfill these features for older browsers.',\n )\n : void 0\n didWarnAboutGenerators = true\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps\n ? warning$1(\n false,\n 'Using Maps as children is unsupported and will likely yield ' +\n 'unexpected results. Convert it to a sequence/iterable of keyed ' +\n 'ReactElements instead.',\n )\n : void 0\n didWarnAboutMaps = true\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable)\n if (_newChildren) {\n var knownKeys = null\n var _step = _newChildren.next()\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value\n knownKeys = warnOnInvalidKey(child, knownKeys)\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable)\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0\n\n var resultingFirstChild = null\n var previousNewFiber = null\n\n var oldFiber = currentFirstChild\n var lastPlacedIndex = 0\n var newIdx = 0\n var nextOldFiber = null\n\n var step = newChildren.next()\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber\n oldFiber = null\n } else {\n nextOldFiber = oldFiber.sibling\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime)\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber\n }\n break\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber)\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx)\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber\n }\n previousNewFiber = newFiber\n oldFiber = nextOldFiber\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber)\n return resultingFirstChild\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime)\n if (_newFiber3 === null) {\n continue\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx)\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3\n } else {\n previousNewFiber.sibling = _newFiber3\n }\n previousNewFiber = _newFiber3\n }\n return resultingFirstChild\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber)\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime)\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key)\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx)\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4\n } else {\n previousNewFiber.sibling = _newFiber4\n }\n previousNewFiber = _newFiber4\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function(child) {\n return deleteChild(returnFiber, child)\n })\n }\n\n return resultingFirstChild\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling)\n var existing = useFiber(currentFirstChild, textContent, expirationTime)\n existing.return = returnFiber\n return existing\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild)\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime)\n created.return = returnFiber\n return created\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key\n var child = currentFirstChild\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling)\n var existing = useFiber(\n child,\n element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props,\n expirationTime,\n )\n existing.ref = coerceRef(returnFiber, child, element)\n existing.return = returnFiber\n {\n existing._debugSource = element._source\n existing._debugOwner = element._owner\n }\n return existing\n } else {\n deleteRemainingChildren(returnFiber, child)\n break\n }\n } else {\n deleteChild(returnFiber, child)\n }\n child = child.sibling\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(\n element.props.children,\n returnFiber.mode,\n expirationTime,\n element.key,\n )\n created.return = returnFiber\n return created\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime)\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element)\n _created4.return = returnFiber\n return _created4\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key\n var child = currentFirstChild\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (\n child.tag === HostPortal &&\n child.stateNode.containerInfo === portal.containerInfo &&\n child.stateNode.implementation === portal.implementation\n ) {\n deleteRemainingChildren(returnFiber, child.sibling)\n var existing = useFiber(child, portal.children || [], expirationTime)\n existing.return = returnFiber\n return existing\n } else {\n deleteRemainingChildren(returnFiber, child)\n break\n }\n } else {\n deleteChild(returnFiber, child)\n }\n child = child.sibling\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime)\n created.return = returnFiber\n return created\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment =\n typeof newChild === 'object' &&\n newChild !== null &&\n newChild.type === REACT_FRAGMENT_TYPE &&\n newChild.key === null\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(\n reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime),\n )\n case REACT_PORTAL_TYPE:\n return placeSingleChild(\n reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime),\n )\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(\n reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime),\n )\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime)\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime)\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild)\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType()\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n case ClassComponentLazy: {\n {\n var instance = returnFiber.stateNode\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent: {\n var Component = returnFiber.type\n invariant(\n false,\n '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.',\n Component.displayName || Component.name || 'Component',\n )\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild)\n }\n\n return reconcileChildFibers\n }", "title": "" }, { "docid": "fb097c95b3351435c860bdf8a545aff5", "score": "0.6876709", "text": "function ChildReconciler(shouldTrackSideEffects) {\n\t function deleteChild(returnFiber, childToDelete) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return;\n\t }\n\t // Deletions are added in reversed order so we add it to the front.\n\t // At this point, the return fiber's effect list is empty except for\n\t // deletions, so we can just append the deletion to the list. The remaining\n\t // effects aren't added until the complete phase. Once we implement\n\t // resuming, this may not be true.\n\t var last = returnFiber.lastEffect;\n\t if (last !== null) {\n\t last.nextEffect = childToDelete;\n\t returnFiber.lastEffect = childToDelete;\n\t } else {\n\t returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n\t }\n\t childToDelete.nextEffect = null;\n\t childToDelete.effectTag = Deletion;\n\t }\n\n\t function deleteRemainingChildren(returnFiber, currentFirstChild) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return null;\n\t }\n\n\t // TODO: For the shouldClone case, this could be micro-optimized a bit by\n\t // assuming that after the first child we've already added everything.\n\t var childToDelete = currentFirstChild;\n\t while (childToDelete !== null) {\n\t deleteChild(returnFiber, childToDelete);\n\t childToDelete = childToDelete.sibling;\n\t }\n\t return null;\n\t }\n\n\t function mapRemainingChildren(returnFiber, currentFirstChild) {\n\t // Add the remaining children to a temporary map so that we can find them by\n\t // keys quickly. Implicit (null) keys get added to this set with their index\n\t var existingChildren = new Map();\n\n\t var existingChild = currentFirstChild;\n\t while (existingChild !== null) {\n\t if (existingChild.key !== null) {\n\t existingChildren.set(existingChild.key, existingChild);\n\t } else {\n\t existingChildren.set(existingChild.index, existingChild);\n\t }\n\t existingChild = existingChild.sibling;\n\t }\n\t return existingChildren;\n\t }\n\n\t function useFiber(fiber, pendingProps, expirationTime) {\n\t // We currently set sibling to null and index to 0 here because it is easy\n\t // to forget to do before returning it. E.g. for the single child case.\n\t var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n\t clone.index = 0;\n\t clone.sibling = null;\n\t return clone;\n\t }\n\n\t function placeChild(newFiber, lastPlacedIndex, newIndex) {\n\t newFiber.index = newIndex;\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return lastPlacedIndex;\n\t }\n\t var current = newFiber.alternate;\n\t if (current !== null) {\n\t var oldIndex = current.index;\n\t if (oldIndex < lastPlacedIndex) {\n\t // This is a move.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t } else {\n\t // This item can stay in place.\n\t return oldIndex;\n\t }\n\t } else {\n\t // This is an insertion.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t }\n\t }\n\n\t function placeSingleChild(newFiber) {\n\t // This is simpler for the single child case. We only need to do a\n\t // placement for inserting new children.\n\t if (shouldTrackSideEffects && newFiber.alternate === null) {\n\t newFiber.effectTag = Placement;\n\t }\n\t return newFiber;\n\t }\n\n\t function updateTextNode(returnFiber, current, textContent, expirationTime) {\n\t if (current === null || current.tag !== HostText) {\n\t // Insert\n\t var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, textContent, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updateElement(returnFiber, current, element, expirationTime) {\n\t if (current !== null && current.type === element.type) {\n\t // Move based on index\n\t var existing = useFiber(current, element.props, expirationTime);\n\t existing.ref = coerceRef(returnFiber, current, element);\n\t existing['return'] = returnFiber;\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\t return existing;\n\t } else {\n\t // Insert\n\t var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\t created.ref = coerceRef(returnFiber, current, element);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\t }\n\n\t function updatePortal(returnFiber, current, portal, expirationTime) {\n\t if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n\t // Insert\n\t var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, portal.children || [], expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n\t if (current === null || current.tag !== Fragment) {\n\t // Insert\n\t var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, fragment, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function createChild(returnFiber, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\t _created.ref = coerceRef(returnFiber, null, newChild);\n\t _created['return'] = returnFiber;\n\t return _created;\n\t }\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\t _created2['return'] = returnFiber;\n\t return _created2;\n\t }\n\t }\n\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\t _created3['return'] = returnFiber;\n\t return _created3;\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n\t // Update the fiber if the keys match, otherwise return null.\n\n\t var key = oldFiber !== null ? oldFiber.key : null;\n\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t if (key !== null) {\n\t return null;\n\t }\n\t return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n\t }\n\t return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\t case REACT_PORTAL_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\t }\n\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t if (key !== null) {\n\t return null;\n\t }\n\n\t return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys, so we neither have to check the old nor\n\t // new node for the key. If both are text nodes, they match.\n\t var matchedFiber = existingChildren.get(newIdx) || null;\n\t return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n\t }\n\t return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n\t }\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\t return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n\t }\n\t }\n\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\t return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t /**\n\t * Warns if there is a duplicate or missing key\n\t */\n\t function warnOnInvalidKey(child, knownKeys) {\n\t {\n\t if (typeof child !== 'object' || child === null) {\n\t return knownKeys;\n\t }\n\t switch (child.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t case REACT_PORTAL_TYPE:\n\t warnForMissingKey(child);\n\t var key = child.key;\n\t if (typeof key !== 'string') {\n\t break;\n\t }\n\t if (knownKeys === null) {\n\t knownKeys = new Set();\n\t knownKeys.add(key);\n\t break;\n\t }\n\t if (!knownKeys.has(key)) {\n\t knownKeys.add(key);\n\t break;\n\t }\n\t warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$2());\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t return knownKeys;\n\t }\n\n\t function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n\t // This algorithm can't optimize by searching from boths ends since we\n\t // don't have backpointers on fibers. I'm trying to see how far we can get\n\t // with that model. If it ends up not being worth the tradeoffs, we can\n\t // add it later.\n\n\t // Even with a two ended optimization, we'd want to optimize for the case\n\t // where there are few changes and brute force the comparison instead of\n\t // going for the Map. It'd like to explore hitting that path first in\n\t // forward-only mode and only go for the Map once we notice that we need\n\t // lots of look ahead. This doesn't handle reversal as well as two ended\n\t // search but that's unusual. Besides, for the two ended optimization to\n\t // work on Iterables, we'd need to copy the whole set.\n\n\t // In this first iteration, we'll just live with hitting the bad case\n\t // (adding everything to a Map) in for every insert/move.\n\n\t // If you change this code, also update reconcileChildrenIterator() which\n\t // uses the same algorithm.\n\n\t {\n\t // First, validate keys.\n\t var knownKeys = null;\n\t for (var i = 0; i < newChildren.length; i++) {\n\t var child = newChildren[i];\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\t for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\t var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (oldFiber === null) {\n\t oldFiber = nextOldFiber;\n\t }\n\t break;\n\t }\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\n\t if (newIdx === newChildren.length) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\t if (!_newFiber) {\n\t continue;\n\t }\n\t lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber;\n\t } else {\n\t previousNewFiber.sibling = _newFiber;\n\t }\n\t previousNewFiber = _newFiber;\n\t }\n\t return resultingFirstChild;\n\t }\n\n\t // Add all children to a key map for quick lookups.\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n\t // Keep scanning and use the map to restore deleted items as moves.\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\t if (_newFiber2) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber2.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber2;\n\t } else {\n\t previousNewFiber.sibling = _newFiber2;\n\t }\n\t previousNewFiber = _newFiber2;\n\t }\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\n\t return resultingFirstChild;\n\t }\n\n\t function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n\t // This is the same implementation as reconcileChildrenArray(),\n\t // but using the iterator instead.\n\n\t var iteratorFn = getIteratorFn(newChildrenIterable);\n\t !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n\t {\n\t // Warn about using Maps as children\n\t if (typeof newChildrenIterable.entries === 'function') {\n\t var possibleMap = newChildrenIterable;\n\t if (possibleMap.entries === iteratorFn) {\n\t !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2()) : void 0;\n\t didWarnAboutMaps = true;\n\t }\n\t }\n\n\t // First, validate keys.\n\t // We'll get a different iterator later for the main pass.\n\t var _newChildren = iteratorFn.call(newChildrenIterable);\n\t if (_newChildren) {\n\t var knownKeys = null;\n\t var _step = _newChildren.next();\n\t for (; !_step.done; _step = _newChildren.next()) {\n\t var child = _step.value;\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\t }\n\n\t var newChildren = iteratorFn.call(newChildrenIterable);\n\t !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\n\t var step = newChildren.next();\n\t for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\t var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (!oldFiber) {\n\t oldFiber = nextOldFiber;\n\t }\n\t break;\n\t }\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\n\t if (step.done) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\t if (_newFiber3 === null) {\n\t continue;\n\t }\n\t lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber3;\n\t } else {\n\t previousNewFiber.sibling = _newFiber3;\n\t }\n\t previousNewFiber = _newFiber3;\n\t }\n\t return resultingFirstChild;\n\t }\n\n\t // Add all children to a key map for quick lookups.\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n\t // Keep scanning and use the map to restore deleted items as moves.\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\t if (_newFiber4 !== null) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber4.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber4;\n\t } else {\n\t previousNewFiber.sibling = _newFiber4;\n\t }\n\t previousNewFiber = _newFiber4;\n\t }\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\n\t return resultingFirstChild;\n\t }\n\n\t function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n\t // There's no need to check for keys on text nodes since we don't have a\n\t // way to define them.\n\t if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n\t // We already have an existing node so let's just update it and delete\n\t // the rest.\n\t deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n\t var existing = useFiber(currentFirstChild, textContent, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t // The existing first child is not a text node so we need to create one\n\t // and delete the existing ones.\n\t deleteRemainingChildren(returnFiber, currentFirstChild);\n\t var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n\t var key = element.key;\n\t var child = currentFirstChild;\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n\t existing.ref = coerceRef(returnFiber, child, element);\n\t existing['return'] = returnFiber;\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\t child = child.sibling;\n\t }\n\n\t if (element.type === REACT_FRAGMENT_TYPE) {\n\t var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\t _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n\t _created4['return'] = returnFiber;\n\t return _created4;\n\t }\n\t }\n\n\t function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n\t var key = portal.key;\n\t var child = currentFirstChild;\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, portal.children || [], expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\t child = child.sibling;\n\t }\n\n\t var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t // This API will tag the children with the side-effect of the reconciliation\n\t // itself. They will be added to the side-effect list as we pass through the\n\t // children and the parent.\n\t function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n\t // This function is not recursive.\n\t // If the top level item is an array, we treat it as a set of children,\n\t // not as a fragment. Nested arrays on the other hand will be treated as\n\t // fragment nodes. Recursion happens at the normal flow.\n\n\t // Handle top level unkeyed fragments as if they were arrays.\n\t // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n\t // We treat the ambiguous cases above the same.\n\t if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n\t newChild = newChild.props.children;\n\t }\n\n\t // Handle object types\n\t var isObject = typeof newChild === 'object' && newChild !== null;\n\n\t if (isObject) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\t case REACT_PORTAL_TYPE:\n\t return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n\t }\n\t }\n\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n\t }\n\n\t if (isArray$1(newChild)) {\n\t return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\n\t if (getIteratorFn(newChild)) {\n\t return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\n\t if (isObject) {\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\t if (typeof newChild === 'undefined') {\n\t // If the new child is undefined, and the return fiber is a composite\n\t // component, throw an error. If Fiber return types are disabled,\n\t // we already threw above.\n\t switch (returnFiber.tag) {\n\t case ClassComponent:\n\t {\n\t {\n\t var instance = returnFiber.stateNode;\n\t if (instance.render._isMockFunction) {\n\t // We allow auto-mocks to proceed as if they're returning null.\n\t break;\n\t }\n\t }\n\t }\n\t // Intentionally fall through to the next case, which handles both\n\t // functions and classes\n\t // eslint-disable-next-lined no-fallthrough\n\t case FunctionalComponent:\n\t {\n\t var Component = returnFiber.type;\n\t invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n\t }\n\t }\n\t }\n\n\t // Remaining cases are all treated as empty.\n\t return deleteRemainingChildren(returnFiber, currentFirstChild);\n\t }\n\n\t return reconcileChildFibers;\n\t}", "title": "" }, { "docid": "da58563fdfd050aedd9329f36b4f4c6b", "score": "0.6876709", "text": "function ChildReconciler(shouldTrackSideEffects) {\n\t function deleteChild(returnFiber, childToDelete) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return;\n\t }\n\t // Deletions are added in reversed order so we add it to the front.\n\t // At this point, the return fiber's effect list is empty except for\n\t // deletions, so we can just append the deletion to the list. The remaining\n\t // effects aren't added until the complete phase. Once we implement\n\t // resuming, this may not be true.\n\t var last = returnFiber.lastEffect;\n\t if (last !== null) {\n\t last.nextEffect = childToDelete;\n\t returnFiber.lastEffect = childToDelete;\n\t } else {\n\t returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n\t }\n\t childToDelete.nextEffect = null;\n\t childToDelete.effectTag = Deletion;\n\t }\n\n\t function deleteRemainingChildren(returnFiber, currentFirstChild) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return null;\n\t }\n\n\t // TODO: For the shouldClone case, this could be micro-optimized a bit by\n\t // assuming that after the first child we've already added everything.\n\t var childToDelete = currentFirstChild;\n\t while (childToDelete !== null) {\n\t deleteChild(returnFiber, childToDelete);\n\t childToDelete = childToDelete.sibling;\n\t }\n\t return null;\n\t }\n\n\t function mapRemainingChildren(returnFiber, currentFirstChild) {\n\t // Add the remaining children to a temporary map so that we can find them by\n\t // keys quickly. Implicit (null) keys get added to this set with their index\n\t var existingChildren = new Map();\n\n\t var existingChild = currentFirstChild;\n\t while (existingChild !== null) {\n\t if (existingChild.key !== null) {\n\t existingChildren.set(existingChild.key, existingChild);\n\t } else {\n\t existingChildren.set(existingChild.index, existingChild);\n\t }\n\t existingChild = existingChild.sibling;\n\t }\n\t return existingChildren;\n\t }\n\n\t function useFiber(fiber, pendingProps, expirationTime) {\n\t // We currently set sibling to null and index to 0 here because it is easy\n\t // to forget to do before returning it. E.g. for the single child case.\n\t var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n\t clone.index = 0;\n\t clone.sibling = null;\n\t return clone;\n\t }\n\n\t function placeChild(newFiber, lastPlacedIndex, newIndex) {\n\t newFiber.index = newIndex;\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return lastPlacedIndex;\n\t }\n\t var current = newFiber.alternate;\n\t if (current !== null) {\n\t var oldIndex = current.index;\n\t if (oldIndex < lastPlacedIndex) {\n\t // This is a move.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t } else {\n\t // This item can stay in place.\n\t return oldIndex;\n\t }\n\t } else {\n\t // This is an insertion.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t }\n\t }\n\n\t function placeSingleChild(newFiber) {\n\t // This is simpler for the single child case. We only need to do a\n\t // placement for inserting new children.\n\t if (shouldTrackSideEffects && newFiber.alternate === null) {\n\t newFiber.effectTag = Placement;\n\t }\n\t return newFiber;\n\t }\n\n\t function updateTextNode(returnFiber, current, textContent, expirationTime) {\n\t if (current === null || current.tag !== HostText) {\n\t // Insert\n\t var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, textContent, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updateElement(returnFiber, current, element, expirationTime) {\n\t if (current !== null && current.type === element.type) {\n\t // Move based on index\n\t var existing = useFiber(current, element.props, expirationTime);\n\t existing.ref = coerceRef(current, element);\n\t existing['return'] = returnFiber;\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\t return existing;\n\t } else {\n\t // Insert\n\t var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n\t created.ref = coerceRef(current, element);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\t }\n\n\t function updateCall(returnFiber, current, call, expirationTime) {\n\t // TODO: Should this also compare handler to determine whether to reuse?\n\t if (current === null || current.tag !== CallComponent) {\n\t // Insert\n\t var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Move based on index\n\t var existing = useFiber(current, call, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updateReturn(returnFiber, current, returnNode, expirationTime) {\n\t if (current === null || current.tag !== ReturnComponent) {\n\t // Insert\n\t var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n\t created.type = returnNode.value;\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Move based on index\n\t var existing = useFiber(current, null, expirationTime);\n\t existing.type = returnNode.value;\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updatePortal(returnFiber, current, portal, expirationTime) {\n\t if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n\t // Insert\n\t var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, portal.children || [], expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n\t if (current === null || current.tag !== Fragment) {\n\t // Insert\n\t var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current, fragment, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function createChild(returnFiber, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n\t _created['return'] = returnFiber;\n\t return _created;\n\t } else {\n\t var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n\t _created2.ref = coerceRef(null, newChild);\n\t _created2['return'] = returnFiber;\n\t return _created2;\n\t }\n\t }\n\n\t case REACT_CALL_TYPE:\n\t {\n\t var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n\t _created3['return'] = returnFiber;\n\t return _created3;\n\t }\n\n\t case REACT_RETURN_TYPE:\n\t {\n\t var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n\t _created4.type = newChild.value;\n\t _created4['return'] = returnFiber;\n\t return _created4;\n\t }\n\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n\t _created5['return'] = returnFiber;\n\t return _created5;\n\t }\n\t }\n\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n\t _created6['return'] = returnFiber;\n\t return _created6;\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n\t // Update the fiber if the keys match, otherwise return null.\n\n\t var key = oldFiber !== null ? oldFiber.key : null;\n\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t if (key !== null) {\n\t return null;\n\t }\n\t return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n\t }\n\t return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\n\t case REACT_CALL_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\n\t case REACT_RETURN_TYPE:\n\t {\n\t // Returns don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a\n\t // yield.\n\t if (key === null) {\n\t return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\n\t case REACT_PORTAL_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\t }\n\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t if (key !== null) {\n\t return null;\n\t }\n\n\t return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys, so we neither have to check the old nor\n\t // new node for the key. If both are text nodes, they match.\n\t var matchedFiber = existingChildren.get(newIdx) || null;\n\t return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n\t }\n\t return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n\t }\n\n\t case REACT_CALL_TYPE:\n\t {\n\t var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\t return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n\t }\n\n\t case REACT_RETURN_TYPE:\n\t {\n\t // Returns don't have keys, so we neither have to check the old nor\n\t // new node for the key. If both are returns, they match.\n\t var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\t return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n\t }\n\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\t return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n\t }\n\t }\n\n\t if (isArray$1(newChild) || getIteratorFn(newChild)) {\n\t var _matchedFiber5 = existingChildren.get(newIdx) || null;\n\t return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t /**\n\t * Warns if there is a duplicate or missing key\n\t */\n\t function warnOnInvalidKey(child, knownKeys) {\n\t {\n\t if (typeof child !== 'object' || child === null) {\n\t return knownKeys;\n\t }\n\t switch (child.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t case REACT_CALL_TYPE:\n\t case REACT_PORTAL_TYPE:\n\t warnForMissingKey(child);\n\t var key = child.key;\n\t if (typeof key !== 'string') {\n\t break;\n\t }\n\t if (knownKeys === null) {\n\t knownKeys = new Set();\n\t knownKeys.add(key);\n\t break;\n\t }\n\t if (!knownKeys.has(key)) {\n\t knownKeys.add(key);\n\t break;\n\t }\n\t warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n\t break;\n\t default:\n\t break;\n\t }\n\t }\n\t return knownKeys;\n\t }\n\n\t function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n\t // This algorithm can't optimize by searching from boths ends since we\n\t // don't have backpointers on fibers. I'm trying to see how far we can get\n\t // with that model. If it ends up not being worth the tradeoffs, we can\n\t // add it later.\n\n\t // Even with a two ended optimization, we'd want to optimize for the case\n\t // where there are few changes and brute force the comparison instead of\n\t // going for the Map. It'd like to explore hitting that path first in\n\t // forward-only mode and only go for the Map once we notice that we need\n\t // lots of look ahead. This doesn't handle reversal as well as two ended\n\t // search but that's unusual. Besides, for the two ended optimization to\n\t // work on Iterables, we'd need to copy the whole set.\n\n\t // In this first iteration, we'll just live with hitting the bad case\n\t // (adding everything to a Map) in for every insert/move.\n\n\t // If you change this code, also update reconcileChildrenIterator() which\n\t // uses the same algorithm.\n\n\t {\n\t // First, validate keys.\n\t var knownKeys = null;\n\t for (var i = 0; i < newChildren.length; i++) {\n\t var child = newChildren[i];\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\t for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\t var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (oldFiber === null) {\n\t oldFiber = nextOldFiber;\n\t }\n\t break;\n\t }\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\n\t if (newIdx === newChildren.length) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\t if (!_newFiber) {\n\t continue;\n\t }\n\t lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber;\n\t } else {\n\t previousNewFiber.sibling = _newFiber;\n\t }\n\t previousNewFiber = _newFiber;\n\t }\n\t return resultingFirstChild;\n\t }\n\n\t // Add all children to a key map for quick lookups.\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n\t // Keep scanning and use the map to restore deleted items as moves.\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\t if (_newFiber2) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber2.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber2;\n\t } else {\n\t previousNewFiber.sibling = _newFiber2;\n\t }\n\t previousNewFiber = _newFiber2;\n\t }\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\n\t return resultingFirstChild;\n\t }\n\n\t function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n\t // This is the same implementation as reconcileChildrenArray(),\n\t // but using the iterator instead.\n\n\t var iteratorFn = getIteratorFn(newChildrenIterable);\n\t !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n\t {\n\t // Warn about using Maps as children\n\t if (typeof newChildrenIterable.entries === 'function') {\n\t var possibleMap = newChildrenIterable;\n\t if (possibleMap.entries === iteratorFn) {\n\t warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n\t didWarnAboutMaps = true;\n\t }\n\t }\n\n\t // First, validate keys.\n\t // We'll get a different iterator later for the main pass.\n\t var _newChildren = iteratorFn.call(newChildrenIterable);\n\t if (_newChildren) {\n\t var knownKeys = null;\n\t var _step = _newChildren.next();\n\t for (; !_step.done; _step = _newChildren.next()) {\n\t var child = _step.value;\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\t }\n\n\t var newChildren = iteratorFn.call(newChildrenIterable);\n\t !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\n\t var step = newChildren.next();\n\t for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\t var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (!oldFiber) {\n\t oldFiber = nextOldFiber;\n\t }\n\t break;\n\t }\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\n\t if (step.done) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\t if (_newFiber3 === null) {\n\t continue;\n\t }\n\t lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber3;\n\t } else {\n\t previousNewFiber.sibling = _newFiber3;\n\t }\n\t previousNewFiber = _newFiber3;\n\t }\n\t return resultingFirstChild;\n\t }\n\n\t // Add all children to a key map for quick lookups.\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n\t // Keep scanning and use the map to restore deleted items as moves.\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\t if (_newFiber4 !== null) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber4.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n\t }\n\t }\n\t lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber4;\n\t } else {\n\t previousNewFiber.sibling = _newFiber4;\n\t }\n\t previousNewFiber = _newFiber4;\n\t }\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\n\t return resultingFirstChild;\n\t }\n\n\t function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n\t // There's no need to check for keys on text nodes since we don't have a\n\t // way to define them.\n\t if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n\t // We already have an existing node so let's just update it and delete\n\t // the rest.\n\t deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n\t var existing = useFiber(currentFirstChild, textContent, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t }\n\t // The existing first child is not a text node so we need to create one\n\t // and delete the existing ones.\n\t deleteRemainingChildren(returnFiber, currentFirstChild);\n\t var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n\t var key = element.key;\n\t var child = currentFirstChild;\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n\t existing.ref = coerceRef(child, element);\n\t existing['return'] = returnFiber;\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\t child = child.sibling;\n\t }\n\n\t if (element.type === REACT_FRAGMENT_TYPE) {\n\t var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n\t created['return'] = returnFiber;\n\t return created;\n\t } else {\n\t var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n\t _created7.ref = coerceRef(currentFirstChild, element);\n\t _created7['return'] = returnFiber;\n\t return _created7;\n\t }\n\t }\n\n\t function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n\t var key = call.key;\n\t var child = currentFirstChild;\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === CallComponent) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, call, expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\t child = child.sibling;\n\t }\n\n\t var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n\t // There's no need to check for keys on yields since they're stateless.\n\t var child = currentFirstChild;\n\t if (child !== null) {\n\t if (child.tag === ReturnComponent) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, null, expirationTime);\n\t existing.type = returnNode.value;\n\t existing['return'] = returnFiber;\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t }\n\t }\n\n\t var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n\t created.type = returnNode.value;\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n\t var key = portal.key;\n\t var child = currentFirstChild;\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, portal.children || [], expirationTime);\n\t existing['return'] = returnFiber;\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\t child = child.sibling;\n\t }\n\n\t var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n\t created['return'] = returnFiber;\n\t return created;\n\t }\n\n\t // This API will tag the children with the side-effect of the reconciliation\n\t // itself. They will be added to the side-effect list as we pass through the\n\t // children and the parent.\n\t function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n\t // This function is not recursive.\n\t // If the top level item is an array, we treat it as a set of children,\n\t // not as a fragment. Nested arrays on the other hand will be treated as\n\t // fragment nodes. Recursion happens at the normal flow.\n\n\t // Handle top level unkeyed fragments as if they were arrays.\n\t // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n\t // We treat the ambiguous cases above the same.\n\t if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n\t newChild = newChild.props.children;\n\t }\n\n\t // Handle object types\n\t var isObject = typeof newChild === 'object' && newChild !== null;\n\n\t if (isObject) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n\t case REACT_CALL_TYPE:\n\t return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n\t case REACT_RETURN_TYPE:\n\t return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n\t case REACT_PORTAL_TYPE:\n\t return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n\t }\n\t }\n\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n\t }\n\n\t if (isArray$1(newChild)) {\n\t return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\n\t if (getIteratorFn(newChild)) {\n\t return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\n\t if (isObject) {\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\t if (typeof newChild === 'undefined') {\n\t // If the new child is undefined, and the return fiber is a composite\n\t // component, throw an error. If Fiber return types are disabled,\n\t // we already threw above.\n\t switch (returnFiber.tag) {\n\t case ClassComponent:\n\t {\n\t {\n\t var instance = returnFiber.stateNode;\n\t if (instance.render._isMockFunction) {\n\t // We allow auto-mocks to proceed as if they're returning null.\n\t break;\n\t }\n\t }\n\t }\n\t // Intentionally fall through to the next case, which handles both\n\t // functions and classes\n\t // eslint-disable-next-lined no-fallthrough\n\t case FunctionalComponent:\n\t {\n\t var Component = returnFiber.type;\n\t invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n\t }\n\t }\n\t }\n\n\t // Remaining cases are all treated as empty.\n\t return deleteRemainingChildren(returnFiber, currentFirstChild);\n\t }\n\n\t return reconcileChildFibers;\n\t}", "title": "" }, { "docid": "2e015823ab3d3bd54c8ad49471debce1", "score": "0.68522155", "text": "function ChildReconciler(shouldTrackSideEffects) {\n\t function deleteChild(returnFiber, childToDelete) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return;\n\t } // Deletions are added in reversed order so we add it to the front.\n\t // At this point, the return fiber's effect list is empty except for\n\t // deletions, so we can just append the deletion to the list. The remaining\n\t // effects aren't added until the complete phase. Once we implement\n\t // resuming, this may not be true.\n\n\n\t var last = returnFiber.lastEffect;\n\n\t if (last !== null) {\n\t last.nextEffect = childToDelete;\n\t returnFiber.lastEffect = childToDelete;\n\t } else {\n\t returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n\t }\n\n\t childToDelete.nextEffect = null;\n\t childToDelete.effectTag = Deletion;\n\t }\n\n\t function deleteRemainingChildren(returnFiber, currentFirstChild) {\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return null;\n\t } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n\t // assuming that after the first child we've already added everything.\n\n\n\t var childToDelete = currentFirstChild;\n\n\t while (childToDelete !== null) {\n\t deleteChild(returnFiber, childToDelete);\n\t childToDelete = childToDelete.sibling;\n\t }\n\n\t return null;\n\t }\n\n\t function mapRemainingChildren(returnFiber, currentFirstChild) {\n\t // Add the remaining children to a temporary map so that we can find them by\n\t // keys quickly. Implicit (null) keys get added to this set with their index\n\t // instead.\n\t var existingChildren = new Map();\n\t var existingChild = currentFirstChild;\n\n\t while (existingChild !== null) {\n\t if (existingChild.key !== null) {\n\t existingChildren.set(existingChild.key, existingChild);\n\t } else {\n\t existingChildren.set(existingChild.index, existingChild);\n\t }\n\n\t existingChild = existingChild.sibling;\n\t }\n\n\t return existingChildren;\n\t }\n\n\t function useFiber(fiber, pendingProps, expirationTime) {\n\t // We currently set sibling to null and index to 0 here because it is easy\n\t // to forget to do before returning it. E.g. for the single child case.\n\t var clone = createWorkInProgress(fiber, pendingProps);\n\t clone.index = 0;\n\t clone.sibling = null;\n\t return clone;\n\t }\n\n\t function placeChild(newFiber, lastPlacedIndex, newIndex) {\n\t newFiber.index = newIndex;\n\n\t if (!shouldTrackSideEffects) {\n\t // Noop.\n\t return lastPlacedIndex;\n\t }\n\n\t var current$$1 = newFiber.alternate;\n\n\t if (current$$1 !== null) {\n\t var oldIndex = current$$1.index;\n\n\t if (oldIndex < lastPlacedIndex) {\n\t // This is a move.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t } else {\n\t // This item can stay in place.\n\t return oldIndex;\n\t }\n\t } else {\n\t // This is an insertion.\n\t newFiber.effectTag = Placement;\n\t return lastPlacedIndex;\n\t }\n\t }\n\n\t function placeSingleChild(newFiber) {\n\t // This is simpler for the single child case. We only need to do a\n\t // placement for inserting new children.\n\t if (shouldTrackSideEffects && newFiber.alternate === null) {\n\t newFiber.effectTag = Placement;\n\t }\n\n\t return newFiber;\n\t }\n\n\t function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n\t if (current$$1 === null || current$$1.tag !== HostText) {\n\t // Insert\n\t var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current$$1, textContent);\n\t existing.return = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updateElement(returnFiber, current$$1, element, expirationTime) {\n\t if (current$$1 !== null && (current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n\t isCompatibleFamilyForHotReloading(current$$1, element)))) {\n\t // Move based on index\n\t var existing = useFiber(current$$1, element.props);\n\t existing.ref = coerceRef(returnFiber, current$$1, element);\n\t existing.return = returnFiber;\n\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\n\t return existing;\n\t } else {\n\t // Insert\n\t var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\t created.ref = coerceRef(returnFiber, current$$1, element);\n\t created.return = returnFiber;\n\t return created;\n\t }\n\t }\n\n\t function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n\t if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n\t // Insert\n\t var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current$$1, portal.children || []);\n\t existing.return = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n\t if (current$$1 === null || current$$1.tag !== Fragment) {\n\t // Insert\n\t var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t // Update\n\t var existing = useFiber(current$$1, fragment);\n\t existing.return = returnFiber;\n\t return existing;\n\t }\n\t }\n\n\t function createChild(returnFiber, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n\t _created.ref = coerceRef(returnFiber, null, newChild);\n\t _created.return = returnFiber;\n\t return _created;\n\t }\n\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n\t _created2.return = returnFiber;\n\t return _created2;\n\t }\n\t }\n\n\t if (isArray(newChild) || getIteratorFn(newChild)) {\n\t var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n\t _created3.return = returnFiber;\n\t return _created3;\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n\t // Update the fiber if the keys match, otherwise return null.\n\t var key = oldFiber !== null ? oldFiber.key : null;\n\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys. If the previous node is implicitly keyed\n\t // we can continue to replace it without aborting even if it is not a text\n\t // node.\n\t if (key !== null) {\n\t return null;\n\t }\n\n\t return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n\t }\n\n\t return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\n\t case REACT_PORTAL_TYPE:\n\t {\n\t if (newChild.key === key) {\n\t return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n\t } else {\n\t return null;\n\t }\n\t }\n\t }\n\n\t if (isArray(newChild) || getIteratorFn(newChild)) {\n\t if (key !== null) {\n\t return null;\n\t }\n\n\t return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\n\t function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t // Text nodes don't have keys, so we neither have to check the old nor\n\t // new node for the key. If both are text nodes, they match.\n\t var matchedFiber = existingChildren.get(newIdx) || null;\n\t return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n\t }\n\n\t if (typeof newChild === 'object' && newChild !== null) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t {\n\t var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n\t if (newChild.type === REACT_FRAGMENT_TYPE) {\n\t return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n\t }\n\n\t return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n\t }\n\n\t case REACT_PORTAL_TYPE:\n\t {\n\t var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n\t return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n\t }\n\t }\n\n\t if (isArray(newChild) || getIteratorFn(newChild)) {\n\t var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n\t return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n\t }\n\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t return null;\n\t }\n\t /**\n\t * Warns if there is a duplicate or missing key\n\t */\n\n\n\t function warnOnInvalidKey(child, knownKeys) {\n\t {\n\t if (typeof child !== 'object' || child === null) {\n\t return knownKeys;\n\t }\n\n\t switch (child.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t case REACT_PORTAL_TYPE:\n\t warnForMissingKey(child);\n\t var key = child.key;\n\n\t if (typeof key !== 'string') {\n\t break;\n\t }\n\n\t if (knownKeys === null) {\n\t knownKeys = new Set();\n\t knownKeys.add(key);\n\t break;\n\t }\n\n\t if (!knownKeys.has(key)) {\n\t knownKeys.add(key);\n\t break;\n\t }\n\n\t warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\t break;\n\t }\n\t }\n\n\t return knownKeys;\n\t }\n\n\t function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n\t // This algorithm can't optimize by searching from both ends since we\n\t // don't have backpointers on fibers. I'm trying to see how far we can get\n\t // with that model. If it ends up not being worth the tradeoffs, we can\n\t // add it later.\n\t // Even with a two ended optimization, we'd want to optimize for the case\n\t // where there are few changes and brute force the comparison instead of\n\t // going for the Map. It'd like to explore hitting that path first in\n\t // forward-only mode and only go for the Map once we notice that we need\n\t // lots of look ahead. This doesn't handle reversal as well as two ended\n\t // search but that's unusual. Besides, for the two ended optimization to\n\t // work on Iterables, we'd need to copy the whole set.\n\t // In this first iteration, we'll just live with hitting the bad case\n\t // (adding everything to a Map) in for every insert/move.\n\t // If you change this code, also update reconcileChildrenIterator() which\n\t // uses the same algorithm.\n\t {\n\t // First, validate keys.\n\t var knownKeys = null;\n\n\t for (var i = 0; i < newChildren.length; i++) {\n\t var child = newChildren[i];\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\n\t for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\n\t var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (oldFiber === null) {\n\t oldFiber = nextOldFiber;\n\t }\n\n\t break;\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\n\t if (newIdx === newChildren.length) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n\t if (_newFiber === null) {\n\t continue;\n\t }\n\n\t lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber;\n\t } else {\n\t previousNewFiber.sibling = _newFiber;\n\t }\n\n\t previousNewFiber = _newFiber;\n\t }\n\n\t return resultingFirstChild;\n\t } // Add all children to a key map for quick lookups.\n\n\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n\t for (; newIdx < newChildren.length; newIdx++) {\n\t var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n\t if (_newFiber2 !== null) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber2.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n\t }\n\t }\n\n\t lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber2;\n\t } else {\n\t previousNewFiber.sibling = _newFiber2;\n\t }\n\n\t previousNewFiber = _newFiber2;\n\t }\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\n\t return resultingFirstChild;\n\t }\n\n\t function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n\t // This is the same implementation as reconcileChildrenArray(),\n\t // but using the iterator instead.\n\t var iteratorFn = getIteratorFn(newChildrenIterable);\n\n\t if (!(typeof iteratorFn === 'function')) {\n\t {\n\t throw Error(\"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\");\n\t }\n\t }\n\n\t {\n\t // We don't support rendering Generators because it's a mutation.\n\t // See https://github.com/facebook/react/issues/12995\n\t if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n\t newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n\t !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n\t didWarnAboutGenerators = true;\n\t } // Warn about using Maps as children\n\n\n\t if (newChildrenIterable.entries === iteratorFn) {\n\t !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n\t didWarnAboutMaps = true;\n\t } // First, validate keys.\n\t // We'll get a different iterator later for the main pass.\n\n\n\t var _newChildren = iteratorFn.call(newChildrenIterable);\n\n\t if (_newChildren) {\n\t var knownKeys = null;\n\n\t var _step = _newChildren.next();\n\n\t for (; !_step.done; _step = _newChildren.next()) {\n\t var child = _step.value;\n\t knownKeys = warnOnInvalidKey(child, knownKeys);\n\t }\n\t }\n\t }\n\n\t var newChildren = iteratorFn.call(newChildrenIterable);\n\n\t if (!(newChildren != null)) {\n\t {\n\t throw Error(\"An iterable object provided no iterator.\");\n\t }\n\t }\n\n\t var resultingFirstChild = null;\n\t var previousNewFiber = null;\n\t var oldFiber = currentFirstChild;\n\t var lastPlacedIndex = 0;\n\t var newIdx = 0;\n\t var nextOldFiber = null;\n\t var step = newChildren.next();\n\n\t for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n\t if (oldFiber.index > newIdx) {\n\t nextOldFiber = oldFiber;\n\t oldFiber = null;\n\t } else {\n\t nextOldFiber = oldFiber.sibling;\n\t }\n\n\t var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n\t if (newFiber === null) {\n\t // TODO: This breaks on empty slots like null children. That's\n\t // unfortunate because it triggers the slow path all the time. We need\n\t // a better way to communicate whether this was a miss or null,\n\t // boolean, undefined, etc.\n\t if (oldFiber === null) {\n\t oldFiber = nextOldFiber;\n\t }\n\n\t break;\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t if (oldFiber && newFiber.alternate === null) {\n\t // We matched the slot, but we didn't reuse the existing fiber, so we\n\t // need to delete the existing child.\n\t deleteChild(returnFiber, oldFiber);\n\t }\n\t }\n\n\t lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = newFiber;\n\t } else {\n\t // TODO: Defer siblings if we're not at the right index for this slot.\n\t // I.e. if we had null values before, then we want to defer this\n\t // for each null value. However, we also don't want to call updateSlot\n\t // with the previous one.\n\t previousNewFiber.sibling = newFiber;\n\t }\n\n\t previousNewFiber = newFiber;\n\t oldFiber = nextOldFiber;\n\t }\n\n\t if (step.done) {\n\t // We've reached the end of the new children. We can delete the rest.\n\t deleteRemainingChildren(returnFiber, oldFiber);\n\t return resultingFirstChild;\n\t }\n\n\t if (oldFiber === null) {\n\t // If we don't have any more existing children we can choose a fast path\n\t // since the rest will all be insertions.\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n\t if (_newFiber3 === null) {\n\t continue;\n\t }\n\n\t lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n\t if (previousNewFiber === null) {\n\t // TODO: Move out of the loop. This only happens for the first run.\n\t resultingFirstChild = _newFiber3;\n\t } else {\n\t previousNewFiber.sibling = _newFiber3;\n\t }\n\n\t previousNewFiber = _newFiber3;\n\t }\n\n\t return resultingFirstChild;\n\t } // Add all children to a key map for quick lookups.\n\n\n\t var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n\t for (; !step.done; newIdx++, step = newChildren.next()) {\n\t var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n\t if (_newFiber4 !== null) {\n\t if (shouldTrackSideEffects) {\n\t if (_newFiber4.alternate !== null) {\n\t // The new fiber is a work in progress, but if there exists a\n\t // current, that means that we reused the fiber. We need to delete\n\t // it from the child list so that we don't add it to the deletion\n\t // list.\n\t existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n\t }\n\t }\n\n\t lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n\t if (previousNewFiber === null) {\n\t resultingFirstChild = _newFiber4;\n\t } else {\n\t previousNewFiber.sibling = _newFiber4;\n\t }\n\n\t previousNewFiber = _newFiber4;\n\t }\n\t }\n\n\t if (shouldTrackSideEffects) {\n\t // Any existing children that weren't consumed above were deleted. We need\n\t // to add them to the deletion list.\n\t existingChildren.forEach(function (child) {\n\t return deleteChild(returnFiber, child);\n\t });\n\t }\n\n\t return resultingFirstChild;\n\t }\n\n\t function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n\t // There's no need to check for keys on text nodes since we don't have a\n\t // way to define them.\n\t if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n\t // We already have an existing node so let's just update it and delete\n\t // the rest.\n\t deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n\t var existing = useFiber(currentFirstChild, textContent);\n\t existing.return = returnFiber;\n\t return existing;\n\t } // The existing first child is not a text node so we need to create one\n\t // and delete the existing ones.\n\n\n\t deleteRemainingChildren(returnFiber, currentFirstChild);\n\t var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t }\n\n\t function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n\t var key = element.key;\n\t var child = currentFirstChild;\n\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n\t isCompatibleFamilyForHotReloading(child, element))) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props);\n\t existing.ref = coerceRef(returnFiber, child, element);\n\t existing.return = returnFiber;\n\n\t {\n\t existing._debugSource = element._source;\n\t existing._debugOwner = element._owner;\n\t }\n\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\n\t child = child.sibling;\n\t }\n\n\t if (element.type === REACT_FRAGMENT_TYPE) {\n\t var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n\t created.return = returnFiber;\n\t return created;\n\t } else {\n\t var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n\t _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n\t _created4.return = returnFiber;\n\t return _created4;\n\t }\n\t }\n\n\t function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n\t var key = portal.key;\n\t var child = currentFirstChild;\n\n\t while (child !== null) {\n\t // TODO: If key === null and child.key === null, then this only applies to\n\t // the first item in the list.\n\t if (child.key === key) {\n\t if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n\t deleteRemainingChildren(returnFiber, child.sibling);\n\t var existing = useFiber(child, portal.children || []);\n\t existing.return = returnFiber;\n\t return existing;\n\t } else {\n\t deleteRemainingChildren(returnFiber, child);\n\t break;\n\t }\n\t } else {\n\t deleteChild(returnFiber, child);\n\t }\n\n\t child = child.sibling;\n\t }\n\n\t var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n\t created.return = returnFiber;\n\t return created;\n\t } // This API will tag the children with the side-effect of the reconciliation\n\t // itself. They will be added to the side-effect list as we pass through the\n\t // children and the parent.\n\n\n\t function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n\t // This function is not recursive.\n\t // If the top level item is an array, we treat it as a set of children,\n\t // not as a fragment. Nested arrays on the other hand will be treated as\n\t // fragment nodes. Recursion happens at the normal flow.\n\t // Handle top level unkeyed fragments as if they were arrays.\n\t // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n\t // We treat the ambiguous cases above the same.\n\t var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n\t if (isUnkeyedTopLevelFragment) {\n\t newChild = newChild.props.children;\n\t } // Handle object types\n\n\n\t var isObject = typeof newChild === 'object' && newChild !== null;\n\n\t if (isObject) {\n\t switch (newChild.$$typeof) {\n\t case REACT_ELEMENT_TYPE:\n\t return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n\t case REACT_PORTAL_TYPE:\n\t return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n\t }\n\t }\n\n\t if (typeof newChild === 'string' || typeof newChild === 'number') {\n\t return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n\t }\n\n\t if (isArray(newChild)) {\n\t return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\n\t if (getIteratorFn(newChild)) {\n\t return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n\t }\n\n\t if (isObject) {\n\t throwOnInvalidObjectType(returnFiber, newChild);\n\t }\n\n\t {\n\t if (typeof newChild === 'function') {\n\t warnOnFunctionType();\n\t }\n\t }\n\n\t if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n\t // If the new child is undefined, and the return fiber is a composite\n\t // component, throw an error. If Fiber return types are disabled,\n\t // we already threw above.\n\t switch (returnFiber.tag) {\n\t case ClassComponent:\n\t {\n\t {\n\t var instance = returnFiber.stateNode;\n\n\t if (instance.render._isMockFunction) {\n\t // We allow auto-mocks to proceed as if they're returning null.\n\t break;\n\t }\n\t }\n\t }\n\t // Intentionally fall through to the next case, which handles both\n\t // functions and classes\n\t // eslint-disable-next-lined no-fallthrough\n\n\t case FunctionComponent:\n\t {\n\t var Component = returnFiber.type;\n\n\t {\n\t {\n\t throw Error((Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\");\n\t }\n\t }\n\t }\n\t }\n\t } // Remaining cases are all treated as empty.\n\n\n\t return deleteRemainingChildren(returnFiber, currentFirstChild);\n\t }\n\n\t return reconcileChildFibers;\n\t}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "b269b349d4e4862a3d4b8b735a30403e", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n hotCompareElements(current.elementType, element.type, hotUpdateChild(current), current.type) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n hotCompareElements(child.elementType, element.type, hotUpdateChild(child), child.type) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "da6418937bece9eb73db69f363f99ab1", "score": "0.68390375", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.flags = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.flags = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.flags = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, lanes) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, lanes) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, lanes);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, lanes) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, lanes, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, lanes) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, lanes);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, lanes);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);\n }\n\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys, returnFiber) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child, returnFiber);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, lanes);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, lanes);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));\n\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType(returnFiber);\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case Block:\n case FunctionComponent:\n case ForwardRef:\n case SimpleMemoComponent:\n {\n {\n {\n throw Error( (getComponentName(returnFiber.type) || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "166acada5574c1a9bb0990b485e89c9f", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n hotCompareElements(current.elementType, element.type, hotUpdateChild(current), current.type) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n hotCompareElements(child.elementType, element.type, hotUpdateChild(child), child.type) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "7cf92859bc39f53405b434d1d2d0bf25", "score": "0.68356806", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n } // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n\n\n var last = returnFiber.lastEffect;\n\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n } // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n\n\n var childToDelete = currentFirstChild;\n\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n // instead.\n var existingChildren = new Map();\n var existingChild = currentFirstChild;\n\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n\n existingChild = existingChild.sibling;\n }\n\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n\n var current = newFiber.alternate;\n\n if (current !== null) {\n var oldIndex = current.index;\n\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null) {\n if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current, element) )) {\n // Move based on index\n var existing = useFiber(current, element.props);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n } // Insert\n\n\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || []);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n /**\n * Warns if there is a duplicate or missing key\n */\n\n\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n\n if (typeof key !== 'string') {\n break;\n }\n\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n\n error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n\n break;\n }\n }\n\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n {\n // First, validate keys.\n var knownKeys = null;\n\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n\n if (_newFiber === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n\n previousNewFiber = _newFiber;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n var iteratorFn = getIteratorFn(newChildrenIterable);\n\n if (!(typeof iteratorFn === 'function')) {\n {\n throw Error( \"An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.\" );\n }\n }\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n if (!didWarnAboutGenerators) {\n error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.');\n }\n\n didWarnAboutGenerators = true;\n } // Warn about using Maps as children\n\n\n if (newChildrenIterable.entries === iteratorFn) {\n if (!didWarnAboutMaps) {\n error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n } // First, validate keys.\n // We'll get a different iterator later for the main pass.\n\n\n var _newChildren = iteratorFn.call(newChildrenIterable);\n\n if (_newChildren) {\n var knownKeys = null;\n\n var _step = _newChildren.next();\n\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n\n if (!(newChildren != null)) {\n {\n throw Error( \"An iterable object provided no iterator.\" );\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n var step = newChildren.next();\n\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n\n break;\n }\n\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n\n if (_newFiber3 === null) {\n continue;\n }\n\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n\n previousNewFiber = _newFiber3;\n }\n\n return resultingFirstChild;\n } // Add all children to a key map for quick lookups.\n\n\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.\n\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent);\n existing.return = returnFiber;\n return existing;\n } // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n\n\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n switch (child.tag) {\n case Fragment:\n {\n if (element.type === REACT_FRAGMENT_TYPE) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.props.children);\n existing.return = returnFiber;\n\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n\n return existing;\n }\n\n break;\n }\n\n case Block:\n\n // We intentionally fallthrough here if enableBlocksAPI is not on.\n // eslint-disable-next-lined no-fallthrough\n\n default:\n {\n if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element) )) {\n deleteRemainingChildren(returnFiber, child.sibling);\n\n var _existing3 = useFiber(child, element.props);\n\n _existing3.ref = coerceRef(returnFiber, child, element);\n _existing3.return = returnFiber;\n\n {\n _existing3._debugSource = element._source;\n _existing3._debugOwner = element._owner;\n }\n\n return _existing3;\n }\n\n break;\n }\n } // Didn't match.\n\n\n deleteRemainingChildren(returnFiber, child);\n break;\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || []);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n\n\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n } // Handle object types\n\n\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n\n {\n {\n throw Error( (Component.displayName || Component.name || 'Component') + \"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.\" );\n }\n }\n }\n }\n } // Remaining cases are all treated as empty.\n\n\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "213f0a116736475286ba9b2a4cc6c49f", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "4f8415b273862476a0c1c2d68aa0b984", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.type === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n case ClassComponentLazy:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "40c1647040fe5069d53317756181df17", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created['return'] = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$2());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2()) : void 0;\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4['return'] = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "2346230c2319e3821e233a6a5acdfd51", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(returnFiber, current, returnNode, expirationTime) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE:\n {\n var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n if (newChild.key === key) {\n return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_CALL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "d5860dcd8942d743271b2dbc740448bc", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "0bfd663984968e0da8de050c9417dc70", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created['return'] = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$2());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4['return'] = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "49e0c0ea5a7c352514b42d71be40cbaf", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && (current$$1.elementType === element.type || (\n // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (_newFiber === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n (function () {\n if (!(typeof iteratorFn === 'function')) {\n {\n throw ReactError(Error('An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.'));\n }\n }\n })();\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n (function () {\n if (!(newChildren != null)) {\n {\n throw ReactError(Error('An iterable object provided no iterator.'));\n }\n }\n })();\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || (\n // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element))) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n (function () {\n {\n {\n throw ReactError(Error((Component.displayName || Component.name || 'Component') + '(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.'));\n }\n }\n })();\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "d5860dcd8942d743271b2dbc740448bc", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "2346230c2319e3821e233a6a5acdfd51", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(returnFiber, current, returnNode, expirationTime) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE:\n {\n var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n if (newChild.key === key) {\n return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_CALL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "2346230c2319e3821e233a6a5acdfd51", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(returnFiber, current, returnNode, expirationTime) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE:\n {\n var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n if (newChild.key === key) {\n return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_CALL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "d5860dcd8942d743271b2dbc740448bc", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "2346230c2319e3821e233a6a5acdfd51", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(returnFiber, current, returnNode, expirationTime) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE:\n {\n var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n if (newChild.key === key) {\n return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_CALL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "213f0a116736475286ba9b2a4cc6c49f", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "e9b2dad2ec12667b7483f289af9f6f20", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "d5860dcd8942d743271b2dbc740448bc", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "d5860dcd8942d743271b2dbc740448bc", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "40c1647040fe5069d53317756181df17", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created['return'] = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$2());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2()) : void 0;\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4['return'] = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "f8ada50685d5b0ae1331193ee06e7ce3", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "2346230c2319e3821e233a6a5acdfd51", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(returnFiber, current, returnNode, expirationTime) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE:\n {\n var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n if (newChild.key === key) {\n return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_CALL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "2346230c2319e3821e233a6a5acdfd51", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(returnFiber, current, returnNode, expirationTime) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE:\n {\n var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n if (newChild.key === key) {\n return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_CALL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "213f0a116736475286ba9b2a4cc6c49f", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "213f0a116736475286ba9b2a4cc6c49f", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$7());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$7()) : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "d5860dcd8942d743271b2dbc740448bc", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.elementType === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from both ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "4f8415b273862476a0c1c2d68aa0b984", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current$$1 = newFiber.alternate;\n if (current$$1 !== null) {\n var oldIndex = current$$1.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current$$1, element, expirationTime) {\n if (current$$1 !== null && current$$1.type === element.type) {\n // Move based on index\n var existing = useFiber(current$$1, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current$$1, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current$$1, element);\n created.return = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current$$1, portal, expirationTime) {\n if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {\n if (current$$1 === null || current$$1.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created.return = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current$$1, fragment, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created.return = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2.return = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3.return = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // We don't support rendering Generators because it's a mutation.\n // See https://github.com/facebook/react/issues/12995\n if (typeof Symbol === 'function' &&\n // $FlowFixMe Flow doesn't know about toStringTag\n newChildrenIterable[Symbol.toStringTag] === 'Generator') {\n !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;\n didWarnAboutGenerators = true;\n }\n\n // Warn about using Maps as children\n if (newChildrenIterable.entries === iteratorFn) {\n !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;\n didWarnAboutMaps = true;\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing.return = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing.return = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created.return = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4.return = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing.return = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created.return = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;\n if (isUnkeyedTopLevelFragment) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n case ClassComponentLazy:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "40c1647040fe5069d53317756181df17", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.mode, expirationTime);\n created.ref = coerceRef(returnFiber, current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);\n _created.ref = coerceRef(returnFiber, null, newChild);\n _created['return'] = returnFiber;\n return _created;\n }\n case REACT_PORTAL_TYPE:\n {\n var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$2());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n !didWarnAboutMaps ? warning(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$2()) : void 0;\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(returnFiber, child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);\n _created4.ref = coerceRef(returnFiber, currentFirstChild, element);\n _created4['return'] = returnFiber;\n return _created4;\n }\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" }, { "docid": "2346230c2319e3821e233a6a5acdfd51", "score": "0.6818463", "text": "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return;\n }\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's effect list is empty except for\n // deletions, so we can just append the deletion to the list. The remaining\n // effects aren't added until the complete phase. Once we implement\n // resuming, this may not be true.\n var last = returnFiber.lastEffect;\n if (last !== null) {\n last.nextEffect = childToDelete;\n returnFiber.lastEffect = childToDelete;\n } else {\n returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;\n }\n childToDelete.nextEffect = null;\n childToDelete.effectTag = Deletion;\n }\n\n function deleteRemainingChildren(returnFiber, currentFirstChild) {\n if (!shouldTrackSideEffects) {\n // Noop.\n return null;\n }\n\n // TODO: For the shouldClone case, this could be micro-optimized a bit by\n // assuming that after the first child we've already added everything.\n var childToDelete = currentFirstChild;\n while (childToDelete !== null) {\n deleteChild(returnFiber, childToDelete);\n childToDelete = childToDelete.sibling;\n }\n return null;\n }\n\n function mapRemainingChildren(returnFiber, currentFirstChild) {\n // Add the remaining children to a temporary map so that we can find them by\n // keys quickly. Implicit (null) keys get added to this set with their index\n var existingChildren = new Map();\n\n var existingChild = currentFirstChild;\n while (existingChild !== null) {\n if (existingChild.key !== null) {\n existingChildren.set(existingChild.key, existingChild);\n } else {\n existingChildren.set(existingChild.index, existingChild);\n }\n existingChild = existingChild.sibling;\n }\n return existingChildren;\n }\n\n function useFiber(fiber, pendingProps, expirationTime) {\n // We currently set sibling to null and index to 0 here because it is easy\n // to forget to do before returning it. E.g. for the single child case.\n var clone = createWorkInProgress(fiber, pendingProps, expirationTime);\n clone.index = 0;\n clone.sibling = null;\n return clone;\n }\n\n function placeChild(newFiber, lastPlacedIndex, newIndex) {\n newFiber.index = newIndex;\n if (!shouldTrackSideEffects) {\n // Noop.\n return lastPlacedIndex;\n }\n var current = newFiber.alternate;\n if (current !== null) {\n var oldIndex = current.index;\n if (oldIndex < lastPlacedIndex) {\n // This is a move.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n } else {\n // This item can stay in place.\n return oldIndex;\n }\n } else {\n // This is an insertion.\n newFiber.effectTag = Placement;\n return lastPlacedIndex;\n }\n }\n\n function placeSingleChild(newFiber) {\n // This is simpler for the single child case. We only need to do a\n // placement for inserting new children.\n if (shouldTrackSideEffects && newFiber.alternate === null) {\n newFiber.effectTag = Placement;\n }\n return newFiber;\n }\n\n function updateTextNode(returnFiber, current, textContent, expirationTime) {\n if (current === null || current.tag !== HostText) {\n // Insert\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateElement(returnFiber, current, element, expirationTime) {\n if (current !== null && current.type === element.type) {\n // Move based on index\n var existing = useFiber(current, element.props, expirationTime);\n existing.ref = coerceRef(current, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n // Insert\n var created = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n created.ref = coerceRef(current, element);\n created['return'] = returnFiber;\n return created;\n }\n }\n\n function updateCall(returnFiber, current, call, expirationTime) {\n // TODO: Should this also compare handler to determine whether to reuse?\n if (current === null || current.tag !== CallComponent) {\n // Insert\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateReturn(returnFiber, current, returnNode, expirationTime) {\n if (current === null || current.tag !== ReturnComponent) {\n // Insert\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n } else {\n // Move based on index\n var existing = useFiber(current, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updatePortal(returnFiber, current, portal, expirationTime) {\n if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {\n // Insert\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function updateFragment(returnFiber, current, fragment, expirationTime, key) {\n if (current === null || current.tag !== Fragment) {\n // Insert\n var created = createFiberFromFragment(fragment, returnFiber.internalContextTag, expirationTime, key);\n created['return'] = returnFiber;\n return created;\n } else {\n // Update\n var existing = useFiber(current, fragment, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n }\n\n function createChild(returnFiber, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n var created = createFiberFromText('' + newChild, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n var _created = createFiberFromFragment(newChild.props.children, returnFiber.internalContextTag, expirationTime, newChild.key);\n _created['return'] = returnFiber;\n return _created;\n } else {\n var _created2 = createFiberFromElement(newChild, returnFiber.internalContextTag, expirationTime);\n _created2.ref = coerceRef(null, newChild);\n _created2['return'] = returnFiber;\n return _created2;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n var _created3 = createFiberFromCall(newChild, returnFiber.internalContextTag, expirationTime);\n _created3['return'] = returnFiber;\n return _created3;\n }\n\n case REACT_RETURN_TYPE:\n {\n var _created4 = createFiberFromReturn(newChild, returnFiber.internalContextTag, expirationTime);\n _created4.type = newChild.value;\n _created4['return'] = returnFiber;\n return _created4;\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _created5 = createFiberFromPortal(newChild, returnFiber.internalContextTag, expirationTime);\n _created5['return'] = returnFiber;\n return _created5;\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _created6 = createFiberFromFragment(newChild, returnFiber.internalContextTag, expirationTime, null);\n _created6['return'] = returnFiber;\n return _created6;\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {\n // Update the fiber if the keys match, otherwise return null.\n\n var key = oldFiber !== null ? oldFiber.key : null;\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a text\n // node.\n if (key !== null) {\n return null;\n }\n return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n if (newChild.key === key) {\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);\n }\n return updateElement(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_CALL_TYPE:\n {\n if (newChild.key === key) {\n return updateCall(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys. If the previous node is implicitly keyed\n // we can continue to replace it without aborting even if it is not a\n // yield.\n if (key === null) {\n return updateReturn(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n\n case REACT_PORTAL_TYPE:\n {\n if (newChild.key === key) {\n return updatePortal(returnFiber, oldFiber, newChild, expirationTime);\n } else {\n return null;\n }\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n if (key !== null) {\n return null;\n }\n\n return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n // Text nodes don't have keys, so we neither have to check the old nor\n // new node for the key. If both are text nodes, they match.\n var matchedFiber = existingChildren.get(newIdx) || null;\n return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);\n }\n\n if (typeof newChild === 'object' && newChild !== null) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n {\n var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n if (newChild.type === REACT_FRAGMENT_TYPE) {\n return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);\n }\n return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);\n }\n\n case REACT_CALL_TYPE:\n {\n var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updateCall(returnFiber, _matchedFiber2, newChild, expirationTime);\n }\n\n case REACT_RETURN_TYPE:\n {\n // Returns don't have keys, so we neither have to check the old nor\n // new node for the key. If both are returns, they match.\n var _matchedFiber3 = existingChildren.get(newIdx) || null;\n return updateReturn(returnFiber, _matchedFiber3, newChild, expirationTime);\n }\n\n case REACT_PORTAL_TYPE:\n {\n var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;\n return updatePortal(returnFiber, _matchedFiber4, newChild, expirationTime);\n }\n }\n\n if (isArray$1(newChild) || getIteratorFn(newChild)) {\n var _matchedFiber5 = existingChildren.get(newIdx) || null;\n return updateFragment(returnFiber, _matchedFiber5, newChild, expirationTime, null);\n }\n\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n\n return null;\n }\n\n /**\n * Warns if there is a duplicate or missing key\n */\n function warnOnInvalidKey(child, knownKeys) {\n {\n if (typeof child !== 'object' || child === null) {\n return knownKeys;\n }\n switch (child.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_CALL_TYPE:\n case REACT_PORTAL_TYPE:\n warnForMissingKey(child);\n var key = child.key;\n if (typeof key !== 'string') {\n break;\n }\n if (knownKeys === null) {\n knownKeys = new Set();\n knownKeys.add(key);\n break;\n }\n if (!knownKeys.has(key)) {\n knownKeys.add(key);\n break;\n }\n warning(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.%s', key, getCurrentFiberStackAddendum$1());\n break;\n default:\n break;\n }\n }\n return knownKeys;\n }\n\n function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {\n // This algorithm can't optimize by searching from boths ends since we\n // don't have backpointers on fibers. I'm trying to see how far we can get\n // with that model. If it ends up not being worth the tradeoffs, we can\n // add it later.\n\n // Even with a two ended optimization, we'd want to optimize for the case\n // where there are few changes and brute force the comparison instead of\n // going for the Map. It'd like to explore hitting that path first in\n // forward-only mode and only go for the Map once we notice that we need\n // lots of look ahead. This doesn't handle reversal as well as two ended\n // search but that's unusual. Besides, for the two ended optimization to\n // work on Iterables, we'd need to copy the whole set.\n\n // In this first iteration, we'll just live with hitting the bad case\n // (adding everything to a Map) in for every insert/move.\n\n // If you change this code, also update reconcileChildrenIterator() which\n // uses the same algorithm.\n\n {\n // First, validate keys.\n var knownKeys = null;\n for (var i = 0; i < newChildren.length; i++) {\n var child = newChildren[i];\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (oldFiber === null) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (newIdx === newChildren.length) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);\n if (!_newFiber) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber;\n } else {\n previousNewFiber.sibling = _newFiber;\n }\n previousNewFiber = _newFiber;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; newIdx < newChildren.length; newIdx++) {\n var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);\n if (_newFiber2) {\n if (shouldTrackSideEffects) {\n if (_newFiber2.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber2.key === null ? newIdx : _newFiber2.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber2;\n } else {\n previousNewFiber.sibling = _newFiber2;\n }\n previousNewFiber = _newFiber2;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {\n // This is the same implementation as reconcileChildrenArray(),\n // but using the iterator instead.\n\n var iteratorFn = getIteratorFn(newChildrenIterable);\n !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;\n\n {\n // Warn about using Maps as children\n if (typeof newChildrenIterable.entries === 'function') {\n var possibleMap = newChildrenIterable;\n if (possibleMap.entries === iteratorFn) {\n warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentFiberStackAddendum$1());\n didWarnAboutMaps = true;\n }\n }\n\n // First, validate keys.\n // We'll get a different iterator later for the main pass.\n var _newChildren = iteratorFn.call(newChildrenIterable);\n if (_newChildren) {\n var knownKeys = null;\n var _step = _newChildren.next();\n for (; !_step.done; _step = _newChildren.next()) {\n var child = _step.value;\n knownKeys = warnOnInvalidKey(child, knownKeys);\n }\n }\n }\n\n var newChildren = iteratorFn.call(newChildrenIterable);\n !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;\n\n var resultingFirstChild = null;\n var previousNewFiber = null;\n\n var oldFiber = currentFirstChild;\n var lastPlacedIndex = 0;\n var newIdx = 0;\n var nextOldFiber = null;\n\n var step = newChildren.next();\n for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {\n if (oldFiber.index > newIdx) {\n nextOldFiber = oldFiber;\n oldFiber = null;\n } else {\n nextOldFiber = oldFiber.sibling;\n }\n var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);\n if (newFiber === null) {\n // TODO: This breaks on empty slots like null children. That's\n // unfortunate because it triggers the slow path all the time. We need\n // a better way to communicate whether this was a miss or null,\n // boolean, undefined, etc.\n if (!oldFiber) {\n oldFiber = nextOldFiber;\n }\n break;\n }\n if (shouldTrackSideEffects) {\n if (oldFiber && newFiber.alternate === null) {\n // We matched the slot, but we didn't reuse the existing fiber, so we\n // need to delete the existing child.\n deleteChild(returnFiber, oldFiber);\n }\n }\n lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = newFiber;\n } else {\n // TODO: Defer siblings if we're not at the right index for this slot.\n // I.e. if we had null values before, then we want to defer this\n // for each null value. However, we also don't want to call updateSlot\n // with the previous one.\n previousNewFiber.sibling = newFiber;\n }\n previousNewFiber = newFiber;\n oldFiber = nextOldFiber;\n }\n\n if (step.done) {\n // We've reached the end of the new children. We can delete the rest.\n deleteRemainingChildren(returnFiber, oldFiber);\n return resultingFirstChild;\n }\n\n if (oldFiber === null) {\n // If we don't have any more existing children we can choose a fast path\n // since the rest will all be insertions.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber3 = createChild(returnFiber, step.value, expirationTime);\n if (_newFiber3 === null) {\n continue;\n }\n lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n // TODO: Move out of the loop. This only happens for the first run.\n resultingFirstChild = _newFiber3;\n } else {\n previousNewFiber.sibling = _newFiber3;\n }\n previousNewFiber = _newFiber3;\n }\n return resultingFirstChild;\n }\n\n // Add all children to a key map for quick lookups.\n var existingChildren = mapRemainingChildren(returnFiber, oldFiber);\n\n // Keep scanning and use the map to restore deleted items as moves.\n for (; !step.done; newIdx++, step = newChildren.next()) {\n var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);\n if (_newFiber4 !== null) {\n if (shouldTrackSideEffects) {\n if (_newFiber4.alternate !== null) {\n // The new fiber is a work in progress, but if there exists a\n // current, that means that we reused the fiber. We need to delete\n // it from the child list so that we don't add it to the deletion\n // list.\n existingChildren['delete'](_newFiber4.key === null ? newIdx : _newFiber4.key);\n }\n }\n lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);\n if (previousNewFiber === null) {\n resultingFirstChild = _newFiber4;\n } else {\n previousNewFiber.sibling = _newFiber4;\n }\n previousNewFiber = _newFiber4;\n }\n }\n\n if (shouldTrackSideEffects) {\n // Any existing children that weren't consumed above were deleted. We need\n // to add them to the deletion list.\n existingChildren.forEach(function (child) {\n return deleteChild(returnFiber, child);\n });\n }\n\n return resultingFirstChild;\n }\n\n function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {\n // There's no need to check for keys on text nodes since we don't have a\n // way to define them.\n if (currentFirstChild !== null && currentFirstChild.tag === HostText) {\n // We already have an existing node so let's just update it and delete\n // the rest.\n deleteRemainingChildren(returnFiber, currentFirstChild.sibling);\n var existing = useFiber(currentFirstChild, textContent, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n }\n // The existing first child is not a text node so we need to create one\n // and delete the existing ones.\n deleteRemainingChildren(returnFiber, currentFirstChild);\n var created = createFiberFromText(textContent, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {\n var key = element.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);\n existing.ref = coerceRef(child, element);\n existing['return'] = returnFiber;\n {\n existing._debugSource = element._source;\n existing._debugOwner = element._owner;\n }\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n if (element.type === REACT_FRAGMENT_TYPE) {\n var created = createFiberFromFragment(element.props.children, returnFiber.internalContextTag, expirationTime, element.key);\n created['return'] = returnFiber;\n return created;\n } else {\n var _created7 = createFiberFromElement(element, returnFiber.internalContextTag, expirationTime);\n _created7.ref = coerceRef(currentFirstChild, element);\n _created7['return'] = returnFiber;\n return _created7;\n }\n }\n\n function reconcileSingleCall(returnFiber, currentFirstChild, call, expirationTime) {\n var key = call.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === CallComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, call, expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromCall(call, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSingleReturn(returnFiber, currentFirstChild, returnNode, expirationTime) {\n // There's no need to check for keys on yields since they're stateless.\n var child = currentFirstChild;\n if (child !== null) {\n if (child.tag === ReturnComponent) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, null, expirationTime);\n existing.type = returnNode.value;\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n }\n }\n\n var created = createFiberFromReturn(returnNode, returnFiber.internalContextTag, expirationTime);\n created.type = returnNode.value;\n created['return'] = returnFiber;\n return created;\n }\n\n function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {\n var key = portal.key;\n var child = currentFirstChild;\n while (child !== null) {\n // TODO: If key === null and child.key === null, then this only applies to\n // the first item in the list.\n if (child.key === key) {\n if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {\n deleteRemainingChildren(returnFiber, child.sibling);\n var existing = useFiber(child, portal.children || [], expirationTime);\n existing['return'] = returnFiber;\n return existing;\n } else {\n deleteRemainingChildren(returnFiber, child);\n break;\n }\n } else {\n deleteChild(returnFiber, child);\n }\n child = child.sibling;\n }\n\n var created = createFiberFromPortal(portal, returnFiber.internalContextTag, expirationTime);\n created['return'] = returnFiber;\n return created;\n }\n\n // This API will tag the children with the side-effect of the reconciliation\n // itself. They will be added to the side-effect list as we pass through the\n // children and the parent.\n function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {\n // This function is not recursive.\n // If the top level item is an array, we treat it as a set of children,\n // not as a fragment. Nested arrays on the other hand will be treated as\n // fragment nodes. Recursion happens at the normal flow.\n\n // Handle top level unkeyed fragments as if they were arrays.\n // This leads to an ambiguity between <>{[...]}</> and <>...</>.\n // We treat the ambiguous cases above the same.\n if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {\n newChild = newChild.props.children;\n }\n\n // Handle object types\n var isObject = typeof newChild === 'object' && newChild !== null;\n\n if (isObject) {\n switch (newChild.$$typeof) {\n case REACT_ELEMENT_TYPE:\n return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));\n\n case REACT_CALL_TYPE:\n return placeSingleChild(reconcileSingleCall(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_RETURN_TYPE:\n return placeSingleChild(reconcileSingleReturn(returnFiber, currentFirstChild, newChild, expirationTime));\n case REACT_PORTAL_TYPE:\n return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));\n }\n }\n\n if (typeof newChild === 'string' || typeof newChild === 'number') {\n return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));\n }\n\n if (isArray$1(newChild)) {\n return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (getIteratorFn(newChild)) {\n return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);\n }\n\n if (isObject) {\n throwOnInvalidObjectType(returnFiber, newChild);\n }\n\n {\n if (typeof newChild === 'function') {\n warnOnFunctionType();\n }\n }\n if (typeof newChild === 'undefined') {\n // If the new child is undefined, and the return fiber is a composite\n // component, throw an error. If Fiber return types are disabled,\n // we already threw above.\n switch (returnFiber.tag) {\n case ClassComponent:\n {\n {\n var instance = returnFiber.stateNode;\n if (instance.render._isMockFunction) {\n // We allow auto-mocks to proceed as if they're returning null.\n break;\n }\n }\n }\n // Intentionally fall through to the next case, which handles both\n // functions and classes\n // eslint-disable-next-lined no-fallthrough\n case FunctionalComponent:\n {\n var Component = returnFiber.type;\n invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');\n }\n }\n }\n\n // Remaining cases are all treated as empty.\n return deleteRemainingChildren(returnFiber, currentFirstChild);\n }\n\n return reconcileChildFibers;\n}", "title": "" } ]
d51f7d799dac16cf47c73ca495e5cd6a
add card courses to time slot containers
[ { "docid": "7bbc7f49b863f70c0e78d92fcfce9126", "score": "0.0", "text": "function addToContainer(a, container){\n for (var i=0, card; card = a[i]; i++) {\n container.appendChild(card)\n }\n}", "title": "" } ]
[ { "docid": "ec3245210dd86cc12fac924a6d44a652", "score": "0.69910383", "text": "function createCourses(){\n var a = [];\n var tem = schedule(createBlocks);\n var coloring = tem[0];\n var free = tem[1];\n for (var el in coloring) {\n var courses = coloring[el];\n for (var i=0, crn; crn=courses[i]; i++) {\n a.push(crn);\n courseObjList[crn]['color'] = el;\n }\n }\n for (var i=0, crn; crn=free[i]; i++) {\n a.push(crn);\n courseObjList[crn]['color'] = 0;\n }\n var cards = createCourseCards(a);\n addToContainer(cards, document.getElementById('course-list'));\n}", "title": "" }, { "docid": "ab10feea76f3f1558370600f76045f6d", "score": "0.66612846", "text": "function addTime2(id, time, a){\n\tvar rows = document.getElementsByClassName(\"time-row\");\n for (var k = 0; k<rows.length; k++) {\n \t\trow2=rows[k].childNodes[1];\n \t\trow3=rows[k].childNodes[2];\n if ((row2==undefined) || (row3==undefined)){\n contents ='<div class=\"col-sm-4\">'+\n '<div class=\"card time\" id=\"'+id+'\">'+\n '<div class=\"card-body\">'+\n '<h5 class=\"card-title time-name\" contenteditable=\"true\"><span class=\"fa fa-edit\" contenteditable=\"false\"></span>'+time+'</h5>'+\n '<p style=\"text-align:right; margin-top:-20px\"><span onclick=\"deleteTime(this)\" class=\"fa fa-times\"></span></p>'+\n '<div class=\"dropzone\"></div>'+\n '</div>'+\n '</div>'+\n '</div>';\n var timeslot = htmlToElement(contents);\n rows[k].appendChild(timeslot);\n timeEventHandler(timeslot);\n var cards = createCourseCards(a);\n addToContainer(cards, timeslot.childNodes[0].childNodes[0].childNodes[2]);\n return true;\n }\n }\n // Adding a new row with a time slot card\n contents ='<div class=\"row time-row extra-time\">'+\n '<div class=\"col-sm-4\">'+\n '<div class=\"card time\" id=\"'+id+'\">'+\n '<div class=\"card-body\">'+\n '<h5 class=\"card-title time-name\" contenteditable=\"true\"><span class=\"fa fa-edit\" contenteditable=\"false\"></span>'+time+'</h5>'+\n '<p style=\"text-align:right; margin-top:-20px\"><span onclick=\"deleteTime(this)\" class=\"fa fa-times\"></span></p>'+\n '<div class=\"dropzone\"></div>'+\n '</div>'+\n '</div>'+\n '</div>'+\n '</div>';\n var timeslot = htmlToElement(contents);\n document.getElementById('time-slot-container').appendChild(timeslot);\n timeEventHandler(timeslot.childNodes[0]);\n var cards = createCourseCards(a);\n addToContainer(cards, timeslot.childNodes[0].childNodes[0].childNodes[0].childNodes[2]);\n}", "title": "" }, { "docid": "841c4605e09825ef1e6577da3fcd8e9b", "score": "0.6395937", "text": "function addTime(){\n var numSlots = document.getElementsByClassName('time').length;\n // Adding a single time slot card\n\n\tvar rows = document.getElementsByClassName(\"time-row\");\n for (var k = 0; k<rows.length; k++) {\n\t\trow2 = rows[k].childNodes[1];\n\t\trow3 = rows[k].childNodes[2];\n if ((row2==undefined) || (row3==undefined)){\n contents ='<div class=\"col-sm-4\">'+\n '<div class=\"card time\" id=\"slot'+(numSlots+1).toString()+'\">'+\n '<div class=\"card-body\">'+\n '<h5 class=\"card-title time-name\" contenteditable=\"true\"><span class=\"fa fa-edit\" contenteditable=\"false\"></span>New Time</h5>'+\n '<p style=\"text-align:right; margin-top:-20px\"><span onclick=\"deleteTime(this)\" class=\"fa fa-times\"></span></p>'+\n '<div class=\"dropzone\"></div>'+\n '</div>'+\n '</div>'+\n '</div>';\n timeslot = htmlToElement(contents);\n rows[k].appendChild(timeslot);\n timeEventHandler(timeslot);\n temp = timeslot;\n return;\n }\n }\n // Adding a new row with a time slot card\n contents ='<div class=\"row time-row extra-time\">'+\n '<div class=\"col-sm-4\">'+\n '<div class=\"card time\" id=\"slot'+(numSlots+1).toString()+'\">'+\n '<div class=\"card-body\">'+\n '<h5 class=\"card-title time-name\" contenteditable=\"true\"><span class=\"fa fa-edit\" contenteditable=\"false\"></span>New Time</h5>'+\n '<p style=\"text-align:right; margin-top:-20px\"><span onclick=\"deleteTime(this)\" class=\"fa fa-times\"></span></p>'+\n '<div class=\"dropzone\"></div>'+\n '</div>'+\n '</div>'+\n '</div>'+\n '</div>';\n timeslot = htmlToElement(contents);\n document.getElementById('time-slot-container').appendChild(timeslot);\n timeEventHandler(timeslot.childNodes[0]);\n}", "title": "" }, { "docid": "425d544492625e0ef80c8b888a9f5f47", "score": "0.6347155", "text": "function buildPage(json){\n document.getElementById('course-list').innerHTML=\"\";\n document.getElementById('time-slot-container').innerHTML=\"\";\n courseObjList = json[\"courseObjList\"];\n console.log(\"Here\", json['timeObjList']['not-scheduled']);\n var cards = createCourseCards(json['timeObjList']['not-scheduled']);\n addToContainer(cards, document.getElementById('course-list'));\n var timeObjList = json['timeObjList'];\n for (var el in timeObjList) {\n if (el != 'not-scheduled'){\n addTime2(el, timeObjList[el]['time'], timeObjList[el]['courses']);\n }\n }\n}", "title": "" }, { "docid": "a052e4d83f7a222ef65f917d2c183549", "score": "0.6338854", "text": "function createCourseCards(a){\n var cards = [];\n if (Object.keys(courseObjList).length > 0){\n console.log(\"courseObjList\");\n console.log(courseObjList);\n console.log(a);\n for (var k=0, el; el = a[k]; k++) {\n console.log(el);\n var rec = courseObjList[el];\n console.log(rec);\n contents ='<div class=\"course-test\" id=\"'+rec['crn']+'\">'+\n '<div>'+\n '<span>'+rec['name']+'</span>'+\n '</div>'+\n '</div>';\n card = htmlToElement(contents)\n if (document.getElementById(rec['name'])){\n console.log('Course has already been added');\n }\n else{\n //document.getElementById('course-list').appendChild(card)\n card.setAttribute('draggable', true);\n var i = parseInt(rec['color']);\n card.style.backgroundColor=color_list[i];\n //events fired on the draggable target\n card.addEventListener(\"dragstart\", function( ev ) {\n //console.log(ev.target.id);\n ev.dataTransfer.setData(\"text\", ev.target.id);\n checkConflicts(ev.target.id);\n }, false);\n cards.push(card);\n }\n }\n }\n return cards;\n}", "title": "" }, { "docid": "62b973849deb35c0c411cdfc51844a0c", "score": "0.6217785", "text": "function ProcessSessionCourses(data)\n{\n cur_slot = data.length;\n \n // If there are courses returned get schedule data\n if( data.length > 0 )\n {\n CalcSchedules();\n }\n\n $(\"#added_courses\").empty()\n // Add the courses to the list\n for( var i = 0; i < data.length; i++ )\n {\n var p = $(\"<p>\",{\n text:data[i],\n slot_id:i,\n });\n $(\"#added_courses\").append( p );\n }\n \n BindCourseClick();\n}", "title": "" }, { "docid": "c42cfd364fd7f1874012a68ecfffd63b", "score": "0.6130254", "text": "function addCourses(courses) {\n for (var i = 0; i < courses.length; i++) {\n addCourse(courses[i], document.getElementById(\"courses\"));\n }\n}", "title": "" }, { "docid": "7690e9af5b492199ca6d5fe54834b727", "score": "0.60008687", "text": "function addCourseToAccordions(addedCourse) {\n // Add selected courses to each major accordion.\n var accordions = $(\".accordion\");\n for (var i = 0; i < accordions.length; i++) {\n addCourseToAccordion(addedCourse, accordions[i]);\n }\n}", "title": "" }, { "docid": "14e421592cf325d8bd1ac6a688f2b3bc", "score": "0.59772414", "text": "function createSlotSchedule(slot, container) {\r\n const div = document.createElement(\"div\"); // create the rectangular box\r\n div.classList.add(\"schedule\");\r\n div.classList.add(\"schedule-item\");\r\n \r\n const firstSpanWrapper = document.createElement(\"span\"); // first span contains the header (which slot is taken)\r\n const h4 = document.createElement(\"h4\");\r\n h4.textContent = \"Паркомясто: \" + slot[\"zone\"] + slot[\"code\"]; // for example: \"Паркомясто: B7\"\r\n firstSpanWrapper.appendChild(h4);\r\n \r\n const secondSpanWrapper = document.createElement(\"span\"); // second span contains information about the taken slot (when and for what interval)\r\n const p = document.createElement(\"p\");\r\n p.textContent = slot[\"date\"] + \", \" + slot[\"start_time\"] + \"—\" + slot[\"end_time\"]; // for example: \"2021-06-24, 15:00-17:00\"\r\n secondSpanWrapper.appendChild(p);\r\n \r\n // append both spans to the div element (the rectangular box)\r\n div.appendChild(firstSpanWrapper);\r\n div.appendChild(secondSpanWrapper);\r\n \r\n // append the rectangular box (which contains information about the given reserved slot) to the container element\r\n container.appendChild(div);\r\n }", "title": "" }, { "docid": "d407f3ccaf650e221b0c1ee35bcbfbb9", "score": "0.5971931", "text": "function buildCourseHTML() {\r\n\tvar courses = getCourses();\r\n\t\r\n\t$('#courseCards').empty();\r\n\t\r\n\tcourses.forEach(function(course) {\r\n\t\t$('#courseCards').append(`\r\n\t\t\t<div class=\"card mt-3\" id=\"course` + course.id + `\">\r\n\t\t\t\t<div class=\"card-header\">\r\n\t\t\t\t\t<div class=\"d-flex align-items-center\">\r\n\t\t\t\t\t\t<span class=\"font-weight-bold mr-auto\" style=\"font-size:16px;\">` + course.courseName + `</span>\r\n\t\t\t\t\t\t<button class=\"btn float-right\" id=\"editCourse` + course.id + `\" style=\"background-color:transparent;\" data-toggle=\"modal\" data-target=\"#classForm\">\r\n\t\t\t\t\t\t\t<i class=\"fa fa-pen\"></i>\r\n\t\t\t\t\t\t</button>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class=\"container mt-2 mb-2\">\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<div class=\"col text-right\">Pattern: </div>\r\n\t\t\t\t\t\t<div class=\"col-8\" name=\"1\">` + course.meetPattern + `</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<div class=\"col text-right\">Time: </div>\r\n\t\t\t\t\t\t<div class=\"col-8\">` + course.startTime + ` - ` + course.endTime + `</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"row\">\r\n\t\t\t\t\t\t<div class=\"col text-right\">Location: </div>\r\n\t\t\t\t\t\t<div class=\"col-8\">` + course.building + ' ' + course.room + `</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t`);\r\n\t});\r\n}", "title": "" }, { "docid": "586e3a1e27db7f706bcb589ee8231f58", "score": "0.59717655", "text": "function AddCourseCallback()\n{\n // Get the new schedules\n CalcSchedules();\n \n // Add click listeners\n BindCourseClick();\n}", "title": "" }, { "docid": "16e3d3364435a46417b67ab8ba8c97ab", "score": "0.59692544", "text": "function save() {\n // initiate an empty JSON object to store all data\n var timeObjList = {};\n\n // grab data from all the time slots on the page\n var slots = document.getElementsByClassName(\"time\");\n for (var i = 0, t; t = slots[i]; i++) {\n var id = t.id;\n // getting the label for the time slot and all its courses\n // default 6 slots\n if (i<6){\n var label=t.childNodes[1].childNodes[1].innerText;\n var courses=t.childNodes[1].childNodes[3].childNodes;\n }\n // extra slots created\n else{\n var label=t.childNodes[0].childNodes[0].innerText;\n var courses=t.childNodes[0].childNodes[2].childNodes;\n }\n\n // create the entry for the time slot in the JSON storage object\n timeObjList[id] = {};\n timeObjList[id][\"time\"]=label;\n timeObjList[id][\"courses\"]=[];\n\n // push data in the time slot\n if (courses.length>0){\n for (var k = 0; k<(courses.length); k++){\n timeObjList[id][\"courses\"].push(courses[k].id)\n }\n }\n }\n\n // store the unscheduled courses (courses not in time slots)\n timeObjList[\"not-scheduled\"] = [];\n var container = document.getElementById('course-list');\n var courses = container.childNodes;\n if (courses.length>1){\n for (var k=1; k<(courses.length); k++){\n timeObjList[\"not-scheduled\"].push(courses[k].id);\n }\n }\n\n // capture the current timestamp\n var date = new Date();\n var y = date.getFullYear();\n m = date.getMonth();\n d = date.getDate();\n h = date.getHours();\n min = date.getMinutes();\n fname = m+'-'+d+'-'+y+'--'+h+'-'+min+'.json';\n format = \"json\";\n var content = {courseObjList, timeObjList};\n\n // save the JSON storage with the name as current timestamp\n download(fname, format, JSON.stringify(content, null, '\\t'));\n}", "title": "" }, { "docid": "4e12c5505d5ee8310bf3631e41508df3", "score": "0.59660596", "text": "function addCourseToAccordion(addedCourseObj, accordion) {\n\n // Get the collection of header/content pairs.\n var accordion = accordion.children[0];\n // Pray the DOM never changes.\n var progName = accordion.parentElement.parentElement.children[0].innerText;\n\n // A list of the DOM children of the accordion.\n var kids = accordion.children;\n var numReqs = kids.length / 2; // children.length always even.\n\n // Create a list of all requirements that addedCourse satisfies.\n var satisfiedReqs = [];\n\n // For each \"requirement\" category in this accordion:\n req_loop:\n for (var j = 0; j < numReqs; j++) {\n var reqName = kids[2 * j].children[0].children[0].innerText;\n var reqPanelHeading = kids[2 * j];\n\n // A list of each \"slot\" into which courses can be added\n var subreqList = kids[2 * j + 1].children;\n\n // Iterate over all slots.\n // If the added course is in a subreq's popover,\n // Replace that subreq with the course name + checkmark + semester.\n for (var k = 0; k < subreqList.length; k++) {\n\n // If addedCourse in subreqlist's popover:\n // Store this subreq as a match, and check next req.\n // ignore struck out courses\n var satisfiedCourse = satisfiesSubreq(addedCourseObj[\"name\"], subreqList[k], true);\n\n // If this subreq is satisfied by added course AND\n // this slot is not already filled with another course:\n if (satisfiedCourse != null && !(\"hiddenHTML\" in subreqList[k])) {\n // Gather relevant information about course.\n var satisfiedDict = {};\n satisfiedDict[\"reqPanelHeading\"] = reqPanelHeading;\n satisfiedDict[\"subreqList\"] = subreqList;\n satisfiedDict[\"firstSatisfied\"] = k;\n satisfiedDict[\"satisfiedCourse\"] = satisfiedCourse[0];\n satisfiedDict[\"popoverString\"] = satisfiedCourse[1];\n satisfiedDict[\"meta\"] = satisfiedCourse[2];\n satisfiedReqs.push(satisfiedDict);\n break req_loop;\n }\n }\n }\n\n // We now have a list of all satisfied reqs for this program.\n // If there is only one satisfied req, add it.\n if (satisfiedReqs.length == 1) {\n addCourseToRequirement(addedCourseObj, satisfiedReqs[0]);\n }\n // More than one satisfied req! Ask user to disambiguate.\n else if (satisfiedReqs.length > 1){\n return; // TODO IMPLEMENT promptDisambiguation and remove this.\n // resolution object storing user choices\n // Let resolutionObj contain course, semester, program, requirement.\n var res = promptDisambiguation(addedCourseObj, satisfiedReqs);\n\n // this is likely totally borked even if it did work\n // Insert override into db\n addOverrideToUser(res[\"course\"], res[\"semester\"], res[\"program\"], res[\"requirement\"]);\n\n // Display the override locally. (add to enrolled courses list, update accordions\n // TODO\n }\n}", "title": "" }, { "docid": "cb81df58ce954277c08be2564345b10e", "score": "0.5956429", "text": "function addCourse(course, body) {\n var div = document.createElement(\"div\");\n div.addEventListener(\"click\", didSelectCourse);\n div.id = course.code;\n div.setAttribute(\"class\", \"container\");\n\n addTextNode(course.title + \", \" + course.code, div);\n addTextNode(course.programme + \", \" + course.level, div);\n addTextNode(\"Semester: \" + course.semester, div);\n\n body.append(div);\n}", "title": "" }, { "docid": "86b14651fe1f3f719d8e9c4b535bda86", "score": "0.59413797", "text": "function RemoveCourse( slot )\n{\n Dajaxice.ssu.remove_course( Dajax.process, { slot_id:slot } );\n Dajaxice.ssu.make_schedules( Dajax.process );\n}", "title": "" }, { "docid": "f46cb8fdaf2e12bbda8690c2d21d6c20", "score": "0.5935836", "text": "function addCourse()\n{\n var courseId = coursesSelect.options[coursesSelect.selectedIndex].value;\n var course = courseList[courseId];\n\n if(isCourseInList(courseId)) {\n alert(\"A UC já está na lista\");\n return;\n }\n\n course[\"url\"] = getCourseURL(courseId);\n\n //Find what kind of classes the course has (PROBLEMS, TEORICA...)\n let loads = getCourseLoads(courseId);\n\n course[\"loads\"] = [];\n for(i in loads)\n {\n let loadLetter = courseLoadNameToLetter(loads[i].type);\n course.loads.push({text: loads[i].type, value: loadLetter, checked: true});\n }\n\n app.selectedCourses.push(course);\n}", "title": "" }, { "docid": "65b5c740cfddb675aa419c4b6e67d0f8", "score": "0.59234995", "text": "function append_time_slots(data, accordion_id) {\n\n $('#' + accordion_id + ' .accordion-inner').html(' ');\n\n $.each(data, function (key, value) {\n\n render_time_slot(data[key], accordion_id);\n\n });\n }", "title": "" }, { "docid": "87fa5ffc671082b1035c56b3e3b27cb6", "score": "0.5918561", "text": "function placeCards ( gameStateObject ) {\n var slots = document.getElementsByClassName('cardSlot')\n for(var i=0; i < slots.length; i++) {\n slots[i].innerHTML = \"\";\n\n if (gameStateObject.deck.cards.length < 10) {\n gameStateObject.deck = new Deck();\n }\n slots[i].appendChild( createCard( gameStateObject.deck.pickCard() ) );\n }\n}", "title": "" }, { "docid": "03a6677ccb03039aa11833a955886e49", "score": "0.59043294", "text": "function processTimecards(tcs) {\n var Ptimecards = [];\n $scope.totalHrsDay = 0;\n for (i = 0; i < tcs.length; i++) {\n if (tcs[i][$scope.selDayName] !== 0) { // Ex: tcs.tuesday!= 0\n var set = {};\n set.selDate = new Date($scope.selDate);\n if (tcs[i].sys_id) set.sys_id = tcs[i].sys_id;\n //if (tcs[i].u_project) set.u_project = tcs[i].u_project.value;\n if (tcs[i].u_project) set.u_project = LocalStorageService.getProjectNameBySysID(tcs[i].u_project.value);\n //if (tcs[i].task) set.task = tcs[i].task.value;\n if (tcs[i].task) set.task = LocalStorageService.getTaskNumberBySysID(tcs[i].task.value);\n if (tcs[i].u_story) set.story = LocalStorageService.getStoryNumberBySysID(tcs[i].u_story.value);\n if (tcs[i].u_billable) set.u_billable = tcs[i].u_billable;\n if (tcs[i].category) set.category = tcs[i].category;\n // timecard.sunday = 3 hrs;\n if (tcs[i][$scope.selDayName]) set.hours = tcs[i][$scope.selDayName] || 0;\n // get Total hours for current or selected date or day \n $scope.totalHrsDay += Number(set.hours);\n // timecard.u_saturday_work_notes (work notes)\n if (tcs[i][\"u_\" + $scope.selDayName + \"_work_notes\"]) set.comments = tcs[i][\"u_\" + $scope.selDayName + \"_work_notes\"];\n if (tcs[i].state) set.state = tcs[i].state;\n Ptimecards.push(set);\n }\n }\n $scope.timecards = Ptimecards;\n }", "title": "" }, { "docid": "01c3b1c45d5c1e27813d46c15447eb47", "score": "0.5901601", "text": "function add_newCard(all_cards, method = \"json\") {\n var byHand = \"\";\n var previous_cards;\n if (method == \"byHand\") {\n byHand += \"up-to-date\";\n previous_cards = document.querySelectorAll(\".up-to-date\");\n }\n\n if (typeof previous_cards !== \"undefined\" && previous_cards.length > 0) {\n previous_cards.forEach((element) => {\n element.remove();\n });\n }\n\n for (i = 0; i < all_cards.length; i++) {\n card_to_add = card_template(byHand, all_cards, i);\n\n var containers1 = document.querySelector(\".layout\");\n containers1.innerHTML += card_to_add;\n datas_refresher();\n }\n}", "title": "" }, { "docid": "3434461ee775a1345fcf1622efba837a", "score": "0.5885146", "text": "appendCourse(newCourse_) {\n this.courseList.push(newCourse_);\n this.$controlElement.children().first().append(newCourse_.$controlElement);\n }", "title": "" }, { "docid": "370203a435f2a89f13174b1cf3f67b51", "score": "0.5849819", "text": "function render_time_slot(time_slot_obj, accordion_id) {\n\n //console.log(time_slot_obj);\n\n if ((Object.keys(time_slot_obj).length) > 3) {\n\n if(time_slot_obj.admin && time_slot_obj.cat_id == 4){\n\n return $('#' + accordion_id + ' .accordion-inner').append('<div class=\"text-center alert alert-danger\"><a href=\"#\" class=\"time_slot\" data-time=\"' + time_slot_obj.time + '\" data-court=\"' + time_slot_obj.court_id + '\" data-bookingid=\"'+time_slot_obj.booking_id+'\">'+time_slot_obj.player1+' '+(time_slot_obj.player2? ' & '+time_slot_obj.player2 : '')+'</br>'+time_slot_obj.booking_description+'</a></div>');\n }\n\n return $('#' + accordion_id + ' .accordion-inner').append('<div class=\"text-center alert alert-danger\">' +time_slot_obj.player1+' '+(time_slot_obj.player2? ' & '+time_slot_obj.player2 : '')+'</br>'+time_slot_obj.booking_description+'</a></div>');\n }\n\n return $('#' + accordion_id + ' .accordion-inner').append('<div class=\"text-center alert alert-success\"><a href=\"#\" class=\"time_slot\" data-court=\"' + time_slot_obj.court_id + '\" data-timeslot=\"' + time_slot_obj.timeslot_id + '\">' + time_slot_obj.time + '</a></div>');\n\n }", "title": "" }, { "docid": "907df65cf93034b6d7ca34e784beae8f", "score": "0.58214116", "text": "function addTimes(parent,selectedRegNum)\n{\n \n \n //Removes the time selection if already there\n if(parent.children(\".class-times\").length > 0 )\n {\n parent.remove();\n }\n if(parent.children(\".course-info\").length > 0 )\n {\n parent.children(\".course-info\").remove();\n }\n\n //Puts the time section there for this class\n parent.append(getListOfTimes(parent,selectedRegNum));\n setOnClickEvents();\n}", "title": "" }, { "docid": "9e4b878286d4196654a0f819416db1b8", "score": "0.5815682", "text": "putClockUp(){\n // Convert the placeholder template script to a string\n let clockCardTemplate = $('#clockCards').html();\n // render the html for the clocks\n $(this.clockPlaceholder).append(Mustache.render(clockCardTemplate, this));\n this.aRenderTime();\n }", "title": "" }, { "docid": "eb78a530c304e2595d174c7b11dee6b5", "score": "0.58114773", "text": "function setCards() {\n activeContainer = 'cards-container';\n var cardsContainer = document.getElementById('cards-container');\n for (var i = 0; i < allCoins.length; i++) { // Looping through all Coins and making a card with each one \n if (i <= 150) { //~ Limited for the first 100 coins at the moment\n var cardDiv = buildCardHTML(allCoins[i], i);\n cardsContainer.append(cardDiv);\n }\n }\n}", "title": "" }, { "docid": "720bc887a602265a8d388dff0928ce87", "score": "0.57566285", "text": "createSlots() {\n var me = this,\n slotOrder = me.getSlotOrder(),\n hours = [],\n minutes = [],\n slots = [],\n ln, i;\n\n for (i = 0, ln = 24; i < ln; i++) {\n hours.push({\n text: i,\n value: i\n });\n }\n\n for (i = 0, ln = 60; i < ln; i = i + 5) {\n minutes.push({\n text: Ext.String.leftPad(i, 2, '0'),\n value: i\n });\n }\n\n slotOrder.forEach(function (item) {\n slots.push(me.createSlot(item, hours, minutes));\n });\n\n me.setSlots(slots);\n }", "title": "" }, { "docid": "795e6c4ce06c7768d3596dc234531dda", "score": "0.57527936", "text": "function dragTimeLineCard() {\n $($('#topCardSlots')).append(\"<div id=8 class='firstCard correct'><img src=img//c8.png></div>\");\n}", "title": "" }, { "docid": "a855d9548dfa34a16c7f32883d7b0672", "score": "0.57337457", "text": "function renderTimeSlots()/*:void*/ {\n var slots/*:Array*/ = [];\n\n this.timeSlots.forEach(function(timeSlot/*:**/)/*:void*/ {\n slots.push(com.coremedia.ui.data.beanFactory.createLocalBean({'name': timeSlot.name}));\n });\n this.getLocalModel().set(this.TIME_SLOTS, slots);\n }", "title": "" }, { "docid": "a33d4dec4ef49b77ac772194c7273cca", "score": "0.5703347", "text": "function _addCourse(cou) {\n var level = $scope.levelRef[cou.level];\n\n // Compile to DOM\n angular.element(document.getElementById('courseCards')).append($compile(\n '<div class=\"col-sm-3\">' +\n '<md-card class=\"general-card md-whiteframe-8dp no-padding\" id=' + cou._id + '>' +\n '<div class=\"header-card\">' +\n '<img src=\"/static/images/design/blackboard.svg\" width=\"50px\" height=\"50px\" />' +\n '</div>' +\n '<md-card-title-text>' +\n '<div class=\"center-card\">' +\n '<p class=\"no-padding\"> ' + cou.name + '</p>' +\n '<p class=\"no-padding\"> ' + level + '</p>' +\n '</div>' +\n '<md-button class=\"md-raised button-eliminate\" ng-click=\"goToCourse(\\'' + cou._id + '\\', $event)\">Ir al curso</md-button>' +\n '</md-card-title-text> ' +\n '</md-card></div>'\n )($scope));\n }", "title": "" }, { "docid": "1834c9b75caeaea9510177691b71c527", "score": "0.57017446", "text": "appendCards() {\n for(let i in this.cards) {\n this.html_content_gameArea.appendChild(this.cards[i].html_card);\n }\n }", "title": "" }, { "docid": "e83ee10049fc774b951ba26506672d70", "score": "0.5683868", "text": "function addToCart(data){\n courseTotal += 1;\n //Taking data id attribute value and assigning it to key\n idKey = $(this).attr('data-id');\n //Substract -1 from key so searching from json data works correctly\n key = idKey - 1;\n //Getting Json data again so we can work with it\n $.getJSON( \"kurssit.json\", function( data ) {\n var addingCourse = {\n courseId : idKey,\n courseName : data.courses[key].name,\n coursePoints : data.courses[key].points,\n };\n courseCart.push(addingCourse);\n console.log(courseCart);\n\n /* for (var jsonKey in data.courses) {\n courseCart[jsonKey] = data.courses[jsonKey];\n }\n console.log(data.courses[key]);\n */\n if (courseCart[key] == undefined) {\n coursesToAdd += idKey + \",\";\n courseCart[key] = 1;\n\n }\n /*else {\n //alert(\"this course already added\");\n courseTotal -= 1;\n }*/\n courseName.push(data.courses[key].name);\n coursePoints.push(data.courses[key].points);\n courseID.push(idKey);\n\n\n pointsTotal += data.courses[key].points;\n if (data.courses[key].category_uuid == id) {\n courseType.push(\"perusopinnot\");\n }\n else if (data.courses[key].category_uuid == id2) {\n courseType.push(\"ydinopinnot\");\n }\n else {\n courseType.push(\"valinnaiset\");\n }\n\n for (var i in courseID) {\n //console.log( courseName[i] + \": Nimi <br>\" + courseID[i] + \": ID <br>\" + coursePoints[i] + \": Pisteet <br>\" + courseTotal + \": Kursseja Yhteensä <br> \" + pointsTotal + \"Pisteitä yhteensä \");\n }\n\n\n showCourseCart();\n removeDIV(idKey);\n });\n\n\n}", "title": "" }, { "docid": "839b9bfa1dcc8458b475fc95ac0672a9", "score": "0.5655476", "text": "function slotRender(slots, element) {\n slots.map((time) => {\n let newTime = tConvert(time);\n element.innerHTML +=\n '<div class=\"slot ml-1 shadow-sm\" onclick=\"togglelock(this)\">' +\n '<input type=\"checkbox\" class=\"lock\" checked value=\"' + time + '\">' +\n '<span class=\"singleSlot\">' + newTime + '</span>' +\n '<i class=\"fas fa-unlock\"></i>' +\n '</div>';\n });\n}", "title": "" }, { "docid": "104367c4ed11617342837e2a8f048eb7", "score": "0.56519884", "text": "function addClassToSemester(semesterCardId, title, dept, course_num, credits, description, courseId) {\n\tvar course = document.createElement(\"li\");\n\t\n\t//update id\n\tcourse.id = courseId;\n\n\t//fill up the course with nutritious content\n\tvar html = '<div class=\"collapsible-header active\">' +\n\t\t'<div class=\"collapsible-header-title-left ' + dept + '\">' + dept + ' ' + course_num + '</div>' +\n\t\t'<div class=\"collapsible-header-title-right\"><span>' + credits + '</span></div>' +\n\t\t'</div>' +\n\t\t'<div class=\"collapsible-body\" style=\"display: block;\">' +\n\t\t'<h5 class=\"center-text\">' + title + '</h5>' +\n\t\t'<p>' + description + '</p>' +\n\t\t'<div class=\"center-btn\">' +\n\t\t'<a class=\"waves-effect waves-light btn red\" onclick=\"deleteCourse(this.parentElement.parentElement.parentElement.id)\">Remove</a>' +\n\t\t'</div></div>';\n\n\tcourse.innerHTML = html;\n\n\t//add to semester course list\n\tdocument.getElementById(semesterCardId).appendChild(course);\n}", "title": "" }, { "docid": "86c61abbad5955d89dce7d48c443c1cf", "score": "0.5629764", "text": "function addCourt(index, mobile) {\n var courtDiv = document.createElement(\"div\");\n courtDiv.id = \"courtSubDiv\" + index.toString();\n if (mobile == false) {\n courtDiv.className = \"4u$ 12$(medium)\";\n } else {\n courtDiv.className = \"12u$ 12$(medium)\";\n }\n\n courtDiv.innerHTML = \"<strong>Court \" + (index + 1).toString() + \"</strong>\";\n document.getElementById(\"courtsDiv\").appendChild(courtDiv);\n\n // Create cur player table\n var curTable = document.createElement('table');\n var row1 = curTable.insertRow(0);\n var row2 = curTable.insertRow(1);\n var row1col1 = row1.insertCell(0);\n row1col1.id = \"cur_\" + index.toString() + \"_0\";\n row1col1.innerHTML = 'Player 1';\n\n var row1col2 = row1.insertCell(1);\n row1col2.id = \"cur_\" + index.toString() + \"_1\";\n row1col2.innerHTML = 'Player 2';\n\n var row2col1 = row2.insertCell(0);\n row2col1.id = \"cur_\" + index.toString() + \"_2\";\n row2col1.innerHTML = 'Player 3';\n\n var row2col2 = row2.insertCell(1);\n row2col2.id = \"cur_\" + index.toString() + \"_3\";\n row2col2.innerHTML = 'Player 4';\n\n courtDiv.appendChild(curTable);\n}", "title": "" }, { "docid": "898ca81797fa66290f2de5c57b87946e", "score": "0.5625832", "text": "addCard(card) {\n this._container.append(card);\n }", "title": "" }, { "docid": "a07f444d134b48251162dedce9a72178", "score": "0.56236243", "text": "function addEventListenerOnTimeSlots() {\n let timeSlots = document.querySelectorAll(\".booking-times div\");\n timeSlots.forEach(slot => {\n slot.addEventListener(\"click\", handleTimeSlotSelection);\n });\n }", "title": "" }, { "docid": "e2656cd7e651b64720ed9a9a1c825be4", "score": "0.5610899", "text": "function htmlCourseList(courses, num, courseBought) {\n\tlet htmlCourses = \"\";\n\tif (courseBought != null) {\n\t\tif (num == null) {\n\t\t\tcourses.forEach(item => {\n\t\t\t\thtmlCourses += `\n <div class=\"col-md-2\">\n <div class=\"course\">\n <img src=\"${item.image}\"/>\n <h6 class=\"course-title\">${item.title}</h6>\n <small class=\"course-content\">\n ${item.content}\n </small>\n <div class=\"course-price\">\n <span>${item.price}$</span>\n <small>499$</small>\n </div>\n <div class=\"seller-label\">Sale 10%</div>\n <div class=\"course-overlay\">\n <a href=\"details.html\" onclick=\"courseDetail(${item.id})\">\n <h6 class=\"course-title\">\n ${item.title}\n </h6>\n <div class=\"course-author\">\n <b>Lê Trung Tín</b>\n <span class=\"mx-1\"> | </span>\n <b class=\"text-capitalize\">${item.categoryTitle}</b>\n </div>\n <div class=\"course-info\">\n <span><i class=\"fa fa-play-circle\"></i> ${item.lectureCount}</span>\n <span class=\"mx-1\"> | </span>\n <span><i class=\"fa fa-clock-o\"></i> ${item.hourCount}</span>\n </div>\n <small class=\"course-content\">\n ${item.content}\n </small>\n </a>\n\t\t\t\t\t\t\t${courseBought.includes(item.id)\n\t\t\t\t\t? `<button class=\"btn-sm btn-dark text-white w-100\" disabled>Add to cart</button>\n ` : `<button class=\"btn btn-sm btn-danger text-white w-100\" onclick=\"addCart(${item.id})\" id=\"addCartBtn_${item.id}\">Add to cart</button> `} </div>\n </div>\n </div>\n \t\t`\n\t\t\t})\n\t\t} else {\n\t\t\tcourses.slice(0, num).forEach(item => {\n\t\t\t\thtmlCourses += `\n <div class=\"col-md-3\">\n <div class=\"course\">\n <img src=\"${item.image}\"/>\n <h6 class=\"course-title\">${item.title}</h6>\n <small class=\"course-content\">\n ${item.content}\n </small>\n <div class=\"course-price\">\n <span>${item.price}$</span>\n <small>499$</small>\n </div>\n <div class=\"seller-label\">Sale 10%</div>\n <div class=\"course-overlay\">\n <a href=\"details.html\" onclick=\"courseDetail(${item.id})\">\n <h6 class=\"course-title\">\n ${item.title}\n </h6>\n <div class=\"course-author\">\n <b>Lê Trung Tín</b>\n <span class=\"mx-1\"> | </span>\n <b class=\"text-capitalize\">${item.categoryTitle}</b>\n </div>\n <div class=\"course-info\">\n <span><i class=\"fa fa-play-circle\"></i> ${item.lectureCount}</span>\n <span class=\"mx-1\"> | </span>\n <span><i class=\"fa fa-clock-o\"></i> ${item.hourCount}</span>\n </div>\n <small class=\"course-content\">\n ${item.content}\n </small>\n </a>\n \n ${courseBought.includes(item.id)\n\t\t\t\t\t? `<button class=\"btn-sm btn-dark text-white w-100\" disabled>Add to cart</button>\n ` : `<button class=\"btn btn-sm btn-danger text-white w-100\" onclick=\"addCart(${item.id})\" id=\"addCartBtn_${item.id}\">Add to cart</button> `}\n </div>\n </div>\n </div>\n \t\t`\n\t\t\t})\n\t\t}\n\t} else {\n\t\tif (num == null) {\n\t\t\tcourses.forEach(item => {\n\t\t\t\thtmlCourses += `\n <div class=\"col-md-2\">\n <div class=\"course\">\n <img src=\"${item.image}\"/>\n <h6 class=\"course-title\">${item.title}</h6>\n <small class=\"course-content\">\n ${item.content}\n </small>\n <div class=\"course-price\">\n <span>${item.price}$</span>\n <small>499$</small>\n </div>\n <div class=\"seller-label\">Sale 10%</div>\n <div class=\"course-overlay\">\n <a href=\"details.html\" onclick=\"courseDetail(${item.id})\">\n <h6 class=\"course-title\">\n ${item.title}\n </h6>\n <div class=\"course-author\">\n <b>Lê Trung Tín</b>\n <span class=\"mx-1\"> | </span>\n <b class=\"text-capitalize\">${item.categoryTitle}</b>\n </div>\n <div class=\"course-info\">\n <span><i class=\"fa fa-play-circle\"></i> ${item.lectureCount}</span>\n <span class=\"mx-1\"> | </span>\n <span><i class=\"fa fa-clock-o\"></i> ${item.hourCount}</span>\n </div>\n <small class=\"course-content\">\n ${item.content}\n </small>\n </a>\n\t\t\t\t\t\t\t<button class=\"btn btn-sm btn-danger text-white w-100\" onclick=\"addCart(${item.id})\" id=\"addCartBtn_${item.id}\">Add to cart</button> \n\t\t\t\t\t\t</div>\n </div>\n </div>\n \t\t`\n\t\t\t})\n\t\t} else {\n\t\t\tcourses.slice(0, num).forEach(item => {\n\t\t\t\thtmlCourses += `\n <div class=\"col-md-3\">\n <div class=\"course\">\n <img src=\"${item.image}\"/>\n <h6 class=\"course-title\">${item.title}</h6>\n <small class=\"course-content\">\n ${item.content}\n </small>\n <div class=\"course-price\">\n <span>${item.price}$</span>\n <small>499$</small>\n </div>\n <div class=\"seller-label\">Sale 10%</div>\n <div class=\"course-overlay\">\n <a href=\"details.html\" onclick=\"courseDetail(${item.id})\">\n <h6 class=\"course-title\">\n ${item.title}\n </h6>\n <div class=\"course-author\">\n <b>Lê Trung Tín</b>\n <span class=\"mx-1\"> | </span>\n <b class=\"text-capitalize\">${item.categoryTitle}</b>\n </div>\n <div class=\"course-info\">\n <span><i class=\"fa fa-play-circle\"></i> ${item.lectureCount}</span>\n <span class=\"mx-1\"> | </span>\n <span><i class=\"fa fa-clock-o\"></i> ${item.hourCount}</span>\n </div>\n <small class=\"course-content\">\n ${item.content}\n </small>\n </a>\n <button class=\"btn btn-sm btn-danger text-white w-100\" onclick=\"addCart(${item.id})\" id=\"addCartBtn_${item.id}\">Add to cart</button>\n </div>\n </div>\n </div>\n \t\t`\n\t\t\t})\n\t\t}\n\t}\n\treturn htmlCourses;\n}", "title": "" }, { "docid": "9b5213e5145daa65feacfc9a641fdcae", "score": "0.5610103", "text": "function drawCard() {\n let numColumns = 9;\n\n $('.playerSetup').empty();\n $('.teeBoxContainer').empty();\n $('.teeBox').empty();\n $('.submit').empty();\n $('.myCourse').append(`<h3>${courseName[0]}</h3>`);\n $('.myCourse').append(`<div class=\"centerMe\">${courseName[1]}</div>`);\n $('.myCourse').append(`<div class=\"centerMe\">${courseName[2]}</div>`);\n $('.myCourse').append(`<br>`);\n $('.myCourse').append(`<hr>`);\n $('.theCard').append(`<div class=\"column\" id=\"labelCard\"></div>`);\n $('.theCard').append(`<div class=\"column\" id=\"firstCard\"></div>`);\n $('.theCard').append(`<div class=\"column\" id=\"outCard\"></div>`);\n $('.theCard').append(`<div class=\"column\" id=\"secondCard\"></div>`);\n $('.theCard').append(`<div class=\"column\" id=\"inCard\"></div>`);\n $('.theCard').append(`<div class=\"column\" id=\"totCard\"></div>`);\n\n $('#labelCard').append(`<div class=\"cells0\">Hole</div>`);\n if (courseHoles[0].teebox[golfer[0].tee].teeType === 'auto change location') {\n courseHoles[0].teebox[golfer[0].tee].teeType = 'auto chg loc';\n }\n $('#labelCard').append(`<div class=\"cells0\">${courseHoles[0].teebox[golfer[0].tee].teeType}</div>`);\n $('#labelCard').append(`<div class=\"cells0\">Handicap</div>`);\n $('#labelCard').append(`<div class=\"cells0\">Par</div>`);\n for (let i = 0; i < golfer.length; i++) {\n $('#labelCard').append(`<div class=\"cells0\">${golfer[i].golfer}</div>`);\n }\n\n for (let c = 0; c < numColumns; c++) {\n $('#firstCard').append(`<div id=col${c} class=\"column\"></div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r0\">${courseHoles[c].hole}</div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r1\">${courseHoles[c].teebox[golfer[0].tee].yards}</div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r2\">${courseHoles[c].teebox[golfer[0].tee].hcp}</div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r3\">${courseHoles[c].teebox[golfer[0].tee].par}</div>`);\n for (let r = 4; r < (golfer.length + 4); r++) {\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r${r}\" onkeyup=\"totalScore(id)\" contenteditable=\"true\"></div>`);\n }\n }\n\n $('#outCard').append(`<div class=\"cells\">OUT</div>`);\n let outY = 0,\n outH = 0,\n outP = 0;\n for (let c = 0; c < 9; c++) {\n outY += courseHoles[c].teebox[golfer[0].tee].yards;\n outH += courseHoles[c].teebox[golfer[0].tee].hcp;\n outP += courseHoles[c].teebox[golfer[0].tee].par;\n }\n $('#outCard').append(`<div class=\"cells\">${outY}</div>`);\n $('#outCard').append(`<div class=\"cells\">${outH}</div>`);\n $('#outCard').append(`<div class=\"cells\">${outP}</div>`);\n for (let r = 4; r < (golfer.length + 4); r++) {\n $('#outCard').append(`<div class=\"cells\" id=out${r}></div>`);\n }\n\n numColumns = 18;\n for (let c = 9; c < numColumns; c++) {\n $('#secondCard').append(`<div id=col${c} class=\"column\"></div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r0\">${courseHoles[c].hole}</div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r1\">${courseHoles[c].teebox[golfer[0].tee].yards}</div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r2\">${courseHoles[c].teebox[golfer[0].tee].hcp}</div>`);\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r3\">${courseHoles[c].teebox[golfer[0].tee].par}</div>`);\n for (let r = 4; r < (golfer.length + 4); r++) {\n $('#col' + c).append(`<div class=\"cells\" id=\"c${c}r${r}\" onkeyup=\"totalScore(id)\" contenteditable=\"true\"></div>`);\n }\n }\n $('#inCard').append(`<div class=\"cells\">IN</div>`);\n let inY = 0,\n inH = 0,\n inP = 0;\n for (let c = 9; c < 18; c++) {\n inY += courseHoles[c].teebox[golfer[0].tee].yards;\n inH += courseHoles[c].teebox[golfer[0].tee].hcp;\n inP += courseHoles[c].teebox[golfer[0].tee].par;\n }\n $('#inCard').append(`<div class=\"cells\">${inY}</div>`);\n $('#inCard').append(`<div class=\"cells\">${inH}</div>`);\n $('#inCard').append(`<div class=\"cells\">${inP}</div>`);\n for (let r = 4; r < (golfer.length + 4); r++) {\n $('#inCard').append(`<div class=\"cells\" id=in${r}></div>`);\n }\n\n $('#totCard').append(`<div class=\"cells\">TOT</div>`);\n let totY = outY + inY,\n totH = outH + inH,\n totP = outP + inP;\n $('#totCard').append(`<div class=\"cells\">${totY}</div>`);\n $('#totCard').append(`<div class=\"cells\">${totH}</div>`);\n $('#totCard').append(`<div class=\"cells\" id=\"totP\">${totP}</div>`);\n for (let r = 4; r < (golfer.length + 4); r++) {\n $('#totCard').append(`<div class=\"cells\" id=tot${r}></div>`);\n }\n}", "title": "" }, { "docid": "fed9ac720f3d6f4890479962f9fec305", "score": "0.56038296", "text": "function updateSlotsFromSlotList() {\n\t\tslotsContainer.children('.'+cssSlot+', .'+cssSolidSlot).remove();\n\t\tvar startTimes = [];\n\t\tslotList.forAll(function(azslot){\n\t\t\tif (azslot.getPlanned_activities() != null && !azslot.getPlanned_activities().isEmpty()) {\n\t\t\t\tcreateSolidSlot(azslot.getStart_time().getHours().get() * 60 + parseInt(azslot.getStart_time().getMinutes().get()));\n\t\t\t} else {\n\t\t\t\tstartTimes.push(\n\t\t\t\t\t\tparseInt(azslot.getStart_time().getHours().get() * 60) + \n\t\t\t\t\t\tparseInt(azslot.getStart_time().getMinutes().get())\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\tstartTimes.sort(function(a,b){return a-b;});\n\t\timAdjustingVisibleSlots = true;\n\t\tfor (var i = 0; i < startTimes.length; i++) {\n\t\t\t// deal with adjacent slots\n\t\t\tvar j = i + 1;\n\t\t\twhile (j < startTimes.length && startTimes[j] == parseInt(startTimes[j-1]) + parseInt(slotDuration)) { j++;}\n\t\t\tj--;\n\t\t\tif (i != j) {\n\t\t\t\tcreateSlot(startTimes[i], (1+j-i) * slotDuration);\n\t\t\t\ti = j;\n\t\t\t} else {\n\t\t\t\tcreateSlot(startTimes[i]);\n\t\t\t}\n\t\t}\n\t\timAdjustingVisibleSlots = false;\n\t}", "title": "" }, { "docid": "e3165296336517e3eb4ac447bdb99a5e", "score": "0.5603415", "text": "function addCardToAppData(cardId, cardDescription, parentSectionId) {\n\n let tempCard = {\n id: `${cardId}`,\n text: `${cardDescription.textContent }`,\n members: []\n };\n console.log(tempCard);\n for (let list of appData.lists) {\n if (list.id === parentSectionId) {\n\n list.tasks.push(tempCard);\n }\n }\n }", "title": "" }, { "docid": "63d7e8b9c6a8036e7c631f5c3f44636c", "score": "0.55854225", "text": "addCourse(course) {\n\n\n if (course in this.courses) {\n this.courses[course]++\n }\n else { this.courses[course] = 1 }\n }", "title": "" }, { "docid": "416d511e62dce0250f69182efac9b0c7", "score": "0.55617064", "text": "function patientSlotRender(slots,element){\n slots.map((time) => {\n let newTime = tConvert(time);\n element.innerHTML +=\n `<div class=\"slot mx-1\"><input type=\"hidden\" class=\"slotvalue\" value=\"${time}\">\n <i class=\"fa-check-circle mr-1\"></i>\n <span class=\"singleSlot\">${newTime}</span>\n </div>`;\n });\n}", "title": "" }, { "docid": "28a1fa448b7d869999df02a8dff4fd00", "score": "0.55546063", "text": "function addCardToCompHandUI(card) {\n\t\tnewCardID = card.cardSuit + card.cardNumber;\n\t\t$(\"#drawnCardUI\").empty();\n\t\t$(\"#compHandUI\").append('<div id=\"' + newCardID + '\"><p class=\"tempCompCardStyle\">' + card.cardNumber + '<br>' + card.cardSuit + '</p></div>');\n\t\t$('#' + newCardID).addClass('card faceDown cardInHand ' + card.cardSuit + ' ' + card.cardNumber);\n\t}", "title": "" }, { "docid": "d361ff212d14fbf9142bc9326df1274f", "score": "0.5541304", "text": "function addIntoCart(course) {\n //create a <tr></tr>\n const row = document.createElement(\"tr\");\n //build the template\n row.innerHTML = `\n <tr>\n <td>\n <img src=\"${course.image}\" width=100>\n </td>\n <td>\n ${course.title}\n </td>\n <td>\n ${course.price}\n </td>\n <td>\n <a href=\"#\" class=\"remove\" data-id=${course.id}>X</a>\n </td>\n </tr>\n `;\n //Add into the shopping shoppingCart\n shoppingCartContent.appendChild(row);\n //add course to the local storage\n saveIntoStorage(course);\n}", "title": "" }, { "docid": "f5cc716dd733df8809b5ee15d17c2da5", "score": "0.55410343", "text": "function setCourseInfo(data) {\n courseInfo[0].textContent = data.coursename;\n courseInfo[0].innerHTML += ` - <span class=\"text-primary\">${data.coursecode}</span>`;\n\n //add the prof name\n courseInfo[1].textContent = `Professor: ${data.profname}`;\n\n //add prof image\n document.querySelectorAll('.profileImg')[1].src = `images/${data.profimg}`;\n\n //add the times\n data.classtime.forEach(time => {\n let newTime = `<li><span class=\"fa fa-clock-o\">${time}</span></li>`;\n courseInfo[1].parentElement.querySelector('ul').innerHTML += newTime;\n })\n\n }", "title": "" }, { "docid": "d3dad64c517ea9dbafb6e6d8619017be", "score": "0.55317706", "text": "addSpending(day, hours = \"10:00PM\", name, quantity) {\n const listSpending = document.querySelector(\"#dayOne\");\n const cardEmpty = document.querySelector(\".empty\").remove();\n //create element\n const div = document.createElement(\"div\");\n div.classList = \"spending shadowBox card p-3 mt-0\";\n div.innerHTML = `\n <div class=\"info\">\n <h3>${name}</h3>\n <span class=\"badge badge-pill badge-primary\">$${quantity}</span>\n </div>\n <div class=\"text-right hour\">\n <span>${hours}</span>\n </div>\n `;\n listSpending.appendChild(div);\n }", "title": "" }, { "docid": "ad8036e8bf6ffd7f9b80a9cb5616e23b", "score": "0.55179286", "text": "function listcourses(){\n\tjQuery.getJSON(\"/user/profile/courses\", function(data){\n\n\t\t$('#courses').contents().remove();\n\n\t\tvar courses = '';\n\t\tcourses += '<div id=\"scheduleaccordion\" class=\"panel-group\">';\n\t\tfor(i = 0; i < data.length; i++) {\n\t\t\tcourses += ' <div class=\"panel panel-primary\">';\n\t\t\tcourses += ' <div class=\"panel-heading\">';\n\t\t\tcourses += ' <h4 class=\"panel-title\">';\n\t\t\tcourses += ' <a aria-expanded=\"false\" class=\"collapsed\" data-toggle=\"collapse\" href=\"#collapse' + i + '\">';\n\t\t\tcourses += ' <div class=\"row\">';\n\t\t\tcourses += ' <div class=\"col-sm-5\">' + data[i].course_name +'</div>';\n\t\t\tcourses += ' <div class=\"col-sm-7 righttext\">Course Code: ' + data[i].course_code + '</div>';\n\t\t\tcourses += ' </div>';\n\t\t\tcourses += ' </a>';\n\t\t\tcourses += ' </h4>';\n\t\t\tcourses += ' </div>';\n\t\t\tcourses += ' <div style=\"height: 0px;\" aria-expanded=\"false\" class=\"panel-collapse collapse\" id=\"collapse' + i + '\">';\n\t\t\tcourses += ' \t<div class=\"panel-body\">';\n\t\t\tcourses += ' \t<div class=\"col-sm-offset-1\">';\n\t\t\tcourses += ' \t\t<div class=\"row\">';\n\t\t\tcourses += ' \t\t<div class=\"form-group col-sm-12\">';\n\t\t\tcourses += ' \t\t<p id=\"description' + i + '\">' + data[i].course_description + '</p>';\n\t\t\tcourses += ' \t\t\t</div>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t<div class=\"row\">';\n\t\t\tcourses += ' \t\t<div class=\"col-sm-6\">';\n\t\t\tcourses += ' \t\t \t <p id=\"coursestartdate' + i + '\">Start Date: ' + String(data[i].start_date).substring(0, 10) + '</p>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t<div class=\"col-sm-6\">';\n\t\t\tcourses += ' \t\t <p id=\"courseenddate' + i + '\">End Date: ' + String(data[i].end_date).substring(0, 10) + '</p>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t<div class=\"row\">';\n\t\t\tcourses += ' \t\t<div class=\"col-sm-6\">';\n\t\t\tcourses += ' \t\t<p id=\"coursetime' + i + '\">Time: ' + data[i].course_time + '</p>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t<div class=\"col-sm-6\">';\n\t\t\tcourses += ' \t\t<p id=\"courseinterval' + i + '\">Interval: ' + data[i].course_interval + '</p>';\n\t\t\tcourses += ' \t\t\t</div>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t<div class=\"row\">';\n\t\t\t//remove comment once target is linked\n\t\t\t//courses += ' \t \t<div class=\"col-sm-6\">';\n\t\t\t//courses += ' \t \t <p id=\"coursetarget' + i + '\">Target: ' + data[i].course_target + '</p>';\n\t\t\t//courses += ' \t \t\t</div>';\n\t\t\tcourses += ' \t \t\t<div class=\"col-sm-6\">';\n\t\t\tcourses += ' \t \t<p id=\"cost' + i + '\">Cost: ' + data[i].default_fee + '</p>';\n\t\t\tcourses += ' \t \t</div>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t<div class=\"row\">';\n\t\t\tcourses += ' \t\t<div class=\"col-sm-6\">';\n\t\t\tcourses += ' \t\t\t<button type=\"submit\" action=\"/register\" class=\"btn btn-default course-submit\" onclick=\"register(this)\" method=\"POST\" id=\"submit\" value=\"' +data[i].course_id +'\">Add to Cart</button>';\n\t\t\tcourses += ' \t\t</div>';\n\t\t\tcourses += ' \t\t\t</div>';\n\t\t\tcourses += ' \t</div>';\n\t\t\tcourses += ' \t</div>';\n\t\t\tcourses += ' </div>';\n\t\t\tcourses += ' </div>';\n\t\t}\n\t\tschedule += '</div>';\n\t\t$('#courses').append(courses);\n\t});\n}", "title": "" }, { "docid": "34c9b2d9a925096bae2a0cc087dc5cd3", "score": "0.5515093", "text": "function AddDayBlock( course, instance )\n{\n // Get the correct day to add block to\n var entries = $(\".\"+schedule.abbrToDay[instance.day]+\".week_day\").children(\".entries\");\n \n // Length and start time of the block\n var lengthValue = DifferenceMilitary( instance.start, instance.end );\n var startValue = MilitaryFloatValue( instance.start )-8;\n \n // Wrapper for the block\n var divWrapper = $(\"<div>\",{\n class:\"class_block_wrapper\",\n });\n \n // Create the block\n var block = $(\"<div>\",{\n class:\"class_block no_select\",\n course_id:course.id,\n instance_id:course.instance_id,\n start_time:instance.start,\n end_time:instance.end,\n });\n \n // Give the block an click function for the context menus\n $(block).click( function(e){\n ContextInit( this, context.dayBlockMenu, DayBlockContextCallback );\n }); \n \n // On Hover event to change z-index of elements\n $(block).mouseover( function(e){\n \n // Push all other day blocks to the bottom\n $(\".class_block\").css( \"z-index\", \"auto\" );\n \n // This is the top\n $(this).css( \"z-index\", 1 );\n }); \n \n // Calculate the size of the new block\n var heightMultiple = ( $(\".calendar\").height() - 20 ) / 16;\n var blockWidth = ($(\".calendar\").width() * 0.10)-2;\n \n // Position and size the new block\n $(block).css( { height: (lengthValue*heightMultiple)+\"px\", top: startValue*heightMultiple, width:(blockWidth)+\"px\" } );\n $(block).text( course.subject );\n \n $(divWrapper).append( block );\n $(entries).append( divWrapper );\n \n // Add a details row\n // First check if there is already a row with the same instance id, if so add\n // the time to the end of that row rather than make a new row\n var row = $(\".schedule_details_row[instance_id=\"+course.instance_id+\"]\");\n \n // If there is a row already add to it and shortcut out\n if( row.length > 0 )\n {\n $(row[0]).text( $(row[0]).text() + \", \" + instance.day + \", \" + instance.start + \" - \" + instance.end );\n return;\n }\n \n var details = $(\"<div>\",{\n text:course.subject + \": \" + instance.day + \", \" + instance.start + \" - \" + instance.end,\n class:\"schedule_details_row no_select\",\n course_id:course.id,\n instance_id:course.instance_id,\n start_time:instance.start,\n end_time:instance.end, \n });\n \n // Give the details row the same context menu as the block\n $(details).click( function(e){\n ContextInit( this, context.dayBlockMenu, DayBlockContextCallback );\n }); \n \n // Add details to schedule details\n $(\".schedule_details\").append( details );\n}", "title": "" }, { "docid": "9a41a9b5c9b9335aeb48b9a2dea2e0e6", "score": "0.551282", "text": "function addSchedule(class_name, cart_button_class) {\n listof_schedule.push(class_name);\n let listof_class_times = getClassTimes(class_name);\n for (session of listof_class_times) {\n // if blocks conflict, style=\"width1/2\"\n var session_start = session.start;\n var start_offset = 0\n var scheduleCell_div = document.getElementById(\"scheduleCell\" + session.day + \"-\" + session_start);\n var session_length = session.end - session.start;\n var block_size = 200 * session_length; // block height determined by end - start\n var template = `\n <button type=\"button\" class=\"classSession${class_name} btn btn-primary classSession\" onclick=\"ScheduleClicked('${class_name}', '${cart_button_class}')\" data-toggle=\"modal\" data-target=\"#cartModalCenter\" style=\"height:${block_size}%;\">${class_name}</button>\n `;\n //scheduleCell_div.style = `padding-top: ${start_offset}vh;`;\n scheduleCell_div.innerHTML = template;\n\n }\n}", "title": "" }, { "docid": "b072bdd43ea5bd8b09e879d5bae90549", "score": "0.5506478", "text": "function handleAddCourse(course) {\n // check that new course isn't already in array\n for (let i = 0; i < courses.length; i++) {\n // check for duplicate courses\n if (course.courseId === courses[i].courseId) {\n setWarning(\"This course is already in your plan.\");\n return;\n }\n }\n // check for required courses\n if (course.restriction === 1) {\n setWarning(\"Required courses are not allowed.\");\n return;\n }\n // check for graduate courses\n if (course.restriction === 2) {\n setWarning(\"Graduate courses are not allowed.\");\n return;\n }\n // see if the course has a defined number of credits\n if (isNaN(course.credits)) {\n\n // check with the user to see how many credits should be applied\n const creditArray = course.credits.split(\" to \");\n if (creditArray.length >= 2) {\n\n // prompt the user to enter the credits\n let credits = prompt(\n `Please select between ${creditArray[0]} and ${creditArray[1]} credits`, \"\"\n );\n credits = parseInt(credits, 10);\n\n // see if the user entered a valid number of credits\n if (credits >= creditArray[0] && credits <= creditArray[1] && !isNaN(credits)) {\n course.credits = credits;\n setCourses(prev => [...prev, course]);\n setWarning(\"\");\n } else {\n setWarning(\"Invalid credit hours selected for course.\");\n }\n\n }\n\n } else {\n // add the new course\n setCourses(prev => [...prev, course]);\n setWarning(\"\");\n }\n }", "title": "" }, { "docid": "a4b8c7e9aae8359dd75902595eba4c55", "score": "0.54831994", "text": "constructor() {\n this.timeSlots = [{\n id: 1,\n time: '9: AM',\n name: '',\n phone: ''\n },\n {\n id: 2,\n time: '10: AM',\n name: '',\n phone: ''\n },\n {\n id: 3,\n time: '11: AM',\n name: '',\n phone: ''\n },\n {\n id: 4,\n time: '12: AM',\n name: '',\n phone: ''\n },\n {\n id: 5,\n time: '1: PM',\n name: '',\n phone: ''\n },\n {\n id: 6,\n time: '2: PM',\n name: '',\n phone: ''\n },\n {\n id: 7,\n time: '3: PM',\n name: '',\n phone: ''\n },\n {\n id: 8,\n time: '4: PM',\n name: '',\n phone: ''\n },\n {\n id: 9,\n time: '5: PM',\n name: '',\n phone: ''\n },\n ]\n }", "title": "" }, { "docid": "22197df8a7ffd6bdf9418cdde43d3c35", "score": "0.5481429", "text": "createCard(n) {\n // initialising new elements\n let card = document.createElement('article'), subjectTag = document.createElement('span'), title = document.createElement('h3'), description = document.createElement('p'), informationDiv = document.createElement('div'), timeDetails = document.createElement('div'), dueDate = document.createElement('h4'), timeTag = document.createElement('span'), editIcon = document.createElement('a'), timeIcon = document.createElement('div'), line = document.createElement('HR');\n // setting classes and attributes\n editIcon.classList.add('edit');\n editIcon.innerHTML = `<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M0 12.6672V16H3.33287L13.1626 6.17028L9.82975 2.83741L0 12.6672ZM15.74 3.59286C16.0867 3.24625 16.0867 2.68632 15.74 2.33971L13.6603 0.259994C13.3137 -0.0866241 12.7538 -0.0866241 12.4072 0.259994L10.7807 1.88644L14.1136 5.21931L15.74 3.59286Z\" fill=\"#909090\"/>\n </svg>`;\n // time icon has been replaced with a priority rating - the priority is ranked in traffic light colors from green to red\n timeIcon.style.width = '12px';\n timeIcon.style.height = '12px';\n timeIcon.style.borderRadius = '12px';\n if (this.priorityRating == 'Low') {\n timeIcon.style.backgroundColor = '#70B815';\n } else if (this.priorityRating == 'Mid') {\n timeIcon.style.backgroundColor = '#E5C44C';\n } else if (this.priorityRating == 'High') {\n timeIcon.style.backgroundColor = '#F59273';\n }\n // setting relevant attributes\n card.classList.add('card');\n card.setAttribute('id', 't-' + n);\n subjectTag.classList.add('tag');\n subjectTag.classList.add('subject');\n timeDetails.classList.add('time-details');\n timeTag.classList.add('time');\n timeTag.classList.add('tag');\n // setting values\n title.textContent = this.name;\n description.textContent = this.description;\n subjectTag.textContent = this.subject;\n // if there is a due date, reformat for display on the cards\n if (this.dueDate.length != 0) {\n let dueDateElements = this.dueDate.split('-');\n let month = months[parseInt(dueDateElements[1]) - 1];\n let day = dueDateElements[2];\n dueDate.textContent = 'Due ' + day + ' ' + month;\n } else {\n dueDate.textContent = 'No due date';\n }\n // concatenating hour and minute estimated time durations\n if (this.estimatedTimeHr > 0 && this.estimatedTimeMin > 0) {\n timeTag.textContent = this.estimatedTimeHr + ' HR ' + this.estimatedTimeMin + ' MIN';\n } else if (this.estimatedTimeHr == 0 && this.estimatedTimeMin > 0) {\n timeTag.textContent = this.estimatedTimeMin + ' MIN';\n } else if (this.estimatedTimeHr > 0 && this.estimatedTimeMin == 0) {\n timeTag.textContent = this.estimatedTimeHr + ' HR';\n } else {\n timeTag.textContent = '∞';\n }\n // appending time details to time div\n timeDetails.appendChild(timeIcon);\n timeDetails.appendChild(dueDate);\n timeDetails.appendChild(timeTag);\n // appending everything to whole div\n // if (this.subject.length != 0) {\n card.appendChild(subjectTag);\n // }\n informationDiv.appendChild(title);\n informationDiv.appendChild(description);\n // card.appendChild(title)\n // card.appendChild(description)\n card.appendChild(informationDiv);\n card.appendChild(line);\n card.appendChild(timeDetails);\n card.appendChild(editIcon);\n // appending card to column\n let columnNames = document.querySelectorAll('.column-name');\n let cardContainers = document.querySelectorAll('.cards');\n let currentStatus = this.status;\n columnNames.forEach(function setColumn(object, index) {\n if (object.value == currentStatus) {\n cardContainers[index].appendChild(card);\n }\n });\n }", "title": "" }, { "docid": "ddc9b8943e2760fecdd07b856021a655", "score": "0.5462537", "text": "function getCourses() {\n if(coursesEl){coursesEl.innerHTML = ''};\n fetch(\"http://localhost:8888/moment5/api/read.php\")\n .then(response => response.json()\n .then(data => {\n data.forEach(courses => {\n if(coursesEl){coursesEl.innerHTML +=\n `<div class=\"course\"> \n<p> \n<b> Kurskod:</b> ${courses.code} <br/>\n<b> Kursnamn:</b> ${courses.name}<br/>\n<b> Progression:</b> ${courses.progression}<br/>\n<b> Kursplan:</b> <a class=\"syllabus_link\" href=\"${courses.coursesyllabus}\" target=\"_blank\">Länk här</a>\n</p>\n<button id=\"${courses.id}\" onClick=\"getOneToUpdate(${courses.id})\">Uppdatera</button>\n<button id=\"${courses.id}\" onClick=\"deleteCourse(${courses.id})\">Radera</button> \n</div>`}\n\n })\n }))\n}", "title": "" }, { "docid": "b42e6e89039e15b0c80a4bb01550666e", "score": "0.54574406", "text": "function startGame() {\n var fiveMinutes = 60 * 5,\n display = timer;\n startTimer(fiveMinutes, display);\n displayCards();\n cards.forEach((card, index) => {\n card.addEventListener(\"click\", addCard);\n card.addEventListener(\"click\", showCard);\n card.addEventListener(\"click\", validateCard);\n // card.setAttribute(\"type\", cards[index]);\n })\n}", "title": "" }, { "docid": "4020b6cf6e15acb8e918520c831ccc85", "score": "0.5457323", "text": "function displayProjCourse(){\n\n//=========Skill=========\n $(\".skill-set .skill-list li\").remove();\n for (var key in skillList) {\n $(\".skill-set .skill-list\").append(`\n <li class=\"text\">\n <div class=\"text\">${key}</div> \n <div class=\"percent\">${skillList[key]}%</div><i class=\"far fa-trash-alt \"></i>\n </li>\n `)\n }\n//=========courses=========\n $(\".courses-wrapper .courses li\").remove();\n courseList.forEach(function(val){\n $(\".courses-wrapper .courses\").append(`\n <li class=\"course\">\n <div class=\"wrapper\">\n <div class=\"course-title\">${val['code']}</div>\n <div class=\"text\">-${val['name']}</div>\n <i class=\"far fa-trash-alt \"></i>\n </div>\n </li>\n `)\n });\n}", "title": "" }, { "docid": "0e8411a6e96e0a149c9114f287865c12", "score": "0.5455736", "text": "addCard(cards) {\n cards.forEach((card, id) => {\n if (card instanceof Card) {\n card\n .setColumnId(this.columnNum)\n .setIdInColumn(this.cardsInColumn.length + id);\n }\n });\n //dodaje Card do kolumny\n this.cardsInColumn = this.cardsInColumn.concat(cards);\n // ustalam jaka będzie następna karta\n this._setNextCard();\n // ta kolumna nie jset pusta\n if (cards[0] instanceof Card)\n this.isEmpty = false;\n }", "title": "" }, { "docid": "8699437766867a35f4ff6deae52a7125", "score": "0.5446996", "text": "function addCourse(CRN, courses) {\n console.log(\"UserStore: Adding course crn \" + CRN + \" to user courses\");\n _courses.push(courses[CRN]);\n}", "title": "" }, { "docid": "747d2c350e8d605d08a7cebf4a8480e8", "score": "0.5444666", "text": "courseAdd(addButton){ \n addButton.addEventListener('click', e=>{\n let addValue = e.target;\n let buttonRow = addValue.parentElement.parentElement.parentElement;\n // row Headers element \n let rowDept = buttonRow.getElementsByTagName('td')[0].innerText;\n let rowTitle = buttonRow.getElementsByTagName('td')[1].innerText;\n let rowName = buttonRow.getElementsByTagName('td')[2].innerText;\n let rowTime = buttonRow.getElementsByTagName('td')[3].innerText;\n let rowCredit = buttonRow.getElementsByTagName('td')[4].innerText;\n let rowInstructor = buttonRow.getElementsByTagName('td')[5].innerText;\n let rowCRN = buttonRow.getElementsByTagName('td')[6].innerText;\n let rowGened = buttonRow.getElementsByTagName('td')[7].innerText;\n\n let addButtonDetails = [rowDept,rowTitle,rowName,rowTime,rowCredit,rowInstructor,rowCRN, rowGened]; \n\n const tableBody = document.querySelector('.add-body');\n const tr = document.createElement('tr');\n tr.classList.add('addRow');\n\n let addButtonIndex = 0;// local index for td elements \n for(let index = 0; index < 8; index++){\n const td = document.createElement('td');\n td.classList.add('addRowData');\n td.innerText = addButtonDetails[addButtonIndex];\n if(addButtonIndex === 4){\n td.classList.add('creditNumber');\n td.classList.remove('addRowData');\n }\n if(addButtonIndex === 7){\n td.classList.add('addCRN');\n td.classList.remove('addRowData');\n }\n addButtonIndex = addButtonIndex + 1;\n tr.appendChild(td)\n }\n \n const tdAddDrop = document.createElement('td');\n tdAddDrop.classList.add('addDrop');\n tdAddDrop.innerHTML=`<button class=\"add\"><i class = \"fas fa-plus\"></i>\n </button><button class=\"drop\"><i class=\"fa fa-trash\"></i></button>`\n tr.appendChild(tdAddDrop);\n\n // prevent repetition of same course addition \n var crnData = document.getElementsByClassName('addCRN');\n for(let crnIndex = 0; crnIndex < crnData.length; crnIndex++){\n if(crnData[crnIndex].innerHTML === addButtonDetails[7]){ // index 7 after the add table is constructed \n this.showAlert('This Course Has Already Been Added', 'danger');\n return;\n }\n }\n tableBody.appendChild(tr);\n \n //passing the deleteButtons to the subFunction\n const dropCourse = tdAddDrop.querySelector('.drop');\n this.courseDrop(dropCourse);\n\n // passing the addbuttons to the subfunction \n const addCourse = tdAddDrop.querySelector('.add');\n this.courseAddLocal(addCourse);\n }) \n }", "title": "" }, { "docid": "a75f156e71ff991ca2d6a2f51118a709", "score": "0.54294604", "text": "appendCard() {\n const template = document.querySelector('#cardTemplate').cloneNode(true);\n const cards = document.querySelector('.cards');\n\n // Modifying template\n template.setAttribute('id', `cardID-${this.ID}`);\n template.querySelector('.message-header p').innerText = this.name;\n template.querySelector('.message-body').innerHTML = cardContent(this.name);\n\n // Place node after focus banner and assign element object property\n cards.prepend(template);\n this.element = cards.children[0]; // eslint-disable-line prefer-destructuring\n\n setTimeout(removeAnimation, 1000, this.element);\n }", "title": "" }, { "docid": "d7c271370ee9072c4683a1b45cebf288", "score": "0.54037154", "text": "function showCurrentCoursesAndSchedule(){\r\n\t\tvar currSemester = window.bidit_globals.g_currSemester;\r\n\t\t//Deleting previous semester information from main screen\r\n\t\t$('#accordion2').empty();\r\n\t\tclearTimetableView();\t\t\r\n\r\n\t\t//Updating current semester info on main screen \r\n\t\tvar currAccordion = window.bidit_globals.g_allSemestersAccordions[currSemester];\r\n\t\tvar displaySettings = window.bidit_globals.g_coursesDisplaySettings[currSemester];\r\n\t\tvar MAIN_STR = 'ראשית';\r\n\t\tvar SUB_STR = 'משנית';\r\n\t\tvar OPTION_STR = 'אפשרות';\r\n\r\n\t\t// Creating accordion's html tags\r\n\t\t$.each(currAccordion,function(){\r\n\t\t\tvar courseName = this.cName;\r\n\t\t\tvar groupsArr = this.kvutzaData;\r\n\t\t\tvar currCourseNum = this.cNum;\r\n\t\t\tvar courseHeading = this.cName + ' (' + this.cNum + ')';\r\n\t\t\tvar numOfHavurot = this.havurotNum; \r\n\t\t\tbuildMainCoursesAccordion(currCourseNum,numOfHavurot,OPTION_STR,courseHeading);\r\n\r\n\t\t\t/* Iterates over the groups of one course */\r\n\t\t\t$.each(groupsArr,function(){\r\n\t\t\t\tvar gKind = this.kind;\r\n\t\t\t\tvar gHavura = getHavuraNum(this.havura);\r\n\t\t\t\tvar gNum = this.gNum;\r\n\t\t\t\tvar gLecturer = this.lecturer;\r\n\t\t\t\tvar gOfenHoraa = this.ofenHoraa;\r\n\r\n\t\t\t\tif(gKind == MAIN_STR){\r\n\t\t\t\t\taddGroupsToMainAccordion(currCourseNum, gNum, gLecturer, gOfenHoraa, gHavura, 'main');\r\n\t\t\t\t}\r\n\t\t\t\telse if(gKind == SUB_STR){\r\n\t\t\t\t\taddGroupsToMainAccordion(currCourseNum, gNum, gLecturer, gOfenHoraa, gHavura, 'sub');\r\n\t\t\t\t\t$('#subBorder' + currCourseNum + gHavura).show();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\t// Updating group selections on main accordion\r\n\t\t$.each(displaySettings, function(){\r\n\t\t\tvar cNum = this.cNum;\r\n\t\t\tvar cColor = this.cColor;\r\n\t\t\tvar courseObj = displaySettings[cNum];\r\n\t\t\tif(courseObj.cChosen == true){\r\n\t\t\t\t//Change chosen course color\r\n\t\t\t\t$('#'+cNum).css('background-color',cColor);\t\r\n\r\n\t\t\t\t//Iterating over current course's groups\r\n\t\t\t\t$.each(courseObj.groups, function(){\r\n\t\t\t\t\tif(this.gChosen == true){\r\n\t\t\t\t\t\tvar currGroupElement = $('li[name=\"'+ cNum + this.gNum +'\"]');\r\n\t\t\t\t\t\tcurrGroupElement.removeClass('course-cell-hover');\r\n\t\t\t\t\t\tcurrGroupElement.addClass('course-cell-highlight');\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Updating group selections on schedule\r\n\t\tupdateTimeTableView();\r\n\r\n\t\t//Updating total hours and total zchut hours for current semester\r\n\t\t$('#totalHours').text('שעות: ' + window.bidit_globals.g_totalHoursArr[currSemester]);\r\n\t\t$('#totalZchutHours').text('נקודות זכות: ' + window.bidit_globals.g_totalZchutHoursArr[currSemester]);\r\n\r\n\t\t/*refreshing the calendar and exams*/\r\n\t\tupdateExamsAndCalendar();\r\n\r\n\t\t/*clear and foucs on course search*/\r\n\t\tclearAndFocusCourseSearch();\r\n\t}", "title": "" }, { "docid": "41066342234458da2feace6c93ebd54d", "score": "0.54014266", "text": "function addHoles() {\r\n for (let p = 1; p <= numplayers; p++) {\r\n for (let h = 0; h <= mycourse.holes.length; h++) {\r\n $(`#colinfo${h + 1}`).html('');\r\n }\r\n }\r\n for (let i = 0; i < mycourse.holes.length; i++) {\r\n $(`#colinfo${i + 1}`).append(`<div class=\"hole-label\">Hole: ${i + 1}<div>`);\r\n }\r\n for (let p = 1; p <= numplayers; p++) {\r\n for (let h = 0; h <= mycourse.holes.length; h++) {\r\n $(`#colinfo${h + 1}`).append(`<label class=\"player-container\">\r\n <span class=\"name${p}\">Player ${p}</span><p class=\"namechange\" onclick=\"editname(this)\">Change Name</p><input onchange=\"totals(this)\" type=\"text\" id=\"p${p}h${h + 1}\"/></label>`);\r\n }\r\n }\r\n for (let h = 0; h <= mycourse.holes.length; h++) {\r\n $(`#colinfo${h + 1}`).append(`<div class=\"info\">Info: </div>`);\r\n }\r\n addYards();\r\n addPar();\r\n addHcp();\r\n $('.addPlayer').css('display', 'inline');\r\n}", "title": "" }, { "docid": "23c258bc599e8372b023ebc3b1c2feca", "score": "0.5395824", "text": "addDishToCourse (courseName, dishName, dishPrice) {\r\n const dish = {\r\n name: dishName,\r\n price: dishPrice,\r\n }\r\n if(courseName === 'appetizers'){\r\n this._course.appetizers.push(dish);\r\n }else if (courseName === 'mains'){\r\n this._course.mains.push(dish);\r\n }else if(courseName === 'desserts'){\r\n this._course.desserts.push(dish);\r\n }else{\r\n console.log('Kindly choose the right course');\r\n }\r\n }", "title": "" }, { "docid": "3c65829d9b0c1cfcdc2e8f5ab026c210", "score": "0.5386727", "text": "function addTask(){\n\n\t//getting current div containing all the lists\n\tconst currentTasks = document.getElementById(\"collection-of-todo-lists\");\n\n\tconst newTask = createNewCardDiv();\n\n\tcurrentTasks.appendChild(newTask);\n\n}", "title": "" }, { "docid": "7a29e1dfba7fa430b63ae08c07d4d7b2", "score": "0.5378166", "text": "function createNewDeck(array) {\n let cardDeck = document.querySelector('.deck');\n cardDeck.innerHTML = \"\";\n\n for (let card of array){\n // Create new card element\n let newCard = document.createElement('li');\n newCard.className = \"card\";\n newCard.innerHTML = card.innerHTML;\n cardDeck.appendChild(newCard);\n\n // Add event listeners\n newCard.addEventListener('click', cardList);\n newCard.addEventListener('click', beginTimer);\n }\n }", "title": "" }, { "docid": "827d6e911247c6320eaadaf16f489c40", "score": "0.5376711", "text": "function placeCards() {\n\tdeck.innerHTML = '';\n\n\tfor(let i = 0; i < cardArray.length; i++){\n\t\tlet card = document.createElement('LI');\n\t \tlet cardI = document.createElement('I');\n\t \tcard.appendChild(cardI);\n\t \tcard.classList.add('card');\n\t \tcard.addEventListener('click', displayCard);\n\t \tcardI.classList.add('fa');\n\t \tcardI.classList.add(cardArray[i]);\n\t \tdeck.appendChild(card);\n\t}\n}", "title": "" }, { "docid": "3001d05ec0e8e2bf06c760ffcae943d6", "score": "0.5371565", "text": "function addHourBlocks(iterations) {\n var currentTime = getCurrentHour(\"LT\");\n\n for (var i = 0; i < iterations; i++) {\n var textTime = blockHour + hourSuffix;\n\n planContainer = $(\"<div>\").addClass(\"row py-1\");\n\n timeText = $(\"<h6>\").addClass(\"text-center\").text(textTime);\n\n timeDiv = $(\"<div>\")\n .addClass(\"col-2 py-3 time-block align-middle\")\n .append(timeText);\n\n textDiv = $(\"<textarea>\")\n .addClass(\"col-8 py-3 overflow-auto\")\n .text(\"\")\n .attr(\"id\", textTime);\n setBackgroundColor(textDiv, currentTime, textTime);\n\n saveDiv = $(\"<div>\").addClass(\n \"col-1 py-3 save unsaved save-container border border-primary\"\n );\n\n planContainer.append(timeDiv, textDiv, saveDiv);\n\n $(\"#planner\").append(planContainer);\n\n addBlockHour();\n }\n}", "title": "" }, { "docid": "c8dc03bc33b88147d26fbcca9145f676", "score": "0.53683686", "text": "function doInTime() {\n timePassed++;\n if (timePassed%20 === 0 && counter < circletable.length) {\n container.appendChild(circletable[counter]);\n counter++;\n }\n addTransformation();\n}", "title": "" }, { "docid": "b96c421f36592002c14c726f6485b86c", "score": "0.53677106", "text": "function prepareShoppingCart() {\n var shoppingCart = document.getElementById(\"shoppingCart\")\n var tempInnerHTML = `<div style=\"border: solid 2px black;\">`\n for (var row = 0; row < 2; row++) {\n var tempHTML = `<div class=\"scheduleRow\">`\n for (var column = 1; column < 6; column++) {\n tempHTML += `<div class=\"card scheduleCell\" name=\"shoppingCart\" id=\"shoppingCart` + row + \"-\" + column + `\"> \n <button class=\"cartButton btn btn-primary notSelectedCart placeholder` + row + `-` + column + `\" data-toggle=\"modal\" data-target=\"#cartModalCenter\" style=\"font-size: 75%; display: none\" onclick=\"this.blur();\"> </div>\n </button>`\n }\n tempHTML += `</div>`\n tempInnerHTML += tempHTML\n }\n tempInnerHTML += `</div>`\n shoppingCart.innerHTML = tempInnerHTML\n\n for (var course of listof_cart) {\n var id = classesAndIds[course][0]\n var className = classesAndIds[course][1]\n var div = document.getElementById(classesAndIds[course][0])\n var button = `<div class=\"card scheduleCell\" name=\"shoppingCart\" id=\"` + id + `\"> \n <button class=\"cartButton btn btn-primary ` + (listof_schedule.includes(course) ? \"selectedCart\" : \"notSelectedCart\") + ` ` + className + `\" data-toggle=\"modal\" data-target=\"#cartModalCenter\" style=\"font-size: 75%; display: none\" onclick=\"CartClicked('${course}', '${className}')\"> </div>\n </button>`\n div.innerHTML = button\n }\n}", "title": "" }, { "docid": "451c9dd241911227673f3d6cdc3cffa8", "score": "0.53642994", "text": "function fillAvailableSlots(column, color, numOfSlots) {\n var numOfSlots = 0;\n for (var i = 0; i < row; i++) {\n console.log('varredura');\n if(boardCircles[i][column].hasClass('circle')){\n numOfSlots += 1;\n }\n }\n console.log('number of available slots', numOfSlots);\n if (numOfSlots !== 0) {\n boardCircles[numOfSlots-1][column].removeClass('circle');\n boardCircles[numOfSlots-1][column].addClass(color);\n }\n\n setTimeout(fillAvailableSlots, 2000);\n }", "title": "" }, { "docid": "808d939f567292216ca72d71d387945d", "score": "0.5362347", "text": "function createCard(jobs) {\n //create functionality to eraze previouse content from display area div\n document.getElementById(\"display_area\").innerHTML = \"\";\n\n for (let i = 0; i < jobs.length; i++) {\n\n //make a card\n let newCard = document.createElement(\"div\");\n newCard.setAttribute(\"class\", \"card mb-3 my_cards\");\n newCard.setAttribute(\"style\", \"max-width: 540px;\");\n\n //make outer div\n let outerDiv = document.createElement(\"div\");\n outerDiv.setAttribute(\"class\", \"row no-gutters\");\n newCard.appendChild(outerDiv);\n \n //make div for image\n let imageDiv = document.createElement(\"div\");\n imageDiv.setAttribute(\"class\", \"col-md-4\");\n outerDiv.appendChild(imageDiv);\n\n //adding image\n let newImage = document.createElement(\"img\");\n newImage.setAttribute(\"class\", \"card-img\");\n newImage.setAttribute(\"src\", `${jobs[i].company_logo}`);\n newImage.setAttribute(\"alt\", `${jobs[i].title}`)\n imageDiv.appendChild(newImage);\n\n //make div for cardBody\n let cardBodyDiv = document.createElement(\"div\");\n cardBodyDiv.setAttribute(\"class\", \"col-md-8\");\n outerDiv.appendChild(cardBodyDiv);\n\n //make card body\n let cardBody = document.createElement(\"div\");\n cardBody.setAttribute(\"class\", \"card-body\");\n cardBodyDiv.appendChild(cardBody);\n\n //make job title\n let jobTitle = document.createElement(\"h5\");\n jobTitle.setAttribute(\"class\", \"card-title\");\n jobTitle.innerHTML = `${jobs[i].title}`;\n cardBody.appendChild(jobTitle);\n\n //make job descr <p>\n let jobDescription = document.createElement(\"p\");\n jobDescription.setAttribute(\"class\", \"card-text\");\n let shortenedDescription;\n if (jobs[i].description.length < 10) {\n shortenedDescription = \"Check company's website for details\";\n } else {\n shortenedDescription = jobs[i].description.substring(0, 100);\n }\n jobDescription.innerHTML = `${shortenedDescription}...`;\n cardBody.appendChild(jobDescription);\n \n //make how to apply <p>\n let howToApply = document.createElement(\"p\");\n howToApply.setAttribute(\"class\", \"card-text\");\n howToApply.innerHTML = `Apply: ${jobs[i].how_to_apply}`;\n cardBody.appendChild(howToApply);\n\n //add btn for job details\n let btnJobDetails = document.createElement(\"button\");\n btnJobDetails.setAttribute(\"class\", \"btn btn-primary\");\n btnJobDetails.innerHTML = \"Job Details\"\n btnJobDetails.addEventListener(\"click\", ()=> {\n let detailsURL = `${jobs[i].url}`;\n window.open(detailsURL);\n })\n\n\n\n cardBody.appendChild(btnJobDetails);\n\n\n document.getElementById(\"display_area\").appendChild(newCard);\n}\n}", "title": "" }, { "docid": "666e8a3a9ce010f7802e019018a35b1d", "score": "0.53615427", "text": "function addJCards(container, id, cards, gameid,deckid)\n{\n window.App.data.deckid = deckid;\n window.App.data.gameid = gameid;\n window.App.data.jCardModels = new App.JCardCollection(cards);\n window.App.views.jCardsView = new App.JCardsView({model: window.App.data.jCardModels.findWhere({id: id}),\n collection: window.App.data.jCardModels,\n selectID:id});\n window.App.views.jCardsView.$el.appendTo(container);\n window.App.views.jCardsView.render();\n\n}", "title": "" }, { "docid": "6e1cca7d03c1214f9435b07fbca6b5f1", "score": "0.5360748", "text": "function clientTimeList(slotList, container, product, day, timelineStartHour, timelineEndHour) {\n\t// constants\n\tvar emptySlotHeight = 82; // Note: this should include borders!\n\tvar emptySlotWidth = 100; // Note: this should include borders!\n\tvar emptySlotBorderWidth = 1;\n\tvar slotDuration = product.getSlot_duration() == undefined ? 15 : product.getSlot_duration().get();\n\ttimelineStartHour = timelineStartHour == undefined ? 0 : timelineStartHour;\n\ttimelineEndHour = timelineEndHour == undefined ? 24 : timelineEndHour;\n\tvar cssHour = 'sim-ui-timelist-hour';\n\tvar cssEmptySlot = 'sim-ui-timelist-empty-slot';\n\tvar cssSlot = 'sim-ui-timelist-slot';\n\tvar cssSolidSlot = 'sim-ui-timelist-solid-slot';\n\tvar cssSlotDelete = 'sim-ui-timelist-slot-delete';\n\tvar cssSlotsContainer = 'sim-ui-timelist-slots-container';\n\tvar jqDataKey = 'sim-ui-timelist-slot';\n\t\n\t// derived values\n\tvar minuteHeight = emptySlotHeight / 60;\n\tproduct.getSlot_duration().addObserver(function(){slotDuration = product.getSlot_duration().get();});\n\n\t// private variables\n\tvar imAdjustingTheSlotList = false;\n\tvar imAdjustingVisibleSlots = false;\n\t\n\t// a container for this timeList\n\tvar list = $('<div>');\n\tcontainer.append(list);\n\t\n\t/*\n\t *\t+---------------------+\n\t *\t| Standard TimeLine |\n\t *\t+---------------------+ \n\t */\n\t\n\t// The timeline has a left column for the numbers of the hours \n\t// and a right column where the slots should go.\n\tvar timeline = $('<table>');\n\ttimeline.attr({cellspacing: \"0\", cellpadding: \"0\"});\n\ttimeline.css({'table-layout':'fixed', 'border-collapse':'collapse', 'border-spacing':'0px'});\n\tlist.append(timeline);\n\t\n\t// Construct the timeline with empty slots.\n\tfor (var i = timelineStartHour; i < timelineEndHour; i++) {\n\t\tvar row = $('<tr>'); \n\t\tvar left = $('<td>');\n\t\tleft.css({'border-width' : emptySlotBorderWidth+'px', height:emptySlotHeight+'px'});\n\t\tleft.addClass(cssHour);\n\t\tleft.html(i);\n\t\t\n\t\tvar right = $('<td>');\n\t\tright.css({\n\t\t\t'min-width'\t\t: emptySlotWidth - emptySlotBorderWidth + 'px',\n\t\t\t'border-width'\t: emptySlotBorderWidth + 'px',\n\t\t\theight\t\t\t: emptySlotHeight + 'px'\n\t\t});\n\t\tright.addClass(cssEmptySlot);\n\t\t\n\t\trow.append(left).append(right);\n\t\ttimeline.append(row);\n\t}\n\n\t// Slots can stretch different hours, so they will be absolutely positioned over the timeline table.\n\tvar slotsContainer = $('<div>');\n\tslotsContainer.css({\n\t\twidth\t: emptySlotWidth + 'px',\n\t\theight\t: (timelineEndHour - timelineStartHour) * emptySlotHeight + 'px',\n\t\tposition: 'absolute'\n\t});\n\tlist.append(slotsContainer);\n\t// update the position of the slotsContainer\n\tslotsContainer.offset(list.find('.'+cssEmptySlot).offset());\n\t\n\t/*\n\t *\t+--------------------------+\n\t *\t| SlotCreation Specifics |\n\t *\t+--------------------------+ \n\t */\n\t\n\tslotsContainer.addClass(cssSlotsContainer);\n\t\n\t// this column overlays the empty slots in the timeline\n\t// we will use this column to listen to mouseclicks.\n\tvar clickableCol = $(document.createElement('div'));\n\tclickableCol.css({\n\t\tposition\t: 'absolute',\n\t\tleft\t\t: 0,\n\t\ttop\t\t\t: 0,\n\t\twidth\t\t: '100%',\n\t\theight\t\t: '100%'\n\t});\n\tslotsContainer.html(clickableCol);\n\tclickableCol.click(function(event) {\n\t\tcreateSlot(computeStartTimeFromPageTopOffset(event.pageY));\n\t});\n\n\tfunction computeStartTimeFromPageTopOffset(pageY) {\n\t\t// the top offset of the clicked location within the slotsContainer\n\t\tvar innerOffset = pageY - slotsContainer.offset().top;\n\t\treturn timelineStartHour * 60 + roundToNearestFive(innerOffset / minuteHeight);\n\t}\n\t\n\t/**\n\t * Creates a solid slot.\n\t * It's simply a block at the given start time, with a height according to slotDuration.\n\t */\n\tfunction createSolidSlot(startTime) {\n\t\tvar slot = $(document.createElement('div'));\n\t\tslot.addClass(cssSolidSlot);\n\t\tslot.css({\n\t\t\t// initial height computed from the slot duration.\n\t\t\theight\t: slotDuration * minuteHeight + 'px',\n\t\t\tposition: 'absolute',\n\t\t\t// position the slot in the right place.\n\t\t\ttop\t\t: computeSlotsContainerTopOffset(startTime) + 'px'\n\t\t});\n\t\tslotsContainer.append(slot);\n\t}\n\t\n\t/**\n\t * Creates a slot.\n\t * It is put at the start hour and minute and has an initial height,\n\t * which is computed from the slotDuration.\n\t * \n\t * The vertical size is resizable, but slots can't be resized over each other\n\t * or outside the timeline.\n\t * Neither can they be resized smaller than the slotDuration.\n\t * \n\t * MinuteLength is optional and can be used to define an initial height other than the slot duration. \n\t */\n\tfunction createSlot(startTime, minuteLength) {\n\t\t// only create a new slot if there is room for it\n\t\tvar next = getNextSlotByTime(startTime);\n\t\tif (next != null && getStartTime(next) - startTime < slotDuration) {\n\t\t\treturn;\n\t\t}\n\t\t// also skip if the slot is too close to the bottom\n\t\tvar slotsContainerTopOffset = computeSlotsContainerTopOffset(startTime);\n\t\tif (slotsContainer.innerHeight() - slotsContainerTopOffset < slotDuration) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t// the slot\n\t\tvar slot = $(document.createElement('div'));\n\t\tslot.addClass(cssSlot);\n\t\tslot.css({\n\t\t\t// initial height computed from the slot duration.\n\t\t\theight\t: minuteLength == undefined ? slotDuration * minuteHeight + 'px' : minuteLength * minuteHeight + 'px',\n\t\t\tposition: 'absolute',\n\t\t\t// position the slot in the right place.\n\t\t\ttop\t\t: slotsContainerTopOffset + 'px'\n\t\t});\n\t\tslotsContainer.append(slot);\n\t\t\n\t\tvar slotDeleteSpan = $('<span>x</span>');\n\t\tslotDeleteSpan.addClass(cssSlotDelete);\n\t\tslotDeleteSpan.css({\n\t\t\tposition: 'absolute', \n\t\t\tright: '3px',\n\t\t\ttop : '0'\n\t\t});\n\t\tslot.append(slotDeleteSpan);\n\t\tslotDeleteSpan.click(function() {\n\t\t\tslot.remove();\n\t\t\tupdateSlotsData();\n\t\t\tupdateSlotsBoundaries();\n\t\t\tupdateSlotList();\n\t\t});\n\t\t\n\t\t// TODO: what do we put in the slot?\n\t\t// put in the start time\n\t\tvar startTimeSpan = $(document.createElement('span'));\n\t\tslot.append(startTimeSpan);\n\t\tupdateStartTimeSpan();\n\t\tslot.append(' - ');\n\t\t// create a span to hold the end time\n\t\tvar endTimeSpan = $(document.createElement('span'));\n\t\tslot.append(endTimeSpan);\n\t\t// compute the end time and put it in the span\n\t\tupdateEndTimeSpan();\n\t\t\n\t\t// computes the start time of the slot and puts it in the span\n\t\t// should be called when the slot is dragged\n\t\tfunction updateStartTimeSpan() {\n\t\t\tvar startTime = getStartTime(slot);\n\t\t\tstartTimeSpan.text(normalize(getHour(startTime)) + ':' + normalize(getMinute(startTime)));\n\t\t}\n\t\t\n\t\t// computes the end time of the slot and puts it in the span.\n\t\t// it's a separate function since it should also be called when the slot is resized\n\t\tfunction updateEndTimeSpan() {\n\t\t\tvar endTime = getStartTime(slot) + roundToNearestFive(slot.innerHeight() / minuteHeight); \n\t\t\tendTimeSpan.text(normalize(getHour(endTime)) + ':' + normalize(getMinute(endTime)));\n\t\t}\n\t\t\n\t\t// keep the slot inside the timeline\n\t\tif (slot.outerWidth() > emptySlotWidth) {\n\t\t\tslot.outerWidth(emptySlotWidth);\n\t\t}\n\t\t// fancy opacity TODO shouldn't really be here, should it?\n\t\tslot.fadeTo(0, 0.8);\n\t\t\n\t\t// options for the jquery ui resizable plugin\n\t\tvar resizeOptions = {\n\t\t\t\t// the slot is resizable in a downward (south) direction \n\t\t\t\thandles\t\t: 's',\n\t\t\t\t// and should not leave the timeline (and thus slotsContainer)\n\t\t\t\tcontainment\t: slotsContainer,\n\t\t\t\t// resize at slotDuration minute intervals\n\t\t\t\tgrid\t\t: [50, slotDuration * minuteHeight],\n\t\t\t\t// update the endtime of the slot on resize\n\t\t\t\tresize: function(){\n\t\t\t\t\tupdateEndTimeSpan();\n\t\t\t\t},\n\t\t\t\t// a slot can never be smaller than the slotDuration\n\t\t\t\tminHeight\t: slotDuration * minuteHeight,\n\t\t\t\t// update the slots\n\t\t\t\tstop\t\t: function(event) {\n\t\t\t\t\t// FIXME apparently resizable plugin partly ignores maxHeight and containment\n\t\t\t\t\t// see these logs\n//\t\t\t\t\tconsole.log('Max resizable height: '+slot.resizable('option', 'maxHeight'));\n//\t\t\t\t\tconsole.log('outerHeight: '+slot.outerHeight());\n//\t\t\t\t\tconsole.log('innerHeight: '+slot.innerHeight());\n//\t\t\t\t\t>> Max resizable height: 75\n//\t\t\t\t\t>> widgets.js:406outerHeight: 85\n//\t\t\t\t\t>> widgets.js:407innerHeight: 81\n\t\t\t\t\t// so let's just do it ourselves\n\t\t\t\t\tvar maxHeight = slot.resizable('option', 'maxHeight');\n\t\t\t\t\t// first check is for resizing over slots (ignoring maxHeight)\n\t\t\t\t\t// second check is for resizing over slotsContainer (ignoring containment)\n\t\t\t\t\tif (slot.innerHeight() > maxHeight \n\t\t\t\t\t\t\t|| slot.offset().top + slot.innerHeight() > slotsContainer.offset().top + slotsContainer.innerHeight()) {\n\t\t\t\t\t\tslot.innerHeight(slot.innerHeight() - slotDuration * minuteHeight);\n\t\t\t\t\t}\n\t\t\t\t\tupdateStartTimeSpan();\n\t\t\t\t\tupdateEndTimeSpan();\n\t\t\t\t\tupdateSlotsBoundaries();\n\t\t\t\t\tupdateSlotList();\n\t\t\t\t}\n\t\t};\n\t\t\n\t\t// options for the jquery ui draggable plugin\n\t\tvar draggableOptions = {\n\t\t\t\t// only drag vertical\n\t\t\t\taxis \t\t: 'y',\n\t\t\t\t// drag in 5 minute intervals\n//\t\t\t\tgrid \t\t: [50, 5 * minuteHeight],\n\t\t\t\t// snapping to edges of slotcontainer\n\t\t\t\tsnap\t\t: '.' + cssSlotsContainer+\", .\"+cssSlot,\n\t\t\t\tsnapMode \t: 'both',\n\t\t\t\tsnapTolerance:3*minuteHeight,\n\t\t\t\t// placeholder for the containment area\n\t\t\t\tcontainment\t: [],\n\t\t\t\t// update the times when the slot is being dragged\n\t\t\t\tdrag : function() {\n\t\t\t\t\tupdateStartTimeSpan();\n\t\t\t\t\tupdateEndTimeSpan();\n\t\t\t\t},\n\t\t\t\t// update the boundaries of previous and next slots\n\t\t\t\tstop\t\t: function(event) {\n\t\t\t\t\tupdateStartTimeSpan();\n\t\t\t\t\tupdateEndTimeSpan();\n\t\t\t\t\tupdateSlotsBoundaries();\n\t\t\t\t\tupdateSlotList();\n\t\t\t\t}\n\t\t};\n\t\t\n\t\t// make the slot resizable\n\t\tslot.resizable(resizeOptions);\n\t\t// make the slot draggable\n\t\tslot.draggable(draggableOptions);\n\n\t\tupdateSlotsData();\n\t\tupdateSlotsBoundaries();\n\t\tupdateSlotList();\n\t}\n\t\n\tfunction getAllSlotsSorted() {\n\t\treturn slotsContainer.children('.'+cssSlot).sort(function(a,b){return $(a).offset().top - $(b).offset().top;});\n\t}\n\tfunction getNextSlotByTime(time) {\n\t\tvar sortedSlots = getAllSlotsSorted();\n\t\tfor (var i = 0; i < sortedSlots.length; i++) {\n\t\t\tif (getStartTime($(sortedSlots[i])) > time) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn i < sortedSlots.length ? $(sortedSlots[i]) : null;\n\t}\n\tfunction getStartTime(slot) {\n\t\treturn parseInt(computeStartTimeFromPageTopOffset(slot.offset().top));\n\t}\n\tfunction getHour(time) {\n\t\treturn Math.floor(time / 60);\n\t}\n\tfunction getMinute(time) {\n\t\treturn roundToNearestFive(time % 60);\n\t}\n\t\n\t// adds a leading 0 if number < 10\n\tfunction normalize(number) {\n\t\treturn number < 10 ? '0' + number : number;\n\t}\n\t\n\t// Rounds the given number to the nearest Integer which can be fully divided by 5.\n\tfunction roundToNearestFive(number) {\n\t\tnumber = Math.round(number);\n\t\treturn number % 5 < 3 ? number - number % 5 : number + (5 - number % 5);\n\t}\n\t\n\t// computes the top offset required to place a slot at the given start time. \n\tfunction computeSlotsContainerTopOffset(time) {\n\t\treturn (time - timelineStartHour * 60) * minuteHeight;\n\t}\n\t\n\t/*\n\t * \t+--------------------+\n\t * \t| Update functions |\n\t * \t+--------------------+\n\t */\n\t\n\t/**\n\t * Updates the jquery data stored for all slots.\n\t * \n\t * jqDataKey : {next : nextSlot, previous: previousSlot}\n\t */\n\tfunction updateSlotsData() {\n\t\tvar slots = getAllSlotsSorted();\n\t\tslots.each(function(i, slot) {\n\t\t\tslot = $(slot);\n\t\t\tslot.data(jqDataKey, {\n\t\t\t\tprevious\t: i > 0 ? $(slots[i-1]) : null,\n\t\t\t\tnext\t\t: i < slots.length - 1 ? $(slots[i+1]) : null\n\t\t\t});\n\t\t});\n\t}\n\t\n\t/**\n\t * Updates the resizable and draggable boundaries for all slots.\n\t */\n\tfunction updateSlotsBoundaries() {\n\t\tvar slots = getAllSlotsSorted();\n\t\tslots.each(function(i, slot) {\n\t\t\tslot = $(slot);\n\t\t\tvar prev = i > 0 ? $(slots[i-1]) : null;\n\t\t\tvar next = i < slots.length - 1 ? $(slots[i+1]) : null;\n\t\t\tupdateDraggableUpperBoundary(slot, prev);\n\t\t\tupdateDraggableLowerBoundary(slot, next);\n\t\t\tupdateResizableBoundary(slot, next);\n\t\t});\n\t\t\n\t\tfunction updateDraggableUpperBoundary(lowerSlot, upperSlot) {\n\t\t\tvar oldContainment = lowerSlot.draggable('option', 'containment');\n\t\t\t// upperSlot is optional, without it we restrict dragging to the slotsContainer\n\t\t\tif (upperSlot == undefined) {\n\t\t\t\tlowerSlot.draggable('option', 'containment', \n\t\t\t\t\t\t[slotsContainer.offset().left,\n\t\t\t\t\t\t slotsContainer.offset().top,\n\t\t\t\t\t\t oldContainment[2],\n\t\t\t\t\t\t oldContainment[3]]);\n\t\t\t} else {\n\t\t\t\tlowerSlot.draggable('option', 'containment', \n\t\t\t\t\t\t[slotsContainer.offset().left,\n\t\t\t\t\t\t upperSlot.offset().top + upperSlot.outerHeight(),\n\t\t\t\t\t\t oldContainment[2],\n\t\t\t\t\t\t oldContainment[3]]);\n\t\t\t}\n\t\t}\n\t\tfunction updateDraggableLowerBoundary(upperSlot, lowerSlot) {\n\t\t\tvar oldContainment = upperSlot.draggable('option', 'containment');\n\t\t\t// lowerSlot is optional, without it we restrict dragging to the slotsContainer\n\t\t\tif (lowerSlot == undefined) {\n\t\t\t\tupperSlot.draggable('option', 'containment',\n\t\t\t\t\t\t[oldContainment[0],\n\t\t\t\t\t\t oldContainment[1],\n\t\t\t\t\t\t slotsContainer.offset().left + emptySlotWidth,\n\t\t\t\t\t\t slotsContainer.offset().top + slotsContainer.innerHeight() - upperSlot.outerHeight()]);\n\t\t\t} else {\n\t\t\t\tupperSlot.draggable('option', 'containment', \n\t\t\t\t\t\t[oldContainment[0],\n\t\t\t\t\t\t oldContainment[1],\n\t\t\t\t\t\t slotsContainer.offset().left + emptySlotWidth,\n\t\t\t\t\t\t lowerSlot.offset().top - upperSlot.outerHeight()]);\n\t\t\t}\n\t\t}\n\t\tfunction updateResizableBoundary(upperSlot, lowerSlot){\n\t\t\tif (lowerSlot == undefined) {\n\t\t\t\t// boundary will be set be the containment\n\t\t\t\tupperSlot.resizable('option', 'maxHeight', slotsContainer.innerHeight());\n\t\t\t} else {\n\t\t\t\tupperSlot.resizable('option', 'maxHeight', lowerSlot.offset().top - upperSlot.offset().top);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates the slotsList with all slots currently visible in the list.\n\t */\n\tfunction updateSlotList() {\n\t\tif (!imAdjustingVisibleSlots) {\n\t\t\timAdjustingTheSlotList = true;\n\t\t\tslotList.clear();\n\t\t\tvar slots = getAllSlotsSorted();\n\t\t\t// split long slots in smaller slots with length = slotDuration\n\t\t\tslots.each(function(i, el){\n\t\t\t\tvar slot = $(el);\n\t\t\t\tvar minutes = slot.innerHeight() / minuteHeight;\n\t\t\t\tfor (var j = 0; j < Math.round(minutes / slotDuration); j++) {\n\t\t\t\t\tvar startTime = getStartTime(slot) + j * slotDuration;\n\t\t\t\t\tslotList.add(new Item({\n\t\t\t\t\t\tproduct : product.getId(),\n\t\t\t\t\t\tday : day.get(),\n\t\t\t\t\t\t'start_time' : {hours: getHour(startTime), minutes : getMinute(startTime)},\n\t\t\t\t\t\tplanned_activities : []\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t});\n\t\t\timAdjustingTheSlotList = false;\n\t\t}\n\t}\n\t\n\t/**\n\t * Updates the currently visible slots from the data in the slotList.\n\t */\n\tfunction updateSlotsFromSlotList() {\n\t\tslotsContainer.children('.'+cssSlot+', .'+cssSolidSlot).remove();\n\t\tvar startTimes = [];\n\t\tslotList.forAll(function(azslot){\n\t\t\tif (azslot.getPlanned_activities() != null && !azslot.getPlanned_activities().isEmpty()) {\n\t\t\t\tcreateSolidSlot(azslot.getStart_time().getHours().get() * 60 + parseInt(azslot.getStart_time().getMinutes().get()));\n\t\t\t} else {\n\t\t\t\tstartTimes.push(\n\t\t\t\t\t\tparseInt(azslot.getStart_time().getHours().get() * 60) + \n\t\t\t\t\t\tparseInt(azslot.getStart_time().getMinutes().get())\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\tstartTimes.sort(function(a,b){return a-b;});\n\t\timAdjustingVisibleSlots = true;\n\t\tfor (var i = 0; i < startTimes.length; i++) {\n\t\t\t// deal with adjacent slots\n\t\t\tvar j = i + 1;\n\t\t\twhile (j < startTimes.length && startTimes[j] == parseInt(startTimes[j-1]) + parseInt(slotDuration)) { j++;}\n\t\t\tj--;\n\t\t\tif (i != j) {\n\t\t\t\tcreateSlot(startTimes[i], (1+j-i) * slotDuration);\n\t\t\t\ti = j;\n\t\t\t} else {\n\t\t\t\tcreateSlot(startTimes[i]);\n\t\t\t}\n\t\t}\n\t\timAdjustingVisibleSlots = false;\n\t}\n\t\n\t/*\n\t * \t+---------------+\n\t * \t| Databinding |\n\t * \t+---------------+\n\t */\n\tslotList.addObserver(function() {\n\t\tif (!imAdjustingTheSlotList) {\n\t\t\tupdateSlotsFromSlotList();\n\t\t}\n\t});\n}", "title": "" }, { "docid": "7a6da29498fde91205bdf16719442351", "score": "0.53552574", "text": "function clickAddCourses(){\n\t\t$('.add_courses').click(function(){\n\t\t\t$('#courses-tab').click();\n\t\t});\n\t}", "title": "" }, { "docid": "500ce029c4815f1ef7620b215ea2a929", "score": "0.5345395", "text": "function pushCourse (course) {\n\tjson.courses.push(course);\n\tjson.scraped_courses = json.courses.length;\n}", "title": "" }, { "docid": "5e38f36b7bdf94b212cf3e9ae3908ce7", "score": "0.5336013", "text": "function addNoneAddedCourse(){\n\t\tif ( $('.added_courses').children().length <= 0 ) {\n\t\t $('.added_courses').append($.parseHTML('<tr class=\"course_added_none\"><td class=\"text-nowrap alert-info\" colspan=\"6\">None</td></tr>'));\n\t\t}\n\t\tcalculateTotalUnits();\n\t}", "title": "" }, { "docid": "e00d89b4041ab0bcc758989ec1cf7dfa", "score": "0.53315437", "text": "renderCourseGrid() {\n\t\tlet grid = document.getElementById(\"course-grid\");\n\t\twhile (grid.firstChild) grid.removeChild(grid.firstChild); // Clear grid\n\n\t\tlet cols = this.plan.get_longest() + 1; // +1 leaves an empty column to add another course to a semester\n\t\tfor (let i = 0; i < this.plan.semesters.length; i++) {\n\t\t\tlet semester = this.plan.semesters[i];\n\t\t\tlet tr = document.createElement(\"tr\");\n\t\t\t\n\t\t\tlet th = document.createElement(\"th\");\n\t\t\tth.className = \"redips-mark\";\n\t\t\tth.innerHTML = semester.semester_year + \" \" + semester.season_name() + \"<br><span class='ch' id='ch\"+semester.semester_year+\"-\"+semester.semester_season+\"'>0 credit hours</span>\";\n\t\t\ttr.appendChild(th);\n\t\t\t\n\t\t\t// Delete button\n\t\t\tif (semester.semester_courses.length == 0) {\n\t\t\t\tlet dele = document.createElement(\"button\");\n\t\t\t\tdele.className = \"btn btn-sm btn-danger delete-semester\";\n\t\t\t\tdele.innerHTML = '<i class=\"fa fa-trash\"></i>';\n\t\t\t\tdele.addEventListener(\"click\", e => {\n\t\t\t\t\tthis.plan.remove_semester(semester.semester_season, semester.semester_year);\n\t\t\t\t\t// Add semester to dropdown so it can be re-added\n\t\t\t\t\tthis.makeElement(\"option\", \"addSemesterSelect\", semester.season_name() + \" \" + semester.semester_year, semester.semester_year + \"-\" + semester.semester_season);\n\t\t\t\t\tthis.update();\n\t\t\t\t});\n\t\t\t\tth.appendChild(dele);\n\t\t\t}\n\t\t\t\n\t\t\tfor (let j = 0; j < cols; j++) {\n\t\t\t\tlet td = document.createElement(\"td\");\n\t\t\t\tif (semester.semester_courses[j] != undefined) {\n\t\t\t\t\ttd.innerHTML = semester.semester_courses[j].to_html();\n\t\t\t\t}\n\t\t\t\ttd.dataset[\"x\"] = j;\n\t\t\t\ttd.dataset[\"y\"] = i;\n\t\t\t\ttr.appendChild(td);\n\t\t\t}\n\n\t\t\tgrid.appendChild(tr);\n\t\t}\n\t\t\n\t\tthis.arrowRender.resize(this.plan.semesters.length, cols);\n\t}", "title": "" }, { "docid": "be180596d34d05bb74a6d3fa7e28adae", "score": "0.53234243", "text": "function insertCards(){\n D1.listNodes('PROD').then(function(nodes) {\n\n // Select the containers to insert the node cards\n const currentContainer = selectContainer('current-member');\n const replicationContainer = selectContainer('replication');\n const contributingContainer = selectContainer('contributing');\n const upcomingContainer = selectContainer('upcoming-member');\n const isOnePlusContainer = currentContainer || replicationContainer || contributingContainer || upcomingContainer;\n\n // Select the containers to insert the node counts\n const currentCountEl = selectCountEl('current-member');\n const replicationCountEl = selectCountEl('replication');\n const contributingCountEl = selectCountEl('contributing');\n const upcomingCountEl = selectCountEl('upcoming-member');\n\n if(!nodes || !isOnePlusContainer) return;\n\n // list only member nodes (not coordinating nodes)\n nodes = nodes.filter(node => node.type !== 'cn');\n\n // sort by name, move nodes that are down to the bottom of the list\n nodes.sort((a, b) => {\n if(a.state === 'down' && b.state !== 'down') return 1;\n if(a.state !== 'down' && b.state === 'down') return -1;\n if(a.name < b.name) return -1;\n if(a.name > b.name) return 1;\n return 0;\n })\n\n // track counts of each type\n let currentCount = 0;\n let contributingCount = 0;\n let replicatorCount = 0;\n let upcomingCount = 0;\n\n // Build cards and insert into category containers\n nodes.forEach(node => {\n const nodeCard = makeMemberNodeCard(node);\n switch(node.operationalStatus) {\n case 'operational':\n currentContainer.innerHTML += nodeCard\n currentCount++;\n break;\n case 'contributing':\n contributingContainer.innerHTML += nodeCard\n contributingCount++;\n break;\n case 'replicator':\n replicationContainer.innerHTML += nodeCard\n replicatorCount++;\n break;\n case 'upcoming':\n upcomingContainer.innerHTML += nodeCard\n upcomingCount++;\n break;\n default:\n console.log('unknown node type', node)\n }\n })\n\n // Insert counts into the DOM\n currentCountEl.innerHTML = currentCount;\n contributingCountEl.innerHTML = contributingCount;\n replicationCountEl.innerHTML = replicatorCount;\n upcomingCountEl.innerHTML = upcomingCount;\n\n })\n }", "title": "" }, { "docid": "110831848155f0bb8d1e42f3611458a5", "score": "0.5317822", "text": "function setupCards(col, cards) {\r\n\t\tcards.forEach(function(card) {\r\n\t\tvar cardObj = new Card(card.id, card.name, card.bootcamp_kanban_column_id);\r\n\t\tcol.addCard(cardObj);\r\n\t});\r\n}", "title": "" }, { "docid": "97d2bfca2d37b9525c7fef194c692d06", "score": "0.53167003", "text": "function addCard(game, tier, position){\n let card = drawCard(game, tier)\n game.board[tier][position] = card;\n \n if(card != null){\n let newRowHTML = \"\", index = 0;\n let parentContainer = document.querySelector(`.tier${tier+1}`).parentElement;\n if(position == 3)\n newRowHTML = parentContainer.innerHTML + game.boughtCard[1].outerHTML;\n else{\n for(let child of parentContainer.children){\n if(position == index)\n newRowHTML = newRowHTML + game.boughtCard[1].outerHTML + child.outerHTML;\n else\n newRowHTML += child.outerHTML;\n index++;\n }\n }\n parentContainer.innerHTML = newRowHTML;\n\n boardCards = document.querySelectorAll(\".gemCard\");\n board = document.querySelector(\"div.boardCards\");\n\n addCardListener(game);\n addCardBoardListener(game);\n }\n}", "title": "" }, { "docid": "4ff67bdd2f5caa7e2607ea53bef66a1b", "score": "0.5316168", "text": "function patientSlots() {\n\n var t = JSON.parse(localStorage.getItem(\"t\"));\n // console.log(t);\n var morningSlots = []\n var afternoonSlots = [];\n var eveningSlots = [];\n \n var morningSlotsDiv = document.getElementsByClassName(\"slotBoxMorning\")[0];\n var eveningSlotsDiv = document.getElementsByClassName(\"slotBoxEvening\")[0];\n var afternoonSlotsDiv = document.getElementsByClassName(\"slotBoxAfternoon\")[0];\n var noslots = \"<p>No slots</p>\";\n\n t.forEach((time) => {\n switch (time.type) {\n case 'M': morningSlots = createSlotsArray(time.Stime, time.Etime, time.duration);\n morningSlots.pop();\n break;\n case 'A': afternoonSlots = createSlotsArray(time.Stime, time.Etime, time.duration);\n afternoonSlots.pop();\n break;\n case 'E': eveningSlots = createSlotsArray(time.Stime, time.Etime, time.duration);\n eveningSlots.pop();\n break;\n default:console.log(\"nothing\");\n }\n });\n if (morningSlots.length > 0) {\n patientSlotRender(morningSlots, morningSlotsDiv);\n } else {\n morningSlotsDiv.innerHTML = noslots;\n }\n\n if (afternoonSlots.length > 0) {\n patientSlotRender(afternoonSlots, afternoonSlotsDiv);\n } else {\n afternoonSlotsDiv.innerHTML = noslots;\n }\n\n if (eveningSlots.length > 0) {\n patientSlotRender(eveningSlots, eveningSlotsDiv);\n } else {\n eveningSlotsDiv.innerHTML = noslots;\n }\n clickListener();\n}", "title": "" }, { "docid": "65eaea7be8951457bbf1aa397844b001", "score": "0.5308376", "text": "function showCard(datas){\n let questionsContainer = document.getElementById(\"questionsContainer\");\n\n for(data of datas) {\n let card = makeCard(data);\n questionsContainer.appendChild(card);\n }\n}", "title": "" }, { "docid": "e894bb653c8e5a9e46d717f9ab1349e5", "score": "0.53036547", "text": "function setupCards(col, cards) {\n\tcards.forEach(function (card) {\n var cardObj = new Card(card.id, card.name);\n \tcol.addCard(cardObj);\n\t});\n}", "title": "" }, { "docid": "18039c0fd40d95ad940ec7faa01787b1", "score": "0.53030586", "text": "constructor() {\n this.courses = [\n {id: 1, title: 'ASP .Net Basics',description: 'ASP .Net Course for beginners',reference: 'ASPNETB001',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 90},\n {id: 2, title: 'ASP .Net Advanced',description: 'ASP .Net Course for middle level programmers',reference: 'ASPNETA001',duration: 10, fees: 1500, status: 'open',location: 'Net Hall 3',totalplaces: 100, availableplaces: 60},\n {id: 3, title: 'JavaScript with 12 Projects',description: 'JavaScript Course with 12 interactive Project work',reference: 'JSCRM001',duration: 9, fees: 1000, status: 'open',location: 'Net Hall 2',totalplaces: 100, availableplaces: 50},\n {id: 4, title: 'AngularJS',description: 'AngularJS Course for developers with some JavaScript knowledge',reference: 'JSCRM006',duration: 6, fees: 1000, status: 'open',location: 'Net Hall 5',totalplaces: 100, availableplaces: 30},\n {id: 5, title: 'ReactJS',description: 'ReactJS Course for developers with some JavaScript knowledge',reference: 'JSCRM007',duration: 6, fees: 1000, status: 'open',location: 'Net Hall 5',totalplaces: 100, availableplaces: 90},\n {id: 6, title: 'HTML5 Basics',description: 'HTML5 Basics',reference: 'HTMLB001',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 10},\n {id: 7, title: 'Bootstrap',description: 'Bootstrap',reference: 'BSTB001',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 8, title: 'JQuery and Ajax',description: 'JQuery and Ajax',reference: 'JSCRM007',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 9, title: 'SQL Server Development',description: 'SQL Server Development',reference: 'SQL001',duration: 15, fees: 2500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 0},\n {id: 10, title: 'ASP .Net Web API1',description: 'ASP .Net Web API Development with Project work',reference: 'ASPNETB010',duration: 18, fees: 2500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 11, title: 'ASP .Net Basics1',description: 'ASP .Net Course for beginners',reference: 'ASPNETB001',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 90},\n {id: 12, title: 'ASP .Net Advanced1',description: 'ASP .Net Course for middle level programmers',reference: 'ASPNETA011',duration: 10, fees: 1500, status: 'open',location: 'Net Hall 3',totalplaces: 100, availableplaces: 60},\n {id: 13, title: 'JavaScript with 12 Projects1',description: 'JavaScript Course with 12 interactive Project work',reference: 'JSCRM011',duration: 9, fees: 1000, status: 'open',location: 'Net Hall 2',totalplaces: 100, availableplaces: 50},\n {id: 14, title: 'AngularJS1',description: 'AngularJS Course for developers with some JavaScript knowledge',reference: 'JSCRM0061',duration: 6, fees: 1000, status: 'open',location: 'Net Hall 5',totalplaces: 100, availableplaces: 30},\n {id: 15, title: 'ReactJS1',description: 'ReactJS Course for developers with some JavaScript knowledge',reference: 'JSCRM0071',duration: 6, fees: 1000, status: 'open',location: 'Net Hall 5',totalplaces: 100, availableplaces: 90},\n {id: 16, title: 'HTML5 Basics1',description: 'HTML5 Basics',reference: 'HTMLB0011',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 10},\n {id: 17, title: 'Bootstrap1',description: 'Bootstrap',reference: 'BSTB0011',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 18, title: 'JQuery and Ajax1',description: 'JQuery and Ajax',reference: 'JSCRM0071',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 19, title: 'SQL Server Development1',description: 'SQL Server Development',reference: 'SQL0011',duration: 15, fees: 2500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 20, title: 'ASP .Net Web API2',description: 'ASP .Net Web API Development with Project work',reference: 'ASPNETB0101',duration: 18, fees: 2500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 21, title: 'ASP .Net Basics2',description: 'ASP .Net Course for beginners',reference: 'ASPNETB0012',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 90},\n {id: 22, title: 'ASP .Net Advanced2',description: 'ASP .Net Course for middle level programmers',reference: 'ASPNETA0012',duration: 10, fees: 1500, status: 'open',location: 'Net Hall 3',totalplaces: 100, availableplaces: 60},\n {id: 23, title: 'JavaScript with 12 Projects2',description: 'JavaScript Course with 12 interactive Project work',reference: 'JSCRM0012',duration: 9, fees: 1000, status: 'open',location: 'Net Hall 2',totalplaces: 100, availableplaces: 50},\n {id: 24, title: 'AngularJS2',description: 'AngularJS Course for developers with some JavaScript knowledge',reference: 'JSCRM0062',duration: 6, fees: 1000, status: 'open',location: 'Net Hall 5',totalplaces: 100, availableplaces: 30},\n {id: 25, title: 'ReactJS2',description: 'ReactJS Course for developers with some JavaScript knowledge',reference: 'JSCRM0072',duration: 6, fees: 1000, status: 'open',location: 'Net Hall 5',totalplaces: 100, availableplaces: 90},\n {id: 26, title: 'HTML5 Basics2',description: 'HTML5 Basics',reference: 'HTMLB0012',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 10},\n {id: 27, title: 'Bootstrap2',description: 'Bootstrap',reference: 'BSTB0012',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 28, title: 'JQuery and Ajax2',description: 'JQuery and Ajax',reference: 'JSCRM0072',duration: 6, fees: 500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces:100},\n {id: 29, title: 'SQL Server Development2',description: 'SQL Server Development',reference: 'SQL0012',duration: 15, fees: 2500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100},\n {id: 30, title: 'ASP .Net Web API2',description: 'ASP .Net Web API Development with Project work',reference: 'ASPNETB0102',duration: 18, fees: 2500, status: 'open',location: 'Net Hall 1',totalplaces: 100, availableplaces: 100}\n ];\n }", "title": "" }, { "docid": "4b84e10f3e74d16cfa989e497325ba77", "score": "0.52954185", "text": "function createCard(card){\n var cardDiv = document.getElementById('card');\n cardDiv.innerHTML = '';\n cardDiv.className = \"card\";\n card.forEach(function(item, index){\n\t var cardItem = document.createElement('div');\n cardItem.className = 'cardItem';\n cardItem.innerHTML = item;\n cardDiv.appendChild(cardItem);\n });\n}", "title": "" }, { "docid": "f7dc88809bfd4c34493382a27b6f388c", "score": "0.52902853", "text": "function startQuiz() {\n titleCard.classList.add(\"d-none\")\n timeBar.parentElement.classList.remove(\"invisible\")\n qCard.classList.remove(\"d-none\")\n resArea.classList.add(\"invisible\")\n startClock()\n quizCards()\n}", "title": "" }, { "docid": "59531b0fac013536ab4f39fef3e1296d", "score": "0.5285004", "text": "onClockAdd(datetime) {\n clocks.push(datetime);\n console.log(\"adding at \", datetime);\n }", "title": "" }, { "docid": "75efd75400afa0f21d4b9044e4c3e7e1", "score": "0.52849877", "text": "function cargarSlots(slots){\r\n\toperarSlots(slots, cargarSlot);\r\n}", "title": "" }, { "docid": "e61ff4af0f4e00d138522609d41ef23e", "score": "0.5279905", "text": "function prepareSlots(){\n\tslotContainer.removeAllChildren();\n\t\n\tfor(var c = 0; c<slotSettings.column; c++){\n\t\tshuffle(slotData.array[c].slots);\n\t\t\n\t\tvar currentX = slotSettings.startX + (slotSettings.width/2) + (slotSettings.width * c);\n\t\tvar currentY = slotSettings.startY + (slotSettings.height/2);\n\t\tcurrentY += slotSettings.height * slotSettings.row;\n\t\tif(slotData.extraslot > 1){\n\t\t\tcurrentY += slotSettings.height * (slotData.extraslot-1);\n\t\t}\n\t\t\n\t\tslotData.array[c].total = spinSettings.slots * slotSettings.row;\n\t\tslotData.array[c].total += slotData.extraslot;\n\t\t\n\t\tvar previousIndexArray = [];\n\t\tif(slotData.array[c].obj.length > 0){\n\t\t\tfor(var s = slotData.array[c].obj.length-slotSettings.row; s<slotData.array[c].obj.length; s++){\n\t\t\t\tpreviousIndexArray.push(slotData.array[c].obj[s].slotIndex);\t\n\t\t\t}\n\t\t}\n\t\tslotData.array[c].obj.length = 0;\n\t\t\n\t\tvar previousIndex = 0;\n\t\tfor(var s = 0; s<slotData.array[c].total; s++){\n\t\t\tvar resultSlot = false;\n\t\t\tif(s >= slotData.extraslot && previousIndex < previousIndexArray.length){\n\t\t\t\tvar slotIndex = previousIndexArray[previousIndex];\n\t\t\t\tpreviousIndex++;\n\t\t\t}else{\n\t\t\t\tvar index = slotData.array[c].index;\n\t\t\t\tvar slotIndex = slotData.array[c].slots[index];\n\t\t\t\tslotData.array[c].index++;\n\t\t\t\tif(slotData.array[c].index > slotData.array[c].slots.length-1){\n\t\t\t\t\tslotData.array[c].index = 0;\n\t\t\t\t\tshuffle(slotData.array[c].slots);\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tvar slotObj = $.slots[slotIndex].clone();\n\t\t\tslotObj.slotIndex = slotIndex;\n\t\t\tslotObj.mask = $.columnMask[c];\n\t\t\tslotContainer.addChild(slotObj);\n\t\t\t\n\t\t\tslotData.array[c].obj.push(slotObj);\n\t\t\t\n\t\t\tslotObj.x = currentX;\n\t\t\tslotObj.y = currentY;\n\t\t\tslotObj.oriY = slotObj.y;\n\t\t\t\n\t\t\tcurrentY -= (slotSettings.height);\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d610ca6b71d9064465ef092b0fa80dfc", "score": "0.52796614", "text": "function nextCard() {\n if (place < qAndA.length - 1) {\n place = place + 1;\n }\n cardContent.innerText = qAndA[place].question;\n }", "title": "" }, { "docid": "628a55a6be206616da5df65a2afcfaa7", "score": "0.52756655", "text": "function listschedule(){\n\tjQuery.getJSON(\"/user/profile/schedule\", function(data){\n\t\t$('#schedule').contents().remove();\n\t\tvar schedule = '';\n\t\tschedule += '<div id=\"scheduleaccordion\" class=\"panel-group\">';\n\t\tfor(i = 0; i < data.length; i++) {\n\t\t\tschedule += ' <div class=\"panel panel-primary\">';\n\t\t\tschedule += ' <div class=\"panel-heading\">';\n\t\t\tschedule += ' <h4 class=\"panel-title\">';\n\t\t\tschedule += ' <a aria-expanded=\"false\" class=\"collapsed\" data-toggle=\"collapse\" href=\"#scollapse' + i + '\">';\n\t\t\tschedule += ' <div class=\"row\">';\n\t\t\tschedule += ' <div class=\"col-sm-5\">' + data[i].course_name +'</div>';\n\t\t\tschedule += ' <div class=\"col-sm-7 righttext\">Course Code: ' + data[i].course_code + '</div>';\n\t\t\tschedule += ' </div>';\n\t\t\tschedule += ' </a>';\n\t\t\tschedule += ' </h4>';\n\t\t\tschedule += ' </div>';\n\t\t\tschedule += ' <div style=\"height: 0px;\" aria-expanded=\"false\" class=\"panel-collapse collapse\" id=\"scollapse' + i + '\">';\n\t\t\tschedule += ' <div class=\"panel-body\">';\n\t\t\tschedule += ' <div class=\"col-sm-offset-1\">';\n\t\t\tschedule += ' <p id=\"description' + i + '\">' + data[i].course_description + '</p>';\n\t\t\tschedule += ' <div class=\"row\">';\n\t\t\tschedule += ' <div class=\"col-sm-6\">';\n\t\t\tschedule += ' <p id=\"coursestartdate' + i + '\">Start Date: ' + String(data[i].start_date).substring(0, 10) + '</p>';\n\t\t\tschedule += ' \t </div>';\n\t\t\tschedule += ' <div class=\"col-sm-6\">';\n\t\t\tschedule += ' <p id=\"courseenddate' + i + '\">End Date: ' + String(data[i].end_date).substring(0, 10) + '</p>';\n\t\t\tschedule += ' </div>';\n\t\t\tschedule += ' <div class=\"col-sm-3\">Days of Week: ' + data[i].course_days + '</div>';\n\t\t\tschedule += ' </div>';\n\t\t\tschedule += ' </div>';\n\t\t\tschedule += ' </div>';\n\t\t\tschedule += ' </div>';\n\t\t\tschedule += ' </div>';\n\t\t}\n\t\tschedule += '</div>';\n\t\t$('#schedule').append(schedule);\n\t});\n}", "title": "" }, { "docid": "02982be61301a924346fed10648e6ec6", "score": "0.5275619", "text": "getCourseScheduleJSON() {\n let scheduledCourses = {};\n const semesterTrs = Array.prototype.slice.call(this.getElementsByTagName('tr'));\n const divs = Array.prototype.slice.call(this.getElementsByTagName('div'));\n\n // Filter out only the course-tiles \n divs.filter(div => div.customTagName === \"course-tile\").forEach(courseTile => {\n const semesterTr = courseTile.closest('tr');\n const semesterTd = courseTile.closest('td');\n // The 'top' of the grid (0, 0) is the top left cell of the timetable. Although this means that the latest semester has a lower y coordinate, it makes calculations a bit simpler.\n // Get the y-coordinate - The base number is twice the row number, since each table tr contains two semesters\n let yCoord = 2 * semesterTrs.indexOf(semesterTr);\n // If the course is year-long, then it will be counted as the lower semester\n // Otherwise, we ask the CourseSlotContainer what slot this course is in, and add that to the base.\n yCoord += (courseTile.courseLength === 'Y') ? 1 : courseTile.parentElement.parentElement.getSlotNumber(courseTile);\n // Get the x coordinate - This doesn't make a difference to anything, it's only for stylistic purposes\n const xCoord = Array.prototype.slice.call(semesterTr.children).indexOf(semesterTd);\n\n scheduledCourses[courseTile.id] = {\n \"x\": xCoord,\n \"y\": yCoord\n };\n });\n\n // Append the anchor semester and year before returning\n return {\n \"anchorSemester\": this.#semesterSelect.value,\n \"anchorYear\": parseInt(this.#yearSelect.value),\n \"numSemesters\": this.#tbody.children.length,\n \"scheduledCourses\": scheduledCourses\n };\n }", "title": "" }, { "docid": "0dd3783947f202365cfdfc3501bd64d8", "score": "0.5273297", "text": "function createPlan() {\n //input area works, make forloop work\n for (var i = 0; i < hour.length; i++) {\n console.log(hour.length);\n\n var d1 = document.createElement(\"div\");\n //<div></div>\n d1.setAttribute(\"class\", \"row time-block\")\n //<div class=\"row time-block\"></div>\n\n var d2 = document.createElement(\"div\");\n d2.setAttribute(\"class\", \"col-md-1\");\n\n var p = document.createElement(\"p\");\n p.textContent = hour[i];\n if (hour[i] < 12) {\n p.textContent = hour[i] + \" AM\";\n }\n if (hour[i] == 12) {\n p.textContent = hour[i] + \"PM\";\n }\n if (hour[i] > 12) {\n p.textContent = hour[i] - 12 + \"PM\";\n\n }\n\n var textarea = document.createElement(\"textarea\");\n //textarea.setAttribute(\"class\",\"description col-md-10\");\n //if current time \n if (currentTime == hour[i]) {\n textarea.setAttribute(\"class\", \"description col-md-10 present \");\n textarea.setAttribute(\"id\", hour[i]);\n\n }\n if (currentTime > hour[i]) {\n textarea.setAttribute(\"class\", \"description col-md-10 past \");\n textarea.setAttribute(\"id\", hour[i]);\n }\n if (currentTime < hour[i]) {\n textarea.setAttribute(\"class\", \"description col-md-10 future \");\n textarea.setAttribute(\"id\", hour[i]);\n }\n\n if(localStorage.getItem($(textarea).attr(\"id\")) != \"\"){\n textarea.textContent = localStorage.getItem($(textarea).attr(\"id\"));\n }\n else{\n textarea.setAttribute(\"placeholder\", \"Enter text here...\");\n }\n //currentTime==hour\n //add class present\n //if(past) currentTime-hour>0\n\n var btn = document.createElement(\"button\");\n textarea.setAttribute(\"id\", hour[i])\n // btn.setAttribute(\"id\", hour[i])\n btn.setAttribute(\"class\", \"saveBtn col-md-1 btn\")\n\n var iframe = document.createElement(\"i\");\n iframe.setAttribute(\"class\", \"fas fa-save\");\n document.querySelector(\".container\").appendChild(d1)\n d2.appendChild(p);\n btn.appendChild(iframe);\n\n d1.appendChild(d2);\n d1.appendChild(textarea);\n d1.appendChild(btn);\n\n \n console.log(\"work\")\n }\nfunction saveText(){\n $(\"textarea\").each(function(){\n var textStorage = $(this).val();\n console.log(textStorage);\n localStorage.setItem($(this).attr(\"id\"),textStorage);\n \n \n \n })\n}\n\n $(\"button\").click(function(){\n saveText();\n})\n\n //create an onclick event.\n //grab the userinput and hour\n //set to local storage\n\n //.saveBtn\n // document.querySelector(\".saveBtn\").onclick = function () {\n // console.log(this.getAttribute(\"id\"));\n // console.log(this.parentElement.children[1].value);\n // localStorage.setItem(this.getAttribute(\"iframe\"), this.parentElement.children[1].value);\n\n // };\n\n // // document.querySelector(\"iframe\").value(localStorage.getItem(\"iframe\"));\n // console.log(localStorage.getItem(\"iframe\"))\n}", "title": "" }, { "docid": "243ee4bec2b2dacbcb74f5a26dd51188", "score": "0.527274", "text": "function renderDeck() {\n var container = document.getElementById('CardDeck');\n console.log(container);\n\n for (var i = 0; i < CardTopic.list.length; i++) {\n container.appendChild(renderCard(i));\n }\n}", "title": "" }, { "docid": "b2d6bc0b41af1d8e015f621d255cb4ec", "score": "0.52722764", "text": "function startGame() {\n for( let i=0; i < cardCount*2; i++ ) {\n let card = document.createElement(\"div\");\n matchgrid.appendChild(card);\n card.setAttribute('id',i);\n card.classList.add('card','blank');\n card.addEventListener(\"click\",clickCard);\n }\n }", "title": "" }, { "docid": "ebc26ca4f365395cd6310630cf945f33", "score": "0.5269249", "text": "function appendCard(idea) {\n cardContainer.innerHTML += `\n <section class=\"idea-card\" data-name=${idea.id}>\n <div class=\"card-top\">\n <button class=\"icon star-icon\" type=\"button\"></button>\n <img class=\"icon delete-icon\" type=\"button\" src=\"./assets/delete.svg\" alt=\"Delete card button\">\n </div>\n <h2 class=\"idea-title\">${idea.title}</h2>\n <p class=\"idea-body\">${idea.body}</p>\n <div class=\"card-bottom\">\n <img class=\"icon\" src=\"./assets/comment.svg\" alt=\"Add comment button\">\n <p class=\"comment\">Comment</p>\n </div>\n </section>`\n form.reset();\n saveDisableToggle();\n}", "title": "" }, { "docid": "37dc7c300cf35cf1d9b2534cb1d6c310", "score": "0.52687323", "text": "static generateTimeline (timelineArray) {\n console.log(\"Updating\");\n var frontDeleteCounter = 0;\n var backDeleteCounter = 0;\n var frontDeleteCounterFlag = true;\n var i;\n\n timelineArray.forEach(function(item, index) {\n var timeSlot = document.getElementById(\"time-slot-\" + (index + 1));\n if (item == 0) {\n backDeleteCounter++;\n if (timeSlot) {\n timeSlot.classList.add(\"unavailable-timeslot\");\n timeSlot.firstElementChild.classList.add(\"unavailable-timeslot\");\n }\n }\n else {\n frontDeleteCounterFlag = false;\n backDeleteCounter = 0;\n\n if (timeSlot) {\n timeSlot.addEventListener('click', () => markAsActive())\n const markAsActive = () => {\n if (!timeSlot.classList.contains('active-timeslot')) {\n var activeTimeslots = document.getElementsByClassName(\"active-timeslot\");\n\n if (activeTimeslots.length >= 2) {\n Timeline.resetActiveSlots();\n }\n\n timeSlot.classList.add('active-timeslot');\n\n if (activeTimeslots.length == 2) {\n var activeIDs = [];\n activeIDs[0] = activeTimeslots[0].id.split(\"-\")[2];\n activeIDs[1] = activeTimeslots[1].id.split(\"-\")[2];\n activeIDs.sort(function(a, b){return a - b});\n var authenticationCounter = 0;\n for (i = (parseInt(activeIDs[0]) + 1); i <= activeIDs[1]; i++) {\n var inBetweenTimeslot = document.getElementById(\"time-slot-\" + i);\n if (inBetweenTimeslot) {\n if (inBetweenTimeslot.classList.contains(\"unavailable-timeslot\")) {\n break;\n }\n else {\n authenticationCounter++;\n } \n }\n }\n if (authenticationCounter == (activeIDs[1] - activeIDs[0])) {\n for (i = (parseInt(activeIDs[0]) + 1); i < activeIDs[1]; i++) {\n var inBetweenTimeslot = document.getElementById(\"time-slot-\" + i);\n if (inBetweenTimeslot) {\n inBetweenTimeslot.classList.add(\"active-in-between\");\n }\n }\n\n var startTimeInput = document.getElementById(\"reservation_start_time\");\n var endTimeInput = document.getElementById(\"reservation_end_time\");\n\n if (startTimeInput) {\n startTimeInput.value = activeTimeslots[0].firstElementChild.innerHTML.trim().replace(/&nbsp;/g,'');\n }\n\n if (endTimeInput) {\n endTimeInput.value = activeTimeslots[1].firstElementChild.innerHTML.trim().replace(/&nbsp;/g,'');\n }\n }\n else {\n Timeline.resetActiveSlots();\n }\n }\n }\n }\n }\n }\n\n if(frontDeleteCounterFlag) {\n frontDeleteCounter++;\n }\n });\n\n frontDeleteCounter = Math.trunc(frontDeleteCounter / 30) * 30;\n backDeleteCounter = Math.trunc(backDeleteCounter / 30) * 30;\n\n for (i = 0; i <= frontDeleteCounter; i++) {\n var timeSlot = document.getElementById(\"time-slot-\" + i);\n if (timeSlot && (i != (frontDeleteCounter))) {\n timeSlot.style.display = \"none\";\n }\n if (i % 30 == 0) {\n var timeLabel = document.getElementById(\"time-label-\" + ((i / 30) - 1));\n if (timeLabel) {\n timeLabel.style.display = \"none\";\n }\n }\n }\n\n for (i = 720; i >= (720 - backDeleteCounter); i--) {\n var timeSlot = document.getElementById(\"time-slot-\" + i);\n if (timeSlot && (i != (720 - backDeleteCounter))) {\n timeSlot.style.display = \"none\";\n }\n if (i % 30 == 0) {\n var timeLabel = document.getElementById(\"time-label-\" + ((i / 30) + 1));\n if (timeLabel) {\n timeLabel.style.display = \"none\";\n }\n }\n }\n\n for (i = 0; i <= 25; i++) {\n var timeSlot = document.getElementById(\"time-slot-\" + (i * 30));\n if (timeSlot) {\n timeSlot.style.backgroundColor = \"#3d3d3d\";\n }\n }\n }", "title": "" }, { "docid": "82feefd46707ae9fd3e78b1df1bf83f5", "score": "0.52683", "text": "createDecks() {\n for (let i = 0; i < this.decks; i++) {\n for (let j = 0; j < 52; j++) {\n this.cards.push(this.createCard(j));\n }\n }\n }", "title": "" }, { "docid": "4e03da8005543e1bdec707e8f2f5e53e", "score": "0.52660394", "text": "function printCourseCards(sSubject) {\n\t$(\".courses-body .panel-group\").empty(); // Clear the body of past prints\n\t$(\".courses-body h3\").text(sSubject); // Display the name of the subject as a title\n\n\t// Find the subject, this should return an array of 1 element, beacuse the subject must be only one time. Then get it's children courses\n\tvar arrChildrenCourses = $.grep(arrGlobalSubjects, function(eSubject){\n\t\treturn eSubject.name === sSubject;\n\t})[0].childrenCourses;\n\n\tvar iCountSubjects = 0; // Counter to set unique id's of the accordions\n\n\t$.each(arrChildrenCourses, function(index, eCourseName) { // For each children course\n\t\tvar arrChildCourse = $.grep(arrGlobalSubjects, function(eSubject) { // Find all the groups \n\t\t\treturn eSubject.name === eCourseName;\n\t\t});\n\n\t\tvar $courseAccordion = $courseAccordionOriginal.clone(true); // Get a copy of the accordion item\n\n\t\t// Add properties for the accordion to work well\n\t\t$courseAccordion.find('.panel-heading').attr(\"id\", \"courseHeading\" + iCountSubjects);\n\t\t$courseAccordion.find('a').attr(\"href\", \"#course\" + iCountSubjects);\n\t\t$courseAccordion.find('a').attr(\"aria-controls\", \"course\" + iCountSubjects);\n\t\t$courseAccordion.find('a').append(eCourseName); // Add course name to the title\n\t\t$courseAccordion.find('.collapse').attr(\"id\", \"course\" + iCountSubjects);\n\t\t$courseAccordion.find('.collapse').attr(\"aria-labelledby\", \"courseHeading\" + iCountSubjects);\n\n\t\t$.each(arrChildCourse, function(iCourse, eCourse) { // Set each children course it's parent course\n\t\t\teCourse.parentCourse = sSubject;\n\t\t\t$courseAccordion.find(\".panel-body\").append(getGroupCard(eCourse));\n\t\t});\n\t\t$(\".courses-body .panel-group\").append($courseAccordion); // Print it\n\t\tiCountSubjects++;\n\t});\n}", "title": "" }, { "docid": "b50acc4f6f88b4d166efd0baabcf1547", "score": "0.5259324", "text": "function slots(data) {\n\n var t = JSON.parse(data);\n\n var morningSlots = []\n var afternoonSlots = [];\n var eveningSlots = [];\n \n var morningSlotsDiv = document.getElementsByClassName(\"slotBoxMorning\")[0];\n var eveningSlotsDiv = document.getElementsByClassName(\"slotBoxEvening\")[0];\n var afternoonSlotsDiv = document.getElementsByClassName(\"slotBoxAfternoon\")[0];\n var noslots = \"<p>No slots</p>\";\n\n t.map((time) => {\n switch (time.type) {\n case 'M': morningSlots = createSlotsArray(time.Stime, time.Etime, time.duration);\n morningSlots.pop();\n break;\n case 'A': afternoonSlots = createSlotsArray(time.Stime, time.Etime, time.duration);\n afternoonSlots.pop();\n break;\n case 'E': eveningSlots = createSlotsArray(time.Stime, time.Etime, time.duration);\n eveningSlots.pop();\n break;\n default:console.log(\"nothing\")\n }\n\n });\n if (morningSlots.length > 0) {\n slotRender(morningSlots, morningSlotsDiv);\n } else {\n morningSlotsDiv.innerHTML = noslots;\n }\n\n if (afternoonSlots.length > 0) {\n slotRender(afternoonSlots, afternoonSlotsDiv);\n } else {\n afternoonSlotsDiv.innerHTML = noslots;\n }\n\n if (eveningSlots.length > 0) {\n slotRender(eveningSlots, eveningSlotsDiv);\n } else {\n eveningSlotsDiv.innerHTML = noslots;\n }\n\n}", "title": "" }, { "docid": "d915e0abe6e7ba0b35f2e950ddd0eec5", "score": "0.52585506", "text": "function AssignCourse(Quarter, Course) {\n //Get rid of the add course button\n Quarter.children().last().remove();\n\n // Create the div container and set its class\n var CourseDiv = $(\"<div></div>\");\n CourseDiv.attr(\"class\", \"Flex MiddleFlex\");\n\n // Create the Select attribute and get its class\n var CourseSelect = $(\"<select></select>\");\n CourseSelect.attr(\"class\", \"CourseSelection WideFlex\");\n CourseDiv.append(CourseSelect);\n\n // Create a blank value\n CourseSelect.append(CreateCourseOption(Course));\n\n // Add in the delete button\n CourseDiv.append(DeleteButton());\n\n // Add the new course element\n Quarter.append(CourseDiv);\n\n // Add in a new add button\n Quarter.append(AddButton());\n}", "title": "" }, { "docid": "c1ad4bc6fd789e2c0bbddc8ea4d23f7a", "score": "0.5257334", "text": "function makeCards(list, area){\n for(movie of list){\n area.append(`\n <div class=\"card\" style=\"background-image: url('${movie.image}');\">\n <div class=\"card-body\" >\n <h5 class=\"card-title\">${movie.title}</h5>\n </div>\n </div>\n `)\n }\n $home.prop('disabled', true)\n addHover();\n cardClick();\n}", "title": "" } ]
60874be23553a31a4d9f99ad19b7a17b
Wrap method callback updated REPORTING_URL w/ passed in PATH
[ { "docid": "79ffc663fae11569acfd785e51d0ac48", "score": "0.62859267", "text": "function wrapCallback (cb, path, call) {\n return function wrappedCallback () {\n let rootSpan = tracer.getActiveRootSpan()\n if (rootSpan) {\n rootSpan.addProperty('REPORTING_URL', path)\n }\n const span = tracer.createSpan(call)\n if (span) {\n span.addProperty('CATEGORY', 'Framework')\n span.addProperty('SUBCATEGORY', 'Restify')\n span.addProperty('COMPONENT_CATEGORY', 'Framework')\n span.addProperty('COMPONENT_DETAIL', 'Restify')\n span.addProperty('PATH', path)\n }\n let result = tracer.bindSpanCallback(cb, span).apply(this, arguments)\n if (span) {\n tracer.endSpan(span)\n }\n return result\n }\n }", "title": "" } ]
[ { "docid": "d2f7b7d978a1e5ecc4450e5f2517ea99", "score": "0.55026805", "text": "function createReportingUrl(uuid, operation, report = 'default-report') {\n let url = new URL(`${window.location.origin}${BASE_PATH}resources/protected_audience_event_level_report_handler.py`);\n url.searchParams.append('uuid', uuid);\n url.searchParams.append('operation', operation);\n\n if (report)\n url.searchParams.append('report', report);\n\n return url.toString();\n}", "title": "" }, { "docid": "9ce2e8abe1d1c3d5bd8b5749fa1bc079", "score": "0.5344835", "text": "formatUrl(path) {\n return path;\n }", "title": "" }, { "docid": "31e715b7c965195b98847726086285f8", "score": "0.5305406", "text": "function helios_metricPath(path, callback) {\n\tvar append = path.replace(forwardSlashRegex, '%2F');\n\tconsole.info(\"Metric Path Append:[%s]\", append);\n\t$.ajax({\n\t\turl: \"api/sub/metrictree/\" + append,\t\t \n\t\tcontext: document.body,\n\t\tsuccess: function(data){\n\t\t\t$.jGrowl('Metric Path for:' + path);\n\t\t\tif(callback==null) {\n\t\t\t\t$('#output').val(JSON.stringify(data));\n\t\t\t\tconsole.dir(JSON.stringify(data));\n\t\t\t} else {\n\t\t\t\treturn callback(data);\n\t\t\t\tcallback(res);\n\t\t\t}\n\t\t}\t\n\t});\n}", "title": "" }, { "docid": "52621f6774bc997b6276387de142c2bd", "score": "0.5194899", "text": "function createWrapServerMethod (method) {\n return function wrapServerMethod (original) {\n return function wrappedServerMethod () {\n let args = Util.argsToArray.apply(this, arguments)\n if (args && args.length > 0) {\n let path = args[0]\n let cb = args[args.length - 1]\n if (Util.isFunction(cb) && !Util.isMonkeyPatched(cb)) {\n cb = shimmer.wrap(cb, null, function wrapMethodCallback (original) {\n return wrapCallback(original, path, 'restify.' + method)\n })\n if (cb) {\n args[args.length - 1] = cb\n }\n }\n }\n\n return original.apply(this, args)\n\n /**\n * Wrap method callback - updated REPORTING_URL w/ passed in PATH\n * @param cb\n * @param path\n * @param call\n */\n function wrapCallback (cb, path, call) {\n return function wrappedCallback () {\n let rootSpan = tracer.getActiveRootSpan()\n if (rootSpan) {\n rootSpan.addProperty('REPORTING_URL', path)\n }\n const span = tracer.createSpan(call)\n if (span) {\n span.addProperty('CATEGORY', 'Framework')\n span.addProperty('SUBCATEGORY', 'Restify')\n span.addProperty('COMPONENT_CATEGORY', 'Framework')\n span.addProperty('COMPONENT_DETAIL', 'Restify')\n span.addProperty('PATH', path)\n }\n let result = tracer.bindSpanCallback(cb, span).apply(this, arguments)\n if (span) {\n tracer.endSpan(span)\n }\n return result\n }\n }\n }\n }\n }", "title": "" }, { "docid": "a718a30dbad98435ede86d02bb7a37ef", "score": "0.51505655", "text": "setPath (callback) {\n\t\t// pick a few file streams in the repo to fetch by ID \n\t\tconst teamId = this.team.id;\n\t\tconst repoId = this.repo.id;\n\t\tthis.expectedStreams = [\n\t\t\tthis.streamsByRepo[repoId][0],\n\t\t\tthis.streamsByRepo[repoId][2]\n\t\t];\n\t\tconst ids = this.expectedStreams.map(stream => stream.id);\n\t\tthis.path = `/streams?teamId=${teamId}&repoId=${repoId}&ids=${ids}`;\n\t\tcallback();\n\t}", "title": "" }, { "docid": "57abaf65e105f0b5ea49beba41341ff0", "score": "0.5107381", "text": "setDownloadPath(path) {\n\t\treturn {\n\t\t\ttype : 'SET_DOWNLOAD_PATH',\n\t\t\tpath : path\n\t\t}\n\t}", "title": "" }, { "docid": "bff6e8794e91a9e869b4139c90360a7e", "score": "0.5091033", "text": "constructor(callHandler, path = []) {\n this.callHandler = callHandler;\n this.path = path;\n }", "title": "" }, { "docid": "fa7ac9c6cc3533a08dba5681d47f0ee6", "score": "0.5056746", "text": "reportUri(parts) {\n let tabParts = parts.join('/')\n return `${this.reportUriBase()}/${tabParts}`\n }", "title": "" }, { "docid": "336b0cdc80bb659893dce70516ee5064", "score": "0.50495046", "text": "function setUrl () {\n return '/tracker/track' + params;\n}", "title": "" }, { "docid": "42c56fbbc5930462d9587b22c34b3134", "score": "0.5008098", "text": "function wrapBuildingURLWithContextPath() {\n var contextPath = calculateContextPath();\n return function(resource) {\n return \"/\" + contextPath + \"/\" + resource;\n };\n}", "title": "" }, { "docid": "1e3e53aa51bc46238a6ab76920ca4898", "score": "0.499073", "text": "withPath(pathname) {\n const location = { ...this.#location, pathname };\n return new UrlWrapper(location, this.#history, this.#params);\n }", "title": "" }, { "docid": "1606e3982cfb88cd41a7908ef4845a26", "score": "0.4981254", "text": "setPath (callback) {\n\t\t// replace the token with a token with a bogus type\n\t\tsuper.setPath(() => {\n\t\t\tconst tokenHandler = new TokenHandler(this.apiConfig.sharedSecrets.auth);\n\t\t\tconst payload = tokenHandler.decode(this.path.split('=')[1]);\n\t\t\tconst token = tokenHandler.generate(payload, 'xyz');\n\t\t\tthis.path = `/web/confirm-email?t=${token}`;\n\t\t\tcallback();\n\t\t});\n\t}", "title": "" }, { "docid": "706d86a8222cff902e286ae7d7c81475", "score": "0.4935446", "text": "url(path, params) {\n const fn = pathToRegexp.compile(this.basePath + path);\n return '#' + fn(params);\n }", "title": "" }, { "docid": "8463a808f017c0c9ea86cbe202abef8a", "score": "0.4920339", "text": "function trackPath(path) {\n let currentUser = userSessionService.getCurrentUser();\n let data = {\n thisaction: path.action,\n marker: path.marker,\n user: currentUser.email\n };\n\n postViewLogData(data);\n }", "title": "" }, { "docid": "3a17d6669c7302a15f5055d845417429", "score": "0.4888732", "text": "generateReport(callback) {\n if (typeof(callback) != \"function\") callback = () => {};\n if (!this.validateItem()) return;\n let item = this.getProps().item;\n if (window.location.hash.split(\"?\").length === 2) {\n this.applyUrlParams(item,queryString.parse(window.location.hash.split(\"?\").pop()));\n }\n this.model.generateReport(item,(error,reports) => {\n if (error) { Store.changeProperty(\"errors\",{general:t(\"Internal error\")});return;}\n this.reportData = [];\n reports.forEach((rows,index) => {\n let format = {title: t('Report')+\" # \"+index, columns: []};\n try { format = JSON.parse(item.queries.filter(query=>query.enabled)[index].outputFormat)} catch (e) {}\n if (!format.title) format.title = item.queries.filter(query=>query.enabled)[index].name;\n let report = {format:format,data:rows};\n try {\n let postScript = item.queries.filter(query=>query.enabled)[index].postScript;\n if (postScript && postScript.length) report = eval(postScript)(report,this);\n } catch (e) { console.log(e);};\n let eventHandlers = item.queries.filter(query=>query.enabled)[index].eventHandlers;\n try { report.eventHandlers = eval(eventHandlers)()} catch (e) { console.log(e);}\n let layout = item.queries.filter(query=>query.enabled)[index].layout;\n if (layout && layout.length) report.layout = layout;\n this.reportData.push(report);\n });\n if (item.postScript && item.postScript.length) {\n try {\n let func = eval(item.postScript);\n this.reportData = func(this.reportData,this);\n } catch (e) { console.log(e);};\n }\n Store.changeProperty(\"reportData\",this.reportData);\n if (callback) callback();\n });\n }", "title": "" }, { "docid": "0c6240e52e010c072f14ba87d07cfbc1", "score": "0.48542455", "text": "setPath (callback) {\n\t\t// pick a pivot point, then filter our expected error codes based on that pivot,\n\t\t// and specify the after parameter to fetch based on the pivot\n\t\tconst pivot = this.codeErrors[5].lastActivityAt;\n\t\tthis.expectedCodeErrors = this.codeErrors.filter(codeError => codeError.lastActivityAt >= pivot);\n\t\tthis.expectedCodeErrors.reverse();\n\t\tthis.path = `/code-errors?teamId=${this.team.id}&after=${pivot}&inclusive`;\n\t\tcallback();\n\t}", "title": "" }, { "docid": "b0582d4e43def9a08ad59d64e67292db", "score": "0.48181036", "text": "function processPath() {\n var dfd = $.Deferred();\n var file = ProjectManager.getSelectedItem();\n\n nodeBridge.processPath(file._path, function( err, resp ) {\n if( err ) {\n StatusBar.updateIndicator(INDICATOR_ID, true, \"inspection-errors\", err);\n dfd.reject(err);\n return;\n }\n StatusBar.updateIndicator(INDICATOR_ID, true, \"inspection-valid\", Strings.UPDATED + ' ' + file._path);\n dfd.resolve(resp);\n });\n return dfd.promise();\n }", "title": "" }, { "docid": "7873935c930d02864e50c4190a8b2722", "score": "0.47841063", "text": "function onSuccessShowSystemReports(result, context, methodname) {\r\n fnHideParentDiv();\r\n if (result == null)\r\n return;\r\n\r\n document.getElementById(\"test\").href = result;\r\n document.getElementById(\"test\").click();\r\n\r\n\r\n}", "title": "" }, { "docid": "c3f8eb0061b610981d2e3aa5bcc20830", "score": "0.47810006", "text": "function setUrl(path){\r\nreturn \"url(\\'../\"\r\n +path\r\n +\"\\')\";\r\n}", "title": "" }, { "docid": "fdd5c9cfaa140ab0ccfab7c478413109", "score": "0.47694448", "text": "setPath (callback) {\n\t\tsuper.setPath(() => {\n\t\t\tthis.path = `/posts?streamId=${this.teamStream.id}`;\n\t\t\tcallback();\n\t\t});\n\t}", "title": "" }, { "docid": "a9a782532b381e6e062bc8b068847a4a", "score": "0.47612372", "text": "setPath (callback) {\n\t\tif (this.type === 'file') {\n\t\t\tthis.stream = this.repoStreams[0];\n\t\t} else if (this.type === 'team stream') {\n\t\t\tthis.stream = this.teamStream;\n\t\t} else if (this.type === 'object') {\n\t\t\tthis.stream = this.postData[0].streams.find(stream => stream.type === 'object');\n\t\t} else {\n\t\t\tthrow `creating streams of type ${this.type} is deprecated`;\n\t\t}\n\t\tthis.path = '/streams/' + this.stream.id;\n\t\tcallback();\n\t}", "title": "" }, { "docid": "030ccad87632b430564cc73b6295a581", "score": "0.47528338", "text": "setPath (callback) {\n\t\t// i am a member of both teams owning these repos, so i should be able to fetch both\n\t\tthis.expectedRepos = [this.postData[0].repos[0], this.postData[2].repos[0]];\n\t\tlet ids = this.expectedRepos.map(repo => repo.id);\n\t\tthis.path = `/repos?teamId=${this.team.id}&ids=${ids}`;\n\t\tcallback();\n\t}", "title": "" }, { "docid": "875ebe8cf00f3e3219b53914a48faba4", "score": "0.4743166", "text": "function process(path, request, response) {\r\n}", "title": "" }, { "docid": "58c867a9059d26ac76950706255a610e", "score": "0.47406906", "text": "parsePath() {\n var protocol = goog.array.contains(this.map_['schemes'], 'https') ?\n 'https' : 'http';\n var host = this.map_['host'];\n var basepath = goog.isString(this.map_['basePath']) ?\n this.map_['basePath'] : '';\n var uri = new goog.Uri();\n uri.setScheme(protocol);\n uri.setDomain(host);\n uri.setPath(basepath);\n this.path = uri.toString();\n }", "title": "" }, { "docid": "a58d7035f9d68498589b77617c7079c9", "score": "0.47376806", "text": "function generateURL(){/* exported generateURL *//* TODO */}", "title": "" }, { "docid": "36455d589243503c9109619da3bd2456", "score": "0.4718889", "text": "onFlowIdOrBasePathChange_(newValue) {\n if (angular.isDefined(this.scope_['flowId']) &&\n angular.isDefined(this.scope_['apiBasePath'])) {\n this.logsUrl =\n [this.scope_['apiBasePath'], this.scope_['flowId'], 'log'].join('/');\n }\n }", "title": "" }, { "docid": "d4b1f639b2d337cef7e232eca192dec2", "score": "0.4711377", "text": "function watchToPath(item, scope, path){\n var pathHandlers = item.pathHandlers;\n\n var msg = this.getMessageByType('path') + path;\n if (!pathHandlers[path]){\n\n // generate message string for current scope path for all watchers\n pathHandlers[path] = msg;\n\n var prop = findObjectByPath(scope, path);\n if (prop) {\n var self = this;\n watchObject(prop.obj, prop.key, function(params){\n params.path = path;\n // this trigger will trig for all child watchers who are listen\n // noo need to store all child watchers callback, using broadcast way\n watchBro.trig(msg, params);\n self.trigChanges(params);\n });\n }\n }\n return msg;\n }", "title": "" }, { "docid": "49b41d933c853e226fefa5d7489f3bce", "score": "0.4705381", "text": "function myLinkFunction(x, y, z){\r\n //call normal code\r\n original_hbLink(x, y, z);\r\n\r\n //report results\r\n addClickToReport(x,y,z);\r\n\r\n //this method ultimately calls _hbSet(). those values will be captured and logged later when _hbSend() fires.\r\n}", "title": "" }, { "docid": "bbc5b31788830e85472dae628a3eb145", "score": "0.4701119", "text": "formatUrl(path) {\n const adjustedPath = path[0] !== '/' ? '/' + path : path;\n //TODO this will need to be adjusted\n return '/api' + adjustedPath;\n }", "title": "" }, { "docid": "d5237d8aeea7785617c72b02504c9ada", "score": "0.4699405", "text": "setPath (callback) {\n\t\t// we'll try to fetch a few streams from our repo, and one from the \"foreign\" repo, which we\n\t\t// don't have access to ... we should get back only the streams from our repo\n\t\tconst teamId = this.team.id;\n\t\tconst repoId = this.repo.id;\n\t\tconst foreignRepoId = this.foreignRepo.id;\n\t\tthis.expectedStreams = [\n\t\t\tthis.streamsByRepo[repoId][0],\n\t\t\tthis.streamsByRepo[repoId][2]\n\t\t];\n\t\tconst otherStreams = [\n\t\t\tthis.streamsByRepo[foreignRepoId][1],\n\t\t];\n\t\tconst allStreams = [...this.expectedStreams, ...otherStreams];\n\t\tconst ids = allStreams.map(stream => stream.id);\n\t\tthis.path = `/streams?teamId=${teamId}&repoId=${repoId}&ids=${ids}`;\n\t\tcallback();\n\t}", "title": "" }, { "docid": "0c718472bfd0f4467335a7053ac4718a", "score": "0.46843588", "text": "setPath (callback) {\n\t\tthis.path = `/posts?teamId=${this.team.id}&streamId=${this.teamStream.id}`;\n\t\tcallback();\n\t}", "title": "" }, { "docid": "80c154c926e2290a4455a6abd63d02d2", "score": "0.46781886", "text": "function setWorkerPath(newPath) {\n workerPath = newPath;\n}", "title": "" }, { "docid": "79115bd5663e334e2b606d25c22682ed", "score": "0.4677192", "text": "processItemForViewUrl (processedItem) {\n trace && console.log('JiraIntegrator.processItemForViewUrl:', this.provider.server._id, this.provider.server.title);\n let self = this;\n \n if (processedItem && processedItem.key) {\n let baseUrl = self.provider.server.baseUrl.replace(/\\/$/, '');\n processedItem.viewUrl = [ baseUrl, 'browse', processedItem.key ].join('/');\n }\n }", "title": "" }, { "docid": "bdaab03bbb379e548dda5f8f89da1048", "score": "0.46726844", "text": "setPath (callback) {\n\t\t// requesting the company created by the other user, but i was included in the team\n\t\tthis.path = '/companies/' + this.company.id;\n\t\tcallback();\n\t}", "title": "" }, { "docid": "ba17a05d4ce94023907fa57f2e8da177", "score": "0.4662188", "text": "function requestReport(chbxs, tag, reportName, category) {\n var payload = {\n gene_signatures: chbxs,\n report_name: reportName\n };\n if (category) {\n payload['category'] = category\n }\n $.ajax({\n url: 'report/custom/' + tag,\n type: 'POST',\n contentType: \"application/json; charset=utf-8\",\n data: JSON.stringify(payload),\n success: function(data) {\n window.location = data.new_url;\n }\n });\n }", "title": "" }, { "docid": "ebcc17cca12c6bb62138a30b4a660c4e", "score": "0.46610162", "text": "static (relativePath, systemPath, stripSlashes) {\n return handler(relativePath, systemPath, stripSlashes, false, false, undefined)\n }", "title": "" }, { "docid": "5c29a13046ada97a911cf98b95a2f035", "score": "0.46596792", "text": "function fullPath(path){\n\treturn baseUrl+path;\n}", "title": "" }, { "docid": "1f1890959133e111d092b3aa4c0b45ab", "score": "0.4658697", "text": "overrideUrl(iUrl) {\n return iUrl;\n }", "title": "" }, { "docid": "1c152750b74117368755735876769290", "score": "0.46416306", "text": "open (path) {\n return browser.url(path);\n }", "title": "" }, { "docid": "c3fecd912addc57cebd15df717255a75", "score": "0.46326566", "text": "function formatReferenceURL(path) {\n return path; /* TODO */\n}", "title": "" }, { "docid": "9dce3c5415e996202191100313ae95b3", "score": "0.46111956", "text": "get path() {}", "title": "" }, { "docid": "27901276a65b600bc2a74898fca12562", "score": "0.4585288", "text": "function FS_url(fpath,oncomplete=void_func,onfail=void_func){\n _FS_request(function(fs){\n _FS_getFileEntry(fs,fpath,function(fileEntry){\n oncomplete(fileEntry.toURL());\n },onfail);\n },onfail);\n}", "title": "" }, { "docid": "3a1243cf3fa239b0b154cbfe915fe3d4", "score": "0.45850706", "text": "set path(value) {}", "title": "" }, { "docid": "fb70c23d69500a3f31f32cd84aa808fe", "score": "0.45768556", "text": "function fixPath(href) {\n return generator.rewriteLink(href, renderOpts());\n }", "title": "" }, { "docid": "f4bb8255004187c91c74f170a3a252cb", "score": "0.45564196", "text": "_getPatchHref(repo, patch) {\n return `/${repo.username}/${repo.reponame}/pull/${repo.pullNumber}/files#diff-${patch.diffId}`;\n }", "title": "" }, { "docid": "b053271f04bf2d3a6f4e23eec019cf32", "score": "0.4549808", "text": "function pathBuilder(_ref4) {var req = _ref4.req,value = _ref4.value,parameter = _ref4.parameter;\n req.url = req.url.split(\"{\".concat(parameter.name, \"}\")).join(encodeURIComponent(value));\n}", "title": "" }, { "docid": "8d7c0eca7ca0e78e7030e82093eba598", "score": "0.4544331", "text": "function requestCB(request, response) {\n\tresponse.end(\"It works. Path hit (request.url) = \" + request.url);\n}", "title": "" }, { "docid": "0d8e579bf4da13033d089e9414f6543d", "score": "0.45439833", "text": "getStatusUrl() {\n\t\t\tthrow new Error('This function must be overridden!');\n\t\t}", "title": "" }, { "docid": "c86592ce61e013471c76173a8dc2597d", "score": "0.45364606", "text": "buildURL(...args) {\n let urlPath = super.buildURL(...args);\n\n if (!urlPath.endsWith('/')) {\n urlPath += '/';\n }\n\n return urlPath;\n }", "title": "" }, { "docid": "93407a7e00f100b3d594f7962add42b2", "score": "0.453187", "text": "function getURL(path) {\n let api = $('#api-url').val();\n let proxy = $('#proxy-url').val();\n\n return proxy + api + path;\n}", "title": "" }, { "docid": "73cd73974e9eaffc568f92eaabdce72c", "score": "0.4521969", "text": "function callback() {\r\n console.info(\"Success: Record updated successfully\");\r\n $(location).prop('href', '#ERViewFeedbackPage');\r\n alert(\"Feedback Updated successfully\");\r\n }", "title": "" }, { "docid": "e18b2867bea505d783745bdb6994f14d", "score": "0.4516618", "text": "function openBBFactoryReport(id, level, name)\r\n {\r\n if(!isValidRecord(\"URL\", \"N\")) return;\r\n\r\n var bDisp = true;\r\n if (getval('chgflds') != \"\")\r\n {\r\n if (confirm(szMsg_Changes))\r\n {\r\n fsubmit(szSAVE);\r\n bDisp = false;\r\n }\r\n }\r\n if (bDisp)\r\n {\r\n var str = 'report?id=' + id + '&method=customreports' + '&level=' + level + '&reportname=' + name+ '&requestFrom=' + 'PLM';\r\n oW('report', str, 800, 650);\r\n }\r\n }", "title": "" }, { "docid": "b6a3822749429c72de85cc7a4984271b", "score": "0.4507919", "text": "open (path) {\n return browser.url(path)\n }", "title": "" }, { "docid": "7e2afa8ea35dc8009c0cde68e0398c4c", "score": "0.45068204", "text": "function updateUrlGroupCallback() {\n // Reload the page to recalculate totals and\n // availability metrics\n $route.reload();\n }", "title": "" }, { "docid": "683ddbaf44c0a16c0315812d9d8bbf63", "score": "0.4497464", "text": "function setPath(id, name, path, status) {\n id = pathPrefix.concat(id);\n var link = document.getElementById(id);\n var span;\n\n if (!name) name = \"Home\";\n\n if (link)\n link.className = pathClass[status];\n else {\n span = document.createElement(\"span\");\n if (pathsContainer.children.length > 0)\n span.appendChild(document.createTextNode(\" > \"));\n\n link = document.createElement(\"a\");\n link.id = id;\n if (path != null) link.href = \"/status/\" + encodeURI(path);\n link.className = pathClass[status];\n link.innerText = name;\n\n span.appendChild(link);\n pathsContainer.appendChild(span);\n }\n}", "title": "" }, { "docid": "e984a6bac948a175ee26f06ffa6263f6", "score": "0.44936737", "text": "function clickme(filter) { \n\n var url = ServiceURL+'GetExcelReport/' + filter;\n location.href = url;\n return false;\n}", "title": "" }, { "docid": "2fd3f3625f3167081a1f7c913ed34017", "score": "0.44904983", "text": "_reportAsyncScript(auth, report, done) {\n let authJSON = JSON.stringify(auth);\n let reportJSON = JSON.stringify(report);\n\n let url = `${this._hostport}/_rpc/v1/reports/uri_encoded` +\n \"?auth=\" + encodeURIComponent(authJSON) +\n \"&report=\" + encodeURIComponent(reportJSON);\n\n let elem = document.createElement(\"script\");\n elem.async = true;\n elem.defer = true;\n elem.src = url;\n elem.type = \"text/javascript\";\n\n let hostElem = document.getElementsByTagName(\"head\")[0];\n if (hostElem) {\n hostElem.appendChild(elem);\n }\n return done(null, null);\n }", "title": "" }, { "docid": "8d617e4bc86c69633bf43f0adb664ebe", "score": "0.4487267", "text": "function gotFileEntry(fileEntry) {\n\tcsvPath = fileEntry.toURL(); // Copying Opened file path\n\tconsole.log(csvPath);\n\tfileEntry.createWriter(gotFileWriter, failToGet);\n}", "title": "" }, { "docid": "0a6675ddb63364d99d2ff45f90f1e9b2", "score": "0.4485354", "text": "function wrapCallback(url) {\n\n}", "title": "" }, { "docid": "0399d3c30ddea42ca114b310174191e1", "score": "0.44721445", "text": "_updateUrl() {\n const history = this.getSampleHandler().provenance.getActionHistory();\n\n let hash = \"\";\n if (history.length) {\n hash =\n \"#\" +\n lzString.compressToEncodedURIComponent(JSON.stringify(history));\n }\n\n window.history.replaceState(\n undefined,\n document.title,\n window.location.pathname + window.location.search + hash\n );\n }", "title": "" }, { "docid": "8bc2a8b6367899d3262f9e751722cca1", "score": "0.44710493", "text": "function reportsHandler () {\n /*jshint validthis: true */\n \"use strict\";\n\n this.submitReport = function(req, res, next) {\n fs.appendFile('./hackatest.txt', req.body.position.lat + \" \" + req.body.position.lng + ' ' + req.body.complaint + ';', function(err) {});\n };\n}", "title": "" }, { "docid": "bd57a52608952e97ca3546f4f489fdac", "score": "0.44633374", "text": "function captureCurrentPath() {\n if (tripwire ) {\n $window.ga('send', 'pageview', $location.path());\n }\n else {\n tripwire = true; // just don't record the first one- it was already recorded in the head script\n }\n }", "title": "" }, { "docid": "3d7d3acfcb6082abd042ab455b65eb3a", "score": "0.445685", "text": "function genPath(pathValuesUrl, myPos, setSize, callback){\n\tconsole.log(\"snapping alfa path to road\");\n\tsnapToRoads(pathValuesUrl, processSnapToRoadResponse, myPos, setSize, callback);\n}", "title": "" }, { "docid": "1e02fcb97eb8b4ee6782d59fd0f83adf", "score": "0.44527662", "text": "function getLastHookedPath() {\n const path = lastHookedRequestUrl.pathname + lastHookedRequestUrl.search;\n window.domAutomationController.send(path);\n}", "title": "" }, { "docid": "7065d008ee2d844512d8ef6320ba482c", "score": "0.44477916", "text": "function patchFetchForRelativeURLs(instance) {\n const fastboot = instance.lookup('service:fastboot');\n setupFastboot(fastboot.get('request'));\n}", "title": "" }, { "docid": "d9f302e9bbbc747b8d122d2fe3070000", "score": "0.4445092", "text": "set path(path) {\n super.path = path;\n }", "title": "" }, { "docid": "4b5d0b78fe913ba3ec513cb0a8867dcc", "score": "0.44400832", "text": "function addPath(req,path) {\n if (path != null) {\n if ($.isArray(path)) {\n req.path = $.map(path,Jolokia.escape).join(\"/\");\n } else {\n req.path = path;\n }\n }\n }", "title": "" }, { "docid": "8b9f9fa06073fda12872e46d20495961", "score": "0.44357517", "text": "function reportFileClick(evt) {\n // Load up the file specified by the file attribute.\n var options = defaultOpenFunctionOptions();\n options.tabId = 'report';\n openFunction(getFunction(evt), options);\n}", "title": "" }, { "docid": "8637cb72b22de6be206ac1e26cfc8cdd", "score": "0.44326466", "text": "register (name, path) {\n patchers.set(name, {path, enabled: true});\n }", "title": "" }, { "docid": "b1e474239bb79e3fb1b7da0f45353546", "score": "0.4428081", "text": "onCodePathStart(codePath, node) {\n funcInfo = {\n upper: funcInfo,\n codePath,\n hasReturn: false,\n hasReturnValue: false,\n messageId: \"\",\n node\n };\n }", "title": "" }, { "docid": "66981b76fdd08b28555dec0cae731a8d", "score": "0.4422732", "text": "function wrapMethodUrlPreprocess (method) {\n return function (inputUrl, fn) {\n const parsedUrl = url.parse(inputUrl)\n\n // Replace local\n if (parsedUrl.host === TEST_HOSTNAME &&\n parsedUrl.port === TEST_PORT) {\n const path = url.format({\n pathname: parsedUrl.pathname,\n search: parsedUrl.search\n })\n return method.call(this, path, fn)\n }\n\n return method.call(this, inputUrl, fn)\n }\n}", "title": "" }, { "docid": "a3a329b042c1292a4a8eeede1006f232", "score": "0.44190764", "text": "downloadFile(parent_directory , full_url, media_id){\n let DOWNLOAD_DIR = \"./data/scraped\";\n var src_name = url.parse(full_url).pathname.split('/').pop();\n let parent_path = path.join(DOWNLOAD_DIR, parent_directory);\n let full_download_path = path.join(parent_path, src_name);\n let thisthat = this;\n var options = {\n directory: parent_path,\n filename: src_name\n }\n download(full_url, options, function(err){\n if(err) console.log(err); \n thisthat.logger.info(`Downloading ${full_download_path}`);\n thisthat.dao.updateMediaPath(full_download_path, media_id);\n }) \n }", "title": "" }, { "docid": "83c51c8e7ce42753f5c99a42af9b1b2f", "score": "0.44185466", "text": "setPath (callback) {\n\t\tconst parentPostId = this.postData[this.whichPostToReplyTo].post.id;\n\t\tsuper.setPath(() => {\n\t\t\tthis.path = `/posts?parentPostId=${parentPostId}`;\n\t\t\tcallback();\n\t\t});\n\t}", "title": "" }, { "docid": "0a23223ac04dfa6ae5a7ecece35fc43a", "score": "0.44162077", "text": "function updateURLFragment(path) {\n window.location.hash = path;\n }", "title": "" }, { "docid": "d6a71da56ed0d4c1f77e3a39b9f5dc47", "score": "0.4407918", "text": "getUrl({ path }) { //Destruction equivalent to modelInstance path\n return `${Env.get('APP_URL')}/uploads/${path}` //The relative path\n }", "title": "" }, { "docid": "b26dcb34c3b9165b0886a214d8ae7282", "score": "0.4406911", "text": "open(path){\n browser.url(path);\n }", "title": "" }, { "docid": "2d42544f4ec4a34e37df2eddc6473a65", "score": "0.44063467", "text": "open () {\n browser.url(path)\n //super.open('http://theculturetrip.com') //provide your additional URL if any. this will append to the baseUrl to form complete URL\n browser.pause(1000);\n }", "title": "" }, { "docid": "dd9ccad24dcded9e33f81b64286e8617", "score": "0.44057176", "text": "function _getReport(reportPath) {\n var endpointUrl =\n config.BASE_URL +\n \"api/repo/files/\" +\n reportPath.replace(/\\//g, \":\") +\n \"/properties\";\n return $http.get(endpointUrl);\n }", "title": "" }, { "docid": "b172acdbb62edc2082cf54ddb3189975", "score": "0.44030705", "text": "function setInvocationUrl() {\n ctrl.version.ui.invocationUrl = VersionHelperService.getInvocationUrl(ctrl.version);\n }", "title": "" }, { "docid": "008117f3853bc597d441674f948dbd7f", "score": "0.44000524", "text": "function SendValidationReport(report){\n var responseBody = process.env.ERRPAGE;\n console.log('Error occurred: ' + report);\n _context.succeed({location: responseBody});\n}", "title": "" }, { "docid": "f1ccadd525f35bfdab9bdde38f3c3f7e", "score": "0.4395779", "text": "setPath (newPath, callback) {\n\t\tif (tools.notType(newPath, 'string')) {\n\t\t\treturn;\n\t\t}\n\t\tsiad.apiCall({\n\t\t\turl: '/renter/rename/' + this.path ,\n\t\t\tmethod: 'POST',\n\t\t\tqs: {\n\t\t\t\tnewsiapath: newPath,\n\t\t\t},\n\t\t}, () => {\n\t\t\tthis.path = newPath;\n\t\t\tif (callback) {\n\t\t\t\tcallback(newPath);\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "b9d42b042ea129219f94aeaa666d6248", "score": "0.43940547", "text": "URLChange(){ \n //console.log(\"hi\");\n }", "title": "" }, { "docid": "03072c70af4574d5e6426794c8c18e6f", "score": "0.4392511", "text": "function instruction_pdf(taskinstruction_id)\n{\n var host = window.location.href;//.hostname\n var httPpath = \"\";\n if (host.indexOf('index.php'))\n {\n httpPath = host.substr(0, (host.indexOf('index.php') + 9)) + '?r=';\n }\n location.href = httpPath + \"pdf/instructionpdf&id=\" + taskinstruction_id;\n}", "title": "" }, { "docid": "52ff9e6abdf94bc1558714da5f75f191", "score": "0.43896794", "text": "function computeURL() {\n var url =options.url;\n if(typeof options.url == 'function') {\n url = options.url.call();\n }\n return url;\n }", "title": "" }, { "docid": "e552d5640f71916532696f8bfc18ffd1", "score": "0.4384339", "text": "function save() {\n var config = {\n path: options.path,\n browser: controller.getBrowser().toLowerCase(),\n compare: options.compare\n };\n $.get('/samples/compare-update-report', config);\n }", "title": "" }, { "docid": "eece67e72da7fb91dfb63ca317f6a68f", "score": "0.43727127", "text": "getFileUpdateUrl(file) {\n return this.getFileUrl(file);\n }", "title": "" }, { "docid": "bdb1d57351fe3f660af3d7dd5416089f", "score": "0.43698978", "text": "function redirectFromPathLabel(path) {\n // get div which holds the path label\n const pathLabel = document.getElementById(\"pathLabel\")\n\n // clear path label\n clearElement(pathLabel)\n\n // add base repo link\n const mainfileAnchor = document.createElement(\"a\")\n mainfileAnchor.textContent = \"dy_mainfile/\"\n mainfileAnchor.onclick = function() { redirectFromPathLabel('') }\n pathLabel.appendChild(mainfileAnchor)\n\n if (path == '') { \n getFolderContent(path)\n return \n }\n\n // add remaining path links \n const pathDirs = path.split(\"/\")\n for (i = 0; i < pathDirs.length; i++){\n const anchor = document.createElement(\"a\")\n anchor.textContent = pathDirs[i] + \"/\"\n anchor.onclick = function() { redirectFromPathLabel(pathDirs.slice(0,i+1).join(\"/\"))} \n pathLabel.appendChild(anchor)\n }\n\n // get folder content\n getFolderContent(path)\n}", "title": "" }, { "docid": "8f588f39ae89dbd671cedf23220ba89f", "score": "0.43675593", "text": "function updatePath(settings) {\n if (settings && settings.path) {\n var parts = [];\n\n if (settings.path instanceof Array) {\n parts = settings.path;\n }\n else if (settings.path instanceof String ) {\n parts = settings.path.split(\"/\");\n //if (parts[parts.length - 1] === \"/\") {\n // parts.splice(parts.length - 1, 1);\n //}\n }\n url.path.components.splice(0, url.path.components.length);\n for (var part of parts) {\n url.path.components.push(part);\n }\n return pushNewState({\n state: settings.state,\n title: settings.title,\n raisePopState: settings.raisePopState\n });\n }\n return url;\n }", "title": "" }, { "docid": "4714f5291653635f109d0613b2b21f95", "score": "0.4366983", "text": "function record_proxy (pathname, handler)\n{\n console.log(\"*** record_proxy isn't implemented\");\n \n // when the corresponding thing is set up\n // pass it to the given handler\n if (/^\\/wot\\/.+/.test(pathname))\n {\n var id = pathname.substr(5);\n console.log('seeking thing for id: ' + id);\n }\n}", "title": "" }, { "docid": "125fb00f4639eca731aee0eb808b5d6b", "score": "0.43624523", "text": "_buildUrl(...extraPaths) {\n let apiVersion = this.config.apiVersion;\n let baseUrl = '/' + apiVersion + '/document';\n\n if (extraPaths.length) {\n baseUrl += '/' + extraPaths.join('/');\n }\n\n return baseUrl;\n }", "title": "" }, { "docid": "3ed23da9e4b91083b9c9409e88192452", "score": "0.4361224", "text": "function highlightPathHandler(e, link) {\n if (link) {\n var $original = $(link).data('original-link');\n var show = e.type === 'showPath';\n // Toggle an additional CSS class to visually highlight the matching link.\n // @todo Consider using same visual appearance as regular hover.\n $original.toggleClass('highlight', show);\n $original.trigger(show ? 'mouseenter' : 'mouseleave');\n }\n }", "title": "" }, { "docid": "9fa66c817bc7f3973d64368d91b5db94", "score": "0.43611574", "text": "function setPathCrumbtrail(irodsAbsolutePath) {\n\n\tif (irodsAbsolutePath == null || irodsAbsolutePath.length == 0) {\n\t\t$(\"#infoDivPathArea\").html(\"\");\n\t\treturn;\n\t}\n\n\t// else\n\n\tvar pathArray = irodsAbsolutePath.split(\"/\");\n\tvar pathLen = irodsAbsolutePath.length;\n\tvar compressedPathArray = new Array();\n\tvar totLen = 0;\n\n\t// compress each part of the path\n\t$.each(pathArray, function(index, value) {\n\t\tcompressedPathArray[index] = truncatePathPart(value);\n\t\ttotLen += compressedPathArray[index].length;\n\n\t});\n\n\tvar s = \"\";\n\n\t// a long path will drop the leading path parts, so indicate truncation\n\tif (totLen > 80) {\n\t\ts += \"...\";\n\t}\n\n\t$.each(compressedPathArray, function(index, value) {\n\t\tif (index > 0) {\n\n\t\t\t// if the path name is really long, just show the last 3 path\n\t\t\t// entries\n\t\t\tif (totLen > 80) {\n\t\t\t\tif (index > compressedPathArray.length - 3) {\n\t\t\t\t\ts += \" / \";\n\t\t\t\t\ts += buildPathPartAnchor(index, pathArray);\n\t\t\t\t\ts += truncatePathPart(value);\n\t\t\t\t\ts += \"</a>\";\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\ts += \" / \";\n\t\t\t\ts += buildPathPartAnchor(index, pathArray);\n\t\t\t\ts += truncatePathPart(value);\n\t\t\t\ts += \"</a>\";\n\t\t\t}\n\t\t}\n\n\t});\n\n\t$(\"#infoDivPathArea\").html(s);\n\n}", "title": "" }, { "docid": "4b1ed9e19466679dc24ee66332d53f4c", "score": "0.43594128", "text": "function rpt_update(levelinfo,pathlink,filter)\n\t{\n\t\tdata = get_data_for_update();\n\t\t\n\t\t$.ajax({\n\t\t\turl : url_upate_list,\n\t\t\tdata : data,\n\t\t\ttype: 'GET',\n\t\t\tsuccess :function(result, textStatus, jqXHR)\n\t\t\t{\n\t\t\t\tif (result.success)\n\t\t\t\t{\n\t\t\t\t\tif (result.lstobject) \n\t\t\t\t\t{\t\n\t\t\t\t\t\t$(\"#rpt_list\").empty();\n\t\t\t\t\t\t$(\"#rpt_list\").append(result.lstobject);\n\t\t\t\t\t\t\n\t\t\t\t\t\trptlink = \"Nothing\";\n\t\t\t\t\t\t//Create a config file.\n\t\t\t\t\t\t//var infosetting = new step_report_store(result.currentpage,result.nav_nbrrow,result.nav_topic,result.nav_topic_by,result.nav_timescale,result.nav_timescale_start,result.nav_timescale_end,result.nav_sort,result.item_msg,result.hasprev,result.hasnext);\n\t\t\t\t\t\t//store into the cache data.\n\t\t\t\t\t\t//report_cache.store_cache_data(result.lstobject,infosetting);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (levelinfo == 1) \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Note update the current page to store before assigning data from server to client\n\t\t\t\t\t\t\tvar varcurrentpage = $(\"#rpt_nav_currentpage\").val();\n\t\t\t\t\t\t\tvar varsortfield = $(\"#rpt_nav_sort\").val();\n\t\t\t\t\t\t\tvar varpagesize = $(\"#rpt_nav_page_size\").val();\n\t\t\t\t\t\t\tvar vartopic = $(\"#rpt_nav_topic\").val();\n\t\t\t\t\t\t\tvar vartopicby = $(\"#rpt_nav_topic_by\").val();\n\t\t\t\t\t\t\tvar vartimescalse = $(\"#rpt_nav_time\").val();\n\t\t\t\t\t\t\tvar varstarttime = $(\"#rpt_nav_starttime\").val();\n\t\t\t\t\t\t\tvar varendtime = $(\"#rpt_nav_endtime\").val();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//var infosetting = new step_report_store(varcurrentpage,result.nav_nbrrow,result.nav_topic,result.nav_topic_by,result.nav_timescale,result.nav_timescale_start,result.nav_timescale_end,varsortfield,result.item_msg,result.hasprev,result.hasnext);\n\t\t\t\t\t\t\tvar infosetting = new step_report_store(varcurrentpage,varpagesize,vartopic,vartopicby,vartimescalse,varstarttime,varendtime,varsortfield,result.item_msg,result.hasprev,result.hasnext);\t\n\t\t\t\t\t\t\trptlink = report_level.showlink(0,pathlink,infosetting,filter);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tvar infosetting = new step_report_store(result.currentpage,result.nav_nbrrow,result.nav_topic,result.nav_topic_by,result.nav_timescale,result.nav_timescale_start,result.nav_timescale_end,result.nav_sort,result.item_msg,result.hasprev,result.hasnext);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (typeof pathlink == 'undefined') \n\t\t\t\t\t\t\t\trptlink = report_level.showlink(0,result.nav_topic,infosetting,\"\");\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\trptlink = report_level.showlink(0,pathlink,infosetting,filter);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tshow_hide_rpt_nav(result);\n\t\t\t\t\t\t\n\t\t\t\t\t\t//Update the hidden input.\n\t\t\t\t\t\tupdate_nav_info(result);\n\t\t\t\t\t\t\n\t\t\t\t\t\t$('#rpt_data_body tr:last').addClass('ui-widget-header');\n\t\t\t\t\t\t$('#rpt_data_body tr:last').find('td:eq(1)').removeAttr('onclick');\n\t\t\t\t\t\t$('#rpt_data_body tr:last').find('td:eq(1)').removeAttr('style');\n\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#rpt_link\").html(rptlink); \n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\t//here\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\talert(result.error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t}", "title": "" }, { "docid": "4f92600ac421a0bbc785e8c6be5dd1d4", "score": "0.4353637", "text": "function getURL(statistic,frame,month){\n\tvar newurl = url.replace(\"STAT\",statistic);\n newurl = newurl.replace(\"MONTH\",month);\n\treturn newurl;\n}", "title": "" }, { "docid": "94cd944439d748de77b0f3341c538293", "score": "0.435164", "text": "function genUrl(opts, path) {\n if (opts.remote) {\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n var pathDel = !opts.path ? '' : '/';\n\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n return opts.protocol + '://' + opts.host + ':' + opts.port + '/' + opts.path + pathDel + path;\n }\n\n return '/' + path;\n}", "title": "" }, { "docid": "94cd944439d748de77b0f3341c538293", "score": "0.435164", "text": "function genUrl(opts, path) {\n if (opts.remote) {\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n var pathDel = !opts.path ? '' : '/';\n\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n return opts.protocol + '://' + opts.host + ':' + opts.port + '/' + opts.path + pathDel + path;\n }\n\n return '/' + path;\n}", "title": "" }, { "docid": "9480cf601ff06f768d030a4f8f691573", "score": "0.4350117", "text": "function genUrl(opts, path) {\n if (opts.remote) {\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n var pathDel = !opts.path ? '' : '/';\n\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n return opts.protocol + '://' + opts.host + ':' + opts.port + '/' +\n opts.path + pathDel + path;\n }\n\n return '/' + path;\n}", "title": "" }, { "docid": "9480cf601ff06f768d030a4f8f691573", "score": "0.4350117", "text": "function genUrl(opts, path) {\n if (opts.remote) {\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n var pathDel = !opts.path ? '' : '/';\n\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n return opts.protocol + '://' + opts.host + ':' + opts.port + '/' +\n opts.path + pathDel + path;\n }\n\n return '/' + path;\n}", "title": "" }, { "docid": "9480cf601ff06f768d030a4f8f691573", "score": "0.4350117", "text": "function genUrl(opts, path) {\n if (opts.remote) {\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n var pathDel = !opts.path ? '' : '/';\n\n // If the host already has a path, then we need to have a path delimiter\n // Otherwise, the path delimiter is the empty string\n return opts.protocol + '://' + opts.host + ':' + opts.port + '/' +\n opts.path + pathDel + path;\n }\n\n return '/' + path;\n}", "title": "" }, { "docid": "0d39ee1ca6b3547bafa21bc9040e3302", "score": "0.43414867", "text": "function goURL(a,b,c){location=trackURL(a,b,c)}", "title": "" } ]
789d7483925111704472a969a334c760
Object Ordering by Field
[ { "docid": "a976e7597f9264fe373e3df768ae3cb1", "score": "0.0", "text": "function parseFieldSpecs(input) {\n var specs = [];\n var tokens = [];\n var i;\n var token;\n if (typeof input === 'string') {\n tokens = input.split(/\\s*,\\s*/);\n }\n else if (typeof input === 'function') {\n tokens = [input];\n }\n else if ($.isArray(input)) {\n tokens = input;\n }\n for (i = 0; i < tokens.length; i++) {\n token = tokens[i];\n if (typeof token === 'string') {\n specs.push(token.charAt(0) === '-' ?\n { field: token.substring(1), order: -1 } :\n { field: token, order: 1 });\n }\n else if (typeof token === 'function') {\n specs.push({ func: token });\n }\n }\n return specs;\n}", "title": "" } ]
[ { "docid": "63ae0d23779f7a7485073e40f9117399", "score": "0.70908284", "text": "sortByField(field, direction, fieldData) {\n const getField = (obj, field) => {\n if (fieldData && fieldData.model && fieldData.modelField) {\n return obj.getIn([fieldData.model, fieldData.modelField]) || '';\n }\n return obj.get(field) || '';\n }\n\n direction = direction || 'asc'; // Default sort direction is ascending\n // TODO: Different sorts by type\n const oldState = Immutable.fromJS(this.state.data);\n if (direction === 'desc') {\n const newState = oldState.sort((a, b) =>\n getField(b, field).localeCompare(getField(a, field))\n );\n this.setState({ data: newState.toJS() });\n }\n else {\n const newState = oldState.sort((a, b) =>\n getField(a, field).localeCompare(getField(b, field))\n );\n this.setState({ data: newState.toJS() });\n }\n }", "title": "" }, { "docid": "069195324901171d81f12ad2144714f5", "score": "0.69612205", "text": "sortByField(fieldName) {\n if (this.sort_key != fieldName) {\n this.sort_key = fieldName;\n this.rev = false;\n } else {\n this.rev = !this.rev;\n }\n\n this.sort();\n }", "title": "" }, { "docid": "3ee56295d5f0ce4f4ce33ad9b2334379", "score": "0.6908954", "text": "sortField (field) {\n field = underscore(field)\n const sortField = this.controller.get('sortField')\n const sortOrder = this.controller.get('sortOrder')\n\n // sortField hasn't changed so we toggle sortOrder\n // check for the descending and ascending versions\n if (field === sortField || '-' + field === sortField) {\n if (sortOrder === '-') {\n this.controller.set('sortOrder', '')\n } else {\n this.controller.set('sortOrder', '-')\n }\n }\n // always update the sortField..either the field changes or the order changes\n this.controller.set('sortField', this.controller.get('sortOrder') + field)\n }", "title": "" }, { "docid": "ac6644d86070b921a46268fb1fb38f81", "score": "0.6586398", "text": "function sortBy(as, fld) {\n return as.sort((a, b) => {\n var y = fget(a, fld), x = fget(b, fld);\n if (Array.isArray(x)) return x.join().localeCompare(y.join());\n if (typeof x==='string') return x.localeCompare(y);\n if (typeof x==='object') return JSON.stringify(x).localeCompare(JSON.stringify(y));\n return x-y;\n });\n}", "title": "" }, { "docid": "32d16e510261b3481b1247d88bc758e2", "score": "0.64555836", "text": "sortByFieldAscending(fieldName){\n function compare(a, b){\n const valueA = a[fieldName];\n const valueB = b[fieldName];\n\n let comparison = 0;\n if(valueA != null && valueB != null){\n if(valueA > valueB){\n comparison = 1;\n }\n else if(valueA < valueB){\n comparison = -1;\n }\n }\n else if(valueA == null && valueB != null){\n comparison = 1;\n }\n else if(valueA != null && valueB == null){\n comparison = -1;\n }\n \n return comparison;\n }\n \n this.tableRows.sort(compare);\n\n //Needed to refresh the UI due to the reactivity of LWCs\n this.tableRows = [...this.tableRows];\n }", "title": "" }, { "docid": "41a2dc4c9a7a2985824426038c4b77a9", "score": "0.6446414", "text": "sortByField(givenShipments, sortCategory, sortDirection) {\n const shipments = sortByKey(givenShipments.slice(), sortCategory);\n\n if (sortDirection === DESC) {\n shipments.reverse();\n }\n\n return shipments;\n }", "title": "" }, { "docid": "1073d75e7a828e071c9f62c2c9f8e660", "score": "0.6434116", "text": "function sortBy() {\n var fields = [].slice.call(arguments),\n n_fields = fields.length;\n return function (A, B) {\n var a, b, field, key, reverse, result, i;\n\n for (i = 0; i < n_fields; i++) {\n result = 0;\n field = fields[i];\n key = typeof field === 'string' ? field : field.name;\n a = A[key];\n b = B[key];\n\n if (typeof field.primer !== 'undefined') {\n a = field.primer(a);\n b = field.primer(b);\n }\n\n reverse = field.reverse ? -1 : 1;\n\n if (a < b) {\n result = reverse * -1;\n }\n\n if (a > b) {\n result = reverse * 1;\n }\n\n if (result !== 0) {\n break;\n }\n }\n\n return result;\n };\n}", "title": "" }, { "docid": "dc61df90d898c04cecc984ccb2e41d6d", "score": "0.6391195", "text": "function orderBy(field) {\n vm.sort.field = field;\n vm.sort.reverse = !vm.sort.reverse;\n }", "title": "" }, { "docid": "d3975d17703f4ebe01d600618eb4b10e", "score": "0.637585", "text": "function sortByStringField(isUp, field){\n return function(x, y) {\n return isUp ? x[field].localeCompare(y[field]) : y[field].localeCompare(x[field]);\n }\n}", "title": "" }, { "docid": "c16ed101dc248e3419bba7784466a88a", "score": "0.6344016", "text": "sortData(fieldname, direction) {\n // serialize the data before calling sort function\n let parseData = JSON.parse(JSON.stringify(this.teamList));\n\n // Return the value stored in the field\n let keyValue = (a) => {\n return a[fieldname];\n };\n\n // cheking reverse direction \n let isReverse = direction === 'asc' ? 1 : -1;\n\n // sorting data \n parseData.sort((x, y) => {\n x = keyValue(x) ? keyValue(x) : ''; // handling null values\n y = keyValue(y) ? keyValue(y) : '';\n\n // sorting values based on direction\n return isReverse * ((x > y) - (y > x));\n });\n\n // set the sorted data to data table data\n this.teamList = parseData;\n\n }", "title": "" }, { "docid": "427ae293c965cdaac92b7b1fc28d7aca", "score": "0.6327979", "text": "MapOrderFields(fields, mapping) {\n if (mapping == undefined) {\n console.error(\"Table missing mapping for MapOrderFields\");\n return;\n }\n let orderby = [];\n //prep array because will receive out of order\n for (let f in fields) {\n orderby.push([]);\n }\n\n for (let f in fields) {\n // capture current field object\n let fobj = fields[f];\n if (fobj.order != null && fobj.sort != null) {\n if (f in mapping) {\n for (let mapname of mapping[f]) {\n let sortobj = {};\n if (fobj.sort == 'up') {\n sortobj[mapname] = 'asc';\n } else {\n sortobj[mapname] = 'desc';\n }\n let stack = orderby[fobj.order];\n if (stack != undefined) {\n stack.push(sortobj);\n } else {\n console.error('Mapping order fields bucket undefined');\n }\n }\n }\n }\n }\n return orderby.flat();\n }", "title": "" }, { "docid": "78289cdd43522ea4b7a2efc4af2ae6a0", "score": "0.6326406", "text": "function sort(field, order) {\n if (field == 'price') {\n if (order == 'l2h') {\n show_products(products.sort(function (a, b) {\n return a.price - b.price;\n }));\n } else if (order == 'h2l') {\n show_products(products.sort(function (a, b) {\n return b.price - a.price;\n }));\n }\n } else if (field == 'rating') {\n if (order == 'l2h') {\n show_products(products.sort(function (a, b) {\n return a.rating - b.rating;\n }));\n } else if (order == 'h2l') {\n show_products(products.sort(function (a, b) {\n return b.rating - a.rating;\n }));\n }\n }\n}", "title": "" }, { "docid": "d8dfa0680263a3de690ed9a25abef4b9", "score": "0.62880594", "text": "sort () {\r\n this._data.sort((a, b) => a.sortOrder !== b.sortOrder ? b.sortOrder - a.sortOrder : a.value.localeCompare(b.value))\r\n }", "title": "" }, { "docid": "42b2967329a894d788c74a55ae12cbf9", "score": "0.6264815", "text": "function sort_by(field, reverse, primer){\n\n var key = function (x) {return primer ? primer(x[field]) : x[field]};\n\n return function (a,b) {\n var A = key(a), B = key(b);\n return (A < B ? -1 : (A > B ? 1 : 0)) * [1,-1][+!!reverse]; \n }\n}", "title": "" }, { "docid": "d27a94674b211c58e18d458d1a3df634", "score": "0.6241614", "text": "function sort_objarr_by_key(objarr, order, key, val_type) {\n\n\t\tvar sorted_arr = [];\n\t\tvar array_key = key.split('.');\n\t\t//in case the field name have dots\n\t\tarray_key = handle_dots(array_key);\n\n\t\tfor (var i = 0; i < objarr.length; i++) {\n\t\t\tvar objval = _init_val(objarr[i], array_key, val_type);\n\n\t\t\tvar insert_index = -1;\n\t\t\tfor (var j = 0; j < sorted_arr.length; j++) {\n\n\t\t\t\tvar objcompval = _init_val(sorted_arr[j], array_key, val_type);\n\n\t\t\t\tif (order == 'desc') {\n\t\t\t\t\tif (objcompval < objval) {\n\t\t\t\t\t\tinsert_index = j;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (order == 'asc') {\n\t\t\t\t\t\tif (objcompval > objval) {\n\t\t\t\t\t\t\tinsert_index = j;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t//if (insert_index == sorted_arr.length - 1) {\n\t\t\tif (insert_index == -1) {\n\t\t\t\tsorted_arr.push(objarr[i]);\n\t\t\t}else {\n\t\t\t\tsorted_arr.splice(insert_index, 0, objarr[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn sorted_arr;\n\n\t\t/*init the value for the sorting*/\n\t\tfunction _init_val(arr,array_key,val_type) {\n\t\t\tvar val= null;\n\t\t\tif (arr.hasOwnProperty(array_key[0])) {\n\t\t\t\tval= arr[array_key[0]];\n\t\t\t\tif(array_key.length > 1){\n\t\t\t\t\tval = arr[array_key[0]][array_key[1]];\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tswitch (val_type) {\n\t\t\t\t\tcase \"text\": val= \"\"; break;\n\t\t\t\t\tcase \"int\": val= -1; break;\n\t\t\t\t\tdefault:\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( (val == \"None\") && (val_type = \"int\")){\n\t\t\t\tval = -1;\n\t\t\t}\n\n\t\t\tif (array_key[1] == \"concat-list\") {\n\t\t\t\tvar str_concat = \"\";\n\t\t\t\tfor (var i = 0; i < val.length; i++) {\n\t\t\t\t\tstr_concat = str_concat + \" \" +val[i].value;\n\t\t\t\t}\n\t\t\t\tval = str_concat;\n\t\t\t}\n\n\t\t\tif (val_type == \"text\"){\n\t\t\t\tval = val.toLowerCase();\n\t\t\t}else{\n\t\t\t\t\tif (val_type == \"date\") {\n\t\t\t\t\t\t\t var val = new Date(val);\n\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tif (val_type == \"int\") {\n\t\t\t\t\t\t\t\t\t\t\tvar val = parseFloat(val);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\t\t\t\tvar val = parseInt(val);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn val;\n\t\t}\n\n\t}", "title": "" }, { "docid": "f75069d390cd8e42ad79281ceb56963a", "score": "0.6217384", "text": "static DEFAULT_SORT_BY_FIELD(){ return \"title\"}", "title": "" }, { "docid": "84e60ed57ba3ffb2badd0e50c549f618", "score": "0.6159654", "text": "function sortData(data) {\n // For precaution, sort the object by date\n /*\n data.sort(function(a, b){\n\t \treturn new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()\n\t });\n */\n\n \tinitFields();\n\n \treturn data;\n}", "title": "" }, { "docid": "bc735d6fc006f154cb9c1763c48f67eb", "score": "0.6148963", "text": "sortBy(field, dir = null){\n this.sortField = field;\n this.sortDir = dir;\n \n switch(field){\n \n case 'cr':\n this._data.sort((a, b) => ((a._cr > b._cr) ? 1 : -1) * dir);\n break;\n \n case 'ac':\n this._data.sort((a, b) => ((parseInt(a.armorClass) > parseInt(b.armorClass)) ? 1 : -1) * dir);\n break;\n \n case 'hp':\n this._data.sort((a, b) => ((a.hitPoints.average > b.hitPoints.average) ? 1 : -1) * dir);\n break;\n \n case 'race':\n this._data.sort((a, b) => ((a.race > b.race) ? 1 : -1) * dir);\n break;\n\n default: //name\n this._data.sort((a, b) => ((a.name > b.name) ? 1 : -1) * dir);\n break;\n }\n }", "title": "" }, { "docid": "39753a2f9edba347d1b24332fb0aa97b", "score": "0.61254364", "text": "function calculateOrder(store, object, before, orderField){\n // Calculates proper value of order for an item to be placed before another\n var afterOrder, beforeOrder = 0;\n if (!orderField) { orderField = \"order\"; }\n\n if(before){\n // calculate midpoint between two items' orders to fit this one\n afterOrder = before[orderField];\n store.query({}, {}).forEach(function(object){\n var ord = object[orderField];\n if(ord > beforeOrder && ord < afterOrder){\n beforeOrder = ord;\n }\n });\n return (afterOrder + beforeOrder) / 2;\n }else{\n // find maximum order and place this one after it\n afterOrder = 0;\n store.query({}, {}).forEach(function(object){\n var ord = object[orderField];\n if(ord > afterOrder){ afterOrder = ord; }\n });\n return afterOrder + 1;\n }\n }", "title": "" }, { "docid": "fa7969cdebee6302dc8b960eeb04f363", "score": "0.606206", "text": "function sort_by(field, reverse, primer) {\n var key = primer ?\n function (x) {\n return primer(x[field])\n } :\n function (x) {\n return x[field]\n };\n\n reverse = !reverse ? 1 : -1;\n\n return function (a, b) {\n return a = key(a), b = key(b), reverse * ((a > b) - (b > a));\n }\n}", "title": "" }, { "docid": "84df2b802d0e5a19a2b8e362aa27cc22", "score": "0.6015888", "text": "function obj_sort(a, b) {\n if (a.name < b.name) {\n return -1;\n } else if (a.name > b.name) {\n return 1;\n } else {\n return 0;\n };\n}", "title": "" }, { "docid": "19235a5a8cbf843081ec7330f6dfd17c", "score": "0.60021627", "text": "function objComparator(property, sortOrder) {\n sortOrder = sortOrder || 1;\n if(property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function (a,b) {\n var result;\n if (typeof a[property] === \"string\" && typeof b[property] === \"string\") {\n result = (a[property].toLowerCase() < b[property].toLowerCase()) ? -1 : (a[property].toLowerCase() > b[property].toLowerCase()) ? 1 : 0;\n }\n else {\n result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n }\n return result * sortOrder;\n }\n }", "title": "" }, { "docid": "3dbcf54cee8ede6578bc4215757b939d", "score": "0.5950521", "text": "sortByFieldDescending(fieldName){\n function compare(a, b){\n const valueA = a[fieldName];\n const valueB = b[fieldName];\n\n let comparison = 0;\n if(valueA != null && valueB != null){\n if(valueB > valueA){\n comparison = 1;\n }\n else if(valueB < valueA){\n comparison = -1;\n }\n }\n else if(valueA == null && valueB != null){\n comparison = 1;\n }\n else if(valueA != null && valueB == null){\n comparison = -1;\n }\n \n return comparison;\n }\n \n this.tableRows.sort(compare);\n\n //Needed to refresh the UI due to the reactivity of LWCs\n this.tableRows = [...this.tableRows];\n }", "title": "" }, { "docid": "b23012d4d3fd3fb4089b1bf49394d329", "score": "0.59272164", "text": "function fastSort(field, ascending) {\n var oldToString = Object.prototype.toString;\n Object.prototype.toString = (typeof field == 'function') ? field : function() { return this[field] };\n if (ascending === false) items.reverse();\n items.sort();\n Object.prototype.toString = oldToString;\n if (ascending === false) items.reverse();\n }", "title": "" }, { "docid": "31942d166e6a572d66c4ebf965019f47", "score": "0.591775", "text": "sortTableRows(){\n if(this._sortObject.sortDirection === 'ASC'){\n this.sortByFieldAscending(this._sortObject.sortField);\n return;\n }\n \n this.sortByFieldDescending(this._sortObject.sortField);\n }", "title": "" }, { "docid": "01fb2265e3a64117c42c6ab0d6437eeb", "score": "0.5905565", "text": "sortFieldName(fieldName) {\n return `${fieldName}.raw`;\n }", "title": "" }, { "docid": "50edf6fadc0e10443445e0e5409ccec5", "score": "0.590543", "text": "_sort(items, order) {\n if (typeof order === \"string\") {\n // order by provided field name\n const name = order; // field name\n items.sort((a, b) => {\n // @TODO: How to treat missing properties?\n const av = a[name];\n const bv = b[name];\n return av > bv ? 1 : av < bv ? -1 : 0;\n });\n }\n else if (typeof order === \"function\") {\n // order by sort function\n items.sort(order);\n }\n else {\n // TODO: extend order by an Object {field:string, direction:string}\n // where direction can be 'asc' or 'desc'\n throw new TypeError(\"Order must be a function or a string\");\n }\n }", "title": "" }, { "docid": "50edf6fadc0e10443445e0e5409ccec5", "score": "0.590543", "text": "_sort(items, order) {\n if (typeof order === \"string\") {\n // order by provided field name\n const name = order; // field name\n items.sort((a, b) => {\n // @TODO: How to treat missing properties?\n const av = a[name];\n const bv = b[name];\n return av > bv ? 1 : av < bv ? -1 : 0;\n });\n }\n else if (typeof order === \"function\") {\n // order by sort function\n items.sort(order);\n }\n else {\n // TODO: extend order by an Object {field:string, direction:string}\n // where direction can be 'asc' or 'desc'\n throw new TypeError(\"Order must be a function or a string\");\n }\n }", "title": "" }, { "docid": "08080740e1d7b971c72ceb168c30048c", "score": "0.5898378", "text": "sortBy(field, reverse, primer) {\n const key = primer\n ? function (x) {\n return primer(x[field]);\n }\n : function (x) {\n return x[field];\n };\n\n return function (a, b) {\n a = key(a);\n b = key(b);\n return reverse * ((a > b) - (b > a));\n };\n }", "title": "" }, { "docid": "5a6e375023f31ed025de8c55e4ffd275", "score": "0.5891989", "text": "function SortByID(x, y) {\n return x.id - y.id;\n}", "title": "" }, { "docid": "c11bbbe9b93618e5678a0d3912d56e73", "score": "0.58872646", "text": "_keyFieldComparator(i) {\n const invert = !this._sortSpecParts[i].ascending;\n return (key1, key2) => {\n const compare = LocalCollection._f._cmp(key1[i], key2[i]);\n\n return invert ? -compare : compare;\n };\n }", "title": "" }, { "docid": "a5bcdf3cbd64f8f12c9c03faeb3d366b", "score": "0.58797973", "text": "function sort(){\n\t\t\t\t var sortOrder = Object.keys(newStructure);\n\t\t\t\t return function(a,b){ return d3.ascending(sortOrder.indexOf(a),sortOrder.indexOf(b)) }\n\t\t\t\t}", "title": "" }, { "docid": "75312629c29a97eac11dbc11edb21c20", "score": "0.58723027", "text": "function sortObjectArray(array, type) {\r\nreturn array.sort(function(a, b) {\r\n if(type==\"libraryID\"){\r\n return parseInt(a.libraryID) - parseInt(b.libraryID);\r\n } else if (type == \"author\") {\r\n return a.author - b.author;\r\n } else {\r\n return a.title - b.title;\r\n }\r\n\r\n});\r\n}", "title": "" }, { "docid": "7d53bf3bd10e8f9d33329c360bbdcaee", "score": "0.58518106", "text": "function sortOld(obj) {\n $('.main-article').remove(); // remove articles and add sorted by date\n obj.sort(function(a, b) {\n a = new Date(a.pub_date);\n b = new Date(b.pub_date);\n return b > a ? -1 : b < a ? 1 : 0;\n });\n objloop(obj);\n }", "title": "" }, { "docid": "0d75f491d9f93c108a58ea09a5ba9750", "score": "0.58479834", "text": "sortItems(a, b) {\n if (this.state.ordering === Order.ASC) {\n if (a[this.state.sort_field] < b[this.state.sort_field]) return -1;\n } else if (this.state.ordering === Order.DESC) {\n if (!(a[this.state.sort_field] < b[this.state.sort_field])) return -1;\n } else {\n return a.id - b.id;\n }\n }", "title": "" }, { "docid": "cda5ca8dceb88d0dc5f60cc99fe347ce", "score": "0.5817494", "text": "function sortFieldsByIndex(userFields, index) {\n var indexFields = index.def.fields.map(getKey);\n\n return userFields.slice().sort(function (a, b) {\n var aIdx = indexFields.indexOf(a);\n var bIdx = indexFields.indexOf(b);\n if (aIdx === -1) {\n aIdx = Number.MAX_VALUE;\n }\n if (bIdx === -1) {\n bIdx = Number.MAX_VALUE;\n }\n return compare(aIdx, bIdx);\n });\n}", "title": "" }, { "docid": "102b795894794a719242e0060a22565b", "score": "0.5812477", "text": "function compareByField(fieldName) {\n // Return a compare function for array's sort() method.\n // Compare the values in the specified field on the array elements.\n return function (a, b) {\n if (a[fieldName] < b[fieldName]) {\n return -1;\n }\n if (a[fieldName] > b[fieldName]) {\n return 1;\n }\n // a must be equal to b\n return 0;\n }\n }", "title": "" }, { "docid": "1f7612740f67490454cc4d63c5cba1a5", "score": "0.5796191", "text": "function sortFieldsByIndex(userFields, index) {\n var indexFields = index.def.fields.map(getKey);\n\n return userFields.slice().sort(function (a, b) {\n var aIdx = indexFields.indexOf(a);\n var bIdx = indexFields.indexOf(b);\n if (aIdx === -1) {\n aIdx = Number.MAX_VALUE;\n }\n if (bIdx === -1) {\n bIdx = Number.MAX_VALUE;\n }\n return utils.compare(aIdx, bIdx);\n });\n}", "title": "" }, { "docid": "65dffb5acfcfcb360635a08e1896cc94", "score": "0.57878166", "text": "sortContacts() {\n let i = this.state.order; //if true, the order is ascending otherwise descending\n function compare(a, b) {\n const A = a.name.toUpperCase();\n const B = b.name.toUpperCase();\n\n let comparison = 0;\n if (i) {\n if (A > B) {\n comparison = 1;\n } else if (A < B) {\n comparison = -1;\n }\n } else {\n if (A > B) {\n comparison = -1;\n } else if (A < B) {\n comparison = 1;\n }\n }\n return comparison;\n }\n this.state.contacts.sort(compare);\n }", "title": "" }, { "docid": "829766a4aee9895a612aff94b904baf8", "score": "0.5786554", "text": "function sortArrayWithObjects(property) {\n let sortOrder = 1;\n if (property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return (a, b) => {\n return ((a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0) * sortOrder;\n }\n}", "title": "" }, { "docid": "3ec6c0c419d5061c7c11d2643664360d", "score": "0.57775456", "text": "static DEFAULT_SORT_BY_FIELD(){ return \"username\"}", "title": "" }, { "docid": "e7601f121947fb6940117bc965d92ce0", "score": "0.57728624", "text": "getSortedData(order) {\n if (this.props.posts) {\n if (order === 'asc') {\n return this.props.posts.sort((a, b) => {\n return a.pricePerMonth - b.pricePerMonth\n })\n } else {\n return this.props.posts.sort((a, b) => {\n return b.pricePerMonth - a.pricePerMonth\n })\n }\n }\n }", "title": "" }, { "docid": "146831a949ff3436eb13ccdd015da973", "score": "0.57705045", "text": "function sortNew(obj) {\n $('.main-article').remove(); // remove articles and add sorted by date\n obj.sort(function(a, b) {\n a = new Date(a.pub_date);\n b = new Date(b.pub_date);\n return a > b ? -1 : a < b ? 1 : 0;\n });\n objloop(obj);\n }", "title": "" }, { "docid": "deb1af22e7c48d6c1c0a6766429f1bd1", "score": "0.5756937", "text": "function dynamicSort(property) \n{\n var sortOrder = 1;\n if(property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function (a,b) {\n var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n return result * sortOrder;\n }\n}", "title": "" }, { "docid": "1aa9eef0c9a36eaa609ae3cc8137f2da", "score": "0.57558316", "text": "function getOrderBy() {\n var result = \"\";\n for (var property in $scope.sort) {\n if ($scope.sort.hasOwnProperty(property)) {\n if ($scope.sort[property].enabled) {\n result = ($scope.sort[property].ascending ? \"\" : \"-\") + $scope.sort[property].property;\n }\n }\n }\n return result;\n }", "title": "" }, { "docid": "61eb194dfaf388f7ef9d31140d04aca2", "score": "0.57535845", "text": "function sortBy(obj, iteratee, context) {\n var index = 0;\n iteratee = cb(iteratee, context);\n return pluck(\n map(obj, function (value, key, list) {\n return {\n value: value,\n index: index++,\n criteria: iteratee(value, key, list),\n };\n }).sort(function (left, right) {\n var a = left.criteria;\n var b = right.criteria;\n if (a !== b) {\n if (a > b || a === void 0) return 1;\n if (a < b || b === void 0) return -1;\n }\n return left.index - right.index;\n }),\n \"value\"\n );\n }", "title": "" }, { "docid": "91e71ba2a4e52978946b3c55200f0224", "score": "0.5747471", "text": "function sortAscending (a, b) {\n\t\t\t\treturn a.id - b.id;\n\t\t\t}", "title": "" }, { "docid": "632187183dc07601121f34a5141c1b96", "score": "0.5744895", "text": "sort(fieldValue, orderText) {\n const column = this.headerData.find(item => item.id === fieldValue)\n const {sortType, customSorting} = column\n const direction = orderText === 'asc' ? 1 : -1\n\n this.data.sort((a, b) => {\n switch (sortType) {\n case 'number':\n return direction * (a[fieldValue] - b[fieldValue])\n case 'string':\n return compareStrings(a[fieldValue], b[fieldValue], orderText)\n case 'custom':\n //customSorting - это как я понял, на будущее сделано, ок\n return direction * customSorting(a, b)\n default:\n return direction * (a[fieldValue] - b[fieldValue])\n }\n })\n \n this.getBodyFromDataWrap()\n }", "title": "" }, { "docid": "bd10ae9fb71e4c8b7a5fc8aeb0a9f76d", "score": "0.57427037", "text": "function sort () {\n debug('sort: %o', store)\n\n store.tags = store.tags.sort(function (obj1, obj2) {\n return obj1.name.toLowerCase().localeCompare(obj2.name.toLowerCase())\n })\n }", "title": "" }, { "docid": "e567b0d68cdac90e6e9d6eb4833d358f", "score": "0.5731119", "text": "_typeorder(t) {\n // http://www.mongodb.org/display/DOCS/What+is+the+Compare+Order+for+BSON+Types\n // XXX what is the correct sort position for Javascript code?\n // ('100' in the matrix below)\n // XXX minkey/maxkey\n return [-1, // (not a type)\n 1, // number\n 2, // string\n 3, // object\n 4, // array\n 5, // binary\n -1, // deprecated\n 6, // ObjectID\n 7, // bool\n 8, // Date\n 0, // null\n 9, // RegExp\n -1, // deprecated\n 100, // JS code\n 2, // deprecated (symbol)\n 100, // JS code\n 1, // 32-bit int\n 8, // Mongo timestamp\n 1 // 64-bit int\n ][t];\n }", "title": "" }, { "docid": "93b892a8c6c9f65865390ad504a684ca", "score": "0.5730416", "text": "static get(query, fields) {\n return this.find(query, fields).sort({ createdAt: -1 });\n }", "title": "" }, { "docid": "c76ab327cb57f4e1c2da5c6818b29468", "score": "0.5717243", "text": "function createFieldSorter(sort) {\n\n function getFieldValuesAsArray(doc) {\n return sort.map(function (sorting) {\n var fieldName = getKey(sorting);\n var parsedField = parseField(fieldName);\n var docFieldValue = getFieldFromDoc(doc, parsedField);\n return docFieldValue;\n });\n }\n\n return function (aRow, bRow) {\n var aFieldValues = getFieldValuesAsArray(aRow.doc);\n var bFieldValues = getFieldValuesAsArray(bRow.doc);\n var collation = collate(aFieldValues, bFieldValues);\n if (collation !== 0) {\n return collation;\n }\n // this is what mango seems to do\n return compare$1(aRow.doc._id, bRow.doc._id);\n };\n}", "title": "" }, { "docid": "c76ab327cb57f4e1c2da5c6818b29468", "score": "0.5717243", "text": "function createFieldSorter(sort) {\n\n function getFieldValuesAsArray(doc) {\n return sort.map(function (sorting) {\n var fieldName = getKey(sorting);\n var parsedField = parseField(fieldName);\n var docFieldValue = getFieldFromDoc(doc, parsedField);\n return docFieldValue;\n });\n }\n\n return function (aRow, bRow) {\n var aFieldValues = getFieldValuesAsArray(aRow.doc);\n var bFieldValues = getFieldValuesAsArray(bRow.doc);\n var collation = collate(aFieldValues, bFieldValues);\n if (collation !== 0) {\n return collation;\n }\n // this is what mango seems to do\n return compare$1(aRow.doc._id, bRow.doc._id);\n };\n}", "title": "" }, { "docid": "be547eadb1a6189cdfd0918f5d5a711a", "score": "0.57144576", "text": "orderby(){\n let data=this.state.ourData;\n data=_.sortBy(data,['name', 'id'])\n this.setState({ourData:data})\n }", "title": "" }, { "docid": "70f54ddb53d3719cbb59daa2cef01d5b", "score": "0.57130015", "text": "sortInputProps() {\n return {\n sort:this.orderBy ? this.orderBy.field : null,\n sortOrder:this.orderBy ? this.orderBy.dir : OrderBy.ASC,\n options:this.sortSelectOptions,\n }\n }", "title": "" }, { "docid": "090db2c7e6fa9e71ef33ec71095116b4", "score": "0.57000077", "text": "function createFieldSorter(sort) {\n\n function getFieldValuesAsArray(doc) {\n return sort.map(function (sorting) {\n var fieldName = getKey(sorting);\n var parsedField = parseField(fieldName);\n var docFieldValue = getFieldFromDoc(doc, parsedField);\n return docFieldValue;\n });\n }\n\n return function (aRow, bRow) {\n var aFieldValues = getFieldValuesAsArray(aRow.doc);\n var bFieldValues = getFieldValuesAsArray(bRow.doc);\n var collation = collate(aFieldValues, bFieldValues);\n if (collation !== 0) {\n return collation;\n }\n // this is what mango seems to do\n return compare(aRow.doc._id, bRow.doc._id);\n };\n}", "title": "" }, { "docid": "9df70d610cfe0716b5b575d66e83bc9a", "score": "0.56882036", "text": "function createFieldSorter(sort) {\n\n function getFieldValuesAsArray(doc) {\n return sort.map(function (sorting) {\n var fieldName = getKey(sorting);\n var parsedField = parseField(fieldName);\n var docFieldValue = getFieldFromDoc(doc, parsedField);\n return docFieldValue;\n });\n }\n\n return function (aRow, bRow) {\n var aFieldValues = getFieldValuesAsArray(aRow.doc);\n var bFieldValues = getFieldValuesAsArray(bRow.doc);\n var collation = collate(aFieldValues, bFieldValues);\n if (collation !== 0) {\n return collation;\n }\n // this is what mango seems to do\n return utils.compare(aRow.doc._id, bRow.doc._id);\n };\n}", "title": "" }, { "docid": "910370179fdb5a7409922076bc2c892f", "score": "0.5686382", "text": "function orderBy(property) {\n var sortOrder = 1; //Ascending\n if (property[0] === \"-\") {\n sortOrder = -1; //Descending\n property = property.substr(1);\n }\n return function(a, b) {\n var result = 0;\n if (a[property] < b[property]) {\n result = -1; //first is small\n } else if (a[property] > b[property]) {\n result = 1; //second is small\n } else {\n result = 0; //both are equal\n }\n return result * sortOrder;\n }\n}", "title": "" }, { "docid": "0a1ba154b08aa08241bdf9364d03c23f", "score": "0.56788266", "text": "function order_facets() {\n data.facets = _.sortBy(data.facets, function(facet){\n return _.indexOf(search_config.facetfields, facet.id);\n });\n }", "title": "" }, { "docid": "d7dcd451dd70ed0b6aaa2c22bea323a9", "score": "0.5677886", "text": "function momentSort (field: string, ascending: boolean = true) {\n return (a, b) => {\n const aVal = get(a, field)\n const bVal = get(b, field)\n if (!aVal && !bVal) return 0\n if (!bVal) return -1\n if (!aVal) return 1\n const aMoment = moment(aVal)\n const bMoment = moment(bVal)\n if (!aMoment.isValid() && !bMoment.isValid()) return 0\n if (!bMoment.isValid()) return -1\n if (!aMoment.isValid()) return 1\n return ascending\n ? aMoment.unix() - bMoment.unix()\n : bMoment.unix() - aMoment.unix()\n }\n}", "title": "" }, { "docid": "a2d767873c8ad1516cfa30b9e4573c02", "score": "0.56754035", "text": "sortMap() {\n const map = {};\n\n if (this.params.q) {\n map.relevance = '';\n }\n map.latest = '-lastPostedAt';\n map.top = '-commentCount';\n map.newest = '-createdAt';\n map.oldest = 'createdAt';\n\n return map;\n }", "title": "" }, { "docid": "2de15ae57d7817ab76903abff9dd4dff", "score": "0.5672204", "text": "sortField(movies){\n var textA = ''\n var textB = ''\n movies.sort(function(a, b) {\n if( localStorage.field === 'movie_rating'){\n textA = a[localStorage.field]\n textB = b[localStorage.field]\n }\n else if( localStorage.field === 'movie_duration'){\n textA = a[localStorage.field]\n textB = b[localStorage.field]\n }\n else if( localStorage.field === 'movie_release_date'){\n textA = new Date(a.movie_release_date);\n textB = new Date(b.movie_release_date);\n console.log(textA)\n console.log(textB)\n console.log(localStorage.order )\n }\n else{\n textA = a[localStorage.field].toUpperCase();\n textB = b[localStorage.field].toUpperCase();\n }\n\n if (localStorage.order === 'asc'){\n return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;\n }\n else{\n return (textA > textB) ? -1 : (textA < textB) ? 1 : 0;\n }\n });\n return movies\n }", "title": "" }, { "docid": "9e1839e2bdbd35e97fbb2a1b17ed1823", "score": "0.566729", "text": "function dynamicSort(property) { // Thanks Wogan @ https://stackoverflow.com/questions/1129216/sort-array-of-objects-by-string-property-value\n var sortOrder = 1;\n\n if(property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n\n return function (a, b) {\n\n var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n return result * sortOrder;\n }\n}", "title": "" }, { "docid": "f12a0782c41e336ad7d4019a7eb3001b", "score": "0.56662416", "text": "function orderBy(arr, props, order) {}", "title": "" }, { "docid": "0bfa4586f944966fa749b5166940fdca", "score": "0.5653867", "text": "function ratingOrderBy() {\n if (vm.isPublic) {\n return '-combined_rating';\n }\n\n return '-rating';\n }", "title": "" }, { "docid": "597179aa64eae350eb06c43383326a7d", "score": "0.56447357", "text": "function dynamicSort(property) {\n var sortOrder = 1;\n if(property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function (a,b) {\n var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n return result * sortOrder;\n }\n}", "title": "" }, { "docid": "597179aa64eae350eb06c43383326a7d", "score": "0.56447357", "text": "function dynamicSort(property) {\n var sortOrder = 1;\n if(property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function (a,b) {\n var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n return result * sortOrder;\n }\n}", "title": "" }, { "docid": "b379dc9fc617a850abb13e8ca03e2a07", "score": "0.563731", "text": "function sortByName(a,b){\n var aName = a.id;\n var bName = b.id;\n \n if(aName < bName){\n return -1;\n }\n \n if(aName > bName){\n return 1; \n \n }else{\n return 0; \n }\n }", "title": "" }, { "docid": "63187ff04e516ffd2a76e294116a634f", "score": "0.5628225", "text": "function dynamicSort(property) {\n var sortOrder = 1;\n if (property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function(a, b) {\n var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n return result * sortOrder;\n }\n }", "title": "" }, { "docid": "c5a13c360a4c1529d3d6802b83e74121", "score": "0.562704", "text": "function core_sort_property(args){\n return core_sort_custom({\n 'array': args['array'],\n 'reverse': args['reverse'],\n 'todo': function(a, b){\n if(a[args['property']] > b[args['property']]){\n return 1;\n\n }else if(a[args['property']] < b[args['property']]){\n return -1;\n }\n\n return 0;\n },\n });\n}", "title": "" }, { "docid": "8a057e4c814bc0f71c48b3438eff717f", "score": "0.56243914", "text": "function dynamicSort(property) {\n var sortOrder = 1;\n if (property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function(a, b) {\n var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n return result * sortOrder;\n }\n}", "title": "" }, { "docid": "76fcd4570a4da54b23f13c98c99b4321", "score": "0.5623085", "text": "get arrangedContent() {\n let sortProperties = this.sortProperties.map(p => {\n let [prop, direction] = p.split(':');\n direction = direction || _sortConstants.default.ASC;\n return [prop, direction];\n });\n\n let _filteredContent = this.filteredContent.slice();\n\n return sortProperties.length ? _filteredContent.sort((row1, row2) => {\n for (let i = 0; i < sortProperties.length; i++) {\n let [prop, direction] = sortProperties[i];\n\n let sortFunction = Ember.get(this, `sortFunctions.${prop}`) || _betterCompare.default;\n\n let result = prop ? sortFunction(Ember.get(row1, prop), Ember.get(row2, prop), direction) : 0;\n\n if (result !== 0) {\n return direction === _sortConstants.default.DESC ? -1 * result : result;\n }\n }\n\n return 0;\n }) : _filteredContent;\n }", "title": "" }, { "docid": "78b8e2b54a9bd487f2b8811da46745db", "score": "0.5622324", "text": "function sortBy(obj, iteratee, context) {\n var index = 0;\n iteratee = cb(iteratee, context);\n return pluck(map(obj, function(value, key, list) {\n return {\n value: value,\n index: index++,\n criteria: iteratee(value, key, list)\n };\n }).sort(function(left, right) {\n var a = left.criteria;\n var b = right.criteria;\n if (a !== b) {\n if (a > b || a === void 0) return 1;\n if (a < b || b === void 0) return -1;\n }\n return left.index - right.index;\n }), 'value');\n }", "title": "" }, { "docid": "80d35b0a77871fc41a53e8be6fe61de8", "score": "0.5620118", "text": "orderby(value) {\n doStringGetterSetter(this, \"orderBy\", value);\n return this;\n }", "title": "" }, { "docid": "5c65655bfaa26ce1613c1a83fe3718cd", "score": "0.56187105", "text": "function sortById(a, b) {\n return a.id - b.id;\n }", "title": "" }, { "docid": "1e2cf99e6f0b35a91953d8f31e2c61a6", "score": "0.5613723", "text": "function dynamicSort(property) {\n var sortOrder = 1;\n if(property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function (a,b) {\n var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n return result * sortOrder;\n }\n }", "title": "" }, { "docid": "5e5061a14ae1264c44723150b847a3f5", "score": "0.5609486", "text": "function dynamicSort(property) {\n \t\t\tvar sortOrder = 1;\n \t\t\tif(property[0] === \"-\") {\n \t\t\t\t sortOrder = -1;\n \t\t\t\t property = property.substr(1);\n \t\t\t}\n \t\t\treturn function (a,b) {\n \t\t \t\tvar result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;\n \t\t \t\treturn result * sortOrder;\n \t\t\t}\n\t\t}", "title": "" }, { "docid": "bdfd54fd72549a873e3e1d0391ab919a", "score": "0.5608239", "text": "function sortBy(obj, iteratee, context) {\n var index = 0;\n iteratee = cb(iteratee, context);\n return pluck(map(obj, function (value, key, list) {\n return {\n value: value,\n index: index++,\n criteria: iteratee(value, key, list)\n };\n }).sort(function (left, right) {\n var a = left.criteria;\n var b = right.criteria;\n if (a !== b) {\n if (a > b || a === void 0)\n return 1;\n if (a < b || b === void 0)\n return -1;\n }\n return left.index - right.index;\n }), \"value\");\n }", "title": "" }, { "docid": "db5a936059b18c869b7afa65949536ea", "score": "0.5599902", "text": "function sortById(a, b) {\n return a.id - b.id;\n }", "title": "" }, { "docid": "654fc1caad7dc9f187cf52435f568069", "score": "0.5598563", "text": "function GetSortOrder(prop) {\n \t// es para ordenar un array de json con (id_partida)\n \treturn function (a, b) {\n \t\tif (a[prop] > b[prop]) {\n \t\t\treturn 1;\n \t\t} else if (a[prop] < b[prop]) {\n \t\t\treturn -1;\n \t\t}\n\n \t\treturn 0;\n \t};\n }", "title": "" }, { "docid": "07e3e98fbf78bf354cc8f3e58b39cb16", "score": "0.5595407", "text": "getSortedData(data) {\n if (!this.sort.active || this.sort.direction === '') {\n return data;\n }\n return data.sort((a, b) => {\n const isAsc = this.sort.direction === 'asc';\n switch (this.sort.active) {\n case 'name': return compare(a.name, b.name, isAsc);\n case 'color': return compare(a.color, b.color, isAsc);\n case 'species': return compare(a.species, b.species, isAsc);\n case 'id': return compare(+a.id, +b.id, isAsc);\n default: return 0;\n }\n });\n }", "title": "" }, { "docid": "f98b757edc02fa3e271427ace4421776", "score": "0.5592238", "text": "function collectionSort(a, b) {\n if (a.created < b.created) {\n return -1;\n }\n if (a.created > b.created) {\n return 1;\n }\n return 0;\n}", "title": "" }, { "docid": "2ce8edc4f27d2f4c1d93d8294a6642a6", "score": "0.55870885", "text": "function SortByName(a, b) {\r\n var aName = a.Issue.toLowerCase();\r\n var bName = b.Issue.toLowerCase();\r\n return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));\r\n\r\n\r\n }", "title": "" }, { "docid": "1cee5b94b102686983115c94b3b745d6", "score": "0.55825096", "text": "sortObject(obj) {\n let sortable = [];\n for(let o in obj) {\n sortable.push([o, obj[o]]);\n }\n sortable.sort(function(a, b) {\n return b[1] - a[1];\n });\n return sortable; // Returns array of 2-tuple arrays [[c1, 2], [c2, 1], ... etc.]\n }", "title": "" }, { "docid": "ddcb0105460005c13ac31053c9c05f11", "score": "0.558101", "text": "function sortByName(a, b)\n{\n return (b.properties.name.toLowerCase() > a.properties.name.toLowerCase() ? -1 : 1);\n}", "title": "" }, { "docid": "f8df43c77ece907bfc5f11ae55a354b5", "score": "0.5572612", "text": "function sort() {\n\t\tvar poll_id = $('#poll_id').val();\n\t\tvar options = $('input[name^=\"options\"]');\n\t\tvar obj = new Object();\n\n\t\t// Loop through all our poll optoins\n\t\t$(options).each(function(i) {\n\t\t\tvar id = $(options).eq(i).attr('name');\n\t\t\tid = id.replace('options[', '');\n\t\t\tid = id.replace('][title]', '');\n\n\t\t\t// Add sort order to our object \"obj\"\n\t\t\tobj[id] = i;\n\n\t\t});\n\n\t\t// POST our sort order\n\t\t$.post(BASE_URL + 'admin/polls/ajax_update_order/' + poll_id, obj, function(data) {\n\t\t\t// It worked!!! (probably)\n\t\t});\n\t}", "title": "" }, { "docid": "355b6d4dd18d72ae0834af3b8a904f88", "score": "0.5568717", "text": "sortBy(field, reverse, primer) {\n\tconst key = primer\n\t\t? function (x) {\n\t\t\treturn primer(x[field]);\n\t\t}\n\t\t: function (x) {\n\t\t\treturn x[field];\n\t\t};\n\n\t\treturn function (a, b) {\n\t\t\ta = key(a);\n\t\t\tb = key(b);\n\t\t\treturn reverse * ((a > b) - (b > a));\n\t\t};\n\t}", "title": "" }, { "docid": "485a9ae29056978529316289e6b6212a", "score": "0.55599636", "text": "function SortByName(a, b){\n var aName = a.nom.toLowerCase();\n var bName = b.nom.toLowerCase(); \n return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));\n}", "title": "" }, { "docid": "67d94fa1d5e692e29b8281f9c17b2a88", "score": "0.55584496", "text": "sortObject(obj) {\n return Object.keys(obj).sort().reduce(function (result, key) {\n result[key] = obj[key];\n return result;\n }, {});\n }", "title": "" }, { "docid": "5709d8713b31e2aefe7af64274342eb0", "score": "0.5554385", "text": "function sortParams(orderDef, fieldRefOption) {\n return (vega_util_1.isArray(orderDef) ? orderDef : [orderDef]).reduce(function (s, orderChannelDef) {\n s.field.push(fielddef_1.vgField(orderChannelDef, fieldRefOption));\n s.order.push(orderChannelDef.sort || 'ascending');\n return s;\n }, { field: [], order: [] });\n}", "title": "" }, { "docid": "5be4f394c37ee0967e4537d81f641df8", "score": "0.55487955", "text": "function SortObjectByDistanceAsc(objectArray) {\n if (objectArray && objectArray.length > 1) {\n\n var swap = false;\n do {\n swap = false;\n\n for (var i = 1; i < objectArray.length; i++) {\n var curr = objectArray[i];\n var prev = objectArray[i - 1];\n\n var currDistance = Orion.GetDistance(curr.Serial());\n var prevDistance = Orion.GetDistance(prev.Serial());\n\n if (currDistance < prevDistance) {\n\n objectArray[i - 1] = curr;\n objectArray[i] = prev;\n swap = true;\n }\n }\n } while (swap)\n\n }\n\n\n return objectArray;\n}", "title": "" }, { "docid": "2ed7ab62aa598aba32eccf23c9b16769", "score": "0.55413973", "text": "function dynamicSort(property) {\n const sortOrder = 1;\n if (property[0] === \"-\") {\n sortOrder = -1;\n property = property.substr(1);\n }\n return function (a, b) {\n const result =\n a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;\n return result * sortOrder;\n };\n }", "title": "" }, { "docid": "00171b41d70435d5db67b6d2ce1644d2", "score": "0.55384004", "text": "function sortFields() {\n\n /*sort by the order number*/\n $('.number-sort').click(function() {\n var orderList = sortList;\n if ($(this).hasClass('asc')) {\n $(this).removeClass('asc');\n orderList.sort(function(a, b) {\n var temp = (a.number).replace('#', '');\n var temp1 = (b.number).replace('#', '');\n return temp1 - temp;\n });\n display(orderList);\n } else {\n $(this).addClass('asc');\n orderList.sort(function(a, b) {\n var temp = (a.number).replace('#', '');\n var temp1 = (b.number).replace('#', '');\n return temp - temp1;\n });\n display(orderList);\n }\n });\n\n /*sort by the description*/\n $('.desc-sort').click(function() {\n var orderList = sortList;\n if ($(this).hasClass('asc')) {\n $(this).removeClass('asc');\n orderList.sort(function(a, b) {\n if (a.description > b.description) {\n return -1;\n }\n return 0;\n });\n display(orderList);\n } else {\n $(this).addClass('asc');\n orderList.sort(function(a, b) {\n if (b.description > a.description) {\n return -1;\n }\n return 0;\n });\n display(orderList);\n }\n });\n\n /*sort by date */\n $('.dd-sort').click(function() {\n var orderList = sortList;\n if ($(this).hasClass('asc')) {\n $(this).removeClass('asc');\n orderList.sort(function(a, b) {\n var temp = new Date(a.date);\n var temp1 = new Date(b.date);\n return temp1 - temp;\n });\n display(orderList);\n } else {\n $(this).addClass('asc');\n orderList.sort(function(a, b) {\n var temp = new Date(a.date);\n var temp1 = new Date(b.date);\n return temp - temp1;\n });\n display(orderList);\n }\n });\n\n /*sort by price*/\n $('.tp-sort').click(function() {\n var orderList = sortList;\n if ($(this).hasClass('asc')) {\n $(this).removeClass('asc');\n orderList.sort(function(a, b) {\n var temp = (a.price).replace('$', '');\n var temp1 = (b.price).replace('$', '');\n return temp1 - temp;\n });\n display(orderList);\n } else {\n $(this).addClass('asc');\n orderList.sort(function(a, b) {\n var temp = (a.price).replace('$', '');\n var temp1 = (b.price).replace('$', '');\n return temp - temp1;\n });\n display(orderList);\n }\n });\n\n }", "title": "" }, { "docid": "13c6fc4e40a1ea3cfcc68e32d3d40600", "score": "0.5536997", "text": "getOrderBy() {\n\t \treturn this.orderBy;\n\t }", "title": "" }, { "docid": "ce70b25f0863027cef55db72687570ae", "score": "0.55368745", "text": "getStandardOrder() {\n return [ ['name', 'ASC'] ];\n }", "title": "" }, { "docid": "e236a9ad9886ae9f5797a93f6a1f5f22", "score": "0.5536607", "text": "getSortedData(data) {\n if (!this.sort || !this.sort.active || this.sort.direction === '') {\n return data;\n }\n return data.sort((a, b) => {\n var _a, _b;\n const isAsc = ((_a = this.sort) === null || _a === void 0 ? void 0 : _a.direction) === 'asc';\n switch ((_b = this.sort) === null || _b === void 0 ? void 0 : _b.active) {\n case 'firstname': return compare(a.firstname, b.firstname, isAsc);\n case 'lastname': return compare(a.lastname, b.lastname, isAsc);\n case 'phone': return compare(+a.phone, +b.phone, isAsc);\n default: return 0;\n }\n });\n }", "title": "" }, { "docid": "d9080189b1f7d248b390b4e5abbdfc91", "score": "0.55302227", "text": "sortByPopularity(object) {\n function compare(a, b) {\n if (a.popularity > b.popularity) return -1;\n if (a.popularity < b.popularity) return 1;\n return 0;\n }\n\n // sort it\n object.sort(compare);\n\n // new state to refresh\n this.setState({ contactArray: object });\n }", "title": "" }, { "docid": "b87e9ea9bf415a645a178d53f4732a9b", "score": "0.55274713", "text": "orderBy(orderBy, ascending = true) {\n const o = \"$orderby\";\n const query = this.query.has(o) ? this.query.get(o).split(\",\") : [];\n query.push(`${encodeURIComponent(orderBy)} ${ascending ? \"asc\" : \"desc\"}`);\n this.query.set(o, query.join(\",\"));\n return this;\n }", "title": "" }, { "docid": "b87e9ea9bf415a645a178d53f4732a9b", "score": "0.55274713", "text": "orderBy(orderBy, ascending = true) {\n const o = \"$orderby\";\n const query = this.query.has(o) ? this.query.get(o).split(\",\") : [];\n query.push(`${encodeURIComponent(orderBy)} ${ascending ? \"asc\" : \"desc\"}`);\n this.query.set(o, query.join(\",\"));\n return this;\n }", "title": "" }, { "docid": "7fdcc2a28254160c054a3c9fc2ba84a5", "score": "0.5526922", "text": "function sortObject(obj, order) {\n var key,\n i,\n tempArray = [],\n tempObj = {};\n\n for (key in obj) {\n tempArray.push(key);\n }\n\n tempArray.sort(function (a, b) {\n return a.toLowerCase().localeCompare(b.toLowerCase());\n });\n\n if (order === 'desc') {\n for (i = tempArray.length - 1; i >= 0; i--) {\n tempObj[tempArray[i]] = obj[tempArray[i]];\n }\n } else {\n for (i = 0; i < tempArray.length; i++) {\n tempObj[tempArray[i]] = obj[tempArray[i]];\n }\n }\n return tempObj;\n }", "title": "" }, { "docid": "75f73e17bb70f721a503d7e94a0c1082", "score": "0.55259025", "text": "function valueSort(obj1,obj2){\n\t\t\tif (obj1.metric < obj2.metric) return -1;\n\t\t\telse if (obj1.metric == obj2.metric) return 0;\n\t\t\telse return 1;\n\t\t}", "title": "" } ]
3794600eb30cb4a9878cfac6076d3f12
Click on goal to fill it
[ { "docid": "f09aecb7b98cfb5e91de5a8137d02f4f", "score": "0.0", "text": "function changecss(id)\n{\n\n const bgColor = \"rgb(218, 32, 182)\";\n\n if (document.getElementById(id).style.backgroundColor) \n {\n document.getElementById(id).style.backgroundColor = \"\"; \n \n } \n else \n {\n document.getElementById(id).style.backgroundColor = bgColor;\n \n }\n\n // Saves coloured squares\n if (typeof(Storage) !== \"undefined\") \n {\n localStorage.setItem(id, document.getElementById(id).style.backgroundColor);\n } \n else \n {\n }\n\n checklines();\n \n}", "title": "" } ]
[ { "docid": "586bd135f9054e1ebb9a8f80e88e169e", "score": "0.6185245", "text": "set goal(goal) {\n let min = 0;\n let max = pastels.length;\n let randomIndex = Math.floor(Math.random() * (max - min) + min);\n this.shadowRoot.querySelector('.plan').style.backgroundColor = pastels[randomIndex];\n this.shadowRoot.querySelector('.plan-label').innerText = goal.title;\n this.shadowRoot.querySelector('.plan-content').innerText = goal.content;\n\n }", "title": "" }, { "docid": "2bc7280a11cde1f1f1ece5337e6113ed", "score": "0.60478765", "text": "function oneClicked() {\n choice = 1;\n findEmptyPosition();\n}", "title": "" }, { "docid": "36ed04b3044786b845df21d8b9284744", "score": "0.6025593", "text": "function drawGoal(x, y, size, alpha){\r\n\tvar blue = color(\"blue\");\r\n\tblue.setAlpha(alpha);\r\n\r\n\tfill(blue);\r\n circle(x+size/2, y+size/2, size*5/6);\r\n erase();\r\n circle(x+size/2, y+size/2, size*7/12);\r\n noErase();\r\n fill(blue);\r\n circle(x+size/2, y+size/2, size/3);\r\n}", "title": "" }, { "docid": "827292186d49ffcaeb09b4c2067d363a", "score": "0.6012324", "text": "function InventoryItemMouth2HarnessBallGagClick() {\n\tInventoryItemMouthBallGagClick();\n}", "title": "" }, { "docid": "3ffb73d3846190b88d806d74a9cbf21f", "score": "0.6003659", "text": "function C006_Isolation_Pillory_Click() {\t\n\tClickInteraction(C006_Isolation_Pillory_CurrentStage);\n}", "title": "" }, { "docid": "2467d3f959e026c6421a1cd3f5d33663", "score": "0.5879657", "text": "function FireHeal() {\n $(\"div.user-skill-bar\").children()[1].click(); //Freeze\n $(\"div.user-skill-bar\").children()[3].click(); //Lightning\n $(\"div.user-skill-bar\").children()[4].click(); //Earth\n $(\"div.user-skill-bar\").children()[0].click(); //Antipode\n $(\"div.user-skill-bar\").children()[2].click(); //Ignite\n}", "title": "" }, { "docid": "88ff74720f36fa0867e856eb0f367b7e", "score": "0.5852715", "text": "function gameAreaOnclick() {\n huntingField.onclick = (evt) => {\n if (!evt.target.classList.contains(\"duck\")) looseBullet();\n playSoundShoot();\n conditionForLoose();\n };\n}", "title": "" }, { "docid": "14e15e8fcb5bec0d46fdcb7a964c4830", "score": "0.5842993", "text": "function markGoalComplete() {\n\t\tprops.markGoalComplete(props.goalId);\n }", "title": "" }, { "docid": "35c41781e6e58273b98248f6d43220b7", "score": "0.5829384", "text": "function markGoalActive() {\n\t\tprops.markGoalActive(props.goalId);\n\t}", "title": "" }, { "docid": "21a19c591896c21502db02cc3643d0c8", "score": "0.5827034", "text": "function C999_Common_PantieGag_Click() {\n\tOverridenIntroImage = \"\";\n\tClickInteraction(C999_Common_PantieGag_CurrentStage);\n\tInventoryClick(GetClickedInventory(), LeaveChapter, LeaveScreen);\n}", "title": "" }, { "docid": "15c3ea96e46517191d6e3a612e76ec66", "score": "0.582055", "text": "function gripClick() {\n Data.Menu.Open = !Data.Menu.Open;\n setMenuPosition();\n\n if (!Data.Menu.Open && Data.Controls.Open) {\n Data.Controls.Open = false;\n setControlsPosition();\n }\n\n if (!Data.Menu.Open && Data.Edit.Open) {\n Data.Edit.Open = false;\n setEditMenuPosition();\n\n Data.Edit.LastMode = Data.Edit.Mode;\n Data.Edit.Mode = EditModes.Off;\n updateMenu();\n }\n}", "title": "" }, { "docid": "f8c7328c82ca2b47fc10071170ecb481", "score": "0.58122146", "text": "function click () {\n\n\t\t\tif (luigiClicks === 50){\n\t\t\t\talert('Luigi wins!');\n\t\t\t} else if (marioClicks === 50) {\n\t\t\t\talert('Mario Wins!');\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "50deb3914fa70650023fa0788df882ab", "score": "0.579628", "text": "function IceHeal() {\n $(\"div.user-skill-bar\").children()[0].click(); //Antipode\n $(\"div.user-skill-bar\").children()[3].click(); //Lightning\n $(\"div.user-skill-bar\").children()[4].click(); //Earth\n $(\"div.user-skill-bar\").children()[2].click(); //Ignite\n $(\"div.user-skill-bar\").children()[1].click(); //Freeze\n}", "title": "" }, { "docid": "7f9ace6b04f0655ceb12af753991356f", "score": "0.5782023", "text": "function C999_Common_BallGag_Click() {\n\tOverridenIntroImage = \"\";\n\tClickInteraction(C999_Common_BallGag_CurrentStage);\n\tInventoryClick(GetClickedInventory(), LeaveChapter, LeaveScreen);\n}", "title": "" }, { "docid": "1765532e2ecb49b3e114a5c19e9bfff8", "score": "0.5732174", "text": "function actionOnClick(){\n switch(index){\n //when the user is prompted to put in the green block\n case 7:\n text.setText(content[index]);\n white.inputEnabled = true;\n index++;\n break; \n //change to angie being lit up after block is placed at the end of the dialogue\n case (content.length):\n showAngieLight();\n default:\n text.setText(content[index]);\n index++;\n }\n }", "title": "" }, { "docid": "c87e0b0187a4b6e551358093f8187cec", "score": "0.5726332", "text": "function blueClick() {\n\tblueLight();\n\tuserPlay.push(4);\n\tuserMovement();\t\n}", "title": "" }, { "docid": "be1cdef0007c246514ba5d74f94a52b1", "score": "0.57180125", "text": "function mine_box_auto_click(h, w) {\r\n if(m_nMineMap[h][w] == MineBox_Marked) { // amrked as mine\r\n return;\r\n }\r\n \r\n var mineBox = document.getElementById(\"tdMineBox_\"+h+\"_\"+w);\r\n mineBox.className = \"divMineMap_td_clicked\";\r\n\r\n m_nMineMap[h][w] = MineBox_Visited;\r\n m_sMineMapBackground[h][w] = \"divMineMap_td_clicked\";\r\n switch(m_nMineMapDisplay[h][w]) {\r\n case MineBox_None:\r\n mineBox.innerHTML = \"\";\r\n break;\r\n case MineBox_Mine:\r\n mineBox.innerHTML = \"<b>*</b>\";\r\n break;\r\n default:\r\n mineBox.innerHTML = m_nMineMapDisplay[h][w];\r\n\t\t\t//alert(mineBox.innerHTML);\r\n return;\r\n }\r\n \r\n// //alert(m_nMineMapDisplay[h][w]+\",\"+h+\",\"+w);\r\n// if(m_nMineMapDisplay[h][w] != MineBox_None) { // got the value\r\n// return;\r\n// }\r\n\r\n //alert(m_nMineMap[h - 1][w]+\",\"+(h-1)+\",\"+w);\r\n // [h-1][w]\r\n if (h > 1 && m_nMineMap[h - 1][w] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h - 1, w);\r\n }\r\n // [h-1][w+1]\r\n if (h > 1 && w < m_nMapWidth && m_nMineMap[h - 1][w + 1] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h - 1, w + 1);\r\n }\r\n // [h][w+1]\r\n if (w < m_nMapWidth && m_nMineMap[h][w + 1] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h, w + 1);\r\n }\r\n // [h+1][w+1]\r\n if (h < m_nMapHeight && w < m_nMapWidth && m_nMineMap[h + 1][w + 1] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h + 1, w + 1);\r\n }\r\n // [h+1][w]\r\n if (h < m_nMapHeight && m_nMineMap[h + 1][w] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h + 1, w);\r\n }\r\n // [h+1][w-1]\r\n if (h < m_nMapHeight && w > 1 && m_nMineMap[h + 1][w - 1] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h + 1, w - 1);\r\n }\r\n // [h][w-1]\r\n if (w > 1 && m_nMineMap[h][w - 1] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h, w - 1);\r\n }\r\n // [h-1][w-1]\r\n if (h > 1 && w > 1 && m_nMineMap[h - 1][w - 1] != MineBox_Visited) { // not visited\r\n mine_box_auto_click(h - 1, w - 1);\r\n }\r\n}", "title": "" }, { "docid": "904bc7cc663d44e66de6692f96f00d64", "score": "0.571483", "text": "function startClick() {\n\t$$(\"div#maze div.boundary\").each(function (item) {\n\t\titem.removeClassName(\"youlose\");\n\t});\n\tend = true;\n\t$(\"status\").textContent = \"Find the end\";\n}", "title": "" }, { "docid": "3dc0c2057e51c2b5c3ab1a2bf01f7511", "score": "0.5710637", "text": "function startFarTrigger() {\n userClicked();\n }", "title": "" }, { "docid": "4eed32b85a5a8d23732b806a915afa8c", "score": "0.57097167", "text": "function pushDown() {\n undraw();\n // const isAtBottom = current.some(x => squares\n while(!current.some(x => squares[currentPosition + x + width].classList.contains('taken'))) {\n currentPosition += width;\n }\n draw();\n freeze();\n }", "title": "" }, { "docid": "560ce2d3d028dd3dbab8db0d13535081", "score": "0.56934464", "text": "function mouseClicked() {\n// test.minStep = 0;\n start =true;\n}", "title": "" }, { "docid": "3641f55969d503f4b2ec704fec0c3e89", "score": "0.56697166", "text": "function ElectricResist() {\n $(\"div.user-skill-bar\").children()[4].click(); //Earth\n $(\"div.user-skill-bar\").children()[0].click(); //Antipode\n $(\"div.user-skill-bar\").children()[1].click(); //Freeze\n $(\"div.user-skill-bar\").children()[2].click(); //Ignite\n $(\"div.user-skill-bar\").children()[3].click(); //Lightning\n}", "title": "" }, { "docid": "3010e021ae8d9c326661fe79d909ab4c", "score": "0.56563437", "text": "function safeClick() {\r\n if (gGame.isFinish) return\r\n if (gGame.isLose) return\r\n if (gGame.safes.length === 0) return\r\n\r\n gGame.safes.pop();\r\n\r\n gElSafe.innerText = \"\"\r\n gGame.safes.forEach(SAFE => { gElSafe.innerText += SAFE })\r\n\r\n if (gGame.safes.length === 0) {\r\n gElSafe.innerText = DONE\r\n }\r\n\r\n var emptys = [];\r\n for (let i = 0; i < gBoard.length; i++) {\r\n for (let j = 0; j < gBoard[i].length; j++) {\r\n var cell = gBoard[i][j];\r\n if (cell.isMine) continue\r\n if (cell.isShown) continue\r\n emptys.push({ i: i, j: j });\r\n }\r\n }\r\n //get random location\r\n var randomIdx = getRandomIntInclusive(0, emptys.length - 1);\r\n var location = emptys[randomIdx];\r\n console.log('emptys:', emptys)\r\n console.log('location:', location)\r\n var elButton = document.querySelector(`.cell${location.i}-${location.j} button`)\r\n\r\n elButton.style.backgroundColor = \"lightgreen\";\r\n // paint it for 2 sec\r\n setTimeout(function () {\r\n elButton.style.backgroundColor = \"lightgrey\";\r\n }, 1000)\r\n\r\n}", "title": "" }, { "docid": "7aadb66f29572fb31437d44e00f8a756", "score": "0.56302667", "text": "function change(hint) {\n document.getElementById(\"beamsize\").innerHTML = BeamFromBar;\n document.getElementById(\"slidebarHint\").innerHTML = hint;\n console.log('Beam size: ' + BeamFromBar);\n fillPage_go(d=40,R=250,circleScale=50,halfOpen=20);\n}", "title": "" }, { "docid": "c21e18e4c63deeff4ef6f42db7eaed38", "score": "0.5628305", "text": "function onFillEmptyClick () {\r\n const elements = $('.grid .cell');\r\n const clickColor = $('.palette button.active').css('background-color');\r\n for (let index = 0; index < elements.length; index = index + 1) {\r\n let nextElement = $( elements[index] );\r\n if (nextElement.css('background-color') === 'rgba(0, 0, 0, 0)') {\r\n nextElement.css('background-color', clickColor);\r\n } \r\n } \r\n }", "title": "" }, { "docid": "a1e7b830f77414ac5483685b3dffa24d", "score": "0.5625137", "text": "function click(id) {\n const square = getElement(id);\n square.clicked = true;\n setElementBorderColour(id,'white');\n}", "title": "" }, { "docid": "1cde78ca0996514cc8752b71660ce930", "score": "0.5622627", "text": "function changeDonationGoal(newgoal){\n $(\"#donation-goal\").html(newgoal);\n}", "title": "" }, { "docid": "7520beffae8a82b9e1639b7290cf0e57", "score": "0.5620108", "text": "toggleGoal() {\n const { filteredTransactions } = this.state;\n const id = filteredTransactions[0].account[0].id;\n let min = 0, max = 0, center = null;\n const goal = {\n account_id: 'mq1a8D3X19HbmJgVxLLyF1bwn9854NtRX6GG5',\n description: 'spending',\n amount: 3500\n }\n if (!this.state.displayGoal) {\n min = goal.amount * 0.95;\n max = goal.amount * 1.05;\n center = goal.amount;\n }\n this.setState({\n annotations: {\n min, max, center\n },\n displayGoal: !this.state.displayGoal\n })\n }", "title": "" }, { "docid": "548e8c5825748054581185b7adfa6ec2", "score": "0.56048644", "text": "function repaintTest() {\n clickAt(75, 50);\n}", "title": "" }, { "docid": "66be6ac59cf79ac991c8556620fc416b", "score": "0.55991274", "text": "selectWhoIsHelpingYou() {\n let householdIndex = (global.updateDataJson.households.length === 0) ? 0 : global.updateDataJson.households.length-1;\n var dataJson = global.updateDataJson.households[householdIndex]\n browser.pauseBrowser(constants.INTERVAL);\n if (dataJson.startYourApplication.getHelpApplyingIndicator==false) {\n logger.log(\"****I am filling for my family\")\n browser.pauseBrowser(constants.PAUSE_BROWSER_3000);\n if(state.toUpperCase()=='ID'){\n browser.waitForElementToDisplay(eval(stateLocatorFile.rb_fillingOutForMyselfAndFamily));\n browser.click(eval(stateLocatorFile.rb_fillingOutForMyselfAndFamily));\n }\n else{\n browser.waitForElementToDisplay(eval(locatorJson.helpApplyingForCoverage.rb_fillingOutForMyselfAndFamily));\n browser.click(eval(locatorJson.helpApplyingForCoverage.rb_fillingOutForMyselfAndFamily)); \n }\n }\n else {\n browser.click(eval(locatorJson.helpApplyingForCoverage.rb_someoneIsHelpingMe));\n }\n\n }", "title": "" }, { "docid": "6b984543ec6ca20b897e7e91b4662def", "score": "0.5588357", "text": "function NoMana() {\n $(\"div.user-skill-bar\").children()[2].click();\n}", "title": "" }, { "docid": "146dd4f30398c5534b20bdc9d1abdb64", "score": "0.55764765", "text": "function handleClick(){\n if( value == 'EMPTY' )takeTurn(position)\n }", "title": "" }, { "docid": "d79f84f90b9ee727f1a02f626b71ddc6", "score": "0.55706936", "text": "function turnclick(square) {\n document.getElementById(hintindex).style.backgroundColor = \"black\";\n document.getElementById(\"hint\").style.backgroundImage = \"url(bulb.png)\";\n if(typeof board[square.target.id]==\"number\") { \n turn(square.target.id, human)\n if(!checkWin(board, human) && !checkTie()) turn(bestSpot(levell), ai);} \n}", "title": "" }, { "docid": "96d15b20dbe8f89231e818dcc99b4d89", "score": "0.55647945", "text": "clickFirstHorseTile(){\n this.firstHorseTile.waitForExist();\n this.firstHorseTile.click();\n }", "title": "" }, { "docid": "96d15b20dbe8f89231e818dcc99b4d89", "score": "0.55647945", "text": "clickFirstHorseTile(){\n this.firstHorseTile.waitForExist();\n this.firstHorseTile.click();\n }", "title": "" }, { "docid": "819c09d5decc27eef454d0094781ea47", "score": "0.55609393", "text": "function C007_LunchBreak_Sarah_Click() {\t\n\n\t// Regular and inventory interactions\n\tClickInteraction(C007_LunchBreak_Sarah_CurrentStage);\n\tvar ClickInv = GetClickedInventory();\n\tif (ClickInv == \"Player\") {\n\t\tC007_LunchBreak_Sarah_IntroText = OveridenIntroText;\n\t\tC007_LunchBreak_Sarah_LeaveIcon = LeaveIcon;\n\t\tInventoryClick(ClickInv, CurrentChapter, CurrentScreen);\n\t}\n\n\t// Recalculates the scene parameters\n\tC007_LunchBreak_Sarah_CalcParams();\n\n}", "title": "" }, { "docid": "6bf624cac810267bb5580a0fcb110961", "score": "0.5556075", "text": "function InventoryItemTorso2FuturisticHarnessClick() {\n\tvar C = (Player.FocusGroup != null) ? Player : CurrentCharacter;\n\tif (InventoryItemFuturisticValidate(C) !== \"\") {\n\t\tInventoryItemFuturisticClickAccessDenied();\n\t} else {\n\n\t\tExtendedItemClick(InventoryItemTorso2FuturisticHarnessOptions);\n\n\t\tvar FuturisticCollarItems = InventoryItemNeckFuturisticCollarGetItems(C);\n\t\tif (MouseIn(1400, 910, 200, 55) && FuturisticCollarItems.length > 0 && DialogFocusItem) { InventoryItemNeckFuturisticCollarColor(C, DialogFocusItem); InventoryItemTorso2FuturisticHarnessExit();}\n\t}\n}", "title": "" }, { "docid": "b9efd249a451de2fbe3d47ce3e21730f", "score": "0.55511975", "text": "function mouseClick(rechthoek){\n var idea = +rechthoek.attr(\"id\").slice(9,12);\n while(idea>=8){\n idea = idea-8;\n }\n var original = idea;\n addToSelection(original);\n highlightRechthoeken();\n //var boolie = true;\n //while(idea<150){\n //\n // d3.select(\"#rechthoek\"+idea).attr(\"fill\", colahs[original]).attr('opacity',\"1\");\n // idea +=8;\n //\n //\n //}\n\n }", "title": "" }, { "docid": "b93faef6ebced4cc2ece953ada37287b", "score": "0.552434", "text": "function EarthResist () {\n $(\"div.user-skill-bar\").children()[3].click(); //Lightning\n $(\"div.user-skill-bar\").children()[0].click(); //Antipode\n $(\"div.user-skill-bar\").children()[1].click(); //Freeze\n $(\"div.user-skill-bar\").children()[2].click(); //Ignite\n $(\"div.user-skill-bar\").children()[4].click(); //Earth\n}", "title": "" }, { "docid": "f10a80e017802ec3b21583581f7bb163", "score": "0.55214703", "text": "function click(sqaure){\n let currentId = sqaure.id\n if(isGameOver) return\n if(sqaure.classList.contains('checked') || square.classList.contains('flag')) return\n if(sqaure.classList.contains('bomb')){\n gameOver(sqaure)\n }\n else {\n let total = sqaure.getAttribute('data')\n if(total !=0){\n sqaure.classList.add('checked')\n sqaure.innerHTML = total\n return\n }\n \n checkSquare(sqaure,currentId)\n \n }\n sqaure.classList.add('checked') \n }", "title": "" }, { "docid": "12fbb97cb89d59746be9fa90ba736ef5", "score": "0.5511331", "text": "function FireResist() {\n $(\"div.user-skill-bar\").children()[1].click(); //Freeze\n $(\"div.user-skill-bar\").children()[0].click(); //Antipode\n $(\"div.user-skill-bar\").children()[3].click(); //Lightning\n $(\"div.user-skill-bar\").children()[4].click(); //Earth\n $(\"div.user-skill-bar\").children()[2].click(); //Ignite\n}", "title": "" }, { "docid": "feae94451a9a2bfc77ec54f2243155dc", "score": "0.55111766", "text": "function click() {\n clickNumber += clickStrength;\n clickNumber = truncate(clickNumber);\n display();\n}", "title": "" }, { "docid": "0237a3d7c72d1de136f028e16350be10", "score": "0.5502353", "text": "function IceResist() {\n $(\"div.user-skill-bar\").children()[0].click(); //Antipode\n $(\"div.user-skill-bar\").children()[3].click(); //Lightning\n $(\"div.user-skill-bar\").children()[4].click(); //Earth\n $(\"div.user-skill-bar\").children()[2].click(); //Ignite\n $(\"div.user-skill-bar\").children()[1].click(); //Freeze\n}", "title": "" }, { "docid": "9354c42fbb6f3c038464547b2076bb85", "score": "0.5497297", "text": "function mouseClick(e) {\n const pos = convertScreenToGrid(e.offsetX, e.offsetY)\n if (pos.x >= 0 && pos.x < size && pos.y >= 0 && pos.y < size) {\n\n if (modifyEnabled) {\n tiles[pos.x][pos.y].property = (e.which === 3) ? 0 : tool\n // redraw the entire grid\n setTile(tiles[pos.x][pos.y])\n } else if (addPersonEnabled) {\n addPerson(pos.x, pos.y)\n }\n\n drawGrid()\n clearSelection()\n // highlightPath(tiles[0][0], findPath(tiles[0][0], tiles[pos.x][pos.y]))\n // console.log(findPath(tiles[0][0], tiles[pos.x][pos.y]))\n // console.log(tiles[pos.x][pos.y].property)\n\n console.log(tool)\n\n }\n}", "title": "" }, { "docid": "8b8ae5e7f763fc9bf6b2d4c7dc3d34cc", "score": "0.54916453", "text": "function mouseClicked() {\n var size = random(50, 350);\n drawPizza(mouseX, mouseY, size);\n}", "title": "" }, { "docid": "ece01c8e74a5e09af3c7a93ce0703df1", "score": "0.54906213", "text": "function displayGoal() {\n // Make the message disappear when a game over happens\n if (state === \"GAMEOVER\") {\n return;\n }\n push();\n // Setting the aesthetics\n fill(255);\n textFont(neoFont);\n textSize(64);\n textAlign(CENTER, CENTER);\n text(goalText, width / 2, goalTextY);\n // Make it move upwards\n goalTextY = goalTextY - 3;\n pop();\n}", "title": "" }, { "docid": "6b3005ee9512043ca71eaea4e6d3381c", "score": "0.5489167", "text": "function main() {\n fillSquare();\n targeter();\n clickListener();\n reset();\n difficulty();\n toggler();\n\n\n\n\n}", "title": "" }, { "docid": "42486a9ea1e5bbade60fd50e375ddfea", "score": "0.5481442", "text": "function mouseClicked(){\n\tif(mouseX>4 && mouseX<140 && mouseY>240 && mouseY<400) // box located around the hands\n\t{\n\t\tcheckDeerGo = true;\n\n\t}\n}", "title": "" }, { "docid": "aa906c4cea1cbce606fbddd7cb9d1b0c", "score": "0.5481195", "text": "function clicked() {\n\n}", "title": "" }, { "docid": "d7a2b78568563c723513995427359c8e", "score": "0.5477747", "text": "function tap_to_expand($element) {\n $element.css({\n \"overflow\": \"hidden\"\n });\n\n var sponsor_text_initial = $element.find(\".plr-sponsor\").first().html();\n $element.find(\".plr-sponsor\").html(\"<em>Tap</em> to learn more! <br> \" + sponsor_text_initial);\n\n $element.find(\"h1\").unwrap().css({\n cursor: \"pointer\"\n });\n\n var initial_h,\n default_h,\n been_clicked = false;\n\n function onresize() {\n var img_height = get_total_height(($element.find(\".plr-img-wrapper\").length === 0) ? $element.find(\"img\") : $element.find(\".plr-img-wrapper div\"));\n var p_height = get_total_height($element.find(\"p\").first()) + get_total_height($element.find(\"p\").last());\n\n var total_body_height;\n if (window.innerWidth < 425 || $element.find(\"img\").length !== 0) {\n\n if ($element.find(\".plr-img-wrapper\").length) total_body_height = p_height;\n else total_body_height = p_height + img_height;\n } else {\n total_body_height = (img_height > p_height) ? img_height : p_height;\n }\n\n default_h =\n parseFloat($element.find(\".topic\").css(\"height\")) +\n get_total_height($element.find(\"h1\")) +\n get_total_height($element.find(\".plr-sponsor\"));\n\n initial_h =\n default_h +\n total_body_height +\n parseFloat($element.css(\"padding-bottom\")) +\n parseFloat($element.css(\"padding-top\"));\n\n if (!been_clicked) $element.css({\n \"height\": default_h + \"px\"\n });\n else $element.css({\n \"height\": initial_h + \"px\"\n });\n }\n\n\n window.addEventListener(\"resize\", onresize);\n $element.find(\"img\").load(onresize);\n onresize();\n\n\n $element.css({\n \"transition\": 1 + \"s\",\n \"height\": default_h + \"px\"\n });\n\n $element.find(\"h1\").click(function() {\n if (!been_clicked) {\n $element.css({\n \"height\": initial_h + \"px\"\n });\n been_clicked = true;\n } else {\n $element.css({\n \"height\": default_h + \"px\"\n });\n been_clicked = false;\n }\n });\n }", "title": "" }, { "docid": "c9ee9563a05688b80366de52ad60e2b3", "score": "0.54737943", "text": "function editGoal() {\n\t\tprops.editTask(props.goalId);\n\t}", "title": "" }, { "docid": "0cd917fe1135d3003e71edb6fba69933", "score": "0.5473521", "text": "function click(event) {\r\n\t\tvar blank = document.getElementById(\"16\");\r\n\t\tif (isNeighbors(this, blank)) {\r\n\t\t\tmove(this, blank);\r\n\t\t}\r\n\t}", "title": "" }, { "docid": "b94e56b9690fb427bae16103b54a768b", "score": "0.5459585", "text": "function clickPrefect() {\n if (student.prefect === true) {\n student.prefect = false;\n } else {\n tryToMakePrefect(student);\n }\n buildList();\n }", "title": "" }, { "docid": "77e514f73e20626cc9eb8850ad99d383", "score": "0.54520446", "text": "function isClicked(x1, y1, x2, y2, countryName, gold, resources, isClicked, ownedBy, health, maxHealth, strength) {\n if (isClicked === 1 && showUnitMap === false && isShopOpen === false) {\n fill(255);\n rect(windowWidth / 2 - 100, windowHeight / 2 - 100, 200, 230);\n fill(0);\n textSize(12);\n text(\"This is \" + countryName, windowWidth / 2 - 90, windowHeight / 2 - 80);\n text(\"It is owned by: \" + ownedBy, windowWidth / 2 - 90, windowHeight / 2 - 60);\n text(\"resources: \" + resources, windowWidth / 2 - 90, windowHeight / 2- 40);\n text(\"gold: \" + gold, windowWidth / 2 - 90, windowHeight / 2 - 20);\n text(\"health: \" + health + \"/\" + maxHealth , windowWidth / 2 - 90, windowHeight / 2);\n text(\"possible damage inflicted: \" + strength , windowWidth / 2 - 90, windowHeight / 2+20);\n text(\"Press C to remove this page!\", windowWidth / 2 - 90, windowHeight / 2 + 80);\n }\n}", "title": "" }, { "docid": "37998917b83161954623ec9b94b35d12", "score": "0.54511976", "text": "function C006_Isolation_Yuki_Click() {\t\n\tClickInteraction(C006_Isolation_Yuki_CurrentStage);\n}", "title": "" }, { "docid": "c013d0b81aac06593efd71588dd692fd", "score": "0.54484606", "text": "function OnClickObjectiveOk() {\n SetActive('#LO', false);\n OnClickL1();\n}", "title": "" }, { "docid": "b4f8a2b7a294c451e115605b6912ad47", "score": "0.54448426", "text": "function clickHandling (mod, icon, target) {\n target.style.backgroundImage = `url('img/${icon}.svg')`;\n target.classList.add(`box-filled-${mod+1}`);\n const indexNum = listItems.indexOf(target);\n game1.gameBoard[indexNum] = 1;\n game1.move += 1;\n checkActive();\n displayWin(checkWin());\n }", "title": "" }, { "docid": "3be69e8080cb5747fa6f78f26097d2b5", "score": "0.54345477", "text": "function turnClick(square) {\n\tturn(square.target.id, countOfelm());\n}", "title": "" }, { "docid": "ae269c51904640a5aeb724c1b0044525", "score": "0.5433791", "text": "function yellowClick() {\n\tyellowLight();\n\tuserPlay.push(3);\n\tuserMovement();\t\n}", "title": "" }, { "docid": "4f5182e71c9148595a5a64496625b9da", "score": "0.5430512", "text": "function safeClick() {\r\n if (gSafeClicksCount === 0) return;\r\n var iIdx = getRandomInt(0, gBoard.length);\r\n var jIdx = getRandomInt(0, gBoard.length);\r\n if (gBoard[iIdx][jIdx].isMine || gBoard[iIdx][jIdx].isShown) {\r\n safeClick();\r\n } else {\r\n var cellSelector = getSelector(iIdx, jIdx);\r\n var elCell = document.querySelector(cellSelector);\r\n elCell.classList.add('hint');\r\n gSafeClicksCount--;\r\n elSafeClickBtnUpdate();\r\n setTimeout(function () {\r\n elCell.classList.remove('hint');\r\n }, 1000);\r\n }\r\n}", "title": "" }, { "docid": "d60012cd9133197126a7e4db314f418b", "score": "0.5423131", "text": "function C005_GymClass_GymFight_Click() {\n\tFightClick();\n}", "title": "" }, { "docid": "15509c69e6dae2eb5128f5ad501fcdf7", "score": "0.5422355", "text": "function click(x, y) {\n console.log(\"klickade\");\n if (gamemode1 == 0) {\n placeBoats(x, y);\n } else {\n fire(x, y);\n }\n}", "title": "" }, { "docid": "aadb737c43fb7fac1bec871732b20ffa", "score": "0.5419302", "text": "function handleClick(event) {\n console.log(event.target);\n const game = document.getElementById('game');\n game.innerHTML = '';\n // access points to progress bar\n const gameProgress = document.getElementById('game-progress');\n let point = Number(event.target.dataset.point)\n if(point == 0) {\n gameProgress.value = 0;\n } else {\n \n }\n gameProgress.value += point;\n appendScene(event.target.dataset.goto);\n}", "title": "" }, { "docid": "bf3bed57a4472e9a7c279c50a8953746", "score": "0.5417575", "text": "function piece_click() {\r\n\tconst piece = $(this);\r\n\tconst field = piece.parent();\r\n\tconst fields = $('.field');\r\n\r\n\tconst field_data = field.attr('id').split('_');\r\n\tconst piece_data = piece.attr('id').split('_');\r\n\r\n\tconst data = {\r\n\t\tx: Number(field_data[0]),\r\n\t\ty: Number(field_data[1]),\r\n\t\tcolor: piece_data[0],\r\n\t\ttype: piece_data[1],\r\n\t};\r\n\r\n\tif (data.color !== player_turn)\r\n\t\treturn;\r\n\r\n\tfields.removeClass('greenBG');\r\n\r\n\tif (field.hasClass('selectedPiece')) {\r\n\t\tfield.removeClass('selectedPiece');\r\n\t}\r\n\telse {\r\n\t\tfields.removeClass('selectedPiece');\r\n\t\tfield.addClass('selectedPiece');\r\n\t\tselect_piece(field, piece, data);\r\n\t}\r\n}", "title": "" }, { "docid": "e6443e304bf1fcaa43e9a91294f97b41", "score": "0.5412148", "text": "function step() {\n validate();\n drawBoard();\n drawStatus();\n}", "title": "" }, { "docid": "b754f67c3cbb2e5b9b43e6b448f136ee", "score": "0.54010385", "text": "function C101_KinbakuClub_Fight_Click() {\n\tFightClick();\n}", "title": "" }, { "docid": "7f113336727edc98d37e48c1bfd31c0a", "score": "0.539773", "text": "click_expertTips_1stHorse(){\n this.expertTips_1stHorse.waitForExist();\n this.expertTips_1stHorse.click();\n }", "title": "" }, { "docid": "33f195a1c8a12cafe7e4bb25ea349c2a", "score": "0.5397252", "text": "function fitGoalCheck () {\n if (mainFitGoal === \"4\" || mainFitGoal === \"6\") {\n thirtyMinutes.classList.add(\"ghost\");\n } else {}\n}", "title": "" }, { "docid": "378bad5e72777d4a1869c836d12a43fd", "score": "0.5385945", "text": "function openClosedDrawer() {\n \"use strict\";\n if ($(\"#StepMaker\").height() <= 20) {\n $(\"[id^='tangelo-drawer-icon-']\").trigger(\"click\");\n }\n}", "title": "" }, { "docid": "15b86b9b362a590fceb4108058240bcd", "score": "0.5377806", "text": "function startNearTrigger() {\n userClicked();\n }", "title": "" }, { "docid": "b3859c6d81cd8bd9f5edcccbb435bd0f", "score": "0.5363235", "text": "function clickTutorialImage() {\n if (tutorialStep === 1) {\n tutorialStep2();\n }\n if (tutorialStep === 2) {\n tutorialStep3();\n }\n}", "title": "" }, { "docid": "cd6bcec4f7fa2a00ddae79031e8a1c9f", "score": "0.5363116", "text": "function clicky()\n{\n element(by.id('gobutton')).click();\n}", "title": "" }, { "docid": "206c0efde723947486f380f26ba1eb1d", "score": "0.5362857", "text": "click() {}", "title": "" }, { "docid": "206c0efde723947486f380f26ba1eb1d", "score": "0.5362857", "text": "click() {}", "title": "" }, { "docid": "206c0efde723947486f380f26ba1eb1d", "score": "0.5362857", "text": "click() {}", "title": "" }, { "docid": "072a866feaa062be0f68721d8c6b19cb", "score": "0.53619283", "text": "function safeClick(elLife) {\r\n elLife.innerHTML = USEDLIFE\r\n setTimeout(() => {\r\n elLife.hidden = true\r\n }, 500);\r\n var safePos = []\r\n for (var i = 0; i < gLevels[gChosenLevelIdx].SIZE; i++) {\r\n for (var j = 0; j < gLevels[gChosenLevelIdx].SIZE; j++) {\r\n var cell = gBoard[i][j]\r\n if (cell.isShown === true || cell.isMine === true) continue\r\n else {\r\n\r\n var coord = { i: i, j: j }\r\n safePos.push(coord)\r\n }\r\n }\r\n }\r\n var safeIdx = getRandomInt(0, safePos.length)\r\n var posI = safePos[safeIdx].i\r\n var posJ = safePos[safeIdx].j\r\n var elCellId = `cell-${posI}-${posJ}`\r\n var elCell = document.querySelector(`#${elCellId}`)\r\n elCell.innerHTML = BELL\r\n setTimeout(() => {\r\n elCell.innerHTML = COVERED_IMG\r\n }, 400);\r\n return\r\n}", "title": "" }, { "docid": "5be978c55b71881625f58054334a6fcf", "score": "0.53591913", "text": "function chooseDefender(){\r\n $('.comp').on('click', function(){\r\n $(this).appendTo($('.arena').addClass('my-2 d-inline-flex flex-row')).addClass('atk-arena bg-danger');\r\n $('.comp').off('click')\r\n $('.atk-arena').removeClass('bg-dark comp user');\r\n enableAtk();\r\n });\r\n}", "title": "" }, { "docid": "498d6a8459fbe7c6592dc4feb2ab34aa", "score": "0.5356447", "text": "function doneBtnClick(){\n\tif ($.groundCoverError.visible === true) {\n\t\t$.groundCover.focus(); //keep the field's input focus\n\t\treturn;\n\t}\n\ttry {\n\t\tvar db = Ti.Database.open('ltemaDB');\n\t\tdb.execute( 'UPDATE plot_observation \\\n\t\t\t\t\tSET ground_cover = ? \\\n\t\t\t\t\tWHERE plot_observation_guid = ?', $.groundCover.value,observationGUID);\t\t\n\t} catch (e){\n\t\tvar errorMessage = e.message;\n\t\tTi.App.fireEvent(\"app:dataBaseError\", {error: errorMessage});\n\t} finally {\n\t\tdb.close();\n\t\t$.modalNav.close();\n\t\tTi.App.fireEvent(\"app:refreshPlotObservations\");\n\t}\n}", "title": "" }, { "docid": "ea01b97c575e1282e2d05e0323f2dd32", "score": "0.5351394", "text": "function greenClick(){\n\tgreenLight();\n\tuserPlay.push(1);\n\tuserMovement();\n}", "title": "" }, { "docid": "cadd1b6084f18ae4e7dbadba5684065e", "score": "0.5350858", "text": "function mousePressed() {\n var click = 0;\n click ++;\n\n if (click > 0){\n textSize(50);\n fill(0);\n text(\"First one's on the hosue!\", 120, 50);\n }\n }", "title": "" }, { "docid": "7d858e9b80d8ccb088b57e32ecf8a4b3", "score": "0.5349519", "text": "async clickGo() {\n\t\t\tawait this.go.click();\n\t\t}", "title": "" }, { "docid": "d823ec1a2777d949bc323836264f00a4", "score": "0.5342585", "text": "focusFigure(clickedTile){\n\t\tthis.defocus();\n\t\tthis.focus.x = clickedTile.x;\n\t\tthis.focus.y = clickedTile.y;\n\t\tthis.focusedTile = clickedTile;\n\t\tthis.moveableTile(this.focusedTile.figure);\n\t}", "title": "" }, { "docid": "080453c4f722ff53354d67db0bcaafe1", "score": "0.53398246", "text": "function onProceedClick() {\n setDisplayValue('q1');\n updateLastViewed('q1');\n showHideElements();\n}", "title": "" }, { "docid": "d8230b962fe860960f3e718c19c41186", "score": "0.5336837", "text": "function mouseClicked() \n{\n\tvar nowMouseX = mouseX;\n\tvar nowMouseY = mouseY;\n\t\n\t// if click outside the panel, ignore it\n\tif (nowMouseX > GAME_WIDTH || nowMouseX < 0 || nowMouseY > GAME_HEIGHT || nowMouseY < 0)\n\t{\n\t\treturn;\n\t}\n\t\n\tif (is_pick_toy_mode)\n\t{\n\t\tlet nextDirection = NextToAddDirection(pickedToy.x, pickedToy.y, nowMouseX, nowMouseY);\n\t\tif (nextDirection != NOT_CHOSEN)\n\t\t{\n\t\t\tpickedToy.add_duration(nextDirection);\n\t\t\tactionRowHTML(\"Add direction \" + nextDirection + \" to toy \" + pickedToy.id);\n\t\t\tswithPlayer();\n\t\t}\n\t\telse if(onSamePickToy(nowMouseX, nowMouseY))\n\t\t{\n\t\t\tis_pick_toy_mode = false;\n\t\t\tpickedToy = NOT_CHOSEN;\n\t\t}\n\t\tvar nextLocationCheck = NextToNextStep(nowMouseX, nowMouseY);\n\t\tif (nextLocationCheck != NOT_CHOSEN)\n\t\t{\n\t\t\tactionRowHTML(\"Move toy \" + pickedToy.id + \" from (\" + pickedToy.x + \", \" + pickedToy.y + \") to (\" + thisPossibleNextSteps[nextLocationCheck].new_x + \", \" + thisPossibleNextSteps[nextLocationCheck].new_y + \")\");\n\t\t\tpickedToy.jump(thisPossibleNextSteps[nextLocationCheck].new_x, thisPossibleNextSteps[nextLocationCheck].new_y);\n\t\t\tif (thisPossibleNextSteps[nextLocationCheck].is_jump)\n\t\t\t{\n\t\t\t\tgame.kill_list_from_jump(thisPossibleNextSteps[nextLocationCheck]);\t\n\t\t\t\t// if same group or not \n\t\t\t\tif ((pickedToy.id < 4 && thisPossibleNextSteps[nextLocationCheck].jump_over < 4) || (4 <= pickedToy.id && pickedToy.id < 8 && 4 <= thisPossibleNextSteps[nextLocationCheck].jump_over && thisPossibleNextSteps[nextLocationCheck].jump_over < 8))\n\t\t\t\t{\n\t\t\t\t\tactionRowHTML(\"Toy \" + pickedToy.id + \" jump over toy \" + thisPossibleNextSteps[nextLocationCheck].jump_over);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tactionRowHTML(\"Toy \" + pickedToy.id + \" kill toy \" + thisPossibleNextSteps[nextLocationCheck].jump_over);\n\t\t\t\t}\n\t\t\t\tthisPossibleNextSteps = game.possible_next_steps(pickedToy.id, false);\n\t\t\t\tif (thisPossibleNextSteps.length > 0)\n\t\t\t\t{\n\t\t\t\t\tis_re_jump_case = true;\n\t\t\t\t\tis_pick_toy_mode = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tswithPlayer();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tswithPlayer();\n\t\t\t}\n\t\t}\n\t}\n\telse if (is_re_jump_case)\n\t{\n\t\tif(onSamePickToy(nowMouseX, nowMouseY))\n\t\t{\n\t\t\tswithPlayer();\n\t\t}\n\t\tvar nextLocationCheck = NextToNextStep(nowMouseX, nowMouseY);\n\t\tif (nextLocationCheck != NOT_CHOSEN)\n\t\t{\n\t\t\tactionRowHTML(\"Move toy \" + pickedToy.id + \" from (\" + pickedToy.x + \", \" + pickedToy.y + \") to (\" + thisPossibleNextSteps[nextLocationCheck].new_x + \", \" + thisPossibleNextSteps[nextLocationCheck].new_y + \")\", \n\t\t\tnew AiMove(AI_MOVE_ADD_DIRECTION,\n\t\t\t\t\t\t\t\tpickedToy.id,\n\t\t\t\t\t\t\t\t-1,\n\t\t\t\t\t\t\t\t[pickedToy.x, pickedToy.y],\n\t\t\t\t\t\t\t\t[thisPossibleNextSteps[nextLocationCheck].jump_over]));\n\t\t\tpickedToy.jump(thisPossibleNextSteps[nextLocationCheck].new_x, thisPossibleNextSteps[nextLocationCheck].new_y);\n\t\t\tif (thisPossibleNextSteps[nextLocationCheck].is_jump)\n\t\t\t{\n\t\t\t\tgame.kill_list_from_jump(thisPossibleNextSteps[nextLocationCheck]);\t\n\t\t\t\t// if same group or not \n\t\t\t\tif ((pickedToy.id < 4 && thisPossibleNextSteps[nextLocationCheck].jump_over < 4) || (4 <= pickedToy.id && pickedToy.id < 8 && 4 <= thisPossibleNextSteps[nextLocationCheck].jump_over && thisPossibleNextSteps[nextLocationCheck].jump_over < 8))\n\t\t\t\t{\n\t\t\t\t\tactionRowHTML(\"Toy \" + pickedToy.id + \" jump over toy \" + thisPossibleNextSteps[nextLocationCheck].jump_over);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tactionRowHTML(\"Toy \" + pickedToy.id + \" kill toy \" + thisPossibleNextSteps[nextLocationCheck].jump_over);\n\t\t\t\t}\n\t\t\t\tthisPossibleNextSteps = game.possible_next_steps(pickedToy.id, false);\n\t\t\t\tif (thisPossibleNextSteps.length > 0)\n\t\t\t\t{\n\t\t\t\t\tis_re_jump_case = true;\n\t\t\t\t\tis_pick_toy_mode = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tswithPlayer();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tswithPlayer();\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\t// find if hiting some node\n\t\tvar nextToNode = clickNextToPickToy(nowMouseX, nowMouseY);\n\t\t\n\t\tif(nextToNode != NOT_CHOSEN)\n\t\t{\n\t\t\tis_pick_toy_mode = true;\n\t\t\t// set the toy we are using now\n\t\t\tpickedToy = nextToNode;\n\t\t\t// find where it can go\n\t\t\tthisPossibleNextSteps = game.possible_next_steps(pickedToy.id, true);\n\t\t\tthisPossibleNewDirections = pickedToy.get_open_directions();\n\t\t}\t\t\n\t}\n}", "title": "" }, { "docid": "f5b7d6c3da80bc271d24395d6d6e88cd", "score": "0.5336682", "text": "function click(square) {\n let currentId = square.id;\n if (isGameOver) {\n return\n }\n if (square.classList.contains(\"checked\") || square.classList.contains(\"flag\")) {\n return\n }\n if (square.classList.contains(\"bomb\")) {\n gameOver(square);\n } else {\n let total = square.getAttribute(\"data\");\n if (total !=0) {\n square.classList.add(\"checked\");\n square.innerHTML = total;\n return;\n }\n checkSquare(square, currentId);\n }\n square.classList.add(\"checked\");\n }", "title": "" }, { "docid": "2f45284c8032b910b0475916d25008ac", "score": "0.5335269", "text": "function myclick(count) {\n GEvent.trigger(gmarkers[count], \"click\");\n}", "title": "" }, { "docid": "de41fb3908bb1921d12d0c9c275deafb", "score": "0.5334904", "text": "function clickSquad() {\n if (student.house === \"Slytherin\" || student.bloodStatus === \"Pure Blood\") {\n student.squad = !student.squad;\n } else {\n notBeSquad();\n }\n buildList();\n }", "title": "" }, { "docid": "814841288c8ea47e8db681f6891f283a", "score": "0.53346795", "text": "function Activate(e)\r\n {\r\n e.target.style.display = \"none\";\r\n amount++;\r\n title.innerHTML = \"<b>\"+amount+\"/\"+clicks+\" CLICKED</b>\";\r\n RandomizeBlocks();\r\n CheckToWin();\r\n }", "title": "" }, { "docid": "0bcb8b167d1aae13f9f5e514bc1fa820", "score": "0.53344136", "text": "function makeStarClick() {\n starGroup.setAll('inputEnabled', true);\n starGroup.setAll('input.useHandCursor', true);\n // Animate each Star to pulse scale\n starGroup.forEach(function(star) {\n star.anchor.set(0.5);\n game.add.tween(star.scale).to( {x:1.05, y:1.05}, 800, \"Sine.easeInOut\", true, 0, -1, true);\n }, this);\n // Animate and destroy on star click\n starGroup.callAll('events.onInputDown.add', 'events.onInputDown', collectStar);\n //starGroup.callAll('events.onInputDown.add', 'events.onInputDown', iconCollectStar);\n // Open modal on star click\n starGroup.callAll('events.onInputDown.add', 'events.onInputDown', displayModal);\n}", "title": "" }, { "docid": "10dd05ee9fda5ad7739f456bfe208a48", "score": "0.5330904", "text": "function progArrowClick() {\n\tif (arrowBtnProg.classList.contains(\"fa-chevron-down\"))\n\t\tprogArrowDownClick();\n\telse if (arrowBtnProg.classList.contains(\"fa-chevron-up\"))\n\t\tProgArrowUpClick();\n\tsetTimeout(function() { removeFadeIn(\"elem__prog\"); }, 1100);\n}", "title": "" }, { "docid": "117c5265e2244682b0ed1b6ddcb75b9d", "score": "0.5328539", "text": "function autoClick(){\n if((cursorMinigameState)&&(!Game.Has('Shimmering veil')||Game.Has('Shimmering veil [on]'))){\n\n //What ? Golden cookie ? Click that one !! You unlock this feature at cursor level 2. Unless you're cheating.\n Game.shimmers.forEach(function(shimmer)\n {\n if( ((shimmer.type == \"golden\") \n ||(shimmer.type == 'reindeer'))\n &&( ((clickerLevelBonus >= 2)&&!(clicked))\n ||(filthyCheaterState) )\n ) \n { \n shimmer.pop(); \n //Cheaters get the omnipotent click but no achievement. Go cheat your own achievements.\n if(!filthyCheaterState){clicked = true; Game.Win('Why would I get my cursor ditry ?');}\n }\n })\n \n //No luck ? Well, I guess I'll click the big one then.\n if (clicked) {clicked = false;}\n else {Game.ClickCookie();}\n\n //No time to waste, we have an appointment in 25ms !\n if(!filthyCheaterState)\n {\n\n //I CAN EAR THE DRUMM OF WAR !!!\n if\n (Game.hasBuff('Elder frenzy') \n || Game.hasBuff('Dragonflight')\n || Game.hasBuff('Click frenzy') \n || Game.hasBuff('Cursed finger')\n || Game.hasBuff('High-five'))\n {\n //NOT FRENZIED ?? YOU SHOULD !\n if (!frenzied)\n {\n frenzied = true;\n cursorMinigame();\n if (frenzyClicker <= 47){Game.Win('That\\'s the stuff');}\n if (frenzyClicker <= 31){Game.Win('Technological singularity');}\n }\n }\n //Dad it's the washing machine please go to sleep now.\n else if(frenzied)\n {\n frenzied = false; \n cursorMinigame();\n }\n }\n\n }\n}", "title": "" }, { "docid": "0f113312f3f6b57a78d276a3a25ef183", "score": "0.5327217", "text": "function box_open(){\n\t\t\tconsole.log(setFlag);\n\t\t\tlet count=1;\n\t\t\tsetFlag(count);\n\t\t\tTweenMax.to('.main_container',{css:{background:\"black\"}});\n\t\t\tdocument.getElementById(\"yo1\").style.display='none';\n\t\t\tdocument.getElementById(\"yo2\").style.display='none';\n\t\t\tdocument.getElementById(\"yo3\").style.display='none';\n\t\t\tdocument.getElementById(\"yo\").style.display='flex';\n}", "title": "" }, { "docid": "2fb4b45cb3265037d8d6ec7d3467362f", "score": "0.5325643", "text": "function click(square) {\n let currentId = square.id\n if (isGameOver) return\n if (square.classList.contains('checked') || square.classList.contains('flag')) return\n if (square.classList.contains('bomb')) {\n gameOver(square)\n } else {\n let total = square.getAttribute('data')\n if (total != 0) {\n square.classList.add('checked')\n square.innerHTML = total\n return\n }\n checkSquare(square, currentId)\n }\n square.classList.add('checked')\n}", "title": "" }, { "docid": "a9e75167d652dd494abc75b1e5144579", "score": "0.5325253", "text": "function focus() {\r\n $('#god').append(\" Pow!!!\");\r\n }", "title": "" }, { "docid": "406bb4f6766a0681a91cae3dd9f70943", "score": "0.53245264", "text": "draw() {\n const menu = document.getElementById('game-start-menu');\n menu.classList.add('active');\n this.clickHandler();\n }", "title": "" }, { "docid": "4f332db0a32a846e0ebb9248301512ab", "score": "0.53240734", "text": "function clickEvent(node){\n var parent = node.parentNode;\n var grandParent = parent.parentNode;\n if (grandParent.getAttribute(\"id\") == \"palette\"){\n setCurrentColor(window.getComputedStyle(node).backgroundColor);\n changePoint (getCurrentColor(), document.getElementById(\"currentColor_r0c0\"), \"black\");\n }\n if (grandParent.getAttribute(\"id\") == \"canvas\"){\n if (isFlood()){\n floodFill(node, window.getComputedStyle(node).backgroundColor, getCurrentColor());\n setFlood(false);\n }\n else {\n changePoint (getCurrentColor(), node, \"black\");\n }\n }\n }", "title": "" }, { "docid": "6cdb8d2f126b4c9af6bf5596de9d64e6", "score": "0.5319028", "text": "function onClick(event) {\n function assignSymbols(event) {\n const $symbol = $(event.target).closest('.choice');\n symbol.human = $symbol.attr('id') === 'o' ? 'O' : 'X';\n symbol.computer = symbol.human === 'O' ? 'X' : 'O';\n }\n\n if (animPaused) {\n assignSymbols(event);\n events.emit('newScreen');\n board = new Board();\n turnAI = false;\n if (Math.random() < 0.5) window.setTimeout(() => drawSymbolAI(true), 2900);\n }\n }", "title": "" }, { "docid": "13398b5fe642fa898aef05cca9449229", "score": "0.53153694", "text": "function clicked(){\n //if game hasn't started yet, start the timer\n if(!gameStart){\n gameStart= true;\n setInterval(setTime, 1000);\n }\n\n //if game over do nothing\n if(gameOver){\n return false;\n }\n //if the cell is already flagged do nothing\n if(this.classList.contains('flagged')){\n return false;\n }\n //if cell has bomb end game\n const count=Number(this.getAttribute('count'));\n if (this.classList.contains('bomb')){\n this.innerHTML='&#11044;'\n triggerAllBombs();\n gameOver = true;\n message = document.querySelector('.message');\n message.innerHTML = 'BOOM goes the landmine';\n message.classList.add('loss');\n // alert('Game over');\n }\n //if cell contains bomb display count on click\n else if(count!=0){\n this.innerHTML=count;\n }\n else if(count===0){\n setTimeout(recursiveCheckNeighbors(this),10);\n }\n\n //paints the cell as clicked\n this.classList.add('clicked');\n }", "title": "" }, { "docid": "d341e2384bd127bd43fa867d055a5025", "score": "0.53138036", "text": "function turnClick(square){\n\tif (typeof tableroOriginal[square.target.id] == 'number'){\n\t\tturn(square.target.id, jugador); \n\t\tif (!revisarEmpate()) turn(bestSpot(), inteligencia);\n\n\t}\n\n\n}", "title": "" }, { "docid": "9054b68cb04b8a04399c8a97901c22cc", "score": "0.53131795", "text": "function interArrowDownClick() {\n\t//removeBulletPoints(\"bullet__prog\" , \"programming__list\");\n\tlistVerticalDisplay(\"elem__inter\", \"interview__list\");\n\tputArrowUp(\"arrow__button__interview\");\n\taddFadeIn(\"elem__inter\");\n\t//alert(\"merge\");\n\taddCoursesBackGround(\"interview\");\n\tshowTextProject(\"elem__text__inter\");\n}", "title": "" }, { "docid": "a4905f38802e51d1ab323681b60ba2a2", "score": "0.531045", "text": "function goal_function(countOfShorts, countOfGoals) {\n let result = Math.random();\n let goalInClick;\n\n console.log(\"result : \" + result);\n\n if (result >= 0.5) {\n goalInClick = 0;\n console.log(\"goalInClick :\" + goalInClick);\n } else {\n goalInClick = 1;\n console.log(\"goalInClick :\" + goalInClick);\n }\n countOfShorts += 1;\n countOfGoals += goalInClick;\n\n arr = [countOfShorts, countOfGoals];\n\n return arr;\n}", "title": "" } ]
0f27427f723170e5aa48859523e046d1
TODO move to App
[ { "docid": "0df150991d593985419b0e7ed224cdc5", "score": "0.0", "text": "handleClick(){\n this.props.ws.send(JSON.stringify({\n id:1, \n from:this.props.userId, \n _type:\"LessonStartRequest\"}\n ))\n console.log(\"Button Pressed\")\n}", "title": "" } ]
[ { "docid": "7b169a3d3a4c1ec3d46594ec531462cb", "score": "0.6229893", "text": "function App(){}", "title": "" }, { "docid": "fc402b000e0d60f40628d7687bc7be82", "score": "0.610911", "text": "function App() { }", "title": "" }, { "docid": "5dbfaa6e9822d00957c0fcf47b5bea38", "score": "0.59900063", "text": "static getApp () {\n return app\n }", "title": "" }, { "docid": "36c9fdc84ec01a61b9a712ebb384b02a", "score": "0.5885347", "text": "function Application(){\n\t\t\n\t\t\n\t}", "title": "" }, { "docid": "55d964ec0cd321a561b8693803d56cb6", "score": "0.5788524", "text": "function onAppReady() {\n \n}", "title": "" }, { "docid": "980cb84687bfcd8f7e804acc96fa527d", "score": "0.5787787", "text": "startApp() { }", "title": "" }, { "docid": "bb40eea72dcdb2c245dd819d440f82f4", "score": "0.57782793", "text": "function App() {\r\n\t\tcontext = getCanvas();\r\n\r\n\t}", "title": "" }, { "docid": "73c276ff880c7cbd1b95c6cc16cef546", "score": "0.5650926", "text": "function App(){\n\n\t//this.init();\n}", "title": "" }, { "docid": "f3c03b281aab78ae07328de6ef54bc1a", "score": "0.5636794", "text": "function runApp( $log ) {\n\n\t\t\n\n\t}", "title": "" }, { "docid": "0e2038d4afbfb13594b9abbabf0172f8", "score": "0.5618027", "text": "function getApp() {\n return app;\n}", "title": "" }, { "docid": "30504d6c01e570d99d71d7a425f1b4be", "score": "0.56014454", "text": "function main() {\r\n giphy.getData().then(res => {\r\n console.log('From App.js', res);\r\n ui.showdata(res.data);\r\n });\r\n}", "title": "" }, { "docid": "acffe366305a123ddf65c9f97713c0bb", "score": "0.55814946", "text": "function ___PRIVATE___(){}", "title": "" }, { "docid": "2e13e42612e2ec51d121044dcf4451fa", "score": "0.5552036", "text": "oncreate () {}", "title": "" }, { "docid": "46754555b2ac109c996a0c3af6a3cc12", "score": "0.5513424", "text": "constructor(app) {\n super(app);\n }", "title": "" }, { "docid": "62e1a59b0082804dda3382fecd762db6", "score": "0.5466703", "text": "onReady() { }", "title": "" }, { "docid": "0186459e4ce622a72f71947a8077227c", "score": "0.5444466", "text": "init() {\n\n\t}", "title": "" }, { "docid": "1130fbfe8de4fecdac8aee86c49c7948", "score": "0.5427238", "text": "onInit() { }", "title": "" }, { "docid": "a2cd16bdc6675c54f0c9d1a32d7b8319", "score": "0.5414774", "text": "function createApp() {\n // ...\n}", "title": "" }, { "docid": "732da2c03889234a9a993613491d4f92", "score": "0.541153", "text": "appLoader() {\n var msg = { 'title': 'Application Data Loaded ', 'msg': '' }\n this.props.triggerLoader(false, msg)\n }", "title": "" }, { "docid": "adcb6a1c2cd8feeb7e8202a35d93e946", "score": "0.53879887", "text": "function app () {\n// let appData = {\n// budget: money,\n// timeData: time,\n// expenses: {},\n// optionalExpenses: {},\n// income: [],\n// savings: false,\n// }\n}", "title": "" }, { "docid": "81ca7d6215c1c18a05ae9d367ad6a954", "score": "0.53803056", "text": "onRender() {}", "title": "" }, { "docid": "68696b86cf4922381678ad336febc65a", "score": "0.5363001", "text": "init() { \n \n }", "title": "" }, { "docid": "dae3894c8c7a728f6bc7b7736a3ee7df", "score": "0.53571993", "text": "onInit() {}", "title": "" }, { "docid": "10b6ab01ce81bbddcf4ce7fdcdbdc306", "score": "0.5351237", "text": "getAppOptions() {\n }", "title": "" }, { "docid": "198a3d6f3cdc8f6ba78057d65946c414", "score": "0.53482544", "text": "fwk_app_on_show() {\n this.fwk_app_on_update();\n }", "title": "" }, { "docid": "1e08ba2cc57742888ecd8cc29cabc3ff", "score": "0.5330484", "text": "function appusers(){}", "title": "" }, { "docid": "a73ed9f76d16d5533192777d7070f623", "score": "0.5327837", "text": "_onRender() {}", "title": "" }, { "docid": "146ff6f46ef3d42f19b4c37c46290fee", "score": "0.5326992", "text": "function PitotiAR() {\n BaseApp.call(this);\n}", "title": "" }, { "docid": "4607f77e0b77d064557277565ec8b11d", "score": "0.5325", "text": "function api () {}", "title": "" }, { "docid": "fc5fa1f08960654ce0328c160924a593", "score": "0.52955484", "text": "constructor(appRef) { }", "title": "" }, { "docid": "fc5fa1f08960654ce0328c160924a593", "score": "0.52955484", "text": "constructor(appRef) { }", "title": "" }, { "docid": "fc5fa1f08960654ce0328c160924a593", "score": "0.52955484", "text": "constructor(appRef) { }", "title": "" }, { "docid": "fc5fa1f08960654ce0328c160924a593", "score": "0.52955484", "text": "constructor(appRef) { }", "title": "" }, { "docid": "da2495e1c28fff848971227c0589bfca", "score": "0.5293594", "text": "constructor() {\n this.app = null;\n }", "title": "" }, { "docid": "8e0c38b1ecf44d72d0e16905036f94fc", "score": "0.5291279", "text": "onRender(){\n\t\t\n\t}", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "b847d12db3d5c5eb7c351a789c15a163", "score": "0.5290394", "text": "constructor() {\n \n \n \n }", "title": "" }, { "docid": "3760b667b62cee6c76949c8f0c0117cd", "score": "0.52710825", "text": "function AppStartApp() {\n\t// Ajout du boutton menu\n\tBuildPageMenu();\n\t// Construire la premiere page de l'application\n\tBuildFirstScreen();\n}", "title": "" }, { "docid": "fce36aa8f2cee9153ecfeba1f24bd4f1", "score": "0.52648175", "text": "get Base() {\n return this.app;\n }", "title": "" }, { "docid": "d25ea80f6d509741d89af23d22af5488", "score": "0.52521044", "text": "getApp () {\n return {\n state: this.state,\n setState: this.setState.bind(this),\n }\n }", "title": "" }, { "docid": "6bfa2715be4bc3ed814e97fc202bb936", "score": "0.52439564", "text": "render() {\n \n }", "title": "" }, { "docid": "1a9a279c92e2fe66760b4a5a62497255", "score": "0.52386576", "text": "function App() {\n return (\n <ApplicationViews />\n );\n}", "title": "" }, { "docid": "b0f94e6b1b64d576699d6248aa903522", "score": "0.52382934", "text": "function App() {\r\n\r\n var debug = true;\r\n this.startFile;\r\n this.simpleViewer;\r\n this.viewers = [];\r\n this.activeViewer;\r\n\r\n this.init = function(){\r\n ContextManager().init(onContextReady);\r\n } \r\n\r\n this.getDomPath = function(el) {\r\n var stack = [];\r\n while ( el.parentNode != null ) {\r\n var sibCount = 0;\r\n var sibIndex = 0;\r\n for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {\r\n var sib = el.parentNode.childNodes[i];\r\n if ( sib.nodeName == el.nodeName ) {\r\n if ( sib === el ) {\r\n sibIndex = sibCount;\r\n }\r\n sibCount++;\r\n }\r\n }\r\n if ( el.hasAttribute('id') && el.id != '' ) {\r\n stack.unshift(el.nodeName.toLowerCase() + el.id);\r\n } else if ( sibCount > 1 ) {\r\n stack.unshift(el.nodeName.toLowerCase() + sibIndex);\r\n } else {\r\n stack.unshift(el.nodeName.toLowerCase());\r\n }\r\n el = el.parentNode;\r\n }\r\n return stack.slice(1); // removes the html element\r\n } \r\n\r\n //when all the common objects are ready and the assets are available\r\n function continueInit() {\r\n this.locale = new WLLocale();\r\n this.locale.init();\r\n this.simpleViewer = new SimpleViewer();\r\n this.simpleViewer.init();\r\n }\r\n\r\n function onContextReady() {\r\n continueInit();\r\n }\r\n\r\n //debug conditionnal logging\r\n this.trace = function (_msg) {\r\n if (debug) {\r\n console.log(\"WPAPP - \" + _msg);\r\n }\r\n }\r\n\r\n }", "title": "" }, { "docid": "7c7cd2808ecab0cbd844549068f1c67e", "score": "0.52212596", "text": "function init() { \n \n }", "title": "" }, { "docid": "6445e3bdb9a1ca5f52a0ac4fe84c7885", "score": "0.5214172", "text": "function App(){\n return(\n <div>\n <ShoppingList name=\"@luispagarcia on Dev.to!\"/>\n </div>\n )\n}", "title": "" }, { "docid": "20834015f208eb3a9e41b31a1e7288b0", "score": "0.5203483", "text": "onReady() {\n\n }", "title": "" }, { "docid": "298ad02bec1400f797082ef46a6c6920", "score": "0.51906115", "text": "_extractAppMenu(app) {\n return {\n name: app.label ? app.label : app.name,\n path: `/${String(app.name).toLowerCase()}`,\n description: '',\n short_description: '',\n sort: app.sort,\n icon: '',\n };\n }", "title": "" }, { "docid": "55b40556b79530c864ad4d3eb064cbd2", "score": "0.5183798", "text": "async homePageStarter() {\n this.createAppProps();\n //console.log(\"test440 appPropsGetter\", this.appPropsGetter());\n // *** create the state and the parameters needed by PRNApp to start\n // *** and stores them in this.appProps\n this.launchReact(this.appPropsGetter());\n this.querySourceHandler(); //***check for keywords in url bar\n await this.trackingInit();\n this.getDataByQuery();\n //this.sessionTracker(); //***TODO THIS DOESNOT SEEMS THE BEST PLACE TO START IT\n return;\n }", "title": "" }, { "docid": "5c4d25e14e09f003a64419e92f840d47", "score": "0.51835054", "text": "onViewInfo() {\n\t\tthis.toggleMenu();\n\t\tFSBL.Clients.LauncherClient.showWindow(\n\t\t\t{\n\t\t\t\tcomponentType: \"App Catalog\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tmonitor: \"mine\",\n\t\t\t\tstaggerPixels: 0,\n\t\t\t\tspawnIfNotFound: true,\n\t\t\t\tleft: \"center\",\n\t\t\t\ttop: \"center\"\n\t\t\t}, (error) => {\n\t\t\t\t// Publish this event so that catalog knows\n\t\t\t\t// what app we want to view\n\n\n\t\t\t\t//NOTE: While not ideal, without a small delay (when having to launch the app catalog) the app catalog wont receive the message as it will still be initializing\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tFSBL.Clients.RouterClient.transmit(\"viewApp\", {\n\t\t\t\t\t\tapp: this.props.app\n\t\t\t\t\t});\n\t\t\t\t}, 250);\n\t\t\t});\n\t}", "title": "" }, { "docid": "4cc4002ea8f5ad6cf92464233c7130dd", "score": "0.51834995", "text": "constructor(application: Application) {\n this.application = application;\n }", "title": "" }, { "docid": "ddc9efad6ee23b5942a39b36357b041d", "score": "0.517898", "text": "function initializeAppViews() {\n\n \tif(!View.mainThumbnailOutput) {\n\t\tView.mainThumbnailOutput = document.getElementById(View.id.mainThumbnailOutput);\n\t}\n\n\tif(!View.mainFriendsListArea) {\n\t\tView.mainFriendsListArea = document.getElementById(View.id.mainFriendsListArea);\n\t}\n\n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "306a6831588985655a0f9fa260ba672f", "score": "0.51773596", "text": "constructor() {\n \n }", "title": "" }, { "docid": "f6ebf6494d051ee55e9884ed0c7bb020", "score": "0.51771826", "text": "get app() {\n return this.game\n }", "title": "" }, { "docid": "c49c4b4fcd8265e36451b29d3e828b15", "score": "0.51744545", "text": "if (mServices.size() > 0) {\n ApplicationInfo ai = mServices.values().iterator().next()\n .mServiceInfo.applicationInfo;\n mPackageInfo = ai;\n mDisplayLabel = mPackageInfo.loadLabel(pm);\n mLabel = mDisplayLabel.toString();\n return;\n }", "title": "" } ]
7e196a918c7d92599465e523ec712fce
create the game board
[ { "docid": "300aab0f0c9d6f2d6362167d2b03b986", "score": "0.0", "text": "function createBoard(){\n for(let i=0;i<cardArray.length;i++)\n {\n var card=document.createElement('img');//creating new HTML tag\n card.setAttribute('src','images/blank.png');\n card.setAttribute('data-id',i);\n card.addEventListener('click',flipcard);\n grid.appendChild(card);//all these img tags go under the grid div \n }\n}", "title": "" } ]
[ { "docid": "7bd1858fbbc2aec8f852675527767d0c", "score": "0.8134585", "text": "function createDrawBoard() {\n\n }", "title": "" }, { "docid": "1be0902445984f0024e5722d62e0aa38", "score": "0.8104859", "text": "createGameBoard() {}", "title": "" }, { "docid": "684f71ed8b08e179f9ff249a441e1b51", "score": "0.81008315", "text": "function createBoard(){\n\t\tgameMode = \"\";\n\t\tvar mainBoard, gameTable, gameRow, gameCell, gameText;\n\t\tvar cellNumber = 0;\n\t\tvar gameTitle = [\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"];\n\t\t\n\t\tmainBoard = document.getElementById(\"mainTag\");\n\t\tmessage = document.createElement(\"p\");\n\t\tmessage.id = \"message\";\n\t\tmainBoard.appendChild(message);\n\t\tgameTable = document.createElement(\"table\");\n\t\tmainBoard.appendChild(gameTable);\n\t\tfor(var i = 0; i < 3 ; i++)\n\t\t{\n\t\t\tgameRow = document.createElement(\"tr\");\n\t\t\tgameTable.appendChild(gameRow);\n\t\t\tfor(var j = 0; j < 3; j++)\n\t\t\t{\n\t\t\t\tgameCell = document.createElement(\"td\");\n\t\t\t\tgameRow.appendChild(gameCell);\n\t\t\t\tgameCell.setAttribute(\"class\", \"gameCells\");\n\t\t\t\tgameCell.id = (\"td\"+cellNumber);\n\t\t\t\tgameText = document.createTextNode(gameTitle[i + (j*3)]);\n\t\t\t\tgameCell.appendChild(gameText);\n\t\t\t\tcellNumber++;\n\t\t\t}\n\t\t}\n\t\tdocument.getElementById(\"message\").innerHTML = \"<br/>\";\n\t}", "title": "" }, { "docid": "6285d4977c6432fbeb54e55011672077", "score": "0.8039013", "text": "function createBoard() {\n\t// Create empty 8x8 grid\n\tlet board = [];\n\tfor (let file=0; file<8; ++file) {\n\t\tboard.push(new Array(8));\n\t}\n\t\n\t// Put pieces in default positions\n\tfor (let combo of [{rank:0,color:\"light\"}, {rank:7,color:\"dark\"}]) {\n\t\tboard[0][combo.rank] = {type:\"rook\", color:combo.color};\n\t\tboard[1][combo.rank] = {type:\"knight\", color:combo.color};\n\t\tboard[2][combo.rank] = {type:\"bishop\", color:combo.color};\n\t\tboard[3][combo.rank] = {type:\"queen\", color:combo.color};\n\t\tboard[4][combo.rank] = {type:\"king\", color:combo.color};\n\t\tboard[5][combo.rank] = {type:\"bishop\", color:combo.color};\n\t\tboard[6][combo.rank] = {type:\"knight\", color:combo.color};\n\t\tboard[7][combo.rank] = {type:\"rook\", color:combo.color};\n\t}\n\t\n\tfor (let file=0; file<8; ++file) {\n\t board[file][1] = {type:\"pawn\",color:\"light\",hasMoved:false};\n\t\tboard[file][6] = {type:\"pawn\",color:\"dark\",hasMoved:false};\n\t}\n\t\n\treturn board;\n}", "title": "" }, { "docid": "34d6c5ca3e109773cae592338c63d2a1", "score": "0.8027155", "text": "function createBoard()\n{\n\tvar i, j, mainBoardCell, mainBoardDragCell, mainBoardDragCellClass, mainBoardCellClass, colorBlack;\n\n\t//Alternate the colors on the board\n\tcolorBlack = false;\n\n\tmainBoardDragCellClass = \"main-board-drag-cell\";\n\t//Chess board: 8x8\n\tfor (i = 0; i < 8; i++) \n\t{\t\n\t\tfor (j = 0; j < 8; j++) \n\t\t{\n\t\t\tif (colorBlack)\n \t\t\tmainBoardCellClass = \"main-board-cell-black\";\n \t\telse\n \t\t\tmainBoardCellClass = \"main-board-cell-white\";\n \t\t//First coloured layer\n \t\tcreateCell(\"#main-board\", mainBoardCellClass, i+\"\"+j);\n \t\t//Second transparent layer\n \t\tcreateCell(\"#\"+i+\"\"+j, mainBoardDragCellClass, \"d\"+i+\"\"+j);\n \tasignCellImageO(i,j);\n \tcolorBlack = !colorBlack;\n\t\t}\n\t\tcolorBlack = !colorBlack;\n } \n}", "title": "" }, { "docid": "417ba241ce02ad4f2f426f556cf5f1a2", "score": "0.79846776", "text": "function createBoard() {\n for (let i = 0; i < boardSize; i++) {\n //create element\n const cell = document.createElement('div')\n //set it's values\n cell.classList.add('cell')\n cell.setAttribute('id', 'cell-' + [i])\n grid.appendChild(cell) //add it to the grid\n }\n makeWalls() //add walls based on the wall array\n showElement('#start') //show start button\n }", "title": "" }, { "docid": "e958134bdb5b85c002b5c16d4c852565", "score": "0.7978603", "text": "function make_board () {\n\n\t\tfor (var i = 0; i < 6; i++) {\n\n\t\t\tfor (var j = 0; j < 7; j++) {\n\n\t\t\t\t// make a board with 7 columns and 6 rows, and assign them with the corresponding column and row numbers.\n\t\t\t\t// give all of them with the data-name \"nothing\". the data-name will change when that particular spot is taken.\n\t\t\t\tvar $circle = $(\"<div class = 'circle' data-name = 'nothing'></div>\");\n\t\t\t\t$circle.addClass(\"col-\" + j);\n\t\t\t\t$circle.addClass(\"row-\" + i);\n\t\t\t\t$row.append($circle);\n\t\t\t\t$row.css(\"background-color\", \"#FFDF00\");\n\n\t\t\t}\n\n\t\t}\n\n\t\t// give data-value (0-41) to all spots (circles).\n\t\tvar $circles = $(\".circle\");\n\n\t\tfor (var i = 0; i < $circles.length; i++) {\n\n\t\t\t$circles.eq(i).attr(\"data-value\", i);\n\n\t\t}\n\n\t\tif (num_of_players === 2) {\n\n\t\t\ttwo_players_move ();\n\n\t\t} else {\n\n\t\t\tcomputer_move ();\n\t\t\tplayer_move ();\n\n\t\t}\n\n\t}", "title": "" }, { "docid": "47826f279114204cab52bb7e0322b74b", "score": "0.7917576", "text": "function createBoard(rows, columns) {\n //Not needed, board creates on initialization\n}", "title": "" }, { "docid": "0f83fd45d74c16e8039115a526f16466", "score": "0.7907059", "text": "function createBoard() {\n board.innerHTML= '';\n for (let i = 0; i < BOARD_INFOS.nb_card_width * BOARD_INFOS.nb_card_height; i++) {\n board.appendChild(createCard(i));\n }\n }", "title": "" }, { "docid": "b9662b8148e7c1f8663fc0738b7d70b7", "score": "0.7904815", "text": "createBoard(rows, cols) {\n // style gameboard with correct number of rows and columns\n this.gameboard.style.setProperty('--grid-rows', rows);\n this.gameboard.style.setProperty('--grid-cols', cols);\n\n // create each cell of the board\n for (let c = 0; c < (rows * cols); c++) {\n let cell = document.createElement(\"div\");\n this.gameboard.appendChild(cell).className = \"grid-item\";\n\n // add cell to the game grid\n this.grid.push(cell);\n };\n }", "title": "" }, { "docid": "eb186a9e2aaa11e5f1a2fd390327e066", "score": "0.78780776", "text": "function _makeBoard() {\n if (players[0].getBoard() === undefined) {\n board = new Board(config.height, config.width);\n players[0].setBoard(board);\n fillBoard(board);\n \n } else {\n board = players[0].getBoard();\n }\n // display board for debug purposes\n players[0].score = 0;\n }", "title": "" }, { "docid": "c57afef40c3343cb02af35ae53cda12d", "score": "0.7833631", "text": "function createBoard() {\n for (let i = 0; i < width * width; i++) {\n let square = document.createElement('div');\n square.innerHTML = 0;\n gridDisplay.appendChild(square);\n squares.push(square);\n }\n generate();\n generate();\n }", "title": "" }, { "docid": "00e5b415e235ad58b4e760f90f6e7289", "score": "0.78326714", "text": "function createBoard() {\r\n\r\n /*\r\n Function to randomly place bombs all over the board.\r\n */\r\n const bombsArr = Array(bombAmount).fill('bomb');\r\n\r\n // Create empty array for remaning squares we need to account for.\r\n const emptyArr = Array(width*width - bombAmount).fill('valid');\r\n\r\n // Create a joint array of the empty spaces and the bomb spaces.\r\n const gameArr = emptyArr.concat(bombsArr);\r\n\r\n // Create a shuffled array using the joint array and the Math.random() function.\r\n const shuffledArr = gameArr.sort(() => Math.random() - 0.5);\r\n\r\n /*\r\n Create 100 squares for the gameboard.\r\n Attach id for every square created.\r\n Push it to an array of squares.\r\n */\r\n for(let i = 0; i < width*width; i++) {\r\n\r\n // We create the squares for each iteration to load our gameboard.\r\n const square = document.createElement('div');\r\n\r\n // Using setAttribute() we assign our id for styling and data referencing. i is used for the id.\r\n square.setAttribute('id', i);\r\n\r\n /*\r\n Add the names of the items from the shuffled array as class names to square.\r\n Use classList.add() to add a new class name.\r\n Use the ith index of the shuffledArr to access the bomb or valid field pass it\r\n into the classList.add() method.\r\n */\r\n square.classList.add(shuffledArr[i]);\r\n\r\n // Add the square into the grid.\r\n grid.appendChild(square);\r\n\r\n // Push each square into the array of squares.\r\n squaresArr.push(square);\r\n\r\n // Let's create the left click event listener for each square.\r\n square.addEventListener('click', function(e) {\r\n\r\n // This is executed when a user clicks on a square\r\n click(square);\r\n\r\n });// end addEventListener()\r\n\r\n /**\r\n * Let's call the addFlag() here.\r\n * The user can right click to add a flag to a chosen square.\r\n */\r\n\r\n // Use the in built function oncontextmenu to fire this function on a right click.\r\n square.oncontextmenu = function(e) {\r\n\r\n // Prevent the refresh\r\n e.preventDefault();\r\n\r\n // Add the flag\r\n addFlag(square);\r\n\r\n }// end event function\r\n\r\n }// end for()\r\n\r\n /*\r\n Add numbers to the neighboring squares of the bombs.\r\n If any of the neighbors have a bomb in the North, NorthEast, East, SouthEast, South,\r\n SouthWest, West or NorthWest square, the sum of those bombs will be displayed as a number\r\n in that particular neighbor's box.\r\n Check every square's surrounding 8 squares for bombs.\r\n\r\n I can use a for loop to check the squaresArr.\r\n If the square we are checking is bounded by the game wall, make sure to check the square on the other side.\r\n */\r\n for(let i = 0; i < squaresArr.length; i++) {\r\n\r\n // Start counting the total number of bombs that are adjacent to our neighbor.\r\n let total = 0;\r\n\r\n /*\r\n Using the === and % operator I will do some math to see if a square is on the left or right side.\r\n Numbers on the left wall will be divisible by 10.\r\n Numbers along the right wall will be divisible by the width by -1;\r\n */\r\n \r\n // Check if the square is disible by the width;\r\n const isLeftEdge = i % width === 0;\r\n\r\n // Check if the square is divisible by the width - 1;\r\n const isRightEdge = i % width === width - 1;\r\n\r\n /*\r\n Using width and arithmetic, we can check whether a certain square contains a bomb.\r\n Width will be used to add or subtract 10, changing which row we are looking at in \r\n relation to i.\r\n When we add or subtract 1, we can look to the right of i, or to the left of i.\r\n Combining this logic, we can check all 8 directions or squares that are next to\r\n the ith square.\r\n */\r\n\r\n // If the square does not contain a bomb,\r\n if(squaresArr[i].classList.contains('valid')) {\r\n\r\n // If the square is not next to the left wall and it contains a bomb.\r\n if(i > 0 && !isLeftEdge && squaresArr[i - 1].classList.contains('bomb')) {\r\n\r\n total++; // Increment our total bomb count.\r\n\r\n }// end if\r\n\r\n // If the square is not next to the right wall and it contains a bomb. (Southwest)\r\n if(i > 9 && !isRightEdge && squaresArr[i + 1 - width].classList.contains('bomb')) {\r\n\r\n total++; // Increment total bomb count.\r\n\r\n }// end if\r\n\r\n // Check for a bomb above the current square;\r\n if(i > 10 && squaresArr[i - width].classList.contains('bomb')) {\r\n\r\n total++;\r\n\r\n }// end if\r\n\r\n // Check NorthWest box for a bomb;\r\n if(i > 11 && !isLeftEdge && squaresArr[i - 1 - width].classList.contains('bomb')) {\r\n\r\n total++;\r\n\r\n }// end if\r\n\r\n // Check if there is a bomb to the right;\r\n if(i < 98 && !isRightEdge && squaresArr[i + 1].classList.contains('bomb')) {\r\n\r\n total++;\r\n\r\n }// end if there is a bomb to the South West;\r\n\r\n if(i < 90 && !isLeftEdge && squaresArr[i - 1 + width].classList.contains('bomb')) {\r\n\r\n total++;\r\n\r\n }// end if\r\n\r\n // Check for a bomb to the South East;\r\n if(i < 88 && !isRightEdge && squaresArr[i + 1 + width].classList.contains('bomb')) {\r\n\r\n total++\r\n\r\n }// end if\r\n\r\n // Check if bomb is below.\r\n if(i < 89 && squaresArr[i + width].classList.contains('bomb')) {\r\n\r\n total++;\r\n\r\n }// end if\r\n\r\n // Get the square we are checking and use setAttribute to add the totals so far.\r\n squaresArr[i].setAttribute('data', total);\r\n\r\n }\r\n\r\n }// end for()\r\n\r\n }// end createBoard.", "title": "" }, { "docid": "a6bed4fe4faa075e93efee41bf5f1d71", "score": "0.7831163", "text": "function createBoard() {\n\t\tfor (var i = 0; i < squareCount; i++) {\n\t\t\tvar newSquare = document.createElement('div');\n\t\t\tnewSquare.className = 'game-square square-0';\n\t\t\tgameBoard.push(0);\n\t\t\tsquareElements.push(newSquare);\n\t\t\tboardElement.appendChild(newSquare);\n\t\t}\n\t}", "title": "" }, { "docid": "62e1e3d95ded0a396c9dba5f78da3844", "score": "0.7758186", "text": "function createBoard() {\n for (let x = 1; x < boardWidth + 1; x++) {\n for (let y = 1; y < boardHeight + 1; y++) {\n square = document.createElement('div')\n board.appendChild(square)\n square.className = 'squares'\n square.setAttribute('data-row', x)\n square.setAttribute('data-column', y)\n square.setAttribute('data-mine', 0)\n square.setAttribute('data-nearby-mine-cells', 0)\n }\n }\n board.style.gridTemplateRows = `repeat(${boardHeight}, ${65 / boardHeight}vmin)`\n board.style.gridTemplateColumns = `repeat(${boardWidth}, ${65 / boardHeight}vmin)`\n board.style.fontSize = `${50 / boardWidth}vmin`\n init()\n}", "title": "" }, { "docid": "df42a41489a60fae70cdbdd9569d7758", "score": "0.77175593", "text": "createGame(){\n this.createGameView();\n this.fillEmptyCells()\n this.generateRandomCellNumber(this.emptyCells);\n this.addActionsForCells()\n }", "title": "" }, { "docid": "3a44cfcc53e0480bd81333af7118870b", "score": "0.7704367", "text": "function newGame() {\n var height = parseInt(document.getElementById(\"height\").value);\n var width = parseInt(document.getElementById(\"width\").value);\n var cut = parseInt(document.getElementById(\"cut\").value);\n var blanktile = parseInt(document.getElementById(\"blank\").value)\n\n //create new game object, then export the parameters to global variables.\n var game = new GameBoard(height,width,cut)\n board = game.boardArray\n globheight = height\n globwidth = width\n globcut = cut\n console.log(game.print())\n\n var windowWidth = window.innerWidth;\n var windowHeight = window.innerHeight\n var cellWidth = Math.min(windowWidth/2,windowHeight/2)/width\n\n\n //loop through the created array to make visible board on page\n var boardWrapper = document.getElementById(\"boardWrapper\");\n \tfor (var i = 0; i<height; i++){\n \tvar row = document.createElement(\"div\");\n \trow.class = \"row\"\n \tfor (var j=0; j<game.boardArray[i].length; j++){\n \t\tvar col = document.createElement(\"div\");\n \t \tcol.style[\"display\"] = \"inline-block\";\n \t \tcol.style[\"width\"] = cellWidth + \"px\";\n \t \tcol.style[\"height\"] = cellWidth + \"px\";\n \t \tcol.style[\"border\"] = \"2px solid black\";\n \t col.style[\"color\"] = \"#2C9090\";\n col.style[\"cursor\"] = \"pointer\";\n //give each square a number that identifies it and ties it to an address in the board array\n // i = row; j = column *in array*\n col.id = i*width+j\n col.className=\"E\"\n col.onmouseover=function(){this.style[\"background-color\"]= \"darkslategrey\"}\n col.onmouseout=function(){colorState(this)}\n col.onclick=function(){mover(this)};\n\t row.appendChild(col)}\n \tboardWrapper.appendChild(row)}\n\n //replace initial button with an instruction\n var instructions = document.getElementById(\"instructions\");\n var oldbutton = document.getElementById(\"button\");\n var buttonDiv = document.getElementById(\"buttonWrapper\")\n buttonDiv.removeChild(oldbutton)\n\n //add instructions to the instructions div\n var centerMessage = document.createTextNode(\"Click on a box to indicate which tile should be left blank:\")\n instructions.style.fontSize = \"20px\";\n instructions.style[\"font-weight\"] = \"bold\";\n var messageWrap = document.createElement(\"div\");\n messageWrap.id = \"msg\"\n messageWrap.appendChild(centerMessage);\n var instructionDiv = document.getElementById(\"instructions\")\n instructionDiv.appendChild(messageWrap);\n\n //add an \"empty board\" and \"newboard\" button\n\n if (blanktile == 1){\n var centerx = Math.floor((globwidth/2))\n var centery = Math.floor((globheight/2))\n var centerAd = [centery,centerx]\n globBlank = centerAd\n populate(centerAd)\n }\n\n }", "title": "" }, { "docid": "699e34f3da64abf5efd012f3d2fb57c2", "score": "0.77032954", "text": "function createBoard() {\n var board = SudokuBoard.generateBoard();\n SudokuBoard.subscribeEvent(SudokuBoard.Public_Events.Game_solved, gameSolvedHandler);\n\n var instructionTemplate = $(Sudoku.templates[\"SudokuInstruction\"]());\n $(sudokuContainerId).append(board)\n .append(instructionTemplate);\n }", "title": "" }, { "docid": "699e34f3da64abf5efd012f3d2fb57c2", "score": "0.77032954", "text": "function createBoard() {\n var board = SudokuBoard.generateBoard();\n SudokuBoard.subscribeEvent(SudokuBoard.Public_Events.Game_solved, gameSolvedHandler);\n\n var instructionTemplate = $(Sudoku.templates[\"SudokuInstruction\"]());\n $(sudokuContainerId).append(board)\n .append(instructionTemplate);\n }", "title": "" }, { "docid": "4950d5ea1701b049f38f006b6fb62bfb", "score": "0.7680355", "text": "function buildBoard(){\r\n\t\tvar x = 0;\r\n\t\tvar y = 0;\r\n\t\t\r\n\t\tvar pieces = [];\r\n\t\tfor(x = 0; x < game.length; x++){\r\n\t\t\tframe[x] = new Array(10);\r\n\t\t\tfor(y = 0; y < game[x].length; y++){\r\n\t\t\t\tswitch(game[x][y]){\r\n\t\t\t\t\tcase 's':\r\n\t\t\t\t\t\t//if(x == 3 )\r\n\t\t\t\t\t\tframe[x][y] = addSquare(x,y,22), mass, 0x00FFFF;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase '#':\r\n\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t\tbreak;\r\n\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// x, y, z, mass, lengthx, lengthy, lengthz\r\n\t\tcorners.push(addCorner(0,1,12, 0, 1, 1, 20));\r\n\t\tcorners.push(addCorner(0,7,12, 0, 1, 1, 20));\r\n\t\tcorners.push(addCorner(7,0,12, 0, 1, 1, 20));\r\n\t\tcorners.push(addCorner(7,7,12, 0, 1, 1, 20));\r\n\r\n\r\n\r\n\t\t\t\t// x, y, z, mass, lengthx, lengthy, lengthz\r\n\r\n\t\t\r\n\t\t\t\t// top and bottom\r\n\t\tsupport.push(addCorner(3.5,7.00,22, 0, 6, 1, 1));\r\n\t\tsupport.push(addCorner(3.5,0,22, 0, 6, 1.05, 1));\r\n\r\n\r\n\t\t// right and left\r\n\t\tsupport.push(addCorner(7,3.5,22, 0, 8, 1.05, 1));\r\n\t\tsupport.push(addCorner(0,3.5,22, 0, 8, 1, 1));\r\n\t\t\r\n\t\tmiddleSquare = addShader(3.5,3.5,22,mass,2,2,1);\r\n\t\tmiddleSquare.name = \"middleSquare\";\r\n\r\n\r\n\t\t\r\n\r\n\t}", "title": "" }, { "docid": "13f54a703b7960fa5c618073bc7c99e5", "score": "0.768024", "text": "create() {\n this.board = [];\n \n for (let i = 0; i < this.boardSize; i++) {\n let newArr = [];\n \n for (let j = 0; j < this.boardSize; j++) {\n newArr.push(new Cell(i, j));\n }\n \n this.board.push(newArr);\n }\n \n canvas.updateCellSize(this.getCellsInRow());\n this.draw();\n }", "title": "" }, { "docid": "f972ef2a3718c46ea342b918bac8955d", "score": "0.76699567", "text": "function createGame() {\r\n\t\tvar tiles = document.querySelectorAll(\"#puzzlearea .tiles\"); // get all tile div\r\n\t\tvar row = 0;\r\n\t\tvar col = 0;\r\n\t\tfor (var i = 0; i < tiles.length; i++) {\r\n\t\t\ttiles[i].style.left = Math.abs(col) + \"px\"; // set location of tiles\r\n\t\t\ttiles[i].style.top = Math.abs(row) + \"px\";\r\n\t\t\ttiles[i].style.backgroundPosition = col + \"px \" + row + \"px\"; // sets portion of pic\r\n\t\t\ttiles[i].id = \"tiles_\" + Math.abs(col/pixel) + \"_\" + Math.abs(row/pixel);\r\n\t\t\tcol -= pixel;\r\n\t\t\t// change if statement, if 4x4, then i % 4 == 3\r\n\t\t\tif ((i % size) === (size - 1)) { // reset, like a typewriter \r\n\t\t\t\tcol = 0;\r\n\t\t\t\trow -= pixel;\r\n\t\t\t}\r\n\t\t}\r\n\t}", "title": "" }, { "docid": "af2f2aff8b9a9879621712663a7e35b5", "score": "0.7648865", "text": "function createBoard() {\n let cardNumber;\n const easyCardNumber = 9;\n const hardCardNumber = 12;\n if (easy) {\n cardNumber = easyCardNumber;\n } else {\n cardNumber = hardCardNumber;\n }\n for (let i = 0; i < cardNumber; i++) {\n let cards = generateUniqueCard(easy);\n qs(\"#game-view #board\").appendChild(cards);\n }\n qs(\"#game-view #details-bar #back-btn\").addEventListener('click', backButton);\n }", "title": "" }, { "docid": "bc5b10e30f766b76bff945976b78950f", "score": "0.7648371", "text": "function makeBoard() {\n for (let y = 0; y < HEIGHT; y++) {\n board.push(Array.from({ length: WIDTH }));\n }\n makeHtmlBoard();\n}", "title": "" }, { "docid": "901e6832b5e12e8d8df97574fa9840ec", "score": "0.7642253", "text": "function makeBoard() {\n // TODO: set \"board\" to empty HEIGHT x WIDTH matrix array\n\n // Creates a for loop initialized at 0, using y as an index limited by the global variable \"HEIGHT\", iterating one positive unit per loop; to represent all individual cells along the y-axis\n for (let y = 0; y < HEIGHT; y++) {\n // For each iteration of parent loop, pushes an array with a length defined by the value of the global variable \"WIDTH\" onto the global variable \"board\"; to represent all individual cells along the x-axis and create the in-JS board structure as this array is extrapolated from each unit on the y-axis \n board.push(Array.from({ length: WIDTH }));\n }\n}", "title": "" }, { "docid": "e8ed0c1dd457d0de435c74babd53310e", "score": "0.76290566", "text": "function setupBoard() {\n state.board = new Array(Number(state.size) * Number(state.size)).fill(\"\");\n board.style = `grid-template-columns: repeat(${state.size}, 1fr)`;\n\n for (let i = 0; i < state.board.length; i++) {\n let div = document.createElement(\"div\");\n div.classList.add(\"cell\");\n div.setAttribute(\"data-index\", i);\n board.append(div);\n }\n\n inGamePage.classList.remove(\"hide\");\n message.classList.remove(\"hide\");\n setupGamePage.classList.add(\"hide\");\n}", "title": "" }, { "docid": "7d099297ebeceae2e229c423df6299d5", "score": "0.7608403", "text": "drawBoard () {\n\t\tfor (var i = 0; i < this.boardHeight; i++) {\n\t\t\tthis.gameBoard[i] = [];\n\t\t\t\n\t\t\tlet gameRow = document.createElement (\"div\");\n\t\t\tgameRow.classList.value = \"game-row row-\" + i;\n\t\t\t\n\t\t\tfor (var k = 0; k < this.boardWidth; k++) {\n\t\t\t\tthis.gameBoard[i][k] = this.TILE_EMPTY;\n\t\t\t\t\n\t\t\t\tlet gameTile = document.createElement (\"div\");\n\t\t\t\tgameTile.classList.value = \"tile tile-\" + k;\n\t\t\t\t\n\t\t\t\tgameRow.appendChild (gameTile);\n\t\t\t}\n\t\t\t\n\t\t\tthis.$gameBoard.appendChild (gameRow);\n\t\t}\n\t}", "title": "" }, { "docid": "bf06c9983a48b2a4b774c593c83512aa", "score": "0.76067895", "text": "function board()\n {\n var _div = $('<div>')\n .attr(\"id\", \"board\")\n .attr('tabindex','1')\n .height(_boardSize)\n .width(_boardSize)\n .css({\n \"background-color\":'white',\n 'margin':'auto'\n });\n $('#'+_gameObject).append(_div);\n }", "title": "" }, { "docid": "07e27026ceec883becb6397083afe820", "score": "0.7589692", "text": "function createGameBoard() {\n // creo los cuadrados que vana a ser minas y los que van a ser nada\n const mineArray = Array(mines).fill(\"mines\");\n const safeBoxArray = Array(width * width - mines).fill(\"safeBox\");\n\n // mezclo estos 2 arrays para tener como va a quedar las bombas en mi tablero y lo mezclo\n const gameBoardArray = safeBoxArray.concat(mineArray);\n const finalShuffledGBArray = gameBoardArray.sort(() => Math.random() - 0.5);\n\n // creo Divs dentro de mi div con class grid eL tablero con tamaño previamente definido en width\n for (let i = 0; i < width * width; i++) {\n const box = document.createElement(\"div\");\n box.setAttribute(\"id\", i);\n box.classList.add(finalShuffledGBArray[i]);\n grid.appendChild(box);\n boxes.push(box);\n\n // click Izquiedo\n box.addEventListener(\"click\", function (e) {\n click(box);\n });\n // click derecho\n document.addEventListener(\"contextmenu\", function (e) {\n e.preventDefault();\n addFlag(box);\n });\n }\n\n // Agregar numeros a los cuadrados cercanos a las minas.\n //Teniendo en cuenta que los cuadrados que estan en los bordes no sumen doble.\n for (let i = 0; i < boxes.length; i++) {\n var total = 0;\n const leftEdge = i % width === 0;\n const rightEdge = i % width === width - 1;\n //esta fue la parte mas dificil es la unica forma que encontre de validar esto :(\n if (boxes[i].classList.contains(\"safeBox\")) {\n if (i > 0 && !leftEdge && boxes[i - 1].classList.contains(\"mines\"))\n total++;\n if (\n i > 9 &&\n !rightEdge &&\n boxes[i + 1 - width].classList.contains(\"mines\")\n )\n total++;\n if (i > 10 && boxes[i - width].classList.contains(\"mines\")) total++;\n if (\n i > 11 &&\n !leftEdge &&\n boxes[i - 1 - width].classList.contains(\"mines\")\n )\n total++;\n if (i < 98 && !rightEdge && boxes[i + 1].classList.contains(\"mines\"))\n total++;\n if (\n i < 90 &&\n !leftEdge &&\n boxes[i - 1 + width].classList.contains(\"mines\")\n )\n total++;\n if (\n i < 88 &&\n !rightEdge &&\n boxes[i + 1 + width].classList.contains(\"mines\")\n )\n total++;\n if (i < 89 && boxes[i + width].classList.contains(\"mines\")) total++;\n boxes[i].setAttribute(\"data\", total);\n }\n }\n }", "title": "" }, { "docid": "3b1f48efbfc1d9b0a830eceb8b6f3055", "score": "0.7578046", "text": "function createBoard() {\n $(\"#win-area\").empty();\n \n // Building our win/loss display and appending it to the page.\n var wSpan = $(\"<span>\").text(wins);\n var lSpan = $(\"<span>\").text(losses);\n \n var pWins = $(\"<p>\").text(\"Wins: \");\n var pLosses = $(\"<p>\").text(\"Losses: \");\n \n pWins.append(wSpan);\n pLosses.append(lSpan);\n \n $(\"#win-area\").append(pWins);\n $(\"#win-area\").append(pLosses);\n }", "title": "" }, { "docid": "87c5a871b8f8cffcdcb46c618ed457ee", "score": "0.7548541", "text": "function createPieces() {\n board.createPieces();\n}", "title": "" }, { "docid": "de4ce0a10b32fa59a0dd61a99812bb73", "score": "0.75462973", "text": "function buildGame() {\n // game board has gameBoardRatioX by gameBoardRatioY aspect ratio\n var gameBoardRatioX = 2;\n var gameBoardRatioY = 1 ;\n // total number of cells rows on $gameBoard\n var gameBoardRows = Math.floor($gameBoardSize * gameBoardRatioY / gameBoardRatioX);\n var cellTotal = $gameBoardSize * gameBoardRows;\n \n $gameBoard.empty();\n // add cell elements to game board elements\n for (var i = 0; i < cellTotal; i++) {\n if (selectedSize === \"sm\") {\n var newCell = \"<a><button class=\\\"cell cell-sm\\\"></button></a>\";\n } else if (selectedSize === \"lg\") {\n var newCell = \"<a><button class=\\\"cell cell-lg\\\"></button></a>\";\n } else { // game board defaults to md size\n var newCell = \"<a><button class=\\\"cell cell-md \\\"></button></a>\";\n }\n \n $gameBoard.append(newCell);\n }\n \n if (selectedSize === \"sm\") {\n clickMax = clickMaxSm;\n clickCount = clickMax;\n } else if (selectedSize === \"lg\") {\n clickMax = clickMaxLg;\n clickCount = clickMax;\n } else { // default to md size\n clickMax = clickMaxMd;\n clickCount = clickMax;\n }\n \n // randomize the color of each cell\n randomizeCells();\n updateStatDisplay();\n \n \n // click handler for drawing on a cell\n $(\".cell\").on(\"click\", darkenCell);\n $(\".cell\").on(\"click\", clickCell);\n \n $($gameBoard).show();\n $($statsBar).show();\n }", "title": "" }, { "docid": "e4f4f288cfe89c6c771502ef234bd4a2", "score": "0.75452954", "text": "function makeBoard() {\n // set \"board\" to empty boardHeight x boardWidth matrix array\n for (let r = 0; r < boardHeight; r++) {\n const row = [];\n for (let c = 0; c < boardWidth; c++) {\n row.push(null);\n }\n board.push(row);\n }\n}", "title": "" }, { "docid": "a896975a2d5ac568e8a8c6463c256606", "score": "0.7532634", "text": "function buildBoard() {\n\tvar board = createMat(10, 12);\n\t// Put FLOOR everywhere and WALL at edges\n\tfor (var i = 0; i < board.length; i++) {\n\t\tfor (var j = 0; j < board[0].length; j++) {\n\t\t\tvar cell = { type: FLOOR, gameElement: null };\n\t\t\tif (i === 0 || i === board.length - 1 ||\n\t\t\t\tj === 0 || j === board[0].length - 1) {\n\t\t\t\tcell.type = WALL;\n\t\t\t\tif (i === 0 && j === 5) cell.type = FLOOR;\n\t\t\t\telse if (i === 9 && j === 5) cell.type = FLOOR;\n\t\t\t\telse if (i === 5 && j === 0) cell.type = FLOOR;\n\t\t\t\telse if (i === 5 && j === 11) cell.type = FLOOR;\n\t\t\t}\n\t\t\tboard[i][j] = cell;\n\t\t}\n\t}\n\t// Place the gamer and two balls\n\tboard[gGamerPos.i][gGamerPos.j].gameElement = GAMER;\n\tboard[2][6].gameElement = BALL;\n\tboard[3][8].gameElement = BALL;\n\treturn board;\n}", "title": "" }, { "docid": "d4c60ceafac3cebb977049f46e2e858d", "score": "0.7527732", "text": "createBoard() {\n let pieceType = 1\n for (let y = 0; y < this.size; y++) {\n for (let x = 0; x < this.size; x++) {\n let tile = new MyTile(\n this.scene,\n this, x, y,\n this.texture)\n let piece = new MyPiece(\n this.scene,\n pieceType)\n\n piece.originalX = x\n piece.originalY = y\n\n tile.setPiece(piece)\n piece.setTile(tile)\n this.board.push(tile)\n pieceType = -pieceType\n }\n if (this.size % 2 === 0)\n pieceType = -pieceType\n }\n }", "title": "" }, { "docid": "d8c79a2514973c79cef67583dd40f7ec", "score": "0.7521453", "text": "function generate_board() {\r\n\t//draw background bue color\r\n\tctx.beginPath();\r\n\tctx.fillStyle = 'blue';\r\n\tctx.rect(0,0,canvas.width,canvas.height);\r\n\tctx.fill();\r\n\tctx.stroke();\r\n\r\n\t//add cicles with color based on value\r\n\tfor (var i = 0; i < 7; i++) {\r\n\t\tconst x = (i*Math.floor(canvas.width/7.0)) + canvas.width/14.0;\r\n\t\tvar column = [];\r\n\t\tfor (var j = 0; j < 6; j++) {\r\n\t\t\tconst y = canvas.height - (j*Math.floor(canvas.height/6.0)) - canvas.height/12.0;\r\n\t\t\tvar slot = new Circle(x,y,90,2);\r\n\t\t\tslot.draw();\r\n\t\t\tcolumn.push(slot);\t\t\t\r\n\t\t}\r\n\t\tgameBoard.push(column);\r\n\t}\r\n\r\n}", "title": "" }, { "docid": "99c045f38254da2f3052d2dff68e0606", "score": "0.7515059", "text": "createGrid () {\n const $board = $(this.selector);\n $board.empty ();\n this.isGameOver = false; // to stop the entract with board when its over ..\n this.player = 'red';\n for (let row = 0; row < this.ROWS; row ++) { // to create a rows in grid ..\n const $row = $('<div>')\n .addClass ('row');\n for (let col = 0; col < this.COLS; col ++) { // to create a columns inside each row ..\n const $col = $('<div>')\n .addClass ('col empty')\n .attr ('data-col', col)\n .attr ('data-row', row); // to set a value for each slot ..\n $row.append ($col);\n }\n $board.append($row);\n }\n }", "title": "" }, { "docid": "06f33724e3a235c84c2ec8338e962d64", "score": "0.75129557", "text": "function generateBoard() {\n console.log('generateBoard()');\n const grid = document.getElementById(\"grid\");\n\n // Set width and height by cellSize\n grid.style.width = width * cellSize + \"px\";\n grid.style.height = height * cellSize + \"px\";\n\n // Generate width * height amount of cells\n for (let i = 0; i < width * height; i++) {\n const div = document.createElement(\"div\");\n grid.appendChild(div);\n }\n }", "title": "" }, { "docid": "37cec86c3c7eb0073146986a204ceee2", "score": "0.75118905", "text": "function populateGameBoard() {\n // fill the board with spaces, fill one preview row above the board\n for (let i = 0; i < 7; i++) {\n // fill the preview row with non-playable spaces\n const $previewSpace = $('<div>');\n $previewSpace.addClass('space preview');\n $previewSpace.appendTo($container);\n previewRow[i] = $previewSpace;\n // insert a down arrow into each preview space\n const $downArrow = $('<i>');\n $downArrow.addClass('fas fa-arrow-down');\n $downArrow.addClass('icon arrow');\n $downArrow.appendTo($previewSpace);\n }\n console.table(previewRow);\n\n // store board's elements into the multi-dimensional array: board[row][col]\n for (let i = 0; i < 42; i++) {\n // fill each column with playable spaces\n const $space = $('<div>');\n $space.addClass('space');\n $space.html(i);\n $space.appendTo($container);\n // store each space on the viewable game board into the 2d array\n let row = Math.floor(i / 7);\n let col = i % 7;\n board[row][col] = $space;\n }\n }", "title": "" }, { "docid": "2dd637a13fab7190f5b1bd81dca772ff", "score": "0.7481868", "text": "function NewGame(){\n\tvar board = document.getElementById(\"board\");\n\t\n\t//offset values for positioning the tiles relative to the borders of the board.\n\t//frame width ratio: the ratio of one of the board's frames' width to the board's overall width.\n\tconst frame_w_ratio = 1/50;\n\tvar x_off = board.offsetLeft + board.width*frame_w_ratio;\n\tvar y_off =\tboard.offsetTop + board.width*frame_w_ratio;\n\t\n\t//get the tile width. tile width = tile height.\n\tlet tile_w = document.getElementById(\"tile1\").clientWidth;\n\t\n\t//get an array of unique random integers\n\tlet rndm_int_arr = RandomIntArr(1,9);\n\n\t//set up the tiles on the board. \n\tlet tile_elem; //DOM element\n\tlet i = 0;\n\tfor(i; i<8; i++){//there are 8 tiles, constant.\n\t\ttile_elem = document.getElementById(\"tile\" + String(rndm_int_arr[i]));\n\n\t\t//3 tiles per row -> (i%3)\n\t\ttile_elem.style.left = String(x_off + (i%3) * tile_w) + \"px\";\t\n\t\t//put 3 tiles in a row, drop exactly one tile height and repeat.\n\t\ttile_elem.style.top = String(y_off + ( Math.floor(i/3) * tile_w)) + \"px\";\n\t\t\n\t\ttile_arr[i] = tile_elem;//to be used when moving the tiles around.\n\t}\n\n\tlet nineth_grid_x = String(x_off + 2*tile_w + \"px\");\n\tlet nineth_grid_y = String(y_off + 2*tile_w + \"px\");\n\n\tif(ac || empty_elem){\n\t\tac.remove();\n\t\tempty_elem.remove();\n\t}\n\n\t//Active tile highlighting\n\tActiveTile(tile_w, nineth_grid_x, nineth_grid_y);\n\t//Empty element\n\tEmptyElem(tile_w, nineth_grid_x, nineth_grid_y);\n}", "title": "" }, { "docid": "d4416fe61e56f6fb2e6ecb98cadb200c", "score": "0.7477708", "text": "function generateBoard(evt) {\n while (gameboard.firstChild) {\n gameboard.removeChild(gameboard.firstChild);\n }\n\n gameboard.style.gridTemplateColumns = `repeat(${drpdwn.value}, 1fr)`;\n gameboard.style.gridTemplateRows = `repeat(${drpdwn.value}, 1fr)`;\n\n for (i = 0; i < drpdwn.value * drpdwn.value; i++) {\n let newSquare = document.createElement(\"button\");\n newSquare.innerHTML = \"a\" + i;\n newSquare.classList.add(\"gamebutton\");\n newSquare.id = \"a\" + i;\n newSquare.style.background =\n colors[Math.floor(Math.random() * colors.length)];\n gameboard.appendChild(newSquare);\n }\n\n buttons = [];\n\n for (j = 0; j < drpdwn.value * drpdwn.value; j++) {\n buttons.push(\"a\" + j);\n }\n}", "title": "" }, { "docid": "9e900107ae70912be85ea9caac2a926b", "score": "0.746606", "text": "function createBoard() {\n\tvar i, j, row, et, board, holder, peg, guess;\n\t\n\tboard = document.getElementById(\"board\");\n\t\n\tfor (i = 0; i < 10; i++) {\n\t\trow = document.createElement(\"div\");\n\t\trow.className = \"row\";\n\t\tholder = document.createElement(\"div\");\n\t\tholder.className = \"holder\";\n\t\tfor (j = 0; j < 4; j++) {\n\t\t\tpeg = document.createElement(\"div\");\n\t\t\tpeg.className = \"peg\";\n\t\t\tholder.appendChild(peg);\n\t\t}\n\t\trow.appendChild(holder);\n\t\tfor (j = 0; j < 4; j++) {\n\t\t\tguess = document.createElement(\"div\");\n\t\t\tguess.className = \"guess\";\n\t\t\tguess.addEventListener(\"click\", function (){\n\t\t\t\tcycleUp(this);\n\t\t\t}, false);\n\t\t\tguess.addEventListener(\"contextmenu\", function (e){\n\t\t\t\te.preventDefault();\n\t\t\t\tcycleDown(this);\n\t\t\t}, false);\n\t\t\trow.appendChild(guess);\n\t\t}\n\t\tboard.appendChild(row);\n\t}\n\treturn (board);\n}", "title": "" }, { "docid": "670a683661f77aee9d5d7589e7b7ab6e", "score": "0.745892", "text": "function setupBoard () {\n gameBoard.length = 0\n for (let i = 0; i < rows; i++) {\n let data = []\n for (let j = 0; j < cols; j++) {\n data.push(STR_EMPTY)\n }\n gameBoard.push(data)\n }\n}", "title": "" }, { "docid": "84a021c32924b9468c4342ac5b100a94", "score": "0.7449308", "text": "function createBoard(rows, columns) {\n for (let i = 0; i < rows; i++) {\n board[i] = [];\n for (let j = 0; j < columns; j++) {\n if (i === 0 || j === 0 || i === rows - 1 || j === columns - 1) {\n board[i][j] = {\n type: 'wall',\n position: { row: i, column: j }\n }; \n }\n else {\n board[i][j] = {\n type: 'grass',\n position: { row: i, column: j }\n };\n }\n }\n }\n}", "title": "" }, { "docid": "7e6bafe71db79e0ea85d4fe3ced2db8c", "score": "0.7448332", "text": "function makeBoard() {\n\tfor (let i = 0; i < HEIGHT; i++) {\n\t\tconst innerArr = [];\n\t\tfor (let i = 0; i < WIDTH; i++) {\n\t\t\tinnerArr.push(null);\n\t\t}\n\t\tboard.push(innerArr);\n\t}\n}", "title": "" }, { "docid": "86739b2e2902ec499869daf8bd48a66a", "score": "0.7447303", "text": "function makeBoard() {\n // TODO: set \"board\" to empty HEIGHT x WIDTH matrix array\n for (let y = 0; y < HEIGHT; y++) {\n board.push(Array.from({ length: WIDTH }));\n }\n}", "title": "" }, { "docid": "3b6b29e19f66f3cff9e07f0ece236204", "score": "0.74409616", "text": "function createBoard() {\n const boardInput = document.getElementById(\"task4-board-size\");\n let boardSize = boardInput.value;\n\n removeErrorMessage(boardInput);\n\n if (!isMatch(boardSize, BOARD_SIZE)) {\n addInputErrorHighlight(boardInput);\n addErrorMessage(boardInput, \"Invalid size or more than 99\");\n return;\n }\n\n removeInputErrorHighlight(boardInput);\n\n /* Remove old board */\n const oldBoard = document.querySelector(\".board-container\");\n removeElement(oldBoard);\n\n /* Create new board */\n boardSize = boardSize.split(/[xх]/);\n const rows = boardSize[0];\n const cols = boardSize[1];\n const parent = document.querySelector(\".task4\");\n\n const boardContainer = document.createElement(\"div\");\n boardContainer.classList.add(\"board-container\");\n\n for (let row = 0; row < rows; row++) {\n const boardRow = document.createElement(\"div\");\n boardRow.classList.add(\"board-row\");\n boardContainer.appendChild(boardRow);\n\n for (let col = 0; col < cols; col++) {\n const boardCol = document.createElement(\"div\");\n boardCol.classList.add(\"board-cell\");\n\n if (isEven(row + col)) {\n boardCol.classList.add(\"black-cell\");\n }\n\n boardRow.appendChild(boardCol);\n }\n }\n\n parent.appendChild(boardContainer);\n}", "title": "" }, { "docid": "56a5225e95e973f31a2b15cf0f0f27a8", "score": "0.74367255", "text": "function buildBoard() {\n var html = '';\n for ( var row = 0; row < puzzle.level; row++ ) {\n for ( var col = 0; col < puzzle.level; col++ ) {\n \n // building the div html element\n var tile = puzzle.board[ row ][ col ];\n var div = '';\n var divOpened = '<div';\n var divClass= ' class=\"tile\"'\n // in id we store the position of the tile in the puzzle.tiles array\n // so we can retrieve it easily\n var divId = ` id=\"${ puzzle.tiles.indexOf( tile ) }\"`;\n var divStyle = ` style =\"\n width: ${ tile.side }px;\n height: ${ tile.side }px;\n overflow: hidden;\n background-image: url( ${ tile.bg } );\n background-position-y: ${ tile.bgY }px;\n background-position-x: ${ tile.bgX }px;\n \"`;\n var divClosed = '></div>';\n \n // put all together\n div = divOpened + divClass + divId + divStyle + divClosed;\n html += div;\n } \n }\n // append to the #board div on the page\n $('#board').html( html );\n}", "title": "" }, { "docid": "136462d87b8a04bbdd0e3ed5427f927d", "score": "0.74304", "text": "function buildBoard() {\r\n var board = createMat(gLevel.SIZE, gLevel.SIZE);\r\n\r\n for (var i = 0; i < board.length; i++) {\r\n for (var j = 0; j < board[0].length; j++) {\r\n board[i][j] = createCell(0, false, false, false);\r\n }\r\n }\r\n\r\n //Add mines in empty cells\r\n var emptyCells = getEmptyCells(board);\r\n for (var i = 0; i < gLevel.MINES; i++) {\r\n var emptyCellIdx = drawObject(emptyCells);\r\n board[emptyCellIdx.i][emptyCellIdx.j] = createCell(0, false, true, false);\r\n }\r\n\r\n return board;\r\n}", "title": "" }, { "docid": "1dee9b8039e9e5eff80dcd12d67953d3", "score": "0.7429194", "text": "function createNewBoard() {\n for (var x = 0; x < difficulty; x++) {\n for (var y = 0; y < difficulty; y++)\n board.cells.push({\n row: x,\n col: y,\n isMine: Boolean(Math.round(Math.random() * 0.7)),\n isMarked: false,\n hidden: true\n });\n }\n}", "title": "" }, { "docid": "ff9485ed7efbe7f1e8ce90ef5e7423a9", "score": "0.74278873", "text": "function createBoard(){\t\n\n\t//get seed and set the seed for randomizer\n\tvar gameHash = Math.floor((Math.random() * maxHash) + 1);\n\t\n\tMath.seedrandom(gameHash);\n\n\t//reset state to pristine state\n\tsessionData = data.slice(0);\n\twordsSelected = [];\n\tteamWords = [];\n\t\n\t//Fill wordsSelected array & create 5 table rows with 5 element \n\tfor(var i = 0; i < NUMBER_OF_WORDS; i++){\n\t\t/*if (!trs[i%5]){\n\t\t\ttrs[i%5] = \"\";\n\t\t}*/\n\t\tvar randomNumber = Math.floor(Math.random() * sessionData.length);\n\t\tvar word = toTitleCase(sessionData[randomNumber]);\n\t\t//var word = sessionData[randomNumber];\n\t\tremoveItem(sessionData, randomNumber);\n\t\twordsSelected.push(word.toLowerCase());\n\t\ttrs[i] = \"<div class=\\\"square center\\\"><div class=\\\"content\\\"><div class=\\\"table\\\"><div class=\\\"table-cell\\\"id=\\'\"+ i +\"\\' onclick=\\\"clicked(\\'\" + i + \"\\')\\\"><a href=\\\"#\\\">\" + word + \"</a></div></div></div></div>\";\n\t\t//trs[i] = \"<div class=\\\"tile\\\" id=\\'\"+ i +\"\\' onclick=\\\"clicked(\\'\" + i + \"\\')\\\"><a href=\\\"#\\\">\" + word + \"</a></div>\";\n\t\t//console.log(\"i: \" + i + \" \" + trs[i] + \",\");\n\t}\n\t\n\t//create the colours array\n\tfor(var i = 0; i < WORDS_PER_TEAM; i++){\n\t\tfor (j=0; j<NUM_TEAMS; j++) {\n\t\t\tcolours.push(teamColours[j]);\n\t\t\t//console.log(\"Pushing colour \" + teamColours[j]);\n\t\t}\n\t}\n\t\n\t// one extra for one of the teams\n\t/*var remainder = Math.floor(Math.random() * data.length) % 3;\n\tconsole.log(\"Math.floor(Math.random() * data.length) % 2: \" + remainder);\n\tif(remainder === 0){\n\t\tcolours.push(teamColours[0]);\n\t\tteams[0].target++;\n\t\tconsole.log(\"Incrementing target to \" + teams[0].target);\n\t\twhoseGo = teamNames[0];\n\t\tteams[0].active = true;\n\t\tactiveTeamColour = teamColours[0];\n\t}else if(remainder === 1){\n\t\tcolours.push(teamColours[1]);\n\t\tteams[1].target++;\n\t\twhoseGo = teamNames[1];\n\t\tteams[1].active = true;\n\t\tactiveTeamColour = teamColours[1];\n\t}else if(remainder === 2){\n\t\tcolours.push(teamColours[2]);\n\t\tteams[2].target++;\n\t\twhoseGo = teamNames[2];\n\t\tteams[2].active = true;\n\t\tactiveTeamColour = teamColours[2];\n\t}else {\n\t\tcolours.push(teamColours[3]);\n\t\tteams[3].target++;\n\t\twhoseGo = teamNames[3];\n\t\tteams[3].active = true;\n\t\tactiveTeamColour = teamColours[3];\n\t}*/\t\n\t\n\tvar extraIndex = Math.floor(Math.random() * NUM_TEAMS);\t\n\tconsole.log(\"Extra team id: \" + extraIndex);\n\tcolours.push(teamColours[extraIndex]);\n\tteams[extraIndex].target++;\n\twhoseGo = teamNames[extraIndex];\n\tteams[extraIndex].active = true;\n\tactiveTeamColour = teamColours[extraIndex];\n\tconsole.log(\"Active team colour: \" + activeTeamColour);\n\t\n\tBLANKS = NUMBER_OF_WORDS - ((WORDS_PER_TEAM * NUM_TEAMS) + 1);\n\t// add neturals \n\tfor(var x = 0; x < BLANKS; x++){\n\t\tcolours.push(COLOR_BROWN);\n\t}\n\n\t// push the assasin\n\t//colours.push(COLOR_BLACK)\n\t\n\tshuffle(colours);\n\tinProgress = true;\n\tisPaused = false;\n\tsendTeams();\n}", "title": "" }, { "docid": "3349e5a26963ca0063bc27e41de2d26a", "score": "0.74239707", "text": "function buildBoard() {\n var board = createMat(10, 12);\n var midI = parseInt(board.length / 2);\n var midJ = parseInt(board[0].length / 2);\n\n // Put FLOOR everywhere and WALL at edges\n for (var i = 0; i < board.length; i++) {\n for (var j = 0; j < board[0].length; j++) {\n var cell = { type: FLOOR, gameElement: null };\n if (i === 0 || i === board.length - 1 || j === 0 || j === board[0].length - 1) {\n if (i !== midI && j !== midJ) cell.type = WALL;\n }\n board[i][j] = cell;\n }\n }\n // Place the gamer\n board[gGamerPos.i][gGamerPos.j].gameElement = GAMER;\n board[2][7].gameElement = BALL;\n board[1][3].gameElement = BALL;\n gBallsOnBoardCount = 2;\n return board;\n}", "title": "" }, { "docid": "3d2092095c69ce64884d12b663918e9d", "score": "0.74184245", "text": "function buildBoard() {\r\n var mat = [];\r\n for (var i = 0; i < gLevel.size; i++) {\r\n mat[i] = [];\r\n for (var j = 0; j < gLevel.size; j++) {\r\n mat[i][j] = createCell();\r\n }\r\n }\r\n return mat;\r\n}", "title": "" }, { "docid": "bd21cca4f4335287a426b8789bea4139", "score": "0.7413976", "text": "function makeHtmlBoard() {\n const htmlBoard = document.getElementById(\"board\");\n //create top row for piece placement\n const top = document.createElement(\"tr\");\n top.setAttribute(\"id\", \"column-top\");\n top.addEventListener(\"click\", handleClick);\n //create headcells for piece placement\n for (let x = 0; x < WIDTH; x++) {\n let headCell = document.createElement(\"td\");\n headCell.setAttribute(\"id\", x);\n top.append(headCell);\n }\n htmlBoard.append(top);\n // create game grid divs\n for (let y = 0; y < HEIGHT; y++) {\n let row = document.createElement(\"tr\");\n for (let x = 0; x < WIDTH; x++) {\n let cell = document.createElement(\"td\");\n cell.setAttribute(\"id\", `${y}-${x}`);\n row.append(cell);\n }\n htmlBoard.append(row);\n }\n}", "title": "" }, { "docid": "58262c8b814e008bb454a7ea604465ef", "score": "0.73912895", "text": "function createBoard() {\n id = 1;\n squares = []\n var squareSize = width / numSquaresPerRow;\n var rowPos = 0;\n while (rowPos <= height - squareSize){\n colPos = 0;\n row = []\n for (var i = 0; i < numSquaresPerRow; i++){\n row.push(new Square(colPos, rowPos, squareSize, id++));\n colPos += squareSize;\n }\n squares.push(row);\n rowPos += squareSize;\n }\n squares[0][0].inFlood = true;\n setAllNeighbors();\n flood(squares[0][0].color);\n}", "title": "" }, { "docid": "7eb3eb9b7f3dcda6eb9afef9a7e265d1", "score": "0.73896855", "text": "function createBoard() {\n\tfor (let i = 0; i < pairRange * 2; i++) {\n\t\tlet div = document.createElement(\"div\");\n\t\tdiv.classList.add(\"card\");\n\t\tlet frontFace = document.createElement(\"div\");\n\t\tlet backFace = document.createElement(\"div\");\n\t\tfrontFace.classList.add(\"front\");\n\t\tbackFace.classList.add(\"back\");\n\n\t\tlet tagFront = document.createElement(\"p\");\n\t\ttagFront.innerHTML = usedEmojis[i];\n\t\ttagFront.classList.add(\"emoji\");\n\n\t\tfrontFace.appendChild(tagFront);\n\t\tdiv.appendChild(frontFace);\n\t\tdiv.appendChild(backFace);\n\t\tdiv.setAttribute(\"id\", \"card\" + i);\n\t\tdiv.addEventListener(\"click\", flipCard);\n\t\tdiv.addEventListener(\"transitionend\", checkCards);\n\t\tboard.appendChild(div);\n\t}\n\n\tresizeBoard();\n}", "title": "" }, { "docid": "a1eebe18ee4b1edf2ce761bef593993c", "score": "0.73890996", "text": "function makeHtmlBoard() {\n\tconst htmlBoard = document.querySelector('#board');\n\t// creates top row that is used to place pieces\n\tlet top = document.createElement('tr');\n\ttop.setAttribute('id', 'column-top');\n\ttop.addEventListener('click', handleClick);\n\n\tfor (let x = 0; x < WIDTH; x++) {\n\t\tconst headCell = document.createElement('td');\n\t\theadCell.setAttribute('id', x);\n\t\ttop.append(headCell);\n\t}\n\thtmlBoard.append(top);\n\n\t// creates board, creating new boxes according to height and width of board\n\tfor (let y = 0; y < HEIGHT; y++) {\n\t\tconst row = document.createElement('tr');\n\t\tfor (let x = 0; x < WIDTH; x++) {\n\t\t\tconst cell = document.createElement('td');\n\t\t\tcell.setAttribute('id', `${y}-${x}`);\n\t\t\trow.append(cell);\n\t\t}\n\t\thtmlBoard.append(row);\n\t}\n}", "title": "" }, { "docid": "fc18fae60fd7e28c70c5df0e51494b8d", "score": "0.7368073", "text": "function constructBoard(width, height) {//boardObj (int int)\n\n\tconst board = document.getElementById('board');\n\tfor (let row = 0; row < height; row++) {\n\t\tconst localRow = row;\n\t\tconst tr = board.appendChild(document.createElement('tr'));\n\t\tfor (let col = 0; col < width; col++) {\n\t\t\tconst localCol = col;\n\t\t\tconst cell = tr.appendChild(document.createElement('td'));\n\t\t\tcell.id = 'square-' + row + '-' + col;\n\t\t\tcell.classList.add('square', 'parity-' + ((row * height + col) % 2 === 0));\n\n\t\t\tconst horzLine = cell.appendChild(document.createElement('div'));\n\t\t\thorzLine.classList.add('horz-line', 'line', 'line-horz-' + row + '-' + col);\n\t\t\thorzLine.onclick = function() {\n\t\t\t\tonLineClicked(localCol, localRow, false);\n\t\t\t};\n\n\t\t\tconst vertLine = cell.appendChild(document.createElement('div'));\n\t\t\tvertLine.classList.add('vert-line', 'line', 'line-vert-' + row + '-' + col);\n\t\t\tvertLine.onclick = function() {\n\t\t\t\tonLineClicked(localCol, localRow, true);\n\t\t\t};\n\t\t}\n\t}\n}", "title": "" }, { "docid": "5766d0543a8c483f916b15070a25a931", "score": "0.7365547", "text": "function createBoard(rows, cols) {\n board.empty();\n for (let i = 0; i < rows; i++) {\n data.grid[i] = [];\n\n var row = $(\"<div>\").addClass(\"row\");\n\n for (let j = 0; j < cols; j++) {\n var col = $(\"<div>\")\n .addClass(\"col hidden\")\n .attr(\"data-row\", i)\n .attr(\"data-col\", j);\n\n if (Math.random() < 0.1) {\n col.addClass(\"mine\");\n //position [i][j] has a mine in it\n data.grid[i][j] = \"M\";\n }\n row.append(col);\n }\n\n board.append(row);\n }\n // For testing the data in the grid\n // console.log(data.grid);\n}", "title": "" }, { "docid": "85090156e55796102f5dda5c320f6dde", "score": "0.7348299", "text": "function generateBoard() {\n this.element = document.createElement('div');\n this.element.tabIndex = -1; // So the element can be focused on on click.\n const range = document.createRange();\n const template = `\n <div class=\"board\" style=\"height: ${this.tileWidth * this.rows}px; width: ${this.tileWidth * this.columns}px;\"></div>\n <p class=\"message\"></p>\n `;\n const frag = range.createContextualFragment(template);\n const board = frag.querySelector('.board');\n\n board.addEventListener('click', this.clickHandler);\n this.element.classList.add('board-container');\n this.tiles.forEach((tile) => board.appendChild(tile.element));\n this.element.appendChild(frag);\n this.element.addEventListener('keydown', this.arrowPressHandler);\n}", "title": "" }, { "docid": "e6814dcfe5e7d8a2793e0b2707ca4825", "score": "0.7339051", "text": "createBoard() {\n\n\n //Create div rows\n //create new dom element\n //Add class signaling\n\n const $board = $(this.selector);\n $board.empty();\n this.gameOver = false;\n this.player = 'green';\n for (let row = 0; row < this.ROWS; row++) {\n const $row = $('<div>')\n .addClass('row');\n\n\n //Create cols/create div\n //Create new dom element\n //Add class signalinng empty\n for (let col = 0; col < this.COLS; col++) {\n const $col = $('<div>')\n .addClass('col empty')\n\n //Create attribute\n //Able to see col and row index\n .attr('data-col', col)\n .attr('data-row', row);\n\n //Append col to row\n //Append all to board\n $row.append($col);\n $board.append($row);\n }\n }\n}", "title": "" }, { "docid": "0d89ac62661c0b88ca0818d338503c1c", "score": "0.7335288", "text": "function gameBoard(rows, cols) {\n $game.empty()\n for (var i = 0; i < rows; i++) {\n const $row = $('<div>').addClass('row');\n for (var j = 0; j < cols; j++) {\n const $col = $('<div>')\n .addClass('col')\n .attr('data-row', i)\n .attr('data-col', j)\n .attr('weight', 999);\n $row.append($col);\n }\n $game.append($row);\n }\n}", "title": "" }, { "docid": "b37362044f6e4dadb11afa18a2f1dc6a", "score": "0.7327962", "text": "_create() {\n this._destroyPieces();\n this._destroyBoard();\n if (this._parentElement) {\n const boardDiv = document.createElement(\"div\");\n boardDiv.className = \"ac-chess-board\";\n const table = document.createElement(\"table\");\n table.className = \"ac-chess-board\";\n\n const coordinates = [];\n\n const createCoordinate = (rank, file, onBottom) => {\n const letters = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"];\n\n const p = document.createElement(\"p\");\n p.className = \"ac-coordinate\";\n p.className += onBottom ? \" ac-rank-coordinate \" : \" ac-file-coordinate\";\n const color = (file + rank) % 2 === 0 ? this._options.darkSquareColor : this._options.lightSquareColor;\n p.style.color = color;\n if (this.isFlipped) {\n p.innerHTML = onBottom ? letters[8 - file - 1] : rank + 1;\n } else {\n p.innerHTML = onBottom ? letters[file] : RANK_COUNT - rank;\n }\n\n coordinates.push(p);\n return p;\n };\n\n for (let rank = 0; rank < RANK_COUNT; rank++) {\n const row = document.createElement(\"tr\");\n for (let file = 0; file < FILE_COUNT; file++) {\n const cell = document.createElement(\"td\");\n cell.style.backgroundColor = (file + rank) % 2 === 0 ? this._options.lightSquareColor : this._options.darkSquareColor;\n if (rank === RANK_COUNT - 1) {\n const coord = createCoordinate(rank, file, true);\n cell.appendChild(coord);\n }\n\n if (file === FILE_COUNT - 1) {\n const coord = createCoordinate(rank, file, false);\n cell.appendChild(coord);\n }\n row.appendChild(cell);\n }\n table.appendChild(row);\n }\n boardDiv.appendChild(table);\n this._parentElement.appendChild(boardDiv);\n\n this._boardElement = boardDiv;\n\n // We need to set the reactive style of the coordinates after the board has been created so we\n // know how big the board is\n for (const coord of coordinates) {\n coord.style.fontSize = `${this.squareClientWidth / 7}px`;\n coord.style.margin = `${this.squareClientWidth / 40}px`;\n }\n }\n }", "title": "" }, { "docid": "6ab969b3fa26c3440cefa8523a31df38", "score": "0.73260635", "text": "function createBoard() {\n let newBoard = [];\n\n // create the board with true or false values for each tile\n for (let y = 0; y < props.rows; y++) {\n let row = [];\n\n // create the individual rows of the board\n for (let x = 0; x < props.cols; x++) {\n row.push(Math.random() < props.litChance)\n }\n newBoard.push(row);\n }\n\n return newBoard;\n }", "title": "" }, { "docid": "2e3df1cec3f268f96b85c8664fcdb47c", "score": "0.7305127", "text": "function makeBoard() {\n // TODO: set \"board\" to empty HEIGHT x WIDTH matrix array\n while(board.length){\n board.pop();\n }\n\n for (let y = 0; y < HEIGHT; y++){\n const curY = [];\n for (let x = 0; x< WIDTH; x++){\n curY.push(null);\n }\n board.push(curY);\n }\n}", "title": "" }, { "docid": "a07b3f512f90216d4265bbf9730ed112", "score": "0.7303788", "text": "function genBoard() {\n\t// Gather board information\n\tvar boardDataLocation = document.getElementById('boardState');\n\tvar data = JSON.parse(boardDataLocation.innerHTML);\n\tresDist = data['res'];\n\tnumDist = data['num'];\n\n\t// Find location of the board\n\tvar board = document.getElementById('board');\n\t// If it's not the players turn then it disallows any clicking on the board\n\tif (!canBuild) {\n\t\tboard.classList.add('nope');\n\t}\n\n\tvar html = \"\";\n\t// Loop through the 5 rows and choose what to do depending on the row with the switch stmt\n\tfor (i = 1; i <= 5; i++) {\n\t\tswitch (i) {\n\t\t\tcase 1:\n\t\t\tcase 5:\n\t\t\t\thtml += \"<div class='row' id='row\" + i + \"'>\";\n\t\t\t\tfor (j = 1; j <= 3; j++) {\n\t\t\t\t\thtml += addHex();\n\t\t\t\t\thtml += addBasicFeatures();\n\t\t\t\t\tif (j == 3) {\n\t\t\t\t\t\thtml += addRightFeatures();\n\t\t\t\t\t}\n\t\t\t\t\tif (i == 5) {\n\t\t\t\t\t\thtml += addBottomRoads();\n\t\t\t\t\t\thtml += addBottomSettlements();\n\t\t\t\t\t\tif (j == 3) {\n\t\t\t\t\t\t\thtml += addFeature('settle', 'botright');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thtml += \"</div>\";\n\t\t\t\t}\n\t\t\t\thtml += \"</div>\";\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\tcase 4:\n\t\t\t\thtml += \"<div class='row' id='row\" + i + \"'>\";\n\t\t\t\tfor (j = 1; j <= 4; j++) {\n\t\t\t\t\thtml += addHex();\n\t\t\t\t\thtml += addBasicFeatures();\n\t\t\t\t\tif (j == 4) {\n\t\t\t\t\t\thtml += addRightFeatures();\n\t\t\t\t\t}\n\t\t\t\t\tif (i == 4) {\n\t\t\t\t\t\tif (j == 1) {\n\t\t\t\t\t\t\thtml += addFeature('road', 'botleft');\n\t\t\t\t\t\t\thtml += addFeature('settle', 'botleft');\n\t\t\t\t\t\t} else if (j == 4) {\n\t\t\t\t\t\t\thtml += addFeature('road', 'botright');\n\t\t\t\t\t\t\thtml += addFeature('settle', 'botright');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thtml += \"</div>\";\n\t\t\t\t}\n\t\t\t\thtml += \"</div>\";\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\thtml += \"<div class='row' id='row\" + i + \"'>\";\n\t\t\t\tfor (j = 1; j <= 5; j++) {\n\t\t\t\t\thtml += addHex();\n\t\t\t\t\thtml += addBasicFeatures();\n\t\t\t\t\tif (j == 1) {\n\t\t\t\t\t\thtml += addFeature('road', 'botleft');\n\t\t\t\t\t\thtml += addFeature('settle', 'botleft');\n\t\t\t\t\t} else if (j == 5) {\n\t\t\t\t\t\thtml += addRightFeatures();\n\t\t\t\t\t\thtml += addFeature('road', 'botright');\n\t\t\t\t\t\thtml += addFeature('settle', 'botright');\n\t\t\t\t\t}\n\t\t\t\t\thtml += \"</div>\";\n\t\t\t\t}\n\t\t\t\thtml += \"</div>\";\n\t\t\t\tbreak;\n\t\t}\n\t}\n\t// Add the base layer board to html doc\n\tboard.innerHTML = html;\n\t// Add all the current buildings\n\taddExistingBuildings();\n\t// Add in the robber\n\taddRobber();\n}", "title": "" }, { "docid": "b2e05f51aaed93d7ac3e37330680ae62", "score": "0.7303094", "text": "function createTiles(){\n\t\t// initialize the gameboard HTML string\n\t\tvar gameboardString = \"\";\n\t\t\n\t\t// add tile images for each row and column value\n\t\tfor(var j = 0; j < model.height; j++){\t\t\n\t\t\tfor(var i = 0; i < model.width; i++){\n\t\t\t\t// Add an image to the gameboard containing a tile\n\t\t\t\tgameboardString = gameboardString + '<div class=\"tint\" id=\"tint' + i + '_' + j + '\"><img src=\"images/grid.png\" id=\"tile' + i + '_' + j + '\" class=\"tile\"/></div>';\n\t\t\t}\n\t\t\t\n\t\t\t// add a line break after each row of tiles\n\t\t\tgameboardString = gameboardString + '<br/>\\n';\n\t\t}\n\t\t\n\t\t// add the generated HTML to the gameboard\n\t\t$(\"#gameboard\").append(gameboardString);\n\t\t\n\t\t// add animation functions to each tile\n\t\tfor(var j = 0; j < model.height; j++){\n\t\t\tfor(var i = 0; i < model.width; i++){\n\t\t\t\tcreateTile({x:i, y:j});\n\t\t\t}\n\t\t}\t\t\n\t}", "title": "" }, { "docid": "b4bc93768c370ada55b3e68cabd27340", "score": "0.7301451", "text": "setupBoard() {\n const elBoard = document.getElementById(this.DOM_IDS.BOARD);\n const elWrapper = document.getElementById(this.DOM_IDS.BOARD_WRAPPER);\n\n // Clear the board\n elBoard.innerHTML = \"\";\n this.board = {};\n\n // Set the board size\n const boardWidth = SETTINGS.BOARD_COLS_WIDE * SETTINGS.CELL_WIDTH_PX;\n const boardHeight = SETTINGS.BOARD_ROWS_HIGH * SETTINGS.CELL_HEIGHT_PX;\n elBoard.style.width = `${boardWidth}px`;\n elBoard.style.height = `${boardHeight}px`;\n\n for (let i = 0; i < SETTINGS.BOARD_ROWS_HIGH; i++) {\n this.board[i] = [];\n const top_pos = i * SETTINGS.CELL_HEIGHT_PX;\n for (let j = 0; j < SETTINGS.BOARD_COLS_WIDE; j++) {\n // Setup the object for storing block positions\n this.board[i][j] = {};\n\n // Calculate left px position of the cell\n const left_pos = j * SETTINGS.CELL_WIDTH_PX;\n\n // Add the block to the board\n const block = document.createElement(\"div\");\n block.style.left = left_pos.toString() + \"px\";\n block.style.top = top_pos.toString() + \"px\";\n block.className = this.DOM_CLASSES.BOARD_BLOCK;\n block.setAttribute(\"id\", `tb_${j}_${i}`);\n elBoard.appendChild(block);\n }\n }\n }", "title": "" }, { "docid": "7cae819d798e4ee5054b1c12b51b1e9d", "score": "0.7298659", "text": "function createBoard() {\n console.log(\"Creating table\");\n var boarddiv = document.getElementById(\"board\");\n var table = document.createElement(\"table\");\n\n for (var i = 0; i < 17; ++i) {\n var tr = document.createElement(\"tr\");\n tr.setAttribute(\"id\", i);\n if (i % 2 == 0) {\n // Major rows have 9 squares and 8 grooves\n tr.setAttribute(\"class\", \"major-row\");\n\n for (var j = 0; j < 17; ++j) {\n var td = document.createElement(\"td\");\n td.setAttribute(\"id\", i.toString() + \"-\" + j.toString());\n if (j % 2 == 0) {\n td.setAttribute(\"class\", \"square\");\n } else {\n td.setAttribute(\"class\", \"v-groove\");\n td.classList.add(\"wall\");\n }\n\n tr.appendChild(td);\n }\n\n } else {\n // Minor rows have 9 grooves and 8 cross sections\n tr.setAttribute(\"class\", \"minor-row\");\n\n for (var j = 0; j < 17; ++j) {\n var td = document.createElement(\"td\");\n td.setAttribute(\"id\", i.toString() + \"-\" + j.toString());\n if (j % 2 == 0) {\n td.setAttribute(\"class\", \"h-groove\");\n td.classList.add(\"wall\");\n } else {\n td.setAttribute(\"class\", \"cross\");\n }\n\n tr.appendChild(td);\n }\n\n }\n\n table.appendChild(tr);\n }\n\n boarddiv.appendChild(table);\n \n}", "title": "" }, { "docid": "e468fb9c90ddcdd4ce37cecdc5b40c69", "score": "0.7297994", "text": "function setUpBoard() {\n for (let i = 0; i < 10; i += 1) {\n for (let j = 0; j < 10; j += 1) {\n var div = document.createElement('div');\n div.classList.add('brick', 'row' + i.toString(), 'col' + j.toString());\n main.appendChild(div);\n }\n }\n }", "title": "" }, { "docid": "74d7b8c65809e2a488359394366abe93", "score": "0.7294779", "text": "createBoard(){\n let board = []\n // Outer loop to create parent\n for (let i = 0; i <= 6; i+=3) {\n let children = []\n //Inner loop to create children\n for (let j = 1; j <= 3; j++) {\n //will create keys 1 - 9\n //TODO: Find a way to make the game board match the state of whatever game object is passed back on create game, or make the behavior of create game, just that, only getting blank empty games.\n //The boardKey prop is used in the Tile fetch request.\n children.push(<td key={i+j}><Tile gameMessage = {this.state.currentGame.gameMessage} boardKey = {i+j} currentPlayer={this.state.currentGame.currentPlayer} callback = {this.getGame}/></td>);\n }\n //Create the parent and add the children\n board.push(<tr key={i}>{children}</tr>);\n }\n return board\n }", "title": "" }, { "docid": "535829a8af10dbc7bddcda904e60fc5a", "score": "0.7275761", "text": "function buildBoard() {\n\tvar device_width = (window.innerWidth > 0) ? window.innerWidth : screen.width;\n\tvar device_height = (window.innerHeight > 0) ? window.innerHeight : screen.height;\n\tvar size = (device_width > device_height) ? (device_height-100)/parseInt(height) : (device_width-100)/parseInt(width);\n\t$minesweeper.empty();\n\tminesLeft = mines;\n\t$minesweeper.append(\"<table class=\\\"board-table\\\"></table>\");\n\tvar $board_table = $(\".board-table\");\n\t$board_table.append(\"<tr id=\\\"row-header\\\" height='\"+50+\"'></tr>\");\n\tvar $header_row = $(\"#row-header\");\n\t$header_row.append(\"<td class='center' onclick='center()' height='\"+50+\"' colspan='\"+parseInt(width/3)+\"'>Center</td>\");\n\t$header_row.append(\"<td class='reset' onclick='buildBoard()' height='\"+50+\"' colspan='\"+parseInt(width/3)+\"'>Reset</td>\");\n\t$header_row.append(\"<td id='mines-left' height='\"+50+\"' colspan='\"+(width-2*parseInt(width/3))+\"'>Mines left: \"+minesLeft+\"</td>\");\n\t$mines_left = $(\"#mines-left\");\n\tfor(var i = 0 ; i < height ; i++) {\n\t\t$board_table.append(\"<tr id=\\\"row\"+i+\"\\\" height='\"+size+\"' width='\"+size+\"'></tr>\");\n\t\tvar $board_row = $(\"#row\"+i);\n\t\tfor(var j = 0 ; j < width ; j++) {\n\t\t\t$board_row.append(\"<td onclick=\\\"discover_user(\"+i+\",\"+j+\")\\\" id=\\\"s\"+i+\"-\"+j+\"\\\" height='\"+size\n\t\t\t+\"' width='\"+size+\"' class='undiscovered' style=\\\"font-size:\"+size/2+\"px;\\\"></td>\");\n\t\t}\n\t}\n\tinitMines(height,width,mines);\n}", "title": "" }, { "docid": "07a8e599fea630910bf29455f0e6507a", "score": "0.72742426", "text": "function gen() {\n // clearing the board ( slightly faster than clearRect )\n canvas.width = canvas.width;\n var temp = [];\n var len = width * height;\n var m = len;\n var count, x_inc, x_dec, y_inc, y_dec, m_inc, m_dec;\n while ( m ) { --m;\n count = 0;\n // calculating increments / decrements\n x_inc = ( m + 1 ) % width - m % width;\n x_dec = ( m - 1 + width) % width - m % width;\n y_inc = ( m + width ) % len - m % len;\n y_dec = ( m - width + len ) % len - m % len;\n // precalculating horizontal incremented / decremented value\n m_inc = m + x_inc;\n m_dec = m + x_dec;\n // horizontal neighbors\n if ( board[m_inc] === true ) { ++count; }\n if ( board[m_dec] === true ) { ++count; }\n // neighbors below\n if ( board[m + y_inc] === true ) { ++count; }\n if ( board[m_inc + y_inc] === true ) { ++count; }\n if ( board[m_dec + y_inc] === true ) { ++count; }\n // neighbors above\n if ( board[m + y_dec] === true ) { ++count; }\n if ( board[m_inc + y_dec] === true ) { ++count; }\n if ( board[m_dec + y_dec] === true ) { ++count; }\n // deciding on next gen and drawing\n if ( count === 3 || ( count === 2 && board[m] === true ) ) {\n temp[m] = true;\n context.fillRect( (m % width) * celldimensions, (m / width >> 0) * celldimensions, celldimensions, celldimensions );\n } else {\n temp[m] = false;\n }\n }\n board = temp.slice();\n if ( playing ) {\n requestAnimationFrame( gen );\n }\n }", "title": "" }, { "docid": "15aa99867eb725ff49d01cc62da45a57", "score": "0.7270892", "text": "function makeBoard() {\n // set \"board\" to empty HEIGHT x WIDTH matrix array\n for (let i = 0; i < HEIGHT; i++) {\n let row = [];\n for (let i = 0; i < WIDTH; i++) {\n row.push(null);\n }\n board.push(row);\n }\n}", "title": "" }, { "docid": "c8bda6463e4132996c6a7a49477467e6", "score": "0.72705644", "text": "function buildBoard(){\n//Clear Previous settings\n won = false\n setCanvas()\n clearGameBoard()\n squareIdList = []\n idListRed = []\n idListBlack = []\n turnsTaken = 0\n turn = 'red'\n rows = 8\n columns = 8\n winAmount = 4\n let customSize = parseInt(document.getElementById(\"setSquareCount\").value)\n let customWinAmout = parseInt(document.getElementById(\"setWinAmount\").value)\n if (customSize){\n rows = customSize\n columns = customSize\n }\n if(customWinAmout){\n winAmount = customWinAmout\n }\n setBoardFloor()\n setBoardWidth();\n setSquareSize();\n setColumnHeights()\n makeBoard();\n drawGrid();\n}", "title": "" }, { "docid": "8341dfbf7df3b24c00cf463aefbb973e", "score": "0.72669965", "text": "makeBoard() {\n for (let y = 0; y < this.HEIGHT; y++) {\n this.board.push(Array.from({ length: this.WIDTH }));\n this.board[y].fill(null);\n }\n }", "title": "" }, { "docid": "5ac30d782b3c1ee7537630b48f6ce7b4", "score": "0.7261004", "text": "function makeBoard()\r\n{\r\n\tdocument.getElementById(\"startgame\").parentElement.removeChild(document.getElementById(\"startgame\"));\r\n\tvar checkersBoard = document.getElementById(\"board\");\r\n\tvar size = parseInt(document.getElementById(\"boardscript\").getAttribute(\"data-name\"));\r\n\tvar row = 1;\r\n\tcheckersBoard.style.height = size+\"px\";\r\n\tcheckersBoard.style.width = size+\"px\";\r\n\tfor(var i=0; i<64; i++)\r\n\t{\r\n\t\tvar box = document.createElement(\"div\");\r\n\t\tvar piece = document.createElement(\"div\");\r\n\t\tvar leftval = 0;\r\n\t\tvar topval = 0;\r\n\t\tpiece.style.width = piece.style.height = size*.125 + \"px\";\r\n\t\tpiece.id = \"piece\" + i;\r\n\t\t\r\n\t\tbox.id = \"box\" + i.toString();\r\n\t\t\r\n\t\tif(i+1<25 && i>0)\r\n\t\t{\t\t\t\t\t\r\n\t\t\tpiece.className = \"redPiece\";\r\n\t\t}\r\n\t\t\r\n\t\tif(i+1<64 && i>39)\r\n\t\t{\r\n\t\t\tpiece.className = \"blackPiece\";\r\n\t\t}\r\n\t\t\r\n\t\tpiece.style.backgroundSize = \"100%\";\r\n\t\t\r\n\t\tif(row%2==0)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t{\r\n\t\t\tif((i+2)%2==0)\r\n\t\t\t{\r\n\t\t\t\tbox.className = \"black\";\r\n\t\t\t\tcheckersBoard.appendChild(box);\r\n\t\t\t\t\r\n\t\t\t\tif(i+1<25 && i>0 || i+1<64 && i>39)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tleftval = box.getBoundingClientRect().left;\r\n\t\t\t\t\tpiece.style.left = leftval + \"px\";\r\n\t\t\t\t\ttopval = box.getBoundingClientRect().top;\r\n\t\t\t\t\tpiece.style.top = topval + \"px\";\r\n\t\t\t\t\tbox.appendChild(piece);\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tbox.className = \"red\";\r\n\t\t\t\tcheckersBoard.appendChild(box);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\telse \r\n\t\t{\r\n\t\t\tif((i+2)%2==0)\r\n\t\t\t{\r\n\t\t\t\tbox.className = \"red\";\r\n\t\t\t\tcheckersBoard.appendChild(box);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tbox.className = \"black\";\r\n\t\t\t\tcheckersBoard.appendChild(box);\r\n\t\t\t\tif(i+1<25 && i>0 || i+1<64 && i>39)\r\n\t\t\t\t{\r\n\t\t\t\t\tleftval = box.getBoundingClientRect().left;\r\n\t\t\t\t\tpiece.style.left = leftval + \"px\";\r\n\t\t\t\t\ttopval = box.getBoundingClientRect().top;\r\n\t\t\t\t\tpiece.style.top = topval + \"px\";\r\n\t\t\t\t\tbox.appendChild(piece);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t\tif((i+1)%8==0)\r\n\t\t\trow++;\r\n\t\t//when mouse pressed down on piece\r\n\t\tpiece.onmousedown = function(event) \r\n\t\t{\r\n\t\t\t//piece being moved\r\n\t\t\tvar pieceUsed = event.target;\r\n\t\t\t//checking to make sure correct piece being moved based on turn\r\n\t\t\tif(((pieceUsed.className==\"redPiece\")&&(turn==1))|| ((pieceUsed.className==\"blackPiece\")&&(turn==0)) || ((pieceUsed.className==\"redKing\")&&(turn==1)) || ((pieceUsed.className==\"blackKing\")&&(turn==0)))\r\n\t\t\t{\r\n\t\t\t\tpieceUsed.style.zIndex = 10;\r\n\t\t\t\tif(jumpExist==false)\r\n\t\t\t\t\thighlightBox(pieceUsed, highlightedBoxes);\r\n\t\t\t\tdocument.addEventListener(\"mousemove\", moveDiv); \r\n\t\t\t\t//moves piece position when cursor moves\r\n\t\t\t\tfunction moveDiv(e)\r\n\t\t\t\t{\r\n\t\t\t\t\tpieceUsed.style.left = e.pageX - pieceUsed.offsetWidth / 2 + \"px\";\r\n\t\t\t\t\tpieceUsed.style.top = e.pageY - pieceUsed.offsetHeight / 2 + \"px\";\r\n\t\t\t\t}\r\n\t\t\t\t//when mouse released from piece\r\n\t\t\t\tpieceUsed.onmouseup = function()\r\n\t\t\t\t{\r\n\t\t\t\t\tvar temp = highlightedBoxes;\r\n\t\t\t\t\t//bring piece z index to normal and remove listener for acutal movement\r\n\t\t\t\t\tdocument.removeEventListener(\"mousemove\", moveDiv);\r\n\t\t\t\t\tpieceUsed.style.zIndex = 2;\r\n\t\t\t\t\t//check if piece is in x and y of a box\r\n\t\t\t\t\tvar boxIn = checkBox(pieceUsed);\r\n\t\t\t\t\t//check if box is a highlighted box\r\n\t\t\t\t\tif((boxIn!=null)&&(containsBox(pieceUsed, highlightedBoxes, boxIn.id.substring(3,boxIn.id.length)))==true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//move piece\r\n\t\t\t\t\t\tpieceUsed.style.left = (boxIn.getBoundingClientRect().left+window.scrollX) + \"px\";\r\n\t\t\t\t\t\tpieceUsed.style.top = (boxIn.getBoundingClientRect().top+window.scrollY) + \"px\";\r\n\t\t\t\t\t\tpieceUsed.parentElement.lastChild = null;\r\n\t\t\t\t\t\tboxIn.appendChild(pieceUsed);\r\n\t\t\t\t\t\t//if after a jump, check to see if another jump\r\n\t\t\t\t\t\tif(jumpExist==true)\r\n\t\t\t\t\t\t\tcheckJump(turn);\r\n\t\t\t\t\t\t//if no jump exists switch turns\r\n\t\t\t\t\t\tif(jumpExist==false)\r\n\t\t\t\t\t\t\tturn=!turn;\r\n\t\t\t\t\t\t//check if after move the piece becomes a king\r\n\t\t\t\t\t\tcheckIfKing(pieceUsed.id.substring(5,pieceUsed.id.length));\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//move piece back to original box\r\n\t\t\t\t\t\tpieceUsed.style.left = (pieceUsed.parentElement.getBoundingClientRect().left+window.scrollX) + \"px\";\r\n\t\t\t\t\t\tpieceUsed.style.top = (pieceUsed.parentElement.getBoundingClientRect().top+window.scrollY) + \"px\";\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//for a move that is not a jump, unhighlight boxes and check if jump exists for new position\r\n\t\t\t\t\tunHighlight(temp);\r\n\t\t\t\t\tcheckJump(turn);\r\n\t\t\t\t\tpieceUsed.onmouseup = null;\r\n\t\t\t\t};\r\n\t\t\t\t//disbale ondragstart function\r\n\t\t\t\tpieceUsed.ondragstart = function() {\r\n\t\t\t\treturn false;\r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n}", "title": "" }, { "docid": "c6d0b469f75293699ce15b7d6b96f12a", "score": "0.7258026", "text": "function drawBoard() {\n var board = $('#board');\n board.empty();\n\n for (var y = 0; y < 14; y++) { //y-axis create 14 rows\n\n for(var x = 0; x < 14; x++) { // x-axis create 14 squares per row\n var square = $('<div class=\"square\"></div>'); //create 196 divs with class 'square'\n square.appendTo(board); //append the squares to the board\n square.css('background-color', colors[x][y]); // assign a color to each square\n }\n }\n}", "title": "" }, { "docid": "0b6f76918d6cc7262b205a31eab8bf84", "score": "0.7245698", "text": "function drawBoard(){\n var html= \"<table>\";\n for(var x=0; x<3; x++){\n\t\thtml += \"<tr>\";\n\t\tfor(var y=0; y<3; y++){\n\t\t class = \"item-\" + board[x][y];\n\t\t html += \"<td x=\"+x+\" y=\"+y+\" class='\"+class+\"'>\" + board[x][y] + \"</td>\";\n\t\t}\n\t\thtml += \"</tr>\";\n }\n html += \"</table>\";\n $('#board').html(html);\n}", "title": "" }, { "docid": "1fca4699f067699534fcc947f47f0b40", "score": "0.72398496", "text": "function drawBoard()\n{\n\tvar i,j;\n\tvar board = \"\";\n\n\tfor (i=1; i<=boardwidth; i++)\n\t{\n\t\tboard += \"<div class='row'>\"\n\t\tfor (j=1; j<=boardlength; j++)\n\t\t{\n\t\t\tboard += \"<div class='square bevel' id='square\" + (((i-1)*boardwidth) + j) + \"'></div>\";\n\t\t}\n\t\tboard += \"</div><div class='div-clear'></div>\"\n\t}\n\tdocument.getElementById('gameboard').innerHTML = board;\n}", "title": "" }, { "docid": "ac13cb911d23083f5c9022496983e8af", "score": "0.7231053", "text": "createBoard() {\n let board = new Array(8);\n for (var i = 0; i < 8; i++) {\n board[i] = new Array(8);\n for (var j = 0; j < 8; j++) {\n board[i][j] = {\n x: j,\n y: i,\n AN: xyToAN(j, i),\n id: xyToAN(j, i),\n currentPiece: null,\n };\n }\n }\n return board\n }", "title": "" }, { "docid": "992ca7820a226148533f4046a2c8f446", "score": "0.72296494", "text": "function createGrid(){\r\n for (let row =0 ; row <board.length; row ++){\r\n for (let col =0; col<board[row].length; col++){\r\n let pieceVal = board[row][col]\r\n if (pieceVal == '') {\r\n cont.innerHTML += `<div id='board-${row}/${col}' data-piece ='board' data-row = '${row}' data-col = '${col}' class = '${color(row,col)}'></div>`\r\n } else {\r\n cont.innerHTML += `<div id='board-${row}/${col}' data-piece ='board' data-row = '${row}' data-col = '${col}' class = '${color(row,col)}'><img id ='${row}/${col}' data-row = '${row}' data-col = '${col}' data-piece=${pieceVal} src =pieces/${pieceVal}.png></div>`\r\n }\r\n }\r\n }\r\n}", "title": "" }, { "docid": "8dd7a73fd267a05409b172e09b1b672c", "score": "0.7226545", "text": "makeBoard() {\n for (let y = 0; y < this.HEIGHT; y++) {\n this.board.push(Array.from({ length: this.WIDTH }));\n }\n }", "title": "" }, { "docid": "c3d019e18f0061516c6128c3fb4f11b5", "score": "0.7223999", "text": "function test_makeBoard() {\n const boardRow = Array(test_WIDTH).fill(null);\n for (let i = 0; i < test_HEIGHT; i++) {\n test_board.push(boardRow);\n }\n }", "title": "" }, { "docid": "66e63a26b4bdebba3dfb47099209815f", "score": "0.7223077", "text": "function createBoard(size) {\n pixelBoard.innerHTML = '';\n for (let i = 0; i < size; i += 1) {\n pixelBoard.appendChild(createRow(size));\n }\n}", "title": "" }, { "docid": "687a2eb26a64de5b726dedf5e11ff61a", "score": "0.7218491", "text": "function initBoard() {\r\n var board = []\r\n\r\n for (var i = 0; i < 6; ++i) {\r\n board.push([])\r\n for (var j = 0; j < 7; ++j) {\r\n board[i].push(0) //0 represents \"normal\" colour and 1 represents first players move and 2 represents second players moves\r\n // board.push({\r\n // positionX: j,\r\n // positionY: i,\r\n // currColor: \"normal\",\r\n // piece: <div style={normalButtonStyle}></div>\r\n // })\r\n }\r\n }\r\n return board\r\n}", "title": "" }, { "docid": "b971bd96495c28e74ca5f023260c6cb6", "score": "0.72174305", "text": "makeBoard() {\n for (let y = 0; y < this.height; y++) {\n this.board.push(Array.from({ length: this.width }));\n }\n }", "title": "" }, { "docid": "bd53e8df771e9a69d13988937f24b213", "score": "0.7215495", "text": "function init(){\n createBoard();\n createCell();\n setPosition();\n \n\n// for (let i = 0; i < 2; i++) {\n// create();\n// }\n// position();\n// console.log(board);\n \n}", "title": "" }, { "docid": "8aa6425fe2935412eff3b7c3f4a355c4", "score": "0.720388", "text": "newBoard() {\n board.length = 0;\n for (i = 0; i < 9; i++) {\n board.push(cell());\n }\n }", "title": "" }, { "docid": "7a919139267d70eb30d46c504f383641", "score": "0.71984595", "text": "function createBoard () {\n\t\tlet initialBoard = [];\n\t\tfor (let y = 0; y < nrows; y++) {\n\t\t\tlet row = [];\n\t\t\tfor (let x = 0; x < ncols; x++) {\n\t\t\t\trow.push(Math.random() < chanceLightStartsOn); // NOTE: 100% of lights start on for winnable board assuming it's symmetric (source: https://www.jaapsch.net/puzzles/lomath.htm#all)\n\t\t\t\t// row.push(Math.random() < 0.3); // NOTE: for random true/false values of cells, uncomment this. 0.3 = 30% of cell being True\n\t\t\t}\n\t\t\tinitialBoard.push(row);\n\t\t}\n\t\treturn initialBoard; // NOTE: returns a nested array 5x5\n\t}", "title": "" }, { "docid": "d4affe329b3e11697cb170e556199c10", "score": "0.71964645", "text": "function createBoard(svg, size) {\n var localSize = size - 1;\n var length = ticTacToe.length();\n var xStart = 30;\n var yStart = 420;\n for (i=0; i < (size - 1); i++) {\n var xArray = new Array();\n var yArray = new Array();\n var xPos = (yStart + length ) + (i * length);\n var yPos = (xStart + length) + (i * length);\n xArray.push(xPos, xStart);\n xArray.push(xPos, xStart + (length * 3));\n var newPoly = svg.append(\"polyline\").attr(\"points\", xArray );\n boardAttributes(newPoly);\n yArray.push(yStart, yPos);\n yArray.push(yStart + (length * 3), yPos);\n newPoly = svg.append(\"polyline\").attr(\"points\", yArray );\n boardAttributes(newPoly);\n }\n createRectangles(svg, size);\n}", "title": "" }, { "docid": "e850aaa2793e9dafa6977cba4c1aac39", "score": "0.71926284", "text": "function boardSetUp(){\n\n// Variables that will keep track of the board size and the layout of the rows and cells.\n var numberOfCells = 0;\n var userBoardSize = 0;\n var rowCounter = 0;\n var rowNumber = 1;\n var colCounter = 0;\n var colNumber = 1;\n\n// Prompt that asks the user to enter the board size\n userBoardSize = prompt(\"Please enter the size of the board. This must be between 4 and 6.\", 4);\n\n// Loop used to validate the board size, will only run if the user enters an invalid board size.\n while ( (userBoardSize < 4) || (userBoardSize > 6) ){\n userBoardSize = prompt(\"Sorry, I can't make a board that size, the board size must be between 4 and 6.\", 3);\n }\n\n // Calculates the numer of cells required based on the user's input.\n numberOfCells = (userBoardSize * userBoardSize);\n\n // A For loop that will create each cell of the board. It uses variables that keep track of the number of rows and columns required, and inserts the revlevent values\n for (var i = 0; i < numberOfCells; i++){\n // A new cell object is created.\n board.cells[i] = new Object();\n // Every cell stats off hidden.\n board.cells[i].hidden = true;\n\n // Adds a row number to each cell Object and keeps track of how many objects on that row.\n if (rowCounter <= userBoardSize){\n board.cells[i].row = rowNumber;\n rowCounter ++;\n }\n\n // If the row is longer than it should be, then a new row is created and the count for that row starts over\n if (rowCounter > userBoardSize){\n rowNumber ++;\n rowCounter = 1;\n board.cells[i].row = rowNumber;\n }\n\n // Adds a column number to each object and keeps track of how many objects are part of that column\n if (colCounter <= userBoardSize){\n board.cells[i].col = colNumber;\n colNumber ++;\n colCounter ++;\n }\n\n // If the column is longer than it should be, then a new column count is reset and starts again.\n if (colCounter > userBoardSize){\n colCounter = 1;\n colNumber = 1;\n board.cells[i].col = colNumber;\n colNumber ++\n }\n\n //Randomally puts a mine in the cell, or not\n board.cells[i].isMine = mineCreator();\n\n // Random number generator for creating a mine\n function mineCreator(){\n var number = Math.random();\n if (number < 0.18) {\n return true;\n }\n if (number > 0.18) {\n return false;\n }\n }\n }\n }", "title": "" }, { "docid": "1882d56ccd763ca08b200a6c66726c6c", "score": "0.7190922", "text": "function setBoard(){\r\n\tpointSize = 14-2*columns;\r\n\tpointSpacing = (60-pointSize)/(columns-1);\r\n\tcheckCount = [0,0,0,0];\r\n\tstructure = [];\r\n\tturnCount = 0;\r\n\tstructure.length = stacks;\r\n\tfor(var i = 0; i < structure.length; i++){\r\n\t\tstructure[i] = [];\r\n\t\tstructure[i].length = rows;\r\n\t\tfor(var j = 0; j < structure[i].length; j++){\r\n\t\t\tstructure[i][j] = [];\r\n\t\t\tstructure[i][j].length = columns;\r\n\t\t}\r\n\t}\r\n\t//Fill game structure with points\r\n\tfor(var i = 0; i < stacks; i++){\r\n\t\tfor(var j = 0; j < rows; j++){\r\n\t\t\tfor(var k = 0; k < columns; k++){\r\n\t\t\t\tstructure[i][j][k] = document.createElement('div');\r\n\t\t\t\tstructure[i][j][k].classList.add('point');\r\n\t\t\t\tstructure[i][j][k].id = k.toString()+j.toString()+i.toString()+'2';\r\n\t\t\t\tstructure[i][j][k].style.width = (pointSize*(1+zOffset*i))+'%';\r\n\t\t\t\tstructure[i][j][k].style.padding = ((pointSize/2)*(1+zOffset*i))+'% 0%';\r\n\t\t\t\tstructure[i][j][k].style.left = (pointSpacing*(1+zOffset*i)*k+i*i+i*2)+'%';\r\n\t\t\t\tstructure[i][j][k].style.top = (50+pointSpacing*(1+zOffset*i)*j+i*i+i*2)+'%';\r\n\t\t\t\tstructure[i][j][k].style.backgroundColor = '#'+(3+3*i)+'F'+(k)+'0'+(j)+'0';\r\n\t\t\t\tstructure[i][j][k].addEventListener('mouseover', addFocus, false);\r\n\t\t\t\tstructure[i][j][k].addEventListener('mouseleave', removeFocus, false);\r\n\t\t\t\tstructure[i][j][k].addEventListener('click', selectPoint, false);\r\n\t\t\t\tdocument.getElementsByClassName('container')[0].appendChild(structure[i][j][k]);\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tdocument.getElementsByTagName('button')[0].addEventListener('click', resetGame, false);\r\n\tdocument.getElementsByTagName('button')[1].addEventListener('click', resetGame3, false);\r\n\tdocument.getElementsByTagName('button')[2].addEventListener('click', resetGame4, false);\r\n\tdocument.getElementsByTagName('button')[3].addEventListener('click', resetGame5, false);\r\n}", "title": "" }, { "docid": "6f63dcb417be132764b78df3ea045688", "score": "0.71863914", "text": "function renderBoard() {\n // init vars\n ticTacToeBoard = new TicTacToeBoard();\n depthLimit();\n displayMessage(\"\");\n currentPlayer = Players.X;\n const board = document.getElementById(\"board\");\n // remove all cells\n while (board.firstChild) {\n board.removeChild(board.firstChild);\n }\n // recreate new board\n for (let i = 0; i < BOARD_SIZE; i++) {\n let row = document.createElement(\"tr\");\n for (let j = 0; j < BOARD_SIZE; j++) {\n let cell = document.createElement(\"td\");\n // add row, col attr to query later\n cell.setAttribute(\"row\", i);\n cell.setAttribute(\"col\", j);\n cell.id = `${i},${j}`;\n // hook funtion\n cell.addEventListener(\"click\", onClickCell);\n row.appendChild(cell);\n }\n board.appendChild(row);\n }\n}", "title": "" }, { "docid": "76463255d84e4d1a6762a4cd512f3a8a", "score": "0.7185447", "text": "function createBoard () {\n for (var i = 0; i < numDiv; i++) {\n if (answer[i] === ' ') {\n createBlankTile()\n } else {\n createLetterTile()\n }\n }\n}", "title": "" }, { "docid": "08e558976a5858ae2163ee391693c8ba", "score": "0.71827567", "text": "function createPieces() {\n\tfor (var i = 0; i < piecesState.length; i++) {\n\t\tfor (var j = 0; j < piecesState[i].length; j++) {\n\t\t\tvar p = piecesState[i][j];\n\t\t\t// find the right slot\n\t\t\tvar slot = $($($(\"#board .row\")[p.y]).find(\".slot\")[p.x]);\n\t\t\tslot.append($(\"<div class='piece player\" + (i + 1) + \"' id='piece\" + (i + 1) + \"'></div>\"));\n\t\t}\n\t}\n}", "title": "" }, { "docid": "127949c45a11d2892f74885ae0eac0f8", "score": "0.7164402", "text": "createGrid() {\n const board = document.getElementById(this.selector);\n while (board.firstChild) {\n board.removeChild(board.firstChild);\n }\n this.isGameOver = false;\n this.player = 'red';\n for (let row = 0; row < this.ROWS; row++) {\n const rowElement = document.createElement('div');\n rowElement.classList.add('row');\n for (let col = 0; col < this.COLS; col++) {\n const colElement = document.createElement('div');\n colElement.classList.add('col', 'empty');\n colElement.dataset.col = col;\n colElement.dataset.row = row;\n rowElement.appendChild(colElement);\n }\n board.appendChild(rowElement);\n }\n }", "title": "" }, { "docid": "8802be655a17d5a56d185267556f5307", "score": "0.7152399", "text": "generateBoard() {\n let rows = [];\n for (let i = 0; i < 8; i++) {\n let cells = [];\n for (let j = 0; j < 8; j++) {\n if ((i === 3 && j === 3) || (i === 4 && j === 4)) {\n cells.push(0); //represents the color white\n } else if ((i === 3 && j === 4) || (i === 4 && j === 3)) {\n cells.push(1); //represents the color black\n } else {\n cells.push(null);\n }\n }\n rows.push(cells);\n }\n\n this.globalVars.game = rows;\n return rows;\n }", "title": "" }, { "docid": "bc0e20b5ff977cd9219775f07038497d", "score": "0.7152122", "text": "makeHtmlBoard() {\n const htmlBoard = document.getElementById('board');\n \n // Create the top row of our board which will act as the game controller for the players. Top row contains a control-row id and a click event listener.\n const controlRow = document.createElement('tr');\n controlRow.setAttribute('id', 'control-row');\n controlRow.addEventListener('click', this.handleClick.bind(this));\n \n for (let x = 0; x < this.width; x++) {\n const controlCell = document.createElement('td');\n controlCell.setAttribute('id', x);\n controlRow.append(controlCell);\n }\n htmlBoard.append(controlRow);\n \n // make main part of board\n for (let y = 0; y < this.height; y++) {\n const gameRow = document.createElement('tr');\n for (let x = 0; x < this.width; x++) {\n const gameCell = document.createElement('td');\n gameCell.setAttribute('id', `${y}-${x}`);\n gameRow.append(gameCell);\n }\n htmlBoard.append(gameRow);\n }\n }", "title": "" }, { "docid": "0156f75b19a56bba5dbce026786faa46", "score": "0.71475637", "text": "function drawBoard() {\n const board = document.querySelector('.board');\n board.innerHTML = '';\n\n board.style.gridTemplateRows = `repeat(${height}, ${cellSize}px)`;\n board.style.gridTemplateColumns = `repeat(${width}, ${cellSize}px)`;\n\n for (let i = 0; i < height; i++) {\n for (let j = 0; j < width; j++) {\n const cell = document.createElement('div');\n cell.classList.add('cell');\n cell.setAttribute('data-row-index', i);\n cell.setAttribute('data-col-index', j);\n cell.addEventListener('click', onCellClick);\n cell.addEventListener('mouseenter', onCellMouseEnter)\n board.appendChild(cell);\n }\n }\n}", "title": "" }, { "docid": "99f20ba65f7ac1b37d970b9aa4d913d7", "score": "0.7146519", "text": "function buildBoard() {\n \n // Clear any previous games\n $(\"#gameboard\").empty();\n \n // Clear the score\n //travelodge.score = 0;\n \n // Create a temporary array to hold all the cards for the board.\n var boardArray = [];\n \n // Push in each of the cards from the cardArray twice.\n for(var h=0; h < travelodge.cardArray.length; h++) {\n boardArray.push(travelodge.cardArray[h]);\n boardArray.push(travelodge.cardArray[h]);\n }\n \n // Shuffle the board array.\n boardArray.shuffle();\n \n // Build the HTML for each card and card row.\n var cardHTML = \"\";\n \n // We have 18 cards so 6 cards in 3 rows...\n for(var i=0; i < 3; i++) {\n \n // Build the card row\n cardHTML += '<div class=\"row card-row\">';\n \n // For each row, build the cards...\n for(var j=0; j < 6; j++) {\n cardHTML += '<div class=\"span2 panel\">';\n cardHTML += '<div class=\"face front\">';\n cardHTML += '<img class=\"cardback\" src=\"/img/cardback2.jpg\" alt=\"Card Back\" /></div>';\n cardHTML += '<div class=\"face back\">';\n cardHTML += '<img class=\"cardfront\" src=\"/img/'+boardArray[j+i*6].file+'\" alt=\"Card Front\" /></div>';\n cardHTML += '</div>';\n }\n \n // Finish the row.\n cardHTML += '</div>';\n \n }\n \n // Add the rows of cards to the gameboard.\n $(\"#gameboard\").append(cardHTML);\n \n }", "title": "" } ]
af543dc5f1386a5797e8b17ae886fd6f
Called from coffee_favorites.html Updates a coffee in user favorites database with given notes. User will be prompted to confirm before update is initiated.
[ { "docid": "46765942312849185e2146fe084aa728", "score": "0.77824587", "text": "function userUpdateFavorite() {\n\tif (confirm(\"Would you like to update your notes for this coffee?\")) {\n\t\tvar ref = db.ref('users/' + firebase.auth().currentUser.uid + '/favorites');\n\t\tvar coffeename = document.getElementById(\"name\").value;\n\t\tref.on('value', function(snapshot) {\n\t\t\tsnapshot.forEach(function(Snapshot) {\n\t\t\t\t\n\t\t\t\tif (Snapshot.val().name === coffeename) {\t\t\t\n\t\t\t\t\tremRef = db.ref('users/' + firebase.auth().currentUser.uid + '/favorites/' + Snapshot.key);\n\t\t\t\t\tremRef.set({\n\t\t\t\t\timage_url: Snapshot.val().image_url, \n\t\t\t\t link: Snapshot.val().link,\n\t\t\t\t location: Snapshot.val().location,\n\t\t\t\t name: Snapshot.val().name,\n\t\t\t\t notes: document.getElementById(\"note\").value,\n\t\t\t\t price: Snapshot.val().price,\n\t\t\t\t rating: Snapshot.val().rating,\n\t\t\t\t served: Snapshot.val().served\n\t\t\t\t })\n\t\t\t\t\t\t.then(function() {\n\t\t\t\t \tconsole.log(\"Update succeeded.\");\n\t\t\t\t \tlocation.reload();\n\t\t\t\t \t})\n\t\t\t\t \t.catch(function(error) {\n\t\t\t\t \tconsole.log(\"Update failed: \" + error.message);\n\t\t\t\t \t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\telse {\n\t\treturn false;\n\t}\n}", "title": "" } ]
[ { "docid": "e97531ae08b007a9410cad1b4fa875b6", "score": "0.62683153", "text": "updateUserFavorites(favorites) {\n updateFavoriteList({ holidayList: favorites })\n .then(() => {\n this.showToast(FAV_UPDATE_SUCCESS_TITLE, FAV_UPDATE_SUCCESS_VARIANT)\n })\n .catch((error) => {\n this.showToast(FAV_UPDATE_ERROR_TITLE, FAV_UPDATE_ERROR_VARIANT)\n });\n }", "title": "" }, { "docid": "42c2b2c7bdea79188f85a473c8644845", "score": "0.6127716", "text": "function updateNote() {\n\n}", "title": "" }, { "docid": "8d252617a429ac9a412e9e2dd3279fd4", "score": "0.61112016", "text": "function favoriteNote(id){\r\n note = notes.find(item => item.id == id)\r\n note.isFavorite = true;\r\n favorites = notes.filter(item => { \r\n return item.isFavorite === true\r\n });\r\n renderNotes(favorites, favoriteList);\r\n}", "title": "" }, { "docid": "cbd8145f7fc1e07226cec4f0c9330b61", "score": "0.6054291", "text": "function didPressConfirm () {\n\tconst clientToEdit = document.getElementById('client').value;\n\tconst newName = document.getElementById('name').value;\n\tconst newEmail = document.getElementById('email').value;\n\tconst newAddress = document.getElementById('address').value;\n\tvar updates = {};\n\n\tif (clientToEdit === '') {\n\t\talert ('You must choose a client to edit.');\n\t\treturn;\n\t}\n\n\tif (newName !== '') {\n\t\tupdates['/Clients/' + cidDict[clientToEdit] + '/name'] = newName;\n\t\tupdates['/PersistenceStartup/Clients/' + cidDict[clientToEdit]] = newName;\n\t}\n\tif (newEmail !== '') {\n\t\tupdates['/Clients/' + cidDict[clientToEdit] + '/email'] = newEmail;\n\t}\n\tif (newAddress !== '') {\n\t\tupdates['/Clients/' + cidDict[clientToEdit] + '/address'] = newAddress;\n\t}\n\n\tdbref.update(updates)\n\t\t.then(() => {\n\t\t\tconsole.log ('Client Update Success');\n\t\t\talert ('Successfully Updated Client!');\n\t\t})\n\t\t.catch ((err) => {\n\t\t\tconsole.log (err);\n\t\t\talert (err.message);\n\t\t})\n}", "title": "" }, { "docid": "a297490d8534ae670c5de20a39ea0134", "score": "0.60503626", "text": "update(e) {\n e.preventDefault();\n const { note: { key } } = this.props;\n const title = this.state.title\n ? this.state.title\n : this.props.note.title;\n const content = this.state.content\n ? this.state.content\n : this.props.note.content;\n noteRepository.update({ key, title, content }, err => {\n if (err) return this.props.alertHandler({\n type: 'error',\n message: 'Failed to update note',\n });\n\n this.dismissModal();\n });\n }", "title": "" }, { "docid": "606453f9670236ba2eacde327d58d90b", "score": "0.60356116", "text": "function addNoteToFavorites(userId, noteId, done) {\n logger.info(\"Inside controller method - add note to favorite\");\n notesService.addNoteToFavorites(userId, noteId, done);\n}", "title": "" }, { "docid": "cd51364816ed60f71c5a87146096e33a", "score": "0.59608483", "text": "function confirmUpdate(){\n confirmed = true;\n updateUser(confirmed);\n clearForm();\n}", "title": "" }, { "docid": "1bb620777a2fd468c16d77068c32ee05", "score": "0.59286225", "text": "function toggleFavourites(notebook, noteID){\r\n let notes = getNotes(notebook);\r\n\r\n notes.forEach(function(note){\r\n if(note.id == noteID){\r\n note.favourite = !note.favourite;\r\n }\r\n });\r\n\r\n saveFile(getNotebookPath(notebook), JSON.stringify(notes));\r\n}", "title": "" }, { "docid": "9ac738325968281104d931ed0521b182", "score": "0.58947694", "text": "function updateNote(noteID) {\n sessionStorage.setItem(\"noteid\", noteID)\n location.href = 'updateNote';\n}", "title": "" }, { "docid": "66df0db134a2b953023fcedbea3f7a95", "score": "0.5829081", "text": "update_notes(img_path, proj_name, notes) {\n var _this = this;\n var db = this.db;\n db.serialize(function() {\n var stmt = db.prepare(\"UPDATE Images SET notes=? WHERE path=? AND proj_name=?\");\n stmt.run(notes, img_path, proj_name);\n stmt.finalize();\n });\n }", "title": "" }, { "docid": "37da8860c6247d4325d6a81a7786dde1", "score": "0.5803095", "text": "function askUserNotes() {\n navigator.notification.prompt(\n 'This is an opportunity to enter any notes you wish to remember about this session', // message\n onPrompt, // callback to invoke\n 'User Notes', // title\n ['Ok'], // buttonLabels\n ' ' // defaultText\n );\n}", "title": "" }, { "docid": "9409dd1faea6d760206b09a96a281c48", "score": "0.5802294", "text": "function editPersonNotes() {\n var person_id = parseInt(localStorage.getItem('person_id'));\n var new_person_notes = '';\n for (i = 0; i < persons.length; i++){\n if (persons[i].id == person_id) {\n new_person_notes = prompt(\"Edit person's notes: \", persons[i].notes);\n persons[i].note = new_person_notes;\n fetch('/persons/' + person_id, {\n method: 'PATCH',\n body: JSON.stringify({\"picture\": persons[i].picture, \"name\": persons[i].name, \"notes\": new_person_notes}),\n headers: {\n 'Content-Type': 'application/json'\n }\n })\n }\n }\n $('#FaceBox-EditNotes').html(new_person_notes);\n }", "title": "" }, { "docid": "79799edb9c243b7af6bf7e3d39a4f330", "score": "0.5772056", "text": "function userAddFavorite() {\n\tif (confirm(\"Would you like to add this coffee to your favorites list?\")) {\n\t\tvar ref = db.ref('users/' + firebase.auth().currentUser.uid + '/favorites');\n\t\tvar coffeename = document.getElementById(\"name\").value;\n\t\tdb.ref('coffees').on('value', function(snapshot) {\n\t\t\tsnapshot.forEach(function(Snapshot) {\n\t\t\t\tif (Snapshot.val().name === coffeename) {\n\t\t\t\t\tref.push(Snapshot.val());\n\t\t\t\t\tconsole.log(\"Add succeeded.\");\n\t\t\t\t\twindow.location.href = './SearchForCoffee.html'\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\telse {\n\t\treturn false;\n\t}\n}", "title": "" }, { "docid": "83e6f6dbc566faf0b584d4c60b400f4b", "score": "0.57381636", "text": "function editAFavorite(req, res) {\n\n}", "title": "" }, { "docid": "20f47cbff22a06790ac36644706ac6eb", "score": "0.5729554", "text": "static updateFavorites(restaurantId, isFavorite) {\r\n fetch(`${DBHelper.DATABASE_URL}/restaurants/${restaurantId}/?is_favorite=${isFavorite}`, {\r\n method: 'PUT'\r\n });\r\n }", "title": "" }, { "docid": "2fa83b2276ca1019e6a19217f4c714f5", "score": "0.56967217", "text": "function updateFavor(req, res) {\n console.log(\"Im in UpdateFavor now on the server side\");\n // console.log(req.params);\n console.log(req.body);\n // console.log(req);\n // console.log(ssn);\n console.log(\"going to do the update now\");\n ssn = req.session;\n console.log(\"current User \" + ssn.currentUser.id);\n var favorId = req.body.id;\n var favorAskerId = req.body.favor_asker_id;\n\n // if (req.body.favor_completer_id === '') {\n // var favorCompleterId = ssn.currentUser.id;\n // var favorCompleterName = ssn.currentUser.user_name;\n // } else {\n var favorCompleterId = req.body.favor_completer_id;\n var favorCompleterName = req.body.favor_completer_name;\n // }\n var favorPrice = req.body.favor_price;\n console.log(\"favorId \" + favorId);\n //when the pending button is clicked, update the favor status to pending\n //and add the favor completer id and name\n //else then complete button was clicked, and youjust update the sttus to complete\n //and update the users' karma koins\n //updating the karma koins on the user table can happen asyncronously from updating the favors table\n if (req.body.favor_status == \"pending\") {\n console.log(\"in the pending if\");\n console.log(\"ssn.currentUser.user_name \" + ssn.currentUser.user_name);\n console.log(req.body);\n db.Favor.update({\n favor_completer_id: ssn.currentUser.id,\n favor_completer_name: ssn.currentUser.user_name,\n favor_status: req.body.favor_status\n }, {\n where: {\n id: {\n $eq: req.body.id\n }\n }\n }).then(function (data, err) {\n console.log(data);\n if (err) {\n // If an error occurred, send a generic server failure\n console.log(\"an error occurred\");\n console.log(err);\n res.status(500).end();\n } else if (data[0]) {\n console.log(\"favor is updated\");\n getFavorsDetail(req, res);\n // res.status(200).end();\n }\n });\n\n } else {\n console.log(\"in the complete if\");\n db.Favor.update({\n favor_status: req.body.favor_status\n }, {\n where: {\n id: {\n $eq: req.body.id\n }\n }\n }).then(function (data, err) {\n console.log(data);\n if (err) {\n // If an error occurred, send a generic server failure\n console.log(\"an error occurred\");\n console.log(err);\n res.status(500).end();\n } else if (data[0]) {\n console.log(\"favor is updated\");\n console.log(\"about to call updateKarmaKoins\");\n console.log(\"req.body.favorCompleter \" + favorCompleterId);\n updateKarmaKoins(favorAskerId, favorCompleterId, favorPrice);\n getFavorsDetail(req, res);\n // res.status(200).end();\n }\n });\n // getFavorsDetail(req, res);\n }\n // console.log(\"queryDetails \" + JSON.stringify(queryDetails));\n // var queryDetailsString = queryDetails.join();\n // console.log(\"queryDetailsString \" + queryDetailsString);\n // db.Favor.update({\n // queryDetailsString\n // })\n // .then(function (data, err) {\n // console.log(data);\n // if (err) {\n // // If an error occurred, send a generic server failure\n // console.log(\"an error occurred\");\n // console.log(err);\n // res.status(500).end();\n // } else if (data[0]) {\n // console.log(\"favor is updated\");\n // res.status(200).end();\n // }\n // });\n // getFavorsDetail(res);\n}", "title": "" }, { "docid": "8645fa6225484d41f4ba053eec05690e", "score": "0.56772095", "text": "function editPersonNotes() {\n //prompts user for input and then update array\n library_persons_notes[individualsId] = prompt(\"Edit Person's Notes\", library_persons_notes[individualsId]);\n\n //update local storage\n window.localStorage.setItem('library_persons_notes_local', JSON.stringify(library_persons_notes));\n\n //update name on page \n $('#FaceBox-EditNotes').html(library_persons_notes[individualsId]);\n }", "title": "" }, { "docid": "f789c1bcd21bcaf92c113eb863387569", "score": "0.56699353", "text": "function editNote(){\n //Get current data\n currentNoteDescription = localStorage.getItem('currentNoteDescription');\n currentNoteText = localStorage.getItem('currentNoteText');\n currentNoteTime = localStorage.getItem('currentNoteTime');\n currentNoteDate = localStorage.getItem('currentNoteDate');\n\n var notes = getNotesObject();\n\n //Loop trhough all current runs \n for (var i =0; i<notes.length; i++){\n\n if(notes[i].noteDescription == currentNoteDescription && notes[i].noteText == currentNoteText && notes[i].noteTime == currentNoteTime && notes[i].noteDate == currentNoteDate){\n \n notes.splice(i, 1);\n }\n\n localStorage.setItem('notes', JSON.stringify(notes));\n }\n\n //grabbing the values from form\n var noteDescription = $('#noteDescriptionEdit').val();\n var noteText = $('#noteEdit').val();\n var currentdate = new Date(); \n var noteDate = currentdate.getDate() + \"/\"\n + (currentdate.getMonth()+1) + \"/\" \n + currentdate.getFullYear() \n \n var noteTime = currentdate.getHours() + \":\" + currentdate.getMinutes()\n\n //Creating an object called run, and assigning its attriubtes\n var update_notes = {\n noteDescription: noteDescription,\n noteText: noteText,\n noteDate: noteDate,\n noteTime: noteTime\n };\n\n //Add new run to runs array \n notes.push(update_notes);\n\n //Stringef object to local storage (saving Json in to localstorage)\n localStorage.setItem('notes', JSON.stringify(notes));\n\n //Redriecting to index page \n window.location.href = \"index.html\";\n\n return false;\n\n }", "title": "" }, { "docid": "c2983b52610f911c254b8c4cfbbe3410", "score": "0.5667068", "text": "#update() {\n\n // get our id, name, and note\n const id = this.#id,\n name = this.#name,\n note = this.#content;\n\n // request to store the html\n return fetch('/api/note', {\n method: 'PUT',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({ id, name, note })\n });\n }", "title": "" }, { "docid": "fee6bef78107cf7dcfec21be71a1557a", "score": "0.56484026", "text": "function setConfirmHandler(infowindow, $notes){\n $('.confirm').click(function(e){\n e.preventDefault();\n var payload = {\n name: currentPlace.name,\n place_id: currentPlace.place_id,\n type: currentPlace.types[0],\n address: currentPlace.formatted_address,\n lat: currentPlace.geometry.location.lat(),\n lng: currentPlace.geometry.location.lng(),\n notes: $('.notes').val()\n };\n console.log($(this).attr('data-id'))\n $.ajax({\n url: '/api/users/edit/addfavorite',\n method: 'put',\n saveButton: $(this),\n data: payload,\n success: function(data){\n\n var counter = $(this.saveButton).attr('data-id');\n var marker = markers[counter];\n\n\n // TEMP: append to profile div\n var $li = $('<li>').text(data.name);\n $('#favorite-places').append($li);\n\n // Remove icon in favor of new\n marker.setMap(null);\n getCurrentProfileUser();\n }\n });\n getCurrentUser();\n })\n}", "title": "" }, { "docid": "e73ddb4cf629b4ae0037ff620ac70fad", "score": "0.562592", "text": "function updateNote() {\n $(document).on(\"submit\", \".save-note\", function(event) {\n event.preventDefault();\n var values = $(this).serialize();\n var url = $(event.target).attr('action');\n $.post(url, values, function( data ) {\n var note = new Note(data);\n $(\"#note-\" + note.id).html(\"\");\n $(\"#note-\" + note.id).html(noteRender);\n var noteRender = note.renderIndexNote();\n $(\".notes-block\").prepend(noteRender);\n });\n }); \n}", "title": "" }, { "docid": "aebd070a189ff18297c91e0a4942c01e", "score": "0.55908096", "text": "saveNote() {\n // Upsert\n this.httpRequestService.putData('notes', this.note).then(response => {\n this.cancelModal('ok');\n\n // Display list\n this.$state.go('notes');\n })\n }", "title": "" }, { "docid": "62249e052cb83628bd730c382f5131a0", "score": "0.556103", "text": "function userRemoveFavorite() {\n\tif (confirm(\"Would you like to remove this coffee from your favorites list?\")) {\n\t\tvar ref = db.ref('users/' + firebase.auth().currentUser.uid + '/favorites');\n\t\tvar coffeename = document.getElementById(\"name\").value;\n\t\tref.on('value', function(snapshot) {\n\t\t\tsnapshot.forEach(function(Snapshot) {\n\t\t\t\tif (Snapshot.val().name === coffeename) {\t\t\t\n\t\t\t\t\tremRef = db.ref('users/' + firebase.auth().currentUser.uid + '/favorites/' + Snapshot.key);\n\t\t\t\t\tremRef.set(null)\n\t\t\t\t\t\t.then(function() {\n\t\t\t\t \tconsole.log(\"Remove succeeded.\");\n\t\t\t\t \twindow.location.href = './CoffeeStorage.html'\n\t\t\t\t \t})\n\t\t\t\t \t.catch(function(error) {\n\t\t\t\t \tconsole.log(\"Remove failed: \" + error.message);\n\t\t\t\t \t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\telse {\n\t\treturn false;\n\t}\n}", "title": "" }, { "docid": "8b071941453a1457e46efbc7c270f61b", "score": "0.5548136", "text": "function updateNote(userId, noteId, updateNoteObj, done) {\n logger.info(\"Inside controller method - update existing note\");\n if (!updateNoteObj.title) return done(\"Please provide all Mandatory fields\");\n\n async.waterfall([\n (cb => notesService.updateNote(userId, noteId, updateNoteObj, cb)),\n ((modifiedNoteObj, cb) => {\n if (updateNoteObj.startDateTime && updateNoteObj.endDateTime && updateNoteObj.frequency) {\n let updateReminderObj = {\n 'startDateTime': updateNoteObj.startDateTime,\n 'endDateTime': updateNoteObj.endDateTime,\n 'frequency': updateNoteObj.frequency\n }\n remindersCtrl.updateReminder(userId, noteId, updateReminderObj, cb);\n }\n })\n ], (err, result) => {\n return done(err, {message: \"Note updated successfully.\"});\n });\n}", "title": "" }, { "docid": "8db1dbee9870ae77bb4765d1f1ec34c6", "score": "0.55287737", "text": "function confirmFavoriteSave() {\n const saveFavoriteButton = $('#save_favorite_button');\n const checkboxes = document.getElementsByClassName(\"ingredientcheckbox\");\n let favoriteOrderIngredients = [];\n for (let i = 0; i < checkboxes.length; i++) {\n if (checkboxes[i].checked) {\n let ingredientPanel = checkboxes[i].parentElement.parentElement;\n favoriteOrderIngredients.push({\n ingredient_type_id: ingredientPanel.getAttribute(\"data-ingredient-type-id\"),\n _id: ingredientPanel.getAttribute(\"data-ingredient-id\"),\n name: checkboxes[i].parentElement.innerText\n });\n }\n }\n if (newFavoriteName && isValidOrder(favoriteOrderIngredients)) {\n saveFavoriteButton.attr(\"data-dismiss\", \"modal\");\n $.ajax({\n url: get_api_url() + \"favorite_orders/\" + thisOrderID,\n method: 'PUT',\n data: {\n ingredients: favoriteOrderIngredients,\n favorite_name: newFavoriteName\n },\n success: function (updated_favorite_order) {\n getFavoritesOn(getCurrentPath());\n showAlert(`\"${updated_favorite_order.favorite_name}\" has been updated.`);\n }\n });\n } else if (!newFavoriteName) {\n alert(\"Please enter name for this favorite.\")\n }\n}", "title": "" }, { "docid": "63d48dac840dad568067ff15a5bf3ebf", "score": "0.54761016", "text": "function setNote(id, title, body, category, tag, archive, view, links) {\n var db = getDatabase();\n var res = \"\";\n db.transaction(function(tx) {\n var rs = tx.executeSql('INSERT OR REPLACE INTO notes VALUES (?,?,?,?,?,?,?,?);', [id,title,body,category,tag,archive,view,links]);\n //console.log(rs.rowsAffected)\n if (rs.rowsAffected > 0) {\n res = \"OK\";\n } else {\n res = \"Error\";\n }\n }\n );\n // The function returns “OK” if it was successful, or “Error” if it wasn't\n return res;\n}", "title": "" }, { "docid": "f4ca323d2d675827f22d458367054310", "score": "0.5475988", "text": "function deleteNote() {\n \n var noteToDelete = $(this).data(\"_id\");\n $.ajax({\n url: \"/api/notes/\" + noteToDelete,\n method: \"DELETE\"\n }).then(function() {\n $.confirm({\n columnClass: 'col-md-8 col-md-offset-2',\n title: 'Notes for this article, ' + currentArticle._id + ', has been deleted!',\n })\n });\n }", "title": "" }, { "docid": "8350fe4c11d16385cc748c151c35b3f2", "score": "0.546595", "text": "function addNotes () {\n\t var db = openDatabase(shortName, version, displayName, maxSize);\n\t \n\t db.transaction(function (transaction) {\n var chooseProperty = document.getElementById(\"chooseProperty\").value;\n var propertyNotes = document.getElementById(\"propertyNotes\").value;\n\ntransaction.executeSql('UPDATE property SET notes = ? WHERE rowid = ?', [ propertyNotes, chooseProperty], successCallBack, errorHandler);\n});\n\t\n}", "title": "" }, { "docid": "2d231c99c6a0623128deb71260a7e273", "score": "0.5456708", "text": "function updatefunction(index) { // it is added as attribute in html\n let indexVariable = index / 1000; //getting index to show, multiplication and division was used to make, id for html element unique\n let updateTitle = document.getElementById(\"UpdatefloatingTextTitlearea\"); //gettint update title ,update notes, checkbox Input area\n let updateNotes = document.getElementById(\"UpdatefloatingTextarea\");\n let updateImportant = document.getElementById(\"UpdatecustomControlAutosizingUpdate\");\n updateTitle.value = titleArray[indexVariable]; //setting those values of the notes (1)\n updateNotes.value = notesArray[indexVariable]; // which user has clicked (2)\n updateImportant.checked = checkBoxArray[indexVariable];\n let notesHeading = document.getElementById(\"UpdateNotesNumber\"); //getting heding of notes element to add notes number\n notesHeading.innerHTML = (indexVariable + 1); // showing notes number, which user wants to update\n} // saving the updated notes", "title": "" }, { "docid": "6397abcd93b5ea8122e5977c3e7f5150", "score": "0.54559606", "text": "function updateNote(newNote) {\n return {\n type: \"CHANGE_NOTE\",\n payload: newNote\n };\n}", "title": "" }, { "docid": "9d81ab587bc6702f931225c6f56d5a9b", "score": "0.54468477", "text": "function unFavoriteNote(id){\r\n note = notes.find(item => item.id == id)\r\n note.isFavorite = false;\r\n favorites = notes.filter(item => { \r\n return item.isFavorite === true\r\n });\r\n renderNotes(favorites, favoriteList);\r\n}", "title": "" }, { "docid": "816827c55c82231832355be66227dfba", "score": "0.5425671", "text": "function updateNote(request, response, data) {\n var parsedData = JSON.parse(data);\n var id = parsedData.noteId;\n var title = parsedData.noteTitle;\n var content = parsedData.noteContent;\n var x = parseInt(parsedData.x, 10);\n var y = parseInt(parsedData.y, 10);\n var toUpdate = [];\n \n if (title) toUpdate.push(\"note_title='\" + title + \"'\");\n if (content) toUpdate.push(\"note_content='\" + content + \"'\");\n if (x) toUpdate.push(\"x=\" + x);\n if (y) toUpdate.push(\"y=\" + y + \" \");\n\n if (toUpdate.length > 0) {\n var updateNoteQuery = \n \"UPDATE note \" +\n \"SET \" + toUpdate.join(', ') +\n \"WHERE note_id=\" + id;\n pg.connect(connectionString, function(err, client, done) {\n client.query(updateNoteQuery, function(err, result) {\n done(client);\n if (err) { return utils.respondError(err, response); }\n return utils.respondPlain(response, \"Y\");\n });\n });\n var username = utils.getUser(request);\n var groupId = utils.getViewingGroup(request);\n notificationServer.checkForNotification(title, username, groupId, \"posts\"); \n notificationServer.checkForNotification(content, username, groupId, \"posts\"); \n }\n}", "title": "" }, { "docid": "af85203552dc4b756d5c42b5d50e7944", "score": "0.5391103", "text": "function checkEdits() {\n\t\tlet textTwo = document.createTextNode(\"✓\");\n\t\tif(localStorage.userEdits != null)\n\t\t\tdocument.querySelector(\"#saved-notes\").innerHTML = localStorage.userEdits;\n\t\t\n\t\t// Hide a saved note when clicked close button\n\t\tfor (i = 0; i < close.length; i++){\n\t\t\tclose[i].onclick = function() {\n\t\t\t\tlet div = this.parentElement;\n\t\t\t\tdiv.style.display = \"none\";\n\t\t\t}\n\t\t}\n\t for (i = 0; i < edit.length; i++){\n\t\tedit[i].onclick = function() {\n\t\tlet div = this.parentElement;\n\t\t\n\t\t// Make notes editable when clicked edit button\n\t\tlet hideMessage;\n\t\tlet noteEditable = document.querySelector(\"#myNotes, #saved-notes\").contentEditable;\n\t\tif (noteEditable == 'inherit' || noteEditable == 'false') {\n\t\t\tdocument.querySelector(\"#myNotes\").contentEditable = true;\n\t\t\tdocument.querySelector(\"#saved-notes\").contentEditable = true;\n\t\t\ttextTwo.nodeValue = '✓';\n\t\t} else {\n\t\t\tdocument.querySelector(\"#myNotes\").contentEditable = false;\n\t\t\tdocument.querySelector(\"#saved-notes\").contentEditable = false;\n\t\t\ttextTwo.nodeValue = ':';\n\t\t\t// Write a confirmation to the user\n\t\t\tdocument.querySelector(\"#update\").innerHTML = \"Changes saved\";\n\t\t\tdocument.querySelector(\"#update\").style.backgroundColor = \"lightgreen\";\n\t\t\tdocument.querySelector(\"#update\").style.border = \"1px solid\";\n\t\t\thideMessage = setTimeout(hideIt, 3000); // hide message in 3secs\n\t\t }\n\t }\n\t }\n\t}", "title": "" }, { "docid": "2b15b2792b8ca0526ad95dd739c4befe", "score": "0.53860515", "text": "async function updateFavorites() {\n if (icon === \"favorite\") {\n // This means heart was pressed\n Storage.addToFavorites(article).then((msg) => {\n Toast.show(msg);\n Storage.getFavorites().then((data) => {\n initFavorites(data);\n });\n });\n } else {\n // Otherwise remove article if exists from favorites\n Storage.removeFromFavorites(article).then(() => {\n Storage.getFavorites().then((data) => {\n initFavorites(data);\n });\n });\n }\n }", "title": "" }, { "docid": "bbb7d4ed0f5991f452095c5b92789abc", "score": "0.53784215", "text": "updateNote(username, id, note) {\n return axios.put(`${API_URL}/notes/${username}/${id}`, note);\n }", "title": "" }, { "docid": "dc2ab8efc11ba2701d898d3d6da7174a", "score": "0.5377926", "text": "function editNotes(noteFormObj, userCharacterId) {\n console.log(\"editNotes noteFormObj, userCharacterId\", noteFormObj, userCharacterId);\n return $.ajax({\n url: `${firebase.getFBsettings().databaseURL}/userCharacter/${userCharacterId}.json`,\n type: 'PATCH',\n data: JSON.stringify(noteFormObj)\n }).done((data) => {\n console.log(\"url for firebase\", `${firebase.getFBsettings().databaseURL}/userCharacter/${userCharacterId}.json`);\n return data;\n });\n}", "title": "" }, { "docid": "ed34c55447702706e55b2021dc79e07f", "score": "0.5332083", "text": "function commitNoteChanges (id) {\n if (id === 0) {\n return addNote()\n }\n let noteTitle = select(`#title-${id}`).value\n let noteBody = select(`#body-${id}`).value\n let request = {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ \"title\": noteTitle, \"body\": noteBody })\n }\n\n fetch(noteURL(id), request)\n .then(response => {\n if (statusOK(response.status)) {\n displayNote(id)\n alert(\"Note changes saved.\")\n } else {\n alert(\"A calamitous problem occured.\")\n }})\n}", "title": "" }, { "docid": "75494cd05f6796096fec4b6ef3c2e58d", "score": "0.53234094", "text": "function changeFavourite(jsonargs) {\n var args = JSON.parse(jsonargs);\n var favouriteItem=args[0];\n var sonosid=args[1];\n LaunchBar.displayNotification({string:'Sonos Play Favourite: \\''+favouriteItem+'\\'', title:\"LaunchBar: Sonos Favourites\", delay:'0s'});\n favouriteItem = encodeURIComponent(favouriteItem);\n var changeResult = HTTP.getJSON(serverRoot+encodeURIComponent(sonosid)+'/favorite/'+favouriteItem);\n LaunchBar.executeAppleScript('tell application \"LaunchBar\" to hide');\n}", "title": "" }, { "docid": "b24da3a1915f77bf5aad6da45f7953d6", "score": "0.532095", "text": "function editNotes(selected, type) {\n var notes = selected.map(function(b){ return b.note }).join(',');\n var ids = selected.map(function(b){ return b.id });\n\n // show the note edit prompt\n egPromptDialog.open(\n egCore.strings.EDIT_BILL_PAY_NOTE, notes, {\n ids : ''+ids,\n ok : function(value) {\n\n var func = 'updateBillNotes';\n if (type == 'payment') func = 'updatePaymentNotes';\n\n billSvc[func](value, ids).then(function() {\n if (type == 'payment') {\n paymentGrid.refresh();\n } else {\n xactGrid.refresh();\n }\n });\n }\n }\n );\n }", "title": "" }, { "docid": "0c77995cba7ef9dd9efb31a5ff1dd208", "score": "0.53204906", "text": "static async updateFavorite(id, is_favorite) {\n return fetch(`${DBHelper.DATABASE_URL}/restaurants/${id}/?is_favorite=${is_favorite}`, {\n method: 'PUT'\n });\n }", "title": "" }, { "docid": "f6fad5b25a8a8d5e4f54850416fa47bf", "score": "0.5315472", "text": "function deleteNote(index){\r\n let confirmDel = confirm(\"Are you Deleting this note!!\");//confirming if really want to delete the note\r\n \r\n if (confirmDel == true) {//if user confirm\r\n let notes = localStorage.getItem(\"notes\");\r\n if (notes == null) {\r\n notesObj = [];\r\n \r\n }else {\r\n notesObj = JSON.parse(notes);\r\n }\r\n\r\n notesObj.splice(index, 1); //deleting a item in array which is clicked\r\n localStorage.setItem(\"notes\" , JSON.stringify(notesObj));//sent back item to the local storage\r\n showNotes();//calling shownotes function\r\n }\r\n}", "title": "" }, { "docid": "d1638e8342423fd68b0a1371c4d7e5d7", "score": "0.5300974", "text": "function saveNote(id, note) {\n console.log(id); console.log(note);\n $.post(\"/Admin/UpdateNote\", { id: id, note: note });\n}", "title": "" }, { "docid": "11979431e13f1b4b1075bbb50e3ad7fd", "score": "0.5299801", "text": "async update({ request, params, response, session }) {\n const task = await Task.find(params.id)\n task.title = request.input(\"title\")\n task.body = request.input(\"body\")\n\n await task.save()\n\n session.flash({ notification: {\n type : \"success\",\n message: \"Task updated!\"\n }})\n\n return response.redirect(\"back\")\n }", "title": "" }, { "docid": "ae707b72d80e1fccc60391ad2ff0c9d4", "score": "0.5293693", "text": "function songOverride(){\n swal(\n {\n title: \"Override existing song?\" ,\n text: title + \" - \" + artist + \" (\" + year + \")\",\n type: \"warning\",\n showCancelButton: true,\n closeOnConfirm: false,\n showLoaderOnConfirm: true,\n },\n function(isConfirm){\n if(isConfirm) {\n $.post(\"ajax/songOverride.php\",\n {\n chords : chords,\n lyrics : lyrics,\n bpm : bpm\n },\n function(data,status){\n if(data=='success'){\n setTimeout(function(){\n swal({\n title:\"Song updated!\",\n text: title + \" - \" + artist + \" (\" + year + \")\",\n type: \"success\"\n },function(isConfirm){\n if(isConfirm){\n location.reload();\n }\n });\n }, 1000);\n } else {\n setTimeout(function(){\n swal({\n title:\"Database issue, contact admin\",\n text: \"Song not updated (\" + data + \")\",\n type: \"error\"\n });\n }, 1000);\n }\n });\n }\n });\n}", "title": "" }, { "docid": "05782d03d6b9374197208d766e0b6171", "score": "0.5283767", "text": "updateConfirm(confirm) {\n // Note: Add headers if needed (tokens/bearer)\n const httpHeaders = this.httpUtils.getHTTPHeaders();\n const id = confirm.get('id');\n const APi_URL = this.httpUtils.domain + '/api/catalog/confirm/';\n return this.http.put(APi_URL + id, confirm, { headers: httpHeaders });\n }", "title": "" }, { "docid": "8df9e26c7b42eba445b7d94d76208e9e", "score": "0.52775276", "text": "function confirmUpdate(text) {\r\n\tvar r=confirm(text);\r\n\tif (r==true)\r\n\t {\r\n\t return true;\r\n\t }\r\n\telse\r\n\t {\r\n\t return false;\r\n\t }\r\n}", "title": "" }, { "docid": "027e6a4776b9df4266e0aa384d0feb2b", "score": "0.5275224", "text": "function editNote(id) {\r\n note = notes.find(item => item.id == id)\r\n quill.setContents(note.editorData)\r\n titleInput.value = note.title\r\n deleteNote(id);\r\n}", "title": "" }, { "docid": "48b896ea064e5ca1b7dc9408a137a3f2", "score": "0.52723014", "text": "updateNote(state, payload) {\n let notes = getSavedNotes('notesArray')\n for (let note of notes) {\n if (note.id === payload.id) {\n note.title = payload.title\n note.body = payload.body\n break\n }\n }\n state.notes = notes\n saveNotes('notesArray', state.notes)\n }", "title": "" }, { "docid": "38d3331d20b05a7b902e3f13183fcd7e", "score": "0.52706516", "text": "function markAsFavourite() {\n\tlet restaurantId = parseInt(this.dataset.id);\n\n\tfunction putInStore(bool) {\n\t\t// Update local Database\n\t\tdbPromise\n\t\t\t.then(db => {\n\t\t\t\tlet store = db.transaction('restaurants-store', 'readwrite').objectStore('restaurants-store');\n\t\t\t\treturn store.get(restaurantId).then(restaurant => {\n\t\t\t\t\trestaurant.is_favorite = bool;\n\t\t\t\t\tlet restaurantStore = db.transaction('restaurants-store', 'readwrite').objectStore('restaurants-store');\n\t\t\t\t\trestaurantStore.put(restaurant);\n\t\t\t\t\treturn restaurantStore.complete;\n\t\t\t\t})\n\t\t\t})\n\t\n\t\t// Put in favourites Store to sync\n\t\tdbPromise\n\t\t\t.then(db => {\n\t\t\t\tlet favouritesStore = db.transaction('sync-favourites', 'readwrite').objectStore('sync-favourites');\n\t\t\t\tfavouritesStore.put({'id': restaurantId, 'is_favorite': bool}, restaurantId);\n\t\t\t\treturn favouritesStore.complete;\n\t\t\t})\n\t}\n\n\tif (this.checked) {\n\t\tthis.nextElementSibling.innerHTML = ' unmark as favourite';\n\t\tputInStore(true);\n\n\t} \n\telse {\n\t\tthis.nextElementSibling.innerHTML = ' mark as favourite';\n\t\tputInStore(false);\n\t}\n\n\t// Activate Background-Sync with ServiceWorkerReady\n\t// Creates promise to send when reconnected as well.\n\tif ('serviceWorker' in navigator) {\n\t\tnavigator.serviceWorker.ready.then(swRegistration => {\n\t\t\treturn swRegistration.sync.register('sync-favourites');\n\t\t});\n\t}\n}", "title": "" }, { "docid": "15543ce5f5cb9a94c073400c948fd13f", "score": "0.52676356", "text": "function askBeforeDelete() {\n if (window.confirm(\"Would you like to delete this note?\")) {\n deleteNote(noteIndex, boardIndex);\n }\n }", "title": "" }, { "docid": "09b3207e81869b5c5e34160190c5dcbd", "score": "0.5265577", "text": "function set_fretboard(notes) {\n\n non_notes = notesNotIn(notes);\n hideNotes(non_notes);\n\n showNotes(notes);\n\n}", "title": "" }, { "docid": "38347de96d14ecafd48f472e56edaf2c", "score": "0.52575374", "text": "static updateFavoriteRestaurant(id, isFavorite) {\n return fetch(`${DBHelper.RESTAURANTS_URL}/${id}/?is_favorite=${isFavorite}`, {\n method: 'PUT',\n });\n }", "title": "" }, { "docid": "13eea99df6cebaeabc1a441b10cf46ad", "score": "0.5251105", "text": "onUpdateTask(taskId, title, due, notes) {\n\t\tconst { updateTask } = this.props;\n\t\tthis.closeDialog();\n\t\tupdateTask({tasklist: this.state.selectedList.id, task: taskId, id: taskId, title, due, notes});\n\t}", "title": "" }, { "docid": "de4aec1e5abf9d60faefdf2daada7933", "score": "0.52475774", "text": "function editNote(index) {\r\n let notes = localStorage.getItem(\"notes\");//calling notes from local storage\r\n if (addTitle.value !== \"\" || addDescription.value !== \"\") {\r\n return alert(\"Please clear the notes before editing\");\r\n }\r\n if (notes == null) {\r\n notesObj = [];\r\n \r\n }else {\r\n notesObj = JSON.parse(notes);\r\n }\r\n\r\n notesObj.findIndex((element, index) => { //getting item\r\n addTitle.value =element.title;//assigning values to text field\r\n addDescription.value =element.description;\r\n })\r\n\r\n notesObj.splice(index,1);//deleteing item\r\n localStorage.setItem(\"notes\", JSON.stringify(notesObj));//pushing edited items showNotes();\r\n showNotes();\r\n }", "title": "" }, { "docid": "387fb0de176076a6c9eceb1ff5169cdc", "score": "0.5244768", "text": "function editNote(index) {\r\n let notes = localStorage.getItem (\"notes\");\r\n if (addTitle.value !== \"\" || addText.value !== \"\"){\r\n return alert (\"please clear the form before editing a note\");\r\n }\r\n if (notes == null) {\r\n notesObj = [];\r\n } else {\r\n notesObj = JSON.parse(notes);\r\n }\r\n notesObj.findIndex ((element, index) => {\r\n addTitle.value = element.title;\r\n addText.value = element.text;\r\n\r\n\r\n })\r\n notesObj.splice(index, 1);\r\n localStorage.setItem(\"notes\", JSON.stringify(notesObj));\r\nshowNotes();\r\n\r\n}", "title": "" }, { "docid": "e487936fdd1468542d7ae8a3d4fa0855", "score": "0.52367586", "text": "function editNote(index) {\n \n}", "title": "" }, { "docid": "4b2eb1fb7d1325fdb0596421fd9e8ae3", "score": "0.5235225", "text": "static updateFavourite(id, value) {\n fetch(`${DBHelper.DATABASE_URL}/${id}/?is_favorite=${value}`, {\n method: 'PUT'\n }).catch(error=>{\n console.log(\"error in updating the value to the server! Maybe you are offline\");\n });\n this.openDB().then(db => {\n const txn = db.transaction('restaurants', 'readwrite');\n const restaurantsStore = txn.objectStore('restaurants');\n restaurantsStore.get('allRestaurants').then(restauran => {\n console.log(`changing state to ${value}`);\n //restauran = restauran.find(r => r.id == id);\n restauran[id - 1].is_favorite = value;\n restaurantsStore.put(restauran, 'allRestaurants');\n });\n });\n }", "title": "" }, { "docid": "cfe1210d09173cfc11da9f9654dd83f0", "score": "0.5225844", "text": "function deleteNote(id) {\n\n let check = confirm(\"Delete this note?\")\n if (!check) {\n return\n }\n\n let request = {\n method: \"DELETE\"\n }\n\n fetch(noteURL(id), request)\n .then(response => {\n if (statusOK(response.status)) {\n alert(\"Note successfully deleted.\")\n // refresh the notes view\n getShowNotes()\n } else {\n alert(\"A calamitous problem occured.\")\n }})\n}", "title": "" }, { "docid": "cf656eda24aebb0fe37e56ffa41565e0", "score": "0.5222712", "text": "function identifyFavorite(favoriteOrderID) {\n const modalTitle = document.getElementById(\"favoriteName\");\n const saveFavoriteButton = $('#save_favorite_button');\n saveFavoriteButton.attr(\"data-dismiss\", null);\n $(\".ingredientcheckbox\").prop(\"checked\", false);\n let favoriteOrderPromise = $.get(get_api_url() + \"favorite_orders/\" + favoriteOrderID);\n favoriteOrderPromise.success(function (favoriteOrder) {\n modalTitle.innerText = favoriteOrder.favorite_name;\n newFavoriteName = favoriteOrder.favorite_name;\n thisOrderID = favoriteOrderID;\n editFavorite(favoriteOrder);\n })\n\n}", "title": "" }, { "docid": "2b1da4cd4c97d86d505fe7807292261b", "score": "0.52208394", "text": "function updateHTMLList() {\n // clear html list\n document.getElementById('view-notes').innerHTML = ''\n\n //add the notes to the html list\n testNotepad.viewNotes().forEach(function(note, index) {\n let listItem = note.displayNote()\n document.getElementById('view-notes').innerHTML += `<li><a href=\"#note${[index]}\">${listItem}</a></li><br>`\n})\n}", "title": "" }, { "docid": "70af0b506f46b75ce80a26f39fbef9c9", "score": "0.5216019", "text": "function setNote(note, userName = getCurrentUser()) {\n var userNotes;\n\n // get notes from storage\n userNotes = getNotes(userName);\n\n // Check if note id already exists\n noteID = note.id;\n var index = userNotes.findIndex(findByID);\n\n // if note doesn't exist then add it\n if (index == -1) {\n\n userNotes.push(note);\n }\n // if note already exists then replace the old version\n else {\n userNotes[index] = note;\n }\n\n // put notes back into storage\n\n // create a notes object with the right format { \"username\" : \"CURRENTUSERNAME\", \"userNotes\" : []}\n var notesObj = {};\n notesObj.username = userName;\n notesObj.userNotes = userNotes;\n\n var allUsersNotes = JSON.parse(localStorage.getItem(\"notes\"));\n\n // if array of notes doesn't exist yet, then create an empty\n if (allUsersNotes == null)\n allUsersNotes = [];\n\n // set username variable to current username\n username = userName;\n\n // find index of this user notes object if it exists\n var currentUserNotesObjIndex = allUsersNotes.findIndex(findByUsername);\n\n\n // if notes object doesn't exist then add it\n if (currentUserNotesObjIndex == -1) {\n\n allUsersNotes.push(notesObj);\n }\n // if notes object already exists then replace the old version\n else {\n allUsersNotes[currentUserNotesObjIndex] = notesObj;\n }\n\n localStorage.setItem(\"notes\", JSON.stringify(allUsersNotes));\n}", "title": "" }, { "docid": "50acc05990c0d46a64d7c14f4c08ae95", "score": "0.52084327", "text": "function updateFavoritesFeed() {\n favoritesCounter.innerHTML = favorites.all().length;\n\n if (favorites.all().length === 0) {\n const favoriteSection = document.querySelector('#favorite_section');\n favoriteSection.innerHTML = makeNotification('You do not currently have any favorites...');\n return;\n }\n\n favoritesView.update(\n favorites.all().map(\n item => ({ id: item.id, joke: item.text, checked: true })\n )\n );\n\n const maxFavoritesReached = favorites.all().length >= 10;\n if (maxFavoritesReached) {\n randomizeCheckbox.parentElement.setAttribute('disabled', true);\n } else {\n randomizeCheckbox.parentElement.removeAttribute('disabled');\n }\n randomizeCheckbox.disabled = maxFavoritesReached;\n}", "title": "" }, { "docid": "dc3dcce2b6443caa9c42425ee231a121", "score": "0.5194991", "text": "put(req, res) {\r\n console.log(\"PUT\");\r\n\r\n return this.noteService\r\n .update(req.params.id, req.body.note, req.auth.user) // The noteService fires the update command, this will update our note (and our JSON file)\r\n .then(() => this.noteService.list(req.auth.user)) // Then we fire list note from the same noteService which returns the array of notes for that user.\r\n .then((notes) => res.json(notes)) // Then we respond to the request with all of our notes in the JSON format back to our clients browser.\r\n .catch((err) => res.status(500).json(err));\r\n }", "title": "" }, { "docid": "eb1f0bf5c76161cd2cdc25de2b8b015e", "score": "0.5193078", "text": "function addFavorite() {\n favoriteFactory.saveFavorite();\n }", "title": "" }, { "docid": "ddd93cf4e7ca81a8b01b1e3bf09a0d55", "score": "0.51916003", "text": "function putNote() {\n \n if (recognisedNoteID == null) {\n alert('You need to scan an object before you can add a note to it!');\n }\n else {\n uiManager.showNotification(-1, \"wait\", \"Uploading your note...\", -1);\n //PUT a note up\n noteText = imageNote.getText(); \n \n putNoteURL = 'http://notes.moodstocks.com/api/v2/note/' + recognisedNoteID + createHash(widget.preferenceForKey('username'), widget.preferenceForKey('password'));\n\n if (longitude == parseFloat(longitude) && latitude == parseFloat(latitude)) { //checks that latitude and longitude are numbers\n putNoteURL = putNoteURL + '&latitude=' + latitude + '&longitude=' + longitude;\n }\n \n try {\n putAjax = new Ajax();\n putAjax.onreadystatechange = putCallback;\n putAjax.open('PUT', putNoteURL, true);\n putAjax.send(noteText);\n }\n catch (e) {\n uiManager.showNotification(500, \"wait\", \"Sorry, I can't connect. Please check that you are connected to the internet and try again\", null);\n }\n }\n}", "title": "" }, { "docid": "7fcb7d9ed4e9a567c97f3a59776863da", "score": "0.5188107", "text": "function submitNewNote() {\r\n //saves note \r\n saveNewNote();\r\n}", "title": "" }, { "docid": "6c4bc74cb4138bae1db76429fb9fcdad", "score": "0.51849234", "text": "function removeFavorite(coffeeID) {\n //Get favorites\n //var favorites = JSON.parse(localStorage.getItem(\"favorites\"));\n //Find favorite with combination of current user & coffee (based on id)\n for(var x=0;x<favorites.length;x++) {\n if (favorites[x].coffeeID === coffeeID) {\n //Found it, delete it\n favorites.splice(x,1);\n }\n }\n //Push updated favorites to LS\n localStorage.setItem(\"favorites\", JSON.stringify(favorites));\n alert(\"Removed the coffee from your favorites. Please keep me in mind, i am super delicious.\");\n location.reload();\n}", "title": "" }, { "docid": "7a2e645ea59d38ee5289a366e92e6c83", "score": "0.5181881", "text": "function saveMarkInfo(title, notes, id) {\n\n // 1.6\n // Cannot submit an empty title\n if (title === '') {\n return;\n }\n\n // 1.6\n // Note was empty, set accordingly\n if (notes === '') {\n //setNoteHeading(3);\n }\n\n query = 'title=' + unmark.urlEncode(title) + '&notes=' + unmark.urlEncode(notes);\n unmark.ajax('/mark/edit/'+id, 'post', query, function(res) {\n $('#mark-'+id).find('.note-placeholder').text(notes);\n });\n }", "title": "" }, { "docid": "e24f6f965461c62506747afdee5f7b1c", "score": "0.5179942", "text": "function deleteNote(index){\r\n let confirmDelete = confirm(\"You are deleting this note!\")\r\n\r\n if (confirmDelete == true){\r\n let notes = localStorage.getItem(\"notes\");\r\n if (notes == null) {\r\n notesObj = [];\r\n } else {\r\n notesObj = JSON.parse(notes);\r\n }\r\n\r\n notesObj.splice(index, 1);\r\n localStorage.setItem (\"notes\" , JSON.stringify(notesObj));\r\n showNotes();\r\n }\r\n\r\n\r\n}", "title": "" }, { "docid": "4388862a59d2c4a4917db848652e34db", "score": "0.51774645", "text": "function putFavoritesOnPage() {\n console.debug(\"putFavoritesOnPage\");\n //Clear stories list\n $allStoriesList.empty();\n\n if (currentUser.favorites.length < 1) {\n $allStoriesList.text(\"No Favorites yet.\");\n }\n // loop through all of our stories and generate HTML for them\n for (let story of currentUser.favorites) {\n //create markup for each story\n const $story = generateStoryMarkup(story);\n //Append each story to storylist\n $allStoriesList.append($story);\n }\n //Show new list\n $allStoriesList.show();\n}", "title": "" }, { "docid": "a5e166c19153024f02d8f81c0cbda042", "score": "0.51766735", "text": "function updateNote(req, res) {\n Note.findById({_id: req.params.id}, (err, note) => {\n if(err) res.send(err);\n Object.assign(note, req.body).save((err, note) => {\n if(err) res.send(err);\n res.json({ message: 'Note updated!', note });\n }); \n });\n}", "title": "" }, { "docid": "387f81ae721f99239b0a7e92e023f9b3", "score": "0.5175941", "text": "function saveNote(e) {\n // Grab the id associated with the Article;\n const articleId = $(this).parents('.card').attr('data-id');\n // POST request for change the note that is entered\n $.ajax({\n method: \"POST\",\n url: \"/savedNote/\" + articleId,\n data: {\n // Value from title input\n title: $('#titleinput').val(),\n // Value from note textarea\n body: $('#bodyinput').val()\n \n }\n }) \n .then(function() {\n $(\"#notes\").empty();\n });\n \n // Then clear the values entered in the input and textarea after saving \n $('#titleinput').val(\"\");\n $('#bodyinput').val(\"\");\n }", "title": "" }, { "docid": "f3ca1c1df3f53067c0d7071c67923344", "score": "0.51752454", "text": "function editDevelopmentNeedProgressOnDB(userID, devNeedID, devNeedStatus, title, completedText){\n\tvar success = function(response){\n\t\tupdateDevelopmentNeedStatusOnList(devNeedID, devNeedStatus);\n if(devNeedStatus == 2){\n \tvar id = response.autoGeneratedNoteID;\n \tvar text = (completedText === \"\") ? ADfullName+ \" has completed Development Need '\"+ title +\"'.\" : ADfullName+ \" has completed Development Need '\"+ title +\"'. \"+\" A comment was added: '\"+ completedText+\"'\";\n \tvar d = new Date();\n \tvar date = moment(d).format('DD MMM YYYY HH:mm');\n \tvar classDate = moment(d).format('YYYY-MM-DD');\n \taddNoteToList(id, \"Auto Generated\", text, date, classDate, emptyArray, emptyArray);\n $(\"#edit-dev-need-button-\"+devNeedID).remove();\n }\n };\n \n\tvar error = function(error){ }\n\t\n\tupdateDevelopmentNeedProgressAction(userID, devNeedID, devNeedStatus, completedText, success, error);\n}", "title": "" }, { "docid": "9d3d6784324faf8763fa219471af077b", "score": "0.5173972", "text": "function updateById(_ref3) {\n var req = _ref3.req,\n res = _ref3.res,\n session = _ref3.session;\n\n var todos = session.get('todos') || [];\n var todo = todos.find(function (todo) {\n return todo.id === req.params.id;\n });\n if (!todo || !req.body.text) return;\n todo.text = req.body.text;\n todo.editing = false;\n session.set('todos', todos);\n res.redirect('back');\n}", "title": "" }, { "docid": "6b9366e2d39242392b6ba250a0cf7d2f", "score": "0.51700926", "text": "updateUserToDatabase() {\n putUser(this.state.userLocal);\n //Have to manually update the local copy of the userArticleList\n this.state.userArticleList.forEach(articleArray => {\n articleArray.forEach(article => {\n this.state.userLocal.savedArticles.forEach(savedArticle => {\n article.isFavorited = false;\n if (savedArticle._id === article._id){\n article.isFavorited = true;\n }\n })\n })\n })\n }", "title": "" }, { "docid": "8a4c4906a25ecaaa77fc18ecd3d98d01", "score": "0.51692444", "text": "function editNote() {\n $(document).on(\"click\", \".js-edit-note\", function(event){\n event.preventDefault();\n $.get( $(event.target).attr('href'), function( data ) {\n var note = new Note(data);\n var noteRender = note.renderEditNote();\n var id = '#' + data.id;\n $(\"#note-\" + note.id).html(noteRender);\n $(\"#note-\" + note.id + ' #note_title').val(note.title);\n $(\"#note-\" + note.id + ' textarea').val(note.content);\n });\n });\n}", "title": "" }, { "docid": "5ef88a42a8dc3ba00b32bf8176310d4d", "score": "0.5161044", "text": "function updateNote() {\n let noteText = myPresentation.getCurrentSlide().getNote();\n inNote.value = noteText;\n}", "title": "" }, { "docid": "5ef88a42a8dc3ba00b32bf8176310d4d", "score": "0.5161044", "text": "function updateNote() {\n let noteText = myPresentation.getCurrentSlide().getNote();\n inNote.value = noteText;\n}", "title": "" }, { "docid": "561fe8464762e1367a79e3fc27f21708", "score": "0.5158804", "text": "function updateDoc(item){\n\t\ttitle.text(item.title);\n\t\ttext.setContent(item.note);\n\t}", "title": "" }, { "docid": "4bccb26d8ef13e0a2e8af97f8fa34043", "score": "0.51483", "text": "function editNote(index) {\n let notes = localStorage.getItem(\"notes\");\n let addTitle = document.getElementById(\"note-title\");\n let addTxt = document.getElementById(\"note-text\");\n\n if (addTitle.value !== \"\" || addTxt.value !== \"\") {\n return alert(\"Please clear the form before editing a note\")\n } \n\n if (notes == null) {\n notesObj = [];\n } else {\n notesObj = JSON.parse(notes);\n }\n console.log(notesObj);\n\n notesObj.findIndex((element, index) => {\n addTitle.value = element.title;\n addTxt.value = element.text;\n })\n notesObj.splice(index, 1);\n localStorage.setItem(\"notes\", JSON.stringify(notesObj));\n showNotes();\n}", "title": "" }, { "docid": "8a4fdfc05493a931ec0df5e2f812085f", "score": "0.51453614", "text": "update() {\n localStorage.setItem('favorites', JSON.stringify(this.recipes))\n }", "title": "" }, { "docid": "91b9f7e1a1743fb690255c1f7eb5d937", "score": "0.51393366", "text": "function editThisList() {\n getListTemplate();\n addNewItem.addEventListener('click', addListItem);\n listArea.addEventListener('click', editListItem);\n\n const deleteList = document.querySelector(\"#deleteListFromEdit\");\n const toHomePage = document.querySelector('#toHomePageFromEdit');\n const saveEditList = document.querySelector('#saveChangedList');\n\n toHomePage.addEventListener('click', function () {\n ifCancel();\n });\n\n deleteList.addEventListener('click', function () {\n ifDelete()\n });\n\n saveEditList.addEventListener('click', function () {\n saveEditNote();\n });\n\n //save edited list\n async function saveEditNote() {\n let data = buildDataObject();\n let req = await fetch(`https://awesome-cat-notes.herokuapp.com/api/lists/${targetID}`, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(data),\n });\n let answer = await req.json();\n if (answer.edited){\n goToHomePage();\n }\n }\n}", "title": "" }, { "docid": "21ce7ae720c3d43bec5d2fa1cb37c4ec", "score": "0.51380366", "text": "onSaveNote () {\n this.props.setSaveDisabled(true)\n this.props.toggleYesNoModal()\n this.props.saveNote()\n }", "title": "" }, { "docid": "a552f921d89aae86773eaefa6d260801", "score": "0.5134008", "text": "function updateInfo() {\n\tconst email = email_display.value\n\tconst name = name_display.value\n\tconst year = year_display.value\n\tconst rating = rating_display.value\n\tif (name == '' || year == '' || rating == '') {\n\t\twindow.alert('Try again.')\n\t\treturn\n\t}\n\tif (!window.confirm('Do you confirm to update the info?')) {\n\t\treturn\n\t}\n\tfetch('/user/' + email + '/' + name + '/' + year + '/' + rating, {\n\t\t\tmethod: 'PATCH'\n\t\t})\n\t\t.then(res => {\n\t\t\tif (res.status != 200) {\n\t\t\t\twindow.alert('Please try again.')\n\t\t\t}\n\t\t})\n\t\t.catch(err => {})\n\twindow.alert('Info updated.')\n}", "title": "" }, { "docid": "addb8d6762f7d2c5efeba8dafa4d06e5", "score": "0.5126024", "text": "function deleteNotefunction(index) {\n let notes = localStorage.getItem(\"notes\"); // getting notes item stored in local storage\n let title = localStorage.getItem(\"title\"); // getting Title item stored in local storage\n let importantCheckbox = localStorage.getItem(\"important\"); // getting Checkbox item stored in local storage\n notesArray = JSON.parse(notes); // storing that item in variable array by converting it to array\n titleArray = JSON.parse(title);\n checkBoxArray = JSON.parse(importantCheckbox);\n notesArray.splice(index, 1); // deleted item , from the array,, by providing it a starting index, which users click\n titleArray.splice(index, 1);\n checkBoxArray.splice(index, 1);\n localStorage.setItem(\"notes\", JSON.stringify(notesArray)); //Again updating the local storage\n localStorage.setItem(\"title\", JSON.stringify(titleArray));\n localStorage.setItem(\"important\", JSON.stringify(checkBoxArray));\n showNotesfunction(); // again calling the Show notes function to referesh the page markup, and show updated notes\n}", "title": "" }, { "docid": "425c0da8a2928aba943c347bdc684a75", "score": "0.51259476", "text": "function addTracksToFavorites() {\n\n}", "title": "" }, { "docid": "2688bbf0e2883c5521fc02a1199fe78b", "score": "0.51251626", "text": "updateNote(knex, id, updatedNote) {\n return knex(\"notes\").where(\"noteid\", id).update(updatedNote);\n }", "title": "" }, { "docid": "23c464306d60a4fb655be1c7e917ae5f", "score": "0.5122798", "text": "function saveNote(title, contents) {\n // Save shared note to data source\n var notesDataSource = new DataSources.FileDataSource(\"notes.json\");\n notesDataSource.insertAtEnd(null, {\n title: title,\n contents: contents,\n comments: document.querySelector(\".commentbox\").value\n }).done(function () {\n // Let everyone know that the notes have been updated\n Windows.Storage.ApplicationData.current.signalDataChanged();\n\n // All done\n share.reportCompleted();\n });\n }", "title": "" }, { "docid": "a0e674484bd115ac1fa4749e16670b55", "score": "0.51226276", "text": "function editNoteContent(notebook, noteID, content){\r\n let notes = getNotes(notebook);\r\n\r\n notes.forEach(function(note){\r\n if(note.id == noteID){\r\n title = content.ops[0].insert;\r\n note.title = (title.length > 18) ? title.substr(0, 18) + \"...\" : title;\r\n note.content = content;\r\n }\r\n });\r\n\r\n saveFile(getNotebookPath(notebook), JSON.stringify(notes));\r\n}", "title": "" }, { "docid": "83b8e6915074052e1435f6ebaa36696a", "score": "0.51217395", "text": "function updateNote(j) {\n\n var db = LocalStorage.openDatabaseSync(\"DraftmapDB\", \"1.0\", \"Draft map database\", 1000000);\n\n db.transaction(\n function(tx) {\n // Create the table, if not existing\n tx.executeSql('CREATE TABLE IF NOT EXISTS Notes (title TEXT, noteTitle TEXT, note TEXT, latti REAL, longi REAL, stackheight INTEGER, fonnt INTEGER, opacit REAL, UNIQUE(latti,longi,stackheight))');\n tx.executeSql('UPDATE Notes SET latti = ? WHERE latti = ? AND longi = ? AND stackheight = ?', [notesInfo.get(j).latti, notesInfo.get(j).longi, notesInfo.get(j).stackheight])\n }\n )\n}", "title": "" }, { "docid": "667152eb573e977328fa71f58c2c0f11", "score": "0.5120832", "text": "async update(req, res) {\n const preUser = await User.findById(req.params.id)\n User.findByIdAndUpdate(req.params.id,{$push:{Notes: req.body.Notes}},{new: true}).then(data=>{\n \n return res.json(data)\n })\n }", "title": "" }, { "docid": "2b2ccc42212c52b9cc835e4f34579e71", "score": "0.51198745", "text": "function editNote(index){\r\n let notes = localStorage.getItem(\"notes\");\r\n if (notes == null) {\r\n notesObj = [];\r\n }\r\n else {\r\n notesObj = JSON.parse(notes);\r\n }\r\n // console.log(notesObj);\r\n notesObj.findIndex((element,index)=>{\r\n addTitle.value=element.Title;\r\n addTxt.value=element.Text;\r\n })\r\n notesObj.splice(index,1);\r\n localStorage.setItem(\"notes\", JSON.stringify(notesObj));\r\n showNotes();\r\n}", "title": "" }, { "docid": "72e51882dbf9fb050c4dae45b6a09e9a", "score": "0.51173747", "text": "processConfirmDeleteList() {\n // DELETE THE LIST\n window.todo.model.removeList(window.todo.model.listToEdit);\n\n // GO BACK TO THE HOME SCREEN\n window.todo.model.goHome();\n\n // AND HIDE THE DIALOG\n window.todo.view.hideDialog();\n }", "title": "" }, { "docid": "fd368fc14dae80aafdd6df6b342538d3", "score": "0.5114559", "text": "function updateBiography() {\n // get values from inputfields\n let biography = $('#inputBio').val();\n\n // update the biography\n FYSCloud.API.queryDatabase(\n \"UPDATE profile SET biography = ? WHERE user_id = ?\",\n [biography, user[0].user_id]\n ).done(function (data) {\n showAlertForSucces();\n }).fail(function (reason) {\n console.log(reason);\n });\n}", "title": "" }, { "docid": "3a5fbaa02dbb7b96ee8720f0403ec133", "score": "0.5111224", "text": "function editNote(noteKey) {\n\t\t$(\"#noteBlockWrapper table\").fadeOut();\n\t\tif(noteKey !== \"new\") {\n\t\t\tconst noteRow = $(\"[data-index='\"+noteKey+\"'] td\");\n\t\t\t$(\"#name\").val(noteRow[0].innerHTML);\n\t\t\t$(\"#noteContent\").val(noteRow[1].innerHTML);\n\t\t}\n\t\t$(\"#noteBlockWrapper form\").fadeIn();\n\t}", "title": "" }, { "docid": "1b54e72c70012d0a5a8f92686c797188", "score": "0.51090986", "text": "onFaveButtonPress(index) {\n this.updateFlair(index, \"isFavorite\");\n }", "title": "" }, { "docid": "4790f5a50a3ae3ae3dc2cd00f4ab740b", "score": "0.5106185", "text": "function showNotes() {\r\n let notes = localStorage.getItem(\"notes\");\r\n if (notes == null) {\r\n notesObj = [];\r\n }\r\n else {\r\n notesObj = JSON.parse(notes);\r\n }\r\n let titles = localStorage.getItem(\"titles\");\r\n if (titles == null) {\r\n titlesObj = [];\r\n }\r\n else {\r\n titlesObj = JSON.parse(titles);\r\n }\r\n let html = \"\";\r\n \r\n \r\n \r\n \r\n // titleHTML=addTitle.value;\r\n notesObj.forEach(function (element, index) {\r\n // titleHTML = addTitle.value\r\n \r\n \r\n html += ` <div class=\"note-body\">\r\n <div class=\"actual-note\">\r\n <h3 class=\"note-title\">` + titlesObj[index]+`</h3>\r\n <p class=\"note\">\r\n ${element}\r\n </p>\r\n <button id=\"${index}\" onClick=\"editNote(this.id)\" class=\"edit\">Edit</button>\r\n <button id=\"${index}\" onClick=\"deleteNote(this.id)\" class=\"delete\">Delete</button>\r\n </div>\r\n </div>`\r\n\r\n });\r\n let notesElm = document.getElementById('notes');\r\n if (notesObj.length != 0)\r\n notesElm.innerHTML = html;\r\n else\r\n notesElm.innerHTML = `No notes to display!`\r\n}", "title": "" }, { "docid": "57ea2e048033838f6d55a8075fb505ae", "score": "0.51047826", "text": "toggle(req,res){\n db.User.findById(req.user.id)\n .then((user) => {\n //check if places already exist in user's favorites. If it doesn't,add\n //If it does, remove\n const yelpId = req.body.id,\n favoritesId = user.favorites,\n foundId = favoritesId.indexOf(yelpId);\n if(foundId === -1){\n //save yelp businesses to db\n //update our User's favorites\n saveYelp(req,res,req.body)\n .then(()=>{\n user.update({\n favorites: [...favoritesId,yelpId]\n })\n .then(user =>{\n res.json(user.favorites);\n })\n .catch((error) =>{\n res.status(400).send(error);\n });\n });\n }else{\n let fav = user.favorites.slice();\n fav.splice(foundId,1);\n user.update({\n favorites: fav\n })\n .then(user =>{\n res.json(user.favorites);\n })\n .catch((error) =>{\n res.status(400).send(error);\n });\n }\n })\n .catch((error) => {\n res.status(400).send(error);\n });\n }", "title": "" }, { "docid": "ee9a6c0027e4704ce548f7039d82c6a7", "score": "0.507251", "text": "function saveNote() {\r\n const note = {\r\n title: getTitle(),\r\n data: quill.root.innerHTML,\r\n editorData: quill.getContents(),\r\n isFavorite: false,\r\n id: Date.now(),\r\n time: getDate(),\r\n }\r\n notes.unshift(note);\r\n addToLocalStorage(notes);\r\n quill.setContents('');\r\n titleInput.value = '';\r\n}", "title": "" }, { "docid": "0a021cbcfa49879fa488ec744f875b5c", "score": "0.50716716", "text": "updateNote() {\n const values = {\n title: this.state.title,\n text: this.state.text,\n x: this.state.x,\n y: this.state.y,\n zIndex: this.state.zIndex,\n };\n\n this.props.updateNote(this.state.id, values);\n }", "title": "" } ]
4343d7e23304b87420c5e6292cd7d79c
end of shims beginning of real work Constructs a promise for an immediate reference, passes promises through, or coerces promises from different systems.
[ { "docid": "47716d9592f62e2c67fb30134cf68ea0", "score": "0.0", "text": "function Q(value) {\n // If the object is already a Promise, return it directly. This enables\n // the resolve function to both be used to created references from objects,\n // but to tolerably coerce non-promises to promises.\n if (value instanceof Promise) {\n return value;\n }\n\n // assimilate thenables\n if (isPromiseAlike(value)) {\n return coerce(value);\n } else {\n return fulfill(value);\n }\n}", "title": "" } ]
[ { "docid": "ff8abe26fe1742d772d9742e47bfbcd4", "score": "0.7179567", "text": "function r(){var e=this;this.promise=new a.default(function(t,n){e.resolve=t,e.reject=n})}", "title": "" }, { "docid": "aea3f3a2374b6ece4c01ef83688ab166", "score": "0.67852724", "text": "function become(newPromise){resolvedPromise=newPromise;if(Q.longStackSupport&&hasStacks){// Only hold a reference to the new promise if long stacks\n// are enabled to reduce memory usage\npromise.source=newPromise;}array_reduce(messages,function(undefined,message){Q.nextTick(function(){newPromise.promiseDispatch.apply(newPromise,message);});},void 0);messages=void 0;progressListeners=void 0;}", "title": "" }, { "docid": "1e95d6dc61176fd05f743d3b96d97b23", "score": "0.6700177", "text": "function Q(value){// If the object is already a Promise, return it directly. This enables\n// the resolve function to both be used to created references from objects,\n// but to tolerably coerce non-promises to promises.\nif(value instanceof Promise){return value;}// assimilate thenables\nif(isPromiseAlike(value)){return coerce(value);}else{return fulfill(value);}}", "title": "" }, { "docid": "703f7a752572c8214e403a652661f776", "score": "0.6641233", "text": "function tProm() {\n\n\tvar res = null;\n\tvar ref = null;\n\n\treturn new Promise(function(resolve, reject) {\n\t\tconsole.log('created promise');\n\n\t});\n/*\n\treturn {\n\t\tp: prom,\n\t\tres: \n\t\trej\n\t}\n*/\n}", "title": "" }, { "docid": "ed2b5aadb12074026d0519c7cb599f25", "score": "0.6602967", "text": "function Promise() {\n}", "title": "" }, { "docid": "fb6e807a7e927ad6fd27eaec31e99cf3", "score": "0.65804964", "text": "function Def(){this.promise=new Promise((function(a,b){this.resolve=a,this.reject=b}).bind(this))}", "title": "" }, { "docid": "e4fb04b43e622b65c2ab2554dc36b322", "score": "0.646109", "text": "function new_promise() {\n var resolve, promise = new Promise((res, rej)=>{resolve = res;});\n return [promise, resolve];\n }", "title": "" }, { "docid": "b2ab1a22ecb981c6ec85896f7c0f4418", "score": "0.6389396", "text": "function coerce(promise){var deferred=defer();Q.nextTick(function(){try{promise.then(deferred.resolve,deferred.reject,deferred.notify);}catch(exception){deferred.reject(exception);}});return deferred.promise;}", "title": "" }, { "docid": "289a63804f2e125f7077717b4ddf2a91", "score": "0.63516694", "text": "deferred() {\n const struct = {}\n struct.promise = new MyPromise((resolve, reject) => {\n struct.resolve = resolve\n struct.reject = reject\n })\n return struct\n }", "title": "" }, { "docid": "a56a228145ae981c7fbc2754d754e2b2", "score": "0.63481975", "text": "function g(t,e,o,r){return new(o||(o=Promise))((function(n,a){function i(t){try{s(r.next(t))}catch(t){a(t)}}function l(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?n(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(i,l)}s((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "508de70e046937f40a88a068a9ac131f", "score": "0.6338368", "text": "function _wrapPromise(val) {\n if (val && angular.isFunction(val.then)) {\n return val;\n }\n return $q.resolve(val);\n }", "title": "" }, { "docid": "fb2131f0e89b047a4e50a3f622b46fcc", "score": "0.6317817", "text": "function defer() {\n\t let resolve = null;\n\t let reject = null;\n\t const p = new Promise((res, rej) => [resolve, reject] = [res, rej]);\n\t return Object.assign(p, { resolve, reject });\n\t}", "title": "" }, { "docid": "fb2131f0e89b047a4e50a3f622b46fcc", "score": "0.6317817", "text": "function defer() {\n\t let resolve = null;\n\t let reject = null;\n\t const p = new Promise((res, rej) => [resolve, reject] = [res, rej]);\n\t return Object.assign(p, { resolve, reject });\n\t}", "title": "" }, { "docid": "c033c0577913b9420af8a7b652fc1d2e", "score": "0.62895817", "text": "function r(e,t,a,i){return new(a||(a=Promise))(function(n,r){function s(e){try{l(i.next(e))}catch(t){r(t)}}function o(e){try{l(i[\"throw\"](e))}catch(t){r(t)}}function l(e){e.done?n(e.value):new a(function(t){t(e.value)}).then(s,o)}l((i=i.apply(e,t||[])).next())})}", "title": "" }, { "docid": "a8d851a8552efc6d8b8ad96ecffbc328", "score": "0.6281502", "text": "function make_promise(guarantee) {\n var status = UNRESOLVED,\n outcome,\n waiting = [],\n dreading = [],\n passable,\n result;\n\n function vouch(deed, func) {\n switch (status) {\n case UNRESOLVED:\n (deed === FULFILLED ? waiting : dreading).push(func);\n break;\n case deed:\n func(outcome);\n break;\n }\n };\n\n function resolve(deed, value) {\n status = deed;\n outcome = value;\n (deed == FULFILLED ? waiting : dreading).forEach(function (func) {\n func.apply(func, outcome);\n });\n waiting = null;\n dreading = null;\n };\n\n passable = {\n when: function (f) {\n result.when(f);\n return this;\n },\n fail: function (f) {\n result.fail(f);\n return this;\n }\n };\n\n result = {\n when: function (func) {\n vouch(FULFILLED, func);\n return this;\n },\n fail: function (func) {\n vouch(SMASHED, func);\n return this;\n },\n fulfill: function () {\n var args = Array.prototype.slice.call(arguments);\n resolve(FULFILLED, args);\n return passable;\n },\n smash: function () {\n var args = Array.prototype.slice.call(arguments);\n resolve(SMASHED, args);\n return passable;\n },\n status: function () {\n return status;\n },\n passable: function () {\n return passable;\n }\n };\n\n if (undefined !== guarantee) {\n return result.fulfill(guarantee);\n }\n return result;\n}", "title": "" }, { "docid": "ca68fe72bb1a5a95b9b22c3c9db49ab6", "score": "0.62504566", "text": "static defer() {\n\t\tlet resolve = null;\n\t\tlet reject = null;\n\n\t\tconst promise = new P((res, rej) => {\n\t\t\tresolve = res;\n\t\t\treject = rej;\n\t\t});\n\n\t\treturn { resolve, reject, promise };\n\t}", "title": "" }, { "docid": "0e4c78aa02719fc772880691d4d5daf7", "score": "0.6244555", "text": "function c(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(e){i(e)}}function s(t){try{u(r[\"throw\"](t))}catch(e){i(e)}}function u(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(a,s)}u((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "2227c05d1f4b48709555565e3dd66a83", "score": "0.61854714", "text": "function Promise() {\n var resolve = function (result) {\n complete(\"resolve\", result);\n promise.state = \"fulfilled\";\n };\n\n var reject = function (err) {\n complete(\"reject\", err);\n promise.state = \"rejected\";\n };\n\n var then = function (resolve, reject) {\n if (callbacks) {\n callbacks.push({\n resolve: resolve,\n reject: reject\n });\n } else {\n var fn = promise.state === \"fulfilled\" ? resolve : reject;\n fn(promise.value);\n }\n\n return this;\n };\n\n var callbacks = [],\n promise = {\n state: \"pending\",\n value: undefined,\n resolve: resolve,\n reject: reject,\n then: then,\n safe: {\n then: function safeThen(resolve, reject) {\n promise.then(resolve, reject);\n return this;\n }\n }\n };\n\n\n function complete(type, result) {\n var rejector = function (resolve, reject) {\n reject(result);\n return this;\n };\n\n var resolver = function (resolve) {\n resolve(result);\n return this;\n };\n\n promise.value = result;\n promise.then = type === \"reject\" ? rejector : resolver;\n promise.resolve = promise.reject = function () {\n throw new Error(\"Promise already completed\");\n };\n\n invokeCallbacks(type, result);\n }\n\n function invokeCallbacks (type, result) {\n var i,\n cb;\n\n for (i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n\n if (cb[type]) {\n cb[type](result);\n }\n }\n\n callbacks = null;\n }\n\n return promise;\n }", "title": "" }, { "docid": "e5d5e938a0f21d892acd472d8bf5c2f0", "score": "0.61774504", "text": "function wrap(fn){\n\treturn Q().then(fn);\n}", "title": "" }, { "docid": "b981a1a8c2d4053d3513ff3ac71d66cd", "score": "0.61772645", "text": "function c(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function l(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(s,l)}a((r=r.apply(e,t||[])).next())})}", "title": "" }, { "docid": "35f37be91fc3d97d53f444d7d2b0a9d6", "score": "0.61771536", "text": "function makePromise(tgt) {\n return new Ember.RSVP.Promise(function (resolve) {\n resolve(tgt);\n });\n }", "title": "" }, { "docid": "a8e808f886ea5a88d1714e8460e0511a", "score": "0.61615103", "text": "_asyncWrapper(result) {\r\n if (typeof result === 'object' && 'then' in result) {\r\n return result;\r\n } else {\r\n return new Promise(function(resolve) {\r\n resolve(result);\r\n });\r\n }\r\n }", "title": "" }, { "docid": "4f078254ff9e2d21a8a5a3f5efa97cc5", "score": "0.6157639", "text": "function r(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function p(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,p)}a((o=o.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "9af840b576d4e851f17de2658ede0c26", "score": "0.61521167", "text": "function defer() {\n var resolve, reject, notify, promise;\n promise = new ExtendedPromise(executor);\n return {\n promise: promise,\n resolve: resolve,\n reject: reject,\n notify: notify\n };\n\n /**\n * The promise executor.\n * @param {function} res The function to call to resolve the promise.\n * @param {function} rej The function to call to reject the promise.\n * @param {function} noti The function to call to perform a notification.\n */\n function executor(res, rej, noti) {\n resolve = res;\n reject = rej;\n notify = noti;\n }\n }", "title": "" }, { "docid": "637db564ea6ec4c5adc91130c559076e", "score": "0.6152014", "text": "function deferredPromise() {\n let resolve;\n let reject;\n const promise = new Promise(function () {\n resolve = arguments[0];\n reject = arguments[1];\n });\n return {\n resolve,\n reject,\n promise\n };\n}", "title": "" }, { "docid": "ca3e530e6b3ec75ad48e75034e2991fa", "score": "0.61386645", "text": "function $Promise(executor) {\n if (typeof executor !== 'function') throw TypeError ('executor is not a function.')\n this._state = 'pending';\n this._value;\n\n executor(this._internalResolve.bind(this), this._internalReject.bind(this));\n// return this;\n}", "title": "" }, { "docid": "96b8da6808bbb5240bb7bd13bd4a36eb", "score": "0.6136716", "text": "function o(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r[\"throw\"](e))}catch(t){o(t)}}function l(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,s)}l((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "96cff48fb23dc289d239211db122877c", "score": "0.6133746", "text": "function a(t,e,i,n){return new(i||(i=Promise))((function(r,a){function s(t){try{l(n.next(t))}catch(e){a(e)}}function o(t){try{l(n[\"throw\"](t))}catch(e){a(e)}}function l(t){t.done?r(t.value):new i((function(e){e(t.value)})).then(s,o)}l((n=n.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "10b441d221d93b1049f6a37e7611e7ef", "score": "0.61276025", "text": "function r(e,t,n,o){return new(n||(n=Promise))((function(r,i){function c(e){try{l(o.next(e))}catch(e){i(e)}}function u(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,u)}l((o=o.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "d09515240677fb7b0664d81a762d01d8", "score": "0.6119259", "text": "thenWithState(onResolve = function(r) { return r }, onReject = function(e) { throw e }) { return new StatefulPromise(this.then(onResolve, onReject)); }", "title": "" }, { "docid": "093678df7d53c0ead990bae9b9db7c28", "score": "0.6117381", "text": "function a(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{u(r.next(e))}catch(t){a(t)}}function s(e){try{u(r[\"throw\"](e))}catch(t){a(t)}}function u(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(o,s)}u((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "e1bfab98f8a442ad1dd1d64a8c0cd445", "score": "0.61143047", "text": "function Fay$$then(a){\n return function(b){\n return Fay$$bind(a)(function(_){\n return b;\n });\n };\n}", "title": "" }, { "docid": "6c34a40f1ec6fc813a66867eeb66192d", "score": "0.6108601", "text": "function $Promise(executor){\n if (typeof executor !== 'function') throw Error('no argument');\n this._state = 'pending';\n this._value = undefined;\n executor(this._internalResolve.bind(this), this._internalReject.bind(this));\n\n}", "title": "" }, { "docid": "e665076784dd5f2c0a71ce8207910bf2", "score": "0.61061656", "text": "function o(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(s,a)}c((n=n.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "255df4dcbe9c9b840f48748bd0cfd98e", "score": "0.6101282", "text": "function getPromise (queue) {\n\t\tvar promise;\n\t\treturn function (Deferred) {\n\t\t\tif (!promise) {\n\t\t\t\tvar P = Deferred && Deferred.Wrapper || Promise;\n\t\t\t\tpromise = new P(function (resolve) {\n\t\t\t\t\tdefer[queue](function () {\n\t\t\t\t\t\tpromise = null;\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn promise;\n//\t\t\tvar P = Deferred && Deferred.Wrapper || Promise;\n//\t\t\treturn new P(function (resolve) {\n//\t\t\t\tdefer[queue](resolve);\n//\t\t\t});\n\t\t};\n\t}", "title": "" }, { "docid": "3427cf7490bd703d5b1825604288f237", "score": "0.6095815", "text": "function sc_makePromise(proc) {\n var isResultReady = false;\n var result = undefined;\n return function() {\n\tif (!isResultReady) {\n\t var tmp = proc();\n\t if (!isResultReady) {\n\t\tisResultReady = true;\n\t\tresult = tmp;\n\t }\n\t}\n\treturn result;\n };\n}", "title": "" }, { "docid": "aebf185fc59a5e5b07c6d86b55af8338", "score": "0.60941917", "text": "function r(e,t,n,i){function a(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function o(e){try{s(i.next(e))}catch(t){r(t)}}function c(e){try{s(i[\"throw\"](e))}catch(t){r(t)}}function s(e){e.done?n(e.value):a(e.value).then(o,c)}s((i=i.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "4981ccd3d9226789628f64a0fc08a517", "score": "0.60926086", "text": "function promiseMaker() {\n //promise is a object which takes 2 callbacks, resolve and reject\n return new Promise(function(resolve, reject) {\n setTimeout(() => {\n var error = true;\n if (!error) {\n console.log('Promise has been resolved');\n //if the promise is kept then resolve will be called\n resolve();\n } else {\n console.log('Sorry i could not fulfill the promise');\n //if promise not kept then reject will be called;\n reject('Sorry not fulfilled');\n }\n }, 2000);\n });\n}", "title": "" }, { "docid": "1546c7891f6d8544d24b41ca09e94d6c", "score": "0.6089961", "text": "function $X(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "a892c97c30293d4c87dec5a4a2671203", "score": "0.6080163", "text": "function nativePromiseVersion() {\n // we use two functions which return promises: returnsFirstPromise() and returnsSecondPromise().\n returnsFirstPromise() // returnsFirstPromise() and ensure that the first promise resolved by using .then().\n .then((firstValue) => {\n // we log the resolved value of the first promise, firstValue, and then return returnsSecondPromise(firstValue).\n console.log(firstValue);\n return returnsSecondPromise(firstValue);\n })\n // We use another .then() to print the second promise’s resolved value to the console.\n .then((secondValue) => {\n console.log(secondValue);\n });\n }", "title": "" }, { "docid": "368b0e1e9d150522172cd38cbe09ec2b", "score": "0.6074555", "text": "function primjer4() {\n var p2 = new Promise(function (resolve, reject) {\n resolve(1);\n });\n\n p2.then(function (value) {\n console.log(value); // 1\n return value + 1;\n }).then(function (value) {\n console.log(value + '- This synchronous usage is virtually pointless'); // 2- This synchronous usage is virtually pointless\n });\n\n p2.then(function (value) {\n console.log(value); // 1\n });\n}", "title": "" }, { "docid": "2d33c495047f2270a59b97614893a298", "score": "0.606627", "text": "constructor (promise /* : Promise */) {\n this.then = function (onFulfilled/* : Function */, onRejected /* : Function */) /* : Thenable */ {\n const Promise = require('./promise')\n const next = new Promise()\n\n promise.chain.push({\n onFulfilled,\n onRejected,\n promise: next\n })\n\n return next.thenable\n }\n }", "title": "" }, { "docid": "f3284f6811f978528cda48d56b84dceb", "score": "0.6060979", "text": "function Q(value) {\n\t\t // If the object is already a Promise, return it directly. This enables\n\t\t // the resolve function to both be used to created references from objects,\n\t\t // but to tolerably coerce non-promises to promises.\n\t\t if (isPromise(value)) {\n\t\t return value;\n\t\t }\n\t\t\n\t\t // assimilate thenables\n\t\t if (isPromiseAlike(value)) {\n\t\t return coerce(value);\n\t\t } else {\n\t\t return fulfill(value);\n\t\t }\n\t\t}", "title": "" }, { "docid": "0d07a19b07268e49458b06f078ba5618", "score": "0.60550886", "text": "function o(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function a(e){try{c(r.next(e))}catch(t){o(t)}}function s(e){try{c(r[\"throw\"](e))}catch(t){o(t)}}function c(e){e.done?n(e.value):i(e.value).then(a,s)}c((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "9d5f7f4fad5444eb20b15568d5147979", "score": "0.60543996", "text": "function a(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function s(e){try{l(r.next(e))}catch(t){a(t)}}function o(e){try{l(r[\"throw\"](e))}catch(t){a(t)}}function l(e){e.done?n(e.value):i(e.value).then(s,o)}l((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "766e2bd8b6ccaa9b0a8c13916e5d6477", "score": "0.60516155", "text": "function defer() {\n var resolve, reject;\n var promise = new Promise(function() {\n resolve = arguments[0];\n reject = arguments[1];\n });\n return {\n resolve: resolve,\n reject: reject,\n promise: promise\n };\n }", "title": "" }, { "docid": "177b7945c17e3df809dc940f6037ba75", "score": "0.6045798", "text": "function $Promise(arg) {\n\n if (typeof arg !== 'function') {\n throw new Error('argument not a function.');\n }\n\n this._handlerGroups = [];\n this._state = 'pending';\n this._internalResolve = function (passedValue) {\n\n if (this._state === 'pending') {\n this._value = passedValue;\n this._state = 'fulfilled';\n }\n\n\n while (this._handlerGroups.length > 0) {\n this._callHandlers(this._value);\n }\n\n\n };\n this._internalReject = function (reason) {\n if (this._state === 'pending') {\n this._value = reason;\n this._state = 'rejected';\n }\n while (this._handlerGroups.length > 0) {\n\n this._callHandlers(this._value);\n\n }\n };\n\n let context = this;\n this.then = function (successHandler, errHandler) {\n //console.log(typeof successHandler, successHandler);\n if (typeof successHandler !== 'function') {\n successHandler = false;\n }\n if (typeof errHandler !== 'function') {\n errHandler = false;\n }\n let thenPromise = new $Promise(function () { });\n console.log(context._value);\n // if (typeof context._handlerGroups[0].successCb !== 'function') {\n // thenPromise._value = context._value;\n // }\n this._handlerGroups.push({\n successCb: successHandler,\n errorCb: errHandler,\n downstream: thenPromise\n });\n //console.log(this._handlerGroups);\n if (this._state !== 'pending') {\n while (this._handlerGroups.length > 0) {\n\n this._callHandlers(this._value);\n\n }\n }\n\n return thenPromise;\n };\n //console.log(this);\n\n this.catch = function (func) {\n return this.then(null, func);\n };\n\n\n let resolve = (value) => {\n this._internalResolve(value);\n //console.log(this._handlerGroups);\n // console.log(this);\n\n };\n let reject = (reason) => {\n this._internalReject(reason);\n };\n arg(resolve, reject);\n\n}", "title": "" }, { "docid": "89bf2bbaf0c07a8c3b1f77e4891482cd", "score": "0.60446364", "text": "function e(e,t,a,r){return new(a||(a=Promise))((function(n,s){function i(e){try{d(r.next(e))}catch(e){s(e)}}function o(e){try{d(r.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(i,o)}d((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "5a62a3b00de3221e75397c4081e6c210", "score": "0.6044433", "text": "function e(t,e,i,n){return new(i||(i=Promise))((function(o,a){function l(t){try{r(n.next(t))}catch(t){a(t)}}function s(t){try{r(n.throw(t))}catch(t){a(t)}}function r(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(l,s)}r((n=n.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "2e00dce73f1596f8ce18dec6610649b2", "score": "0.60370594", "text": "function o(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function c(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "041a281bafe911ef1d17b0c47a750fd2", "score": "0.60340923", "text": "function Q(value) {\n\t // If the object is already a Promise, return it directly. This enables\n\t // the resolve function to both be used to created references from objects,\n\t // but to tolerably coerce non-promises to promises.\n\t if (value instanceof Promise) {\n\t return value;\n\t }\n\t\n\t // assimilate thenables\n\t if (isPromiseAlike(value)) {\n\t return coerce(value);\n\t } else {\n\t return fulfill(value);\n\t }\n\t }", "title": "" }, { "docid": "17a425754e88cd9fa44978b652dd1c69", "score": "0.603401", "text": "static resolve(p) {\n return (p instanceof promise) ? p : new promise((r,j)=>{\n r(p)\n })\n }", "title": "" }, { "docid": "d016d598ff019ee093f0cfe8a3590bc9", "score": "0.60325396", "text": "function deferred() {\n var def = {};\n def.promise = new Promise(function (resolve, reject) {\n def.resolve = resolve;\n def.reject = reject;\n });\n return def;\n}", "title": "" }, { "docid": "418696daed1a825a14719ebc4ea20b0b", "score": "0.60313934", "text": "function r(e,t,o,n){return new(o||(o=Promise))((function(i,r){function a(e){try{c(n.next(e))}catch(e){r(e)}}function s(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "68f17bbb8c8e1d2f055e8506ab44e781", "score": "0.60285515", "text": "function Promise(resolver) {\n if (!(this instanceof Promise)) {\n return new Promise(resolver);\n }\n var queue = [];\n var resolved = false;\n // The `handler` variable points to the function that will\n // 1) handle a .then(onFulfilled, onRejected) call\n // 2) handle a .resolve or .reject call (if not fulfilled)\n // Before 2), `handler` holds a queue of callbacks.\n // After 2), `handler` is a simple .then handler.\n // We use only one function to save memory and complexity.\n // Case 1) handle a .then(onFulfilled, onRejected) call\n function pending(onFulfilled, onRejected){\n return Promise(function(resolver,rejecter){\n queue.push({\n resolve: onFulfilled,\n reject: onRejected,\n resolver:resolver,\n rejecter:rejecter\n });\n });\n }\n function then(onFulfilled, onRejected) {\n return resolved?resolved(onFulfilled, onRejected):pending(onFulfilled, onRejected);\n }\n // Case 2) handle a .resolve or .reject call\n // (`onFulfilled` acts as a sentinel)\n // The actual function signature is\n // .re[ject|solve](sentinel, success, value)\n function resolve(success, value){\n var action = success ? 'resolve' : 'reject';\n var queued;\n var callback;\n for (var i = 0, l = queue.length; i < l; i++) {\n queued = queue[i];\n callback = queued[action];\n if (typeof callback === 'function') {\n immediate(execute,callback, value, queued.resolver, queued.rejecter);\n }else if(success){\n queued.resolver(value);\n }else{\n queued.rejecter(value);\n }\n }\n // Replace this handler with a simple resolved or rejected handler\n resolved = createHandler(then, value, success);\n }\n this.then = then;\n function yes(value) {\n if (!resolved) {\n resolve(true, value);\n }\n }\n function no (reason) {\n if (!resolved) {\n resolve(false, reason);\n }\n }\n try{\n resolver(function(a){\n if(a && typeof a.then==='function'){\n a.then(yes,no);\n }else{\n yes(a);\n }\n },no);\n }catch(e){\n no(e);\n }\n}", "title": "" }, { "docid": "037bc94ec7c64f47317d327b39cb8fb4", "score": "0.6018892", "text": "function o(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{u(r.next(t))}catch(e){o(e)}}function s(t){try{u(r[\"throw\"](t))}catch(e){o(e)}}function u(t){t.done?n(t.value):i(t.value).then(a,s)}u((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "edab64a4d2b3672ff0b23338875bf64c", "score": "0.60156053", "text": "function A(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function s(t){try{l(r.next(t))}catch(e){o(e)}}function a(t){try{l(r[\"throw\"](t))}catch(e){o(e)}}function l(t){t.done?n(t.value):i(t.value).then(s,a)}l((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "4d3a0c6d6371745c32107e7bfd1e3e9e", "score": "0.60130084", "text": "function fullPromise(param) {\n\t//PLACE YOUR CODE HERE:\n}", "title": "" }, { "docid": "d4f60390da4a313e2765675b829a8d8e", "score": "0.6006977", "text": "function e(e,t,s,n){return new(s||(s=Promise))((function(i,r){function a(e){try{h(n.next(e))}catch(e){r(e)}}function o(e){try{h(n.throw(e))}catch(e){r(e)}}function h(e){e.done?i(e.value):new s((function(t){t(e.value)})).then(a,o)}h((n=n.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "21781f87c858d8b88bf98ae9f97320b7", "score": "0.60067195", "text": "function Q(value) {\n\t // If the object is already a Promise, return it directly. This enables\n\t // the resolve function to both be used to created references from objects,\n\t // but to tolerably coerce non-promises to promises.\n\t if (isPromise(value)) {\n\t return value;\n\t }\n\t\n\t // assimilate thenables\n\t if (isPromiseAlike(value)) {\n\t return coerce(value);\n\t } else {\n\t return fulfill(value);\n\t }\n\t}", "title": "" }, { "docid": "f0e5b898377ceea24badfa76ce6ad389", "score": "0.6006499", "text": "function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "361ef027576224b854e8dab599911442", "score": "0.60062045", "text": "function A(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,a){function o(t){try{B(i.next(t))}catch(e){a(e)}}function A(t){try{B(i[\"throw\"](t))}catch(e){a(e)}}function B(t){t.done?n(t.value):r(t.value).then(o,A)}B((i=i.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "a9162ad35ab6db3c7095eface79882dc", "score": "0.6005947", "text": "function coerce(promise) {\n\t var deferred = defer();\n\t Q.nextTick(function () {\n\t try {\n\t promise.then(deferred.resolve, deferred.reject, deferred.notify);\n\t } catch (exception) {\n\t deferred.reject(exception);\n\t }\n\t });\n\t return deferred.promise;\n\t}", "title": "" }, { "docid": "854f9a430aa58029c2b0e9fa690ae5f8", "score": "0.60059327", "text": "function coerce(promise) {\n\t var deferred = defer();\n\t Q.nextTick(function () {\n\t try {\n\t promise.then(deferred.resolve, deferred.reject, deferred.notify);\n\t } catch (exception) {\n\t deferred.reject(exception);\n\t }\n\t });\n\t return deferred.promise;\n\t }", "title": "" }, { "docid": "2f41e70d88d89da444eb0805ea29074c", "score": "0.60057974", "text": "function bn(e,t,i,r){return new(i||(i=Promise))((function(n,a){function o(e){try{s(r.next(e))}catch(zs){a(zs)}}function c(e){try{s(r[\"throw\"](e))}catch(zs){a(zs)}}function s(e){e.done?n(e.value):new i((function(t){t(e.value)})).then(o,c)}s((r=r.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "882fd84d8315a258f97de2c29242aa1b", "score": "0.6003495", "text": "function a(e,t,r,n){return new(r||(r=Promise))((function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((n=n.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "3b7908a90402579c612beb71eb11b037", "score": "0.60021454", "text": "function o(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}u((r=r.apply(e,t||[])).next())})}", "title": "" }, { "docid": "47911d2c394beb022861afa5083a949e", "score": "0.5997224", "text": "function jg(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(t){i(t)}}function l(e){try{s(o.throw(e))}catch(t){i(t)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}s((o=o.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "b477b59be4585577d4b3285fbcd588bd", "score": "0.59931517", "text": "function o(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{c(r.next(t))}catch(e){o(e)}}function s(t){try{c(r[\"throw\"](t))}catch(e){o(e)}}function c(t){t.done?n(t.value):i(t.value).then(a,s)}c((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "e3a06a3b6074682d39296616099c974d", "score": "0.599241", "text": "function promiseOf(type) {\n var self = getInstance(this, promiseOf);\n self.type = type;\n return self;\n}", "title": "" }, { "docid": "2d7ed2d6530ec32fe6346574f6d9b156", "score": "0.59876984", "text": "function r(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function c(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "f7fdc59b99880c566b97acd559e8fe79", "score": "0.5986103", "text": "function become(newPromise) {\n\t resolvedPromise = newPromise;\n\t\n\t if (Q.longStackSupport && hasStacks) {\n\t // Only hold a reference to the new promise if long stacks\n\t // are enabled to reduce memory usage\n\t promise.source = newPromise;\n\t }\n\t\n\t array_reduce(messages, function (undefined, message) {\n\t Q.nextTick(function () {\n\t newPromise.promiseDispatch.apply(newPromise, message);\n\t });\n\t }, void 0);\n\t\n\t messages = void 0;\n\t progressListeners = void 0;\n\t }", "title": "" }, { "docid": "a71359a4adebf28eddabe3f4ca868199", "score": "0.59810686", "text": "function u(e,t,n,o){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function l(e){try{s(o.next(e))}catch(t){a(t)}}function i(e){try{s(o[\"throw\"](e))}catch(t){a(t)}}function s(e){e.done?n(e.value):r(e.value).then(l,i)}s((o=o.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "00a1318406d6511edc4b44fb3b4dcf70", "score": "0.59795135", "text": "function r(t,e,n,r){return new(n||(n=Promise))((function(i,o){function c(t){try{a(r.next(t))}catch(e){o(e)}}function s(t){try{a(r[\"throw\"](t))}catch(e){o(e)}}function a(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(c,s)}a((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "0191d87bf0a61504ee4d706c6a6b5e9e", "score": "0.5978965", "text": "function makeResolver() {\n let result = {};\n result.promise = new Promise(function(fulfill,reject){\n result.fulfill = fulfill;\n result.reject = reject;\n });\n result.id = rcount;\n result.promise.id = rcount;\n rcount++;\n return result;\n}", "title": "" }, { "docid": "29f01e78ab26b9d48240c07272b91f15", "score": "0.59764206", "text": "function u(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{c(r.next(t))}catch(e){o(e)}}function s(t){try{c(r[\"throw\"](t))}catch(e){o(e)}}function c(t){t.done?n(t.value):i(t.value).then(a,s)}c((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "8ad32d2cee9bbdbd69211e33b259bf7a", "score": "0.59762526", "text": "function become(newPromise) {\n resolvedPromise = newPromise;\n \n if (Q.longStackSupport && hasStacks) {\n // Only hold a reference to the new promise if long stacks\n // are enabled to reduce memory usage\n promise.source = newPromise;\n }\n \n array_reduce(messages, function (undefined, message) {\n Q.nextTick(function () {\n newPromise.promiseDispatch.apply(newPromise, message);\n });\n }, void 0);\n \n messages = void 0;\n progressListeners = void 0;\n }", "title": "" }, { "docid": "1d3024d950abddea46153a21b75e1f23", "score": "0.59750044", "text": "function a(e,t,n,i){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function s(e){try{l(i.next(e))}catch(t){a(t)}}function o(e){try{l(i[\"throw\"](e))}catch(t){a(t)}}function l(e){e.done?n(e.value):r(e.value).then(s,o)}l((i=i.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "24e67187038a2b9a09b86e5cee8c272a", "score": "0.5973812", "text": "function CreatePromise()\n\t\t{\n\t\t\tlet Callbacks = {};\n\t\t\tlet PromiseHandler = function (Resolve,Reject)\n\t\t\t{\n\t\t\t\tCallbacks.Resolve = Resolve;\n\t\t\t\tCallbacks.Reject = Reject;\n\t\t\t}\n\t\t\tlet Prom = new Promise(PromiseHandler);\n\t\t\tProm.Resolve = Callbacks.Resolve;\n\t\t\tProm.Reject = Callbacks.Reject;\n\t\t\treturn Prom;\n\t\t}", "title": "" }, { "docid": "fa86792a9f33ab60571e239b6cc86c05", "score": "0.596979", "text": "function Q(value) {\n\t // If the object is already a Promise, return it directly. This enables\n\t // the resolve function to both be used to created references from objects,\n\t // but to tolerably coerce non-promises to promises.\n\t if (value instanceof Promise) {\n\t return value;\n\t }\n\t\n\t // assimilate thenables\n\t if (isPromiseAlike(value)) {\n\t return coerce(value);\n\t } else {\n\t return fulfill(value);\n\t }\n\t}", "title": "" }, { "docid": "93842043416ac98d8c2fcc8178717265", "score": "0.5969635", "text": "returnPromise(value) {\n if (this._isPromise(value)) {\n return value;\n }\n else {\n var deferred = Q.defer();\n deferred.resolve(value);\n return deferred.promise;\n }\n }", "title": "" }, { "docid": "641c556cffaad491c3d0f9792c6d9659", "score": "0.59695506", "text": "function u(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "9c85ae86e6770b9587cbdcb783e020a2", "score": "0.5968034", "text": "function Q(value) {\n\t // If the object is already a Promise, return it directly. This enables\n\t // the resolve function to both be used to created references from objects,\n\t // but to tolerably coerce non-promises to promises.\n\t if (isPromise(value)) {\n\t return value;\n\t }\n\n\t // assimilate thenables\n\t if (isPromiseAlike(value)) {\n\t return coerce(value);\n\t } else {\n\t return fulfill(value);\n\t }\n\t}", "title": "" }, { "docid": "be8a9e61bd8ed993dbd38d0339b56ae7", "score": "0.5963847", "text": "function coerce(promise) {\n\t\t var deferred = defer();\n\t\t nextTick(function () {\n\t\t try {\n\t\t promise.then(deferred.resolve, deferred.reject, deferred.notify);\n\t\t } catch (exception) {\n\t\t deferred.reject(exception);\n\t\t }\n\t\t });\n\t\t return deferred.promise;\n\t\t}", "title": "" }, { "docid": "331d8580d26ca0831826cdc9037a817c", "score": "0.59597695", "text": "function o(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{l(r.next(t))}catch(e){o(e)}}function s(t){try{l(r[\"throw\"](t))}catch(e){o(e)}}function l(t){t.done?n(t.value):i(t.value).then(a,s)}l((r=r.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "ba67e4ca295d0d827967412480186445", "score": "0.59535486", "text": "function e(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(s,a)}c((n=n.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "9532fa3e8bd50c3208425cc0105702c5", "score": "0.5952521", "text": "function o(e,t,n,i){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function a(e){try{l(i.next(e))}catch(t){o(t)}}function s(e){try{l(i[\"throw\"](e))}catch(t){o(t)}}function l(e){e.done?n(e.value):r(e.value).then(a,s)}l((i=i.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "3211f50de29978457079c7fdb427c45c", "score": "0.5952258", "text": "function Promise() {\n this._thens = [];\n }", "title": "" }, { "docid": "bc7ec3e03263e76aee2a9b498a918c70", "score": "0.5951912", "text": "function o(e,t,n,i){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function s(e){try{l(i.next(e))}catch(t){a(t)}}function o(e){try{l(i[\"throw\"](e))}catch(t){a(t)}}function l(e){e.done?n(e.value):r(e.value).then(s,o)}l((i=i.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "10a7b98c4cbded9a0841529c9c42a0a7", "score": "0.59493476", "text": "function u(t,e,n,o){return new(n||(n=Promise))((function(r,i){function u(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}c((o=o.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "15218bcaffd5dde84853924a3f951ef8", "score": "0.59479344", "text": "function v(e,t,n,o){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function l(e){try{s(o.next(e))}catch(t){a(t)}}function i(e){try{s(o[\"throw\"](e))}catch(t){a(t)}}function s(e){e.done?n(e.value):r(e.value).then(l,i)}s((o=o.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "86ba973db3d68f30886207be2a2f7e63", "score": "0.5946815", "text": "function d(e,t,n,o){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function l(e){try{s(o.next(e))}catch(t){a(t)}}function i(e){try{s(o[\"throw\"](e))}catch(t){a(t)}}function s(e){e.done?n(e.value):r(e.value).then(l,i)}s((o=o.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "24a966c71d0d616287c485aecbda069a", "score": "0.5944061", "text": "static promiseURI(theURI, form) {\nreturn new Promise((resolve, reject) => {\nvar theCB;\ntheCB = (val, errC, errT, part) => {\nif (errC > 0) {\nif (typeof lggr.trace === \"function\") {\nlggr.trace(`promiseURI ${theURI} rejecting ${errT}`);\n}\nreturn reject(new Error(JSON.stringify([errC, errT, part])));\n} else {\nif (typeof lggr.trace === \"function\") {\nlggr.trace(`promiseURI ${theURI} resolving`);\n}\nreturn resolve(val);\n}\n};\nreturn Data.fetchURI(theURI, theCB, form);\n});\n}", "title": "" }, { "docid": "abd0add84460310c1b8becf282179a1c", "score": "0.59423983", "text": "function $Promise(executor){\n if (typeof executor !== 'function'){\n throw new TypeError ('executor is not a function')\n };\n this._handlerGroups= [];\n this._state = 'pending';\n\n\n executor(this._internalResolve.bind(this), this._internalReject.bind(this))\n\n}", "title": "" }, { "docid": "d8eb8fdf4b6de19e19ca05ba6e886acb", "score": "0.5937916", "text": "function o(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{c(i.next(t))}catch(e){o(e)}}function s(t){try{c(i[\"throw\"](t))}catch(e){o(e)}}function c(t){t.done?n(t.value):r(t.value).then(a,s)}c((i=i.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "d8eb8fdf4b6de19e19ca05ba6e886acb", "score": "0.5937916", "text": "function o(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{c(i.next(t))}catch(e){o(e)}}function s(t){try{c(i[\"throw\"](t))}catch(e){o(e)}}function c(t){t.done?n(t.value):r(t.value).then(a,s)}c((i=i.apply(t,e||[])).next())}))}", "title": "" }, { "docid": "7edb6680566909d0fa31db4413b8cec9", "score": "0.59369713", "text": "function SPromise(func){\n\t\t// simple/super/speedy/synchronous promise\n\t\tvar retVal, stage=0, thenFuncs = null, catchFuncs = null, finallies = null, retObj = new SPromise_construct(\n\t\t\tfunction(tFunc, cFunc){\n\t\t\t\tif (DEBUGMODE){\n\t\t\t\t\tif (tFunc != undefined && typeof tFunc !== \"function\"){\n\t\t\t\t\t\tconsole.warn(Object.prototype.toString.call(tFunc) + \" is not a valid function to be called after a successful promise\");\n\t\t\t\t\t}\n\t\t\t\t\tif (cFunc != undefined && typeof cFunc !== \"function\"){\n\t\t\t\t\t\tconsole.warn(Object.prototype.toString.call(cFunc) + \" is not a valid function to be called after a rejected promise\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (stage === 0){\n\t\t\t\t\t// promise has not yet completed...\n\t\t\t\t\treturn _NOCHECK_SPromise(function(accept, reject){\n\t\t\t\t\t\tvar finalAcceptor = typeof tFunc === \"function\" ? function(){accept(tFunc(retVal));} : accept;\n\t\t\t\t\t\tvar finalRejector = typeof cFunc === \"function\" ? function(){reject(cFunc(retVal));} : reject;\n\n\t\t\t\t\t\tif (thenFuncs !== null) {\n\t\t\t\t\t\t\tif (typeof thenFuncs === \"function\") {\n\t\t\t\t\t\t\t\tthenFuncs = [ thenFuncs, finalAcceptor ];\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthenFuncs.push(finalAcceptor);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else thenFuncs = finalAcceptor;\n\n\t\t\t\t\t\tif (catchFuncs !== null) {\n\t\t\t\t\t\t\tif (typeof catchFuncs === \"function\") {\n\t\t\t\t\t\t\t\tcatchFuncs = [ catchFuncs, finalRejector ];\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcatchFuncs.push(finalRejector);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else catchFuncs = finalRejector;\n\t\t\t\t\t});\n\t\t\t\t} else try {\n\t\t\t\t\treturn stage === 2 ? (\n\t\t\t\t\t\ttypeof tFunc === \"function\" ? _NOCHECK_resolve( tFunc(retVal) ) : undefinedResolve\n\t\t\t\t\t) : (\n\t\t\t\t\t\ttypeof cFunc === \"function\" ? _NOCHECK_reject( cFunc(retVal) ) : undefinedResolve\n\t\t\t\t\t);\n\t\t\t\t} catch(e) {return _NOCHECK_reject(e);}\n\t\t\t},\n\t\t\tfunction(cFunc){\n\t\t\t\tif (DEBUGMODE){\n\t\t\t\t\tif (cFunc != undefined && typeof cFunc !== \"function\"){\n\t\t\t\t\t\tconsole.warn(Object.prototype.toString.call(cFunc) + \" is not a valid function to be called after a rejected promise\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (stage === 0){\n\t\t\t\t\t// promise has not yet completed...\n\t\t\t\t\treturn _NOCHECK_SPromise(function(accept){\n\t\t\t\t\t\tif (catchFuncs !== null) {\n\t\t\t\t\t\t\tif (typeof catchFuncs === \"function\") {\n\t\t\t\t\t\t\t\tcatchFuncs = [ catchFuncs, function(){accept(cFunc(retVal));} ];\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcatchFuncs.push(function(){accept(cFunc(retVal));});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else catchFuncs = function(){accept(cFunc(retVal));};\n\t\t\t\t\t\tif (thenFuncs !== null) {\n\t\t\t\t\t\t\tif (typeof thenFuncs === \"function\") {\n\t\t\t\t\t\t\t\tthenFuncs = [ thenFuncs, accept ];\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthenFuncs.push(accept);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else thenFuncs = accept;\n\t\t\t\t\t});\n\t\t\t\t} else if (stage === 2) { // if success, then merely propagate the response transparently\n\t\t\t\t\treturn _NOCHECK_resolve(retVal);\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn typeof cFunc === \"function\" ? _NOCHECK_resolve( cFunc(retVal) ) : undefinedResolve;\n\t\t\t\t\t} catch(e) {\n\t\t\t\t\t\treturn _NOCHECK_reject(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tfunction(fFunc){\n\t\t\t\tif (DEBUGMODE){\n\t\t\t\t\tif (fFunc != undefined && typeof fFunc !== \"function\"){\n\t\t\t\t\t\tconsole.warn(Object.prototype.toString.call(fFunc) + \" is not a valid function to be called 'finally' after promise\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (stage === 0) {\n\t\t\t\t\tif (finallies !== null) {\n\t\t\t\t\t\tif (typeof finallies === \"function\") {\n\t\t\t\t\t\t\tfinallies = [ finallies, fFunc ];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfinallies.push(fFunc);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else finallies = fFunc;\n\t\t\t\t} else try {\n\t\t\t\t\tfFunc();\n\t\t\t\t} catch(e) {\n\t\t\t\t\treturn _NOCHECK_reject(e);\n\t\t\t\t}\n\t\t\t\treturn retObj;\n\t\t\t}\n\t\t);\n\t\t// stage undefined = unfulfilled\n\t\t// stage true = accepted\n\t\t// stage false = rejected\n\n\t\tfunction acceptP(x){\n\t\t\t// This specific order should allow for max GZip compression\n\t\t\tif (stage === 0) {\n\t\t\t\tif (isPromise(x)) {\n\t\t\t\t\tx.then(acceptP, rejectP); // wait for further commitment before resolving. [FYI: this takes a non-compliant shortcut]\n\t\t\t\t} else {\n\t\t\t\t\tretVal = x;\n\t\t\t\t\tstage = 2;\n\t\t\t\t\tif (thenFuncs !== null)\t{\n\t\t\t\t\t\tif (typeof thenFuncs === \"function\") {\n\t\t\t\t\t\t\tthenFuncs(x);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthenFuncs.forEach(proxy, x);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthenFuncs = null;\n\t\t\t\t\t}\n\t\t\t\t\tcatchFuncs = null;\n\t\t\t\t\tif (finallies !== null)\t{\n\t\t\t\t\t\tif (typeof finallies === \"function\") {\n\t\t\t\t\t\t\tfinallies();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfinallies.forEach(exec);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinallies = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfunction rejectP(x){\n\t\t\tif (stage === 0) {\n\t\t\t\tretVal = x;\n\t\t\t\tstage = 1;\n\t\t\t\tif (catchFuncs !== null)\t{\n\t\t\t\t\tif (typeof catchFuncs === \"function\") {\n\t\t\t\t\t\tcatchFuncs(x);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcatchFuncs.forEach(proxy, x);\n\t\t\t\t\t}\n\t\t\t\t\tcatchFuncs = null;\n\t\t\t\t}\n\t\t\t\tthenFuncs = null;\n\t\t\t\tif (finallies !== null)\t{\n\t\t\t\t\tif (typeof finallies === \"function\") {\n\t\t\t\t\t\tfinallies();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfinallies.forEach(exec);\n\t\t\t\t\t}\n\t\t\t\t\tfinallies = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// synchonously defered stacking allows for super performance\n\t\tif (isInsidePromise === true) {\n\t\t\tpersuadoStack.push(\n\t\t\t\tfunction(){\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfunc(acceptP, rejectP);\n\t\t\t\t\t} catch(e) {\n\t\t\t\t\t\trejectP(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\tpStackLength = pStackLength + 1|0;//+= 3;\n\t\t} else {\n\t\t\tpromiseLevel = promiseLevel + 1|0;\n\t\t\tif (isInsidePromise = promiseLevel === promiseBufferLvl){\n\t\t\t\ttry {\n\t\t\t\t\tfunc(acceptP, rejectP);\n\t\t\t\t} catch(e) {\n\t\t\t\t\trejectP(e);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tfunc(acceptP, rejectP);\n\t\t\t\t} catch(e) {\n\t\t\t\t\trejectP(e);\n\t\t\t\t}\n\t\t\t\tif (isInsidePromise === true && promiseLevel === 1) { // if this is the outermost promise\n\t\t\t\t\tresolvePends();\n\t\t\t\t}\n\t\t\t}\n\t\t\tpromiseLevel = promiseLevel - 1|0;\n\t\t}\n\t\treturn retObj;\n\t}", "title": "" }, { "docid": "faa51564fccef0bd0bb576fd4b893f56", "score": "0.59334457", "text": "function createPromise() {\n var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n var defaultTypes = [ActionType.Pending, ActionType.Fulfilled, ActionType.Rejected];\n var PROMISE_TYPE_SUFFIXES = config.promiseTypeSuffixes || defaultTypes;\n var PROMISE_TYPE_DELIMITER = config.promiseTypeDelimiter || '_';\n\n return function (ref) {\n var dispatch = ref.dispatch;\n\n\n return function (next) {\n return function (action) {\n\n /**\n * Instantiate variables to hold:\n * (1) the promise\n * (2) the data for optimistic updates\n */\n var promise = void 0;\n var data = void 0;\n\n /**\n * There are multiple ways to dispatch a promise. The first step is to\n * determine if the promise is defined:\n * (a) explicitly (action.payload.promise is the promise)\n * (b) implicitly (action.payload is the promise)\n * (c) as an async function (returns a promise when called)\n *\n * If the promise is not defined in one of these three ways, we don't do\n * anything and move on to the next middleware in the middleware chain.\n */\n\n // Step 1a: Is there a payload?\n if (action.payload) {\n var PAYLOAD = action.payload;\n\n // Step 1.1: Is the promise implicitly defined?\n if (Object(_isPromise_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(PAYLOAD)) {\n promise = PAYLOAD;\n }\n\n // Step 1.2: Is the promise explicitly defined?\n else if (Object(_isPromise_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(PAYLOAD.promise)) {\n promise = PAYLOAD.promise;\n data = PAYLOAD.data;\n }\n\n // Step 1.3: Is the promise returned by an async function?\n else if (typeof PAYLOAD === 'function' || typeof PAYLOAD.promise === 'function') {\n promise = PAYLOAD.promise ? PAYLOAD.promise() : PAYLOAD();\n data = PAYLOAD.promise ? PAYLOAD.data : undefined;\n\n // Step 1.3.1: Is the return of action.payload a promise?\n if (!Object(_isPromise_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(promise)) {\n\n // If not, move on to the next middleware.\n return next(_extends({}, action, {\n payload: promise\n }));\n }\n }\n\n // Step 1.4: If there's no promise, move on to the next middleware.\n else {\n return next(action);\n }\n\n // Step 1b: If there's no payload, move on to the next middleware.\n } else {\n return next(action);\n }\n\n /**\n * Instantiate and define constants for:\n * (1) the action type\n * (2) the action meta\n */\n var TYPE = action.type;\n var META = action.meta;\n\n /**\n * Instantiate and define constants for the action type suffixes.\n * These are appended to the end of the action type.\n */\n\n var _PROMISE_TYPE_SUFFIXE = _slicedToArray(PROMISE_TYPE_SUFFIXES, 3),\n PENDING = _PROMISE_TYPE_SUFFIXE[0],\n FULFILLED = _PROMISE_TYPE_SUFFIXE[1],\n REJECTED = _PROMISE_TYPE_SUFFIXE[2];\n\n /**\n * Function: getAction\n * Description: This function constructs and returns a rejected\n * or fulfilled action object. The action object is based off the Flux\n * Standard Action (FSA).\n *\n * Given an original action with the type FOO:\n *\n * The rejected object model will be:\n * {\n * error: true,\n * type: 'FOO_REJECTED',\n * payload: ...,\n * meta: ... (optional)\n * }\n *\n * The fulfilled object model will be:\n * {\n * type: 'FOO_FULFILLED',\n * payload: ...,\n * meta: ... (optional)\n * }\n */\n\n\n var getAction = function getAction(newPayload, isRejected) {\n return _extends({\n // Concatentate the type string property.\n type: [TYPE, isRejected ? REJECTED : FULFILLED].join(PROMISE_TYPE_DELIMITER)\n\n }, newPayload === null || typeof newPayload === 'undefined' ? {} : {\n payload: newPayload\n }, META !== undefined ? { meta: META } : {}, isRejected ? {\n error: true\n } : {});\n };\n\n /**\n * Function: handleReject\n * Calls: getAction to construct the rejected action\n * Description: This function dispatches the rejected action and returns\n * the original Error object. Please note the developer is responsible\n * for constructing and throwing an Error object. The middleware does not\n * construct any Errors.\n */\n var handleReject = function handleReject(reason) {\n var rejectedAction = getAction(reason, true);\n dispatch(rejectedAction);\n\n throw reason;\n };\n\n /**\n * Function: handleFulfill\n * Calls: getAction to construct the fullfilled action\n * Description: This function dispatches the fulfilled action and\n * returns the success object. The success object should\n * contain the value and the dispatched action.\n */\n var handleFulfill = function handleFulfill() {\n var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\n var resolvedAction = getAction(value, false);\n dispatch(resolvedAction);\n\n return { value: value, action: resolvedAction };\n };\n\n /**\n * First, dispatch the pending action:\n * This object describes the pending state of a promise and will include\n * any data (for optimistic updates) and/or meta from the original action.\n */\n next(_extends({\n // Concatentate the type string.\n type: [TYPE, PENDING].join(PROMISE_TYPE_DELIMITER)\n\n }, data !== undefined ? { payload: data } : {}, META !== undefined ? { meta: META } : {}));\n\n /**\n * Second, dispatch a rejected or fulfilled action and move on to the\n * next middleware.\n */\n return promise.then(handleFulfill, handleReject);\n };\n };\n };\n}", "title": "" }, { "docid": "89a8adb3d8d105c546885dee6004b4d1", "score": "0.5930733", "text": "function nativePromiseVersion() {\n returnsFirstPromise()\n .then((firstValue) => {\n console.log(firstValue);\n return returnsSecondPromise(firstValue);\n })\n .then((secondValue) => {\n console.log(secondValue);\n });\n}", "title": "" }, { "docid": "ca3c6b959f992034407002b9a426ff70", "score": "0.59281456", "text": "function e(e,t,a,n){return new(a||(a=Promise))((function(i,o){function r(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(r,s)}l((n=n.apply(e,t||[])).next())}))}", "title": "" }, { "docid": "7ffdae0a96d79f999366686d3d9bd3ea", "score": "0.59261316", "text": "then(opt_resolve, opt_reject) {\n if (!opt_resolve && !opt_reject) {\n return this.promise_;\n }\n return this.promise_.then(opt_resolve, opt_reject);\n }", "title": "" } ]
36f530c605e910090438f74dadca68aa
Triggers the activityHandler manually to allow external user defined activity. i.e. While watching a video
[ { "docid": "38d587149f4dbb466567109d4cf524ef", "score": "0.0", "text": "function updatePageActivity(trackers) {\n dispatchToTrackers(trackers, function (t) {\n t.updatePageActivity();\n });\n}", "title": "" } ]
[ { "docid": "b3aa3f38068b2908c7620aade6a3d2c0", "score": "0.6129819", "text": "function startAction(localVideo, remoteVideo) {\n\n}", "title": "" }, { "docid": "0a8329a9a5a829e77283c7e961f0dcd8", "score": "0.5920481", "text": "startLocalVideo() {\n console.log(\"SFU::startLocalVideo\");\n this.attachMedia();\n }", "title": "" }, { "docid": "4583d87c306d87a5c900bdd117bf7037", "score": "0.5758417", "text": "function onClickHandler(info, tab) {\n\n var vidId = info.linkUrl.split('?v=')[1]; // get unique vid id\n var redirectUrl = \"https://youtube.com/v/\" + vidId; // create direct link to vid\n chrome.tabs.update (tab.id, {url: redirectUrl}); // navigate current tab to direct vid page\n}", "title": "" }, { "docid": "115e85470345630dff10a42cdae055d0", "score": "0.5743016", "text": "function activityHandler() {\n var now = new Date();\n lastActivityTime = now.getTime();\n }", "title": "" }, { "docid": "166384c4c2dc33b55f489f94b290653b", "score": "0.55884635", "text": "function onActivity() {\r\n this.latestActivity = new Date().getTime();\r\n}", "title": "" }, { "docid": "befd9f6cb7fcfe0344f1a245cce8a313", "score": "0.55434304", "text": "function notify_video_watched(video_id) {\n if (chrome.tabs) {\n chrome.tabs.getSelected(null, function(tab) {\n chrome.tabs.sendMessage(tab.id, { operation: \"video watched\", video_id: video_id }, function(response) {\n console.log(\"Video \" + video_id + \" watched.\");\n });\n });\n }\n}", "title": "" }, { "docid": "a061410ee4c759a29ff4e5c0b347111f", "score": "0.5531906", "text": "onVideoFocusChanged(e) {\n const userId = e.detail.userId;\n const from = e.detail.from;\n let detail = {\n media: this.localStream,\n from: 'videoFocusChanged'\n };\n // if from click handler must need a change\n if (from === 'onClickHandler') {\n detail.media = userId === 'local' ? this.localStream : this.remoteStreams[userId];\n } else {\n if (this.remoteStreams[this.previouslySelectedUserId]) {\n detail.media = this.remoteStreams[this.previouslySelectedUserId];\n } else if (this.remoteStreams[userId]) {\n detail.media = this.remoteStreams[userId];\n }\n }\n this.previouslySelectedUserId = userId;\n TriggerEvent(\n CsioEvents.CsioMediaCtrl.VIDEO_FOCUS_CHANGE, detail);\n }", "title": "" }, { "docid": "419200d0a99c075282dd808cfe54f20b", "score": "0.55109227", "text": "function videoStarted() { playing = true }", "title": "" }, { "docid": "065ebb92f518e75c8992cc05d2d86d34", "score": "0.5490573", "text": "function LatchToVideo() {\r\n var MainVid = document.getElementsByTagName('video');\r\n for (let i = 0; i < MainVid.length; i++){\r\n if (MainVid[i].className == \"video-stream html5-main-video\"){\r\n MainVid[i].onseeked = function() {\r\n console.log(MainVid[i].currentTime); // It's in seconds.miliseconds format\r\n // SEND THIS TO APP\r\n\t\t\t};\r\n\t\t\tMainVid[i].onpause = function() {\r\n\t\t\t\tconsole.log(\"VIDEO PAUSE\")\r\n\t\t\t\t// SEND THIS TO APP\r\n\t\t\t};\r\n\t\t\tMainVid[i].onplay = function() {\r\n\t\t\t\tconsole.log(\"VIDEO PLAY\")\r\n\t\t\t\t// SEND THIS TO APP\r\n\t\t\t};\r\n\r\n\t\t\talert(\"Time Seeker Latched\");\r\n break;\r\n }\r\n }\r\n}", "title": "" }, { "docid": "b15f475deafc59c0b1349885dfeb541d", "score": "0.5446551", "text": "function NYT_VideoPlayerStart() {}", "title": "" }, { "docid": "019a37434d8e9c1b146b3a55696e9601", "score": "0.53827655", "text": "function onAccessApproved(id) {\n if (!id) {\n updateMessage(\"Access rejected.\");\n return;\n }\n\n screenController.startScreenConnection({\n audio:{\n mandatory: {\n chromeMediaSource: 'desktop',\n chromeMediaSourceId: id\n }\n },\n video: {\n mandatory: {\n chromeMediaSource: 'desktop',\n chromeMediaSourceId: id,\n maxWidth: screen.width,\n maxHeight: screen.height\n }\n }\n }, document.querySelector('#video'));\n}", "title": "" }, { "docid": "212eaccf021b9c62faf1b07d40b163ce", "score": "0.53713655", "text": "activity(ev) {\n this.lastActivityTime = Date.now();\n }", "title": "" }, { "docid": "b759a89b8a69740755f485d2db1d7dc6", "score": "0.53308016", "text": "function videoControl (videoId, tempUrl, obj) {\n\t\t\t\tdocument.getElementById(videoId).play();\n\t\t\t\t$(\"#\"+videoId).bind(\"ended\", function() {\n\t\t\t\t\t$(\"#\"+videoId).css(\"display\",\"none\");\n\n //show the hidden clicked link/image\n $(obj).css(\"display\", \"block\");\n\n // Add back the original url in case if user will click on Video link again.\n\t\t\t\t\t$(obj).attr('href', tempUrl);\n\t\t\t\t});\n\t\t\t\t//\n\t\t\t}", "title": "" }, { "docid": "e339b4e033ab4c615ec0072b81eff778", "score": "0.5308056", "text": "function onPlayerReady(e) {\r\n /* don't play the video for now, autoplay is cancerous.\r\n e.target.playVideo();\r\n */\r\n}// close onplayerready function", "title": "" }, { "docid": "b62e954091458f53aab73f4cd72a3909", "score": "0.5272384", "text": "async function setActivity(channelName, startTimestamp) {\n\n if (!rpc || !windows.mainWindow.win) {\n return\n }\n\n rpc.setActivity({\n details: `Watching ${channelName}`,\n startTimestamp,\n largeImageKey: \"icon_discord\",\n instance: false\n })\n}", "title": "" }, { "docid": "0f24bf9014810118580d6ee98549d98a", "score": "0.5269774", "text": "function setupActivity() {\n var activity = require(\"./activity-setup.js\");\n activity.setupActivity(game.scene.scenes[0]);\n}", "title": "" }, { "docid": "5e329f249a77ef5003412eac433de960", "score": "0.5253463", "text": "function onPlayerReady(event) {\r\n //event.target.playVideo();\r\n}", "title": "" }, { "docid": "5b67a0778530efb133a9e46a649aa424", "score": "0.5249193", "text": "function screenClick() {\n\tvidplay();\n}", "title": "" }, { "docid": "43bbaa9884d66ed9af96a259d11ecb6c", "score": "0.5245779", "text": "function onPlayerReady(event) {\nevent.target.playVideo();\n}", "title": "" }, { "docid": "4b76c34a171aa9b89e7d0b2d78b8bd49", "score": "0.5240268", "text": "updateActivity(context, activity) {\n return __awaiter(this, void 0, void 0, function* () {\n debug('Web adapter does not support updateActivity.');\n });\n }", "title": "" }, { "docid": "abb8801eb6cd5094039609905190fa09", "score": "0.5240107", "text": "static enableVideo() {\n Agora.enableVideo();\n }", "title": "" }, { "docid": "a2014c0ef182f5d0c623de780cb4d67f", "score": "0.52389187", "text": "function onPlayerReady(event) {\n//event.target.playVideo();\n}", "title": "" }, { "docid": "4c9b6caa77f9e8bafab1fc99a992dafb", "score": "0.5231936", "text": "function customAutoLoadActions(){\r\n\r\n\t\r\n\tsetHomePageStyle();\r\n\t//set_analytics_obj(config.application.user);\r\n\t/*\r\n\tapp.initialize();\r\n\t\r\n\tsetSplashAsBackground(config.application.user);\r\n\tsetMoreColorTheme(config.application.user);\r\n\t//setThemeAppearance(config.application.user);\r\n\tif(device.platform == \"Android\"){\r\n\t\tvar recordFileName = \"choiceline.mp3\";\r\n\t}else{\r\n\t\tvar recordFileName = \"choiceline.wav\";\r\n\t}*/\r\n}", "title": "" }, { "docid": "cada911b6db48fda451e6c84bd58e8ee", "score": "0.5212664", "text": "playVideo() {\n\t\t// this.loadVideo();\n\t}", "title": "" }, { "docid": "c08d91ad7a039e221c408685c4645a87", "score": "0.5207593", "text": "function showActivity( activity )\n{\n if ( activity .video != null && activity .audio == null )\n {\n beginTheatre() ;\n $( \"#theatre\" ) .click( destroyTheatre ) ;\n\n var video_json = $.parseJSON( '{\"playable\":' + activity .video .playable + \n ',\"url_iphone\":\"' + activity .video .url_iphone + '\"}' ) ;\n showVideo( video_json ) ;\n return ;\n }\n stopAllAudio() ;\n var imageDiv = \"<div id=box_container> <div id=image_div> \\\n <img src=\" + activity .activity_url + \" id='activity_detail_img'> \\\n <div id='photo_black_cover'> </div> \\\n <div id='btn_part'> </div> \\\n <div id='audio_playing_block'> <p id='duration_time'>0.0\" + '\"' + \"</p> </div> \\\n </div> </div>\" ;\n $( \"#theatre\" ) .prepend( imageDiv ) ;\n $( \"#activity_detail_img\" ) .load( function() { \n $( \"#photo_black_cover\" ) .css( \"display\" , \"none\" ) ;\n }) ;\n $( \"#activity_detail_img\" ) .css( \"max-width\" , \"1000px\" ) ;\n $( \"#activity_detail_img\" ) .css( \"height\" , \"auto\" ) ;\n $( \"#activity_detail_img\" ) .css( \"width\" , \"auto\" ) ;\n //$( \"#image_div\" ) .css( \"width\" , activity .img_width ) ;\n new_close_button( $( \"#image_div\" ) ) ;\n\n // activity btn show\n var params_count = 0 ;\n if ( activity .audio != null )\n {\n var audio_json = '{\"id\":' + activity .audio .id + ',\"filename\":\"' + activity .audio .filename + '\"}'\n $( \"#btn_part\" ) .append( \"<a href=javascript:touchAudio(\" + audio_json + \") class='btn has_audio'> </a>\" );\n params_count ++ ;\n }\n if ( activity .video != null )\n {\n var video_json = '{\"playable\":' + activity .video .playable + \n ',\"url_iphone\":\"' + activity .video .url_iphone + '\"}' ;\n $( \"#btn_part\" ) .append( \"<a href=javascript:showVideo(\" + video_json + \") class='btn has_video'> </a>\" ) ;\n params_count ++ ;\n }\n if ( params_count == 1 ) $( \"#btn_part\" ) .css( \"margin-left\" , \"-35px\" ) ;\n if ( params_count == 2 ) $( \"#btn_part\" ) .css( \"margin-left\" , \"-90px\" ) ;\n\n // Theatre show\n beginTheatre() ;\n $( \"#btn_part\" ) .click( function( event ) {\n event .stopPropagation() ;\n }) ;\n $( \"#theatre\" ) .click( destroyTheatre ) ;\n if ( activity .audio != null ) touchAudio( activity .audio ) ;\n}", "title": "" }, { "docid": "c6d65ad5c3c0e8de44a4f442ac9db6d8", "score": "0.51922345", "text": "function watchVideo() {\n var video = document.getElementsByTagName(\"video\")[0];\n //alert(video);\n if (video) {\n for (i in videoEvents) {\n if (videoEvents[i].triggered) return;\n videoEvents[i].triggered = true;\n video.addEventListener(videoEvents[i].type, function (e) {\n var mediaEvent = new Caliper.Events.MediaEvent();\n mediaEvent.setActor(actor);\n var videoObject = new Caliper.Entities.VideoObject();\n videoObject.setId(e.target.src);\n videoObject.setDuration(e.target.duration);\n\n if (e.type === 'playing') {\n mediaEvent.setAction(Caliper.Actions.MediaActions.STARTED);\n } else if (e.type === 'pause') {\n mediaEvent.setAction(Caliper.Actions.MediaActions.PAUSED);\n }\n\n videoObject.setIsPartOf(object);\n mediaEvent.setObject(videoObject);\n\n var target = new Caliper.Entities.MediaLocation();\n target.setId(e.target.src);\n target.setCurrentTime(new Date().getTime());\n\n mediaEvent.setTarget(target);\n mediaEvent.setEventTime(new Date().toISOString());\n\n console.log('new mediaEvent:'+ JSON.stringify(mediaEvent,1));\n postEvent(sensor, mediaEvent);\n });\n }\n }\n clearTimeout(interval);\n }", "title": "" }, { "docid": "2a8a62bd6814949aac34e8900a0e1131", "score": "0.51874304", "text": "function onPlayerReady(event) {\n //event.target.playVideo();\n }", "title": "" }, { "docid": "e6e908d1b20a6a6663bc16549587c04c", "score": "0.5184198", "text": "function onPlayerReady(event) {\n //event.target.playVideo();\n }", "title": "" }, { "docid": "6ce5f3284451c9d2ba04f30eab257eaa", "score": "0.5183094", "text": "function handleAPILoaded(token) {\n getPlaylistId();\n props = {\n \"id\": \"watchlatercontext\",\n \"title\": \"Add video to Watch Later\",\n \"contexts\": ['page', 'frame', 'link'],\n \"onclick\": watchLater\n }\n chrome.contextMenus.create(props, function() {\n // console.log('context created');\n });\n}", "title": "" }, { "docid": "45dd542cf926b8040f021f3dbece60e9", "score": "0.5169318", "text": "function onVideoClickTrigger(){\n $_fsg_button.togglePlayButton('hide');\n\t\t$_fullsize.stopSlideShow();\n\t}", "title": "" }, { "docid": "44c87b2bb33ebaf01bcc8b0e04e7a6dd", "score": "0.516864", "text": "function setClick2CallVideoWidget(config) {\r\n\tif (!videoWidgetHtml) {\r\n\t\tthrow new TypeError(config.click2callMediaWidget + \"widget has not been set, cannot build click-2-call tab\");\r\n\t}\r\n\t\r\n\torientationOfClick2Call = config.click2callOrientation;\r\n\t\r\n\t/*\r\n\t * Setup event handlers for the video widget\r\n\t */\r\n\tvar setupVideoWidgetHandlers = function () {\r\n\t\t$('.croc_side-tab').click(function() {\r\n\t\t\tif (!isClicked) {\r\n\t\t\t\tswitch (orientationOfClick2Call) {\r\n\t\t\t\tcase 'top':\r\n\t\t\t\t\t// Expand tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\ttop: '343px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'left':\r\n\t\t\t\t\t// Expand tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tleft: '511px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\t// Expand tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tright: '511px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// Show tab content\r\n\t\t\t\t$('.croc_side-tab-content-video').show(600);\r\n\t\t\t\t\r\n\t\t\t\t// Make a call if not already making a call\r\n\t\t\t\tif (!crocObjectConnected) {\r\n\t\t\t\t\trequestVideo(config.addressToCall);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tisClicked = true;\r\n\t\t\t} else if (isClicked) {\r\n\t\t\t\tswitch (orientationOfClick2Call) {\r\n\t\t\t\tcase 'top':\r\n\t\t\t\t\t// Collapse tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\ttop: '0px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'left':\r\n\t\t\t\t\t// Collapse tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tleft: '0px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\t// Collapse tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tright: '0px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// Show tab content\r\n\t\t\t\t$('.croc_side-tab-content-video').hide(1000);\r\n\t\t\t\t\r\n\t\t\t\tisClicked = false;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t});\r\n\t\t\r\n\t\t// Setup close button\r\n\t\t$('.croc_btn_close').click(function(){\r\n\t\t\t// End the video call\r\n\t\t\tendVideo();\r\n\t\t});\r\n\t\t\r\n\t\t// Setup end call button\r\n\t\t$('.croc_btn_endcall_s').click(function() {\r\n\t\t\t// End the video call\r\n\t\t\tendVideo();\r\n\t\t});\r\n\t\t\r\n\t\tvar togglePauseVideo = false;\r\n\t\t\r\n\t\t// Set pause video button\r\n\t\t$('.croc_btn_pausevideo_s').click(function () {\r\n\t\t\tif (!togglePauseVideo) {\r\n\t\t\t\ttogglePauseVideo = true;\r\n\t\t\t\tpauseVideo();\r\n\t\t\t} else {\r\n\t\t\t\ttogglePauseVideo = false;\r\n\t\t\t\tresumeVideo();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tvar toggleOnMute = false;\r\n\t\t\r\n\t\t// Set mute audio button\r\n\t\t$('.croc_mute_video_audio').click(function () {\r\n\t\t\tif (!toggleOnMute) {\r\n\t\t\t\ttoggleOnMute = true;\r\n\t\t\t\tmuteAudio();\r\n\t\t\t} else {\r\n\t\t\t\ttoggleOnMute = false;\r\n\t\t\t\tunmuteAudio();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tvar toggleLocalVideo = true;\r\n\t\t\r\n\t\t// Setup click event for local video button to display/hide local video\r\n\t\t$('.croc_btn_localvideo').click(function () {\r\n\t\t\tif (toggleLocalVideo) {\r\n\t\t\t\ttoggleLocalVideo = false;\r\n\t\t\t\t$('.croc_tpl_controls').removeClass(\"croc_ui_localvideoshown\");\r\n\t\t\t} else {\r\n\t\t\t\ttoggleLocalVideo = true;\r\n\t\t\t\t$('.croc_tpl_controls').addClass(\"croc_ui_localvideoshown\");\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\t// Setup full screen button\r\n\t\t$('.croc_btn_fullscreen').click(function() {\r\n\t\t\tif (!isFullscreen) {\r\n\t\t\t\tisFullscreen = true;\r\n\t\t\t\tsetVideoToFullscreen(true);\r\n\t\t\t} else {\r\n\t\t\t\tisFullscreen = false;\r\n\t\t\t\tsetVideoToFullscreen(false);\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\t// Setup keypad popout\r\n\t\t$('.croc_ui_popout').click(function(evt){\r\n\t\t\t$('body').click(function(evt2){\r\n\t\t\t\t// Dont close if popout content is pressed\r\n\t\t\t\tvar currentTarget = $(evt.target);\r\n\t\t\t\twhile(currentTarget[0]){\r\n\t\t\t\t\tif(currentTarget[0] === evt.target[0]) {\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tcurrentTarget = currentTarget.parent();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$('body').off('click');\r\n\r\n\t\t\t\t$('.croc_ui_popout').removeClass('croc_ui_popout_open');\r\n\t\t\t\t$('.croc_tpl_titlebar').removeClass('croc_ui_shown');\r\n\t\t\t\t$('.croc_tpl_actions').removeClass('croc_ui_shown');\r\n\t\t\t});\r\n\r\n\t\t\tevt.stopPropagation();\r\n\t\t\t$('.croc_ui_popout').addClass('croc_ui_popout_open');\r\n\t\t\t$('.croc_tpl_titlebar').addClass('croc_ui_shown');\r\n\t\t\t$('.croc_tpl_actions').addClass('croc_ui_shown');\r\n\t\t});\r\n\r\n\t\t// Make sure keypad and tool bars aren't displayed\r\n\t\t$('.croc_ui_popout').removeClass('croc_ui_popout_open');\r\n\t\t$('.croc_tpl_titlebar').removeClass('croc_ui_shown');\r\n\t\t$('.croc_tpl_actions').removeClass('croc_ui_shown');\r\n\r\n\t\t// Setup keypad buttons\r\n\t\tvar keypad = $('.croc_ui_keypad');\r\n\t\tkeypad.find('.croc_tpl_key').click(function(){\r\n\t\t\tvar value = $(this).find('.croc_tpl_main').text();\r\n\t\t\tvideoSession.sendDTMF(value);\r\n\t\t});\r\n\t};\r\n\t\r\n\t// Get the HTML element to append to\r\n\tvar htmlElement = $(config.appendClick2callTo);\r\n\tvar i;\r\n\t\r\n\t// Add the HTML as a child of the element specified in the configuration if the element exists.\r\n\tif (htmlElement.length !== 0) {\r\n\t\t// For every HTML element of that kind, add video tab\r\n\t\tfor (i=0; i < htmlElement.length; i++) {\r\n\t\t\t// Check that document contains HTML element\r\n\t\t\tif ($.contains(document, htmlElement[i])) {\r\n\t\t\t\t// Add video tab\r\n\t\t\t\t$(config.appendClick2callTo).append(videoWidgetHtml);\r\n\t\t\t} else {\r\n\t\t\t\t// If the HTML element specified doesn't exist, add to HTML\r\n\t\t\t\t$('html').append(videoWidgetHtml);\r\n\t\t\t}\r\n\t\t}\r\n\t} else {\r\n\t\t// If the HTML element specified doesn't exist, add to HTML\r\n\t\t$('html').append(videoWidgetHtml);\r\n\t}\r\n\t\r\n\t// Add video widget event handlers\r\n\tsetupVideoWidgetHandlers();\r\n\t\r\n\t/*\r\n\t * Setup the position of the click to call tab; fixed or absolute\r\n\t */\r\n\tvar positionOfClick2Call = config.click2callPosition;\r\n\tmediaWidget = config.click2callMediaWidget;\r\n\t\r\n\t// Add to correct widget only if value is absolute or fixed\r\n\tif (mediaWidget === 'video' && positionOfClick2Call === 'absolute' || positionOfClick2Call === 'fixed') {\r\n\t\t// Change css position to user defined/default position\r\n\t\t$('.croc_tab-wrapper-video').css('position', config.click2callPosition);\r\n\t}\r\n\t\r\n\t/*\r\n\t * Setup the tab orientation on screen; top, right, bottom or left\r\n\t */\r\n\tswitch (orientationOfClick2Call) {\r\n\tcase 'top':\r\n\t\t$('.croc_tab-container').removeClass('croc_tab-wrapper-video');\r\n\t\t$('.croc_tab-container').addClass('croc_video-top-tab');\r\n\t\t$('.croc_side-tab').removeClass('croc_rotate-vertical');\r\n\t\t$('.croc_side-tab').addClass('croc_video-top-side-tab');\r\n\t\t$('.croc_side-tab-content-video').addClass('croc_video-top-content');\r\n\t\t$('.croc_side-tab').css('borderRadius', '0 0 10px 10px');\r\n\t\tbreak;\r\n\tcase 'bottom':\r\n\t\t$('.croc_tab-container').removeClass('croc_tab-wrapper-video');\r\n\t\t$('.croc_tab-container').addClass('croc_video-bottom-tab');\r\n\t\t$('.croc_side-tab').removeClass('croc_rotate-vertical');\r\n\t\t$('.croc_side-tab').addClass('croc_video-side-tab-bottom');\r\n\t\t$('.croc_side-tab-content-video').addClass('croc_video-bottom-content');\r\n\t\tbreak;\r\n\tcase 'left':\r\n\t\t$('.croc_tab-container').addClass('croc_video-left-tab');\r\n\t\t$('.croc_side-tab-content-video').addClass('croc_video-left-content');\r\n\t\t$('.croc_side-tab').css('borderRadius', '0 0 10px 10px');\r\n\t\tbreak;\r\n\tdefault:\r\n\t\tbreak;\r\n\t}\r\n}", "title": "" }, { "docid": "44c87b2bb33ebaf01bcc8b0e04e7a6dd", "score": "0.516864", "text": "function setClick2CallVideoWidget(config) {\r\n\tif (!videoWidgetHtml) {\r\n\t\tthrow new TypeError(config.click2callMediaWidget + \"widget has not been set, cannot build click-2-call tab\");\r\n\t}\r\n\t\r\n\torientationOfClick2Call = config.click2callOrientation;\r\n\t\r\n\t/*\r\n\t * Setup event handlers for the video widget\r\n\t */\r\n\tvar setupVideoWidgetHandlers = function () {\r\n\t\t$('.croc_side-tab').click(function() {\r\n\t\t\tif (!isClicked) {\r\n\t\t\t\tswitch (orientationOfClick2Call) {\r\n\t\t\t\tcase 'top':\r\n\t\t\t\t\t// Expand tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\ttop: '343px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'left':\r\n\t\t\t\t\t// Expand tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tleft: '511px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\t// Expand tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tright: '511px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// Show tab content\r\n\t\t\t\t$('.croc_side-tab-content-video').show(600);\r\n\t\t\t\t\r\n\t\t\t\t// Make a call if not already making a call\r\n\t\t\t\tif (!crocObjectConnected) {\r\n\t\t\t\t\trequestVideo(config.addressToCall);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tisClicked = true;\r\n\t\t\t} else if (isClicked) {\r\n\t\t\t\tswitch (orientationOfClick2Call) {\r\n\t\t\t\tcase 'top':\r\n\t\t\t\t\t// Collapse tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\ttop: '0px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'left':\r\n\t\t\t\t\t// Collapse tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tleft: '0px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\t// Collapse tab.\r\n\t\t\t\t\t$('.croc_tab-container').animate({\r\n\t\t\t\t\t\tright: '0px'\r\n\t\t\t\t\t});\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t// Show tab content\r\n\t\t\t\t$('.croc_side-tab-content-video').hide(1000);\r\n\t\t\t\t\r\n\t\t\t\tisClicked = false;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t});\r\n\t\t\r\n\t\t// Setup close button\r\n\t\t$('.croc_btn_close').click(function(){\r\n\t\t\t// End the video call\r\n\t\t\tendVideo();\r\n\t\t});\r\n\t\t\r\n\t\t// Setup end call button\r\n\t\t$('.croc_btn_endcall_s').click(function() {\r\n\t\t\t// End the video call\r\n\t\t\tendVideo();\r\n\t\t});\r\n\t\t\r\n\t\tvar togglePauseVideo = false;\r\n\t\t\r\n\t\t// Set pause video button\r\n\t\t$('.croc_btn_pausevideo_s').click(function () {\r\n\t\t\tif (!togglePauseVideo) {\r\n\t\t\t\ttogglePauseVideo = true;\r\n\t\t\t\tpauseVideo();\r\n\t\t\t} else {\r\n\t\t\t\ttogglePauseVideo = false;\r\n\t\t\t\tresumeVideo();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tvar toggleOnMute = false;\r\n\t\t\r\n\t\t// Set mute audio button\r\n\t\t$('.croc_mute_video_audio').click(function () {\r\n\t\t\tif (!toggleOnMute) {\r\n\t\t\t\ttoggleOnMute = true;\r\n\t\t\t\tmuteAudio();\r\n\t\t\t} else {\r\n\t\t\t\ttoggleOnMute = false;\r\n\t\t\t\tunmuteAudio();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tvar toggleLocalVideo = true;\r\n\t\t\r\n\t\t// Setup click event for local video button to display/hide local video\r\n\t\t$('.croc_btn_localvideo').click(function () {\r\n\t\t\tif (toggleLocalVideo) {\r\n\t\t\t\ttoggleLocalVideo = false;\r\n\t\t\t\t$('.croc_tpl_controls').removeClass(\"croc_ui_localvideoshown\");\r\n\t\t\t} else {\r\n\t\t\t\ttoggleLocalVideo = true;\r\n\t\t\t\t$('.croc_tpl_controls').addClass(\"croc_ui_localvideoshown\");\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\t// Setup full screen button\r\n\t\t$('.croc_btn_fullscreen').click(function() {\r\n\t\t\tif (!isFullscreen) {\r\n\t\t\t\tisFullscreen = true;\r\n\t\t\t\tsetVideoToFullscreen(true);\r\n\t\t\t} else {\r\n\t\t\t\tisFullscreen = false;\r\n\t\t\t\tsetVideoToFullscreen(false);\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\t// Setup keypad popout\r\n\t\t$('.croc_ui_popout').click(function(evt){\r\n\t\t\t$('body').click(function(evt2){\r\n\t\t\t\t// Dont close if popout content is pressed\r\n\t\t\t\tvar currentTarget = $(evt.target);\r\n\t\t\t\twhile(currentTarget[0]){\r\n\t\t\t\t\tif(currentTarget[0] === evt.target[0]) {\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tcurrentTarget = currentTarget.parent();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$('body').off('click');\r\n\r\n\t\t\t\t$('.croc_ui_popout').removeClass('croc_ui_popout_open');\r\n\t\t\t\t$('.croc_tpl_titlebar').removeClass('croc_ui_shown');\r\n\t\t\t\t$('.croc_tpl_actions').removeClass('croc_ui_shown');\r\n\t\t\t});\r\n\r\n\t\t\tevt.stopPropagation();\r\n\t\t\t$('.croc_ui_popout').addClass('croc_ui_popout_open');\r\n\t\t\t$('.croc_tpl_titlebar').addClass('croc_ui_shown');\r\n\t\t\t$('.croc_tpl_actions').addClass('croc_ui_shown');\r\n\t\t});\r\n\r\n\t\t// Make sure keypad and tool bars aren't displayed\r\n\t\t$('.croc_ui_popout').removeClass('croc_ui_popout_open');\r\n\t\t$('.croc_tpl_titlebar').removeClass('croc_ui_shown');\r\n\t\t$('.croc_tpl_actions').removeClass('croc_ui_shown');\r\n\r\n\t\t// Setup keypad buttons\r\n\t\tvar keypad = $('.croc_ui_keypad');\r\n\t\tkeypad.find('.croc_tpl_key').click(function(){\r\n\t\t\tvar value = $(this).find('.croc_tpl_main').text();\r\n\t\t\tvideoSession.sendDTMF(value);\r\n\t\t});\r\n\t};\r\n\t\r\n\t// Get the HTML element to append to\r\n\tvar htmlElement = $(config.appendClick2callTo);\r\n\tvar i;\r\n\t\r\n\t// Add the HTML as a child of the element specified in the configuration if the element exists.\r\n\tif (htmlElement.length !== 0) {\r\n\t\t// For every HTML element of that kind, add video tab\r\n\t\tfor (i=0; i < htmlElement.length; i++) {\r\n\t\t\t// Check that document contains HTML element\r\n\t\t\tif ($.contains(document, htmlElement[i])) {\r\n\t\t\t\t// Add video tab\r\n\t\t\t\t$(config.appendClick2callTo).append(videoWidgetHtml);\r\n\t\t\t} else {\r\n\t\t\t\t// If the HTML element specified doesn't exist, add to HTML\r\n\t\t\t\t$('html').append(videoWidgetHtml);\r\n\t\t\t}\r\n\t\t}\r\n\t} else {\r\n\t\t// If the HTML element specified doesn't exist, add to HTML\r\n\t\t$('html').append(videoWidgetHtml);\r\n\t}\r\n\t\r\n\t// Add video widget event handlers\r\n\tsetupVideoWidgetHandlers();\r\n\t\r\n\t/*\r\n\t * Setup the position of the click to call tab; fixed or absolute\r\n\t */\r\n\tvar positionOfClick2Call = config.click2callPosition;\r\n\tmediaWidget = config.click2callMediaWidget;\r\n\t\r\n\t// Add to correct widget only if value is absolute or fixed\r\n\tif (mediaWidget === 'video' && positionOfClick2Call === 'absolute' || positionOfClick2Call === 'fixed') {\r\n\t\t// Change css position to user defined/default position\r\n\t\t$('.croc_tab-wrapper-video').css('position', config.click2callPosition);\r\n\t}\r\n\t\r\n\t/*\r\n\t * Setup the tab orientation on screen; top, right, bottom or left\r\n\t */\r\n\tswitch (orientationOfClick2Call) {\r\n\tcase 'top':\r\n\t\t$('.croc_tab-container').removeClass('croc_tab-wrapper-video');\r\n\t\t$('.croc_tab-container').addClass('croc_video-top-tab');\r\n\t\t$('.croc_side-tab').removeClass('croc_rotate-vertical');\r\n\t\t$('.croc_side-tab').addClass('croc_video-top-side-tab');\r\n\t\t$('.croc_side-tab-content-video').addClass('croc_video-top-content');\r\n\t\t$('.croc_side-tab').css('borderRadius', '0 0 10px 10px');\r\n\t\tbreak;\r\n\tcase 'bottom':\r\n\t\t$('.croc_tab-container').removeClass('croc_tab-wrapper-video');\r\n\t\t$('.croc_tab-container').addClass('croc_video-bottom-tab');\r\n\t\t$('.croc_side-tab').removeClass('croc_rotate-vertical');\r\n\t\t$('.croc_side-tab').addClass('croc_video-side-tab-bottom');\r\n\t\t$('.croc_side-tab-content-video').addClass('croc_video-bottom-content');\r\n\t\tbreak;\r\n\tcase 'left':\r\n\t\t$('.croc_tab-container').addClass('croc_video-left-tab');\r\n\t\t$('.croc_side-tab-content-video').addClass('croc_video-left-content');\r\n\t\t$('.croc_side-tab').css('borderRadius', '0 0 10px 10px');\r\n\t\tbreak;\r\n\tdefault:\r\n\t\tbreak;\r\n\t}\r\n}", "title": "" }, { "docid": "8c35aec3af91ec03dc44b4078abaa108", "score": "0.5166906", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n }", "title": "" }, { "docid": "01b40323f470866154f7543a487694ce", "score": "0.51593804", "text": "function s123VideoHandler($obj, mobile) {\n var player = $obj.data('player');\n var videoURL = $obj.data('video');\n var customStyle = $obj.find('img').attr('style') ? $obj.find('img').attr('style') : '';\n var width = $obj.find('img').width();\n var height = $obj.find('img').height();\n if (player === 'site123') {\n videoURL = '/include/globalVideoPlayer.php?cad=1&url=' + encodeURIComponent(videoURL) + '&width=' + width + '&height=' + height;\n }\n /**\n * On mobile devices we disable the videos auto load because there\n * is some mobiles devices that don't know how to handle it.\n */\n if (mobile) {\n if (player === 'site123') {\n videoURL += '&autoplay=false';\n } else {\n videoURL = videoURL.replace('autoplay', 'disable-autoplay');\n }\n }\n /**\n * Replace the video thumbnail with the video object related to its type.\n * Note: we used: `allow=\"autoplay; fullscreen\"` because the videos stop work\n * with `autoplay`, source: https://stackoverflow.com/a/50339171/469161\n */\n $obj.replaceWith('<div class=\"video-wrapper\"><iframe data-player=\"' + player + '\" style=\"' + customStyle + 'width:' + width + 'px;height:' + height + 'px;\" type=\"text/html\" src=\"' + videoURL + '\" allow=\"autoplay; fullscreen\" frameborder=\"0\" allowfullscreen></iframe></div>');\n}", "title": "" }, { "docid": "1f8162c79cbd60388ad5e2bc71c2ca0b", "score": "0.5158046", "text": "function openMediaAssetLib() {\n $rootScope.$broadcast('evt.openMediaLib', {\n tab: 'asset',\n chooseAssetCallback: __chooseAssetCallback,\n canChooseMultipleFile: false\n });\n }", "title": "" }, { "docid": "95e6e5df693a29984056b0559440aa70", "score": "0.5151863", "text": "function onPlayerReady(event) {\r\n event.target.playVideo();\r\n}", "title": "" }, { "docid": "95e6e5df693a29984056b0559440aa70", "score": "0.5151863", "text": "function onPlayerReady(event) {\r\n event.target.playVideo();\r\n}", "title": "" }, { "docid": "e08334cc0203860c83c66373fccc0a4b", "score": "0.51456594", "text": "function handleUserMedia(stream) {\n\n console.log('Adding local stream.');\n localVideo.src = window.URL.createObjectURL(stream);\n localStream = stream;\n sendMessage('got user media');\n if (isInitiator) {\n maybeStart();\n }\n}", "title": "" }, { "docid": "85e9b87327a9d3ddbadcf21e101f2f67", "score": "0.51439947", "text": "function enablestart() {\n startVideo()\n }", "title": "" }, { "docid": "193fd35250a78982fbc8ba0721756018", "score": "0.5137978", "text": "function setActivity( name, type )\r\n{\r\n if( ['watching', 'streaming', 'playing', 'listening'].includes( type.toLowerCase() ) )\r\n {\r\n client.user.setActivity( name, {type: type.toUpperCase()} )\r\n .then( presence => debug(`Set activity to ${type} ${name}.`) )\r\n .catch( error );\r\n }\r\n}", "title": "" }, { "docid": "117e16a16ab529fd5b93ac4d9004bd22", "score": "0.5136329", "text": "function onPlayerReady(event) {\n // event.target.playVideo();\n }", "title": "" }, { "docid": "bf0553642aa43101d600d37e627be36d", "score": "0.5125462", "text": "function changeView() {\n open = setInterval(function() {\n rotateView()\n }, 5000) //set this for length of video + amount of break time you want in between playing the video\n console.log('Inactivity Trigger')\n }", "title": "" }, { "docid": "8a8d230c19c18520bdf983a7ff736576", "score": "0.51233774", "text": "function onPlayerReady(event) {\n // event.target.playVideo();\n}", "title": "" }, { "docid": "7f858b25bff8d89880dc177dde1124c4", "score": "0.51171464", "text": "function handleClickMovie() {\n props.callback(movie)\n }", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "23d2262c0b5c1e6766fcadbc402087e6", "score": "0.5113211", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "a293295c3b7af66d9f64be9fba65e882", "score": "0.5106654", "text": "setupHandlers() {\n this.activityProc.messageActivityHandler = {\n onMessage: (ctx) => __awaiter(this, void 0, void 0, function* () {\n const teamsCtx = teams.TeamsContext.from(ctx);\n const text = teamsCtx.getActivityTextWithoutMentions() || '';\n switch (text.toLowerCase()) {\n case 'cards':\n yield this.sendCards(ctx);\n break;\n default:\n let count = yield this.countAccessor.get(ctx);\n count = count === undefined ? 1 : ++count;\n yield this.countAccessor.set(ctx, count);\n let activity = {\n textFormat: 'xml',\n text: `${count}: You said \"${ctx.activity.text}\"`\n };\n yield ctx.sendActivity(activity);\n yield this.conversationState.saveChanges(ctx);\n }\n })\n };\n this.activityProc.invokeActivityHandler = {\n onMessagingExtensionQuery: (ctx, query) => __awaiter(this, void 0, void 0, function* () {\n // Extract the search text from the query information\n let searchtext = '';\n if (query.parameters && query.parameters[0]) {\n if (query.parameters[0].name === 'initialRun') {\n searchtext = '';\n }\n else if (query.parameters[0].value) {\n searchtext = query.parameters[0].value;\n }\n }\n // Create an AdaptiveCard instance to send as response\n // Call handleQuery function to generate the list of preview cards\n let preview_list = api_js_1.handleQuery(searchtext);\n let response = {\n status: 200,\n body: {\n composeExtension: {\n type: 'result',\n attachmentLayout: 'list',\n attachments: preview_list\n }\n }\n };\n return Promise.resolve(response);\n }),\n onMessagingExtensionFetchTask: (ctx, query) => __awaiter(this, void 0, void 0, function* () {\n return Promise.resolve({\n status: 200,\n body: {\n task: api_js_1.taskModuleResponse(query, false)\n }\n });\n }),\n onMessagingExtensionSubmitAction: (ctx, query) => __awaiter(this, void 0, void 0, function* () {\n let body;\n let data = query.data;\n if (data && data.done) {\n let sharedMessage = (query.commandId === 'shareMessage' && query.commandContext === 'message')\n ? `Shared message: <div style=\"background:#F0F0F0\">${JSON.stringify(query.messagePayload)}</div><br/>`\n : '';\n let preview = botbuilder_1.CardFactory.thumbnailCard('Created Card', `Your input: ${data.userText}`);\n let heroCard = botbuilder_1.CardFactory.heroCard('Created Card', `${sharedMessage}Your input: <pre>${data.userText}</pre>`);\n body = {\n composeExtension: {\n type: 'result',\n attachmentLayout: 'list',\n attachments: [\n Object.assign({}, heroCard, { preview })\n ]\n }\n };\n }\n else if (query.commandId === 'createWithPreview' || query.botMessagePreviewAction) {\n if (!query.botMessagePreviewAction) {\n body = {\n composeExtension: {\n type: 'botMessagePreview',\n activityPreview: {\n attachments: [\n api_js_1.taskModuleResponseCard(query)\n ]\n }\n }\n };\n }\n else {\n let userEditActivities = query.botActivityPreview;\n let card = userEditActivities\n && userEditActivities[0]\n && userEditActivities[0].attachments\n && userEditActivities[0].attachments[0];\n if (!card) {\n body = {\n task: {\n type: 'message',\n value: 'Missing user edit card. Something wrong on Teams client.'\n }\n };\n }\n else if (query.botMessagePreviewAction === 'send') {\n body = undefined;\n yield ctx.sendActivities([\n { attachments: [card] }\n ]);\n }\n else if (query.botMessagePreviewAction === 'edit') {\n body = {\n task: {\n type: 'continue',\n value: {\n card: card\n }\n }\n };\n }\n }\n }\n else {\n body = {\n task: api_js_1.taskModuleResponse(query, false)\n };\n }\n return Promise.resolve({ status: 200, body });\n }),\n onTaskModuleFetch: (ctx, query) => __awaiter(this, void 0, void 0, function* () {\n const response = {\n status: 200,\n body: {\n task: api_js_1.taskModuleResponse(query, false)\n }\n };\n return Promise.resolve(response);\n }),\n onTaskModuleSubmit: (ctx, query) => __awaiter(this, void 0, void 0, function* () {\n const data = query.data;\n const response = {\n status: 200,\n body: {\n task: api_js_1.taskModuleResponse(query, !!data.done)\n }\n };\n return Promise.resolve(response);\n }),\n onAppBasedLinkQuery: (ctx, query) => __awaiter(this, void 0, void 0, function* () {\n let previewImg = botbuilder_1.CardFactory.images([{\n url: 'https://assets.pokemon.com/assets/cms2/img/pokedex/full/025.png'\n }]);\n let preview = botbuilder_1.CardFactory.thumbnailCard('Preview Card', `Your query URL: ${query.url}`, previewImg);\n let heroCard = botbuilder_1.CardFactory.heroCard('Preview Card', `Your query URL: <pre>${query.url}</pre>`, previewImg);\n const response = {\n status: 200,\n body: {\n composeExtension: {\n type: 'result',\n attachmentLayout: 'list',\n attachments: [\n Object.assign({}, heroCard, { preview })\n ]\n }\n }\n };\n return Promise.resolve(response);\n }),\n onInvoke: (ctx) => __awaiter(this, void 0, void 0, function* () {\n yield ctx.sendActivity({ textFormat: 'xml', text: `[General onInvoke] <pre>${JSON.stringify(ctx.activity, null, 2)}</pre>` });\n return { status: 200, body: { composeExtensions: {} } };\n })\n };\n }", "title": "" }, { "docid": "978509376e870358b75accbd341abde1", "score": "0.5077055", "text": "function scriptAPI() {\r\n\r\n\t//'\r\n\tswitch(scriptConfig.autoplayMode) {\r\n\r\n\t\tcase 0:\r\n\t\t\twatchVA.uwPlayer.playVideo();\r\n\t\t\tbreak;\r\n\r\n\t\tcase 1:\r\n\t\t\tvar autoplayFirstPlay = true;\r\n\t\t\tunsafeWindow.YoutubeautoplayPauseFirstPlay = function(newState) {\r\n\t\t\t\tif ((autoplayFirstPlay) && (newState == 1)) {\r\n\t\t\t\t\twatchVA.uwPlayer.seekTo(0, false);\r\n\t\t\t\t\twatchVA.uwPlayer.pauseVideo();\r\n\t\t\t\t\twatchVA.uwPlayer.unMute();\r\n\t\t\t\t\tautoplayFirstPlay = false;\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\twatchVA.uwPlayer.addEventListener(\"onStateChange\", \"YoutubeautoplayPauseFirstPlay\");\r\n\t\t\twatchVA.uwPlayer.mute();\r\n\t\t\twatchVA.uwPlayer.playVideo();\r\n\t\t\tbreak;\r\n\r\n\t\tcase 2:\r\n\t\t\tbreak;\r\n\r\n\t}\r\n\r\n\t// Expands the video\r\n\tif (scriptConfig.expandVideo) watchVA.expandPlayer();\r\n\r\n\t//'\r\n\tunsafeWindow.YoutuberestoreSize = function(isWide) {\r\n\t\twatchVA.resizePlayer(\"normal\", true);\r\n\t}\r\n\twatchVA.uwPlayer.addEventListener(\"SIZE_CLICKED\", \"YoutuberestoreSize\");\r\n\r\n\t//'\r\n\tfunction updateResizePlayer(evt) {\r\n\t\twatchVA.resizePlayer(null, true);\r\n\t}\r\n\twindow.addEventListener(\"resize\", updateResizePlayer, false);\r\n\r\n\t//'\r\n\tvar quicklistDiv = $(yt_QUICKLIST_ID);\r\n\tif (quicklistDiv) {\r\n\t\tquicklistDiv.addEventListener(\"DOMAttrModified\", function(evt) {\r\n\t\t\tif ((evt.attrName == \"class\") && (evt.attrChange == evt.MODIFICATION)) updateResizePlayer(evt);\r\n\t\t}, false);\r\n\t}\r\n\r\n\t//'\r\n\twatchVA.resizePlayer(scriptConfig.videoSize, !scriptConfig.scrollToVideo);\r\n\r\n\t//'\r\n\tvar mainResizeButton = $(\"Youtube-main-resize-button\");\r\n\tif (mainResizeButton) mainResizeButton.disabled = false;\r\n\r\n}", "title": "" }, { "docid": "7b8a58a01ea7fbab5e97d0156a81b787", "score": "0.50687134", "text": "function applyBroadcast () {\n \n if(deviceType ==='iOS'){\n \n var args = Array.prototype.slice.call(arguments);\n scope.$apply(function () {\n scope.$emit.apply(scope, args);\n });\n }\n else{\n window.location = \"vnd.youtube:\"+scope.videoId;\n }\n }", "title": "" }, { "docid": "ed9714bd9e3850f4ab86e7bc7e8ca361", "score": "0.50604075", "text": "function onLocalVideo(callback) {\r\n _onLocalVideoCallback = callback;\r\n }", "title": "" }, { "docid": "62d8ea31ed4ed13a5a7db6db6b623cbd", "score": "0.5060246", "text": "function onPlayerReady(event) { \n event.target.playVideo();\n console.log('playerReady')\n }", "title": "" }, { "docid": "fc0defa4d01e69b1e66fa9a52cd6c57a", "score": "0.50560075", "text": "function onPlayerReady(event) {\n\t\t\t\t\t\tevent.target.playVideo();\n\t\t\t\t\t}", "title": "" }, { "docid": "5bdcf868420e5b6d4e49cc9992781489", "score": "0.50542665", "text": "play(){\n\t\twindow[this.id].playVideo() \n\t\tfor( var i=0; i<this.listener.length; i++ )\n\t\t\tif( Konekti.client[this.listener[i]].play !== undefined )\n\t\t\t\tKonekti.client[this.listener[i]].play(this.id) \n\t}", "title": "" }, { "docid": "5d65311aa0b3244323ab988d59531de2", "score": "0.5043518", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "5d65311aa0b3244323ab988d59531de2", "score": "0.5043518", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "5d65311aa0b3244323ab988d59531de2", "score": "0.5043518", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n}", "title": "" }, { "docid": "5bf18b0661313c9ec42d9768d9597fa9", "score": "0.50421464", "text": "function notify (text)\n {\n log ('** video event: ' + text);\n }", "title": "" }, { "docid": "b866ed06697ab2cf561f3626454dbb27", "score": "0.50386214", "text": "function onPlayerStateChange(e) {\n\t//console.log(e['target']);\n\tplayerToTarget = '#'+e['target']['h']['id'];\n\tif (e.data === 1){\n\t\t$(playerToTarget).addClass('active');\n\t} else if (e.data === 0){\n\t\t//console.log('waiting');\n\t\tfor (var i = 0; i < playerInfoList.length; i++) {\n\t\t\tif (playerInfoList[i].id == e['target']['h']['id']) {\n\t\t\tvideoStart = playerInfoList[i].videoStart;\n\t\t\t//console.log(videoStart);\n\t\t\te.target.seekTo(videoStart);\n\t\t\te.target.playVideo()\n\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "2e307db1cf81ceadc481630e211997e3", "score": "0.50360155", "text": "activateActivity() {\n this.props.navigation.navigate(\"qrScanner\",\n {\n activityID: this.props.activityID,\n bucketListID: this.props.listID,\n reloadListsFunc: this.props.reloadListsFunc\n });\n }", "title": "" }, { "docid": "8d7232c2e0df85f55c5ec966067074ab", "score": "0.50356466", "text": "function onWebActivated(args) {\r\n logger.Log(\"Web Activated\");\r\n }", "title": "" }, { "docid": "ed07c178a3ce026c3b3bcb5c7e3f603f", "score": "0.50292146", "text": "function onPlayerReady(event) {\r\n console.log('onPlayerReady');\r\n //event.target.playVideo();\r\n}", "title": "" }, { "docid": "a72af69d6ed138f7457d125ec6cb414a", "score": "0.50261235", "text": "function playVideo(){\n // if the flash player is beign used\n if(playertype == 'flash'){\n\n // hack to hide the display name\n // http://docs.brightcove.com/en/video-cloud/smart-player-api/samples/update-media.html\n VP.getCurrentVideo(function(videoDTO){\n videoDTO.displayName = \"\";\n contentModule.updateMedia(videoDTO, function(newVideoDTO){\n VP.play();\n });\n });\n\n } else {\n // todo: need to test on ipad to see which events are possible \n // var win = document.getElementById('myExperience').contentWindow\n // win.postMessage({'funct' : 'play'}, \"*\");\n }\n }", "title": "" }, { "docid": "52f234712f40e0d0766953421e668037", "score": "0.5025068", "text": "function onPlayerReady(event) \r\n\t{\r\n\t\tevent.target.playVideo();\r\n\t}", "title": "" }, { "docid": "2837c5ee4e2f1db01b989bdf990812ca", "score": "0.5023827", "text": "_attachEvents() {\n this.on(\"ready\", async () => {\n await this._loadOptions(this.clientOptions);\n if (typeof this.game.name === \"function\") {\n this.user.setActivity(this.game.name(this), { url: this.game.url, type: this.game.type });\n } else {\n this.user.setActivity(this.game.name, { url: this.game.url, type: this.game.type });\n }\n console.log(`${chalk.bgBlueBright(\"INFO\")} ${this.readyMessage}`);\n });\n this.on(\"message\", message => this._handleMessage(message));\n process.on(\"unhandledRejection\", e => console.log(`${chalk.bgRedBright(\"ERROR\")}${chalk.redBright(e.stack)}`));\n }", "title": "" }, { "docid": "0c2e64a7136e9acf3974a5cc1d7bd7e4", "score": "0.502376", "text": "function startVid(){\r\n\tmodVP.loadVideo(vid_id);\r\n\tMACYS.coremetrics.cmCreatePageElementTag('ca-POC-oVerlayvideo.video', 'ca-POC-oVerlayvideo.video', 'video', '');\r\n\t\r\n}", "title": "" }, { "docid": "43bf5dab7de59b45084e7d41ab125285", "score": "0.5023584", "text": "function startVideo() {\n\n handTrack.startVideo(video).then(function (status) {\n console.log(\"video started\", status);\n if (status) {\n // optional update of text on screen to indicate the tracking has started successfully\n updateNote.innerText = \"Video started. Now tracking\"\n isVideo = true\n // runDetection defined in this script below\n runDetection()\n } else {\n // optional update of text on screen to indicate video is not enabled\n updateNote.innerText = \"Please enable video\"\n }\n });\n}", "title": "" }, { "docid": "179c0db38c5ad7996a22ea40f7634dca", "score": "0.502178", "text": "function onPlayerReady(event) {\r\n event.target.playVideo();\r\n }", "title": "" }, { "docid": "013505322ac3acfa511f2645a6b3a337", "score": "0.5020015", "text": "function runApp() {\r\n chrome.app.window.create(\r\n 'src/index.html', \r\n {\r\n 'id': 'initialBrowserWindowID',\r\n bounds: {\r\n width: window.parent.screen.width,\r\n height: window.parent.screen.height\r\n }\r\n },\r\n function(newWindow) {\r\n newWindow.contentWindow.onload = function(window){\r\n const webview = window.target.querySelector('body webview');\r\n\r\n const nagaramiButton = window.target.querySelector('#nagarami-button');\r\n nagaramiButton.text = chrome.i18n.getMessage(\"buttonLabel\");\r\n\r\n webview.addEventListener('loadcommit', function(e) {\r\n if(e.url.match(/^https:\\/\\/www.youtube.com\\/watch\\?v=/)) {\r\n nagaramiButton.style.visibility = 'visible';\r\n } else {\r\n nagaramiButton.style.visibility = 'hidden';\r\n }\r\n });\r\n\r\n nagaramiButton.onclick = function() {\r\n webview.executeScript({code: \"location.href\"},\r\n function(results) {\r\n const linkUrl = results[0];\r\n playMovie(linkUrl);\r\n })\r\n }\r\n\r\n const label = chrome.i18n.getMessage(\"menuLabel\");\r\n webview.contextMenus.create({\r\n type: 'normal',\r\n id: 'hello',\r\n contexts: [\"link\"],\r\n title: label,\r\n onclick: function(info) {\r\n playMovie(info.linkUrl);\r\n }\r\n });\r\n }\r\n }\r\n );\r\n}", "title": "" }, { "docid": "0332034f5eff76ac582846d3badae284", "score": "0.5019934", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n event.target.mute();\n}", "title": "" }, { "docid": "8473765723778555fc627e27b971b256", "score": "0.5014552", "text": "function receiveMessage(event) {\n if (event.data) {\n var activity = JSON.parse(event.data);\n startActivity(activity);\n }\n }", "title": "" }, { "docid": "b674431ff7fcaf2e54e41d62a3e58e73", "score": "0.50084996", "text": "function onRemoteVideo(callback) {\r\n _onRemoteVideoCallback = callback;\r\n }", "title": "" }, { "docid": "2ea79d44d35cf3f350c7866215f95253", "score": "0.5007387", "text": "function onContactClicked (id) {\n if (APP.conference.isLocalId(id)) {\n $(\"#localVideoContainer\").click();\n return;\n }\n\n let remoteVideo = remoteVideos[id];\n if (remoteVideo && remoteVideo.hasVideo()) {\n // It is not always the case that a videoThumb exists (if there is\n // no actual video).\n if (remoteVideo.hasVideoStarted()) {\n // We have a video src, great! Let's update the large video\n // now.\n VideoLayout.handleVideoThumbClicked(id);\n } else {\n\n // If we don't have a video src for jid, there's absolutely\n // no point in calling handleVideoThumbClicked; Quite\n // simply, it won't work because it needs an src to attach\n // to the large video.\n //\n // Instead, we trigger the pinned endpoint changed event to\n // let the bridge adjust its lastN set for myjid and store\n // the pinned user in the lastNPickupId variable to be\n // picked up later by the lastN changed event handler.\n eventEmitter.emit(UIEvents.PINNED_ENDPOINT, remoteVideo, true);\n }\n }\n}", "title": "" }, { "docid": "6008189f49bf15cdbad37da23bfb1ce3", "score": "0.5005966", "text": "function scriptAPI() {\r\n\r\n\t//'\r\n\tswitch(scriptConfig.autoplayMode) {\r\n\r\n\t\tcase 0:\r\n\t\t\twatchVA.uwPlayer.playVideo();\r\n\t\t\tbreak;\r\n\r\n\t\tcase 1:\r\n\t\t\tvar autoplayFirstPlay = true;\r\n\t\t\tunsafeWindow.ytfautoplayPauseFirstPlay = function(newState) {\r\n\t\t\t\tif ((autoplayFirstPlay) && (newState == 1)) {\r\n\t\t\t\t\twatchVA.uwPlayer.seekTo(0, false);\r\n\t\t\t\t\twatchVA.uwPlayer.pauseVideo();\r\n\t\t\t\t\twatchVA.uwPlayer.unMute();\r\n\t\t\t\t\tautoplayFirstPlay = false;\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\twatchVA.uwPlayer.addEventListener(\"onStateChange\", \"ytfautoplayPauseFirstPlay\");\r\n\t\t\twatchVA.uwPlayer.mute();\r\n\t\t\twatchVA.uwPlayer.playVideo();\r\n\t\t\tbreak;\r\n\r\n\t\tcase 2:\r\n\t\t\tbreak;\r\n\r\n\t}\r\n\r\n\t// Expands the video\r\n\tif (scriptConfig.expandVideo) watchVA.expandPlayer();\r\n\r\n\t//'\r\n\tunsafeWindow.ytfrestoreSize = function(isWide) {\r\n\t\twatchVA.resizePlayer(\"default\", true);\r\n\t}\r\n\twatchVA.uwPlayer.addEventListener(\"SIZE_CLICKED\", \"ytfrestoreSize\");\r\n\r\n\t//'\r\n\tfunction updateResizePlayer(evt) {\r\n\t\twatchVA.resizePlayer(null, true);\r\n\t}\r\n\twindow.addEventListener(\"resize\", updateResizePlayer, false);\r\n\r\n\t//'\r\n\tvar quicklistDiv = $(YT_QUICKLIST_ID);\r\n\tif (quicklistDiv) {\r\n\t\tquicklistDiv.addEventListener(\"DOMAttrModified\", function(evt) {\r\n\t\t\tif ((evt.attrName == \"class\") && (evt.attrChange == evt.MODIFICATION)) updateResizePlayer(evt);\r\n\t\t}, false);\r\n\t}\r\n\r\n\t//'\r\n\twatchVA.resizePlayer(scriptConfig.videoSize, !scriptConfig.scrollToVideo);\r\n\r\n\t//'\r\n\tvar mainResizeButton = $(\"ytf-main-resize-button\");\r\n\tif (mainResizeButton) mainResizeButton.disabled = false;\r\n\r\n}", "title": "" }, { "docid": "c320006daf6fb24723179becde976cbd", "score": "0.50009924", "text": "function onPlayerReady(event) {\n\tevent.target.playVideo();\n\n}", "title": "" }, { "docid": "2d5977675a8419350b8f5027901cf6db", "score": "0.49996567", "text": "function runPlayer(url) {\n var context = new Dash.di.DashContext();\n player = new MediaPlayer(context);\n player.startup();\n player.attachView(document.querySelector(\"#videoTag\"));\n player.attachSource(url);\n}", "title": "" }, { "docid": "963beb233de1e2299ffa965824851813", "score": "0.4989224", "text": "function streamVideo(port, node, action) {\n $(node).attr(\"src\", \"//coolfore.com:\"+port+\"/?action=\"+action);\n}", "title": "" }, { "docid": "b0f9df1b44e5afc6887f3bfce0fbf1f6", "score": "0.4988725", "text": "static handlePlayButton() {\r\n\t\t\r\n\t}", "title": "" }, { "docid": "882bb9424b804206c0f648f6b726ef7d", "score": "0.49886084", "text": "function switchToLive(){\n\tsequenceStopped = false;\n\tcurrentSequence = 'live';\n\t/* Stream de live dans le container video*/\n\tcontainerVideo.src = URL.createObjectURL(mainStream);\n\t/* creation du stream d'enregistrement */\n\tcreateSimpleOutputStream();\n\t/* Creation du buffer du stream d'enregistrement */\n\tcreateRecorder();\n\t/* Demarrage de l'enregistrement*/\n\tstartRecorder();\n}", "title": "" }, { "docid": "9c2f8195aa3cb3a1c91e700fbd89f702", "score": "0.49877524", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n }", "title": "" }, { "docid": "9c2f8195aa3cb3a1c91e700fbd89f702", "score": "0.49877524", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n }", "title": "" }, { "docid": "9c2f8195aa3cb3a1c91e700fbd89f702", "score": "0.49877524", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n }", "title": "" }, { "docid": "9c2f8195aa3cb3a1c91e700fbd89f702", "score": "0.49877524", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n }", "title": "" }, { "docid": "9c2f8195aa3cb3a1c91e700fbd89f702", "score": "0.49877524", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n }", "title": "" }, { "docid": "2c6544b404cd1c31539f9a81d2f94fb5", "score": "0.4987734", "text": "async function setActivity() {\n if (config.includeTime == \"t\") {\n rpc.setActivity({\n details: config.topline,\n state: config.bottomline,\n startTimestamp,\n instance: false,\n });\n } else\n\n rpc.setActivity({\n details: config.topline,\n state: config.bottomline,\n instance: false,\n });\n}", "title": "" }, { "docid": "0a59119f8c32b9e7ac85672f347c6b8e", "score": "0.49783862", "text": "function openBehaviorViewer(e)\t{\n\t\tchrome.tabs.create({\n\t\t\turl: server + \"/index.html?userid=\" + user_id\n\t\t});\n\t}", "title": "" }, { "docid": "19ac5f575e2787e79cd216f5c311de2a", "score": "0.49749434", "text": "doSnapshotActivity(frameIdxOverride) {\n let passiveAction = {\n selectedFrameIdx: frameIdxOverride ? frameIdxOverride : this.state.selectedFrameIdx,\n }\n snapshotActivity(this.props.asset, passiveAction)\n }", "title": "" }, { "docid": "38aef8ccc90d0f099ce2c8d1fd987ced", "score": "0.49745628", "text": "function listenForPreviewClicks () {\n\n $('.video-list').click( event => {\n\n if (event.target.target !== '_blank') {\n event.preventDefault();\n\n // get a tag info\n var anchorClicked = $(event.target).closest('a');\n\n // call video api\n callYouTubeVideoAPI(anchorClicked[0].attributes.videoID.value, updateMainVideoFromAnchorClick);\n\n $('.social-media-feed').animate({\n scrollTop: 0\n }, 'slow');\n\n }\n\n });\n\n}", "title": "" }, { "docid": "8ff8febe4b656a2c986472ce3d98283e", "score": "0.49720758", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n event.target.mute();\n }", "title": "" }, { "docid": "11a8b971452e30b0f91a70067bfb94f8", "score": "0.49704942", "text": "function onPlayerReady(event) {\n \tconsole.log(\"onPlayerReady\");\n event.target.playVideo();\n }", "title": "" }, { "docid": "8ccadee23132f63db08c3aaa47ad98f3", "score": "0.49704725", "text": "function addVideoListeners() {\n $('.video-item').on('click', function () {\n let videoId = $(this).data('id');\n playVideo(videoId);\n });\n }", "title": "" }, { "docid": "03cfd59d25e607397b3f88f4fc06ff9b", "score": "0.4958853", "text": "function onPlayerReady(event) {\n event.target.playVideo();\n }", "title": "" } ]
cb417979b2964e6b8e1f20caaaa67fee
Retrieves all root components associated with a DOM element, directive or component instance. Root components are those which have been bootstrapped by Angular.
[ { "docid": "53906782da8eb85d5754f0a2324ffe4d", "score": "0.7008895", "text": "function getRootComponents(elementOrDir) {\n return [...getRootContext(elementOrDir).components];\n}", "title": "" } ]
[ { "docid": "3c5a8064273b687d8d227f6e8e4cbf5b", "score": "0.70974386", "text": "static getRootComponents() {\n var topLevelDomNodes = null;\n var rootNodes = [];\n try {\n var app = $A.getRoot();\n rootNodes.push({\n id: app.getGlobalId(),\n components: [this.getComponent(app.getGlobalId())]\n });\n\n if (app.isInstanceOf('ltng:outApp')) {\n topLevelDomNodes = document.querySelectorAll('[data-ltngout-rendered-by]');\n\n var map = {};\n var parentNodes = [];\n\n topLevelDomNodes.forEach(node => {\n const id = node.getAttribute('data-ltngout-rendered-by');\n const component = $A.getComponent(id);\n\n rootNodes.push({\n dom: node,\n id: 'data-ltngout-rendered-by$' + id,\n components: [this.getComponent(id, { body: false })]\n });\n });\n }\n } catch (e) {}\n\n return JsonSerializer.stringify(rootNodes);\n }", "title": "" }, { "docid": "ca7ab1f570fed9a2bc1bd520fa1e57a7", "score": "0.62854934", "text": "function getComponents() {\n\t\tvar deffered = $q.defer();\n\t\t$http.get('/api/components')\n\t\t\t.success(function(response) {\n\t\t\t\tdeffered.resolve(response);\n\t\t\t});\n\t\treturn deffered.promise;\n\t}", "title": "" }, { "docid": "5acf80ca9ec83d10206ce5d86f92308f", "score": "0.61815643", "text": "function getComponentElements(element) {\n var root = $(element),\n elements = root.find(COMPONENT_SELECTOR).add(root.filter(COMPONENT_SELECTOR));\n\n return elements;\n }", "title": "" }, { "docid": "6f26139acb9a2a1f662fa8f6dff16c4e", "score": "0.6148023", "text": "function getRootComponents(target) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__spread\"])(getRootContext$1(target).components);\n}", "title": "" }, { "docid": "6f26139acb9a2a1f662fa8f6dff16c4e", "score": "0.6148023", "text": "function getRootComponents(target) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__spread\"])(getRootContext$1(target).components);\n}", "title": "" }, { "docid": "285495ac3a9478b0fd487053876526e5", "score": "0.5942242", "text": "static get components() {\n return Array.from(ComponentRegistration._components.values());\n }", "title": "" }, { "docid": "403b2e9293a22e7dae887a1efd670cf1", "score": "0.5886331", "text": "function findComponents(node) {\n let childrenArray;\n if (rootNodes.includes(node)) {\n// console.log('findcomponentsroot');\n// fix for apps that have a root with vue$3 instead of __vue__\n if (components.includes(rootNodes[0].__vue__)) \n components.unshift(rootNodes[0].__vue__); \n childrenArray = node.__vue__.$children;\n }\n else {\n// console.log('findcomponentschild');\n childrenArray = node.$children;\n }\n childrenArray.forEach((child) => {\n components.push(child);\n if(child.$children.length > 0) findComponents(child)\n });\n }", "title": "" }, { "docid": "ae449ef9d80dd2296b1c86ed7fee4746", "score": "0.57349426", "text": "get components() {\n return this._providers;\n }", "title": "" }, { "docid": "0ef77bf73202cbf10a950cadc9356baf", "score": "0.5665301", "text": "getAllRootElements() {\n return Array.from(this._applications.keys());\n }", "title": "" }, { "docid": "0ef77bf73202cbf10a950cadc9356baf", "score": "0.5665301", "text": "getAllRootElements() {\n return Array.from(this._applications.keys());\n }", "title": "" }, { "docid": "0ef77bf73202cbf10a950cadc9356baf", "score": "0.5665301", "text": "getAllRootElements() {\n return Array.from(this._applications.keys());\n }", "title": "" }, { "docid": "0ef77bf73202cbf10a950cadc9356baf", "score": "0.5665301", "text": "getAllRootElements() {\n return Array.from(this._applications.keys());\n }", "title": "" }, { "docid": "0ba7fb31ec01e9e0412f9e1428bbf638", "score": "0.5562686", "text": "static getRootClass() {\n return '.component';\n }", "title": "" }, { "docid": "c1d4f4fa8382967fd5ca6339b6d247f5", "score": "0.549911", "text": "function getComponents(obj){\r\n\t\t//console.log(obj);\r\n\t\tvar tags = null;\r\n\t\tif(typeof obj.querySelectorAll !== 'undefined'){\r\n\t\t\ttags = obj.querySelectorAll(\"component\");\r\n\t\t}else if(typeof obj.getElementsByTagName !== 'undefined'){\r\n\t\t\ttags = obj.getElementsByTagName(\"component\");\r\n\t\t}\r\n\t\t//console.log(tags);\r\n\t\treturn tags;\r\n\t}", "title": "" }, { "docid": "4efcc4d617b896800cdb88a541e6eda8", "score": "0.54965544", "text": "static get components() {\n return this._components;\n }", "title": "" }, { "docid": "03cecdafbeb4e6c2e980b188bc5de545", "score": "0.5490399", "text": "findNamespaceRoot(component) {\n const path = getArrayFromComponentPath(component.path);\n // First get the component with nested parents.\n let comp = this.webform.getComponent(path);\n comp = Array.isArray(comp) ? comp[0] : comp;\n const namespaceKey = this.recurseNamespace(comp);\n\n // If there is no key, it is the root form.\n if (!namespaceKey || this.form.key === namespaceKey) {\n return this.form.components;\n }\n\n const componentSchema = component.component;\n // If the current component is the namespace, we don't need to find it again.\n if (namespaceKey === component.key) {\n return [...componentSchema.components, componentSchema];\n }\n\n // Get the namespace component so we have the original object.\n const namespaceComponent = getComponent(this.form.components, namespaceKey, true);\n return namespaceComponent ? namespaceComponent.components : comp.components;\n }", "title": "" }, { "docid": "1dd726b09ef767a2f0407408c477788f", "score": "0.54675436", "text": "function getRootView(component) {\n ngDevMode && assertDefined(component, 'component');\n var lElementNode = _getComponentHostLElementNode(component);\n var lViewData = lElementNode.view;\n while (lViewData[PARENT]) {\n lViewData = lViewData[PARENT];\n }\n return lViewData;\n}", "title": "" }, { "docid": "1dd726b09ef767a2f0407408c477788f", "score": "0.54675436", "text": "function getRootView(component) {\n ngDevMode && assertDefined(component, 'component');\n var lElementNode = _getComponentHostLElementNode(component);\n var lViewData = lElementNode.view;\n while (lViewData[PARENT]) {\n lViewData = lViewData[PARENT];\n }\n return lViewData;\n}", "title": "" }, { "docid": "1dd726b09ef767a2f0407408c477788f", "score": "0.54675436", "text": "function getRootView(component) {\n ngDevMode && assertDefined(component, 'component');\n var lElementNode = _getComponentHostLElementNode(component);\n var lViewData = lElementNode.view;\n while (lViewData[PARENT]) {\n lViewData = lViewData[PARENT];\n }\n return lViewData;\n}", "title": "" }, { "docid": "1dd726b09ef767a2f0407408c477788f", "score": "0.54675436", "text": "function getRootView(component) {\n ngDevMode && assertDefined(component, 'component');\n var lElementNode = _getComponentHostLElementNode(component);\n var lViewData = lElementNode.view;\n while (lViewData[PARENT]) {\n lViewData = lViewData[PARENT];\n }\n return lViewData;\n}", "title": "" }, { "docid": "1dd726b09ef767a2f0407408c477788f", "score": "0.54675436", "text": "function getRootView(component) {\n ngDevMode && assertDefined(component, 'component');\n var lElementNode = _getComponentHostLElementNode(component);\n var lViewData = lElementNode.view;\n while (lViewData[PARENT]) {\n lViewData = lViewData[PARENT];\n }\n return lViewData;\n}", "title": "" }, { "docid": "26d12a466cf207b6211ccc71aaffd735", "score": "0.5394914", "text": "function getRootComponentPromise(){\n\t\t\t// Make sure that the loading of the root component starts\n\t\t\tvar oViews = oNavigationControllerProxy.oRouter.getViews();\n\t\t\toViews.getView({\n\t\t\t\tviewName: \"root\"\t\n\t\t\t});\n\t\t\treturn oTemplateContract.mRouteToTemplateComponentPromise.root;\n\t\t}", "title": "" }, { "docid": "db2e1fa316b9b7bbecdf0a1db70a2788", "score": "0.5324856", "text": "function getComponentInputs($injector, name) {\n\t var cmpDefs = $injector.get(name + \"Directive\"); // could be multiple\n\t if (!cmpDefs || !cmpDefs.length)\n\t throw new Error(\"Unable to find component named '\" + name + \"'\");\n\t return cmpDefs.map(getBindings).reduce(common_1.unnestR, []);\n\t}", "title": "" }, { "docid": "92c1c079eee9523f0aed5444ce292e3e", "score": "0.5316713", "text": "function init(element) {\n var elements = [element],\n appElement,\n moduleName,\n names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],\n NG_APP_CLASS_REGEXP = /\\sng[:\\-]app(:\\s*([\\w\\d_]+);?)?\\s/;\n\n function append(elm) {\n return (elm && elements.push(elm));\n }\n\n angular.forEach(names, function(name) {\n names[name] = true;\n append(document.getElementById(name));\n name = name.replace(':', '\\\\:');\n if(element[0].querySelectorAll) {\n angular.forEach(element[0].querySelectorAll('.' + name), append);\n angular.forEach(element[0].querySelectorAll('.' + name + '\\\\:'), append);\n angular.forEach(element[0].querySelectorAll('[' + name + ']'), append);\n }\n });\n\n //TODO: search the script tags for angular.bootstrap\n angular.forEach(elements, function(elm) {\n if(!appElement) {\n var className = ' ' + element.className + ' ';\n var match = NG_APP_CLASS_REGEXP.exec(className);\n if(match) {\n appElement = elm;\n moduleName = (match[2] || '').replace(/\\s+/g, ',');\n } else {\n angular.forEach(elm.attributes, function(attr) {\n if(!appElement && names[attr.name]) {\n appElement = elm;\n moduleName = attr.value;\n }\n });\n }\n }\n });\n\n if(appElement) {\n (function addReg(moduleName) {\n if(regModules.indexOf(moduleName) === -1) {\n // register existing modules\n regModules.push(moduleName);\n var mainModule = angular.module(moduleName);\n\n // register existing components (directives, services, ...)\n invokeQueue(null, mainModule._invokeQueue, moduleName);\n invokeQueue(null, mainModule._configBlocks, moduleName); // angular 1.3+\n\n angular.forEach(mainModule.requires, addReg);\n }\n })(moduleName);\n }\n }", "title": "" }, { "docid": "80c584d9afd4034f0b20b8a3e20325eb", "score": "0.5293866", "text": "function init(element) {\n\t\tvar elements = [element],\n\t\t\tappElement,\n\t\t\tmoduleName,\n\t\t\tnames = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],\n\t\t\tNG_APP_CLASS_REGEXP = /\\sng[:\\-]app(:\\s*([\\w\\d_]+);?)?\\s/;\n\n\t\tfunction append(elm) {\n\t\t\treturn (elm && elements.push(elm));\n\t\t}\n\n\t\tangular.forEach(names, function(name) {\n\t\t\tnames[name] = true;\n\t\t\tappend(document.getElementById(name));\n\t\t\tname = name.replace(':', '\\\\:');\n\t\t\tif(element.querySelectorAll) {\n\t\t\t\tangular.forEach(element.querySelectorAll('.' + name), append);\n\t\t\t\tangular.forEach(element.querySelectorAll('.' + name + '\\\\:'), append);\n\t\t\t\tangular.forEach(element.querySelectorAll('[' + name + ']'), append);\n\t\t\t}\n\t\t});\n\n\t\t//TODO: search the script tags for angular.bootstrap\n\t\tangular.forEach(elements, function(elm) {\n\t\t\tif(!appElement) {\n\t\t\t\tvar className = ' ' + element.className + ' ';\n\t\t\t\tvar match = NG_APP_CLASS_REGEXP.exec(className);\n\t\t\t\tif(match) {\n\t\t\t\t\tappElement = elm;\n\t\t\t\t\tmoduleName = (match[2] || '').replace(/\\s+/g, ',');\n\t\t\t\t} else {\n\t\t\t\t\tangular.forEach(elm.attributes, function(attr) {\n\t\t\t\t\t\tif(!appElement && names[attr.name]) {\n\t\t\t\t\t\t\tappElement = elm;\n\t\t\t\t\t\t\tmoduleName = attr.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tif(appElement) {\n\t\t\t(function addReg(moduleName) {\n\t\t\t\tif(regModules.indexOf(moduleName) === -1) {\n\t\t\t\t\t// register existing modules\n\t\t\t\t\tregModules.push(moduleName);\n\t\t\t\t\tvar mainModule = angular.module(moduleName);\n\n\t\t\t\t\t// register existing components (directives, services, ...)\n\t\t\t\t\tinvokeQueue(null, mainModule._invokeQueue, moduleName);\n\t\t\t\t\tinvokeQueue(null, mainModule._configBlocks, moduleName); // angular 1.3+\n\n\t\t\t\t\tangular.forEach(mainModule.requires, addReg);\n\t\t\t\t}\n\t\t\t})(moduleName);\n\t\t}\n\t}", "title": "" }, { "docid": "ae151e603de88199aee240d92ae8540f", "score": "0.5290039", "text": "function findRoots() {\n for (let i = 0; i < keysArray.length; i += 1) {\n const testNode = domNodes[0].children[keysArray[i]];\n if (!rootNodes.includes(testNode) && testNode.__vue__) rootNodes.push(testNode);\n }\n return rootNodes;\n }", "title": "" }, { "docid": "cbf40ac0536cfbe47270121336394612", "score": "0.52898806", "text": "getComponents() {\n return this.components;\n }", "title": "" }, { "docid": "4a2526471535e62aeddc5cefd15cd340", "score": "0.5289257", "text": "function mountDollarSliceComponents() {\n // search page for components, and instantiate their controllers\n DS.service('components', ['$document', '$module', function ($document, $module) {\n var controllers = _pickBy($module.definitions, function (definition) {\n return definition.providerStrategy === $module.providers.controller;\n }),\n list = Object.keys(controllers); // for each component on the page, loop through the instances and kickoff the controller\n\n\n _each(list, function (name) {\n var components = $document.querySelectorAll('[data-uri*=\"/_components/' + name + '/\"]'),\n // matches data-uri=\"<site prefix>/_components/<name>/instances/<id>\"\n defaultComponents = $document.querySelectorAll('[data-uri$=\"/_components/' + name + '\"]'); // matches data-uri=\"<site prefix>/_components/<name>\"\n\n _each(components, initController(name));\n\n _each(defaultComponents, initController(name));\n }); // expose list of components on the page\n\n\n this.components = list;\n\n function initController(name) {\n return function (component) {\n try {\n $module.get(name, component);\n } catch (error) {\n logMountError(component, error);\n }\n };\n }\n }]); // other components might want to interact with our service, but we'll start it here.\n\n DS.get('components');\n}", "title": "" }, { "docid": "ffbf6854fe8906c82f0ae8923a75716a", "score": "0.526916", "text": "static forRoot(components) {\n return {\n ngModule: AgGridModule,\n providers: [\n { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: components, multi: true }\n ],\n };\n }", "title": "" }, { "docid": "e6e13dba947f5f674ab0a5c13468635f", "score": "0.5245565", "text": "get components() {\n return Array.from(this.#descriptor.components.keys());\n }", "title": "" }, { "docid": "cc56c6e583eec1af110a81c8961a811b", "score": "0.51401246", "text": "static processAll() {\n for (const component of ReactComponents.recursiveComponents()) {\n ReactComponents.push(component.constructor);\n }\n }", "title": "" }, { "docid": "2976b30213e0b7a8953fa38ea581f0a9", "score": "0.5128568", "text": "initializeComponent(element) {\n const childInjector = Injector.create({ providers: [], parent: this.injector });\n const projectableNodes = extractProjectableNodes(element, this.componentFactory.ngContentSelectors);\n this.componentRef = this.componentFactory.create(childInjector, projectableNodes, element);\n this.viewChangeDetectorRef = this.componentRef.injector.get(ChangeDetectorRef);\n this.implementsOnChanges = isFunction(this.componentRef.instance.ngOnChanges);\n this.initializeInputs();\n this.initializeOutputs(this.componentRef);\n this.detectChanges();\n const applicationRef = this.injector.get(ApplicationRef);\n applicationRef.attachView(this.componentRef.hostView);\n }", "title": "" }, { "docid": "90eebb89c378e73b2ead86522179df88", "score": "0.51249635", "text": "hydrate() {\n document.querySelectorAll(this.settings.querySelector).forEach((element) => {\n let kind = element.getAttribute(this.settings.componentKind);\n let component = this.componentMap.resolveComponent(kind);\n\n this.attachToComponent(component, element);\n });\n }", "title": "" }, { "docid": "acc28b2907ac198c847fa3560ba87127", "score": "0.51151264", "text": "function getRootView$1(componentOrView) {\n var lView;\n if (Array.isArray(componentOrView)) {\n ngDevMode && assertDefined(componentOrView, 'lView');\n lView = componentOrView;\n }\n else {\n ngDevMode && assertDefined(componentOrView, 'component');\n lView = readPatchedLView(componentOrView);\n }\n while (lView && !(lView[FLAGS] & 128 /* IsRoot */)) {\n lView = lView[PARENT];\n }\n return lView;\n}", "title": "" }, { "docid": "acc28b2907ac198c847fa3560ba87127", "score": "0.51151264", "text": "function getRootView$1(componentOrView) {\n var lView;\n if (Array.isArray(componentOrView)) {\n ngDevMode && assertDefined(componentOrView, 'lView');\n lView = componentOrView;\n }\n else {\n ngDevMode && assertDefined(componentOrView, 'component');\n lView = readPatchedLView(componentOrView);\n }\n while (lView && !(lView[FLAGS] & 128 /* IsRoot */)) {\n lView = lView[PARENT];\n }\n return lView;\n}", "title": "" }, { "docid": "a9e7f2bfe56a1e6a5c98ea1bc4ad7285", "score": "0.508256", "text": "function getViewComponent(element) {\n var context = loadLContext(element);\n var lView = context.lView;\n while (lView[PARENT] && lView[HOST] === null) {\n // As long as lView[HOST] is null we know we are part of sub-template such as `*ngIf`\n lView = lView[PARENT];\n }\n return lView[FLAGS] & 128 /* IsRoot */ ? null : lView[CONTEXT];\n}", "title": "" }, { "docid": "a9e7f2bfe56a1e6a5c98ea1bc4ad7285", "score": "0.508256", "text": "function getViewComponent(element) {\n var context = loadLContext(element);\n var lView = context.lView;\n while (lView[PARENT] && lView[HOST] === null) {\n // As long as lView[HOST] is null we know we are part of sub-template such as `*ngIf`\n lView = lView[PARENT];\n }\n return lView[FLAGS] & 128 /* IsRoot */ ? null : lView[CONTEXT];\n}", "title": "" }, { "docid": "8f6f6d97fc193aba2cdc58d1601502d7", "score": "0.5071733", "text": "static dettachFromDOM() {\n this._components = this._components.filter((component)=>{\n\n let test = window.document.contains(component.el);\n\n if (!test) {\n if (/* component.hasOwnProperty('destroy') && */ typeof component.destroy === 'function') {\n component.destroy();\n }\n if (component.id) {\n this._componentsIds[id] = null;\n delete this._componentsIds[id];\n }\n }\n\n return test;\n \n });\n \n }", "title": "" }, { "docid": "4e66a0a110d856f97c5f7d15866c9b6d", "score": "0.5071702", "text": "[_getParents](element) {\n const parents = [];\n let current = element;\n // Stop to body.\n while (current && current !== document.body) {\n // Skip shadow roots.\n if (current.nodeType === Node.ELEMENT_NODE) {\n parents.push(current);\n }\n // ShadowDom v1\n if (current.assignedSlot) {\n // Collect slots from deepest slot to top.\n while (current = current.assignedSlot) {\n parents.push(current);\n }\n // Continue the search on the top slot.\n current = parents.pop();\n continue;\n }\n current = current.parentNode ||\n current.host;\n }\n return parents;\n }", "title": "" }, { "docid": "c290dc3b789738e732bed2a9f6582d9c", "score": "0.50671905", "text": "get allElements() {\n return this.root.querySelectorAll(this.selector);\n }", "title": "" }, { "docid": "e476ba0f4ae21aec7c67b870f7abb3d7", "score": "0.5054544", "text": "function render() {\n for (const [root, component] of roots) {\n let dataDom = component();\n root.innerHTML = dataDom; // render\n }\n }", "title": "" }, { "docid": "74c1d97c8bca4b99d5a0b27142f9aa66", "score": "0.5034825", "text": "[_getParents](element) {\n const parents = [];\n let current = element;\n // Stop to body.\n while (current && current !== document.body) {\n // Skip shadow roots.\n if (current.nodeType === Node.ELEMENT_NODE) {\n parents.push(current);\n }\n // ShadowDom v1\n if (current.assignedSlot) {\n // Collect slots from deepest slot to top.\n while (current = current.assignedSlot) {\n parents.push(current);\n }\n // Continue the search on the top slot.\n current = parents.pop();\n continue;\n }\n current = current.parentNode ||\n current.host;\n }\n return parents;\n }", "title": "" }, { "docid": "69748ceb205383b91a580687e38c52df", "score": "0.50218916", "text": "createDomElements() {\n const appRoot = this.createElem('div', ['app', 'js-app']);\n\n const form = this.createElem('form', ['search-form', 'js-search-form']);\n\n const inputMarkup = this.createElem('input', ['search-form__input']);\n\n inputMarkup.type = 'text';\n inputMarkup.name = 'query';\n inputMarkup.autocomplete = 'off';\n inputMarkup.placeholder = 'Search images...';\n\n form.append(inputMarkup);\n\n const list = this.createElem('ul', ['card-list', 'js-card-list']);\n\n const spin = this.createSpinnerElement();\n\n appRoot.append(form, list, spin);\n\n return appRoot;\n }", "title": "" }, { "docid": "d3a71542560960b741f15cba4cf09958", "score": "0.49719238", "text": "function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {\n const tView = rootLView[TVIEW];\n // Create directive instance with factory() and store at next index in viewData\n const component = instantiateRootComponent(tView, rootLView, componentDef);\n rootContext.components.push(component);\n componentView[CONTEXT] = component;\n hostFeatures && hostFeatures.forEach((feature) => feature(component, componentDef));\n // We want to generate an empty QueryList for root content queries for backwards\n // compatibility with ViewEngine.\n if (componentDef.contentQueries) {\n const tNode = getCurrentTNode();\n ngDevMode && assertDefined(tNode, 'TNode expected');\n componentDef.contentQueries(1 /* Create */, component, tNode.directiveStart);\n }\n const rootTNode = getCurrentTNode();\n ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');\n if (tView.firstCreatePass &&\n (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {\n setSelectedIndex(rootTNode.index);\n const rootTView = rootLView[TVIEW];\n registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);\n invokeHostBindingsInCreationMode(componentDef, component);\n }\n return component;\n}", "title": "" }, { "docid": "d3a71542560960b741f15cba4cf09958", "score": "0.49719238", "text": "function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {\n const tView = rootLView[TVIEW];\n // Create directive instance with factory() and store at next index in viewData\n const component = instantiateRootComponent(tView, rootLView, componentDef);\n rootContext.components.push(component);\n componentView[CONTEXT] = component;\n hostFeatures && hostFeatures.forEach((feature) => feature(component, componentDef));\n // We want to generate an empty QueryList for root content queries for backwards\n // compatibility with ViewEngine.\n if (componentDef.contentQueries) {\n const tNode = getCurrentTNode();\n ngDevMode && assertDefined(tNode, 'TNode expected');\n componentDef.contentQueries(1 /* Create */, component, tNode.directiveStart);\n }\n const rootTNode = getCurrentTNode();\n ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');\n if (tView.firstCreatePass &&\n (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {\n setSelectedIndex(rootTNode.index);\n const rootTView = rootLView[TVIEW];\n registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);\n invokeHostBindingsInCreationMode(componentDef, component);\n }\n return component;\n}", "title": "" }, { "docid": "d3a71542560960b741f15cba4cf09958", "score": "0.49719238", "text": "function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {\n const tView = rootLView[TVIEW];\n // Create directive instance with factory() and store at next index in viewData\n const component = instantiateRootComponent(tView, rootLView, componentDef);\n rootContext.components.push(component);\n componentView[CONTEXT] = component;\n hostFeatures && hostFeatures.forEach((feature) => feature(component, componentDef));\n // We want to generate an empty QueryList for root content queries for backwards\n // compatibility with ViewEngine.\n if (componentDef.contentQueries) {\n const tNode = getCurrentTNode();\n ngDevMode && assertDefined(tNode, 'TNode expected');\n componentDef.contentQueries(1 /* Create */, component, tNode.directiveStart);\n }\n const rootTNode = getCurrentTNode();\n ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');\n if (tView.firstCreatePass &&\n (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {\n setSelectedIndex(rootTNode.index);\n const rootTView = rootLView[TVIEW];\n registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);\n invokeHostBindingsInCreationMode(componentDef, component);\n }\n return component;\n}", "title": "" }, { "docid": "d3a71542560960b741f15cba4cf09958", "score": "0.49719238", "text": "function createRootComponent(componentView, componentDef, rootLView, rootContext, hostFeatures) {\n const tView = rootLView[TVIEW];\n // Create directive instance with factory() and store at next index in viewData\n const component = instantiateRootComponent(tView, rootLView, componentDef);\n rootContext.components.push(component);\n componentView[CONTEXT] = component;\n hostFeatures && hostFeatures.forEach((feature) => feature(component, componentDef));\n // We want to generate an empty QueryList for root content queries for backwards\n // compatibility with ViewEngine.\n if (componentDef.contentQueries) {\n const tNode = getCurrentTNode();\n ngDevMode && assertDefined(tNode, 'TNode expected');\n componentDef.contentQueries(1 /* Create */, component, tNode.directiveStart);\n }\n const rootTNode = getCurrentTNode();\n ngDevMode && assertDefined(rootTNode, 'tNode should have been already created');\n if (tView.firstCreatePass &&\n (componentDef.hostBindings !== null || componentDef.hostAttrs !== null)) {\n setSelectedIndex(rootTNode.index);\n const rootTView = rootLView[TVIEW];\n registerHostBindingOpCodes(rootTView, rootTNode, rootLView, rootTNode.directiveStart, rootTNode.directiveEnd, componentDef);\n invokeHostBindingsInCreationMode(componentDef, component);\n }\n return component;\n}", "title": "" }, { "docid": "13f9d4fb7ae452b9f8041f0a53eb1872", "score": "0.4962527", "text": "function getRootView(componentOrLView) {\n ngDevMode && assertDefined(componentOrLView, 'component');\n let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView);\n while (lView && !(lView[FLAGS] & 512 /* IsRoot */)) {\n lView = getLViewParent(lView);\n }\n ngDevMode && assertLView(lView);\n return lView;\n}", "title": "" }, { "docid": "13f9d4fb7ae452b9f8041f0a53eb1872", "score": "0.4962527", "text": "function getRootView(componentOrLView) {\n ngDevMode && assertDefined(componentOrLView, 'component');\n let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView);\n while (lView && !(lView[FLAGS] & 512 /* IsRoot */)) {\n lView = getLViewParent(lView);\n }\n ngDevMode && assertLView(lView);\n return lView;\n}", "title": "" }, { "docid": "13f9d4fb7ae452b9f8041f0a53eb1872", "score": "0.4962527", "text": "function getRootView(componentOrLView) {\n ngDevMode && assertDefined(componentOrLView, 'component');\n let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView);\n while (lView && !(lView[FLAGS] & 512 /* IsRoot */)) {\n lView = getLViewParent(lView);\n }\n ngDevMode && assertLView(lView);\n return lView;\n}", "title": "" }, { "docid": "13f9d4fb7ae452b9f8041f0a53eb1872", "score": "0.4962527", "text": "function getRootView(componentOrLView) {\n ngDevMode && assertDefined(componentOrLView, 'component');\n let lView = isLView(componentOrLView) ? componentOrLView : readPatchedLView(componentOrLView);\n while (lView && !(lView[FLAGS] & 512 /* IsRoot */)) {\n lView = getLViewParent(lView);\n }\n ngDevMode && assertLView(lView);\n return lView;\n}", "title": "" }, { "docid": "6b137d0cbddb769299b589c8d7ab9186", "score": "0.49573645", "text": "get Components() {\n return this.components;\n }", "title": "" }, { "docid": "e934a61444bdf482230740a80b7a7bec", "score": "0.49504122", "text": "function components() {\n const div = document.createElement('div');\n div.className = 'components'\n div.appendChild(componentsRights());\n return div;\n}", "title": "" }, { "docid": "d2b543a9547abfa4c0be56d84151c42b", "score": "0.4949807", "text": "getRoots() {\n return this.getBoundaryNodes(true);\n }", "title": "" }, { "docid": "c4ca1086efbc938e7f9bf5d89ae36b15", "score": "0.49430686", "text": "function createRootComponent(componentView, componentDef, rootView, rootContext, hostFeatures) {\n var tView = rootView[TVIEW];\n // Create directive instance with factory() and store at next index in viewData\n var component = instantiateRootComponent(tView, rootView, componentDef);\n rootContext.components.push(component);\n componentView[CONTEXT] = component;\n hostFeatures && hostFeatures.forEach(function (feature) { return feature(component, componentDef); });\n if (tView.firstTemplatePass && componentDef.hostBindings) {\n var rootTNode = getPreviousOrParentTNode();\n setCurrentDirectiveDef(componentDef);\n componentDef.hostBindings(1 /* Create */, component, rootTNode.index - HEADER_OFFSET);\n setCurrentDirectiveDef(null);\n }\n return component;\n}", "title": "" }, { "docid": "c4ca1086efbc938e7f9bf5d89ae36b15", "score": "0.49430686", "text": "function createRootComponent(componentView, componentDef, rootView, rootContext, hostFeatures) {\n var tView = rootView[TVIEW];\n // Create directive instance with factory() and store at next index in viewData\n var component = instantiateRootComponent(tView, rootView, componentDef);\n rootContext.components.push(component);\n componentView[CONTEXT] = component;\n hostFeatures && hostFeatures.forEach(function (feature) { return feature(component, componentDef); });\n if (tView.firstTemplatePass && componentDef.hostBindings) {\n var rootTNode = getPreviousOrParentTNode();\n setCurrentDirectiveDef(componentDef);\n componentDef.hostBindings(1 /* Create */, component, rootTNode.index - HEADER_OFFSET);\n setCurrentDirectiveDef(null);\n }\n return component;\n}", "title": "" }, { "docid": "64b37c310cc36d8a1afd527cbf26edc1", "score": "0.49393284", "text": "static compileComponents() {\n return TestBedImpl.INSTANCE.compileComponents();\n }", "title": "" }, { "docid": "08f4659e5a98904ba51dcd2ea3717f2e", "score": "0.49335203", "text": "async get_components() {\n\t\tconst response = await fetch(`${this.apiurl}/components/list`)\n\t\t\t.then(r => r.json())\n\n\t\t// throw an error\n\t\tif (!response.success) {\n\t\t\tthrow new Error(response.message)\n\t\t}\n\n\t\tthis._setState('components', response.components)\n\n\t\treturn response.components\n\t}", "title": "" }, { "docid": "349d152fdf36ac987addc9e27c64d0c9", "score": "0.49224475", "text": "function getAllLeafComponents (callback) {\n\n function getLeafComponentsRec(parent) {\n\n var components = [];\n\n if (typeof parent.children !== \"undefined\") {\n\n var children = parent.children;\n\n for (var i = 0; i < children.length; i++) {\n\n var child = children[i];\n\n if (typeof child.children !== \"undefined\") {\n\n var subComps = getLeafComponentsRec(child);\n\n components.push.apply(components, subComps);\n }\n else {\n components.push(child);\n }\n }\n }\n\n return components;\n }\n\n viewer.getObjectTree(function (result) {\n\n var allLeafComponents = getLeafComponentsRec(result.root);\n\n callback(allLeafComponents);\n });\n }", "title": "" }, { "docid": "1913dc30d1263d40f5a382bd4ade6749", "score": "0.490258", "text": "function getHostElement(componentOrDirective) {\n return getLContext(componentOrDirective).native;\n}", "title": "" }, { "docid": "1913dc30d1263d40f5a382bd4ade6749", "score": "0.490258", "text": "function getHostElement(componentOrDirective) {\n return getLContext(componentOrDirective).native;\n}", "title": "" }, { "docid": "1913dc30d1263d40f5a382bd4ade6749", "score": "0.490258", "text": "function getHostElement(componentOrDirective) {\n return getLContext(componentOrDirective).native;\n}", "title": "" }, { "docid": "1913dc30d1263d40f5a382bd4ade6749", "score": "0.490258", "text": "function getHostElement(componentOrDirective) {\n return getLContext(componentOrDirective).native;\n}", "title": "" }, { "docid": "721adf4da4ec2f0ee1ce00c067ca7419", "score": "0.48816353", "text": "static async getAllComponent()\n {\n try {\n\n let components = await ModelComponent.findAll();\n return components\n\n\n } catch (e) {\n \n }\n }", "title": "" }, { "docid": "d7cddd6416575934fde802a643b7e37f", "score": "0.4863221", "text": "function getDOM(comp) {\n var rendered = comp;\n while (rendered instanceof _Component2.default) {\n //判断对象是否是dom\n rendered = rendered.__rendered;\n }\n return rendered;\n}", "title": "" }, { "docid": "9802b03573759c7091fe5d08b7d74619", "score": "0.48554698", "text": "function mountDom$1(vnode) {\n if (Array.isArray(vnode)) {\n return flattenWithoutNull(vnode.map(mountDom$1));\n }\n\n return asDom(mount$1(vnode));\n}", "title": "" }, { "docid": "908fca3edb27ee141255699562842bbb", "score": "0.48389873", "text": "function initAll(parentElement) {\n if (typeof parentElement === 'undefined') parentElement = document;\n for (let i = 0, len = componentNames.length; i < len; i++) {\n initComponent(componentNames[i], parentElement);\n }\n}", "title": "" }, { "docid": "563ea01769bfdc47a5e2c2c9a24378d7", "score": "0.48376903", "text": "function getComponentForLtngOut(components) {\n if (!components.length) {\n return;\n }\n let owner = components[0].getOwner();\n while (!owner.getOwner().isInstanceOf('aura:application') && owner.getOwner() !== owner) {\n owner = owner.getOwner();\n }\n return owner;\n}", "title": "" }, { "docid": "623dd29b663a0c0c792a11d6e3b6d129", "score": "0.48372123", "text": "getRootElement() {\n return this._rootElement;\n }", "title": "" }, { "docid": "d8f42dc7259beafecaff49f82f65fee4", "score": "0.48292372", "text": "getInternalElements()\n {\n return (this.wrapper.get()[0]).children;\n }", "title": "" }, { "docid": "9221511a050ce0530056689065bcc8c0", "score": "0.48156354", "text": "function gatherElements () {\n elements = {\n main: $element[0],\n scrollContainer: $element[0].querySelector('.md-virtual-repeat-container'),\n scroller: $element[0].querySelector('.md-virtual-repeat-scroller'),\n ul: $element.find('ul')[0],\n input: $element.find('input')[0],\n wrap: $element.find('md-autocomplete-wrap')[0],\n root: document.body\n };\n\n elements.li = elements.ul.getElementsByTagName('li');\n elements.snap = getSnapTarget();\n elements.$ = getAngularElements(elements);\n\n inputModelCtrl = elements.$.input.controller('ngModel');\n }", "title": "" }, { "docid": "8b3fb38dbe02dfd23d94e93f4d861e6b", "score": "0.48110512", "text": "getPageElements() {\n\t\treturn document.querySelectorAll('.grid__header, .grid__content, .altaside, .altaside__btn, .grid__aside, .grid__footer, .grid__footer--notification, .grid__footer--settings, .modal, .modal__close--btn, .modal__form, .modal__form--list, .modal__form--btn'); //Query DOM for header, content, aside, footer el.\n\t}", "title": "" }, { "docid": "f2770092b718c92411fdfedc7802cd9e", "score": "0.47941986", "text": "function getDirectives(element) {\n const context = loadLContext(element);\n if (context.directives === undefined) {\n context.directives = getDirectivesAtNodeIndex(context.nodeIndex, context.lView, false);\n }\n // The `directives` in this case are a named array called `LComponentView`. Clone the\n // result so we don't expose an internal data structure in the user's console.\n return context.directives === null ? [] : [...context.directives];\n}", "title": "" }, { "docid": "f2770092b718c92411fdfedc7802cd9e", "score": "0.47941986", "text": "function getDirectives(element) {\n const context = loadLContext(element);\n if (context.directives === undefined) {\n context.directives = getDirectivesAtNodeIndex(context.nodeIndex, context.lView, false);\n }\n // The `directives` in this case are a named array called `LComponentView`. Clone the\n // result so we don't expose an internal data structure in the user's console.\n return context.directives === null ? [] : [...context.directives];\n}", "title": "" }, { "docid": "7e82f715036bcf1af2fdd2597104b99c", "score": "0.47790053", "text": "static get __attachedInstances() {\n return Array.from(document.body.children).filter(el => el instanceof OverlayElement);\n }", "title": "" }, { "docid": "e680e727aaac18745cd9ce374e3b4455", "score": "0.4764497", "text": "function bootstrap(elt) {\n for (var _len2 = arguments.length, types = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n types[_key2 - 1] = arguments[_key2];\n }\n\n if (types.length === 0) {\n types = [Application];\n }\n types.forEach(register);\n // register transparent container: <ui:fragment>\n register({ NAME: 'fragment', TEMPLATE: '<ui:transclude/>' });\n // collect and register `bare-template` definitions\n var staticTypes = [].concat([].concat(_toConsumableArray(doc.getElementsByTagName('script')))).filter(function (e) {\n return e.id && !REGISTRY.has(e.id) && e.type === 'text/x-template';\n });\n staticTypes.map(function (e) {\n return { NAME: e.id, TEMPLATE: e.innerText };\n }).forEach(register);\n // use `<body>` as mount element by default\n return new Bootstrap(elt || doc.body, types[0]);\n}", "title": "" }, { "docid": "99f4321a4a06629db040a38f676e961a", "score": "0.47644943", "text": "function _componentBindings(appComponentType) {\n return [\n di_1.bind(application_tokens_1.APP_COMPONENT)\n .toValue(appComponentType),\n di_1.bind(application_tokens_1.APP_COMPONENT_REF_PROMISE)\n .toFactory(function (dynamicComponentLoader, injector) {\n // TODO(rado): investigate whether to support bindings on root component.\n return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)\n .then(function (componentRef) {\n if (lang_1.isPresent(componentRef.location.nativeElement)) {\n injector.get(testability_1.TestabilityRegistry)\n .registerApplication(componentRef.location.nativeElement, injector.get(testability_1.Testability));\n }\n return componentRef;\n });\n }, [dynamic_component_loader_1.DynamicComponentLoader, di_1.Injector]),\n di_1.bind(appComponentType)\n .toFactory(function (p) { return p.then(function (ref) { return ref.instance; }); }, [application_tokens_1.APP_COMPONENT_REF_PROMISE]),\n ];\n}", "title": "" }, { "docid": "4387e367cf1d680ab880f3024547bb88", "score": "0.4750591", "text": "function _componentProviders(appComponentType) {\n return [\n di_22.provide(application_tokens_2.APP_COMPONENT, { useValue: appComponentType }),\n di_22.provide(application_tokens_2.APP_COMPONENT_REF_PROMISE, {\n useFactory: function (dynamicComponentLoader, appRef, injector) {\n // Save the ComponentRef for disposal later.\n var ref;\n // TODO(rado): investigate whether to support providers on root component.\n return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector, function () { appRef._unloadComponent(ref); })\n .then(function (componentRef) {\n ref = componentRef;\n var testability = injector.getOptional(testability_1.Testability);\n if (lang_92.isPresent(testability)) {\n injector.get(testability_1.TestabilityRegistry)\n .registerApplication(componentRef.location.nativeElement, testability);\n }\n return componentRef;\n });\n },\n deps: [dynamic_component_loader_1.DynamicComponentLoader, ApplicationRef, di_22.Injector]\n }),\n di_22.provide(appComponentType, {\n useFactory: function (p) { return p.then(function (ref) { return ref.instance; }); },\n deps: [application_tokens_2.APP_COMPONENT_REF_PROMISE]\n }),\n ];\n }", "title": "" }, { "docid": "39f312111705a5ffce432e340a9bf928", "score": "0.4746084", "text": "_getComponentRootNode(componentRef) {\n return componentRef.hostView.rootNodes[0];\n }", "title": "" }, { "docid": "39f312111705a5ffce432e340a9bf928", "score": "0.4746084", "text": "_getComponentRootNode(componentRef) {\n return componentRef.hostView.rootNodes[0];\n }", "title": "" }, { "docid": "3fdda832a954a36fa88ee103e3ebb821", "score": "0.4742986", "text": "_getRootNode() {\n const nativeElement = this._viewContainerRef.element.nativeElement;\n // The directive could be set on a template which will result in a comment\n // node being the root. Use the comment's parent node if that is the case.\n return (nativeElement.nodeType === nativeElement.ELEMENT_NODE ?\n nativeElement : nativeElement.parentNode);\n }", "title": "" }, { "docid": "3fdda832a954a36fa88ee103e3ebb821", "score": "0.4742986", "text": "_getRootNode() {\n const nativeElement = this._viewContainerRef.element.nativeElement;\n // The directive could be set on a template which will result in a comment\n // node being the root. Use the comment's parent node if that is the case.\n return (nativeElement.nodeType === nativeElement.ELEMENT_NODE ?\n nativeElement : nativeElement.parentNode);\n }", "title": "" }, { "docid": "d2e7b8b7acb55c60bd2cca713cc0426a", "score": "0.47424716", "text": "function findDirectiveDefMatches(tView, tNode) {\n ngDevMode && assertFirstCreatePass(tView);\n ngDevMode && assertTNodeType(tNode, 3 /* TNodeType.AnyRNode */ | 12 /* TNodeType.AnyContainer */);\n const registry = tView.directiveRegistry;\n let matches = null;\n let hostDirectiveDefs = null;\n if (registry) {\n for (let i = 0; i < registry.length; i++) {\n const def = registry[i];\n if (isNodeMatchingSelectorList(tNode, def.selectors, /* isProjectionMode */ false)) {\n matches || (matches = []);\n if (isComponentDef(def)) {\n if (ngDevMode) {\n assertTNodeType(tNode, 2 /* TNodeType.Element */, `\"${tNode.value}\" tags cannot be used as component hosts. ` +\n `Please use a different tag to activate the ${stringify(def.type)} component.`);\n if (isComponentHost(tNode)) {\n throwMultipleComponentError(tNode, matches.find(isComponentDef).type, def.type);\n }\n }\n // Components are inserted at the front of the matches array so that their lifecycle\n // hooks run before any directive lifecycle hooks. This appears to be for ViewEngine\n // compatibility. This logic doesn't make sense with host directives, because it\n // would allow the host directives to undo any overrides the host may have made.\n // To handle this case, the host directives of components are inserted at the beginning\n // of the array, followed by the component. As such, the insertion order is as follows:\n // 1. Host directives belonging to the selector-matched component.\n // 2. Selector-matched component.\n // 3. Host directives belonging to selector-matched directives.\n // 4. Selector-matched directives.\n if (def.findHostDirectiveDefs !== null) {\n const hostDirectiveMatches = [];\n hostDirectiveDefs = hostDirectiveDefs || new Map();\n def.findHostDirectiveDefs(def, hostDirectiveMatches, hostDirectiveDefs);\n // Add all host directives declared on this component, followed by the component itself.\n // Host directives should execute first so the host has a chance to override changes\n // to the DOM made by them.\n matches.unshift(...hostDirectiveMatches, def);\n // Component is offset starting from the beginning of the host directives array.\n const componentOffset = hostDirectiveMatches.length;\n markAsComponentHost(tView, tNode, componentOffset);\n }\n else {\n // No host directives on this component, just add the\n // component def to the beginning of the matches.\n matches.unshift(def);\n markAsComponentHost(tView, tNode, 0);\n }\n }\n else {\n // Append any host directives to the matches first.\n hostDirectiveDefs = hostDirectiveDefs || new Map();\n def.findHostDirectiveDefs?.(def, matches, hostDirectiveDefs);\n matches.push(def);\n }\n }\n }\n }\n return matches === null ? null : [matches, hostDirectiveDefs];\n}", "title": "" }, { "docid": "442b056b89133bdc922e2f53e78f1e74", "score": "0.47272968", "text": "function gatherElements () {\n elements = {\n main: $element[0],\n scrollContainer: $element[0].getElementsByClassName('md-virtual-repeat-container')[0],\n scroller: $element[0].getElementsByClassName('md-virtual-repeat-scroller')[0],\n ul: $element.find('ul')[0],\n input: $element.find('input')[0],\n wrap: $element.find('md-autocomplete-wrap')[0],\n root: document.body\n };\n elements.li = elements.ul.getElementsByTagName('li');\n elements.snap = getSnapTarget();\n elements.$ = getAngularElements(elements);\n }", "title": "" }, { "docid": "dcfa1a0a2556dc926f92aa4b5df62eeb", "score": "0.4725508", "text": "getRootElement() {\n return this._getElement(this._getRootElementID());\n }", "title": "" }, { "docid": "a72545afb04f75e598746a9a91a56e4d", "score": "0.47234124", "text": "dispose() {\n const { _root } = this;\n\n if (!!_root) {\n _root.dispose();\n }\n\n this._components.clear();\n\n this._root = null;\n }", "title": "" }, { "docid": "0a12572106fdad539f30465fc373987d", "score": "0.47181782", "text": "function getAllAppNodes(selector) {\n return state.appRoot.querySelectorAll(selector);\n }", "title": "" }, { "docid": "ff24c5da15a429012d380a2f4e94be5f", "score": "0.47108227", "text": "function getOwningComponent(elementOrDir) {\n const context = getLContext(elementOrDir);\n if (context === null)\n return null;\n let lView = context.lView;\n let parent;\n ngDevMode && assertLView(lView);\n while (lView[TVIEW].type === 2 /* Embedded */ && (parent = getLViewParent(lView))) {\n lView = parent;\n }\n return lView[FLAGS] & 512 /* IsRoot */ ? null : lView[CONTEXT];\n}", "title": "" }, { "docid": "ff24c5da15a429012d380a2f4e94be5f", "score": "0.47108227", "text": "function getOwningComponent(elementOrDir) {\n const context = getLContext(elementOrDir);\n if (context === null)\n return null;\n let lView = context.lView;\n let parent;\n ngDevMode && assertLView(lView);\n while (lView[TVIEW].type === 2 /* Embedded */ && (parent = getLViewParent(lView))) {\n lView = parent;\n }\n return lView[FLAGS] & 512 /* IsRoot */ ? null : lView[CONTEXT];\n}", "title": "" }, { "docid": "13da79b0505a28c98f91295c10d12986", "score": "0.47047952", "text": "static getAllComponents() {\n let all = Timetable.getAll().map(item => {\n return item.component;\n });\n return [...new Set(all)]; // all unique\n }", "title": "" }, { "docid": "d48ff7e46801a735ef1281234a3a2053", "score": "0.4700368", "text": "function gatherElements () {\n elements = {\n main: $element[ 0 ],\n ul: $element.find('ul')[ 0 ],\n input: $element.find('input')[ 0 ],\n wrap: $element.find('md-autocomplete-wrap')[ 0 ],\n root: document.body\n };\n elements.li = elements.ul.getElementsByTagName('li');\n elements.snap = getSnapTarget();\n elements.$ = getAngularElements(elements);\n }", "title": "" }, { "docid": "e3dcdcc0b61fd2b04797ff2708bf6c62", "score": "0.46881142", "text": "refreshEventListeners() {\n this.actionEvents = {};\n this.modelEls = [];\n this.dbEls = [];\n\n this.walker(this.root, (el) => {\n if (el.isSameNode(this.root)) {\n // Skip the component root element\n return;\n }\n\n const element = new Element(el);\n\n if (element.isUnicorn) {\n if (\n hasValue(element.field) &&\n (hasValue(element.db) || hasValue(element.model))\n ) {\n if (!this.attachedDbEvents.some((e) => e.isSame(element))) {\n this.attachedDbEvents.push(element);\n addDbEventListener(this, element.el, element.field.eventType);\n }\n\n if (!this.dbEls.some((e) => e.isSame(element))) {\n this.dbEls.push(element);\n }\n } else if (\n hasValue(element.model) &&\n isEmpty(element.db) &&\n isEmpty(element.field)\n ) {\n if (!this.attachedModelEvents.some((e) => e.isSame(element))) {\n this.attachedModelEvents.push(element);\n addModelEventListener(this, element.el, element.model.eventType);\n }\n\n if (!this.modelEls.some((e) => e.isSame(element))) {\n this.modelEls.push(element);\n }\n } else if (hasValue(element.loading)) {\n this.loadingEls.push(element);\n\n // Hide loading elements that are shown when an action happens\n if (element.loading.show) {\n element.hide();\n }\n }\n\n if (hasValue(element.key)) {\n this.keyEls.push(element);\n }\n\n element.actions.forEach((action) => {\n if (this.actionEvents[action.eventType]) {\n this.actionEvents[action.eventType].push({ action, element });\n } else {\n this.actionEvents[action.eventType] = [{ action, element }];\n\n if (\n !this.attachedEventTypes.some((et) => et === action.eventType)\n ) {\n this.attachedEventTypes.push(action.eventType);\n addActionEventListener(this, action.eventType);\n }\n }\n });\n }\n });\n }", "title": "" }, { "docid": "2e33acd3ea9101569960c07930ad08e2", "score": "0.46830773", "text": "function getOwningComponent(elementOrDir) {\n const context = loadLContext(elementOrDir, false);\n if (context === null)\n return null;\n let lView = context.lView;\n let parent;\n ngDevMode && assertLView(lView);\n while (lView[TVIEW].type === 2 /* Embedded */ && (parent = getLViewParent(lView))) {\n lView = parent;\n }\n return lView[FLAGS] & 512 /* IsRoot */ ? null : lView[CONTEXT];\n}", "title": "" }, { "docid": "2e33acd3ea9101569960c07930ad08e2", "score": "0.46830773", "text": "function getOwningComponent(elementOrDir) {\n const context = loadLContext(elementOrDir, false);\n if (context === null)\n return null;\n let lView = context.lView;\n let parent;\n ngDevMode && assertLView(lView);\n while (lView[TVIEW].type === 2 /* Embedded */ && (parent = getLViewParent(lView))) {\n lView = parent;\n }\n return lView[FLAGS] & 512 /* IsRoot */ ? null : lView[CONTEXT];\n}", "title": "" }, { "docid": "5bbb87a23ab4dd222d1cae36c45ad180", "score": "0.46812412", "text": "function getInternalInstanceChildren(instance) {\n if (instance.$children) {\n return instance.$children;\n }\n if (Array.isArray(instance.subTree.children)) {\n return instance.subTree.children.filter(vnode => !!vnode.component).map(vnode => vnode.component);\n }\n return [];\n}", "title": "" }, { "docid": "80cf586af7f748b32d75c56cdb3e1954", "score": "0.4668208", "text": "function renderAddedComponents(g) {\n var componentManager = g.component();\n if (componentManager) {\n componentManager.filter(function(c) {\n return !c.isRendered();\n }).forEach(function(c) {\n c.render(g.root());\n });\n }\n }", "title": "" }, { "docid": "447a77524bf77b42c5cf15bfe850b451", "score": "0.46162847", "text": "function instantiateAllDirectives(tView, lView, tNode) {\n var start = tNode.directiveStart;\n var end = tNode.directiveEnd;\n if (!getFirstTemplatePass() && start < end) {\n getOrCreateNodeInjectorForNode(tNode, lView);\n }\n for (var i = start; i < end; i++) {\n var def = tView.data[i];\n if (isComponentDef(def)) {\n addComponentLogic(lView, tNode, def);\n }\n var directive = getNodeInjectable(tView.data, lView, i, tNode);\n postProcessDirective(lView, directive, def, i);\n }\n}", "title": "" } ]
52fe90aa63ae3beb0dfa06def4bf6e70
Builds the absolute url for the destination page
[ { "docid": "62b5da260dea1ed2066ab92824f14bfd", "score": "0.6505829", "text": "getDestinationUrl(path) {\n this.authService.getLogger().verbose(\"Guard - getting destination url\");\n // Absolute base url for the application (default to origin if base element not present)\n const baseElements = document.getElementsByTagName(\"base\");\n const baseUrl = this.location.normalize(baseElements.length ? baseElements[0].href : window.location.origin);\n // Path of page (including hash, if using hash routing)\n const pathUrl = this.location.prepareExternalUrl(path);\n // Hash location strategy\n if (pathUrl.startsWith(\"#\")) {\n this.authService.getLogger().verbose(\"Guard - destination by hash routing\");\n return `${baseUrl}/${pathUrl}`;\n }\n /*\n * If using path location strategy, pathUrl will include the relative portion of the base path (e.g. /base/page).\n * Since baseUrl also includes /base, can just concatentate baseUrl + path\n */\n return `${baseUrl}${path}`;\n }", "title": "" } ]
[ { "docid": "b9e28dd294658ea06eb5c872c9971ed0", "score": "0.66606325", "text": "function createUrl(){\r\n let origin = location.origin;\r\n let host = location.host;\r\n let pathname = location.pathname.split(\"/\")[1];\r\n let cont = origin + \"/\" + pathname;\r\n return cont;\r\n }", "title": "" }, { "docid": "bdd1ef22b09dd2af90635c66110014e6", "score": "0.65969986", "text": "function construct_url(file) {\n\t \tpathname = window.location.pathname.split(\"/\");\n\t \tpathname.pop();\n\t \tpathname = pathname.join(\"/\");\n\t \treturn (window.location.hostname + pathname + file);\n\t }", "title": "" }, { "docid": "5f5149b0639ee214076fa91070e3f7a4", "score": "0.6315782", "text": "function getURL(){\n\t\tvar targetURL = \"/?\";\n\t\tvar location = $(\"#locationInput\").val();\n\t\tvar date = $(\"#dateInput\").val();\n\t\tvar shape = $(\"#shapeInput\").val();\n\t\tvar id = $(\"#idInput\").val();\n\n\t\tif(location){\n\t\t\tlocation = location.split(\",\");\n\t\t\tlocation = (location[0]+\", \"+location[1].trim()).toLowerCase();\n\t\t\ttargetURL = appendURL(targetURL,\"l\",location);\n\t\t}\n\n\t\tif(date){\n\t\t\tdate = date.split(\"/\");\n\t\t\tdate = (+date[0])+\"/\"+(+date[1])+\"/\"+(+date[2]);\n\t\t\ttargetURL = appendURL(targetURL,\"o\",date);\n\t\t}\n\n\t\tif(shape){\n\t\t\ttargetURL = appendURL(targetURL,\"s\",shape.toLowerCase())\n\t\t}\n\n\t\tif(id){\n\t\t\ttargetURL = appendURL(targetURL,\"i\",id);\n\t\t}\n\n\t\treturn encodeURI(targetURL);\n\t}", "title": "" }, { "docid": "077280856b8558cb921f56b0ca55270d", "score": "0.6230535", "text": "function generate_url(){\n\tvar url = window.location.href.split('?')[0] + \"?\";\n\tvar append = \"\";\n\n //Add stationname\n append += \"stationname=\" + imageObj.stationname;\n\n //Get new URL\n var total = url + append;\n\n\t//Update in address bar without reloading page\n\tvar pagename = window.location.href.split('/');\n\n if (url.indexOf(\".html\") != -1){\n pagename = pagename[pagename.length-1];\n pagename = pagename.split(\".html\")[0];\n var stateObj = { foo: \"bar\" };\n history.replaceState(stateObj, \"\", pagename+\".html?\"+append);\n\t}\n if (url.indexOf(\".html\") == -1){\n\tpagename = pagename[pagename.length-1];\n\tpagename = pagename.split(\".html\")[0];\n\tvar stateObj = { foo: \"bar\" };\n\thistory.replaceState(stateObj, \"\", pagename+\"index.html?\"+append);\n\t}\n\n\treturn total;\n}", "title": "" }, { "docid": "86cab851342995be923000120b4e06b8", "score": "0.6210362", "text": "function generateRoomUrl() {\n var room = shortUrl();\n var link = document.getElementById(\"room-url\");\n roomUrl = \"https://\" + window.location.host + \"/\" + room;\n link.href = roomUrl;\n link.innerHTML = roomUrl;\n}", "title": "" }, { "docid": "92fa172c6eec8008bf1dd141024ef03f", "score": "0.6193154", "text": "function computeURL() {\n var url = settings.url;\n if (typeof settings.url == 'function') {\n url = settings.url.call();\n }\n return url;\n }", "title": "" }, { "docid": "1dd96fcbd58fe73d963355c50f38b128", "score": "0.61734027", "text": "getTargetURL () {\n // Copying over data fields should be done lazily, since some required data may not be\n // captured until after page scripts run.\n this.copySocialDataFields()\n return this.clickAction.targetURL\n }", "title": "" }, { "docid": "1a44ed8c99230d55d4ce83b38a66b5dd", "score": "0.6156841", "text": "function buildAbsoluteUrl(fhirEndpoint=\"\", reference) {\n\tif (/^http/.test(reference)) {\n\t\treturn reference;\n\t} else {\n\t\treturn fhirEndpoint.replace(/\\/*$/, \"/\") + reference;\n\t}\n}", "title": "" }, { "docid": "2e7c158101de89f1db1369a16531b3d2", "score": "0.6150285", "text": "function computeURL() {\n var url = settings.url;\n if(typeof settings.url == 'function') {\n url = settings.url.call();\n }\n return url;\n }", "title": "" }, { "docid": "2e7c158101de89f1db1369a16531b3d2", "score": "0.6150285", "text": "function computeURL() {\n var url = settings.url;\n if(typeof settings.url == 'function') {\n url = settings.url.call();\n }\n return url;\n }", "title": "" }, { "docid": "4b31fbc7563dce76a827144c4103f4f2", "score": "0.61341965", "text": "function buildUrl(suffix) {\n return `${BASE_URL}/${suffix}`;\n}", "title": "" }, { "docid": "28203dd4e6c12da2a6caabc702802341", "score": "0.6131826", "text": "function url() {\n if (error) return error\n return builder.url()\n }", "title": "" }, { "docid": "77cccb6d9cd895191612533f8a6b5478", "score": "0.61009717", "text": "buildUrl() {\n return propsToQuery(this.component.props, this.props).then(queryString => {\n\n let url;\n\n if (this.props.url) {\n url = this.props.url;\n } else if (this.props.env) {\n url = this.component.envUrls[this.props.env];\n } else {\n url = this.component.url;\n }\n\n if (queryString) {\n\n let base;\n let query;\n let hash;\n\n [ base, hash ] = url.split('#');\n [ base, query ] = base.split('?');\n\n if (query) {\n query = `${query}&${queryString}`;\n } else {\n query = queryString;\n }\n\n url = base;\n\n if (query) {\n url = `${url}?${query}`;\n }\n\n if (hash) {\n url = `${url}#${hash}`;\n }\n\n return url;\n }\n\n return url;\n });\n }", "title": "" }, { "docid": "73c38e535ef40272bc61fe042aaa2b17", "score": "0.6081277", "text": "function _url () {\n return constants.url(this.query);\n }", "title": "" }, { "docid": "9e113c053d7fb20169ed60e510048814", "score": "0.60588324", "text": "getURL() {\n var originalPath = this.getHash().substr(1);\n var outPath = originalPath;\n\n if (outPath[0] !== '/') {\n outPath = '/'; // Only add the # if the path isn't empty.\n // We do NOT want `/#` since the ampersand\n // is only included (conventionally) when\n // the location.hash has a value\n\n if (originalPath) {\n outPath += `#${originalPath}`;\n }\n }\n\n return outPath;\n }", "title": "" }, { "docid": "b852d07a20a062ad023dda4fc592f880", "score": "0.6026437", "text": "function buildUrl() {\n const fetchUrl =\n startURL + startDate + \",\" + endDate + \"&limit=\" + comicLimit + endUrl;\n return fetchUrl;\n}", "title": "" }, { "docid": "85b8a3976970d40db2fcc8645e290aa1", "score": "0.601408", "text": "static get TARGET_URL() { return TARGET_URL; }", "title": "" }, { "docid": "e0ac19b6a1444c5da890bedb7a72af99", "score": "0.60099775", "text": "function getAbsolutePath() {\n\t\t var loc = window.location;\n\t\t var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('http://themes.iki-bir.com/') + 1);\n\t\t return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));\n }", "title": "" }, { "docid": "5406f7a6e3bef485b5f8939b681822d4", "score": "0.6002635", "text": "getAbsoluteUrl(url) {\n return url.startsWith('/') ? url : '/' + url;\n }", "title": "" }, { "docid": "31d27a2269942064e607f174c52cdff5", "score": "0.5983727", "text": "function createApexURL( pageName ){\n var currentLocation = window.location.href;\n var ajaxURL = currentLocation.replace( 'gblite.', 'c.' );\n ajaxURL = ajaxURL.substring(0, ajaxURL.toLowerCase().indexOf('/apex/' )) + '/apex/' + pageName;\n return( ajaxURL );\n}", "title": "" }, { "docid": "a0de18d652fb044bdaae050043a10275", "score": "0.59369504", "text": "function getFullUrl(res) {\n var url = $(\"#serverurl\").val();\n if (url.lastIndexOf('/') === url.length-1) {\n url = url.slice(0,url.length-1);\n }\n\n return url + res;\n }", "title": "" }, { "docid": "12e5eee4b1c3acbe2fc6629fbb97d905", "score": "0.5933392", "text": "getFullUrl() {\n return this.host + this.uri + this.getQueryString();\n }", "title": "" }, { "docid": "e8860b8ea651b6f0216d6c42eb2bbcf6", "score": "0.5931275", "text": "get __effectiveBaseUrl() {\n return this.baseUrl\n ? this.constructor.__createUrl(\n this.baseUrl,\n document.baseURI || document.URL\n ).href.replace(/[^\\/]*$/, '')\n : '';\n }", "title": "" }, { "docid": "5f8d192a469e2e7358e7ca1e8f54c574", "score": "0.59045553", "text": "function getMyURL(){\n res={}\n res.fullurl= location.href\n res.baseurl= location.origin\n res.path = location.href.replace(location.origin,'')\n return merge(res,location)\n}", "title": "" }, { "docid": "e708d275ec47ccff055c14521385d2a0", "score": "0.59039986", "text": "function getAbsolutePath() {\n\t\t var loc = window.location;\n\t\t var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);\n\t\t return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));\n }", "title": "" }, { "docid": "3416123d533caf10e5f27325e67ecc4a", "score": "0.5898253", "text": "function buildUrl(busNo, startStationNo, destStationNo) {\n//\tbusInfo = getBusInfo(busNo);\n\tbusfreq = \"\";\n\tvar direction = 'd';\n\tif(startStationNo < destStationNo)\n\t\tdirection = 'u';\n//\tif(busInfo != undefined && busInfo.frequency !=\"\")\n//\t\tbusfreq = \"&nbsp;(&nbsp;\" + busInfo.frequency + \"&nbsp;mins)\";\n\turl = '<a href=\"#\"' + ' onClick=\"return goLinkBusRoute(' \n\t\t\t\t+ \"'\" + busNo + \"'\" + ',' + startStationNo + ',' + destStationNo + \n\t\t\t\t\", '\" + direction + \"'\" + ')\">' \n\t\t\t\t+ busNo + busfreq + \"</a>\" ;\n\treturn url;\n\n}", "title": "" }, { "docid": "bb77ba3c5e06b7a4c9c1c8d208b6b2bd", "score": "0.58886296", "text": "function getAbsolutePath() {\r\n\t\t\tvar loc = window.location;\r\n\t\t\tvar pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);\r\n\t\t\treturn loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));\r\n\t\t}", "title": "" }, { "docid": "172d2e23a53dcdabd2fb0abade5e9792", "score": "0.58835423", "text": "function uiGetPageUrl()\r\n{\r\nvar strUrl = '../html/basic_home.htm';\r\nreturn strUrl;\r\n}", "title": "" }, { "docid": "672053030691a6dda0e86ddb992972de", "score": "0.5882322", "text": "function buildUrl(raw_company_string, raw_position_string){\n var company = parseCompany(raw_company_string);\n var position = parsePosition(raw_position_string);\n var baseUrl = \"http://52.14.17.113:8080/api/all/\";\n var fullUrl = baseUrl + company + \"/\" + position;\n return fullUrl;\n}", "title": "" }, { "docid": "1e02f188877195ae0cd23d01cfe77020", "score": "0.5877284", "text": "function PaginatorUrl () {}", "title": "" }, { "docid": "dccba7f31bb2bc5885212a672ffe8bee", "score": "0.58758676", "text": "get __effectiveBaseUrl(){return this.baseUrl?this.constructor.__createUrl(this.baseUrl,document.baseURI||document.URL).href.replace(/[^\\/]*$/,\"\"):\"\"}", "title": "" }, { "docid": "26d5c364de328b48eda28edb508f8ce5", "score": "0.5836256", "text": "function getFullURL(relative) {\n return getLocationOrigin() + window.location.pathname + relative;\n}", "title": "" }, { "docid": "2bb338e375ab463adfed4bddd4609ad7", "score": "0.58240706", "text": "function getAbsolutePath() {\n\t\t\tvar loc = window.location;\n\t\t\tvar pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);\n\t\t\treturn loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));\n\t\t}", "title": "" }, { "docid": "5f1ee5216da7274073b69063710feb0b", "score": "0.5822039", "text": "function getUrl() {\n var url = $location.absUrl();\n var hashIndex = url.indexOf('#');\n if (hashIndex != -1) {\n url = url.substr(0, hashIndex);\n }\n var queryIndex = url.indexOf('?');\n if (queryIndex != -1) {\n url = url.substr(0, queryIndex);\n }\n return url\n }", "title": "" }, { "docid": "edc6191cdb6a2fe05da109cd909545c3", "score": "0.58182544", "text": "function getUrl() {\n var params = \"?\";\n // Get all the basic params\n params += 'numBirds=' + vm.numBirds;\n params += '&numSets=' + vm.numSets;\n params += '&fadeAmount=' + vm.fadeAmount;\n params += '&stroke=' + vm.stroke;\n params += '&maxRadius=' + vm.maxRadius;\n params += '&desiredSeparation=' + vm.desiredSeparation;\n params += '&maxSpeed=' + vm.maxSpeed;\n params += '&maxForce=' + vm.maxForce;\n params += '&regenTime=' + vm.regenTime;\n params += '&startPositionMode=' + vm.startPositionMode;\n params += '&avoidMouse=' + vm.avoidMouse;\n\n // Get the current state\n params += '&bgColourHex=' + encodeURIComponent( bgColour.hex );\n params += '&bgColourRGB=' + encodeURIComponent( bgColour.rgb );\n params += '&setVariables=' + encodeURIComponent( JSON.stringify( setVariables ) );\n params += '&placedStartPositions=' + encodeURIComponent( JSON.stringify( vm.placedStartPositions ) );\n\n var url = window.location.origin + window.location.pathname + params;\n return url;\n }", "title": "" }, { "docid": "6e82ba701a70594f0a4a49ef0c553a73", "score": "0.5805581", "text": "generateFullUrl(urlPath) {\n return this.hostname + AbstractHttpClient.normalizeUrlPath(urlPath);\n }", "title": "" }, { "docid": "8b1ec33141b37ef28f27a1ca86a4f9de", "score": "0.57877517", "text": "async getOutputPath() {\n let uri = await this.getOutputLink();\n if (this.getFrontMatterData()[this.config.keys.permalinkRoot]) {\n return normalize(uri);\n } else {\n return normalize(this.outputDir + \"/\" + uri);\n }\n }", "title": "" }, { "docid": "ab0e99e0ba2d9f677f4d3691337c7a08", "score": "0.57713866", "text": "function get_url() {\n var query_string = '?';\n var idx = 0;\n $( \"a.a-profile\" ).each(function() {\n query_string += ('id' + idx + '=' + get_user_id( $(this).attr('href') ) + '&');\n idx++;\n });\n return ('https://storystreetconsulting.com/wsgi' + query_string);\n }", "title": "" }, { "docid": "5687b6acd27d814dceb59cecba29bd40", "score": "0.5769388", "text": "function getAjaxUrl(relUrl) {\r\n var parser = _parseUrl(_config.rootUrl); //get the anchor object\r\n \r\n //build relative URL\r\n parser.pathname = (_config.baseApiUri + \"/\" + relUrl)\r\n .replace(\"//\", \"/\"); //Chrome and IE behave differently.\r\n\r\n return parser.href;\r\n }", "title": "" }, { "docid": "b4b87968518a2fb15933612b70e3df0b", "score": "0.5766431", "text": "function FormatPathToURL(_path)//this format the path of mainWindow.html into URL address,and \n{\n return url.format({\n pathname: path.join(__dirname,_path),\n protocol: 'file:',\n slashes: true\n })\n}", "title": "" }, { "docid": "38e2f57db6630f65720b7937c5460209", "score": "0.57633483", "text": "function getFullURL() {\n\n // local variable for url\n var sURL = document.location.href;\n\n // return url stripped of the index\n return sURL.replace( \"index.html\", \"\" );\n}", "title": "" }, { "docid": "66641b7b11d91d2d73984ac8760fa9f0", "score": "0.57415915", "text": "function buildUrl (uri) {\n var self = this;\n\n var url = self.buildBaseUrl(uri);\n url = url + uri.pathname;\n\n // Return original URL if no params to append.\n if ( angular.isUndefined(uri.params) && angular.isUndefined(uri.query) ) {\n return url;\n }\n\n var paramsAsStrings = [];\n\n angular.forEach(uri.params, function(value, key) {\n paramsAsStrings.push(key + '=' + value);\n });\n\n if ( angular.isDefined(uri.query) && uri.query !== '' ) {\n paramsAsStrings.push(uri.query);\n }\n\n // Return original URL if no params to append.\n if ( paramsAsStrings.length === 0 ) {\n return url;\n }\n\n var finalUrl = url;\n\n if (finalUrl.substring(finalUrl.length - 1) === '?') {\n finalUrl += paramsAsStrings.join('&');\n } else {\n finalUrl += '?' + paramsAsStrings.join('&');\n }\n\n return finalUrl;\n }", "title": "" }, { "docid": "3e8aed1af8460eb47b5918d247dde6ca", "score": "0.5734303", "text": "function buildUrl(base, arguments) {\n \n if (base.charAt(base[base.length-1]) != \"/\") {\n base += \"/\"\n }\n\n for (var i = 0; i < arguments.length; i++) {\n base += arguments[i] + \"/\";\n }\n \n return base;\n}", "title": "" }, { "docid": "690b0149337fffe42de0cd2505c2f62a", "score": "0.5696232", "text": "get mapHref() {\n const activeCoordinate = this.state.activeCoordinate.location;\n let mapHrefURL = '';\n\n if (activeCoordinate.Latitude && activeCoordinate.Longitude) {\n mapHrefURL = encodeURI(\n `${EXTERNAL_GOOGLE_MAPS_URL}${activeCoordinate.Latitude},${\n activeCoordinate.Longitude\n }`\n );\n } else {\n mapHrefURL = encodeURI(\n `${EXTERNAL_GOOGLE_MAPS_URL}${normalizeString(\n activeCoordinate.Street\n )}+${normalizeString(activeCoordinate.City)}+${normalizeString(\n activeCoordinate.State\n )}+${normalizeString(activeCoordinate.PostalCode)}`\n );\n }\n return mapHrefURL;\n }", "title": "" }, { "docid": "537e13f21a849a665a3d44df55566508", "score": "0.56928617", "text": "function createURL(EISESSION,docidlist,curURL)\n{\n\tvar milli = (new Date()).getTime();\n\tvar temp = curURL.split('/');\t\t\n\tvar url = 'http://www.engineeringvillage.com/delivery/download/submit.url?downloadformat=ris&displayformat=abstract&timestamp=' + milli + docidlist + '&handlelist=1'\n\t//Z.debug(\"risurl: \" + url)\n\treturn url;\n}", "title": "" }, { "docid": "8de035a2da050653b83dc3f8e64c4b2a", "score": "0.5685205", "text": "static getWebUrlFromAbsolute(url) {\n let u = url.toLowerCase().trim();\n if (u.indexOf('?') !== -1) {\n u = u.substring(0, u.indexOf('?'));\n }\n if (u.indexOf('/_layouts/') !== -1) {\n u = u.substring(0, u.indexOf('/_layouts/'));\n }\n if (u.indexOf('/forms/') !== -1) {\n u = u.substring(0, u.indexOf('/forms/'));\n u = u.substring(0, u.lastIndexOf('/'));\n }\n if (u.indexOf('/lists/') !== -1) {\n u = u.substring(0, u.indexOf('/lists/'));\n }\n if (u.indexOf('/sitepages/') !== -1) {\n u = u.substring(0, u.indexOf('/sitepages/'));\n }\n if (u.endsWith(\".aspx\")) {\n u = u.substring(0, u.lastIndexOf('/'));\n }\n return u;\n }", "title": "" }, { "docid": "aa79d7c70705687d47f3575f0a31a882", "score": "0.5680622", "text": "function toAbsolute(relativePath) { \n //const url = new URL(url[, base])\n var absoluteURL = new URL(relativePath, document.baseURI).href\n // console.log(absoluteURL);\n return absoluteURL;\n//=> \"https://stackoverflow.com/questions/mypath\"\n}", "title": "" }, { "docid": "cfb7a16e3e0503a5f22965ed6a0c65cf", "score": "0.56650025", "text": "function determineURLBase() {\n if (SEQUENCE_VIEWER_CONFIGURATION.bigWigConfig.url)\n return SEQUENCE_VIEWER_CONFIGURATION.bigWigConfig.url;\n if (SEQUENCE_VIEWER_CONFIGURATION.bigWigConfig.folder)\n return '/viewer/files/';\n}", "title": "" }, { "docid": "61930870903f0967f3726b453d7f2e58", "score": "0.56605047", "text": "function makeRelativeToFile(url) {\n intellisense.progress();\n\n var scriptFilePath = intellisense.executingScriptFileName;\n if (typeof scriptFilePath === 'undefined') {\n return url;\n }\n\n var startPath;\n if (url.indexOf('/') === 0) {\n // If the url is absolute the start path is the \n // root path of the project or website.\n startPath = _$requirejs_rootPath;\n } else if (isBaseUrlDefined || _$requirejs_dataMain === \"\") {\n // Else if a baseUrl has been user defined, or no\n // data-main path was specified, the start path will be\n // the location of the HTML page that loads RequireJS.\n startPath = _$requirejs_startPagePath;\n } else {\n // Otherwise the start path is specified\n // in the data main attribute.\n startPath = _$requirejs_dataMainPath;\n }\n\n // The start path should never be undefined or empty.\n // If it is return the original url.\n if (typeof startPath === \"undefined\" || startPath === \"\") {\n return url;\n }\n\n var i;\n var scriptPath = normalize(startPath.substr(0, startPath.lastIndexOf(\"/\") + 1) + url);\n var scriptParts = scriptPath.split('\\\\');\n var currentParts = scriptFilePath.toLowerCase().split('\\\\');\n\n for (i = 1; i < currentParts.length; i++) {\n if (currentParts[i] !== scriptParts[i]) {\n break;\n }\n }\n\n var prefix = \"\";\n var baseUrl = scriptParts.slice(i, scriptPath.length - 1).join('/');\n var dots = currentParts.length - 1 - i;\n\n if (dots === 0) {\n prefix = \"./\";\n } else {\n for (i = 0 ; i < dots; i++) {\n prefix += \"../\";\n }\n }\n\n return prefix + baseUrl;\n }", "title": "" }, { "docid": "274bc3f7fcf1cb6c80ad5617e3c81d5d", "score": "0.565997", "text": "function cf_getUrl(){\n\tvar arr = location.pathname.split('/');\n\tif(arr[arr.length-1].length < 1) arr.pop();\n\tarr.pop();\n\treturn location.protocol + '//' + location.host + arr.join('/') + '/';\n}", "title": "" }, { "docid": "747e09df4cb4b7096b71d8033fbbba10", "score": "0.56567645", "text": "url() {\n return this.baseUrl+this.name;\n }", "title": "" }, { "docid": "4d53d7b148486226b6b012667608ce03", "score": "0.56461996", "text": "getFullUrl() {\n try{\n return window.location.href;\n } catch(e){\n return 'https://iliketurtles.com/?state=87fc3814-4cb9-43a5-b723-63ecebd65c5a,cdc3d520-8b74-46ac-9f4c-8f27d04ab49f&view=eli';\n }\n }", "title": "" }, { "docid": "f3cf5bdd3f696389054b0eb25a7812ff", "score": "0.5637846", "text": "function toAbsoluteUrl(candidateUrl) {\n return new Promise(function (resolve) {\n if (Object(__WEBPACK_IMPORTED_MODULE_0__pnp_common__[\"m\" /* isUrlAbsolute */])(candidateUrl)) {\n // if we are already absolute, then just return the url\n return resolve(candidateUrl);\n }\n if (SPRuntimeConfig.baseUrl !== null) {\n // base url specified either with baseUrl of spfxContext config property\n return resolve(Object(__WEBPACK_IMPORTED_MODULE_0__pnp_common__[\"d\" /* combine */])(SPRuntimeConfig.baseUrl, candidateUrl));\n }\n if (global$1._spPageContextInfo !== undefined) {\n // operating in classic pages\n if (Object(__WEBPACK_IMPORTED_MODULE_0__pnp_common__[\"j\" /* hOP */])(global$1._spPageContextInfo, \"webAbsoluteUrl\")) {\n return resolve(Object(__WEBPACK_IMPORTED_MODULE_0__pnp_common__[\"d\" /* combine */])(global$1._spPageContextInfo.webAbsoluteUrl, candidateUrl));\n }\n else if (Object(__WEBPACK_IMPORTED_MODULE_0__pnp_common__[\"j\" /* hOP */])(global$1._spPageContextInfo, \"webServerRelativeUrl\")) {\n return resolve(Object(__WEBPACK_IMPORTED_MODULE_0__pnp_common__[\"d\" /* combine */])(global$1._spPageContextInfo.webServerRelativeUrl, candidateUrl));\n }\n }\n // does window.location exist and have a certain path part in it?\n if (global$1.location !== undefined) {\n var baseUrl_1 = global$1.location.toString().toLowerCase();\n [\"/_layouts/\", \"/siteassets/\"].forEach(function (s) {\n var index = baseUrl_1.indexOf(s);\n if (index > 0) {\n return resolve(Object(__WEBPACK_IMPORTED_MODULE_0__pnp_common__[\"d\" /* combine */])(baseUrl_1.substr(0, index), candidateUrl));\n }\n });\n }\n return resolve(candidateUrl);\n });\n}", "title": "" }, { "docid": "c2387a238d9ddf589f2967dd85c5798a", "score": "0.56318", "text": "getProjectUrlProps(project) {\n const org = this.props.organization;\n const path = `/${org.slug}/${project.slug}/`;\n\n if (this.context.location) {\n return {to: path};\n } else {\n return {href: path};\n }\n }", "title": "" }, { "docid": "7f1628b2447752e8e37ec92acc783843", "score": "0.5630817", "text": "makeAbsoluteLink(...paths) {\n return (this.config.publicUrl.replace(/\\/$/, '') +\n path_1.join(this.endpointPrefix, ...paths));\n }", "title": "" }, { "docid": "7a24013ca9d06ed44a7663ac10e49e71", "score": "0.56297904", "text": "function makeAbsolute(url) {\n\tvar a = document.createElement('a');\n\ta.href = url;\n\treturn a.href;\n}", "title": "" }, { "docid": "3cbe72b96487d0d22f708fbec5606f9e", "score": "0.5627478", "text": "function createClientSideURL(location, base) {\n if (base === undefined && typeof window !== 'undefined') {\n var _window, _window$location;\n // window.location.origin is \"null\" (the literal string value) in Firefox\n // under certain conditions, notably when serving from a local HTML file\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=878297\n base = ((_window = window) == null ? void 0 : (_window$location = _window.location) == null ? void 0 : _window$location.origin) !== 'null' ? window.location.origin : window.location.href;\n }\n var url = new URL(location.toString(), base);\n url.hash = '';\n return url;\n }", "title": "" }, { "docid": "006c4829f315806c336335def1e459d4", "score": "0.56222093", "text": "function _get_url(els) {\n return basepath + els.join('/');\n}", "title": "" }, { "docid": "1e7665d04413b0b4606a9730fa044df7", "score": "0.5616684", "text": "function toAbsoluteUrl(candidateUrl) {\r\n return new Promise(function (resolve) {\r\n if (Object(_pnp_common__WEBPACK_IMPORTED_MODULE_0__[\"isUrlAbsolute\"])(candidateUrl)) {\r\n // if we are already absolute, then just return the url\r\n return resolve(candidateUrl);\r\n }\r\n if (_splibconfig__WEBPACK_IMPORTED_MODULE_1__[\"SPRuntimeConfig\"].baseUrl !== null) {\r\n // base url specified either with baseUrl of spfxContext config property\r\n return resolve(Object(_pnp_common__WEBPACK_IMPORTED_MODULE_0__[\"combine\"])(_splibconfig__WEBPACK_IMPORTED_MODULE_1__[\"SPRuntimeConfig\"].baseUrl, candidateUrl));\r\n }\r\n if (global._spPageContextInfo !== undefined) {\r\n // operating in classic pages\r\n if (Object(_pnp_common__WEBPACK_IMPORTED_MODULE_0__[\"hOP\"])(global._spPageContextInfo, \"webAbsoluteUrl\")) {\r\n return resolve(Object(_pnp_common__WEBPACK_IMPORTED_MODULE_0__[\"combine\"])(global._spPageContextInfo.webAbsoluteUrl, candidateUrl));\r\n }\r\n else if (Object(_pnp_common__WEBPACK_IMPORTED_MODULE_0__[\"hOP\"])(global._spPageContextInfo, \"webServerRelativeUrl\")) {\r\n return resolve(Object(_pnp_common__WEBPACK_IMPORTED_MODULE_0__[\"combine\"])(global._spPageContextInfo.webServerRelativeUrl, candidateUrl));\r\n }\r\n }\r\n // does window.location exist and have a certain path part in it?\r\n if (global.location !== undefined) {\r\n var baseUrl_1 = global.location.toString().toLowerCase();\r\n [\"/_layouts/\", \"/siteassets/\"].forEach(function (s) {\r\n var index = baseUrl_1.indexOf(s);\r\n if (index > 0) {\r\n return resolve(Object(_pnp_common__WEBPACK_IMPORTED_MODULE_0__[\"combine\"])(baseUrl_1.substr(0, index), candidateUrl));\r\n }\r\n });\r\n }\r\n return resolve(candidateUrl);\r\n });\r\n}", "title": "" }, { "docid": "f3976e4f15262d3a8ebd4510fa615f12", "score": "0.5614329", "text": "function toAbsoluteUrl(candidateUrl) {\r\n return new Promise(function (resolve) {\r\n if (_pnp_common__WEBPACK_IMPORTED_MODULE_1__[\"Util\"].isUrlAbsolute(candidateUrl)) {\r\n // if we are already absolute, then just return the url\r\n return resolve(candidateUrl);\r\n }\r\n if (SPRuntimeConfig.baseUrl !== null) {\r\n // base url specified either with baseUrl of spfxContext config property\r\n return resolve(_pnp_common__WEBPACK_IMPORTED_MODULE_1__[\"Util\"].combinePaths(SPRuntimeConfig.baseUrl, candidateUrl));\r\n }\r\n if (typeof global._spPageContextInfo !== \"undefined\") {\r\n // operating in classic pages\r\n if (global._spPageContextInfo.hasOwnProperty(\"webAbsoluteUrl\")) {\r\n return resolve(_pnp_common__WEBPACK_IMPORTED_MODULE_1__[\"Util\"].combinePaths(global._spPageContextInfo.webAbsoluteUrl, candidateUrl));\r\n }\r\n else if (global._spPageContextInfo.hasOwnProperty(\"webServerRelativeUrl\")) {\r\n return resolve(_pnp_common__WEBPACK_IMPORTED_MODULE_1__[\"Util\"].combinePaths(global._spPageContextInfo.webServerRelativeUrl, candidateUrl));\r\n }\r\n }\r\n // does window.location exist and have a certain path part in it?\r\n if (typeof global.location !== \"undefined\") {\r\n var baseUrl_1 = global.location.toString().toLowerCase();\r\n [\"/_layouts/\", \"/siteassets/\"].forEach(function (s) {\r\n var index = baseUrl_1.indexOf(s);\r\n if (index > 0) {\r\n return resolve(_pnp_common__WEBPACK_IMPORTED_MODULE_1__[\"Util\"].combinePaths(baseUrl_1.substr(0, index), candidateUrl));\r\n }\r\n });\r\n }\r\n return resolve(candidateUrl);\r\n });\r\n}", "title": "" }, { "docid": "0a56e95395c45f40a868a702fedd8b53", "score": "0.5611974", "text": "function absoluteURL(url)\n{\n if (!feed.baseURL) {\n return url;\n }\n\n var baseURL = feed.baseURL.protocol + \"://\" + feed.baseURL.domain;\n // if it is absolute within the domain\n if (url.indexOf(\"/\") == 0) url = baseURL + url;\n // if it is relative to the current resorce\n else url = baseURL + \"/\" + feed.baseURL.resource + url;\n return url;\n}", "title": "" }, { "docid": "80ca3e0bf87f47eec98533ffb9ac054c", "score": "0.55984044", "text": "function generateURL()\n{\n\tvar url = '?c=';\n\t\n\tfor(i = 1; i <= 8; i++)\n\t\turl += getComp('group' + i);\n\t\n\t$('#link').attr('href', url);\n}", "title": "" }, { "docid": "cf79f494a9d8bc17198af4d1ad0ca3dc", "score": "0.5587782", "text": "function buildUrlProductLink(page, queryObj) {\r\n return page + \"?\" + $.param(queryObj);\r\n }", "title": "" }, { "docid": "a3e33fd73359b0550fd4d624d567935a", "score": "0.55863696", "text": "function genPageUrl(page) {\n\n var queryStr = window.location.search;\n var pageParamStr = \"page=\" + page;\n\n if (queryStr.length > \"page=\".length && 0 < queryStr.indexOf(\"page=\")){ //the string has at least \"?page=\"\n var queryParams = queryStr.substring(1).split('&');\n queryStr = \"\";\n for (var i = 0; i < queryParams.length; i++) { // reassambling without page param\n if (queryParams[i] && queryParams[i].indexOf(\"page=\")) queryStr = queryStr + (queryStr?\"&\":\"\") + queryParams[i];\n }\n } else if (0 < queryStr.length) queryStr = queryStr.substring(1); //removing leading \"?\"\n\n queryStr = \"?\" + pageParamStr + (queryStr?\"&\":\"\") + queryStr;\n\n return window.location.protocol + \"//\" + window.location.hostname\n + (window.location.port ? (\":\" + window.location.port) : \"\")\n + window.location.pathname\n + queryStr\n + window.location.hash;\n }", "title": "" }, { "docid": "7576b254bae40c104f26d6f29c352766", "score": "0.5575719", "text": "function baseURL(accountIndex) {\n\tvar firstPart = '';\n\tvar secondPart = '';\n\tif (isMobile()) {\n\t\tfirstPart = 'https://mail.google.com/mail/mu/mp/';\n\t\tsecondPart = '#tl/search/';\n\t} else {\n\t\tfirstPart = 'https://mail.google.com/mail/u/';\n\t\tsecondPart = '/#search/';\n\t}\n\n\tvar url = firstPart + accountIndex + secondPart;\n\treturn url;\n}", "title": "" }, { "docid": "863c2b902cab535eea5a2ea51c30804a", "score": "0.5574536", "text": "function makeUrl() {\n var url;\n if (projectid !== \"null\" && status !== \"null\" && country !== \"null\") {\n url = \"http://\" + location.host + \"/adminpanel/projects/\" + projectid + '/' + status + '/' + country;\n } else {\n if (projectid === \"null\") {\n alert(\"Please select project id !\")\n } else if (country === \"null\") {\n alert(\"Please select country !\")\n } else if (status === \"null\") {\n alert(\"Please select status !\")\n }\n }\n return url;\n }", "title": "" }, { "docid": "ebda1c7956f3240c348712978c48978a", "score": "0.5571843", "text": "function buildConfiguredURL() {\n var numQuestions = $(\"#num-questions-input\").find(\":selected\").val();\n var category = $(\"#category-input\").find(\":selected\").val();\n var difficulty = $(\"#difficulty-input\").find(\":selected\").val();\n var type = $(\"#type-input\").find(\":selected\").val();\n\n var url = BASE_URL + \"?\";\n url += \"amount=\" + numQuestions + \"&\";\n url += \"category=\" + category + \"&\";\n url += \"difficulty=\" + difficulty + \"&\";\n url += \"type=\" + type;\n\n console.log(url);\n return url;\n}", "title": "" }, { "docid": "868d626506ed69cb6a28a10e24d54935", "score": "0.5564431", "text": "function buildURL(file) {\n\t\t\t\tif (device.platform.toLowerCase() === \"android\") {\n\t\t\t\t\tvar $androidFile = \"/android_asset/www/\" + file;\n\t\t\t\t\treturn $androidFile;\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "c48fbf716837ae598248444ca534bf34", "score": "0.55587786", "text": "function makeRelative(location) {\n\t\tif (!location) {\n\t\t\treturn location;\n\t\t}\n\t\tvar hostName = window.location.protocol + \"//\" + window.location.host; //$NON-NLS-0$\n\t\tif (location.indexOf(hostName) === 0) {\n\t\t\treturn location.substring(hostName.length);\n\t\t}\n\t\treturn location;\n\t}", "title": "" }, { "docid": "c699421a45ae04e5fd9a765dcc6d33b2", "score": "0.5551291", "text": "function getAbsolutePath() {\n var loc = window.location;\n var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);\n return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));\n}", "title": "" }, { "docid": "496a753144623c55077e09dd5c7c8ab0", "score": "0.5549139", "text": "static __createUrl(url,base){return new URL(url,base)}", "title": "" }, { "docid": "4d58216380694550c912e8f19da64676", "score": "0.55306023", "text": "getUrl() {\n var _a;\n const routerLink = (_a = this.routerLink) !== null && _a !== void 0 ? _a : this.routerLinkWithHref;\n return routerLink\n ? this.router.serializeUrl(routerLink.urlTree)\n : undefined;\n }", "title": "" }, { "docid": "c3092bc413bb841b07686657e3abe3f5", "score": "0.553018", "text": "function _buildURL(root, options){\n var ret = \"?\", k, v, first=true;\n var opts = $.extend({}, options, CoreDefaults);\n for(o in opts){\n k = o;\tv = opts[o];\n ret += (first?\"\":\"&\")+k+\"=\"+v;\n first=false;\n }\n return root + ret;\n }", "title": "" }, { "docid": "06fcf28d726866814995e369e8887f23", "score": "0.55183977", "text": "function getURL() {\n return window.location.href.toString();\n}", "title": "" }, { "docid": "7dff256599c0dc751a6a5f560eb330a8", "score": "0.55182123", "text": "function getBase() {\r\n\r\n if (location.href.indexOf('http://local') != -1) {\r\n return '//localhost/Archive/2002/';\r\n } else {\r\n return '//www.radlohead.com/';\r\n }\r\n\r\n}", "title": "" }, { "docid": "66bd16ce3e3c651b1589f329a98deef3", "score": "0.55167955", "text": "getURL() {\n return new URL(this.root.location.href)\n }", "title": "" }, { "docid": "585d0178591fa045bf11759826d5b748", "score": "0.55139947", "text": "function buildUrl(config) {\n function getParamUrl(v) {\n if (typeof v === 'boolean' && !v) {\n return '';\n }\n return v;\n }\n var clean = \"\" + SCRIPTLETURLPREFIX_ + config.currentUrlSearchFragment.substring(0, config.currentUrlSearchFragment.indexOf(\"&\" + ROUTEPARAMNAME_ + \"=\")) + \"&\" + ROUTEPARAMNAME_ + \"=\" + config.routeName;\n var newParams = clean + \"&\" + Object.keys(config.params).map(function (p) { return p + \"=\" + getParamUrl(config.params[p]); }).join('&');\n return newParams;\n }", "title": "" }, { "docid": "d57b2c56ead699c3a656d7096dc99149", "score": "0.5509276", "text": "_buildUrl(spec, extension) {\n return super._buildUrl(spec, extension)\n }", "title": "" }, { "docid": "205b57d95bbf8e9561109faefe4388ec", "score": "0.55076903", "text": "function buildURL(plugin, id, tabs, width, height, cover, small_header, friends) {\n\tvar url = \"\";\n\turl = plugin + id + '&' + tabs + '&' + 'width=' + width + '&' + 'height=' + height + '&' + cover + '&' + small_header + '&' + friends;\n\tconsole.log(url);\n\treturn url;\n}", "title": "" }, { "docid": "a3564af2fc8c45cf562a7cf6efb9952c", "score": "0.54910135", "text": "function getNewURL() {\n\n // Standardize SAT/ACT\n // take larger score and standardize\n if (act.property(\"value\") == 0 && sat.property(\"value\") == 0) {\n admissionstest = 0;\n } else if (sat.property(\"value\") != 0 && act.property(\"value\") == 0) {\n admissionstest = (sat.property(\"value\") - means.admissionstest) / stds.admissionstest;\n } else if (sat.property(\"value\") == 0 && act.property(\"value\") != 0) {\n admissionstest = (act2sat[act.property(\"value\")] - means.admissionstest) / stds.admissionstest;\n } else {\n if (sat.property(\"value\") > act2sat[act.property(\"value\")]) {\n admissionstest = (sat.property(\"value\") - means.admissionstest) / stds.admissionstest;\n } else {\n admissionstest = (act2sat[act.property(\"value\")] - means.admissionstest) / stds.admissionstest;\n }\n }\n\n // Standardize GPA, Average AP, and SAT2\n var gpaValue = (gpa.property(\"value\") - means.GPA) / stds.GPA;\n var apaveValue = (apave.property(\"value\") - means.averageAP) / stds.averageAP;\n var sat2aveValue = (sat2ave.property(\"value\") - means.SATsubject) / stds.SATsubject;\n var minority = 0;\n if (race.property(\"value\") > 0) {\n minority = 1;\n }\n\n // Construct New URL\n var result_url = url.replace(\"{TEST}\", admissionstest)\n .replace(\"{GPA}\", gpaValue)\n .replace(\"{AP}\", apnum.property(\"value\"))\n .replace(\"{APAVE}\", apaveValue)\n .replace(\"{SAT2}\", sat2aveValue)\n .replace(\"{HS}\", hs.property(\"value\"))\n .replace(\"{GENDER}\", gender.property(\"value\"))\n .replace(\"{MINOR}\", minority);\n return result_url;\n }", "title": "" }, { "docid": "af5bba0d069440ff554781bfc67186ec", "score": "0.54888105", "text": "static getRestaurantURL(restaurant) {\r\n // return `./restaurant.html?id=${restaurant.id}`\r\n return `restaurant.html?id=${restaurant.id}`\r\n }", "title": "" }, { "docid": "38d6c88c6e663198508ea06786bdc5d8", "score": "0.54850817", "text": "function updateRoomURL() {\n\t\troomURL.innerHTML = '<a href=' + window.location.href + '>' + window.location.href + '</a>';\n\t\tconsole.log('Updated URL is: ' + url);\n\t}", "title": "" }, { "docid": "ca1a1b250174c059d6687ead9dfb66d9", "score": "0.5477506", "text": "createUrl() {\n let url = this.url;\n url += `?callback=${this.CALLBACK}`;\n if (this.apiKey) {\n url += `&key=${this.apiKey}`;\n }\n if (this.channel) {\n url += `&channel=${this.channel}`;\n }\n if (this.client) {\n url += `&client=${this.client}`;\n }\n if (this.libraries.length > 0) {\n url += `&libraries=${this.libraries.join(\",\")}`;\n }\n if (this.language) {\n url += `&language=${this.language}`;\n }\n if (this.region) {\n url += `&region=${this.region}`;\n }\n if (this.version) {\n url += `&v=${this.version}`;\n }\n if (this.mapIds) {\n url += `&map_ids=${this.mapIds.join(\",\")}`;\n }\n return url;\n }", "title": "" }, { "docid": "0ec34b9a9458cb8b33375a417bdcea15", "score": "0.5473531", "text": "toUrl() {\n return this._url;\n }", "title": "" }, { "docid": "0ec34b9a9458cb8b33375a417bdcea15", "score": "0.5473531", "text": "toUrl() {\n return this._url;\n }", "title": "" }, { "docid": "864ef3247d30d2a215107bdb41efa93f", "score": "0.54666024", "text": "function getNavURL(targetLoc) {\n\tvar baseURL = 'https://www.google.com/maps/dir/?api=1&',\n\t\tlat = encodeURI(targetLoc.Latitude),\n\t\tlon = encodeURI(targetLoc.Longitude);\n\treturn baseURL + 'destination=' + lat + ',' + lon;\n}", "title": "" }, { "docid": "4b3ec114c19fb006c1171d67e4f2d882", "score": "0.5465645", "text": "createUrl() {\n const storageKey = 'gl-window-config-' + (0,_utils_utils__WEBPACK_IMPORTED_MODULE_2__.getUniqueId)();\n const config = _config_resolved_config__WEBPACK_IMPORTED_MODULE_4__.ResolvedLayoutConfig.minifyConfig(this._config);\n try {\n localStorage.setItem(storageKey, JSON.stringify(config));\n }\n catch (e) {\n throw new Error('Error while writing to localStorage ' + (0,_utils_utils__WEBPACK_IMPORTED_MODULE_2__.getErrorMessage)(e));\n }\n const url = new URL(location.href);\n url.searchParams.set('gl-window', storageKey);\n return url.toString();\n }", "title": "" }, { "docid": "521abe076f1bd2e6c3fd60f9829a946c", "score": "0.5464184", "text": "getCurrentDayUrl(){\n // constants for the REST URL\n const period = 'period=P1D' // set to get the full day's data\n\n // builds variable strings\n let parameterString = `parameterCd=${this.parameter}`;\n let siteString = `sites=${this.gage}`\n\n // concatenates url parts \n let url = `${this.base_url}?${this.format}`; // base url\n url = url + `&${siteString}`; // site code\n url = url + `&${period}`; // period of time code\n url = url + `&${parameterString}`; // parameter codes\n url = url + `&${this.siteStatus}`; // site status\n\n // returns the url\n return url;\n }", "title": "" }, { "docid": "7f21fca5f924ffc76da4796d4a1d93af", "score": "0.54622686", "text": "buildURL(modelName, id, snapshot, requestType, query){\n\t\t\n\t\treturn `http://localhost:4040/api/v1/project`;\n }", "title": "" }, { "docid": "f11394dbe992dfdfd44a3a8d17a187b4", "score": "0.5461428", "text": "function abs(uri) {\n var a = _Global.document.createElement(\"a\");\n a.href = uri;\n return a.href;\n }", "title": "" }, { "docid": "8d32c606ebc825839df81b9d5cb343a4", "score": "0.5457548", "text": "function getBaseURL() {\n return window.location.href.replace(/map.html/gi, '');\n }", "title": "" }, { "docid": "ca16e956e5f8122b5158cc0d1d1aab6f", "score": "0.5456946", "text": "function getUrl() {\n // let url = locatino.url + \"id\";\n // return url\n}", "title": "" }, { "docid": "ce2527c2e2e423ad8ec08ab89cfab1b2", "score": "0.54500866", "text": "get url() {\n var root = paths.api.root;\n\n return root + this.path;\n }", "title": "" }, { "docid": "875011d94a02c7c75187464ebb2f2086", "score": "0.54481536", "text": "setLocationFromHref() {\n const { hashbanged, hashbangPrefix } = this.configuration;\n const parser = document.createElement('a');\n parser.href = window.location.href;\n const baseUrl = hashbanged ? parser.hash.replace(hashbangPrefix, '')\n : parser.pathname;\n this.location = {\n path: baseUrl.startsWith('/') ? baseUrl : `/${baseUrl}`,\n url: hashbanged ? parser.hash : parser.pathname,\n pattern: baseUrl.startsWith('/') ? baseUrl : `/${baseUrl}`,\n params: this.getState(),\n sender: '',\n };\n }", "title": "" }, { "docid": "08cb154982cfe6ce0d46cfaef66b080f", "score": "0.544799", "text": "function buildurl(input) {\n return input ? `'${input}'`.replace(/([^:]\\/)\\/+/g, '$1') : '';\n}", "title": "" }, { "docid": "058423a6d9e39e8ddffb5e81cb155cd0", "score": "0.5445781", "text": "updateURL() {\n\t\t// convert main inputs to binary\n\t\tlet encodedW = (+BOARD.width).toString(2).padStart(12, '0');\n\t\tlet encodedH = (+BOARD.height).toString(2).padStart(12, '0');\n\t\tlet encodedS = (+BOARD.squareSize).toString(2).padStart(12, '0');\n\t\t// convert to b64\n\t\tlet encodedMain = this.encodeOne(encodedH.substring(0, 6)) \n\t\t\t+ this.encodeOne(encodedH.substring(6, 12))\n\t\t\t+ this.encodeOne(encodedW.substring(0, 6)) \n\t\t\t+ this.encodeOne(encodedW.substring(6, 12))\n\t\t\t+ this.encodeOne(encodedS.substring(0, 6)) \n\t\t\t+ this.encodeOne(encodedS.substring(6, 12));\n\n\t\tconst newURL = window.location.href.split('?')[0] \n\t\t\t+ '?r=' + UI.encodeRules()\n\t\t\t+ '&a=' + UI.encodeAnts()\n\t\t\t+ '&m=' + encodedMain\n\t\t\t+ ((BOARD.wrap) ? '&p=' : '');\n $('#url-text').html(newURL);\n \n this.updateHaskell();\n\n\t\treturn newURL;\n\t}", "title": "" }, { "docid": "00e8a06d5ada5497a72b2899f6ec03da", "score": "0.54448164", "text": "url (file) {\n return path.abs(file);\n }", "title": "" }, { "docid": "b5374b165f524ae87068cc305c9fcb13", "score": "0.54315484", "text": "function makeURL(toolchain, config) {\n return 'index.html?tc=' + toolchain + '&config=' + config;\n}", "title": "" }, { "docid": "2bf29ef430180b152fd99a610bd3cd1e", "score": "0.5431167", "text": "function directUrl(directProjectId) {\n return `${WEBSITE}/direct/projectOverview.action?formData.projectId=${directProjectId}`;\n}", "title": "" }, { "docid": "5c69064d6e00830007b9e394f4538e46", "score": "0.5426076", "text": "function buildUrl ( url, parameters ) {\r\n \t\tvar href = \"\";\r\n \t\tvar qs = \"\";\r\n \t\tfor(var key in parameters) {\r\n \t\t\tvar value = parameters[key];\r\n \t\t\tqs += encodeURIComponent(key) + \"=\" + encodeURIComponent(value) + \"&\";\r\n \t\t}\r\n \t\tif (qs.length > 0) {\r\n \t\t\tqs = qs.substring(0, qs.length-1); \r\n \t\t\thref = url + \"?\" + qs;\r\n \t\t}\r\n \t\treturn href;\r\n \t}", "title": "" } ]
f660297f62f5cca0099fcbdc6e9ab10a
update pacman's coordinates on drag
[ { "docid": "74e5f8d9fd05e889cefb4ee437855ba5", "score": "0.6830191", "text": "function dragMove(d) {\n d3.select(this)\n .attr(\"x\", d3.event.x - settings.pacmanRadius)\n .attr(\"y\", d3.event.y - settings.pacmanRadius);\n}", "title": "" } ]
[ { "docid": "6ffc9201f63eba58bf98c60d950e918b", "score": "0.67474836", "text": "move(cursors) {\n //for geting to the other side\n const current_tile = layer_for_pacman.getTileAtWorldXY(this.pac.x, this.pac.y, true);\n if (current_tile.x == 27 && current_tile.y == 14) {\n this.pac.x = 420;\n this.pac.y = 312;\n return {\n \"x\": this.pac.x, \"y\": this.pac.y, \"is_veloX\": false, \"is_veloY\": false,\n \"velo\": 0, \"angle\": this.pac.angle\n }\n }\n else if (current_tile.x == 0 && current_tile.y == 14) {\n this.pac.x = 830;\n this.pac.y = 312;\n return {\n \"x\": this.pac.x, \"y\": this.pac.y, \"is_veloX\": false, \"is_veloY\": false,\n \"velo\": 0, \"angle\": this.pac.angle\n }\n }\n //pacman's velocity when reacting to key pressed\n var velo = 75;\n //pacman goes left \n if (cursors.left.isDown) {\n this.pac.setVelocityX(-velo);\n this.pac.setVelocityY(0);\n this.pac.angle = 180;\n this.fix_position(false, true);\n if (this.pac.y == 108)\n this.pac.y = 105\n return {\n \"x\": this.pac.x, \"y\": this.pac.y, \"is_veloX\": true, \"is_veloY\": false,\n \"velo\": -velo, \"angle\": this.pac.angle\n };\n }\n //pacman goes right\n else if (cursors.right.isDown) {\n this.pac.setVelocityX(velo);\n this.pac.setVelocityY(0);\n this.pac.angle = 0;\n this.fix_position(false, true);\n if (this.pac.y == 108)\n this.pac.y = 105\n return {\n \"x\": this.pac.x, \"y\": this.pac.y, \"is_veloX\": true, \"is_veloY\": false,\n \"velo\": velo, \"angle\": this.pac.angle\n };\n }\n //pacman goes up\n else if (cursors.up.isDown) {\n this.pac.setVelocityX(0);\n this.pac.setVelocityY(-velo);\n this.pac.angle = 270;\n this.fix_position(true, false);\n return {\n \"x\": this.pac.x, \"y\": this.pac.y, \"is_veloX\": false, \"is_veloY\": true,\n \"velo\": -velo, \"angle\": this.pac.angle\n };\n }\n //pacman goes down \n else if (cursors.down.isDown) {\n this.pac.setVelocityX(0);\n this.pac.setVelocityY(velo);\n this.pac.angle = 90;\n this.fix_position(true, false);\n return {\n \"x\": this.pac.x, \"y\": this.pac.y, \"is_veloX\": false, \"is_veloY\": true,\n \"velo\": velo, \"angle\": this.pac.angle\n };\n }\n return {\n \"x\": this.pac.x, \"y\": this.pac.y, \"is_veloX\": false, \"is_veloY\": false,\n \"velo\": 0, \"angle\": this.pac.angle\n };\n\n }", "title": "" }, { "docid": "9580287375a8afaf627a1c2f7cb6a1ff", "score": "0.6536268", "text": "updateCoordonate(newCoordonate) {\r\n this.x = newCoordonate.x;\r\n this.y = newCoordonate.y;\r\n }", "title": "" }, { "docid": "32dcbdd807d8075cb38180b4de74853c", "score": "0.65149665", "text": "function updatePositionPacman(){\n let direction = pacman.direction;\n let x = pacman.j;\n let y = pacman.i;\n if (typeof direction !== 'undefined'){\n board_objects[pacman.i][pacman.j] = 0;\n if (y>0 && direction === up_key && board_static[--y][x] !== 1){\n pacman.i--;\n }\n else if (y<19 && direction===down_key && board_static[++y][x]!==1 && board_static[y][x]!==2){\n pacman.i++;\n }\n else if (x>0 && direction===left_key && board_static[y][--x]!==1){\n pacman.j--;\n }\n else if (x<16 && direction===right_key && board_static[y][++x]!==1){\n pacman.j++;\n }\n }\n\n board_objects[pacman.i][pacman.j] = 3;\n\n updateScore();\n draw();\n}", "title": "" }, { "docid": "f2d9b88570aaf90df54f76cd0c51b792", "score": "0.64309263", "text": "function setPosition() {\n // direction in Rad. Generally, 1 Rad stands for 100km\n var current_rotate = map.getBearing();\n if (!manual && Math.random() > 0.95) {\n // direction += (Math.random() - 0.5) /5;\n }\n \n point.coordinates[0] += drone.speed * Math.sin(drone.direction) / 100;\n point.coordinates[1] += drone.speed * Math.cos(drone.direction) / 100;\n\n current_rotate = (-current_rotate) + drone.direction * (180 / Math.PI);\n\n if (featureCol.features.length>0){\n featureCol.features[0].geometry = point;\n featureCol.features[0].properties.name = drone.name;\n featureCol.features[0].properties.rotate = current_rotate;\n featureCol.features[0].properties.life = drone.life;\n }\n // update other drones status.\n updateDrones();\n map.getSource('drone').setData(featureCol);\n if (miniMap && miniMap.getSource(\"drone\") && featureCol){\n miniMap.getSource(\"drone\").setData(featureCol);\n miniMap.getSource(\"myDrone\").setData(point);\n }\n // map.setLayoutProperty('drone', 'icon-rotate', current_rotate);\n\n \n if (window.locking) {\n if (miniMap) {\n miniMap.setCenter(point.coordinates);\n }\n map.flyTo({\n center: point.coordinates,\n });\n // console.warn('calc current_rotate in deg: ' + current_rotate, \" cur_drone_direction: \"+ direction);\n }\n\n // sync Mydrone status..\n drone.point = point;\n // console.log(\"drone direction: \" + drone.direction);\n\n // Update ChatPopup lnglat.\n var lnglat = point.coordinates.concat();\n updatePopUp(lnglat);\n}", "title": "" }, { "docid": "562e2750bb2ebe252b69e4be98c9c083", "score": "0.6195875", "text": "function update() { \n console.log('idate')\n featureElement.attr('d', path);\n //Move Circles when Map moves\n }", "title": "" }, { "docid": "0b85f02921db48fd122696c37304c559", "score": "0.6194125", "text": "update(){\r\n\t\tlet p;\r\n\t\tthis.pnts.reset();\r\n\t\tfor( p of this.points ) this.pnts.add( p.pos, p.color, p.size, p.shape );\r\n\t\tthis.updated = false;\r\n\t}", "title": "" }, { "docid": "4d9b14ebf14390425e7ccdf230d82282", "score": "0.6178701", "text": "update(dt) {\n if(this.isSelfDragging) {\n this.pos = { x: Game.selfMousePos.x + this._dragOffset.x, y: Game.selfMousePos.y + this._dragOffset.y };\n }\n else if(this.isOtherDragging) {\n this.pos = { \n x: Game.otherMousePosSmooth.x + this._dragOffset.x, \n y: Game.otherMousePosSmooth.y + this._dragOffset.y \n };\n }\n }", "title": "" }, { "docid": "ec4a3d6e84aa6e8f4a19955b3e9f7109", "score": "0.61599493", "text": "set DragUpdated(value) {}", "title": "" }, { "docid": "aa0e8c49b71c6b082a841d735f01f022", "score": "0.61559886", "text": "function mapPan(x, y) {\n $G.viewBox.x += x;\n $G.viewBox.y += y;\n}", "title": "" }, { "docid": "dc61ac109413b6c9e8ffaf8cd1f125bd", "score": "0.6153958", "text": "updateLoc(x, y) {\n\t\tthis.pos.set(x, y);\n\t}", "title": "" }, { "docid": "20665bd7bd86fa09e6a61d2cc766621c", "score": "0.6138012", "text": "function move() {\n // get the location of the cursor in the SVG element\n let Ps = d3.mouse(this); // screen coodinates\n // let Pw = stereographic.invert( Ps ) // map coordinates\n // let Pc = [ rightAscensionScale.invert(Pw[0]), Pw[1] ]; // celestial coodinates\n // ascension.html( Pc[0] );\n // declination.html( Pc[1] );\n if( moved )\n moved( Ps );\n }", "title": "" }, { "docid": "452aef63412475be0e2c1ab677c2387a", "score": "0.61078644", "text": "function dragmove(d) {\n var dx = d3.event.x - d.px;\n var dy = d3.event.y - d.py;\n if (d.fixed & 1) {\n force.nodes().forEach(function(node) {\n if (node.fixed & 1) {\n node.px += dx;\n node.py += dy;\n // Also set x,y for when force updating is turned off\n node.x = node.px;\n node.y = node.py;\n }\n });\n } else {\n d.px += dx;\n d.py += dy;\n // ditto\n d.x = d.px;\n d.y = d.py;\n }\n redraw();\n force.resume();\n }", "title": "" }, { "docid": "a8cbf9cee0028ec7374f59b5aa6ca64b", "score": "0.6100551", "text": "function onMove(e) {\n if (!isDragging) return;\n var coords = e.lngLat;\n\n // Set a UI indicator for dragging.\n canvas.style.cursor = 'grabbing';\n\n // Update the Point feature in `geojson` coordinates\n // and call setData to the source layer `point` on it.\n geojson.features[0].geometry.coordinates = [coords.lng, coords.lat];\n\tlongitudeOnMap = coords.lng;\n\tlatitudeOnMap = coords.lat;\n map.getSource('point').setData(geojson);\n\tmap.getSource('source_circle_500').setData(geojson);\n}", "title": "" }, { "docid": "4b09c6f1743684b50905c901d40983d6", "score": "0.61001927", "text": "move() {\n this.angleX = map(mouseX, 0, width, -4 * PI, 4 * PI, true);\n this.angleY = map(mouseY, 0, height, -4 * PI, 4 * PI, true);\n this.angle = this.angleX * (this.x / width) + this.angleY * (this.y / height);\n this.dropletX = this.x + 20 * cos(2 * PI * this.t + this.angle);\n this.dropletY = this.y + 20 * sin(2 * PI * this.t + this.angle);\n }", "title": "" }, { "docid": "56a2f80c15b02ed0462acb7def32bb71", "score": "0.6075654", "text": "function updatePos() {\n mContainer.css(\"left\", (mPos.x + settings.shiftMap.x_px) + \"px\");\n mContainer.css(\"top\", (mPos.y + settings.shiftMap.y_px) + \"px\");\n }", "title": "" }, { "docid": "9422bf0a68d16d8d5ce7fef7e9327fd1", "score": "0.60587656", "text": "function updateLocation( dx, dy ) {\n var new_latitude = lat + (dy / r_earth) * (180 / Math.PI);\n var new_longitude = lon + (dx / r_earth) * (180 / Math.PI) / Math.cos(lat * Math.PI/180);\n lat = new_latitude;\n lon = new_longitude;\n}", "title": "" }, { "docid": "1e713ff74328dda45720e8d2f1bdfa3f", "score": "0.60535187", "text": "function mousemove(event) {\r\n view.longitude = originalLongitude - (event.offsetX - originalX) * 0.5;\r\n view.latitude = originalLatitude + (event.offsetY - originalY) * 0.5;\r\n updateCanvas();\r\n }", "title": "" }, { "docid": "18f3f232bc8cebd0dcabb788a580b9d6", "score": "0.6037567", "text": "function onDragMove(){\n if(this.dragging){\n var newPosition = this.data.getLocalPosition(this.parent);\n this.x = newPosition.x - (this.clickOffset.x * container.scale.x);\n this.y = newPosition.y - (this.clickOffset.y * container.scale.y);\n }\n}", "title": "" }, { "docid": "ee2a83885b48ad8e8ba53bfe88ba1597", "score": "0.60359246", "text": "updateOld() {\n this.oldCoordinates.x = this.coordinates.x;\n this.oldCoordinates.y = this.coordinates.y;\n }", "title": "" }, { "docid": "26615ad33fb947f140887806fdcb133d", "score": "0.6026207", "text": "function updatePosition() {\n robot.curr_x = new_x;\n robot.curr_y = new_y;\n robot.curr_orientation = new_orientation;\n}", "title": "" }, { "docid": "6a7634c892efecd3a46ef3c1d9ae64e5", "score": "0.5988624", "text": "updateOld() {\n this.oldCoordinates.x = this.coordinates.x;\n this.oldCoordinates.y = this.coordinates.y;\n }", "title": "" }, { "docid": "6f1a2b429fd49306c9d998308ef00e69", "score": "0.59885645", "text": "function updatePosition(p) {\n p.x += (p.v.x * DT) * p$.M_TO_CM;\n p.y += (p.v.y * DT) * p$.M_TO_CM;\n }", "title": "" }, { "docid": "826f2e17c394a63b2278d0e2859eec02", "score": "0.5984442", "text": "updatePosition() {\n this.translation = this.modelViewTransform.modelToViewPosition( this.shapePiece.positionProperty.value );\n }", "title": "" }, { "docid": "bfca2504d92e2bd5c1301dd9c1856efe", "score": "0.5961179", "text": "function move () {\n // get pacman's location info\n var x = pacman.x;\n var y = pacman.y;\n var xu = Math.ceil(pacman.x);\n var yu = Math.ceil(pacman.y);\n var xd = Math.floor(pacman.x);\n var yd = Math.floor(pacman.y);\n\n // should pacman be teleported\n testIfTeleport(x, y);\n\n // if changing direction\n if (nextState != moveState) {\n switch (nextState) {\n case 1:\n // don't move on non int value\n if (y % 1 !== 0) {\n break;\n }\n // changing from right to left\n if (x % 1 !== 0) {\n pacman.x -= vel;\n moveState = nextState;\n return;\n }\n // changing from vertical to horizontal\n if (!(level[x - 1][yu] <= 0 || level[x - 1][yd] <= 0)) {\n moveState = nextState;\n pacman.x -= vel;\n eatFood();\n return;\n }\n break;\n\n case 2:\n // don't move on non int value\n if (x % 1 !== 0) {\n break;\n }\n // changing from right to left\n if (y % 1 !== 0) {\n pacman.y -= vel;\n moveState = nextState;\n return;\n }\n // changing from vertical to horizontal\n if (!(yu <= 0 || level[xu][y - 1] <= 0 || level[xd][y - 1] <= 0)) {\n moveState = nextState;\n pacman.y -= vel;\n eatFood();\n return;\n }\n break;\n\n case 3:\n // don't move on non int value\n if (y % 1 !== 0) {\n break;\n }\n // changing from right to left\n if (x % 1 !== 0) {\n pacman.x += vel;\n moveState = nextState;\n return;\n }\n // changing from vertical to horizontal\n if (!(xd >= s.cols - 1 || level[x + 1][yd] <= 0 || level[x + 1][yu] <= 0)) {\n moveState = nextState;\n pacman.x += vel;\n eatFood();\n return;\n }\n break;\n\n case 4:\n // don't move on non int value\n if (x % 1 !== 0) {\n break;\n }\n // changing from right to left\n if (y % 1 !== 0) {\n pacman.y += vel;\n moveState = nextState;\n return;\n }\n // changing from vertical to horizontal\n if (!(yd >= s.rows - 1 || level[xd][y + 1] <= 0 || level[xu][y + 1] <= 0)) {\n moveState = nextState;\n pacman.y += vel;\n eatFood();\n return;\n }\n break;\n }\n }\n\n if (moveState === 0) { return; }\n\n // testing if pacman can still move\n switch (moveState) {\n // a pressed\n case 1:\n if (x % 1 !== 0) {\n pacman.x -= vel;\n return;\n } else if (xd === 0) {\n if (x - vel >= 0) {\n pacman.x -= vel;\n } else {\n lastState = moveState;\n moveState = 0;\n }\n\n return;\n } else if (level[x - 1][yu] <= 0 || level[x - 1][yd] <= 0) {\n lastState = moveState;\n moveState = 0;\n return;\n }\n pacman.x -= vel;\n break;\n\n // w pressed\n case 2:\n if (y % 1 !== 0) {\n pacman.y -= vel;\n return;\n }\n if (yu <= 0 || level[xu][y - 1] <= 0 || level[xd][y - 1] <= 0) {\n lastState = moveState;\n moveState = 0;\n return;\n }\n\n pacman.y -= vel;\n break;\n\n // d pressed\n case 3:\n if (x % 1 !== 0) {\n pacman.x += vel;\n return;\n }\n if (xu === s.cols - 1) {\n // added for array\n eatFood();\n\n if (x + vel <= s.cols - 1) {\n pacman.x += vel;\n } else {\n lastState = moveState;\n moveState = 0;\n }\n return;\n }\n if (xd >= s.cols - 1 || level[x + 1][yd] <= 0 || level[x + 1][yu] <= 0) {\n lastState = moveState;\n moveState = 0;\n return;\n }\n pacman.x += vel;\n break;\n\n // s pressed\n case 4:\n if (y % 1 !== 0) {\n pacman.y += vel;\n return;\n }\n if (yd >= s.rows - 1 || level[xd][y + 1] <= 0 || level[xu][y + 1] <= 0) {\n lastState = moveState;\n moveState = 0;\n return;\n }\n pacman.y += vel;\n break;\n\n default:\n console.log(\"This shouldn't display move!\");\n }\n\n // test if eat food or power up\n eatFood();\n}", "title": "" }, { "docid": "c9d9dc60b74cc936232ae64d6973a103", "score": "0.5948947", "text": "function updateMarkerCordinates() {\n var self = this;\n $scope.marker = {\n id: 0,\n coords: {\n latitude: self.coords.latitude,\n longitude: self.coords.longitude\n },\n options: {\n draggable: true\n }\n };\n }", "title": "" }, { "docid": "502c0a385c9973f6a94826bd464e53e4", "score": "0.5924693", "text": "function pan(dx, dy) {\n\t\tx += dx * radius;\n\t\ty += dy * radius;\n\t\trefresh();\n\t}", "title": "" }, { "docid": "073727db83334f88de3b9df12df2197a", "score": "0.59200597", "text": "updatePos(x, y) {\n this.x = x;\n this.y = y;\n }", "title": "" }, { "docid": "bfc0e3bc8a161c7ab924d3bba198c270", "score": "0.5883869", "text": "updatePosition (x, y) {\n this.x = x;\n this.y = y;\n }", "title": "" }, { "docid": "e29bc0d6952ea9fd5df23d89d7de5b23", "score": "0.58820033", "text": "function updatePosition(O){\n O.x += O.dx;\n O.y += O.dy;\n }", "title": "" }, { "docid": "3a6cd7effb79935b175826eed6426ba8", "score": "0.58793503", "text": "move() {\n this.x += this.deltaX;\n this.y += this.deltaY;\n }", "title": "" }, { "docid": "dd02d40b548885b882ead1387d63c840", "score": "0.5862058", "text": "onDragMove(data) {\n this.dragZone.dragMove(data);\n }", "title": "" }, { "docid": "d2bd8f212cf578dfaa0587ccb964a285", "score": "0.5860717", "text": "move() {\n this.whiteBloodCell.translate(this.velocity);\n this.point = this.point.add(this.velocity);\n }", "title": "" }, { "docid": "30233dda390a0f5cfe23f07660752025", "score": "0.5853449", "text": "function updatePoint(){\n\t\tcurretPoints\t=\tcurretPoints + POINT;\n\t\tpointsField.innerHTML\t=\tcurretPoints;\n\t}", "title": "" }, { "docid": "8b15aad4f5e41475aa3a5a552c13d7f1", "score": "0.5848072", "text": "update(delta) {\n super.update(delta);\n let object = this.room.findNearestGameObjectBelowPoint(this.x, this.y, this);\n\n if (!object ) {\n return;\n }\n \n if (object.constructor.name === Pole.name || object.constructor.name === PoleTop.name) {\n this.x = object.x;\n }\n }", "title": "" }, { "docid": "a0b0132046ac9d55ad398afe9824758c", "score": "0.5847449", "text": "function move() {\n if (mDragging.isDragging == false) {\n var dx = settings.pos.x - mPos.x; //replaced in this projecct by settins.pos\n var dy = settings.pos.y - mPos.y; //replaced in this projecct by settins.pos\n\n //var dx=mTarget.x-mPos.x; //replaced in this projecct by settins.pos\n //var dy=mTarget.y-mPos.y; //replaced in this projecct by settins.pos\n //console.log(dx+\" \"+dy);\n\n var vectorLength = Math.sqrt(dx * dx + dy * dy);\n\n if (vectorLength > 5) {\n //normalize to equal speed\n var speed = 5;//5 pixel per update --> 10 pixel per second\n dx = (dx / vectorLength) * speed;\n dy = (dy / vectorLength) * speed;\n }\n\n mPos.x = mPos.x + dx;\n mPos.y = mPos.y + dy;\n\n dx = mLastSendPos.x - mPos.x;\n dy = mLastSendPos.y - mPos.y;\n var dist = Math.sqrt(dx * dx + dy * dy);\n if (dist > 100) {\n mLastSendPos.x = mPos.x;\n mLastSendPos.y = mPos.y;\n if (settings.onMove != undefined) {\n settings.onMove(settings.name, mPos.x, mPos.y);\n }\n }\n updatePos();\n }\n }", "title": "" }, { "docid": "e692b22da792b545081158567865e013", "score": "0.58467627", "text": "function ondrag(x,y,but,cmd,shift,capslock,option,ctrl)\n{\n\t\t\tvar moveknob = true;\n\t\tmousex = sketch.screentoworld(x,y)[0];\n\t\tmousey = sketch.screentoworld(x,y)[1];\n\n\tmousedist = computedist(mousex,mousey,knobpos[selectedknob],knobpos[selectedknob+1]);\n\tif(moveknob){\n\tknobpos[selectedknob] = mousex;\n\tknobpos[selectedknob+1] = mousey;\n\t}\n\n\tbang();\n}", "title": "" }, { "docid": "91ad7f342d30200b33f3fe2bbb1b4494", "score": "0.58456606", "text": "function moveDown() {\n pacman.direction = 'down';\n if (gameData[pacman.y+1][pacman.x] !== WALL) {\n gameData[pacman.y][pacman.x] = GROUND;\n pacman.y = pacman.y + 1 ;\n // gameData[pacman.y][pacman.x] = PACMAN;\n }\n}", "title": "" }, { "docid": "be78e3f4589025254788141bff3eb394", "score": "0.5835592", "text": "updateTeleportedPosition(data) {\n this.setState({ currentPosition: data });\n }", "title": "" }, { "docid": "c3b775ec1391743465e2adcff16abadf", "score": "0.5835321", "text": "move() {\n this.posX += this.deltaX;\n this.posY += this.deltaY;\n }", "title": "" }, { "docid": "c3b775ec1391743465e2adcff16abadf", "score": "0.5835321", "text": "move() {\n this.posX += this.deltaX;\n this.posY += this.deltaY;\n }", "title": "" }, { "docid": "b774a560f9ea5dcb348b4fc53b1b7679", "score": "0.58337826", "text": "function movePacman() {\n\n if (play == \"True\") {\n \n \n \n //move the pacman\n if (moveComplete == \"True\") {\n \n if (pacManx == 0 && direction != \"right\"){\n pacManx = 1050;\n }else if(pacManx == 1050){\n pacManx = -gridSize;\n }\n \n switch (direction) {\n case \"up\":\n\n checkMove();\n\n if (pacCheck == \"False\") {\n break;\n }\n\n //calculate new pack man position\n newPacMany = pacMany - gridSize;\n newPacManx = pacManx;\n\n pacMany = pacMany - 10;\n lastTrueDirection = \"up\";\n\n moveComplete = \"False\";\n\n break;\n case \"down\":\n\n checkMove();\n\n if (pacCheck == \"False\") {\n break;\n }\n\n //calculate new pack man position\n newPacMany = pacMany + gridSize;\n newPacManx = pacManx;\n\n pacMany = pacMany + 10;\n lastTrueDirection = \"down\";\n\n moveComplete = \"False\";\n\n break;\n case \"left\":\n\n checkMove();\n\n if (pacCheck == \"False\") {\n break;\n }\n\n //calculate new pack man position\n newPacManx = pacManx - gridSize;\n newPacMany = pacMany;\n\n pacManx = pacManx - 10;\n lastTrueDirection = \"left\";\n\n moveComplete = \"False\";\n\n break;\n case \"right\":\n\n checkMove();\n\n if (pacCheck == \"False\") {\n break;\n }\n\n //calculate new pack man position\n newPacManx = pacManx + gridSize;\n newPacMany = pacMany;\n\n pacManx = pacManx + 10;\n lastTrueDirection = \"right\";\n\n moveComplete = \"False\";\n\n break;\n default:\n //this shouldnt happen\n }\n } else if (moveComplete == \"False\") {\n\n if (pacManx == newPacManx && pacMany == newPacMany) {\n moveComplete = \"True\";\n movePacman();\n } else {\n switch (lastTrueDirection) {\n case \"up\":\n\n pacMany = pacMany - 10;\n\n break;\n case \"down\":\n\n pacMany = pacMany + 10;\n break;\n case \"left\":\n\n pacManx = pacManx - 10;\n\n break;\n case \"right\":\n\n pacManx = pacManx + 10;\n\n\n default:\n //this shouldnt happen\n }\n }\n }\n\n\n }\n}", "title": "" }, { "docid": "6609c177f79f660cd1e664995929b2a1", "score": "0.58327335", "text": "move() {\n this.posX += this.deltaX;\n this.posY += this.deltaY;\n }", "title": "" }, { "docid": "146fea8b888ef692684d41ed8e9d7086", "score": "0.5827663", "text": "function mcPourDragMoveListener(event) {\n var target = event.target,\n //Keep the dragged position in the data-x/data-y attributes.\n x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,\n y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;\n \n var cylinderType = (target.getAttribute('id').includes('50') ? measuringcylinder50 : measuringcylinder10);\n \n //If the element's \"inDropzone\" data-attribute is set to true, when moved we translate the element normally, however allow the new tilting\n if (target.dataset.inDropzone == 'true') {\n target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px) rotate(80deg)';\n } else {\n //Otherwise, we translate the element with a 45degree tilt. This is so it suggests to the user that it needs to be poured.\n target.style.webkitTransform = target.style.transform = 'translate(' + x + 'px, ' + y + 'px)' + (cylinderType.state.shouldPour ? 'rotate(45deg)' : '');\n }\n //Update the posiion attributes.\n target.setAttribute('data-x', x);\n target.setAttribute('data-y', y);\n}", "title": "" }, { "docid": "94852bf09da9430b179e9f1b5d4bce3c", "score": "0.58120626", "text": "function mouseDragged(){\r\n if(dist(mouseX, mouseY, planet1_x, planet1_y) <= planet1_r/2){\r\n planet1_x = mouseX;\r\n planet1_y = mouseY;\r\n }\r\n\r\n else if(dist(mouseX, mouseY, planet2_x, planet2_y) <= planet2_r/2){\r\n planet2_x = mouseX;\r\n planet2_y = mouseY;\r\n }\r\n\r\n else if(dist(mouseX, mouseY, planet3_x, planet3_y) <= planet3_r/2){\r\n planet3_x = mouseX;\r\n planet3_y = mouseY;\r\n }\r\n }", "title": "" }, { "docid": "d190826882664551e50ed3a1fc02cd49", "score": "0.5790595", "text": "function positionUpdater(player, oldY, oldX) {\n mapArrays[player.y + oldY][player.x + oldX].playerHere = false;\n mapArrays[player.y][player.x].playerHere = true;\n }", "title": "" }, { "docid": "7296400478050d01a48a48c20f749a73", "score": "0.57804704", "text": "move () {\n let curr_x;\n let curr_y;\n if (this.dir == 'L') {\n curr_x = this.location[0][0] - offset;\n curr_y = this.location[0][1];\n } else if (this.dir == 'R') {\n curr_x = this.location[0][0] + offset;\n curr_y = this.location[0][1];\n } else if (this.dir == 'U') {\n curr_x = this.location[0][0];\n curr_y = this.location[0][1] - offset;\n } else if (this.dir == 'D') {\n curr_x = this.location[0][0];\n curr_y = this.location[0][1] + offset;\n } \n\n // After move unshift location\n this.location.unshift([curr_x, curr_y])\n }", "title": "" }, { "docid": "a5c25600c0368ce1eeceef403f5d2b69", "score": "0.5780031", "text": "move(){\n this.x += this.velocite.x;\n this.y += this.velocite.y;\n }", "title": "" }, { "docid": "985b18e117f7c5cee0026abc1c5dafd6", "score": "0.5774086", "text": "update() {\n this.goTheWayWereFacing();\n this.constrainToMap();\n }", "title": "" }, { "docid": "af668a57c0eefbfc080df82d2f5176ff", "score": "0.5770299", "text": "changeCoordinates(data) {\n\t\tthis.location_x = parseFloat(data[0]);\n\t\tthis.location_y = parseFloat(data[1]);\n\t}", "title": "" }, { "docid": "df83f95beef5d8b0bd04440a80194912", "score": "0.57691884", "text": "function onUp(e) {\n if (!isDragging) return;\n var coords = e.lngLat;\n\tsendAjaxRequest();\n // Print the coordinates of where the point had\n // finished being dragged to on the map.\n\t// TODO tu zavolat query na hladane veci\n\tconsole.log('Longitude: ' + coords.lng + '<br />Latitude: ' + coords.lat);\n canvas.style.cursor = '';\n isDragging = false;\n}", "title": "" }, { "docid": "3d399ca3b72f07a491e640a1c5aebc37", "score": "0.57691395", "text": "update() {\n if (!this.dragging) {\n this.angle += this.aVel\n this.aVel += this.aAcc\n this.aVel *= this.damping\n this.aAcc = 0.33 / this.arm * cos(this.angle)\n }\n}", "title": "" }, { "docid": "d0085c63c281731fca9a996478384070", "score": "0.57621753", "text": "update() {\n if(this.variables.isPositionChanged) {\n this.variables.isPositionChanged = false;\n this.owner.x = this.variables.positionX;\n this.owner.y = this.variables.positionY;\n }\n if(this.variables.isRotationChanged) {\n this.variables.isRotationChanged = false;\n this.owner.rotation = this.variables.rotation;\n }\n if(this.variables.isAlphaChanged) {\n this.variables.isAlphaChanged = false;\n this.owner.alpha = this.variables.alpha;\n }\n if(this.variables.isScaleChanged) {\n this.variables.isScaleChanged = false;\n this.owner.scaleX = this.variables.scaleX;\n this.owner.scaleY = this.variables.scaleY;\n }\n if(this.variables.isFilterChanged) {\n this.variables.isFilterChanged = false;\n this.owner.updateCache();\n }\n }", "title": "" }, { "docid": "7e999b47b317ab04b276cbea0b7e3a05", "score": "0.57605785", "text": "function drag() {\r\n\tif (gamestate === \"inhand\") {\r\n\t\tif (num1 === 1) {\r\n\t\t\tMatter.Body.setPosition(stone1.body, { x: mouseX, y: mouseY });\r\n\t\t}\r\n\t}\r\n}", "title": "" }, { "docid": "c51c5b624a2753b6e081f116259cfe4e", "score": "0.5758518", "text": "change(newCoord) {\r\n let { coord } = this;\r\n coord.x = newCoord.x;\r\n coord.y = newCoord.y;\r\n }", "title": "" }, { "docid": "ee6b4d51c28cb69569a11800618b3c4d", "score": "0.5751391", "text": "moveKudosOnBoard() {\n for (let i = 0, length = this.data.kudoses.length; i < length; i = i + 1) {\n if (this.data.kudoses[i].id === this.dragObject.avatar.dataset.id) {\n this.data.kudoses[i].coordinates = this.dragObject.avatar.coordinates;\n }\n }\n }", "title": "" }, { "docid": "4f106133c26d35a43654d29951a87733", "score": "0.574774", "text": "move(new_position){\n this.position.x = new_position.x;\n this.position.y = new_position.y;\n }", "title": "" }, { "docid": "8b0086f9b72982a3132d25337bf5a452", "score": "0.5738198", "text": "update() {\n this.location.add(this.velocity);\n\t}", "title": "" }, { "docid": "8c0020c69e445036c07307d6f349a0a9", "score": "0.5737823", "text": "drift() {\n this.posX = this.posX + this.deltaX;\n this.posY = this.posY + this.deltaY;\n }", "title": "" }, { "docid": "6a089d53201eba7ccf6e1e2ac489ee11", "score": "0.5735752", "text": "updatePointerPos(event) {\n\t\tconst offset = this.canvasElement.getBoundingClientRect();\n\t\tconst xZoom = this.canvasElement.width / this.canvasElement.clientWidth;\n\t\tconst yZoom = this.canvasElement.height /this.canvasElement.offsetHeight;\n\t\t// Maybe this should be a struct instead of an array?\n\t\tif (!this.settings.stabilizer.enabled) {\n\t\t\tthis.lastPos = this.currentPos;\n\t\t}\n\t\tthis.currentPos = [\n\t\t\t(event.clientX - offset.left) * xZoom,\n\t\t\t(event.clientY - offset.top) * yZoom\n\t\t];\n\t}", "title": "" }, { "docid": "73f7202cedf23c1e520e5ee372bd78e9", "score": "0.5734978", "text": "function movePlane() {\n // Calculate the distance between mouse and plane in X and in Y\n let xDistance = mouseX - plane.x;\n let yDistance = mouseY - plane.y;\n // Add a percentage of the x and y distance to the plane's current (x,y) location\n // based on current lag\n plane.x = plane.x + xDistance/(plane.lag*4);\n plane.y = plane.y + yDistance/(plane.lag*4);\n}", "title": "" }, { "docid": "660049deea63238a51d5df4a95d57821", "score": "0.5734763", "text": "worldeditDrag() {\n\t\tlet mouseStart = [0, 0];\n\t\tlet holding = false;\n\t\tlet pos = [0, 0];\n\t\tlet currentPos = [0, 0];\n\t\tlet moveEvery = 30;\n\t\tlet movement = 0;\n\n\t\tthis.editView.world.addEventListener(\"mousedown\", (event) => {\n\t\t\tif (this.editView.mode == \"drag\") {\n\t\t\t\tholding = true;\n\t\t\t\tmouseStart = [event.clientX, event.clientY];\n\t\t\t\tthis.editView.world.style.cursor = \"grabbing\";\n\n\t\t\t\tpos = this.editView.world.style.transform.split(\", \");\n\t\t\t\tpos[0] = parseInt(pos[0].split(\"(\").pop());\n\t\t\t\tpos[1] = parseInt(pos[1]);\n\t\t\t\tthis.editView.world.style.transform = `translate(${pos[0]}px, ${pos[1]}px)`;\n\t\t\t}\n\t\t});\n\n\t\tthis.editView.world.addEventListener(\"mousemove\", (event) => {\n\t\t\tif (holding && this.editView.mode == \"drag\" && movement == 0) {\n\t\t\t\tcurrentPos = [pos[0] + event.clientX - mouseStart[0], pos[1] + event.clientY - mouseStart[1]];\n\t\t\t\tthis.editView.world.style.transform = `translate(${currentPos[0]}px, ${currentPos[1]}px)`;\n\t\t\t}\n\t\t\tmovement = movement < moveEvery ? movement + 1 : 0;\n\t\t});\n\n\t\tdocument.addEventListener(\"mouseup\", () => {\n\t\t\tif (holding) {\n\t\t\t\tholding = false;\n\t\t\t\tthis.editView.world.style.cursor = \"grab\";\n\t\t\t\tpos = [currentPos[0], currentPos[1]];\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "3d17302e09955111a1a45c0041ccec93", "score": "0.5732995", "text": "updatePos() {\n this.particle_obj.position.set(this.posX, this.posY, this.posZ);\n }", "title": "" }, { "docid": "49f10672bbceb1e72c6a76baf5453f4c", "score": "0.57269114", "text": "function updatePosition(latLng) {\n\n jQuery('#CoordenadaX').val(latLng.lat());\n jQuery('#CoordenadaY').val(latLng.lng());\n\n}", "title": "" }, { "docid": "17724c8bbb2aa21baaff5e85ac13d501", "score": "0.57256556", "text": "function update_coordinates()\n\t{\n\t\tif ( point !== null && sprite !== null ) {\n\t\t\tvar module = point.getPosition();\n\n\t\t\tposition.x = module.x + sprite.x._;\n\t\t\tposition.y = module.y + sprite.y._;\n\t\t}\n\t}", "title": "" }, { "docid": "04b285ac7eebeb0d608f0fdafb2d137a", "score": "0.5715644", "text": "get DragUpdated() {}", "title": "" }, { "docid": "841483df95ff16376604cc681fbbb195", "score": "0.5712114", "text": "function updatePoint() {\n mapView.graphics.removeAll();\n //create a new map point\n var mapPoint = new Point({\n x: mainView.center.x,\n y: mainView.center.y,\n z: mainView.center.z,\n spatialReference: 102100\n });\n\n pointGraphic = new Graphic({\n geometry: mapPoint,\n symbol: pointSymbol,\n });\n\n mapView.graphics.add(pointGraphic);\n }", "title": "" }, { "docid": "918fba7181132d95a17c61d32b726401", "score": "0.57067466", "text": "function update_position() {\n\tg.selectAll(\".nodes\").attr(\"x\", function (d) {return d.x;}).attr(\"y\", function (d) {return d.y;});\n\tg.selectAll(\"circle\").attr(\"cx\", function (d) {return d.x;}).attr(\"cy\", function (d) {return d.y;});\n\tg.selectAll(\"image\").attr(\"x\", function (d) {return d.x-d.r;}).attr(\"y\", function (d) {return d.y-d.r;});\n\tg.selectAll(\".name\").attr(\"x\", function (d) {return d.x;}).attr(\"y\", function (d) {return d.y;});\n\tg.selectAll(\".button\").attr(\"x\", function (d) { return d.x }).attr(\"y\", function (d) { return d.y - d.r -5});\n\te.selectAll(\".edges\").select(\"line\")\n\t\t.attr(\"x1\", function(d) {return d.source.x; })\n\t\t.attr(\"y1\", function(d) {return d.source.y;})\n\t\t.attr(\"x2\", function(d) {return d.dest.x;})\n\t\t.attr(\"y2\", function(d) {return d.dest.y;});\n}", "title": "" }, { "docid": "b9e4686007e97f6e11f352065c31f8b8", "score": "0.5705286", "text": "positionChange_() {\n const position = this.panorama_.getPosition();\n const newCoordinates = this.fromLonLat_([position.lng(), position.lat()]);\n super.panoramaPositionChange(newCoordinates);\n }", "title": "" }, { "docid": "bdbd5c337804f185a58ef3e26e66322c", "score": "0.56990457", "text": "updatePos (dt) {\n let pos = {};\n pos.x = this.x; pos.y = this.y;\n let dp = util.vector.multiply(dt, this.getVelocity(dt)); //Change in position by product of dt and velocity (update velocity at same time)\n pos = util.vector.add(pos, dp);\n this.x = pos.x;\n this.y = pos.y;\n }", "title": "" }, { "docid": "1847383916d8d1961a378baf1de729fe", "score": "0.56960684", "text": "function dragmove(d) {\n if( !draggable )\n return;\n d.x += d3.event.dx;\n d.y += d3.event.dy;\n updateSVG(d.x, d.y);\n G.attr(\"transform\",\"translate(\" + d.x + \",\" + d.y + \")\");\n for(var i = 0; i < links.length; ++i)\n links[i].update();\n }", "title": "" }, { "docid": "4a7e3e11d186ff7a449291e9e6b3027d", "score": "0.56957316", "text": "move(position){\n this.position.x = position.x;\n this.position.y = position.y;\n }", "title": "" }, { "docid": "c1b7118be0c65d39950de2f9302d4b35", "score": "0.5692979", "text": "updateLocationWithVector() {\n this.x += this.vector.velX;\n this.y += this.vector.velY;\n this.boundingCircle.setLocationWithVector(this.vector.velX, this.vector.velY);\n if(this.radar) this.radar.setLocationWithVector(this.vector.velX, this.vector.velY);\n }", "title": "" }, { "docid": "c7a65b9e771cee5c1d38db586826f5ad", "score": "0.56875753", "text": "move() {\n // update constraints and planets properties if asked by the user\n if (this.options.resizable === true) {\n this.counter += 1;\n if (this.counter >= 25) {\n // The position of the origin\n this.pos.x = this.c.width * this.options.position.x;\n this.pos.y = this.c.height * this.options.position.y;\n\n // Compute constraints\n this.computeConstraints();\n\n // Update planets properties\n this.updatePlanets();\n this.counter = 0;\n }\n }\n\n // Move planets\n for (let i = 0; i < this.planets.length; i += 1) {\n this.planets[i].move();\n }\n }", "title": "" }, { "docid": "35dfe007a426f613d3112f762f1cf5bf", "score": "0.56811917", "text": "function updatePoints() {\r\n //Loop through points array\r\n\t\tfor(var i = 0; i < points.length; i++) {\r\n //Calculate velocity in both x and y directions\r\n var p = points[i],\r\n vx = (p.x - p.oldx) * friction;\r\n vy = (p.y - p.oldy) * friction;\r\n //update positions\r\n\t\t\tp.oldx = p.x;\r\n\t\t\tp.oldy = p.y;\r\n\t\t\tp.x += vx;\r\n p.y += vy;\r\n //Don't forget about gravity\r\n if(p.ghost == false)\r\n p.y += gravity;\r\n else if(p.ghost == true)\r\n {\r\n //p.y -= gravity * .2;\r\n if(p.y < height/2)\r\n {\r\n p.y += gravity * .1;\r\n }\r\n if(p.y > height/2)\r\n {\r\n p.y -= gravity * .1;\r\n }\r\n\r\n p.x += 0.05;\r\n }\r\n\r\n //On top of stonehedge apply wind if cannonball\r\n if(p.x > (width/2 - 75) && p.x < (width/2 + 100) && p.ghost == false)\r\n {\r\n p.x += wind();\r\n }\r\n //If ghost goes out of bounds to the right\r\n if(p.x > width && p.x < width + 5 && p.ghost == true && p.name ==1)\r\n {\r\n makeGhost(Math.random() * 500 + 20, height - Math.random() * 200);\r\n }\r\n\t\t}\r\n }", "title": "" }, { "docid": "4d76bc84b124bf5baa629e6e9e6afbb6", "score": "0.5680394", "text": "function posRecalculate() {\n\t\t\t\n\t\t\tupdateMaxLightboxHeight();\n\t\t\t\n\t\t\tvar frame = getBoxFrame();\n\t\t\t\n\t\t\tvar framePos = getBoxFrame().position();\n\t\t\t\n\t\t\tvar fieldWidth = $(window).width() - frame.width();\n\t\t\tvar fieldLeftPx = fieldWidth / 100 * dragPercPos.left;\n\t\t\t\t\t\t\t\n\t\t\tvar fieldHeight = $(window).height() - frame.height();\n\t\t\tvar fieldTopPx = fieldHeight / 100 * dragPercPos.top;\n\t\t\t\t\t\t\t\n\t\t\tframe.css({\n\t\t\t\tleft: fieldLeftPx,\n\t\t\t\ttop: fieldTopPx\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "a539c7bded01cd90e1ea45e70dd6a868", "score": "0.5677164", "text": "function updateUp(){\n\tyCord=yCord-1;\n\tif(yCord<0){\n\t\tyCord = 0;\n\t}\n\tdrawMap();\t\n}", "title": "" }, { "docid": "d161c324e59ad449fb1d2ab558b4e72f", "score": "0.5672381", "text": "drag(x, y) {\n this.doDrag(x, y);\n }", "title": "" }, { "docid": "404d5ce771e8994c02a1167b48e7d8d4", "score": "0.5671854", "text": "onDrag(e) {\n e.dataTransfer.setData(\"piece\", this)\n e.dataTransfer.setData(\"initcoords\", this.props.coords)\n let moves = this.validMoves()\n this.props.highlightSpaces(moves);\n }", "title": "" }, { "docid": "57e733b02fafe278ea16842879a0176b", "score": "0.5666845", "text": "function dragstarted(d) {\n if (!d3.event.active) simulation.alphaTarget(0.3).restart();\n d.fx = d.x;\n d.fy = d.y;\n }", "title": "" }, { "docid": "76bbbcf0940c532cf627b1b7e2d6ba8b", "score": "0.5658851", "text": "onDrag(element, event, ui) {\n var currentElementPositions = this.state.positions[element];\n if (currentElementPositions){\n var newPositionData = {};\n newPositionData[element] = {\n x: currentElementPositions.x + ui.x,\n y: currentElementPositions.y + ui.y\n };\n // persist element position.\n User.setElementsPositions(newPositionData);\n }\n\n }", "title": "" }, { "docid": "fc11a26f7228c4cd7d9a184f01205f39", "score": "0.5654161", "text": "function dragstarted(event, d) {\n\t\t\t// console.log(d);\n\t\t\tif (!event.active) vis.simulation.alphaTarget(.03).restart();\n\t\t\td.fx = d.x;\n\t\t\td.fy = d.y;\n\t\t}", "title": "" }, { "docid": "67cb691695b4e53127c8892933f2546b", "score": "0.5651503", "text": "setPosition(x, y) {\r\n this.data.x = x;\r\n this.data.y = y;\r\n }", "title": "" }, { "docid": "0b4a16a1081a10bb4a6a0e780c58b524", "score": "0.5650928", "text": "update(){\n if(!this.done){\n this.x += this.dx;\n this.y += this.dy;\n if(this.aim > 0){\n if(this.dx < 0){\n this.dx = this.dx + 0.03;\n }\n else if(this.dx < 0){\n this.dx = this.dx - 0.03;\n }\n if(this.dy < 0 && !this.done){\n this.dy = this.dy + 0.03;\n }\n if(this.dy > 0){\n this.dy = 0;\n this.done = true;\n }\n }\n if(this.aim === 0){\n if(this.dy < 0 && !this.done){\n this.dy = this.dy + 0.03;\n }\n if(this.dy > 0){\n this.dy = 0;\n this.done = true;\n }\n }\n if(this.aim < 0){\n if(this.dx > 0){\n this.dx = this.dx + 0.03;\n }\n if(this.dy < 0 && !this.done){\n this.dy = this.dy + 0.03;\n }\n if(this.dy > 0){\n this.dy = 0;\n this.done = true;\n }\n }\n }\n }", "title": "" }, { "docid": "bcbd747bd64f918e3e41e2ed41c88e5e", "score": "0.56498575", "text": "doDrag(pointer)\n {\n if (typeof this.dragObj != \"undefined\")\n {\n this.dragObj.x = pointer.x;\n this.dragObj.y = pointer.y;\n }\n }", "title": "" }, { "docid": "80614dbf7aec20f7f7dc3aff6b620440", "score": "0.56460404", "text": "function udpateMapCordinates() {\n var self = this;\n $scope.map = {\n id: parseInt(Math.expm1(Math.random()).toString().slice('2')),\n zoom: 12,\n center: {\n latitude: self.coords.latitude,\n longitude: self.coords.longitude\n },\n options: {\n draggable: true\n },\n bounds: {},\n scrollwheel: false,\n markersEvents: {\n click: function(marker, eventName, model, arguments) {\n console.log('Marker was clicked (' + marker + ', ' + eventName);\n $scope.map.window = {\n model: model,\n title: model.name,\n show: true,\n coords: model.coords,\n template: model.template\n };\n }\n },\n window: {\n coords: {},\n marker: {},\n show: false,\n closeClick: function() {\n this.show = false;\n },\n options: {}, // define when map is ready\n title: ''\n }\n };\n }", "title": "" }, { "docid": "459141657cf32c9db81a827a0ea6e6a5", "score": "0.5645144", "text": "adjustPosition(x, y) {\r\n this.x += x;\r\n this.y += y;\r\n }", "title": "" }, { "docid": "c90cf1e99442810bfb8179a093322e44", "score": "0.56447464", "text": "function dragstarted(d) {\n if (!d3.event.active) simulation.alphaTarget(.03).restart();\n d.fx = d.x;\n d.fy = d.y;\n }", "title": "" }, { "docid": "c90cf1e99442810bfb8179a093322e44", "score": "0.56447464", "text": "function dragstarted(d) {\n if (!d3.event.active) simulation.alphaTarget(.03).restart();\n d.fx = d.x;\n d.fy = d.y;\n }", "title": "" }, { "docid": "b7f9e3a30eebffa1210dd4885105bc52", "score": "0.5640633", "text": "move(){\r\n\r\n this.x += this.vx;\r\n this.y += this.vy;\r\n\r\n\r\n }", "title": "" }, { "docid": "c5f22f5d7a0dc832b34944cde4eb30fa", "score": "0.56389654", "text": "imagesDraggable() {\n this.input.on('drag', function (pointer, gameObject, dragX, dragY) {\n\n gameObject.x = dragX;\n gameObject.y = dragY;\n\n });\n\n }", "title": "" }, { "docid": "4c5aba937d5451f7ec6b27cd3db7c249", "score": "0.5638084", "text": "update(){\n\t\tthis.draw();\n\t\tthis.x = this.x + this.velocity.x;\n\t\tthis.y = this.y + this.velocity.y;\n\t}", "title": "" }, { "docid": "4c5aba937d5451f7ec6b27cd3db7c249", "score": "0.5638084", "text": "update(){\n\t\tthis.draw();\n\t\tthis.x = this.x + this.velocity.x;\n\t\tthis.y = this.y + this.velocity.y;\n\t}", "title": "" }, { "docid": "70ccd7b5f36680dc41a6870043c17202", "score": "0.563793", "text": "getNewCoords() {\n this.x += Math.cos(this.angle) * this.stepDist;\n this.y -= Math.sin(this.angle) * this.stepDist;\n }", "title": "" }, { "docid": "88ff9971d8fdcd1304a94662f9876d0d", "score": "0.5635953", "text": "drag(mouseX, mouseY) {\n const trueX = mouseX - this.relClickX;\n const trueY = mouseY - this.relClickY;\n\n this.selectedPiece.setPosition(\n new xyCoord(trueX, trueY, true, true),\n this.selectedPiece.theta,\n this.selectedPiece.flipped);\n }", "title": "" }, { "docid": "d4a2e64bae6704f7b8733c7075966343", "score": "0.56332976", "text": "function dragstarted(d) {\n if (!d3.event.active) simulation.alphaTarget(0.3).restart();\n d.fx = d.x;\n d.fy = d.y;\n }", "title": "" }, { "docid": "7a32cf8cac053e1577f942860062cc58", "score": "0.5632362", "text": "function update_positie(event){\n\t// use currentPosition to center the map\n\tvar newPos = new google.maps.LatLng(currentPosition.coords.latitude, currentPosition.coords.longitude);\n\tmap.setCenter(newPos);\t\n\tcurrentPositionMarker.setPosition(newPos);\n}", "title": "" }, { "docid": "3e5c05407efaade724c6a873f8810763", "score": "0.562973", "text": "function dragstarted(d) {\n if (!d3.event.active) simulation.alphaTarget(.03).restart();\n d.fx = d.x;\n d.fy = d.y;\n }", "title": "" }, { "docid": "8f449842e900cbdc339e8f405624506c", "score": "0.5628853", "text": "function onMapMove(e) { askForPlots(); }", "title": "" }, { "docid": "51d81b414ae96e65a523461d9d18b549", "score": "0.5621974", "text": "function dragged(event) {\n if (movablePieceSelected){\n d3.select(this)\n .attr('x', event.x - squareside/2)\n .attr('y', event.y - squareside/2)\n }\n\n}", "title": "" }, { "docid": "29d62d7c3407d3d0bf992580a9607e3a", "score": "0.56199497", "text": "setPosition(x, y, is_veloX, is_veloY, velo, angle) {\n this.pac.x = x;\n this.pac.y = y;\n this.pac.angle = angle;\n if (is_veloX) {\n this.pac.setVelocityY(0);\n this.pac.setVelocityX(velo);\n }\n if (is_veloY) {\n this.pac.setVelocityY(velo);\n this.pac.setVelocityX(0);\n }\n }", "title": "" } ]
87c0f2a4433c59539c551830823b1fe1
If modifier key is pressed, then all keyboard events are completely broken
[ { "docid": "6856ff5ec7c7712d720e22d5f9988140", "score": "0.0", "text": "function hotkey_key(event, key, issymbol) {\n\tvar code = event.which;\n\tif (HOT_PRESSED_KEYS[code] || issymbol) {\n\t\tHOT_PRESSED_KEYS[code] = (event.type === \"keydown\");\n\t\tkey = String.fromCharCode(code);\n\t}\n\treturn key;\n}", "title": "" } ]
[ { "docid": "702d3e56c552ef88fa661e332fcf0467", "score": "0.74225396", "text": "addKeyModifier(e) {\n if (e.keyCode === 16) {\n this.shiftPressed = true;\n }\n else if (e.keyCode === 17) {\n this.ctrlPressed = true;\n }\n }", "title": "" }, { "docid": "b07cd4e8d73f4c3330ef17c328fb56ec", "score": "0.7351975", "text": "static set modifierKeysChanged(value) {}", "title": "" }, { "docid": "d1850f8805a9d84d89fff46dd20d7f4d", "score": "0.7208383", "text": "static get modifierKeysChanged() {}", "title": "" }, { "docid": "447faa8dae6d5e507e2d5e9e4c186b56", "score": "0.6995794", "text": "keyDown(event) {\n event = normalizeEvent(event);\n if (this.isHandledInputEvent(event)) {\n if (this.isCtrlZ(event)) {\n event.preventDefault();\n this.get('rawEditor').undo();\n }\n else {\n let handlers = this.get('inputHandlers').filter(h => h.isHandlerFor(event));\n try {\n handlers.some( handler => {\n let response = handler.handleEvent(event);\n if (!response.get('allowBrowserDefault'))\n event.preventDefault();\n if (!response.get('allowPropagation'))\n return true;\n return false;\n });\n }\n catch(e) {\n warn(`handler failure`, {id: 'contenteditable.keydown.handler'});\n warn(e, {id: 'contenteditable.keydown.handler'});\n }\n }\n this.get('rawEditor').updateRichNode();\n this.get('rawEditor').generateDiffEvents.perform();\n this.capturedEvents.pushObject(event); // TODO: figure this out again\n }\n else {\n runInDebug( () => {\n console.warn('unhandled keydown', event); //eslint-disable-line no-console\n });\n }\n this.lastKeyDown = event;\n }", "title": "" }, { "docid": "49666ddfad9d7d7eeccd93e042d28def", "score": "0.69104844", "text": "_releaseModifiers(modifiers) {\n\n // Since we do not know whether left or right version of each key is pressed, we\n // release both...\n if (modifiers & Clutter.ModifierType.CONTROL_MASK) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Control_L, Clutter.KeyState.RELEASED);\n this._keyboard.notify_keyval(0, Clutter.KEY_Control_R, Clutter.KeyState.RELEASED);\n }\n\n if (modifiers & Clutter.ModifierType.SHIFT_MASK) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Shift_L, Clutter.KeyState.RELEASED);\n this._keyboard.notify_keyval(0, Clutter.KEY_Shift_R, Clutter.KeyState.RELEASED);\n }\n\n if (modifiers & Clutter.ModifierType.MOD1_MASK) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Alt_L, Clutter.KeyState.RELEASED);\n this._keyboard.notify_keyval(0, Clutter.KEY_Alt_R, Clutter.KeyState.RELEASED);\n }\n\n if ((modifiers & Clutter.ModifierType.MOD4_MASK) ||\n (modifiers & Clutter.ModifierType.SUPER_MASK)) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Super_L, Clutter.KeyState.RELEASED);\n this._keyboard.notify_keyval(0, Clutter.KEY_Super_R, Clutter.KeyState.RELEASED);\n }\n }", "title": "" }, { "docid": "5ca6dec90e978e5ba3867e048b34aa21", "score": "0.687433", "text": "keydown( event ) {\n if ( !this.enableKeyobardEvents ) return\n switch ( event.code ) {\n case 'Space':\n this.computeSceneBoundingSphere( )\n this.zoomExtents( )\n event.stopPropagation( )\n break\n case 'ShiftLeft':\n if ( !this.isSpinning ) {\n this.controls.enabled = false\n this.domObject.style.cursor = 'copy'\n }\n break\n default:\n break\n }\n }", "title": "" }, { "docid": "6cd1be83e50a379062c70e6d2392e2b5", "score": "0.68701077", "text": "onKeydown(e) {\n const eventCode = (e.code && e.code.toLowerCase()) || String(e.keyCode)\n if (!e.repeat || !this.downKeys.has(eventCode)) {\n this.addToHistory(e)\n this.downKeys.add(eventCode)\n this.fireEventReactions(e, false)\n this.fireEventReactions(e, true)\n } else {\n this.fireEventReactions(e, true)\n }\n if (metaKeyCodes.some((k) => this.downKeys.has(k))) {\n this.downKeys.forEach((dk) => {\n if (!modifierKeyCodes.includes(dk)) {\n if (!this.artificialKeyUpTimes[dk])\n setTimeout(\n window.requestIdleCallback(() => this.fireArtificialKeyUp(dk, e)),\n 500\n )\n this.artificialKeyUpTimes[dk] = Date.now()\n }\n })\n }\n }", "title": "" }, { "docid": "3d36483a10ee3fdd1014fd6d8e54dd1f", "score": "0.6847593", "text": "_pressModifiers(modifiers) {\n if (modifiers & Clutter.ModifierType.CONTROL_MASK) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Control_L, Clutter.KeyState.PRESSED);\n }\n\n if (modifiers & Clutter.ModifierType.SHIFT_MASK) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Shift_L, Clutter.KeyState.PRESSED);\n }\n\n if (modifiers & Clutter.ModifierType.MOD1_MASK) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Alt_L, Clutter.KeyState.PRESSED);\n }\n\n if ((modifiers & Clutter.ModifierType.MOD4_MASK) ||\n (modifiers & Clutter.ModifierType.SUPER_MASK)) {\n this._keyboard.notify_keyval(0, Clutter.KEY_Super_L, Clutter.KeyState.PRESSED);\n }\n }", "title": "" }, { "docid": "5988acad04cb044073a82c501b3293ef", "score": "0.67920995", "text": "function keydown(event){switch(event.keyCode){case $mdConstant.KEY_CODE.LEFT_ARROW:event.preventDefault();incrementIndex(-1,true);break;case $mdConstant.KEY_CODE.RIGHT_ARROW:event.preventDefault();incrementIndex(1,true);break;case $mdConstant.KEY_CODE.SPACE:case $mdConstant.KEY_CODE.ENTER:event.preventDefault();if(!locked)select(ctrl.focusIndex);break;}ctrl.lastClick=false;}", "title": "" }, { "docid": "99d45d8ec7755bf5fb3b846236dfbc38", "score": "0.6785706", "text": "_handleKeydown(event) {\n // We don't handle any key bindings with a modifier key.\n if ((0,_angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_18__.hasModifierKey)(event)) {\n return;\n }\n switch (event.keyCode) {\n case _angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_18__.ENTER:\n case _angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_18__.SPACE:\n if (this.focusIndex !== this.selectedIndex) {\n this.selectFocusedIndex.emit(this.focusIndex);\n this._itemSelected(event);\n }\n break;\n default:\n this._keyManager.onKeydown(event);\n }\n }", "title": "" }, { "docid": "ff2b0527556156f12f93d0e37bfdf4a8", "score": "0.67551357", "text": "allowKeyEventPropagation() {}", "title": "" }, { "docid": "b448e956c15c140a712d5978823d270d", "score": "0.6746159", "text": "handleKeyboardEvent(event) {\n if (event.equals(10 /* Space */)\n || event.equals(15 /* LeftArrow */)\n || event.equals(17 /* RightArrow */)\n || event.equals(9 /* Escape */)) {\n event.stopPropagation();\n }\n }", "title": "" }, { "docid": "92df143215d48ddbea4fd476b52f6e9e", "score": "0.6722299", "text": "modifiers (e) {\n if (!this.hasModifier()) {\n return true\n }\n return e.altKey === this.altKey &&\n e.ctrlKey === this.ctrlKey &&\n e.metaKey === this.metaKey &&\n e.shiftKey === this.shiftKey\n }", "title": "" }, { "docid": "ba9e25b54ab3548af49aaa03ca29a63b", "score": "0.6702016", "text": "_handleKeydown(event) {\n // We don't handle any key bindings with a modifier key.\n if (Object(_angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_14__[\"hasModifierKey\"])(event)) {\n return;\n }\n switch (event.keyCode) {\n case _angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_14__[\"ENTER\"]:\n case _angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_14__[\"SPACE\"]:\n if (this.focusIndex !== this.selectedIndex) {\n this.selectFocusedIndex.emit(this.focusIndex);\n this._itemSelected(event);\n }\n break;\n default:\n this._keyManager.onKeydown(event);\n }\n }", "title": "" }, { "docid": "ba9e25b54ab3548af49aaa03ca29a63b", "score": "0.6702016", "text": "_handleKeydown(event) {\n // We don't handle any key bindings with a modifier key.\n if (Object(_angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_14__[\"hasModifierKey\"])(event)) {\n return;\n }\n switch (event.keyCode) {\n case _angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_14__[\"ENTER\"]:\n case _angular_cdk_keycodes__WEBPACK_IMPORTED_MODULE_14__[\"SPACE\"]:\n if (this.focusIndex !== this.selectedIndex) {\n this.selectFocusedIndex.emit(this.focusIndex);\n this._itemSelected(event);\n }\n break;\n default:\n this._keyManager.onKeydown(event);\n }\n }", "title": "" }, { "docid": "4610cc99d0ea8005cc1be0ad5a6f09fe", "score": "0.66932636", "text": "function keydown() {\n if (d3_event.keyCode === 93) { // context menu\n d3_event.preventDefault();\n d3_event.stopPropagation();\n down.menu = d3_event.timeStamp;\n tooltip.classed('rightclick', true);\n }\n }", "title": "" }, { "docid": "4c213d2909358ab96ae96ebd6d13bbd4", "score": "0.66927", "text": "function myKeyDown(kev) {\r\n//============================================================================\r\n// Called when user presses down ANY key on the keyboard;\r\n//\r\n// For a light, easy explanation of keyboard events in JavaScript,\r\n// see: http://www.kirupa.com/html5/keyboard_events_in_javascript.htm\r\n// For a thorough explanation of a mess of JavaScript keyboard event handling,\r\n// see: http://javascript.info/tutorial/keyboard-events\r\n//\r\n// NOTE: Mozilla deprecated the 'keypress' event entirely, and in the\r\n// 'keydown' event deprecated several read-only properties I used\r\n// previously, including kev.charCode, kev.keyCode. \r\n// Revised 2/2019: use kev.key and kev.code instead.\r\n//\r\n\tdocument.getElementById('KeyDownResult').innerHTML = ''; // clear old result\r\n document.getElementById('KeyModResult' ).innerHTML = ''; \r\n console.log( \"--kev.code:\", kev.code, \"\\t\\t--kev.key:\", kev.key, \r\n \"\\n--kev.ctrlKey:\", kev.ctrlKey, \"\\t--kev.shiftKey:\",kev.shiftKey,\r\n \"\\n--kev.altKey:\", kev.altKey, \"\\t--kev.metaKey:\", kev.metaKey);\r\n document.getElementById('KeyModResult' ).innerHTML = \r\n \" --kev.code:\"+kev.code +\" --kev.key:\"+kev.key+\r\n \"<br>--kev.ctrlKey:\"+kev.ctrlKey+\" --kev.shiftKey:\"+kev.shiftKey+\r\n \"<br> --kev.altKey:\"+kev.altKey +\" --kev.metaKey:\"+kev.metaKey;\r\n \r\n //\"--kev.code:\"+kev.code+\"--kev.key:\"+kev.key; \r\n/* \"\\n--kev.ctrlKey:\", kev.ctrlKey, \"\\t--kev.shiftKey:\",kev.shiftKey,\r\n \"\\n--kev.altKey:\", kev.altKey, \"\\t--kev.metaKey:\", kev.metaKey);\r\n*/\r\n switch(kev.code) {\r\n\t\tcase \"KeyP\":\r\n\t\t\tconsole.log(\"Pause/unPause!\\n\"); // print on console,\r\n\t\t\tdocument.getElementById('KeyDownResult').innerHTML = \r\n\t\t\t'myKeyDown() found p/P key. Pause/unPause!'; // print on webpage\r\n\t\t\tif(g_isRun==true) {\r\n\t\t\t g_isRun = false; // STOP animation\r\n\t\t\t }\r\n\t\t\telse {\r\n\t\t\t g_isRun = true; // RESTART animation\r\n\t\t\t tick();\r\n\t\t\t }\r\n\t\t\tbreak;\r\n\t\t//------------------WASD navigation-----------------\r\n\t\tcase \"KeyA\":\r\n\t\t\tconsole.log(\"a/A key: Strafe LEFT!\\n\");\r\n\t\t\tdocument.getElementById('KeyDownResult').innerHTML = \r\n\t\t\t'myKeyDown() found a/A key. Strafe LEFT!';\r\n g_eyeX += .4*Math.cos((90+g_theta)*Math.PI/180);\r\n g_eyeY += .4*Math.sin((90+g_theta)*Math.PI/180);\r\n\r\n\t\t\tbreak;\r\n case \"KeyD\":\r\n\t\t\tconsole.log(\"d/D key: Strafe RIGHT!\\n\");\r\n\t\t\tdocument.getElementById('KeyDownResult').innerHTML = \r\n\t\t\t'myKeyDown() found d/D key. Strafe RIGHT!';\r\n g_eyeX -= .4*Math.cos((90+g_theta)*Math.PI/180);\r\n g_eyeY -= .4*Math.sin((90+g_theta)*Math.PI/180);\r\n\t\t\tbreak;\r\n\t\tcase \"KeyS\":\r\n\t\t\tconsole.log(\"s/S key: Move BACK!\\n\");\r\n\t\t\tdocument.getElementById('KeyDownResult').innerHTML = \r\n\t\t\t'myKeyDown() found s/Sa key. Move BACK.';\r\n g_eyeX -= .4*Math.cos(g_theta*Math.PI/180)\r\n g_eyeY -= .4*Math.sin(g_theta*Math.PI/180)\r\n g_eyeZ -= .4*Math.atan(z_move)\r\n\t\t\tbreak;\r\n\t\tcase \"KeyW\":\r\n\t\t\tconsole.log(\"w/W key: Move FWD!\\n\");\r\n\t\t\tdocument.getElementById('KeyDownResult').innerHTML = \r\n\t\t\t'myKeyDown() found w/W key. Move FWD!';\r\n g_eyeX += .4*Math.cos(g_theta*Math.PI/180)\r\n g_eyeY += .4*Math.sin(g_theta*Math.PI/180)\r\n g_eyeZ += .4*Math.atan(z_move)\r\n\t\t\tbreak;\r\n\t\t//----------------Arrow keys------------------------\r\n\t\tcase \"ArrowLeft\": \t\r\n\t\t\tconsole.log(' left-arrow.');\r\n\t\t\t// and print on webpage in the <div> element with id='Result':\r\n \t\tdocument.getElementById('KeyDownResult').innerHTML =\r\n \t\t\t'myKeyDown(): Left Arrow='+kev.keyCode;\r\n g_theta += 2.0; // turn left.\r\nconsole.log(\"g_theta:\",g_theta)\r\n\t\t\tbreak;\r\n\t\tcase \"ArrowRight\":\r\n\t\t\tconsole.log('right-arrow.');\r\n \t\tdocument.getElementById('KeyDownResult').innerHTML =\r\n \t\t\t'myKeyDown():Right Arrow:keyCode='+kev.keyCode;\r\n g_theta -= 2.0; // turn right,\r\nconsole.log(\"g_theta:\",g_theta)\r\n \t\tbreak;\r\n\t\tcase \"ArrowUp\":\t\t\r\n\t\t\tconsole.log(' up-arrow.');\r\n \t\tdocument.getElementById('KeyDownResult').innerHTML =\r\n \t\t\t'myKeyDown(): Up Arrow:keyCode='+kev.keyCode;\r\n z_move += .02;\r\n\t\t\tbreak;\r\n\t\tcase \"ArrowDown\":\r\n\t\t\tconsole.log(' down-arrow.');\r\n \t\tdocument.getElementById('KeyDownResult').innerHTML =\r\n \t\t\t'myKeyDown(): Down Arrow:keyCode='+kev.keyCode;\r\n z_move -=.02;\r\n \t\tbreak;\t\r\n default:\r\n console.log(\"UNUSED!\");\r\n \t\tdocument.getElementById('KeyDownResult').innerHTML =\r\n \t\t\t'myKeyDown(): UNUSED!';\r\n break;\r\n }\r\n}", "title": "" }, { "docid": "9c4b2120def2e6504008fb908cb05a12", "score": "0.66874033", "text": "function trap(e) {\n\tif (!e) {\n\t\te = event;\n\t\te.which = e.keyCode;\n\t}\n\ttry {\n\t\tmodifierKey = e.ctrlKey || e.altKey || e.metaKey;\n\t}\n\tcatch(e) {\n\t\tmodifierKey = false;\n\t}\n\treturn modifierKey || e.which == 0;\n}", "title": "" }, { "docid": "19c77b029cc5e88e85900b378eea9957", "score": "0.6681034", "text": "isKeyboardEvent() {\n return this.type >= Message.Type.KEY_DOWN && this.type <= Message.Type.KEY_ENTER;\n }", "title": "" }, { "docid": "08c49009ada48232c4016dd01b9b2efb", "score": "0.66267544", "text": "_handleKeyEvent(e) { return false; }", "title": "" }, { "docid": "d0e67579679cc9a922945cb122ff1613", "score": "0.662055", "text": "function editOnKeyDown(editor, e) {\n var keyCode = e.which, editorState = editor._latestEditorState;\n switch (keyCode) {\n case Keys.RETURN:\n // The top-level component may manually handle newline insertion. If\n // no special handling is performed, fall through to command handling.\n if (e.preventDefault(), editor.props.handleReturn && isEventHandled(editor.props.handleReturn(e, editorState))) return;\n break;\n\n case Keys.ESC:\n return e.preventDefault(), void (editor.props.onEscape && editor.props.onEscape(e));\n\n case Keys.TAB:\n return void (editor.props.onTab && editor.props.onTab(e));\n\n case Keys.UP:\n return void (editor.props.onUpArrow && editor.props.onUpArrow(e));\n\n case Keys.DOWN:\n return void (editor.props.onDownArrow && editor.props.onDownArrow(e));\n\n case Keys.SPACE:\n // Handling for OSX where option + space scrolls.\n if (isChrome && isOptionKeyCommand(e)) {\n e.preventDefault();\n // Insert a nbsp into the editor.\n var contentState = DraftModifier.replaceText(editorState.getCurrentContent(), editorState.getSelection(), \" \");\n return void editor.update(EditorState.push(editorState, contentState, \"insert-characters\"));\n }\n }\n var command = editor.props.keyBindingFn(e);\n // If no command is specified, allow keydown event to continue.\n if (command) {\n if (\"undo\" === command) // Since undo requires some special updating behavior to keep the editor\n // in sync, handle it separately.\n return void keyCommandUndo(e, editorState, editor.update);\n // Allow components higher up the tree to handle the command first.\n if (// At this point, we know that we're handling a command of some kind, so\n // we don't want to insert a character following the keydown.\n e.preventDefault(), !editor.props.handleKeyCommand || !isEventHandled(editor.props.handleKeyCommand(command, editorState))) {\n var newState = onKeyCommand(command, editorState);\n newState !== editorState && editor.update(newState);\n }\n }\n }", "title": "" }, { "docid": "49c8f5478002a5a69c2446dda3d3b807", "score": "0.66192067", "text": "function clearModifier(event){\n var key = event.keyCode, k;\n if(key == 93 || key == 224) key = 91;\n if(key in _mods) {\n _mods[key] = false;\n for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;\n }\n }", "title": "" }, { "docid": "801fe970e4b6d785ca8387b64eabef96", "score": "0.66014963", "text": "function hasModifier(e) {\n return (e.ctrlKey || e.metaKey || e.shiftKey);\n }", "title": "" }, { "docid": "01b03acefbefbdaf3ef0d4b6df841cfc", "score": "0.6600086", "text": "function hasModifier(e)\n {\n return (e.ctrlKey || e.metaKey || e.shiftKey);\n }", "title": "" }, { "docid": "c6a6aabeb8cd1757e9e05f5229c0346d", "score": "0.6596279", "text": "function keyDown(e) {\n e.preventDefault();\n keys[e.key] = true;\n }", "title": "" }, { "docid": "1f745bd0a5c2acf6ae876c9d15196462", "score": "0.65948236", "text": "hasModifier () {\n return this.altKey || this.ctrlKey || this.metaKey || this.shiftKey\n }", "title": "" }, { "docid": "8a3ca03d92ebd111b539ce0d55f8bf17", "score": "0.659101", "text": "function keyDown (evt) {\n\t\tif (!evt) return true;\n\t\tvar code = evt.keyCode;\n\t\tif (code < 33) return true; // ignore special keys: ENTER, TAB, etc\n\n\t\tvar\n\t\t\tPANE = {\n\t\t\t\t38: \"north\" // Up Cursor\n\t\t\t,\t40: \"south\" // Down Cursor\n\t\t\t,\t37: \"west\" // Left Cursor\n\t\t\t,\t39: \"east\" // Right Cursor\n\t\t\t}\n\t\t,\tisCursorKey = (code >= 37 && code <= 40)\n\t\t,\tALT = evt.altKey // no worky!\n\t\t,\tSHIFT = evt.shiftKey\n\t\t,\tCTRL = evt.ctrlKey\n\t\t,\tpane = false\n\t\t,\ts, o, k, m, el\n\t\t;\n\n\t\tif (!CTRL && !SHIFT)\n\t\t\treturn true; // no modifier key - abort\n\t\telse if (isCursorKey && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey\n\t\t\tpane = PANE[code];\n\t\telse // check to see if this matches a custom-hotkey\n\t\t\t$.each(c.borderPanes.split(\",\"), function(i,p) { // loop each pane to check its hotkey\n\t\t\t\to = options[p];\n\t\t\t\tk = o.customHotkey;\n\t\t\t\tm = o.customHotkeyModifier; // if missing or invalid, treated as \"CTRL+SHIFT\"\n\t\t\t\tif ((SHIFT && m==\"SHIFT\") || (CTRL && m==\"CTRL\") || (CTRL && SHIFT)) { // Modifier matches\n\t\t\t\t\tif (k && code == (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches\n\t\t\t\t\t\tpane = p;\n\t\t\t\t\t\treturn false; // BREAK\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\tif (!pane) return true; // no hotkey - abort\n\n\t\t// validate pane\n\t\to = options[pane]; // get pane options\n\t\ts = state[pane]; // get pane options\n\t\tif (!o.enableCursorHotkey || s.isHidden || !$Ps[pane]) return true;\n\n\t\t// see if user is in a 'form field' because may be 'selecting text'!\n\t\tel = evt.target || evt.srcElement;\n\t\tif (el && SHIFT && isCursorKey && (el.tagName==\"TEXTAREA\" || (el.tagName==\"INPUT\" && (code==37 || code==39))))\n\t\t\treturn true; // allow text-selection\n\n\t\t// SYNTAX NOTES\n\t\t// use \"returnValue=false\" to abort keystroke but NOT abort function - can run another command afterwards\n\t\t// use \"return false\" to abort keystroke AND abort function\n\t\ttoggle(pane);\n\t\tevt.stopPropagation();\n\t\tevt.returnValue = false; // CANCEL key\n\t\treturn false;\n\t}", "title": "" }, { "docid": "6f2a35942209c0ec0d17c6b1b701e504", "score": "0.65884477", "text": "function allowKeys(e, code){\n if (e.type.indexOf('key') === -1) return true;\n return e.which === code;\n }", "title": "" }, { "docid": "548e8f60a8d51a02f8ca1db4ff2b6e2e", "score": "0.65671504", "text": "function onKeyDown(event) {\n if (event.key == 'left' || event.key == 'right') {\n return false;\n }\n }", "title": "" }, { "docid": "4f5ef721cdede9c969af2673fb5bc7c4", "score": "0.65617824", "text": "handleKeydown() {\n if (this.isTopLevel && this.elements.controller) {\n this.elements.controller.dom.toggle.addEventListener(\"keydown\", () => {\n this.currentEvent = \"keyboard\";\n\n const key = keyPress(event);\n\n if (key === \"Space\" || key === \"Enter\") {\n preventEvent(event);\n }\n });\n }\n }", "title": "" }, { "docid": "f1c0bec813e50cdf9c511cbcca8ca8cc", "score": "0.6561462", "text": "function onKeyDown(evt) {\n setMovementflag(evt.keyCode, true);\n}", "title": "" }, { "docid": "64a1aa0daeaf21dea8cd8b09f9e4a959", "score": "0.65584743", "text": "function keyDown(e) {\n if(document.layers) {\n placeflag = (e.modifiers & Event.CONTROL_MASK) > 0;\n }\n else {\n placeflag = window.event.ctrlKey;\n }\n setStatus();\n}", "title": "" }, { "docid": "997ab470c7abe86656cb00ab6521d0b3", "score": "0.65403324", "text": "function clearModifier(event){\n\t var key = event.keyCode, k,\n\t i = index(_downKeys, key);\n\n\t // remove key from _downKeys\n\t if (i >= 0) {\n\t _downKeys.splice(i, 1);\n\t }\n\n\t if(key == 93 || key == 224) key = 91;\n\t if(key in _mods) {\n\t _mods[key] = false;\n\t for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;\n\t }\n\t }", "title": "" }, { "docid": "997ab470c7abe86656cb00ab6521d0b3", "score": "0.65403324", "text": "function clearModifier(event){\n\t var key = event.keyCode, k,\n\t i = index(_downKeys, key);\n\n\t // remove key from _downKeys\n\t if (i >= 0) {\n\t _downKeys.splice(i, 1);\n\t }\n\n\t if(key == 93 || key == 224) key = 91;\n\t if(key in _mods) {\n\t _mods[key] = false;\n\t for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;\n\t }\n\t }", "title": "" }, { "docid": "f9d3cd1402c70c588457710452c3e084", "score": "0.6538649", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\";\n }", "title": "" }, { "docid": "1ff87780555c2b57e2a99ac2fa509f7b", "score": "0.6526679", "text": "function onKeyDown( e ) {\n\n if ( e.keyCode == 17 ) { // Ctrl\n window.keyDown.ctrl = true;\n }\n\n if ( e.keyCode == 16 ) { // Shift\n window.keyDown.shift = true;\n }\n}", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "430fe587aed31284bf26098fbe41cc4d", "score": "0.6525366", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n }", "title": "" }, { "docid": "0737086fd5be71d1638d402b04963cbf", "score": "0.651744", "text": "handleKeyDown(evt) {\n if (evt.key === 'Enter' && this.editable) {\n this.setEditMode(false);\n }\n }", "title": "" }, { "docid": "0dd6243842975faef273284e7f0d436d", "score": "0.65007955", "text": "function keydownHandler(evt) {\n var keyUpper = evt.key.toUpperCase();\n\n if (keyUpper === \"SHIFT\") {\n G_shiftDown = true;\n evt.preventDefault();\n return;\n } else if (keyUpper === \"CONTROL\") {\n G_controlDown = true;\n evt.preventDefault();\n return;\n } else if (keyUpper === \"META\") {\n G_metaDown = true;\n evt.preventDefault();\n return;\n } else if (keyUpper === \"ALT\") {\n G_altDown = true;\n evt.preventDefault();\n return;\n } else if (KEY_SLOW_PANZOOM.includes(keyUpper)) {\n G_slowPanZoomDown = true;\n return;\n }\n\n if (keyUpper === \"ESCAPE\") {\n document.activeElement.blur();\n clearMouse();\n clearKeys();\n return;\n }\n\n if (document.activeElement !== document.body) {\n // something else has the focus\n return;\n }\n\n // undo\n if (keyUpper === \"Z\" && (G_controlDown || G_metaDown)) {\n undoRedoLabel();\n return;\n }\n\n // skip the rest of the key handlers if certain modifiers are down\n if (!G_controlDown && !G_metaDown && !G_altDown) {\n // since no modifier is pressed, it is safe to call the preventDefault method here\n event.preventDefault();\n\n // pan and zoom based on keyboard input when the main window is in focus\n if (G_keyMap.get(\"PAN_LEFT\").includes(keyUpper)) {\n G_pleftDown = true;\n } else if (G_keyMap.get(\"PAN_RIGHT\").includes(keyUpper)) {\n G_prightDown = true;\n } else if (G_keyMap.get(\"ZOOM_IN\").includes(keyUpper)) {\n G_zinDown = true;\n } else if (G_keyMap.get(\"ZOOM_OUT\").includes(keyUpper)) {\n G_zoutDown = true;\n }\n\n // toggle between previous/next label options\n if (G_keyMap.get(\"PREVIOUS_LABEL\").includes(keyUpper)) {\n prevCurrentLabel();\n } else if (G_keyMap.get(\"NEXT_LABEL\").includes(keyUpper)) {\n nextCurrentLabel();\n }\n\n // change label range\n else if (G_keyMap.get(\"CYCLE\").includes(keyUpper)) {\n cycleServerLabels();\n }\n // Increase y-axis magnitude\n else if (G_keyMap.get(\"DOUBLE_Y_MAG\").includes(keyUpper)) {\n increaseMagnitude();\n }\n // Increase y-axis magnitude\n else if (G_keyMap.get(\"RESET_Y_MAG\").includes(keyUpper)) {\n resetMagnitude();\n }\n // Decrease y-axis magnitude\n else if (G_keyMap.get(\"HALVE_Y_MAG\").includes(keyUpper)) {\n decreaseMagnitude();\n }\n else if (keyUpper === \" \") {\n resetHandler();\n evt.preventDefault();\n }\n else if (G_keyMap.get(\"RETURN_BACK\").includes(keyUpper)) {\n restoreZoomHistory();\n }\n else {\n var digit = Number.parseInt(keyUpper);\n if (!isNaN(digit)) {\n if (digit === 0) {\n showAllSignals();\n } else if (digit >= 1 && digit <= 9) {\n toggleSignalVisibility(digit - 1);\n }\n }\n }\n }\n}", "title": "" }, { "docid": "2ddd0425a2d3d52ffd316df4f0de905f", "score": "0.6499253", "text": "handleKeyDown(e){\n let charCode = String.fromCharCode(e.which).toLowerCase();\n\n if(this.state.isFormDisabled){\n //Listening for Cmd key\n if(e.metaKey && charCode === 'c') {\n this.state.duplicatedNote = this.state.note;\n }\n \n if(e.metaKey && charCode === 'v') {\n if(this.state.duplicatedNote != undefined) {\n this.duplicateNote(this.state.duplicatedNote);\n }\n }\n\n //Listening for Ctrl key\n if(e.ctrlKey && charCode === 'c') {\n this.state.duplicatedNote = this.state.note;\n }\n\n if(e.ctrlKey && charCode === 'v') {\n if(this.state.duplicatedNote != undefined) {\n this.duplicateNote(this.state.duplicatedNote);\n }\n }\n }\n }", "title": "" }, { "docid": "8147d1d04a1e2e2eadc1781fcff35859", "score": "0.6490728", "text": "function handleKeyDown(event) {\n\t\t\n currentlyPressedKeys[event.keyCode] = true;\n }", "title": "" }, { "docid": "53df989d11db5a58cd10812e14c7617d", "score": "0.64869285", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\";\n }", "title": "" }, { "docid": "53df989d11db5a58cd10812e14c7617d", "score": "0.64869285", "text": "function isModifierKey(value) {\n var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\";\n }", "title": "" }, { "docid": "b32c5873db61339853fae0fafc9ed658", "score": "0.64841676", "text": "function RIGHT_KEY_EventsHandler () {\n\n }", "title": "" }, { "docid": "bbca16411584b88f55acb9488efc30cb", "score": "0.6483837", "text": "function keydown(evt) {\n keyboard.keydown(evt);\n}", "title": "" }, { "docid": "04b5e9447bc8701e3f10d489386d0d36", "score": "0.6482558", "text": "function editOnKeyDown(editor, e) {\n var keyCode = e.which;\n var editorState = editor._latestEditorState;\n\n switch (keyCode) {\n case Keys.RETURN:\n e.preventDefault();\n // The top-level component may manually handle newline insertion. If\n // no special handling is performed, fall through to command handling.\n if (editor.props.handleReturn && isEventHandled(editor.props.handleReturn(e, editorState))) {\n return;\n }\n break;\n case Keys.ESC:\n e.preventDefault();\n editor.props.onEscape && editor.props.onEscape(e);\n return;\n case Keys.TAB:\n editor.props.onTab && editor.props.onTab(e);\n return;\n case Keys.UP:\n editor.props.onUpArrow && editor.props.onUpArrow(e);\n return;\n case Keys.RIGHT:\n editor.props.onRightArrow && editor.props.onRightArrow(e);\n return;\n case Keys.DOWN:\n editor.props.onDownArrow && editor.props.onDownArrow(e);\n return;\n case Keys.LEFT:\n editor.props.onLeftArrow && editor.props.onLeftArrow(e);\n return;\n case Keys.SPACE:\n // Handling for OSX where option + space scrolls.\n if (isChrome && isOptionKeyCommand(e)) {\n e.preventDefault();\n // Insert a nbsp into the editor.\n var contentState = DraftModifier.replaceText(editorState.getCurrentContent(), editorState.getSelection(), '\\xA0');\n editor.update(EditorState.push(editorState, contentState, 'insert-characters'));\n return;\n }\n }\n\n var command = editor.props.keyBindingFn(e);\n\n // If no command is specified, allow keydown event to continue.\n if (!command) {\n return;\n }\n\n if (command === 'undo') {\n // Since undo requires some special updating behavior to keep the editor\n // in sync, handle it separately.\n keyCommandUndo(e, editorState, editor.update);\n return;\n }\n\n // At this point, we know that we're handling a command of some kind, so\n // we don't want to insert a character following the keydown.\n e.preventDefault();\n\n // Allow components higher up the tree to handle the command first.\n if (editor.props.handleKeyCommand && isEventHandled(editor.props.handleKeyCommand(command, editorState))) {\n return;\n }\n\n var newState = onKeyCommand(command, editorState);\n if (newState !== editorState) {\n editor.update(newState);\n }\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "f1ec4b5c47291021fd8881f980dc4116", "score": "0.6482051", "text": "function keyName(event, noShift) {\n if (presto && event.keyCode == 34 && event[\"char\"]) { return false }\n var name = keyNames[event.keyCode];\n if (name == null || event.altGraphKey) { return false }\n // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,\n // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)\n if (event.keyCode == 3 && event.code) { name = event.code; }\n return addModifierNames(name, event, noShift)\n }", "title": "" }, { "docid": "4ac7e2eebbff0db631bce8d0234d48e7", "score": "0.6481654", "text": "function clearModifier(event){\n var key = event.keyCode, k,\n i = index(_downKeys, key);\n\n // remove key from _downKeys\n if (i >= 0) {\n _downKeys.splice(i, 1);\n }\n\n if(key == 93 || key == 224) key = 91;\n if(key in _mods) {\n _mods[key] = false;\n for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;\n }\n }", "title": "" }, { "docid": "4ac7e2eebbff0db631bce8d0234d48e7", "score": "0.6481654", "text": "function clearModifier(event){\n var key = event.keyCode, k,\n i = index(_downKeys, key);\n\n // remove key from _downKeys\n if (i >= 0) {\n _downKeys.splice(i, 1);\n }\n\n if(key == 93 || key == 224) key = 91;\n if(key in _mods) {\n _mods[key] = false;\n for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = false;\n }\n }", "title": "" }, { "docid": "ea74a5a4b2047d962170ad5ff8c9f874", "score": "0.64810145", "text": "function handleKeyDown(event) {\n //console.log(\"Key down \", event.key, \" code \", event.code);\n currentlyPressedKeys[event.key] = true;\n}", "title": "" }, { "docid": "88a6ea40233b6797cb192bb04bdf8ba2", "score": "0.6472761", "text": "function keydown(event) {\n switch (event.keyCode) {\n case $mdConstant.KEY_CODE.LEFT_ARROW:\n event.preventDefault();\n incrementIndex(-1, true);\n break;\n case $mdConstant.KEY_CODE.RIGHT_ARROW:\n event.preventDefault();\n incrementIndex(1, true);\n break;\n case $mdConstant.KEY_CODE.SPACE:\n case $mdConstant.KEY_CODE.ENTER:\n event.preventDefault();\n if (!locked) ctrl.selectedIndex = ctrl.focusIndex;\n break;\n }\n ctrl.lastClick = false;\n }", "title": "" }, { "docid": "5377dd3e10406521cb93c036582b906d", "score": "0.646968", "text": "function setKeyTriggers() {\n $('body').on('keydown', triggerKeyboardEvent);\n }", "title": "" }, { "docid": "9f9874ddc24b558586693724ce49da7a", "score": "0.646519", "text": "function DoKeyDown(e){\r\n if (e.ctrlKey){\r\n persistPreview = true;\r\n }\r\n}", "title": "" }, { "docid": "5679f0b526d38ebb05f62daa137baec2", "score": "0.64644724", "text": "function editorKeyDown(editor,e){\n\tswitch(e.keyCode){\n\n\t/*\tSome browsers do the right thing with these keys\n\t\tby default. Others don't. Preventing default and\n\t\tdoing it manually smooths out the differences.\t*/\n\n\tcase 66: // bold key\n\t\tif(e.ctrlKey){\n\t\t\tdocument.execCommand('bold',false,null);\n\t\t\te.preventDefault();\n\t\t}\n\t\tbreak;\n\tcase 73: // italics key\n\t\tif(e.ctrlKey){\n\t\t\tdocument.execCommand('italic',false,null);\n\t\t\te.preventDefault();\n\t\t}\n\t\tbreak;\n\tcase 85: // underline key\n\t\tif(e.ctrlKey){\n\t\t\tdocument.execCommand('underline',false,null);\n\t\t\te.preventDefault();\n\t\t}\n\t\tbreak;\n\n\t/*\tKeys that need to be allowed to bubble.\n\t\tEverything else falls through to the bottom.\t*/\n\n\t//escape key\n\tcase 27:\n\t\tthis.node.blur();\n\t\treturn;\n\n\t//undo and redo keys\n\tcase 89: //CTRL+y\n\tcase 90: //CTRL+z\n\t\tif(e.ctrlKey){ e.preventDefault(); }\n\t\treturn;\n\n\t}\n\n\t/*\tBy default, stop propagation\n\t\tto avoid firing hot-keys for other stuff\t*/\n\n\te.stopPropagation();\n}", "title": "" }, { "docid": "088794cf8d78d66108c804a4d0c34ecb", "score": "0.6464283", "text": "function VerifyCharModifier(next) {\n \"use strict\";\n var queue = [];\n var timer = null;\n function process() {\n if (timer) {\n return;\n }\n\n var delayProcess = function () {\n clearTimeout(timer);\n timer = null;\n process();\n };\n\n while (queue.length !== 0) {\n var cur = queue[0];\n queue = queue.splice(1);\n switch (cur.type) {\n case 'stall':\n // insert a delay before processing available events.\n /* jshint loopfunc: true */\n timer = setTimeout(delayProcess, 5);\n /* jshint loopfunc: false */\n return;\n case 'keydown':\n // is the next element a keypress? Then we should merge the two\n if (queue.length !== 0 && queue[0].type === 'keypress') {\n // Firefox sends keypress even when no char is generated.\n // so, if keypress keysym is the same as we'd have guessed from keydown,\n // the modifier didn't have any effect, and should not be escaped\n if (queue[0].escape && (!cur.keysym || cur.keysym.keysym !== queue[0].keysym.keysym)) {\n cur.escape = queue[0].escape;\n }\n cur.keysym = queue[0].keysym;\n queue = queue.splice(1);\n }\n break;\n }\n\n // swallow stall events, and pass all others to the next stage\n if (cur.type !== 'stall') {\n next(cur);\n }\n }\n }\n return function(evt) {\n queue.push(evt);\n process();\n };\n}", "title": "" }, { "docid": "036e0d68b61b0c5e24b877d5c5da7cdb", "score": "0.64620507", "text": "function keydown(event) {\n keys[event.keyCode] = true;\n}", "title": "" }, { "docid": "036e0d68b61b0c5e24b877d5c5da7cdb", "score": "0.64620507", "text": "function keydown(event) {\n keys[event.keyCode] = true;\n}", "title": "" }, { "docid": "797e39ee680e86bed5d4db3b6524a91e", "score": "0.64619225", "text": "function isModifierKey(value) {\n\t var name = typeof value == \"string\" ? value : keyNames[value.keyCode]\n\t return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n\t}", "title": "" }, { "docid": "797e39ee680e86bed5d4db3b6524a91e", "score": "0.64619225", "text": "function isModifierKey(value) {\n\t var name = typeof value == \"string\" ? value : keyNames[value.keyCode]\n\t return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n\t}", "title": "" }, { "docid": "d17195c0d331c010e13c88936ef308b8", "score": "0.6460311", "text": "function kdown(e) {\n keyState[e.keyCode || e.which] = true;\n}", "title": "" }, { "docid": "7afd30f8d3b3cc7235a25b77f60134d6", "score": "0.6457997", "text": "function isModifierKey(value) {\n\t var name = typeof value == \"string\" ? value : keyNames[value.keyCode];\n\t return name == \"Ctrl\" || name == \"Alt\" || name == \"Shift\" || name == \"Mod\"\n\t}", "title": "" }, { "docid": "71dbf2b2334afd9be795307570c43b61", "score": "0.64483607", "text": "function keydown (event) {\r\n switch (event.keyCode) {\r\n case $mdConstant.KEY_CODE.LEFT_ARROW:\r\n event.preventDefault();\r\n incrementIndex(-1, true);\r\n break;\r\n case $mdConstant.KEY_CODE.RIGHT_ARROW:\r\n event.preventDefault();\r\n incrementIndex(1, true);\r\n break;\r\n case $mdConstant.KEY_CODE.SPACE:\r\n case $mdConstant.KEY_CODE.ENTER:\r\n event.preventDefault();\r\n if (!locked) ctrl.selectedIndex = ctrl.focusIndex;\r\n break;\r\n }\r\n ctrl.lastClick = false;\r\n }", "title": "" }, { "docid": "0163fffe67d767fbe9c93911a00525ad", "score": "0.644736", "text": "function KeyEventDecoder(modifierState, next) {\n \"use strict\";\n function sendAll(evts) {\n for (var i = 0; i < evts.length; ++i) {\n next(evts[i]);\n }\n }\n function process(evt, type) {\n var result = {type: type};\n var keyId = kbdUtil.getKey(evt);\n if (keyId) {\n result.keyId = keyId;\n }\n\n var keysym = kbdUtil.getKeysym(evt);\n\n var hasModifier = modifierState.hasShortcutModifier() || !!modifierState.activeCharModifier();\n // Is this a case where we have to decide on the keysym right away, rather than waiting for the keypress?\n // \"special\" keys like enter, tab or backspace don't send keypress events,\n // and some browsers don't send keypresses at all if a modifier is down\n if (keysym && (type !== 'keydown' || kbdUtil.nonCharacterKey(evt) || hasModifier)) {\n result.keysym = keysym;\n }\n\n var isShift = evt.keyCode === 0x10 || evt.key === 'Shift';\n\n // Should we prevent the browser from handling the event?\n // Doing so on a keydown (in most browsers) prevents keypress from being generated\n // so only do that if we have to.\n var suppress = !isShift && (type !== 'keydown' || modifierState.hasShortcutModifier() || !!kbdUtil.nonCharacterKey(evt));\n\n // If a char modifier is down on a keydown, we need to insert a stall,\n // so VerifyCharModifier knows to wait and see if a keypress is comnig\n var stall = type === 'keydown' && modifierState.activeCharModifier() && !kbdUtil.nonCharacterKey(evt);\n\n // if a char modifier is pressed, get the keys it consists of (on Windows, AltGr is equivalent to Ctrl+Alt)\n var active = modifierState.activeCharModifier();\n\n // If we have a char modifier down, and we're able to determine a keysym reliably\n // then (a) we know to treat the modifier as a char modifier,\n // and (b) we'll have to \"escape\" the modifier to undo the modifier when sending the char.\n if (active && keysym) {\n var isCharModifier = false;\n for (var i = 0; i < active.length; ++i) {\n if (active[i] === keysym.keysym) {\n isCharModifier = true;\n }\n }\n if (type === 'keypress' && !isCharModifier) {\n result.escape = modifierState.activeCharModifier();\n }\n }\n\n if (stall) {\n // insert a fake \"stall\" event\n next({type: 'stall'});\n }\n next(result);\n\n return suppress;\n }\n\n return {\n keydown: function(evt) {\n sendAll(modifierState.keydown(evt));\n return process(evt, 'keydown');\n },\n keypress: function(evt) {\n return process(evt, 'keypress');\n },\n keyup: function(evt) {\n sendAll(modifierState.keyup(evt));\n return process(evt, 'keyup');\n },\n syncModifiers: function(evt) {\n sendAll(modifierState.syncAny(evt));\n },\n releaseAll: function() { next({type: 'releaseall'}); }\n };\n}", "title": "" }, { "docid": "ae5f85c6e7c06e0e163929696e9538a6", "score": "0.64427984", "text": "function hndlKeyDown(_event) {\n keysPressed[_event.key] = true;\n }", "title": "" }, { "docid": "ae478e5b5fbc51f9818924427bd709d7", "score": "0.64393884", "text": "function keyPressed(e) {\n\tswitch (e.keyCode) {\n\t\tcase 18: //Alt\n\t\t\tselectMultiple=!selectMultiple;\n\t\t\tdocument.getElementById(\"multiSelect\").checked = selectMultiple;\n\t\t\tbreak;\n\t\tcase 13: //Carriage return\n\t\t\tmodalthing = document.getElementById(\"modalbox\");\n\t\t\tif (modalthing.style.display == \"block\") {\n\t\t\t\tokModal();\n\t\t\t}\n\t\t\tbreak;\n\t}\n}", "title": "" } ]
08eba71bf0837e5a1cd61ede6c90c63f
another read() call => stack overflow. This way, it might trigger a nextTick recursion warning, but that's not so bad.
[ { "docid": "ba90ccae155797a8fa3a7a0452d214c1", "score": "0.0", "text": "function emitReadable(stream) {\n var state = stream._readableState;\n debug('emitReadable', state.needReadable, state.emittedReadable);\n state.needReadable = false;\n\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n process.nextTick(emitReadable_, stream);\n }\n}", "title": "" } ]
[ { "docid": "9ff7e14d235d45d9aea99693effc6140", "score": "0.64204574", "text": "function readN() {\n setN(read());\n}", "title": "" }, { "docid": "e914602b9b639e9cea78158dc61c1275", "score": "0.6245672", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state)}}", "title": "" }, { "docid": "c5eec4afd3df3b429322dc2886b1c567", "score": "0.6202474", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "c5eec4afd3df3b429322dc2886b1c567", "score": "0.6202474", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "c5eec4afd3df3b429322dc2886b1c567", "score": "0.6202474", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "c5eec4afd3df3b429322dc2886b1c567", "score": "0.6202474", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "c5eec4afd3df3b429322dc2886b1c567", "score": "0.6202474", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "c5eec4afd3df3b429322dc2886b1c567", "score": "0.6202474", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "c5eec4afd3df3b429322dc2886b1c567", "score": "0.6202474", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "18427f2d3d1c867c901f2b6538e7ac86", "score": "0.6198205", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;process.nextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "8571ea7a6594c1c07486e8158bf384fa", "score": "0.6194152", "text": "_read() {}", "title": "" }, { "docid": "f32de037904fbe2182d7045f8f334c6b", "score": "0.61281073", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;process.nextTick(function(){maybeReadMore_(stream,state);});}}", "title": "" }, { "docid": "f32de037904fbe2182d7045f8f334c6b", "score": "0.61281073", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;process.nextTick(function(){maybeReadMore_(stream,state);});}}", "title": "" }, { "docid": "e565f8ee7bda70dbfad6d8128ad68d46", "score": "0.6111671", "text": "function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;pna.nextTick(maybeReadMore_,stream,state);}}", "title": "" }, { "docid": "4bed019f3b3a404f0a02c11147d4415d", "score": "0.5995903", "text": "function maybeReadMore(stream$$1, state$$1) {\n if (!state$$1.readingMore) {\n state$$1.readingMore = true;\n process.nextTick(maybeReadMore_, stream$$1, state$$1);\n }\n}", "title": "" }, { "docid": "443f737a68d4327d44a65d979ac0b85e", "score": "0.5980527", "text": "function maybeReadMore(stream, state) {\n\t\t\t\t\t\t\tif (!state.readingMore) {\n\t\t\t\t\t\t\t\tstate.readingMore = true;\n\t\t\t\t\t\t\t\tprocess.nextTick(function() {\n\t\t\t\t\t\t\t\t\tmaybeReadMore_(stream, state);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}", "title": "" }, { "docid": "a4c6dcf758e7ea1a6294d2e65a214faa", "score": "0.5923476", "text": "_read() {\n const self = this;\n\n self.__read(self.offset,\n function(err, data) {\n if (err) {\n self.emit('error', err);\n if (self._autoCloseLob) {\n self.emit('close');\n }\n return;\n }\n\n if (data) {\n self.offset += data.length;\n }\n\n self.push(data);\n\n if (self._autoCloseLob && !data) {\n process.nextTick(function() {\n self.emit('close');\n });\n }\n }\n );\n }", "title": "" }, { "docid": "470a939ce1b197bc4e3ea985c6194795", "score": "0.5914547", "text": "function flow(e,t,n){depth+=1;var r=e.read(t);r?n(r):e.once(\"readable\",flow.bind(null,e,t,n));depth-=1;console.log(\"flow(\"+depth+\"): exit\")}", "title": "" }, { "docid": "ca77217129366b4c4a81c8057e07f4d3", "score": "0.589654", "text": "_read(size) {\n // no more data\n if (this.inputs.length == 0) {\n setImmediate(() => this.push(null));\n } else {\n // remove the first input, and push that on the next event loop\n let input = this.inputs[0];\n this.inputs = this.inputs.slice(1);\n setImmediate(() => this.push(input));\n }\n }", "title": "" }, { "docid": "0a83a14eb297c030eb5ff6f7147be905", "score": "0.5871609", "text": "function _GpfStreamBufferedReadToken () {\n}", "title": "" }, { "docid": "71619e0c44cbd19f898669b924c5fe01", "score": "0.58619046", "text": "function maybeReadMore(stream, state) {\n\t\t if (!state.readingMore) {\n\t\t state.readingMore = true;\n\t\t process.nextTick(function() {\n\t\t maybeReadMore_(stream, state);\n\t\t });\n\t\t }\n\t\t}", "title": "" }, { "docid": "7c74d6a5cc883f91b6c8a8d9183c2756", "score": "0.5861796", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function () {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "32fc267b7474e29e272d8f6ad4817ffc", "score": "0.5859495", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore && state.constructed) {\n state.readingMore = true\n process.nextTick(maybeReadMore_, stream, state)\n }\n}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "676c7976342185eeaabf2a0331abfb90", "score": "0.58582217", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(function() {\n\t maybeReadMore_(stream, state);\n\t });\n\t }\n\t}", "title": "" }, { "docid": "241cc6678036bf076c15456e86fd5e17", "score": "0.5842184", "text": "function maybeReadMore(stream, state) {\n\t\t\t\t\t\t\tif (!state.readingMore) {\n\t\t\t\t\t\t\t\tstate.readingMore = true;\n\t\t\t\t\t\t\t\tpna.nextTick(maybeReadMore_, stream, state);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}", "title": "" }, { "docid": "9fb6c6a9dc19134653e9adb206d573c0", "score": "0.58329284", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t process.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "4ff65be34dc50fb01f9aef1a1aa2d6cf", "score": "0.58186316", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n nextTick(maybeReadMore_, stream, state);\n }\n }", "title": "" }, { "docid": "7ec6a1851fede2ef6a26a04929192323", "score": "0.5806665", "text": "read() {\n }", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "0c0ad597e5cfb04310fd1c7d222322db", "score": "0.5789399", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8cf14feb4637d673dccae97e9b24a2e7", "score": "0.5788868", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n nextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "8cf14feb4637d673dccae97e9b24a2e7", "score": "0.5788868", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n nextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "8cf14feb4637d673dccae97e9b24a2e7", "score": "0.5788868", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n nextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "6280cbe23fd15a78390003d865757191", "score": "0.5784636", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n }", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "8b7296a21370dd599a393a77b08b98a7", "score": "0.5774099", "text": "function maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t pna.nextTick(maybeReadMore_, stream, state);\n\t }\n\t}", "title": "" }, { "docid": "4f8b27ba7f6617b616467c59bce6876d", "score": "0.576491", "text": "read() {\n throw new ObnizError_1.ObnizDeprecatedFunctionError(\"read\", \"readWait\");\n }", "title": "" }, { "docid": "93301b557b5240dc1d48197115926b55", "score": "0.5748125", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n }", "title": "" }, { "docid": "93301b557b5240dc1d48197115926b55", "score": "0.5748125", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n }", "title": "" }, { "docid": "c94a8e842520908e56205b853cb1e6b2", "score": "0.57427555", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n }", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" }, { "docid": "b0cc94c95f073375bf24013c6a92b09a", "score": "0.5741158", "text": "function maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n processNextTick(maybeReadMore_, stream, state);\n }\n}", "title": "" } ]
d4e68ee12f934e4b03e880108e19a486
handles submitting button to send messages
[ { "docid": "acfa2500d7553d86c074793bf358114f", "score": "0.626809", "text": "handleSubmit(e) {\n e.preventDefault();\n //invokes sendMessage function with inputted text which was earlier kept in this.state.message\n this.sendMessage(this.state.message);\n //clears input field after msg is sent\n this.setState({\n message: \"\"\n });\n //keeps input focused after submitting msg\n this.nameInput.focus();\n }", "title": "" } ]
[ { "docid": "827300b1c0b8a93f6f42b0736542d998", "score": "0.74214566", "text": "submitMessage(e) {\n e.preventDefault();\n this.sendMessage(e);\n }", "title": "" }, { "docid": "89fa7ae0cabec1594fb1bf2d5a0c3fc6", "score": "0.72943574", "text": "function onMessageFormSubmit(e) {\n e.preventDefault();\n // Check that the user entered a message\n if (messageInputElement.value) {\n submitNewNumber(messageInputElement.value.trim()).then(function() {\n // Clear message text field and re-enable the SEND button.\n resetMaterialTextfield(messageInputElement);\n toggleButton();\n });\n }\n}", "title": "" }, { "docid": "852e2937b2e0b098bfcc60fd0cd91301", "score": "0.72824097", "text": "submitMessage(e) {\n e.preventDefault();\n let content = $(this.$form.get(0).elements.input).val();\n $(this.$form.get(0).elements.input).val('');\n this.getHost().submitMessage(this.getMessageObj(content));\n }", "title": "" }, { "docid": "7a1d16c862e89a21d2b579fa82d360be", "score": "0.72410077", "text": "function submitHandler(name, email, message) {\r\n sendMessage({ name, email, message })\r\n .then(() => {\r\n alert(\"Sent Successfully!\");\r\n window.location.reload();\r\n })\r\n .catch(err => {\r\n alert(\"There was an error. Please try again later\" + err);\r\n window.location.reload();\r\n });\r\n }", "title": "" }, { "docid": "f324e6090299ed5e1299e10449c96b62", "score": "0.71528375", "text": "function handleSubmit(e) {\n e.preventDefault();\n socket.emit(\"new message\", {\n message: newMessage,\n user: props.user,\n });\n setNewMessage(\"\");\n }", "title": "" }, { "docid": "8ac30775449bbaaef95de81442bb53a5", "score": "0.71261114", "text": "function sendButton(){\r\n\r\n var btn = $(\"#sendButton\");\r\n\r\n btn.click(function(){\r\n\r\n sendMessage( $(\"#messageInput\") );\r\n })\r\n}", "title": "" }, { "docid": "cda2939b2c4b0812985b276b5d67b907", "score": "0.70616794", "text": "function onMessageFormSubmit(e) {\n e.preventDefault();\n // Check that the user entered a message and is signed in.\n if (messageInputElement.value && checkSignedInWithMessage()) {\n saveMessage(messageInputElement.value).then(function() {\n // Clear message text field and re-enable the SEND button.\n resetMaterialTextfield(messageInputElement);\n toggleButton();\n });\n }\n}", "title": "" }, { "docid": "5a9ecac7fb293cb9fe7c0bfc6c31af5d", "score": "0.70259386", "text": "function submitfunction(){\n var from = $('#user').text();\n var message= $('#m').val();\n if(message != ''){\n socket.emit('chatMessage',from,message); //send to server on chatMessage\n }\n $('#m').val('').focus();\n\n return false;\n\n}", "title": "" }, { "docid": "de040e7ea09cabe80b3cba821f9d9f2b", "score": "0.7025312", "text": "function submitClicked_() {\n\n var submit = this,\n form = submit.parentNode,\n textarea = getFormTextarea(form);\n\n send_( textarea );\n\n }", "title": "" }, { "docid": "4953e387de6485200582d1dbf7dfb6d0", "score": "0.69910574", "text": "function sendMessage(){\n\t\t\t// send message data to backend\n\t\t\tsocket.emit(\"send\", { message : $('.field').val() });\n\t\t\t// clear the textbox input\n\t\t\t$('.field').val(\"\");\n\t}", "title": "" }, { "docid": "85c3d3b71ba628d5ba40194753de3363", "score": "0.6952673", "text": "function submitChatMsg(e) {\n e.preventDefault();\n\n const inputMessage = document.querySelector('#message');\n\n if (inputMessage.value) {\n let msg = inputMessage;\n let msgText = inputMessage.value;\n\n // Emit message to server\n socket.emit('chatMessage', { msg: msgText, room: globalRoom });\n\n // Clear input\n inputMessage.value = '';\n msg.focus();\n }\n}", "title": "" }, { "docid": "09b64b2aac051ef50c9a0d13cb315fa1", "score": "0.69132197", "text": "function send() {\n\t\tsendMessage('chat-message', {\n\t\t\t\"username\": getChatUsername(),\n\t\t\t\"message\": getChatMessage()\n\t\t});\n\n\t\t// Clear the input field after sending\n\t\tqs('#chat-input').value = '';\n\t}", "title": "" }, { "docid": "f8f18781fd4f30fdfc05a8a85580d4ea", "score": "0.690797", "text": "function send(msg){\na=document.getElementsByClassName('input')[1];\ndispatch(a,\"textInput\",msg);\ndocument.getElementsByClassName('icon-send')[0].click();\n}", "title": "" }, { "docid": "23e6d3b4e64285f7d807f81a55d39645", "score": "0.6879788", "text": "onButtonClick(e) {\n\n if (this.state.newMsg !== \"\") {\n //this.joinNewUserMsg(this.state.newMsg)\n this.sendMsgToServer(this.state.newMsg)\n }\n }", "title": "" }, { "docid": "04ac6a215c141f31465326cf8591e274", "score": "0.6870938", "text": "function sendButtonMessage(recipientID) {\n sendTextMessage(recipientID, \"Respondendo um botao\");\n}", "title": "" }, { "docid": "8cc74939d39b0b57b2a841ed29ed0657", "score": "0.68495667", "text": "sendMessage() {\n const messageInput = this.template.querySelector('.chat-message');\n const valid = reportFormValidity([messageInput], inputError);\n if (valid) {\n this.handlePublish();\n }\n }", "title": "" }, { "docid": "f31535c4b5e887abafbfc4d47d0306ae", "score": "0.68444425", "text": "function submitMessage(){\n\tvar data = getData();\n\tajax(\"/handle_data\",\"POST\",data);\n\treturn false;\n}", "title": "" }, { "docid": "78707974fb7e455e5606239f047959b2", "score": "0.6821585", "text": "function submitMessage(e) {\r\n\t\te.preventDefault();\r\n\t\tvar text = $(\"#inputtext\").val();\r\n\t\t$(\"#inputtext\").val(\"\");\r\n\t\tif (currentChatRef) {\r\n\t\t\t// Push the message to the chatroom. Calls currentChatRef child_added listener\r\n\t\t\tcurrentChatRef.push(text);\r\n\t\t}\r\n\t}", "title": "" }, { "docid": "082e6f85d61466ccb87144a1d7499a32", "score": "0.6818507", "text": "function submitMessage() {\n\t\t\t\tvar format = {\n\t\t\t\t\t'color': $('#colorpicker').val(),\n\t\t\t\t\t'style': $('#fontstyle').val(),\n\t\t\t\t\t'size': $('#fontsize').val(),\n\t\t\t\t\t'family': $('#fontfamily').val()\n\t\t\t\t};\n\n\t\t\t\tvar message = {\n\t\t\t\t\t'content': $('#submit_message_text').val(),\n\t\t\t\t\t'format': format\n\t\t\t\t}\n\t\t\t\tif (!message.content.replace(/^\\s+/, '').replace(/\\s+$/, ''))\n\t\t\t\t\treturn;\n\n\t\t\t\t$('#submit_message_text').val(\"\");\n\t\t\t\t$.get(\n\t\t\t\t\tposturl + '&message=' + encodeURIComponent(JSON.stringify(message)) + '&' + buildMoreOptions(),\n\t\t\t\t\tfunction (response) {\n\t\t\t\t\t\tresponse = typeof response == 'object' ? response : $.getAsObject(response);\n\t\t\t\t\t\tif (!response.success) {\n\t\t\t\t\t\t\talert(response.reason);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t'json'\n\t\t\t\t);\n\t\t\t}", "title": "" }, { "docid": "41dd01ba525514a27613185c09e47c93", "score": "0.68101186", "text": "onSubmitButtonClick(){\n var outputMessage = (this.areRequiredInputsFilled()) ? this.getFormattedFormContent() : this.errorMessage;\n\n this.printToOutput(outputMessage);\n }", "title": "" }, { "docid": "67413df18d76f5ebb44c69f1164e61da", "score": "0.67974824", "text": "function whenSend(){\n\t\t$(\"#send\").click(function(){\n\t\t\t$.ajax({\n\t\t\t\turl:\"/chat/set-msg\",\n\t\t\t\ttype:\"post\",\n\t\t\t\tdata:{\n\t\t\t\t\tmsg: $(\"#textbox\").val(),\n\t\t\t\t\t_token: $('body [token]').attr('token')\n\t\t\t\t},\n\t\t\t\tsuccess: function (data){\n\t\t\t\t\tvar prevMessage = $(\"#content\").html();\n\t\t\t\t\t $(\"#content\").append(\"You : \"+data+\"<br>\");\n\t\t\t\t\t $(\"#textbox\").val(\"\");\n\t\t\t\t\t},\n\t\t\t\terror: function(){\n\t\t\t\t\talert(\"error\");\n\t\t\t\t} \n\n\t\t\t});\n\n\t\t});\n\t}", "title": "" }, { "docid": "f67f84e60b4dd4d025b9049c4a38afd5", "score": "0.67966235", "text": "function sendMessage() {\n\tvar message_request;\n\t//Get the messages from the database somehow\n\tif ($('.write-message').is(':empty')){\n\t\tmessage_request = \"/sendMessage?message=\" + $(\".write-message\").val();\n\t\t$.get(message_request, function(response) {\n\t\t\tconsole.log(\"Logged Message Sent - \" + response + \"\");\n\t\t});\n\t}\n}", "title": "" }, { "docid": "02d75163da79a5bc07e2576d2f84eba3", "score": "0.6794042", "text": "function sendMessage () {\n var message = $inputMessage.val();\n var submitTime = new Date($.now());\n submitTime = submitTime.toString();\n if (message) {\n $inputMessage.val('');\n addChatMessage({\n username: username,\n message: message,\n submitTime: submitTime\n });\n socket.emit('new message', {message: message, submitTime: submitTime});\n }\n }", "title": "" }, { "docid": "783f863698833b63f0b1920b16c32847", "score": "0.6781362", "text": "function submitForm(event) {\n event.preventDefault();\n\n const newMessage = document.getElementById('user-message').value;\n console.log(newMessage)\n nsSocket.emit('newMessageFromClient', { message: newMessage });\n}", "title": "" }, { "docid": "b3fee830fdbd7d945d35fa35045b17c7", "score": "0.67713386", "text": "function sendMessage()\n{\n const textInput = document.getElementById(\"message\");\n const message = textInput.value;\n textInput.value = \"\";\n textInput.focus();\n\n if(message != \"\") {\n addPost(name, message, true);\n sendPost(name, message);\n }\n}", "title": "" }, { "docid": "7e4fdb4d541cad3e66b4827eb4e0df66", "score": "0.67485464", "text": "function sendData(){\n\tvar toSend = document.getElementById(\"toSend\");\n\tconsole.log(toSend.value);\n\ttry{\n\t\ttextChannel.send(toSend.value);\n\t\tdocument.getElementById(\"messages\").innerHTML += \"<p><b>Moi :</b> \"+ toSend.value +\"</p>\";\n\t\t\n\t\t//once message sent, textarea is cleared and focused once new (in button clicked case)\n\t\ttoSend.value = '';\n\t\ttoSend.focus();\n\t}\n\tcatch(e){\n\t\ttrace(e.message);//trace equals to console.log. Comes from Google's adapter.js\n\t}\n}", "title": "" }, { "docid": "7cdf5b2ac349aa3e9d60467dbbdf0578", "score": "0.6745156", "text": "handleSubmit(message) {\n this.send(message, () => {\n this.refresh();\n });\n }", "title": "" }, { "docid": "7d655828613a654574f8e1a6d78a9c72", "score": "0.6715605", "text": "function sendMessage () {\n var outgoing = document.getElementById(\"outgoing\");\n if (outgoing.value.length > 0) {\n msgManager.sendUPC(UPC.SEND_MESSAGE_TO_ROOMS, \"CHAT_MESSAGE\", pl.edu.libratus.orbiter.room.id, \"true\", \"\", outgoing.value);\n outgoing.value = \"\";\n // Focus text field again after submission (required for IE8 only)\n setTimeout(function () {\n outgoing.focus();\n }, 10);\n }\n}", "title": "" }, { "docid": "9f79bfee7938df4e705719ceb7816bd8", "score": "0.6694468", "text": "async function sendMessage(e) {\r\n if (e.key === \"Enter\" && currentUser) {\r\n const message = msgInput.value;\r\n msgInput.value = \"\";\r\n\r\n const form = new FormData();\r\n form.append('userTo', currentUser);\r\n form.append('msg', message);\r\n\r\n //checks for a valid user\r\n const res = await fetch(\"data/messages.php\", {\r\n method: 'POST',\r\n credentials: 'same-origin',\r\n body: form,\r\n });\r\n const json = await res.json();\r\n\r\n const returnedMessage = json.message;\r\n const { body, date} = returnedMessage;\r\n\r\n currentMessagesDiv.innerHTML += `<div class=\"message self\">\r\n <p class=\"msg-text\">${body}</p>\r\n <p class=\"small text-muted\">${date}</p>\r\n </div>`;\r\n\r\n e.preventDefault();\r\n }\r\n}", "title": "" }, { "docid": "219b565ead4bc8368a8e48c8ea2852fd", "score": "0.66893715", "text": "function send(){\r\n var dataToSend = {\r\n action: 'send',\r\n message: $('#messageBox').val()\r\n } \r\n $('#messageBox').val('');\r\n \r\n $.post(server, dataToSend,responseReceived);\r\n}", "title": "" }, { "docid": "9c894040253c3054bdd4461079634729", "score": "0.66687715", "text": "function onMessageFormSubmit(e) {\n e.preventDefault();\n var message = messageInputElement.value;\n var isItValid = validWord(message);\n // Check that the user entered a message and is signed in.\n if (message && checkSignedInWithMessage()) {\n // Check if gaming is running\n if (gameOngoing == true) {\n //Check if string is one word (no spaces)\n if (message.includes(' ') == false) {\n if (isItValid == true) {\n alreadySubmitted(message);\n }\n } else {\n var spaceSnackbar = {\n message: \"Answers can't have any spaces, Try Again!\",\n timeout: 2000\n };\n signInSnackbarElement.MaterialSnackbar.showSnackbar(spaceSnackbar);\n }\n }\n saveMessage(message).then(function() {\n // Clear message text field and re-enable the SEND button.\n resetMaterialTextfield(messageInputElement);\n toggleButton();\n });\n }\n}", "title": "" }, { "docid": "fe638df17c3d4f9c653b4d8e994904fd", "score": "0.6662644", "text": "function sendFormMessage(e) {\r\n e.preventDefault();\r\n\r\n const message = createMessage(\r\n createTemplate(\"teal\", nameInput.value, messageInput.value)\r\n );\r\n\r\n //get the message node to add a class to it\r\n //different style in user message\r\n message.childNodes[1].classList.add(\"user-message\");\r\n\r\n //add html tag\r\n chat.appendChild(message);\r\n\r\n //Scroll to last message\r\n chat.scrollTo(0, chat.scrollHeight);\r\n\r\n //Disable username change\r\n nameInput.disabled = true;\r\n sendButton.disabled = true;\r\n\r\n //Delete what was written in the input\r\n messageInput.value = \"\";\r\n}", "title": "" }, { "docid": "59717f339160805cb81c3e5bce3bc258", "score": "0.66616714", "text": "function sendButton() {\n getResponse();\n}", "title": "" }, { "docid": "ff585464d1d1f77afeb45443a65f43b3", "score": "0.6653972", "text": "function blockSubmit() {\n\t\t\t\tsendChatText();\n\t\t\t\treturn false;\n\t\t\t}", "title": "" }, { "docid": "9076ce77084591cef326b114a11600c6", "score": "0.66515005", "text": "function sendBtn(btn) {\n\tdocument.getElementById('handle').innerHTML = btn\n\tdocument.getElementById('send').click()\n}", "title": "" }, { "docid": "799ced8f7097941638b93f5152481ee7", "score": "0.6649468", "text": "function sendMessage1() {\n var messageToSend1 = $('#btn-input-chat1').val();\n sendbird1.message(messageToSend1);\n}", "title": "" }, { "docid": "9d839e89c77ae400fb9ec449057b1ed5", "score": "0.6639801", "text": "function handleSubmit(ev) {\n ev.preventDefault();\n var text = ev.target.elements.text.value;\n var msg = new Mensaje(text);\n allOfMsgs.addNewMsg(msg);\n window.location.reload();\n}", "title": "" }, { "docid": "e4456ff233e01be78d45bd609e573cab", "score": "0.6637989", "text": "function sendMessage() {\n document.querySelector('.btn-submit').addEventListener(['click', 'keypress'], () => {\n validationContact();\n });\n}", "title": "" }, { "docid": "4653b2c122667f15bd7953414d65f59d", "score": "0.6624657", "text": "function submitChatInput()\n{\n\tlet input = Engine.GetGUIObjectByName(\"chatInput\");\n\tlet text = input.caption;\n\n\tif (!text.length)\n\t\treturn;\n\n\tif (handleChatCommand(text))\n\t\tEngine.LobbySendMessage(text);\n\n\tinput.caption = \"\";\n}", "title": "" }, { "docid": "334004e2be34f3367b707540c9dcf9a7", "score": "0.66118497", "text": "sendMessage() {\n if (this.msgInput.value.length > 0) {\n this.globalChatWindow.postMessage({author: this.name, message: this.msgInput.value}, '*');\n this.msgInput.value = '';\n }\n }", "title": "" }, { "docid": "bba320bbfbf07fb2a17c97542344d4db", "score": "0.65969604", "text": "function sendButtonClicked(event){\n var text = messageText.value;\n if(dataChannel.readyState == \"open\" && text.length>0)\n {\n console.log(\"sending\" + text);\n dataChannel.send(text);\n }\n}", "title": "" }, { "docid": "ff99006fc50fb05d3f0bb86d3051a2e0", "score": "0.65819794", "text": "function submit_message(message) {\n var socketId = pusher.connection.socket_id\n $.post(\"/send_message\", {\n message: message,\n socketId: socketId\n })\n}", "title": "" }, { "docid": "e0ffdcf5c19d642c83f2dfc2f87e2336", "score": "0.6543902", "text": "function sendMessage(event) {if (event.keyCode == 13 && event.ctrlKey) {var mF = $xf(\"//form[@name='msg']\"); if (mF) mF.submit();}; return;}", "title": "" }, { "docid": "67a9a91fb9c76efdd1fc3062d3cac8c1", "score": "0.6535494", "text": "function chatInputSubmit() {\n\tvar chatMsg = $(\"#interaction-chat-input\").val().trim();\n\t$(\"#interaction-chat-input\").val(\"\");\n\t$(\"#interaction-chat-input-char-counter\").text(\"0/50\");\n\tif(chatMsg && chatMsg.length<=50) {\n\t\tvar timeId = Date.now();\n\t\tif(Number($(\"#playground\").attr(\"data-game-category\")) != 0 && $(\"#playground\").attr(\"data-is-game-closed\") != \"true\") { // => Timed Game (for all viewers Active and Non-Active(spectators))\n\t\t\tif($(\".player\").attr(\"data-is-active-player\") === \"true\") { // => (Active) Player mode\n\t\t\t\tchatInputAnimation(timeId, chatMsg, \"player\");\n\t\t\t\tsocket.emit(\"chatInput\", {timeId: timeId, chatMsg: chatMsg});\n\t\t\t}\n\t\t\t// else { // => Spectator mode\n\t\t\t// \t// Not implemented so far\n\t\t\t// \tsocket.emit(\"chatInput\", {timeId: timeId, chatMsg: chatMsg});\n\t\t\t// }\n\t\t}\t\n\t\t$(\"#interaction-chat-input-send-btn .fa\").removeClass(\"tada\");\n\t\t$(\"#interaction-chat-input-send-btn .fa\").addClass(\"bounceOut\");\n\t\tsetTimeout(function(){\n\t\t\t$(\"#interaction-chat-input-send-btn .fa\").removeClass(\"bounceOut\");\n\t\t\t$(\"#interaction-chat-input-send-btn .fa\").addClass(\"bounceIn\");\n\t\t\tsetTimeout(function(){\n\t\t\t\t$(\"#interaction-chat-input-send-btn .fa\").removeClass(\"bounceIn\");\n\t\t\t}, 700);\n\t\t}, 900);\n\t}\t\n}", "title": "" }, { "docid": "db684a38e7aa1187421e9d28e7534d78", "score": "0.6532013", "text": "function onSendPublicMessageBtClick(event) {\r\n var msg_str = $(\"#msg_txt\").val();\r\n if (msg_str !== \"\") {\r\n var isSent = sfs.send(new SFS2X.Requests.System.PublicMessageRequest(msg_str));\r\n if (isSent){\r\n $(\"#msg_txt\").val(\"\");\r\n }\r\n }\r\n}", "title": "" }, { "docid": "e01b395f372dd2cf663ade2218cecf89", "score": "0.65282774", "text": "sendMessage(e) {\n e.preventDefault();\n\n // Valores obtenidos de los inputs\n const params = {\n name: this.inputName.value,\n source: this.inputSource.value,\n quote: this.textAreaQuote.value,\n other: this.textAreaOther.value\n };\n\n // Validamos que no se encuentren vacios los campos requeridos del formularios\n if (params.name && params.source && params.quote) {\n this.handleToggle();\n // \"params\" se envia a firebase database\n const db = firebaseConfig.database().ref('contactForm').push(params).then(() => {\n console.log('El mensaje fue enviado exitosamente');\n }).catch(() => {\n console.log('El mensaje no pudo ser enviado');\n });\n this.resetForm();\n }\n }", "title": "" }, { "docid": "48dd4cee2a5e32804b42584c6f48507a", "score": "0.6527379", "text": "function sendMessage(e) {\r\n e.preventDefault();\r\n\r\n\r\n // get values to be submitted\r\n const timestamp = Date.now();\r\n const messageInput = document.getElementById(\"message-input\");\r\n const message = messageInput.value;\r\n\r\n\r\n // clear the input box\r\n messageInput.value = \"\";\r\n\r\n\r\n document\r\n .getElementById(\"messages\")\r\n .scrollIntoView({ behavior: \"smooth\", block: \"end\", inline: \"nearest\" });\r\n\r\n // create db collection and send in the data\r\n db.ref(\"messages/\" + timestamp).set({\r\n username,\r\n message\r\n });\r\n}", "title": "" }, { "docid": "2f22a587a8812f3a415ecb7efb71d638", "score": "0.65157795", "text": "function submittoChatroomfunction(){\n var from = $('#loggedUser').val();\n var chatroom = $('#chatroom').val();\n var message = $('#msgbox').val();\n if(message != '' ) {\n socket.emit('chatroomMessage', chatroom, from, message);\n}\n$('#msgbox').val('').focus();\n return false;\n}", "title": "" }, { "docid": "36c6d03524690e5e1c1719de5f8dafdf", "score": "0.651456", "text": "function handleMessageFormSubmit(){\n var title = $(\"#title\").val();\n var text = $(\"#text\").val();\n var name = $(\"#name\").val();\n console.log(title);\n console.log(text);\n console.log(name);\n addMessage(title, text,name);\n $(\"#title\").val(\"\");\n $(\"#text\").val(\"\");\n $(\"#name\").val(\"\");\n\n\n}", "title": "" }, { "docid": "5144855acdf6bed44852fa066f412d24", "score": "0.6492567", "text": "_onSendMessage() {\n console.log('Send Message requested');\n this._processAndSendMessage(this.state.text);\n\n this.state.text = '';\n this.state.shouldShowSendMessageButton = false;\n this.setState(this.state);\n }", "title": "" }, { "docid": "c1f5521896846dcf5f6f7b2b0cd967a7", "score": "0.6490875", "text": "function handleSend(e) {\n e.preventDefault();\n if (newMessage) {\n setMessages((messages) => [\n ...messages,\n { who: \"user\", text: newMessage },\n ]);\n setNewMessage(\"\");\n setTimeout(botReply, 800);\n }\n }", "title": "" }, { "docid": "4cb51d92e828c17d696104f3b67d0b46", "score": "0.64907986", "text": "function send() {\n var msg = $input.val().trim()\n if (msg) {\n socket.emit('message', msg)\n $messages.prepend('<li><span><b>' + socket.socket.sessionid + '</b></span> ' + msg + '</li>')\n }\n $input.val('')\n }", "title": "" }, { "docid": "6333d24a29b8e42d8956173247fcd43d", "score": "0.6479007", "text": "replyButtonClick() {\n if (this.replyForm) {\n this.replyForm.cancel();\n } else {\n this.reply();\n }\n }", "title": "" }, { "docid": "91eca47a80b438deb1aa872512702295", "score": "0.6474522", "text": "function sendMessage() {\n let message = elTextArea.value.trim();\n if (message != \"\"){\n moveMessageToHistory('from-user', message);\n elTextArea.value = \"\";\n let formattedMessage = formatMessage(message)\n watsonCommunication = openCommunicationToWatson();\n watsonCommunication.onreadystatechange = receiveMessage\n watsonCommunication.send(formattedMessage);\n }\n}", "title": "" }, { "docid": "57d36a669f9736df5459437f4e3bc52b", "score": "0.6472798", "text": "onSubmit(e){\n e.preventDefault()\n this.props.sendMessage(this.state.message)\n this.setState({\n message: ''\n })\n }", "title": "" }, { "docid": "ab1c4ace532c5bc5d874ce018e932a94", "score": "0.64709085", "text": "function onSendMessage(ev) {\n ev.preventDefault()\n document.querySelector('.message-sent-container').style.display = 'flex';\n toggleModal();\n}", "title": "" }, { "docid": "968dabae4ec97dbe5f81d2c53994342f", "score": "0.64695233", "text": "function sendChatButtonFunction (){\ndocument.querySelector(\"body\").addEventListener(\"click\", ()=>{\n // targets button id\n if (event.target.id.includes(\"Sendmsg\")){\n // value of what a user types into chatroom\nconst chatinput = document.querySelector(\"#Chatinput\").value;\nconsole.log(chatinput)\n// new message structure\nconst msgObject= {\n \"message\": chatinput,\n \"userId\": localStorage.getItem(\"userId\")}\n // posts new message to json\napiChat.postOneMessage(msgObject)\n// gets all messages and prints\n.then(apiChat.getAllMessages)\n// parses messages\n.then(parsedMessages =>{\n renderChat.buildChatCard(parsedMessages)})\n}})}", "title": "" }, { "docid": "53d93579f2f4bdd5c155370753e1f95f", "score": "0.6459303", "text": "function requestform(e){\n e.preventDefault();\n loader.style.display= 'block';\n btn.style.display= 'none';\n \n \n\n //get values from request home tutor\n var name = getInputval('name');\n var email = getInputval('email');\n var phone = getInputval('phone');\n \n \n \n var subject = getInputval('subject');\n var address = getInputval('address');\n \n \n \n\n savemessage(name, email,phone,subject,address);\n \n}", "title": "" }, { "docid": "6f82c4a5b50d079912e34079c142d0e4", "score": "0.64590216", "text": "function handleFormSubmit() {\n onReplySubmitted({ commentId, postId, reply })\n setReply('')\n }", "title": "" }, { "docid": "13dfb7f6949ba252bf6c66456cf524ed", "score": "0.64574754", "text": "function submitChat() {\n var input = $('#message').val();\n \n if (input) {\n socket.emit('message', {message: input, room: currentRoom});\n }\n\n // Clear the typed message.\n $('#message').val('');\n}", "title": "" }, { "docid": "aa7fcd6a4d0f5f03eed8560bb2b32622", "score": "0.64527804", "text": "function signalR_SubmitForm() {\n if (debug) {\n echoBrowserMessage('<b style=\"color: gold\">Event: </b><span style=\"color: blue\">Submit Form Method Invoked - </span>Sending Message to SignalRServer');\n }\n\n signalR.invoke('submitForm');\n}", "title": "" }, { "docid": "8297bf0364ec302db6cfba37fe8224b4", "score": "0.64456475", "text": "function send(){\r\n var text = document.getElementById(\"messageinput\").value;\r\n webSocket.send(text);\r\n }", "title": "" }, { "docid": "90a6fd2260648be3ad9b95735a43ece3", "score": "0.6435127", "text": "function postMessage(){\n\tvar myMessage = $('#message').val();\n\t$('#message').val('');\n\tsocket.emit('messageFromClient', {message: myMessage, role: global.role, name: global.name});\t\n}", "title": "" }, { "docid": "e244c57e6838a2ca4d39d83924120314", "score": "0.6430292", "text": "function sendForm() {\n 'use strict';\n var status = false;\n\n if (document.forms['ss-form']['entry.901227537'].value === \"\" && document.forms['ss-form']['entry.458261783'].value === \"\") {\n $('#ss-submit').replaceWith($('#ss-submit').clone(true));\n $('#ss-submit').addClass('button-shake');\n $('.form-name,.form-email,.form-text').addClass('form-input-warning');\n } else {\n status = true;\n $('#ss-submit').removeClass('button-shake').addClass('button-sent').attr('disabled', true);\n $('.form-name,.form-email,.form-text').removeClass('form-input-warning');\n $('.form-name,.form-tel,.form-email,.form-text').addClass('form-input-sent');\n $('.form-message').css({'opacity': '0'}).html(\"メッセージが送信されました\").addClass('form-message-sent').delay(500).animate({'opacity': '1'}, 300);\n }\n return status;\n}", "title": "" }, { "docid": "0eb62f2240bf6fe98939a7f417720665", "score": "0.64187217", "text": "function handleFormSubmit(event){\n event.preventDefault();\n \n var targetButton = $(this);\n //this variable stores the message written in the text area.\n scheduledItem = targetButton.parent().children().eq(1).val();\n //this variable stores the ID corresponding to the hour.\n var targetId = targetButton.siblings().eq(0).attr('id');\n\n messagesArray = JSON.parse(localStorage.getItem(\"myMessages\")) || [];\n\n var newMessObj = {elementId: targetId, message: scheduledItem}\n \n if(scheduledItem != undefined || scheduledItem != null){\n overwriteMessages(newMessObj);\n messagesArray.push(newMessObj);\n window.localStorage.setItem(\"myMessages\", JSON.stringify(messagesArray));\n }\n\n}", "title": "" }, { "docid": "c150a991840f07af0d95d0c5030cc6e7", "score": "0.64118236", "text": "function sendMessage () {\n var message = $inputMessage.val();\n // Prevent markup from being injected into the message\n message = cleanInput(message);\n // if there is a non-empty message and a socket connection\n if (message && connected) {\n $inputMessage.val('');\n stashMessage(message);\t// stash the message for delivery\n\n }\n }", "title": "" }, { "docid": "6bf380c003005d713c501e6051f0772f", "score": "0.6406616", "text": "functionSubmit(e) {\n e.preventDefault();\n //alert(\"Enviando...\");\n //alert(JSON.stringify(this.state));\n this.sendDataServer();\n }", "title": "" }, { "docid": "a2d4641305d176b47b6f5527b5297b4c", "score": "0.6405266", "text": "sendMessage() {\n\t\tvar url = HOST + \"newMsg\"\n\t\tvar params = {\n\t\t\t'msg': $(\"#msgInput\").val(),\n\t\t\t'user': this.username\n\t\t}\n\t\tvar callbackFn = () => this.loadMessages()\n\t \t$.get( url, params , callbackFn)\n\t \t// clear whats in the msgInput text-input field\n\t\t$(\"#msgInput\").val('')\n\t}", "title": "" }, { "docid": "728c79860a65856c686d7aea7f551d51", "score": "0.64042324", "text": "handleSubmit(event) {\r\n\r\n event.preventDefault()\r\n\r\n\r\n this.buttonsbutt(event);\r\n }", "title": "" }, { "docid": "b0baff135fade3b9bf649292c2a3bcf6", "score": "0.6400489", "text": "function ajaxSubmit(form) {\n var data = {\n action: \"askQuote\",\n dataType:\"JSON\",\n message_name: $(\"#message_name\").val(),\n message_email: $(\"#message_email\").val(),\n message_phno: $(\"#message_phno\").val(),\n message_company: $(\"#message_company\").val(),\n message_text: $(\"#message_text\").val(),\n to_email: $(\"#to_email\").val(),\n post_id: $(\"#post_id\").val(),\n submitted: $(\"#submitted\").val()\n };\n\n var button = $(form).find('#submit');\n\n var or_txt = button.val();\n console.log(or_txt);\n button.prop('disabled', true).val('Sending');\n\n $.post(sitesettings.ajaxurl, data, function (res) {\n var resultObj = $.parseJSON(res);\n if(resultObj.result === 'success'){\n $('#success').modal('show');\n }else{\n $('#error').modal('show');\n }\n button.prop('disabled', false).val('Sent');\n\n setTimeout(function () {\n button.val(or_txt);\n }, 1000);\n });\n }", "title": "" }, { "docid": "51fc5977664d0ae68d717a73fdb10db9", "score": "0.63995534", "text": "onSubmit(event) {\n event.preventDefault();\n this.props.addMessage(this.state.text, this.state.status.toString());\n }", "title": "" }, { "docid": "7245d2aee862c8456547a10a5fe63730", "score": "0.6397828", "text": "function handleMessage(event) {\n event.preventDefault();\n //gets data from form\n var form = event.target;\n var message = form.elements[\"message\"].value;\n var sender = form.elements[\"sender\"].value;\n\n //create a message object\n var msg = new Message(message, sender);\n //render the message\n msg.render();\n}", "title": "" }, { "docid": "6d0063b74dd339576108d8ceacbd6fac", "score": "0.6388868", "text": "function fetchAndSendMessage(){\n\tlet msg = document.getElementsByName(\"send-input\")[0].value;\n\tif (msg === \"\") {\n\t\treturn\n\t}\n\n\n\t$.post(\n\t\tbackendAddr+MESSAGES_PATH,\n\t\t{Msg:msg, Dest:select},\n\t\t'jsonp'\n\t)\n\n\n\tupdateChatBox()\n}", "title": "" }, { "docid": "181925ffbbd2514e93be455ec1701a59", "score": "0.6382835", "text": "function sendMessage() {\n var text = $input.val();\n var body = {message: text, scope: messenger.lastBotMessage ? messenger.lastBotMessage.scope : \"\"};\n\n messenger.send(text);\n if(messenger.validate(text))\n $.post(BASE_URL + 'talk', JSON.stringify(body), function(response){\n messenger.lastBotMessage = response;\n messenger.recieve(response.message);\n setEmotion(response.emotion);\n });\n\n $input.val('');\n $input.focus();\n }", "title": "" }, { "docid": "6af26d4fd8e034c19d43db9f763027aa", "score": "0.6381822", "text": "function sendMessage () {\n var outgoing = document.getElementById(\"outgoing\");\n var filter = new net.user1.orbiter.filters.AttributeFilter();\n var comparison = new net.user1.orbiter.filters.AttributeComparison(\"chatRoom.team\",\n orbiter.self().getAttribute(\"team\", \"chatRoom\"),\n net.user1.orbiter.filters.CompareType.EQUAL);\n filter.addComparison(comparison);\n\n if (outgoing.value.length > 0) {\n // displayChatMessage(\"Sending message to the \"\n // + orbiter.self().getAttribute(\"team\", \"chatRoom\") + \"team\");\n chatRoom.sendMessage(\"CHAT_MESSAGE\", \"true\", filter, outgoing.value, \"true\");\n outgoing.value = \"\";\n // Focus text field again after submission (required for IE8 only)\n setTimeout(function () {outgoing.focus();}, 10);\n }\n}", "title": "" }, { "docid": "c5b22e9808075629de0f79698cbb1c54", "score": "0.637839", "text": "function send_message(event) {\n // get and validate message from input field\n var user_message = document.getElementById(\"chat_form_input\").value;\n user_message = user_message.trim();\n if (!user_message || user_message.length === 0) {\n return;\n }\n\n // empty input field\n document.getElementById(\"chat_form_input\").value = null;\n\n // format receiver ID\n var receiver = current_chatwindow['name'] == \"global\" ? null : current_chatwindow['name'];\n\n // send message to MATRX\n data = {\"content\":user_message, \"sender\": lv_agent_id, \"receiver\": receiver}\n console.log(\"Sending message to matrx:\", data);\n send_matrx_api_post_message(matrx_send_message_url, data);\n}", "title": "" }, { "docid": "dc70e7393ca57bc9d703a1780f42bb27", "score": "0.6373285", "text": "function handleFormSubmit(event) {\n\n var bodyInput = $(\"#message\").val().trim();\n var nameInput = $(\"#name\").val().trim();\n var phoneInput = $(\"#phone\").val().trim();\n var emailInput = $(\"#email\").val().trim();\n\n event.preventDefault();\n // Don't submit unless the form is complete\n if (!nameInput || !emailInput || !bodyInput) {\n return;\n }\n // Constructing a newMessage\n var newMessage = {\n name: nameInput,\n email: emailInput,\n phone: phoneInput,\n body: bodyInput\n\n }; // submit the new comment\n // submitToApi(newMessage);\n submitMessage(newMessage);\n\n // empty out the input fields\n $(\"#message\").val(\"\");\n $(\"#name\").val(\"\");\n $(\"#email\").val(\"\");\n $(\"#phone\").val(\"\");\n\n }", "title": "" }, { "docid": "e174545299957c11c82428d53fe3af50", "score": "0.6368778", "text": "function sendMessage() {\n this.ClientApi.call('chat-engine', 'chat', { Username: UserName, Chatroom: ChatRoom, Message: $('#message').val() })\n $('#message').val('')\n}", "title": "" }, { "docid": "f0b297ae897f26493538d3cc68d5989f", "score": "0.63678", "text": "handlingUserEvents() {\n\n this.dom.addEventListener('submit', (e) => {\n \n e.preventDefault();\n\n // capture the user message to be sent\n let input = this.dom.querySelector('.message-input input');\n PubSub.publish('newClientMessage', input.value);\n input.value = '';\n })\n }", "title": "" }, { "docid": "e1c7b39a383e2ac4cb6acae52c622402", "score": "0.6363851", "text": "function sendMessage(event){\r\n event.preventDefault();\r\n let message = document.querySelector(\"#message\");\r\n websocket.send(login+\" : \"+message.value);\r\n message.value = \"\";\r\n}", "title": "" }, { "docid": "0bc710f775ab92ebf98f3eecf9291a4a", "score": "0.63616186", "text": "function submitForm(event) {\n event.preventDefault();\n // display a message once the form has been submitted\n sentMessage.innerText = 'Sent!';\n // clear all input values\n form.reset();\n}", "title": "" }, { "docid": "1fe0e8d35f74a2528752b0b428c9cc2f", "score": "0.6355976", "text": "function sendMessage() {\r\n\r\n\t\tvar msg = trim(input.val());\r\n\t\tif(msg.length == 0){\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\tif (enableBBCode) {\r\n\t\t\t // message can't be empty after resolving bbcode\r\n\t\t\t if (trim(bbCodeParser.ParseBBCode(msg, true)) == \"\") {\r\n\t\t\t\t ChatManager.DialogsHelper.DisplayDialog(pnlInformDialog);\r\n\t\t\t\t return false;\r\n\t\t\t }\r\n\t\t }\r\n\r\n\t\tif ((drpRecipient.length > 0) && (drpRecipient.val() > 0)) {\r\n\t\t\tthat.GroupManager.SendMessageToUser(drpRecipient.val(), input.val(), that);\r\n\t\t} else {\r\n\t\t\tthat.GroupManager.SendMessage(input.val(), that);\r\n\t\t}\r\n\r\n\t\tif ((chbWhisper.length > 0) && !chbWhisper.attr('checked')) {\r\n\t\t\tdrpRecipient.val(0);\r\n\t\t}\r\n\r\n\t\ttriggerPostMessageEvent();\r\n\t\treturn false;\r\n\t}", "title": "" }, { "docid": "b2b598cc2c540f3c6c5d10d0b672cb9d", "score": "0.6336414", "text": "function receiveMessageFromContainer(event) \n{\n let json = JSON.parse(event.data);\n document.getElementById(\"message_title\").value = json.subject;\n document.getElementById(\"message_body\").value = json.body;\n document.getElementById(\"new_message\").submit();\n}", "title": "" }, { "docid": "79b7239737c35ffb03d9f2c99b3fe362", "score": "0.6334683", "text": "handleSubmit(event) {\r\n\t\tif(this.state.value!=''){\r\n\t\t\tlet obj = {roomid:this.state.roomid, userid:this.state.playerid, name: this.state.name, imageindex:this.props.imageindex, message: this.state.value}\r\n\t\t\tws.emit('messages',obj);\r\n\t\t\tthis.setState({value: ''});\r\n\t\t}\r\n event.preventDefault();\r\n }", "title": "" }, { "docid": "9ed6fd438ee86c345db344c546e08dc7", "score": "0.6334644", "text": "function sendMessage() {\n if ($(\"#txtMessage\").val()) {\n console.log(\"sent to socket.\");\n socket.send(receiver + \"$\" + nickname +\"@\"+$('#username').val() +\"#\" + $(\"#txtMessage\").val());\n $(\"#txtMessage\").val(\"\");\n }\n }", "title": "" }, { "docid": "9d93087bc976c42ff0625b7e24aec3a1", "score": "0.63320196", "text": "function sendMessage(message) {\n if (message !== \"\") {\n webSocket.send(message);\n id(\"message\").value = \"\";\n }\n}", "title": "" }, { "docid": "e1b0a5192131d46cd7066fe6435d4373", "score": "0.6311297", "text": "function update_send_message_btn()\n {\n //update onclick\n document.querySelector(\"#btn-send-message\").onclick = function()\n {\n //remove leading withe space from the message\n let message = document.querySelector(\"#message\").value.trim();\n\n //only send message if then input is not empty. with current time , useraname and channel it was sent in\n if(message != \"\")\n {\n let currentTime = current_time();\n let date = get_date();\n let username = localStorage.getItem(\"display-name\");\n let channel = localStorage.getItem(\"last-channel\");\n socket.emit('sending message', {\"date\": date, \"channel\":channel, \"message\": message, \"current_time\":currentTime, \"username\":username});\n return false;\n }\n //reset the input to be empty\n document.querySelector(\"#message\").value = \"\";\n };\n }", "title": "" }, { "docid": "cf291ca89a3936e3c3474604e40fa5b7", "score": "0.63108927", "text": "function sentMessage() {\n\tif (my.messageInput.val() != \"\") {\n //do we have everyone's pubkey?\n var cleartext = my.messageInput.val()\n var buff = new Buffer(cleartext)\n var ciphertext = box.multibox(buff, my.pks, Object.keys(my.current_userlist).length)\n\t\tmy.socket.emit('message', JSONB.stringify(ciphertext))\n\t\tmy.messageInput.val('');\n\t\tmy.submitButton.button('loading');\n\t}\n}", "title": "" }, { "docid": "62658a65318acdecbb27bf2d30200aa5", "score": "0.63106155", "text": "handleMessageSubmit(e){\n //extract data from html form and emit\n //to socket code on backend\n e.preventDefault()\n let alias = this.state.alias;\n let message = this.state.message;\n if (!message){\n alert('Message must not be empty');\n return;\n }\n socket.emit('send message', {\n alias: alias,\n message: message\n });\n this.setState({ message: '' }); //clear message for user after sending\n }", "title": "" }, { "docid": "7d0a841fdd215b45262f1d2704c0bfb7", "score": "0.6300686", "text": "function sendMessage(e) {\n sendChannel.current.send(text);\n setMessages(messages => [...messages, { yours: true, value: text }]);\n setText(\"\");\n }", "title": "" }, { "docid": "564f53ccae0d86e89f020cd671d3eef0", "score": "0.6297664", "text": "function say(msg){\n var save = document.querySelector('#robinSendMessage input[type=text]').value;\n document.querySelector('#robinSendMessage input[type=text]').value = msg;\n document.querySelector('#robinSendMessage input[type=submit]').click();\n document.querySelector('#robinSendMessage input[type=text]').value = save;\n}", "title": "" }, { "docid": "6fcd8e4706086282f96f91be7d673018", "score": "0.62971574", "text": "function sendMessage () {\r\n var message = $inputMessage.val();\r\n // Prevent markup from being injected into the message\r\n message = cleanInput(message);\r\n // if there is a non-empty message and a socket connection\r\n if (message && connected) {\r\n $inputMessage.val('');\r\n postMsg(username, message);\r\n // tell server to execute 'new message' and send along one parameter\r\n socket.emit('new message', message);\r\n }\r\n }", "title": "" }, { "docid": "2908afd2205be382bbebdd319dff540d", "score": "0.6293681", "text": "function sendMessage() {\n var message = cleanInput($inputMessage.val().trim()); // on récupere la value de l'input (on passe pas par un submit d'un form)\n\n // if there is a non-empty message and a socket connection\n if (message && connected) {\n $inputMessage.val('');\n $avatarInput.val('');\n\n addChatMessage({\n username: user.name,\n message: message,\n avatar: user.avatar // add\n });\n\n // tell server to execute 'new_message' and send along one parameter\n socket.emit('new_message', message);\n }\n}", "title": "" }, { "docid": "49fd6710e6f4268d1c7503dd95a7baed", "score": "0.6290405", "text": "sendMessage() {\n // we remove whitespaces from both sides of the string newMessage\n this.newMessage = this.newMessage.trim();\n if (this.newMessage != '') {\n // if the result is not an empty string, we create a new object representing a new message, and we svae it in the variable myMessage\n let myMessage = this.getMessageObject(this.newMessage, 'sent');\n\n // we add this new message to the currently displayed conversation\n this.contacts[this.currentIndex].messages.push(myMessage);\n\n // after the new message is added to the messages panel, the panel automatically scrolls to the end\n Vue.nextTick(this.scrollMessages);\n\n // we reset the value of newMessage (i.e. the value of the input placed inside the div with id \"send-message\")\n this.newMessage = '';\n\n // we automatically generate an answer\n // this answer will be displayed in the messages panel after 1 second\n setTimeout(this.answer, 1000);\n }\n }", "title": "" }, { "docid": "5f20330d7a6895ad5edfde2fc4cc966c", "score": "0.62798584", "text": "handleSubmit(event) {\n event.preventDefault();\n\n // loading state\n this.setState(prevState => ({\n loading: !prevState.loading\n }));\n\n // call method to insert a new message\n Meteor.call('messages.new', { content: this.state.content }, (err, res) => {\n // handle error\n \n // no more loading state, clean the input\n this.setState(prevState => ({\n loading: !prevState.loading,\n content: '',\n }));\n });\n }", "title": "" }, { "docid": "3ef671fee6b28228b08be78a15688f53", "score": "0.6274982", "text": "function submitfunction() {\n let from = $('#user').val()\n let message = $('#m').val()\n if (message !== '') {\n if (message.indexOf(\"/image\") == 0) {\n message = message.substring(6,message.length);\n message = '<img src=\"' + message + '\" height=50% width=50%>';\n socket.emit('chatMessage', from, message);\n }\n else if (message.indexOf(\"/link\") == 0) {\n message = message.substring(5,message.length);\n message = '<a href=\"' + message + '\">' + message + '</a>';\n socket.emit('chatMessage', from, message); \n }\n else if (message.indexOf(\"/bold\") == 0) {\n message = message.substring(5,message.length);\n message = '<b>' + message + '</b>';\n socket.emit('chatMessage', from, message); \n }\n else if (message.indexOf(\"/big\") == 0) {\n message = message.substring(4,message.length);\n message = '<h1>' + message + '</h1>';\n socket.emit('chatMessage', from, message);\n }\n else if (message.indexOf(\"/youtube\") == 0) {\n message = message.substring(8,message.length);\n if (message.includes(\"watch?v=\")) {\n message = message.replace(\"watch?v=\", \"embed/\");\n }\n message = '<br><iframe id=\"youtube\" width=\"818\" height=\"409\" src=\"' + message + '\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>';\n socket.emit('chatMessage', from, message);\n }\n else {\n socket.emit('chatMessage', from, message);\n }\n }\n \n // what language and selector is used below?\n // set the value to an empty string and\n // focus on the message box again\n $('#m').val('').focus()\n return false; // don't refresh\n}", "title": "" }, { "docid": "6232b5b279eb0e4e86fe6dfeb570d763", "score": "0.62739253", "text": "_sendMessage () {\r\n const message = this._chatFormTextarea.value\r\n if (message === '') {\r\n return\r\n }\r\n\r\n if (this._webSocket.readyState === 1) {\r\n this._webSocket.send(JSON.stringify({\r\n type: 'message',\r\n data: `${message}`,\r\n username: `${this._nickname}`,\r\n key: 'eDBE76deU7L0H9mEBgxUKVR0VCnq0XBd'\r\n }))\r\n } else {\r\n this._errorMessage.classList.remove('hidden')\r\n window.setTimeout(() => {\r\n this._errorMessage.classList.add('hidden')\r\n }, 5000)\r\n }\r\n\r\n this._chatFormTextarea.value = ''\r\n }", "title": "" }, { "docid": "cf0f136b472a4a6fa1527573b4a6b28b", "score": "0.62668365", "text": "function submitForm(event) {\n event.preventDefault();\n // display a message once the form has been submitted\n sentMessage.innerHTML = '<div class=\"success\">Your message has been sent!</div>';\n // clear all input values\n form.reset();\n}", "title": "" }, { "docid": "0eb3e103bfb4ed154f576bfb94b6a27a", "score": "0.62465996", "text": "function handleSubmitButton(){\n let userText = $('#text-search-feild').val();\n console.log(\"Button submission query made: \" + userText);\n makeAPIRequest(userText);\n $('#text-search-feild').val('');\n}", "title": "" }, { "docid": "e9d18c7a14ed62ea94105b709bd67a3b", "score": "0.6244834", "text": "function sendMessage(message) {\n if (message !== \"\") {\n webSocket.send(message);\n id(\"message\").value = \"\";\n }\n }", "title": "" } ]
3f95ec790a4d558d0ea49d4e54987cd4
PURE_IMPORTS_START _reduce PURE_IMPORTS_END PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END
[ { "docid": "d99b200b789dfda8169a54b85f0cf876", "score": "0.0", "text": "function refCount() {\n return function refCountOperatorFunction(source) {\n return source.lift(new RefCountOperator(source));\n };\n}", "title": "" } ]
[ { "docid": "8a5aa0f4f76626f03e88f8134aa3e301", "score": "0.56982374", "text": "subscribe() {}", "title": "" }, { "docid": "77da7144ce7560f3e5d130442d11a577", "score": "0.53541255", "text": "function vo(t, e, n, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var i, o, u, s, a, c, h, f, l, p;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(d) {\n switch (d.label) {\n case 0:\n for (i = O(t), o = mn(), u = hn(), s = vn(), a = 0, c = n; a < c.length; a++) h = c[a], \n f = e.Pc(h.metadata.name), h.document && (o = o.add(f)), u = u.zt(f, e.yc(h)), s = s.zt(f, e.gc(h.metadata.readTime));\n return l = i.Ec.Nr({\n Wr: !0\n }), [ 4 /*yield*/ , ao(i, function(t) {\n // It is OK that the path used for the query is not valid, because this will\n // not be read and queried.\n return he(re(Z.ot(\"__bundle__/docs/\" + t)));\n }(r)) ];\n\n case 1:\n // Allocates a target to hold all document keys from the bundle, such that\n // they will not get garbage collected right away.\n return p = d.sent(), [ 2 /*return*/ , i.persistence.runTransaction(\"Apply bundle documents\", \"readwrite\", (function(t) {\n return uo(t, l, u, X.min(), s).next((function(e) {\n return l.apply(t), e;\n })).next((function(e) {\n return i._o.Yi(t, p.targetId).next((function() {\n return i._o.er(t, o, p.targetId);\n })).next((function() {\n return i.Tc.Zo(t, e);\n }));\n }));\n })) ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "605e42349328b8512236066acd8eb265", "score": "0.5324258", "text": "subscribe(func) {\n this.reduxSubscribers.push(func);\n }", "title": "" }, { "docid": "cb107ef3bb6d6a34a63bb74c9b16d111", "score": "0.527363", "text": "subscribe(e, t) {\n this.has(e) || (this.events[e] = []);\n let s = [];\n if (Array.isArray(t)) for (const n of t) s.push(...this.subscribe(e, n)); else this.events[e].push(t), \n s.push((() => this.removeListener(e, t)));\n return s;\n }", "title": "" }, { "docid": "e0f8385c6e7494d7c3964e56dba22c2d", "score": "0.5270633", "text": "function Subscriber(id, obj) {\n\t\tthis.oId = id;\n\t\tthis.obj = obj;\n\n\t\t// holds all fns to reduce over published data\n\t\tthis._pipeline_ = [];\n\t}", "title": "" }, { "docid": "c279a15c49ab3c31d635b54c32a0148f", "score": "0.5211676", "text": "async function subscribe(args) {\n // Temporary for v15 to v16 migration. Remove in v17\n arguments.length < 2 ||\n Object(_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__[\"devAssert\"])(\n false,\n 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.',\n );\n const {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n subscribeFieldResolver,\n } = args;\n const resultOrStream = await createSourceEventStream(\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n subscribeFieldResolver,\n );\n\n if (!Object(_jsutils_isAsyncIterable_mjs__WEBPACK_IMPORTED_MODULE_2__[\"isAsyncIterable\"])(resultOrStream)) {\n return resultOrStream;\n } // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `execute` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n\n const mapSourceToResponse = (payload) =>\n Object(_execute_mjs__WEBPACK_IMPORTED_MODULE_7__[\"execute\"])({\n schema,\n document,\n rootValue: payload,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n }); // Map every source value to a ExecutionResult value as described above.\n\n return Object(_mapAsyncIterator_mjs__WEBPACK_IMPORTED_MODULE_8__[\"mapAsyncIterator\"])(resultOrStream, mapSourceToResponse);\n}", "title": "" }, { "docid": "dae5204be05d6c64c73d4c2e88e17bf1", "score": "0.5177281", "text": "pipe(...fns)\n {\n return x => fns.reduce((y, f) => f(y), x);\n }", "title": "" }, { "docid": "833ea1d312562f3f165f89b2a7e51cb7", "score": "0.5106217", "text": "function ju(t, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"])(this, void 0, void 0, function () {\n var e, i, o, u, s, a, c, h;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"])(this, function (n) {\n switch (n.label) {\n case 0:\n return Wu(e = D(t)), Yu(e), !0 !== r || !0 === e.Hh ? [3\n /*break*/\n , 3] : (i = e.kh.$u(), [4\n /*yield*/\n , Bu(e, i.O())]);\n\n case 1:\n return o = n.sent(), e.Hh = !0, [4\n /*yield*/\n , Xo(e.Oh, !0)];\n\n case 2:\n for (n.sent(), u = 0, s = o; u < s.length; u++) {\n a = s[u], Oo(e.Oh, a);\n }\n\n return [3\n /*break*/\n , 7];\n\n case 3:\n return !1 !== r || !1 === e.Hh ? [3\n /*break*/\n , 7] : (c = [], h = Promise.resolve(), e.qh.forEach(function (t, n) {\n e.kh.zu(n) ? c.push(n) : h = h.then(function () {\n return Du(e, n), go(e.Kc, n,\n /*keepPersistedTargetData=*/\n !0);\n }), Po(e.Oh, n);\n }), [4\n /*yield*/\n , h]);\n\n case 4:\n return n.sent(), [4\n /*yield*/\n , Bu(e, c)];\n\n case 5:\n return n.sent(), // PORTING NOTE: Multi-Tab only.\n function (t) {\n var e = D(t);\n e.Kh.forEach(function (t, n) {\n Po(e.Oh, n);\n }), e.Wh.wu(), e.Kh = new Map(), e.Qh = new ht(Y.V);\n }(e), e.Hh = !1, [4\n /*yield*/\n , Xo(e.Oh, !1)];\n\n case 6:\n n.sent(), n.label = 7;\n\n case 7:\n return [2\n /*return*/\n ];\n }\n });\n });\n }", "title": "" }, { "docid": "017dae2032b04b8015361b5b4e2ec717", "score": "0.509843", "text": "function filterReduce(array) {\n //your code here!\n}", "title": "" }, { "docid": "87f72ccb540d7e3853ebec9395720919", "score": "0.5075552", "text": "function Emitter() {\n // key = eventName, value: array of funcs\n let eventTracker = {}\n\n const subscribe = (name, cb) => {\n if (eventTracker[name]) {\n eventTracker[name].push(cb)\n } else {\n eventTracker[name] = [cb];\n }\n\n const release = () => {\n let theCbs = eventTracker[name];\n if (theCbs) {\n let index = theCbs.indexOf(cb);\n if (index > -1) {\n theCbs.splice(index, 1);\n }\n }\n }\n\n return {\n release\n }\n }\n\n const emit = (name, ...theArgs) => {\n let theCbs = eventTracker[name];\n if (theCbs) {\n // for (let i = 0; i < theCbs.length; i++) {\n // let cb = theCbs[i];\n // cb.apply(null, theArgs)\n // }\n console.log(name, \"services running\")\n theCbs.forEach(cb => {\n cb.apply(null, theArgs)\n })\n }\n }\n\n return {\n subscribe,\n emit\n }\n}", "title": "" }, { "docid": "b839e622f00c83230dc7254e427ce4fb", "score": "0.5055114", "text": "function cs(t, e, n, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var i, o;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(u) {\n switch (u.label) {\n case 0:\n return [ 4 /*yield*/ , function(t, e) {\n var n = O(t), r = O(n.zo);\n return n.persistence.runTransaction(\"Lookup mutation documents\", \"readonly\", (function(t) {\n return r.yi(t, e).next((function(e) {\n return e ? n.Tc.Xo(t, e) : lr.resolve(null);\n }));\n }));\n }((i = O(t)).bh, e) ];\n\n case 1:\n return null === (o = u.sent()) ? [ 3 /*break*/ , 6 ] : \"pending\" !== n ? [ 3 /*break*/ , 3 ] : [ 4 /*yield*/ , pu(i.yl) ];\n\n case 2:\n // If we are the primary client, we need to send this write to the\n // backend. Secondary clients will ignore these writes since their remote\n // connection is disabled.\n return u.sent(), [ 3 /*break*/ , 4 ];\n\n case 3:\n \"acknowledged\" === n || \"rejected\" === n ? (\n // NOTE: Both these methods are no-ops for batches that originated from\n // other clients.\n Ju(i, e, r || null), Zu(i, e), function(t, e) {\n O(O(t).zo).xi(e);\n }(i.bh, e)) : x(), u.label = 4;\n\n case 4:\n return [ 4 /*yield*/ , is(i, o) ];\n\n case 5:\n return u.sent(), [ 3 /*break*/ , 7 ];\n\n case 6:\n // A throttled tab may not have seen the mutation before it was completed\n // and removed from the mutation queue, in which case we won't have cached\n // the affected documents. In this case we can safely ignore the update\n // since that means we didn't apply the mutation locally at all (if we\n // had, we would have cached the affected documents), and so we will just\n // see any resulting document changes via normal remote document updates\n // as applicable.\n N(\"SyncEngine\", \"Cannot apply mutation batch with id: \" + e), u.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "c89c7031bf1d6eff65770bc458a11b34", "score": "0.50404435", "text": "static Subscribe(topic, callback) {\n // If topic does not exist, set a new topic\n // ////////\n if (!mainTopics.hasOwnProperty(topic)) mainTopics[topic] = [];\n \n // register the callback with its topic\n // ////////\n mainTopics[topic].push(callback);\n \n // returns the unsubscribe method\n return () => Mediator.Unsubscribe(topic, callback);\n }", "title": "" }, { "docid": "41e93e669a5be1946b123607d1d05458", "score": "0.5031379", "text": "constructor(source, initialSubscriber) {\n this.sub1 = void 0;\n this.sub2 = void 0;\n this.spillover = void 0;\n this.source = source;\n this.sub1 = initialSubscriber;\n }", "title": "" }, { "docid": "fe257405f9b5c579e3e8dd068ca05d81", "score": "0.5027967", "text": "subscribe(e, s) {\n this.has(e) || (this.events[e] = []);\n let t = [];\n if (Array.isArray(s)) for (const r of s) t.push(...this.subscribe(e, r)); else this.events[e].push(s), \n t.push((() => this.removeListener(e, s)));\n return t;\n }", "title": "" }, { "docid": "df496b7b722090aecbddb294a352996c", "score": "0.50075096", "text": "subscribe(fn) {\n _(this).listeners.push(fn);\n\n var unsub = () => {\n const len = _(this).listeners.length;\n for(var i = 0; i < len; i++) {\n listener = _(this).listeners[i];\n\n if (fn == listener) {\n let left = _(this).listeners.slice(0, i);\n let right = _(this).listeners.slice(i + 1, len);\n _(this).listener = [...left, ...right];\n break;\n }\n }\n }\n\n // Initialize publish to new subscriber\n fn(this);\n _(this).executeOnAllModules(fn);\n\n return unsub;\n }", "title": "" }, { "docid": "da818cf4d3e942e45080f12b684cba7e", "score": "0.5006606", "text": "map(fn) {\n return new Single((subscriber) => {\n return this._source({\n onComplete: (value) => subscriber.onComplete(fn(value)),\n onError: (error) => subscriber.onError(error),\n onSubscribe: (cancel) => subscriber.onSubscribe(cancel),\n });\n });\n }", "title": "" }, { "docid": "7257c44658cd3dbffdd55c06e8dbf7f6", "score": "0.49597076", "text": "summarize /* istanbul ignore next */ () {}", "title": "" }, { "docid": "25fa50eea4282394494850d3e8a02587", "score": "0.49512377", "text": "function mu(t, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"])(this, void 0, void 0, function () {\n var e, i, o, u, s, a;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"])(this, function (n) {\n switch (n.label) {\n case 0:\n return e = Wu(t), (u = e.Bh.get(r)) ? ( // PORTING NOTE: With Multi-Tab Web, it is possible that a query view\n // already exists when EventManager calls us for the first time. This\n // happens when the primary tab is already listening to this query on\n // behalf of another tab and the user of the primary also starts listening\n // to the query. EventManager will not have an assigned target ID in this\n // case and calls `listen` to obtain this ID.\n i = u.targetId, e.kh.Wu(i), o = u.view.xh(), [3\n /*break*/\n , 4]) : [3\n /*break*/\n , 1];\n\n case 1:\n return [4\n /*yield*/\n , yo(e.Kc, Pn(r))];\n\n case 2:\n return s = n.sent(), a = e.kh.Wu(s.targetId), i = s.targetId, [4\n /*yield*/\n , wu(e, r, i, \"current\" === a)];\n\n case 3:\n o = n.sent(), e.Jh && Oo(e.Oh, s), n.label = 4;\n\n case 4:\n return [2\n /*return*/\n , o];\n }\n });\n });\n }", "title": "" }, { "docid": "f89465cef7ed82f3b5b933fbb73ec247", "score": "0.49243346", "text": "function AstEmitSubscription(tokenIds, fnHandler) {\n\tif (!(tokenIds instanceof Array)) {\n\t\ttokenIds = [tokenIds];\n\t}\n\tthis.tokenIds = tokenIds;\n\tthis.fnHandler = fnHandler;\n}", "title": "" }, { "docid": "66df691d8093b56ccf35071a0d505132", "score": "0.49063802", "text": "subscribe(subscriber) {\n if (this.has(subscriber)) {\n return;\n }\n\n if (this.sub1 === void 0) {\n this.sub1 = subscriber;\n return;\n }\n\n if (this.sub2 === void 0) {\n this.sub2 = subscriber;\n return;\n }\n\n this.spillover = [this.sub1, this.sub2, subscriber];\n this.subscribe = spilloverSubscribe;\n this.unsubscribe = spilloverUnsubscribe;\n this.notify = spilloverNotifySubscribers;\n this.has = spilloverHas;\n this.sub1 = void 0;\n this.sub2 = void 0;\n }", "title": "" }, { "docid": "652bc629a0e93d348ca198b4eb8ec9b7", "score": "0.4899069", "text": "function vs(t, e, n) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var r, i, o, u, s, a, c, h, f, l;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(p) {\n switch (p.label) {\n case 0:\n if (!(r = ys(t)).Ml) return [ 3 /*break*/ , 10 ];\n i = 0, o = e, p.label = 1;\n\n case 1:\n return i < o.length ? (u = o[i], r.Sl.has(u) ? (\n // A target might have been added in a previous attempt\n N(\"SyncEngine\", \"Adding an already active target \" + u), [ 3 /*break*/ , 5 ]) : [ 4 /*yield*/ , fo(r.bh, u) ]) : [ 3 /*break*/ , 6 ];\n\n case 2:\n return s = p.sent(), [ 4 /*yield*/ , ao(r.bh, s) ];\n\n case 3:\n return a = p.sent(), [ 4 /*yield*/ , zu(r, ls(s), a.targetId, \n /*current=*/ !1) ];\n\n case 4:\n p.sent(), tu(r.yl, a), p.label = 5;\n\n case 5:\n return i++, [ 3 /*break*/ , 1 ];\n\n case 6:\n c = function(t) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(e) {\n switch (e.label) {\n case 0:\n return r.Sl.has(t) ? [ 4 /*yield*/ , co(r.bh, t, \n /* keepPersistedTargetData */ !1).then((function() {\n eu(r.yl, t), $u(r, t);\n })).catch(mi) ] : [ 3 /*break*/ , 2 ];\n\n // Release queries that are still active.\n case 1:\n // Release queries that are still active.\n e.sent(), e.label = 2;\n\n case 2:\n return [ 2 /*return*/ ];\n }\n }));\n }, h = 0, f = n, p.label = 7;\n\n case 7:\n return h < f.length ? (l = f[h], [ 5 /*yield**/ , c(l) ]) : [ 3 /*break*/ , 10 ];\n\n case 8:\n p.sent(), p.label = 9;\n\n case 9:\n return h++, [ 3 /*break*/ , 7 ];\n\n case 10:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "0e3dfaa9a2641b5917b4ffd46be2f7c9", "score": "0.48990396", "text": "addSubscriber(propName, fn) {\n _subscribers[propName].push(fn)\n }", "title": "" }, { "docid": "a56d81c43a770cdc237d7e929c51614d", "score": "0.48898914", "text": "function ds(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var n, r, i, o, u, s, a, c;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(f) {\n switch (f.label) {\n case 0:\n return bs(n = x(t)), _s(n), !0 !== e || !0 === n.Ll ? [ 3 /*break*/ , 3 ] : (r = n.pl.Sa(), \n [ 4 /*yield*/ , vs(n, r.rt()) ]);\n\n case 1:\n return i = f.sent(), n.Ll = !0, [ 4 /*yield*/ , Tu(n.gl, !0) ];\n\n case 2:\n for (f.sent(), o = 0, u = i; o < u.length; o++) s = u[o], iu(n.gl, s);\n return [ 3 /*break*/ , 7 ];\n\n case 3:\n return !1 !== e || !1 === n.Ll ? [ 3 /*break*/ , 7 ] : (a = [], c = Promise.resolve(), \n n.Dl.forEach((function(t, e) {\n n.pl.$a(e) ? a.push(e) : c = c.then((function() {\n return rs(n, e), po(n.Sh, e, \n /*keepPersistedTargetData=*/ !0);\n })), ou(n.gl, e);\n })), [ 4 /*yield*/ , c ]);\n\n case 4:\n return f.sent(), [ 4 /*yield*/ , vs(n, a) ];\n\n case 5:\n return f.sent(), \n // PORTING NOTE: Multi-Tab only.\n function(t) {\n var e = x(t);\n e.Nl.forEach((function(t, n) {\n ou(e.gl, n);\n })), e.Fl.Mc(), e.Nl = new Map, e.xl = new an(it.J);\n }(n), n.Ll = !1, [ 4 /*yield*/ , Tu(n.gl, !1) ];\n\n case 6:\n f.sent(), f.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "237457b8e37be8e8ed3991fc4e1b361d", "score": "0.48694527", "text": "function vc(t) {\n for (var e, n, r, i = [], o = 1; o < arguments.length; o++) i[o - 1] = arguments[o];\n t instanceof Ds && (t = t.d_);\n var u = {\n includeMetadataChanges: !1\n }, s = 0;\n \"object\" != typeof i[s] || Ca(i[s]) || (u = i[s], s++);\n var a, c, h, f = {\n includeMetadataChanges: u.includeMetadataChanges\n };\n if (Ca(i[s])) {\n var l = i[s];\n i[s] = null === (e = l.next) || void 0 === e ? void 0 : e.bind(l), i[s + 1] = null === (n = l.error) || void 0 === n ? void 0 : n.bind(l), \n i[s + 2] = null === (r = l.complete) || void 0 === r ? void 0 : r.bind(l);\n }\n if (t instanceof js) c = Cs(t.firestore, Ma), h = re(t.S_.path), a = {\n next: function(e) {\n i[s] && i[s](mc(c, t, e));\n },\n error: i[s + 1],\n complete: i[s + 2]\n }; else {\n var p = Cs(t, Fs);\n c = Cs(p.firestore, Ma), h = p.C_;\n var d = new pc(c);\n a = {\n next: function(t) {\n i[s] && i[s](new hc(c, d, p, t));\n },\n error: i[s + 1],\n complete: i[s + 2]\n }, Ha(t.C_);\n }\n return function(t, e, n, r) {\n var i = this, o = new Ts(r), u = new ku(e, o, n);\n return t._s.Ps((function() {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(i, void 0, void 0, (function() {\n var e;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(n) {\n switch (n.label) {\n case 0:\n return e = Nu, [ 4 /*yield*/ , Oa(t) ];\n\n case 1:\n return [ 2 /*return*/ , e.apply(void 0, [ n.sent(), u ]) ];\n }\n }));\n }));\n })), function() {\n o.i_(), t._s.Ps((function() {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(i, void 0, void 0, (function() {\n var e;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(n) {\n switch (n.label) {\n case 0:\n return e = Au, [ 4 /*yield*/ , Oa(t) ];\n\n case 1:\n return [ 2 /*return*/ , e.apply(void 0, [ n.sent(), u ]) ];\n }\n }));\n }));\n }));\n };\n }(qa(c), h, f, a);\n}", "title": "" }, { "docid": "18b6cb4eac8683f900333ba45b6dfe4a", "score": "0.48673165", "text": "constructor(subscriber) {\n this.subscriber = subscriber;\n }", "title": "" }, { "docid": "ae0b8204393b8deedaef10055ff46213", "score": "0.48620686", "text": "function subscribeSuccess$(_ref3) {\n var payload = _ref3.payload;\n var socket, wsSendChannelSubscription, notebookWSinitializer, fetchZeppelinStatusHandler, readMessageHandler, pingHandler, pongHandler, paragraphHandler;\n return regeneratorRuntime.wrap(function subscribeSuccess$$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n socket = payload;\n\n // CALL RX HANDLER\n\n _context5.next = 3;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"call\"])(__WEBPACK_IMPORTED_MODULE_5_sagas_websocket_websocketChannelHandler__[\"a\" /* wsSendChannelSubscriptionHandler */], { socket: socket });\n\n case 3:\n wsSendChannelSubscription = _context5.sent;\n _context5.next = 6;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"fork\"])(__WEBPACK_IMPORTED_MODULE_7_sagas_websocket_notebookHandlers_notebookInitialize__[\"a\" /* notebookWSInitialize$ */], { socket: socket });\n\n case 6:\n notebookWSinitializer = _context5.sent;\n _context5.next = 9;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"fork\"])(__WEBPACK_IMPORTED_MODULE_8_sagas_websocket_zeppelinStatusHandler__[\"a\" /* fetchzeppelinStatusHandler$ */], { socket: socket });\n\n case 9:\n fetchZeppelinStatusHandler = _context5.sent;\n _context5.next = 12;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"fork\"])(__WEBPACK_IMPORTED_MODULE_4_sagas_websocket_reader__[\"a\" /* default */], { socket: socket });\n\n case 12:\n readMessageHandler = _context5.sent;\n _context5.next = 15;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"fork\"])(__WEBPACK_IMPORTED_MODULE_9_sagas_websocket_pingPongHandler__[\"a\" /* pingHandler$ */]);\n\n case 15:\n pingHandler = _context5.sent;\n _context5.next = 18;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"fork\"])(__WEBPACK_IMPORTED_MODULE_9_sagas_websocket_pingPongHandler__[\"b\" /* pongHandler$ */], { socket: socket });\n\n case 18:\n pongHandler = _context5.sent;\n _context5.next = 21;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"fork\"])(__WEBPACK_IMPORTED_MODULE_6_sagas_websocket_notebookHandlers_paragraphHandler__[\"a\" /* paragraphHandler$ */], { socket: socket });\n\n case 21:\n paragraphHandler = _context5.sent;\n _context5.next = 24;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"take\"])([__WEBPACK_IMPORTED_MODULE_12_actions_types__[\"LOGOUT_SUCCESS\"], __WEBPACK_IMPORTED_MODULE_13_actions_websocket_types__[\"i\" /* WS_RECONNECTING */]]);\n\n case 24:\n if (!(socket && socket.websocket && socket.websocket.readyState === WebSocket.OPEN)) {\n _context5.next = 27;\n break;\n }\n\n _context5.next = 27;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"call\"])(socket.closeSocket);\n\n case 27:\n if (!(wsSendChannelSubscription && !wsSendChannelSubscription.closed)) {\n _context5.next = 31;\n break;\n }\n\n console.warn(\"will unsubscribe wsSendChannelSubscription\");\n _context5.next = 31;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"call\"])([wsSendChannelSubscription, wsSendChannelSubscription.unsubscribe]);\n\n case 31:\n _context5.next = 33;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"cancel\"])(notebookWSinitializer);\n\n case 33:\n _context5.next = 35;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"cancel\"])(readMessageHandler);\n\n case 35:\n _context5.next = 37;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"cancel\"])(fetchZeppelinStatusHandler);\n\n case 37:\n _context5.next = 39;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"cancel\"])(pingHandler);\n\n case 39:\n _context5.next = 41;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"cancel\"])(pongHandler);\n\n case 41:\n _context5.next = 43;\n return Object(__WEBPACK_IMPORTED_MODULE_1_redux_saga_effects__[\"cancel\"])(paragraphHandler);\n\n case 43:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _marked5, this);\n}", "title": "" }, { "docid": "4ecdee289d015664b5bb5b34743ad3b6", "score": "0.48601264", "text": "function Xu(t, e, n) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var r, i, o, u, s, a;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(c) {\n switch (c.label) {\n case 0:\n // PORTING NOTE: Multi-tab only.\n return (r = x(t)).pl.qa(e, \"rejected\", n), i = r.Nl.get(e), (o = i && i.key) ? (u = (u = new an(it.J)).Ht(o, new Ut(o, Z.min())), \n s = _n().add(o), a = new Sn(Z.min(), \n /* targetChanges= */ new Map, \n /* targetMismatches= */ new hn(P), u, s), [ 4 /*yield*/ , Qu(r, a) ]) : [ 3 /*break*/ , 2 ];\n\n case 1:\n return c.sent(), \n // Since this query failed, we won't want to manually unlisten to it.\n // We only remove it from bookkeeping after we successfully applied the\n // RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to\n // this query when the RemoteStore restarts the Watch stream, which should\n // re-trigger the target failure.\n r.xl = r.xl.remove(o), r.Nl.delete(e), ss(r), [ 3 /*break*/ , 4 ];\n\n case 2:\n return [ 4 /*yield*/ , po(r.Sh, e, \n /* keepPersistedTargetData */ !1).then((function() {\n return rs(r, e, n);\n })).catch(_i) ];\n\n case 3:\n c.sent(), c.label = 4;\n\n case 4:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "607d3c9172c5068bb3d75c821d25c366", "score": "0.48593304", "text": "function scalarReduce(out, s) {\r\n\t let s0 = bigIntCommon_1.BIG_2097151 & bigIntHelper_1$4.BigIntHelper.read3(s, 0);\r\n\t let s1 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 2) >> bigIntCommon_1.BIG_ARR[5]);\r\n\t let s2 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 5) >> bigIntCommon_1.BIG_ARR[2]);\r\n\t let s3 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 7) >> bigIntCommon_1.BIG_ARR[7]);\r\n\t let s4 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 10) >> bigIntCommon_1.BIG_ARR[4]);\r\n\t let s5 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 13) >> bigIntCommon_1.BIG_ARR[1]);\r\n\t let s6 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 15) >> bigIntCommon_1.BIG_ARR[6]);\r\n\t let s7 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 18) >> bigIntCommon_1.BIG_ARR[3]);\r\n\t let s8 = bigIntCommon_1.BIG_2097151 & bigIntHelper_1$4.BigIntHelper.read3(s, 21);\r\n\t let s9 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 23) >> bigIntCommon_1.BIG_ARR[5]);\r\n\t let s10 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 26) >> bigIntCommon_1.BIG_ARR[2]);\r\n\t let s11 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 28) >> bigIntCommon_1.BIG_ARR[7]);\r\n\t let s12 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 31) >> bigIntCommon_1.BIG_ARR[4]);\r\n\t let s13 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 34) >> bigIntCommon_1.BIG_ARR[1]);\r\n\t let s14 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 36) >> bigIntCommon_1.BIG_ARR[6]);\r\n\t let s15 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 39) >> bigIntCommon_1.BIG_ARR[3]);\r\n\t let s16 = bigIntCommon_1.BIG_2097151 & bigIntHelper_1$4.BigIntHelper.read3(s, 42);\r\n\t let s17 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 44) >> bigIntCommon_1.BIG_ARR[5]);\r\n\t let s18 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 47) >> bigIntCommon_1.BIG_ARR[2]);\r\n\t let s19 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 49) >> bigIntCommon_1.BIG_ARR[7]);\r\n\t let s20 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 52) >> bigIntCommon_1.BIG_ARR[4]);\r\n\t let s21 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read3(s, 55) >> bigIntCommon_1.BIG_ARR[1]);\r\n\t let s22 = bigIntCommon_1.BIG_2097151 & (bigIntHelper_1$4.BigIntHelper.read4(s, 57) >> bigIntCommon_1.BIG_ARR[6]);\r\n\t let s23 = (bigIntHelper_1$4.BigIntHelper.read4(s, 60) >> bigIntCommon_1.BIG_ARR[3]);\r\n\t s11 += s23 * bigIntCommon_1.BIG_666643;\r\n\t s12 += s23 * bigIntCommon_1.BIG_470296;\r\n\t s13 += s23 * bigIntCommon_1.BIG_654183;\r\n\t s14 -= s23 * bigIntCommon_1.BIG_997805;\r\n\t s15 += s23 * bigIntCommon_1.BIG_136657;\r\n\t s16 -= s23 * bigIntCommon_1.BIG_683901;\r\n\t s23 = bigIntCommon_1.BIG_ARR[0];\r\n\t s10 += s22 * bigIntCommon_1.BIG_666643;\r\n\t s11 += s22 * bigIntCommon_1.BIG_470296;\r\n\t s12 += s22 * bigIntCommon_1.BIG_654183;\r\n\t s13 -= s22 * bigIntCommon_1.BIG_997805;\r\n\t s14 += s22 * bigIntCommon_1.BIG_136657;\r\n\t s15 -= s22 * bigIntCommon_1.BIG_683901;\r\n\t s22 = bigIntCommon_1.BIG_ARR[0];\r\n\t s9 += s21 * bigIntCommon_1.BIG_666643;\r\n\t s10 += s21 * bigIntCommon_1.BIG_470296;\r\n\t s11 += s21 * bigIntCommon_1.BIG_654183;\r\n\t s12 -= s21 * bigIntCommon_1.BIG_997805;\r\n\t s13 += s21 * bigIntCommon_1.BIG_136657;\r\n\t s14 -= s21 * bigIntCommon_1.BIG_683901;\r\n\t s21 = bigIntCommon_1.BIG_ARR[0];\r\n\t s8 += s20 * bigIntCommon_1.BIG_666643;\r\n\t s9 += s20 * bigIntCommon_1.BIG_470296;\r\n\t s10 += s20 * bigIntCommon_1.BIG_654183;\r\n\t s11 -= s20 * bigIntCommon_1.BIG_997805;\r\n\t s12 += s20 * bigIntCommon_1.BIG_136657;\r\n\t s13 -= s20 * bigIntCommon_1.BIG_683901;\r\n\t s20 = bigIntCommon_1.BIG_ARR[0];\r\n\t s7 += s19 * bigIntCommon_1.BIG_666643;\r\n\t s8 += s19 * bigIntCommon_1.BIG_470296;\r\n\t s9 += s19 * bigIntCommon_1.BIG_654183;\r\n\t s10 -= s19 * bigIntCommon_1.BIG_997805;\r\n\t s11 += s19 * bigIntCommon_1.BIG_136657;\r\n\t s12 -= s19 * bigIntCommon_1.BIG_683901;\r\n\t s19 = bigIntCommon_1.BIG_ARR[0];\r\n\t s6 += s18 * bigIntCommon_1.BIG_666643;\r\n\t s7 += s18 * bigIntCommon_1.BIG_470296;\r\n\t s8 += s18 * bigIntCommon_1.BIG_654183;\r\n\t s9 -= s18 * bigIntCommon_1.BIG_997805;\r\n\t s10 += s18 * bigIntCommon_1.BIG_136657;\r\n\t s11 -= s18 * bigIntCommon_1.BIG_683901;\r\n\t s18 = bigIntCommon_1.BIG_ARR[0];\r\n\t const carry = new BigInt64Array(17);\r\n\t carry[6] = (s6 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s7 += carry[6];\r\n\t s6 -= carry[6] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[8] = (s8 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s9 += carry[8];\r\n\t s8 -= carry[8] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[10] = (s10 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s11 += carry[10];\r\n\t s10 -= carry[10] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[12] = (s12 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s13 += carry[12];\r\n\t s12 -= carry[12] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[14] = (s14 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s15 += carry[14];\r\n\t s14 -= carry[14] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[16] = (s16 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s17 += carry[16];\r\n\t s16 -= carry[16] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[7] = (s7 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s8 += carry[7];\r\n\t s7 -= carry[7] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[9] = (s9 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s10 += carry[9];\r\n\t s9 -= carry[9] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[11] = (s11 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s12 += carry[11];\r\n\t s11 -= carry[11] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[13] = (s13 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s14 += carry[13];\r\n\t s13 -= carry[13] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[15] = (s15 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s16 += carry[15];\r\n\t s15 -= carry[15] << bigIntCommon_1.BIG_ARR[21];\r\n\t s5 += s17 * bigIntCommon_1.BIG_666643;\r\n\t s6 += s17 * bigIntCommon_1.BIG_470296;\r\n\t s7 += s17 * bigIntCommon_1.BIG_654183;\r\n\t s8 -= s17 * bigIntCommon_1.BIG_997805;\r\n\t s9 += s17 * bigIntCommon_1.BIG_136657;\r\n\t s10 -= s17 * bigIntCommon_1.BIG_683901;\r\n\t s17 = bigIntCommon_1.BIG_ARR[0];\r\n\t s4 += s16 * bigIntCommon_1.BIG_666643;\r\n\t s5 += s16 * bigIntCommon_1.BIG_470296;\r\n\t s6 += s16 * bigIntCommon_1.BIG_654183;\r\n\t s7 -= s16 * bigIntCommon_1.BIG_997805;\r\n\t s8 += s16 * bigIntCommon_1.BIG_136657;\r\n\t s9 -= s16 * bigIntCommon_1.BIG_683901;\r\n\t s16 = bigIntCommon_1.BIG_ARR[0];\r\n\t s3 += s15 * bigIntCommon_1.BIG_666643;\r\n\t s4 += s15 * bigIntCommon_1.BIG_470296;\r\n\t s5 += s15 * bigIntCommon_1.BIG_654183;\r\n\t s6 -= s15 * bigIntCommon_1.BIG_997805;\r\n\t s7 += s15 * bigIntCommon_1.BIG_136657;\r\n\t s8 -= s15 * bigIntCommon_1.BIG_683901;\r\n\t s15 = bigIntCommon_1.BIG_ARR[0];\r\n\t s2 += s14 * bigIntCommon_1.BIG_666643;\r\n\t s3 += s14 * bigIntCommon_1.BIG_470296;\r\n\t s4 += s14 * bigIntCommon_1.BIG_654183;\r\n\t s5 -= s14 * bigIntCommon_1.BIG_997805;\r\n\t s6 += s14 * bigIntCommon_1.BIG_136657;\r\n\t s7 -= s14 * bigIntCommon_1.BIG_683901;\r\n\t s14 = bigIntCommon_1.BIG_ARR[0];\r\n\t s1 += s13 * bigIntCommon_1.BIG_666643;\r\n\t s2 += s13 * bigIntCommon_1.BIG_470296;\r\n\t s3 += s13 * bigIntCommon_1.BIG_654183;\r\n\t s4 -= s13 * bigIntCommon_1.BIG_997805;\r\n\t s5 += s13 * bigIntCommon_1.BIG_136657;\r\n\t s6 -= s13 * bigIntCommon_1.BIG_683901;\r\n\t s13 = bigIntCommon_1.BIG_ARR[0];\r\n\t s0 += s12 * bigIntCommon_1.BIG_666643;\r\n\t s1 += s12 * bigIntCommon_1.BIG_470296;\r\n\t s2 += s12 * bigIntCommon_1.BIG_654183;\r\n\t s3 -= s12 * bigIntCommon_1.BIG_997805;\r\n\t s4 += s12 * bigIntCommon_1.BIG_136657;\r\n\t s5 -= s12 * bigIntCommon_1.BIG_683901;\r\n\t s12 = bigIntCommon_1.BIG_ARR[0];\r\n\t carry[0] = (s0 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s1 += carry[0];\r\n\t s0 -= carry[0] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[2] = (s2 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s3 += carry[2];\r\n\t s2 -= carry[2] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[4] = (s4 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s5 += carry[4];\r\n\t s4 -= carry[4] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[6] = (s6 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s7 += carry[6];\r\n\t s6 -= carry[6] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[8] = (s8 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s9 += carry[8];\r\n\t s8 -= carry[8] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[10] = (s10 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s11 += carry[10];\r\n\t s10 -= carry[10] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[1] = (s1 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s2 += carry[1];\r\n\t s1 -= carry[1] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[3] = (s3 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s4 += carry[3];\r\n\t s3 -= carry[3] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[5] = (s5 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s6 += carry[5];\r\n\t s5 -= carry[5] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[7] = (s7 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s8 += carry[7];\r\n\t s7 -= carry[7] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[9] = (s9 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s10 += carry[9];\r\n\t s9 -= carry[9] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[11] = (s11 + bigIntCommon_1.BIG_1_SHIFTL_20) >> bigIntCommon_1.BIG_ARR[21];\r\n\t s12 += carry[11];\r\n\t s11 -= carry[11] << bigIntCommon_1.BIG_ARR[21];\r\n\t s0 += s12 * bigIntCommon_1.BIG_666643;\r\n\t s1 += s12 * bigIntCommon_1.BIG_470296;\r\n\t s2 += s12 * bigIntCommon_1.BIG_654183;\r\n\t s3 -= s12 * bigIntCommon_1.BIG_997805;\r\n\t s4 += s12 * bigIntCommon_1.BIG_136657;\r\n\t s5 -= s12 * bigIntCommon_1.BIG_683901;\r\n\t s12 = bigIntCommon_1.BIG_ARR[0];\r\n\t carry[0] = s0 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s1 += carry[0];\r\n\t s0 -= carry[0] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[1] = s1 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s2 += carry[1];\r\n\t s1 -= carry[1] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[2] = s2 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s3 += carry[2];\r\n\t s2 -= carry[2] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[3] = s3 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s4 += carry[3];\r\n\t s3 -= carry[3] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[4] = s4 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s5 += carry[4];\r\n\t s4 -= carry[4] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[5] = s5 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s6 += carry[5];\r\n\t s5 -= carry[5] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[6] = s6 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s7 += carry[6];\r\n\t s6 -= carry[6] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[7] = s7 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s8 += carry[7];\r\n\t s7 -= carry[7] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[8] = s8 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s9 += carry[8];\r\n\t s8 -= carry[8] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[9] = s9 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s10 += carry[9];\r\n\t s9 -= carry[9] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[10] = s10 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s11 += carry[10];\r\n\t s10 -= carry[10] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[11] = s11 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s12 += carry[11];\r\n\t s11 -= carry[11] << bigIntCommon_1.BIG_ARR[21];\r\n\t s0 += s12 * bigIntCommon_1.BIG_666643;\r\n\t s1 += s12 * bigIntCommon_1.BIG_470296;\r\n\t s2 += s12 * bigIntCommon_1.BIG_654183;\r\n\t s3 -= s12 * bigIntCommon_1.BIG_997805;\r\n\t s4 += s12 * bigIntCommon_1.BIG_136657;\r\n\t s5 -= s12 * bigIntCommon_1.BIG_683901;\r\n\t s12 = bigIntCommon_1.BIG_ARR[0];\r\n\t carry[0] = s0 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s1 += carry[0];\r\n\t s0 -= carry[0] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[1] = s1 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s2 += carry[1];\r\n\t s1 -= carry[1] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[2] = s2 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s3 += carry[2];\r\n\t s2 -= carry[2] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[3] = s3 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s4 += carry[3];\r\n\t s3 -= carry[3] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[4] = s4 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s5 += carry[4];\r\n\t s4 -= carry[4] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[5] = s5 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s6 += carry[5];\r\n\t s5 -= carry[5] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[6] = s6 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s7 += carry[6];\r\n\t s6 -= carry[6] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[7] = s7 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s8 += carry[7];\r\n\t s7 -= carry[7] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[8] = s8 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s9 += carry[8];\r\n\t s8 -= carry[8] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[9] = s9 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s10 += carry[9];\r\n\t s9 -= carry[9] << bigIntCommon_1.BIG_ARR[21];\r\n\t carry[10] = s10 >> bigIntCommon_1.BIG_ARR[21];\r\n\t s11 += carry[10];\r\n\t s10 -= carry[10] << bigIntCommon_1.BIG_ARR[21];\r\n\t out[0] = Number(s0 >> bigIntCommon_1.BIG_ARR[0]);\r\n\t out[1] = Number(s0 >> bigIntCommon_1.BIG_ARR[8]);\r\n\t out[2] = Number((s0 >> bigIntCommon_1.BIG_ARR[16]) | (s1 << bigIntCommon_1.BIG_ARR[5]));\r\n\t out[3] = Number(s1 >> bigIntCommon_1.BIG_ARR[3]);\r\n\t out[4] = Number(s1 >> bigIntCommon_1.BIG_ARR[11]);\r\n\t out[5] = Number((s1 >> bigIntCommon_1.BIG_ARR[19]) | (s2 << bigIntCommon_1.BIG_ARR[2]));\r\n\t out[6] = Number(s2 >> bigIntCommon_1.BIG_ARR[6]);\r\n\t out[7] = Number((s2 >> bigIntCommon_1.BIG_ARR[14]) | (s3 << bigIntCommon_1.BIG_ARR[7]));\r\n\t out[8] = Number(s3 >> bigIntCommon_1.BIG_ARR[1]);\r\n\t out[9] = Number(s3 >> bigIntCommon_1.BIG_ARR[9]);\r\n\t out[10] = Number((s3 >> bigIntCommon_1.BIG_ARR[17]) | (s4 << bigIntCommon_1.BIG_ARR[4]));\r\n\t out[11] = Number(s4 >> bigIntCommon_1.BIG_ARR[4]);\r\n\t out[12] = Number(s4 >> bigIntCommon_1.BIG_ARR[12]);\r\n\t out[13] = Number((s4 >> bigIntCommon_1.BIG_ARR[20]) | (s5 << bigIntCommon_1.BIG_ARR[1]));\r\n\t out[14] = Number(s5 >> bigIntCommon_1.BIG_ARR[7]);\r\n\t out[15] = Number((s5 >> bigIntCommon_1.BIG_ARR[15]) | (s6 << bigIntCommon_1.BIG_ARR[6]));\r\n\t out[16] = Number(s6 >> bigIntCommon_1.BIG_ARR[2]);\r\n\t out[17] = Number(s6 >> bigIntCommon_1.BIG_ARR[10]);\r\n\t out[18] = Number((s6 >> bigIntCommon_1.BIG_ARR[18]) | (s7 << bigIntCommon_1.BIG_ARR[3]));\r\n\t out[19] = Number(s7 >> bigIntCommon_1.BIG_ARR[5]);\r\n\t out[20] = Number(s7 >> bigIntCommon_1.BIG_ARR[13]);\r\n\t out[21] = Number(s8 >> bigIntCommon_1.BIG_ARR[0]);\r\n\t out[22] = Number(s8 >> bigIntCommon_1.BIG_ARR[8]);\r\n\t out[23] = Number((s8 >> bigIntCommon_1.BIG_ARR[16]) | (s9 << bigIntCommon_1.BIG_ARR[5]));\r\n\t out[24] = Number(s9 >> bigIntCommon_1.BIG_ARR[3]);\r\n\t out[25] = Number(s9 >> bigIntCommon_1.BIG_ARR[11]);\r\n\t out[26] = Number((s9 >> bigIntCommon_1.BIG_ARR[19]) | (s10 << bigIntCommon_1.BIG_ARR[2]));\r\n\t out[27] = Number(s10 >> bigIntCommon_1.BIG_ARR[6]);\r\n\t out[28] = Number((s10 >> bigIntCommon_1.BIG_ARR[14]) | (s11 << bigIntCommon_1.BIG_ARR[7]));\r\n\t out[29] = Number(s11 >> bigIntCommon_1.BIG_ARR[1]);\r\n\t out[30] = Number(s11 >> bigIntCommon_1.BIG_ARR[9]);\r\n\t out[31] = Number(s11 >> bigIntCommon_1.BIG_ARR[17]);\r\n\t}", "title": "" }, { "docid": "3ecd075f075ba327d5078fe47e6122e2", "score": "0.48435527", "text": "constructor(subscribe) {\n this._subscribe = subscribe;\n }", "title": "" }, { "docid": "146cc0a24fca7892bb06fe329307309c", "score": "0.48410928", "text": "function ps(t, e, n, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var i, o;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(u) {\n switch (u.label) {\n case 0:\n return [ 4 /*yield*/ , function(t, e) {\n var n = x(t), r = x(n.Ho);\n return n.persistence.runTransaction(\"Lookup mutation documents\", \"readonly\", (function(t) {\n return r.gi(t, e).next((function(e) {\n return e ? n.Ic.Zo(t, e) : yr.resolve(null);\n }));\n }));\n }((i = x(t)).Sh, e) ];\n\n case 1:\n return null === (o = u.sent()) ? [ 3 /*break*/ , 6 ] : \"pending\" !== n ? [ 3 /*break*/ , 3 ] : [ 4 /*yield*/ , mu(i.gl) ];\n\n case 2:\n // If we are the primary client, we need to send this write to the\n // backend. Secondary clients will ignore these writes since their remote\n // connection is disabled.\n return u.sent(), [ 3 /*break*/ , 4 ];\n\n case 3:\n \"acknowledged\" === n || \"rejected\" === n ? (\n // NOTE: Both these methods are no-ops for batches that originated from\n // other clients.\n ns(i, e, r || null), es(i, e), function(t, e) {\n x(x(t).Ho).Ni(e);\n }(i.Sh, e)) : S(), u.label = 4;\n\n case 4:\n return [ 4 /*yield*/ , as(i, o) ];\n\n case 5:\n return u.sent(), [ 3 /*break*/ , 7 ];\n\n case 6:\n // A throttled tab may not have seen the mutation before it was completed\n // and removed from the mutation queue, in which case we won't have cached\n // the affected documents. In this case we can safely ignore the update\n // since that means we didn't apply the mutation locally at all (if we\n // had, we would have cached the affected documents), and so we will just\n // see any resulting document changes via normal remote document updates\n // as applicable.\n E(\"SyncEngine\", \"Cannot apply mutation batch with id: \" + e), u.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "6719c870e0184565099b7e84b3033778", "score": "0.48404646", "text": "function reduce (arr, cb) {\n // accumulator\n}", "title": "" }, { "docid": "18173ea2dbb878a077cc24c46bf9cf8c", "score": "0.4822781", "text": "function pubSub(){var singles={},newListener=newSingle('newListener'),removeListener=newSingle('removeListener');function newSingle(eventName){return singles[eventName]=singleEventPubSub(eventName,newListener,removeListener);}/** pubSub instances are functions */function pubSubInstance(eventName){return singles[eventName]||newSingle(eventName);}// add convenience EventEmitter-style uncurried form of 'emit' and 'on'\n\t['emit','on','un'].forEach(function(methodName){pubSubInstance[methodName]=varArgs(function(eventName,parameters){apply(parameters,pubSubInstance(eventName)[methodName]);});});return pubSubInstance;}", "title": "" }, { "docid": "d4010f9917e890c67b8a4cfd5815fee1", "score": "0.48005077", "text": "function _subscribe(subscriber) {\n\t /* jshint validthis:true */\n\t var that = this;\n\t\n\t // call super._subscribe()\n\t var subscription = Object.getPrototypeOf(Object.getPrototypeOf(this))\n\t ._subscribe.call(this, subscriber);\n\t that._countStimulus.next(that.refCount);\n\t\n\t var _unsubscribe = subscription._unsubscribe.bind(subscription);\n\t\n\t // money-patch _unsubscribe() and defer to the subscrition\n\t subscription._unsubscribe = function unsubscribe() {\n\t _unsubscribe(subscription);\n\t that._countStimulus.next(that.refCount);\n\t };\n\t return subscription;\n\t}", "title": "" }, { "docid": "760f3698be2a49f26ad27fd78c4d1bfc", "score": "0.48001146", "text": "function Va(t, e, n) {\n var r = this;\n void 0 === n && (n = {});\n var i = new vr;\n return t.fs.ys((function() {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(r, void 0, void 0, (function() {\n var r;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(o) {\n switch (o.label) {\n case 0:\n return r = function(t, e, n, r, i) {\n var o = new Ds({\n next: function(o) {\n // Remove query first before passing event to user to avoid\n // user actions affecting the now stale query.\n e.ys((function() {\n return ku(t, u);\n }));\n var s = o.docs.has(n);\n !s && o.fromCache ? \n // TODO(dimond): If we're online and the document doesn't\n // exist then we resolve with a doc.exists set to false. If\n // we're offline however, we reject the Promise in this\n // case. Two options: 1) Cache the negative response from\n // the server so we can deliver that even when you're\n // offline 2) Actually reject the Promise in the online case\n // if the document doesn't exist.\n i.reject(new U(R.UNAVAILABLE, \"Failed to get document because the client is offline.\")) : s && o.fromCache && r && \"server\" === r.source ? i.reject(new U(R.UNAVAILABLE, 'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to \"server\" to retrieve the cached document.)')) : i.resolve(o);\n },\n error: function(t) {\n return i.reject(t);\n }\n }), u = new Cu(se(n.path), o, {\n includeMetadataChanges: !0,\n sl: !0\n });\n return xu(t, u);\n }, [ 4 /*yield*/ , Ca(t) ];\n\n case 1:\n return [ 2 /*return*/ , r.apply(void 0, [ o.sent(), t.fs, e, n, i ]) ];\n }\n }));\n }));\n })), i.promise;\n}", "title": "" }, { "docid": "a9e476ca73eb6b7b8c3f697f8e49bffe", "score": "0.4798139", "text": "reduce_result(z_result, h_node) {\n\t\tlet {\n\t\t\tgroup: k_group,\n\t\t\treductions: k_pairwise_tree,\n\t\t\treduce_task: h_task_ready,\n\t\t} = this;\n\n\t\t// final result\n\t\tif(HP_WORKER_NOTIFICATION !== z_result) {\n\t\t\tlet z_completion = this.complete_callback(z_result);\n\n\t\t\t// add to outer stream\n\t\t\tif(z_completion instanceof active_group) {\n\t\t\t\tlet k_lake = this.lake();\n\t\t\t\tlet fk_lake = k_lake.complete_callback;\n\t\t\t\tlet hp_lock = Symbol('key');\n\n\t\t\t\tz_completion.end(() => {\n\t\t\t\t\tk_group.unlock(hp_lock);\n\t\t\t\t});\n\n\t\t\t\t// rewrap completion callback function\n\t\t\t\tk_lake.complete_callback = () => {\n\t\t\t\t\tk_group.wait(hp_lock, () => {\n\t\t\t\t\t\tfk_lake();\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\t// notification\n\t\telse {\n\t\t\tif(this.debug) {\n\t\t\t\tconsole.warn('\\t == committed '+h_node.left+' </> '+h_node.right);\n\t\t\t}\n\n\t\t\t// able to perform a reduction\n\t\t\tlet h_merge = k_pairwise_tree.commit(h_node);\n\t\t\t// k_pairwise_tree.print();\n\t\t\tif(h_merge) {\n\t\t\t\tif(this.debug) {\n\t\t\t\t\tconsole.warn('merged '+h_merge.node.left+' <-> '+h_merge.node.right);\n\t\t\t\t}\n\t\t\t\tlet k_worker = h_node.item.worker;\n\n\t\t\t\t// this reduction will be the last one; do not hold result\n\t\t\t\tif(h_merge.makes_root) {\n\t\t\t\t\th_task_ready = Object.assign({}, h_task_ready);\n\t\t\t\t\th_task_ready.hold = false;\n\t\t\t\t}\n\n\t\t\t\t// after reduction;\n\t\t\t\tlet fk_reduction = (z_result_reduction, i_task_reduction, k_worker_reduction) => {\n\t\t\t\t\t// if(this.debug) debugger;\n\n\t\t\t\t\t// recurse on reduction; update sender for callback scope\n\t\t\t\t\tthis.reduce_result(z_result_reduction, Object.assign(h_merge.node, {\n\t\t\t\t\t\titem: {\n\t\t\t\t\t\t\tworker: k_worker_reduction,\n\t\t\t\t\t\t\ttask_id: i_task_reduction,\n\t\t\t\t\t\t},\n\t\t\t\t\t}));\n\t\t\t\t};\n\n\t\t\t\t// give reduction task to worker that finished earlier; pass to the right\n\t\t\t\tif(k_worker === h_merge.left.worker) {\n\t\t\t\t\tk_group.relay({\n\t\t\t\t\t\tdebug: this.debug,\n\t\t\t\t\t\tsender: h_node.item,\n\t\t\t\t\t\treceiver: h_merge.right,\n\t\t\t\t\t\treceiver_primary: false,\n\t\t\t\t\t\ttask_ready: h_task_ready,\n\t\t\t\t\t}, fk_reduction);\n\t\t\t\t}\n\t\t\t\t// pass to the left\n\t\t\t\telse {\n\t\t\t\t\tk_group.relay({\n\t\t\t\t\t\tdebug: this.debug,\n\t\t\t\t\t\tsender: h_node.item,\n\t\t\t\t\t\treceiver: h_merge.left,\n\t\t\t\t\t\treceiver_primary: true,\n\t\t\t\t\t\ttask_ready: h_task_ready,\n\t\t\t\t\t}, fk_reduction);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "473bc4f9feccdb06bcd57739a6f49d9c", "score": "0.4793775", "text": "function eu(t, e) {\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__awaiter)(this, void 0, void 0, (function() {\n var n, i, o, s, u, a, c, h;\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__generator)(this, (function(r) {\n switch (r.label) {\n case 0:\n return uu(n = F(t)), au(n), !0 !== e || !0 === n.$o ? [ 3 /*break*/ , 3 ] : (i = n.sharedClientState.getAllActiveQueryTargets(), \n [ 4 /*yield*/ , nu(n, i.toArray()) ]);\n\n case 1:\n return o = r.sent(), n.$o = !0, [ 4 /*yield*/ , ss(n.remoteStore, !0) ];\n\n case 2:\n for (r.sent(), s = 0, u = o; s < u.length; s++) a = u[s], Uo(n.remoteStore, a);\n return [ 3 /*break*/ , 7 ];\n\n case 3:\n return !1 !== e || !1 === n.$o ? [ 3 /*break*/ , 7 ] : (c = [], h = Promise.resolve(), \n n.Vo.forEach((function(t, e) {\n n.sharedClientState.isLocalQueryTarget(e) ? c.push(e) : h = h.then((function() {\n return Qs(n, e), Hi(n.localStore, e, \n /*keepPersistedTargetData=*/ !0);\n })), Bo(n.remoteStore, e);\n })), [ 4 /*yield*/ , h ]);\n\n case 4:\n return r.sent(), [ 4 /*yield*/ , nu(n, c) ];\n\n case 5:\n return r.sent(), \n // PORTING NOTE: Multi-Tab only.\n function(t) {\n var e = F(t);\n e.Co.forEach((function(t, n) {\n Bo(e.remoteStore, n);\n })), e.No.ts(), e.Co = new Map, e.Do = new We(ct.comparator);\n }(n), n.$o = !1, [ 4 /*yield*/ , ss(n.remoteStore, !1) ];\n\n case 6:\n r.sent(), r.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "316e4a53a256818ae9b8c0fda4b29086", "score": "0.47842947", "text": "function Ju(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var n, r, i;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(o) {\n switch (o.label) {\n case 0:\n return n = x(t), r = n.Sl.get(e), (i = n.Dl.get(r.targetId)).length > 1 ? [ 2 /*return*/ , (n.Dl.set(r.targetId, i.filter((function(t) {\n return !ye(t, e);\n }))), void n.Sl.delete(e)) ] : n.$l ? (\n // We need to remove the local query target first to allow us to verify\n // whether any other client is still interested in this target.\n n.pl.La(r.targetId), n.pl.Ca(r.targetId) ? [ 3 /*break*/ , 2 ] : [ 4 /*yield*/ , po(n.Sh, r.targetId, \n /*keepPersistedTargetData=*/ !1).then((function() {\n n.pl.Ba(r.targetId), ou(n.gl, r.targetId), rs(n, r.targetId);\n })).catch(_i) ]) : [ 3 /*break*/ , 3 ];\n\n case 1:\n o.sent(), o.label = 2;\n\n case 2:\n return [ 3 /*break*/ , 5 ];\n\n case 3:\n return rs(n, r.targetId), [ 4 /*yield*/ , po(n.Sh, r.targetId, \n /*keepPersistedTargetData=*/ !0) ];\n\n case 4:\n o.sent(), o.label = 5;\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "f1160b04a861003cc25fd6b1aea26bcc", "score": "0.47694045", "text": "function tu(t, e, i, o) {\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__awaiter)(this, void 0, void 0, (function() {\n var n, s;\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__generator)(this, (function(r) {\n switch (r.label) {\n case 0:\n return [ 4 /*yield*/ , function(t, e) {\n var n = F(t), r = F(n._n);\n return n.persistence.runTransaction(\"Lookup mutation documents\", \"readonly\", (function(t) {\n return r.jt(t, e).next((function(e) {\n return e ? n.Mn.pn(t, e) : Ir.resolve(null);\n }));\n }));\n }((n = F(t)).localStore, e) ];\n\n case 1:\n return null === (s = r.sent()) ? [ 3 /*break*/ , 6 ] : \"pending\" !== i ? [ 3 /*break*/ , 3 ] : [ 4 /*yield*/ , Zo(n.remoteStore) ];\n\n case 2:\n // If we are the primary client, we need to send this write to the\n // backend. Secondary clients will ignore these writes since their remote\n // connection is disabled.\n return r.sent(), [ 3 /*break*/ , 4 ];\n\n case 3:\n \"acknowledged\" === i || \"rejected\" === i ? (\n // NOTE: Both these methods are no-ops for batches that originated from\n // other clients.\n Ks(n, e, o || null), js(n, e), function(t, e) {\n F(F(t)._n).Gt(e);\n }(n.localStore, e)) : O(), r.label = 4;\n\n case 4:\n return [ 4 /*yield*/ , Ys(n, s) ];\n\n case 5:\n return r.sent(), [ 3 /*break*/ , 7 ];\n\n case 6:\n // A throttled tab may not have seen the mutation before it was completed\n // and removed from the mutation queue, in which case we won't have cached\n // the affected documents. In this case we can safely ignore the update\n // since that means we didn't apply the mutation locally at all (if we\n // had, we would have cached the affected documents), and so we will just\n // see any resulting document changes via normal remote document updates\n // as applicable.\n C(\"SyncEngine\", \"Cannot apply mutation batch with id: \" + e), r.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "97fc90462a571181c3ab6e886ef1f77c", "score": "0.4766562", "text": "function _find_subscription(dl_subs, publisher, event, kw, subscriber)\n {\n let sub_list = [];\n\n let __global__ = null;\n let __config__ = null;\n let __filter__ = null;\n if(kw) {\n let __global__ = kw[\"__global__\"];\n let __config__ = kw[\"__config__\"];\n let __filter__ = kw[\"__filter__\"];\n }\n\n for(let i=0; i<dl_subs.length; i++) {\n let subs = dl_subs[i];\n let match = true;\n\n if(subscriber) {\n if(subscriber != subs.subscriber) {\n match = false;\n }\n }\n\n if(event) {\n if(event != subs.event) {\n match = false;\n }\n }\n\n if(__config__) {\n let kw_config = subs[\"__config__\"];\n if(kw_config) {\n if(!kw_is_identical(kw_config, __config__)) {\n match = false;\n }\n } else {\n match = false;\n }\n }\n if(__global__) {\n let kw_global = subs[\"__global__\"];\n if(kw_global) {\n if(!kw_is_identical(kw_global, __global__)) {\n match = false;\n }\n } else {\n match = false;\n }\n }\n if(__filter__) {\n let kw_filter = subs[\"__filter__\"];\n if(kw_filter) {\n if(!kw_is_identical(kw_filter, __filter__)) {\n match = false;\n }\n } else {\n match = false;\n }\n }\n\n if(match) {\n sub_list.push(subs);\n }\n }\n return sub_list;\n }", "title": "" }, { "docid": "d028cfef5c4d5070aa8877950f6f2af4", "score": "0.47631127", "text": "function pipe(functions) {\n\n}", "title": "" }, { "docid": "acc2a9835b0ddac9a73434e3ed3edbbd", "score": "0.47628808", "text": "publish(event, data) {\n if (!subscribers[event]) return\n subscribers[event].forEach(subscriberCallback =>\n subscriberCallback(data))\n }", "title": "" }, { "docid": "1297e3522e2c15d15f9ed0c8ae1ddb2a", "score": "0.47608614", "text": "function reduce(accumulator, seed) {\n if (arguments.length >= 2) {\n return function reduceOperatorFunctionWithSeed(source) {\n return Object(pipe[\"a\" /* pipe */])(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);\n };\n }\n return function reduceOperatorFunction(source) {\n return Object(pipe[\"a\" /* pipe */])(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);\n };\n}", "title": "" }, { "docid": "b4188f8d450b8d797f458984720791aa", "score": "0.47342315", "text": "function Uu(t, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"])(this, void 0, void 0, function () {\n var e, i, o;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"])(this, function (n) {\n switch (n.label) {\n case 0:\n return [4\n /*yield*/\n , mo((e = D(t)).Kc, r.query,\n /* usePreviousResults= */\n !0)];\n\n case 1:\n return i = n.sent(), o = r.view.Nh(i), [2\n /*return*/\n , (e.Jh && Pu(e, r.targetId, o.Dh), o)];\n }\n });\n });\n }", "title": "" }, { "docid": "30c4534ce3e950709fed37dd3ca2849c", "score": "0.47333393", "text": "function subscribeImpl(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) {\n var subscription = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver);\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `execute` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n return (0, _mapAsyncIterator2.default)(subscription, function (payload) {\n return (0, _execute.execute)(schema, document, payload, contextValue, variableValues, operationName, fieldResolver);\n });\n}", "title": "" }, { "docid": "30c4534ce3e950709fed37dd3ca2849c", "score": "0.47333393", "text": "function subscribeImpl(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) {\n var subscription = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver);\n\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `execute` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n return (0, _mapAsyncIterator2.default)(subscription, function (payload) {\n return (0, _execute.execute)(schema, document, payload, contextValue, variableValues, operationName, fieldResolver);\n });\n}", "title": "" }, { "docid": "6b5a451b7890d9970639606ca43395fa", "score": "0.4720384", "text": "function spaghetti() {\n // does a transfrom\n // calls another fuction for some data\n // does another transform \n // does some logic\n}", "title": "" }, { "docid": "4209beec0279e266519c3451ed803d54", "score": "0.47173518", "text": "function demo() {\n let array1 = [[0, 1], [2, 3], [4, 5]].reduceRight(\n (accumulator, currentValue) => accumulator.concat(currentValue)\n );\n\n console.log(array1);\n // expected output: Array [4, 5, 2, 3, 0, 1]\n\n sumUpAllValuesInArray();\n flattenArrayOfArrays();\n runListOfAsyncFunctions();\n differenceBetweenReduceAndReduceRight();\n definingComposibleFunction();\n}", "title": "" }, { "docid": "f1b9376e4d7270b902aeb59d3d93bd44", "score": "0.4716039", "text": "function Ku(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var n, r, i, o, u, s;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(a) {\n switch (a.label) {\n case 0:\n return n = bs(t), (o = n.Sl.get(e)) ? (\n // PORTING NOTE: With Multi-Tab Web, it is possible that a query view\n // already exists when EventManager calls us for the first time. This\n // happens when the primary tab is already listening to this query on\n // behalf of another tab and the user of the primary also starts listening\n // to the query. EventManager will not have an assigned target ID in this\n // case and calls `listen` to obtain this ID.\n r = o.targetId, n.pl.ka(r), i = o.view.Pl(), [ 3 /*break*/ , 4 ]) : [ 3 /*break*/ , 1 ];\n\n case 1:\n return [ 4 /*yield*/ , lo(n.Sh, de(e)) ];\n\n case 2:\n return u = a.sent(), s = n.pl.ka(u.targetId), r = u.targetId, [ 4 /*yield*/ , Hu(n, e, r, \"current\" === s) ];\n\n case 3:\n i = a.sent(), n.$l && iu(n.gl, u), a.label = 4;\n\n case 4:\n return [ 2 /*return*/ , i ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "897d530758a3bcec8c58313ba2542b19", "score": "0.47125557", "text": "subscribe(event, callback) {\n if (!subscribers[event]) {\n subscribers[event] = []\n }\n const index = subscribers[event].push(callback) - 1 // push returns new length of the array\n\n return {\n unsubscribe() {\n subscribers[event].splice(index, 1) // removing the callback \n }\n };\n }", "title": "" }, { "docid": "a6945da18d59850567843dd986c82132", "score": "0.46977505", "text": "function uniqSubs() {\n}", "title": "" }, { "docid": "c5531c3418414a2fc2ea6836867236b6", "score": "0.4696991", "text": "_callSubscriber() {\n console.log('observer');\n }", "title": "" }, { "docid": "897262c96c58f1c1d318f55c5d84c506", "score": "0.4693831", "text": "generateSubscribeFunc(field){\n if(this.subscribers[field]){\n debug(\"FAILED TO GENERATE NEW SUBSRIBE FUNCTION (FIELD TO SUBSCRIBE WASNT UNIQUE)\");\n throw err;\n }\n this.subscribers[field] = new Map();\n let subId = 0;\n return (updateFunction) => {\n this.subscribers[field].set(subId, updateFunction);\n return subId++;\n }\n }", "title": "" }, { "docid": "db7baed1f1a66b9f67e32f8b26d58bf3", "score": "0.4693187", "text": "function Tu(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var n, r;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(i) {\n switch (i.label) {\n case 0:\n return n = x(t), e ? (n.Fh.delete(2 /* IsSecondary */), [ 4 /*yield*/ , nu(n) ]) : [ 3 /*break*/ , 2 ];\n\n case 1:\n return i.sent(), [ 3 /*break*/ , 5 ];\n\n case 2:\n return (r = e) ? [ 3 /*break*/ , 4 ] : (n.Fh.add(2 /* IsSecondary */), [ 4 /*yield*/ , ru(n) ]);\n\n case 3:\n i.sent(), r = n.Mh.set(\"Unknown\" /* Unknown */), i.label = 4;\n\n case 4:\n r, i.label = 5;\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "57f7b67217d2ff93dc04fcaa8d196b77", "score": "0.4686723", "text": "function subscribe (partitionName, listener, arrKeys, listenerName) {\r\n if (typeof listener !== 'function') {\r\n error('subscribe listener argument is not a function.')\r\n }\r\n if (!Array.isArray(arrKeys)) {\r\n arrKeys = [arrKeys]\r\n }\r\n if (_store !== null) {\r\n if (typeof _store[partitionName] === undefinedString) {\r\n error(`${partitionName} is an invalid partition.`)\r\n }\r\n _store[partitionName].subscribe(listener, arrKeys, listenerName)\r\n } else {\r\n _subscribers.push({ partitionName, listener, arrKeys, listenerName })\r\n }\r\n}", "title": "" }, { "docid": "2d27ba1683c8096e2e5a9b4c8fb6ea81", "score": "0.46862468", "text": "function reducer(value, count, arg) {\n\n }", "title": "" }, { "docid": "23c8dd6cb57de81e6fccdc716bd9102e", "score": "0.46838126", "text": "function subjectFunctional(rc) {\n return rc.subject;\n}", "title": "" }, { "docid": "c13a1989189e66aa346e8f37ac6c98d1", "score": "0.4679539", "text": "function Bu(t, e, n) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var r, i, o, u;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(s) {\n switch (s.label) {\n case 0:\n r = ms(t), s.label = 1;\n\n case 1:\n return s.trys.push([ 1, 5, , 6 ]), [ 4 /*yield*/ , function(t, e) {\n var n, r = O(t), i = K.now(), o = e.reduce((function(t, e) {\n return t.add(e.key);\n }), mn());\n return r.persistence.runTransaction(\"Locally write mutations\", \"readwrite\", (function(t) {\n return r.Tc.Xo(t, o).next((function(o) {\n n = o;\n for (\n // For non-idempotent mutations (such as `FieldValue.increment()`),\n // we record the base state in a separate patch mutation. This is\n // later used to guarantee consistent values and prevents flicker\n // even if the backend sends us an update that already includes our\n // transform.\n var u = [], s = 0, a = e; s < a.length; s++) {\n var c = a[s], h = Fe(c, n.get(c.key));\n null != h && \n // NOTE: The base state should only be applied if there's some\n // existing document to override, so use a Precondition of\n // exists=true\n u.push(new Qe(c.key, h, kt(h.proto.mapValue), Re.exists(!0)));\n }\n return r.zo.Ri(t, i, u, e);\n }));\n })).then((function(t) {\n var e = t.xs(n);\n return {\n batchId: t.batchId,\n ri: e\n };\n }));\n }(r.bh, e) ];\n\n case 2:\n return i = s.sent(), r.Vl.Ca(i.batchId), function(t, e, n) {\n var r = t.Fl[t.currentUser.A()];\n r || (r = new rn(V)), r = r.zt(e, n), t.Fl[t.currentUser.A()] = r;\n }(r, i.batchId, n), [ 4 /*yield*/ , is(r, i.ri) ];\n\n case 3:\n return s.sent(), [ 4 /*yield*/ , pu(r.yl) ];\n\n case 4:\n return s.sent(), [ 3 /*break*/ , 6 ];\n\n case 5:\n return o = s.sent(), u = Er(o, \"Failed to persist write\"), n.reject(u), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "c465267ff0f8c4b4aa35ce274eb260c3", "score": "0.46793088", "text": "addSubscriber(propName, fn) {\n _subscribers[propName].push(fn)\n }", "title": "" }, { "docid": "c465267ff0f8c4b4aa35ce274eb260c3", "score": "0.46793088", "text": "addSubscriber(propName, fn) {\n _subscribers[propName].push(fn)\n }", "title": "" }, { "docid": "9ba7b0365ca0bba640778478e0b8a08c", "score": "0.46770576", "text": "function sumArray() {\n const reducer = (accumulator, currentValue) => accumulator + currentValue;\n console.log(numbers1.reduce(reducer));\n}", "title": "" }, { "docid": "a28a603d270bf7fb1761df9dc5643f27", "score": "0.46760505", "text": "function Fu(t, r, i, o) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"])(this, void 0, void 0, function () {\n var e, u;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"])(this, function (n) {\n switch (n.label) {\n case 0:\n return [4\n /*yield*/\n , function (t, e) {\n var n = D(t),\n r = D(n.xi);\n return n.persistence.runTransaction(\"Lookup mutation documents\", \"readonly\", function (t) {\n return r.jr(t, e).next(function (e) {\n return e ? n.Ga.Li(t, e) : or.resolve(null);\n });\n });\n }((e = D(t)).Kc, r)];\n\n case 1:\n return null === (u = n.sent()) ? [3\n /*break*/\n , 6] : \"pending\" !== i ? [3\n /*break*/\n , 3] : [4\n /*yield*/\n , Go(e.Oh)];\n\n case 2:\n // If we are the primary client, we need to send this write to the\n // backend. Secondary clients will ignore these writes since their remote\n // connection is disabled.\n return n.sent(), [3\n /*break*/\n , 4];\n\n case 3:\n \"acknowledged\" === i || \"rejected\" === i ? ( // NOTE: Both these methods are no-ops for batches that originated from\n // other clients.\n ku(e, r, o || null), Su(e, r), function (t, e) {\n D(D(t).xi).Zr(e);\n }(e.Kc, r)) : S(), n.label = 4;\n\n case 4:\n return [4\n /*yield*/\n , Lu(e, u)];\n\n case 5:\n return n.sent(), [3\n /*break*/\n , 7];\n\n case 6:\n // A throttled tab may not have seen the mutation before it was completed\n // and removed from the mutation queue, in which case we won't have cached\n // the affected documents. In this case we can safely ignore the update\n // since that means we didn't apply the mutation locally at all (if we\n // had, we would have cached the affected documents), and so we will just\n // see any resulting document changes via normal remote document updates\n // as applicable.\n T(\"SyncEngine\", \"Cannot apply mutation batch with id: \" + r), n.label = 7;\n\n case 7:\n return [2\n /*return*/\n ];\n }\n });\n });\n }", "title": "" }, { "docid": "0368e51d2b47c78ee3b5d6f4c7da0df0", "score": "0.4669364", "text": "subscribe(filterFunc, iterFunc) {\n return this.assertTable()\n .then(() => this.fullQuery(filterFunc).run(this.conn))\n .then(cursor => cursor.each((err, message) => {\n if (err) {\n throw err;\n }\n\n iterFunc(message.topic, message.payload);\n }));\n }", "title": "" }, { "docid": "895c9e65691850c90625a9738fa63ee0", "score": "0.46693316", "text": "function hs(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var n, r, i, o, u, s, a, c;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(h) {\n switch (h.label) {\n case 0:\n return ys(n = O(t)), ms(n), !0 !== e || !0 === n.Ml ? [ 3 /*break*/ , 3 ] : (r = n.Vl.va(), \n [ 4 /*yield*/ , fs(n, r.it()) ]);\n\n case 1:\n return i = h.sent(), n.Ml = !0, [ 4 /*yield*/ , bu(n.yl, !0) ];\n\n case 2:\n for (h.sent(), o = 0, u = i; o < u.length; o++) s = u[o], tu(n.yl, s);\n return [ 3 /*break*/ , 7 ];\n\n case 3:\n return !1 !== e || !1 === n.Ml ? [ 3 /*break*/ , 7 ] : (a = [], c = Promise.resolve(), \n n.Sl.forEach((function(t, e) {\n n.Vl.La(e) ? a.push(e) : c = c.then((function() {\n return $u(n, e), co(n.bh, e, \n /*keepPersistedTargetData=*/ !0);\n })), eu(n.yl, e);\n })), [ 4 /*yield*/ , c ]);\n\n case 4:\n return h.sent(), [ 4 /*yield*/ , fs(n, a) ];\n\n case 5:\n return h.sent(), \n // PORTING NOTE: Multi-Tab only.\n function(t) {\n var e = O(t);\n e.xl.forEach((function(t, n) {\n eu(e.yl, n);\n })), e.Nl.kc(), e.xl = new Map, e.Cl = new rn(tt.H);\n }(n), n.Ml = !1, [ 4 /*yield*/ , bu(n.yl, !1) ];\n\n case 6:\n h.sent(), h.label = 7;\n\n case 7:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "b9acf83f369b0eb559eeb7c85b054297", "score": "0.46678805", "text": "constructor(source) {\n this.subscribers = {};\n this.source = source;\n }", "title": "" }, { "docid": "7e43653f0be76b44cc8c5356dc256ea8", "score": "0.4667312", "text": "function addStream(req, res, view, delta) {\n // save a reference to our subscriber\n var myReduction, data, sub;\n\n sub = {\n res: res\n };\n\n // give him an identity and save his headers\n // note we will use the headers for our \"personalization\"\n // stage in the pipeline\n sub._identity = new Identity();\n sub._identity.headers = req.headers;\n sub._identity.delta = delta;\n\n // throw this in our hash\n view.subscriptions[sub._identity._id] = sub;\n\n function drain() {\n var draindata;\n global.logger.log('info', 'drain - subscription:', sub._identity._id);\n if (sub.data) {\n if (sub._identity.delta) {\n draindata = Symmetry.diff(sub.last, sub.data);\n } else {\n draindata = sub.data;\n }\n\n sub.last = sub.data;\n\n res.write('event: ');\n res.write(view._identity._id + '\\n');\n res.write(\"data: \");\n sub.overflow = !res.write(JSON.stringify(draindata) + '\\n\\n');\n }\n delete sub.data;\n }\n\n // if we lose a subscriber, take it out of the hash\n function remove() {\n delete view.subscriptions[sub._identity._id];\n }\n res.on('end', remove);\n res.on('close', remove);\n res.on('drain', drain);\n\n // get the reduction\n myReduction = view.personalize(sub._identity._id);\n data = JSON.stringify(myReduction);\n if (sub._identity.delta) {\n sub.last = myReduction;\n }\n\n // NOTE we need to break this up or express escape encodes\n // it. must\n // think it's a header!\n res.write('event: ');\n res.write(view._identity._id + '\\n');\n res.write(\"data: \");\n sub.overflow = !res.write(data + '\\n\\n');\n\n}", "title": "" }, { "docid": "323561d2d99ad357602f69a73ba4bd30", "score": "0.46533686", "text": "function F$2(F){function m(e,o,i){if(e instanceof t$5)return e.toArray();if(Y$5(e))return e;throw new t$6(o,e$7.InvalidParameter,i)}function p(n,t){const r=n.length,e=Math.floor(r/2);return 0===r?[]:1===r?[n[0]]:y(p(n.slice(0,e),t),p(n.slice(e,r),t),t)}function y(n,t,r){const e=[];for(;n.length>0||t.length>0;)if(n.length>0&&t.length>0){let o=r(n[0],t[0]);isNaN(o)&&(o=0),o<=0?(e.push(n[0]),n=n.slice(1)):(e.push(t[0]),t=t.slice(1));}else n.length>0?(e.push(n[0]),n=n.slice(1)):t.length>0&&(e.push(t[0]),t=t.slice(1));return e}async function v(n,t){const r=n.length,e=Math.floor(r/2);if(0===r)return [];if(1===r)return [n[0]];const o=[await v(n.slice(0,e),t),await v(n.slice(e,r),t)];return P(o[0],o[1],t,[])}async function P(n,t,r,e){const o=e;if(!(n.length>0||t.length>0))return e;if(n.length>0&&t.length>0){let i=await r(n[0],t[0]);return isNaN(i)&&(i=1),i<=0?(o.push(n[0]),n=n.slice(1)):(o.push(t[0]),t=t.slice(1)),P(n,t,r,e)}return n.length>0?(o.push(n[0]),P(n=n.slice(1),t,r,e)):t.length>0?(o.push(t[0]),P(n,t=t.slice(1),r,e)):void 0}function I(r,o,i,u){V$5(i,1,2,r,o);let l=i[0];if(E$3(l)&&(l=l.toArray()),!1===Y$5(l))throw new t$6(r,e$7.InvalidParameter,o);if(i.length>1){if(!1===F$3(i[1]))throw new t$6(r,e$7.InvalidParameter,o);let e=l;const a=i[1].createFunction(r);return u?v(e,a):(e=p(e,((n,t)=>a(n,t))),e)}let f=l;if(0===f.length)return [];const g={};for(let n=0;n<f.length;n++){const t=O$4(f[n]);\"\"!==t&&(g[t]=!0);}if(!0===g.Array||!0===g.Dictionary||!0===g.Feature||!0===g.Point||!0===g.Polygon||!0===g.Polyline||!0===g.Multipoint||!0===g.Extent||!0===g.Function)return f.slice(0);let F=0,m=\"\";for(const n in g)F++,m=n;return f=F>1||\"String\"===m?p(f,((n,t)=>{if(null==n||n===k$3)return null==t||t===k$3?0:1;if(null==t||t===k$3)return -1;const r=K$3(n),e=K$3(t);return r<e?-1:r===e?0:1})):\"Number\"===m?p(f,((n,t)=>n-t)):\"Boolean\"===m?p(f,((n,t)=>n===t?0:t?-1:1)):\"Date\"===m?p(f,((n,t)=>t-n)):f.slice(0),f}F.functions.array=function(r,a){return F.standardFunction(r,a,((c,s,l)=>{V$5(l,1,2,r,a);const f=re$5(l[0]);if(isNaN(f)||!1===L$3(f))throw new t$6(r,e$7.InvalidParameter,a);const d=v$2(l[1],null),h=new Array(f);return h.fill(d),h}))},F.functions.front=function(r,o){return F.standardFunction(r,o,((i,u,s)=>{if(V$5(s,1,1,r,o),E$3(s[0])){if(s[0].length()<=0)throw new t$6(r,e$7.OutOfBounds,o);return s[0].get(0)}if(Y$5(s[0])){if(s[0].length<=0)throw new t$6(r,e$7.OutOfBounds,o);return s[0][0]}throw new t$6(r,e$7.InvalidParameter,o)}))},F.functions.back=function(r,o){return F.standardFunction(r,o,((i,u,s)=>{if(V$5(s,1,1,r,o),E$3(s[0])){if(s[0].length()<=0)throw new t$6(r,e$7.OutOfBounds,o);return s[0].get(s[0].length()-1)}if(Y$5(s[0])){if(s[0].length<=0)throw new t$6(r,e$7.OutOfBounds,o);return s[0][s[0].length-1]}throw new t$6(r,e$7.InvalidParameter,o)}))},F.functions.push=function(r,o){return F.standardFunction(r,o,((i,u,a)=>{if(V$5(a,1,2,r,o),Y$5(a[0]))return a[0][a[0].length]=a[1],a[0].length;throw new t$6(r,e$7.InvalidParameter,o)}))},F.functions.pop=function(r,o){return F.standardFunction(r,o,((i,u,a)=>{if(V$5(a,1,1,r,o),Y$5(a[0])){if(a[0].length<=0)throw new t$6(r,e$7.OutOfBounds,o);const e=a[0][a[0].length-1];return a[0].length=a[0].length-1,e}throw new t$6(r,e$7.InvalidParameter,o)}))},F.functions.erase=function(r,u){return F.standardFunction(r,u,((a,l,f)=>{if(V$5(f,2,2,r,u),Y$5(f[0])){let e=re$5(f[1]);if(isNaN(e)||!1===L$3(e))throw new t$6(r,e$7.InvalidParameter,u);const a=f[0];if(a.length<=0)throw new t$6(r,e$7.OutOfBounds,u);if(e<0&&(e=a.length+e),e<0)throw new t$6(r,e$7.OutOfBounds,u);if(e>=a.length)throw new t$6(r,e$7.OutOfBounds,u);return a.splice(e,1),k$3}throw new t$6(r,e$7.InvalidParameter,u)}))},F.functions.insert=function(r,u){return F.standardFunction(r,u,((a,l,f)=>{if(V$5(f,3,3,r,u),Y$5(f[0])){const e=re$5(f[1]);if(isNaN(e)||!1===L$3(e))throw new t$6(r,e$7.InvalidParameter,u);const a=f[2],c=f[0];if(e>c.length)throw new t$6(r,e$7.OutOfBounds,u);if(e<0&&e<-1*c.length)throw new t$6(r,e$7.OutOfBounds,u);return e===c.length?(c[e]=a,k$3):(c.splice(e,0,a),k$3)}throw new t$6(r,e$7.InvalidParameter,u)}))},F.functions.resize=function(r,a){return F.standardFunction(r,a,((l,f,d)=>{if(V$5(d,2,3,r,a),Y$5(d[0])){const e=re$5(d[1]);if(isNaN(e)||!1===L$3(e))throw new t$6(r,e$7.InvalidParameter,a);if(e<0)throw new t$6(r,e$7.InvalidParameter,a);const c=v$2(d[2],null),l=d[0];if(l.length>=e)return l.length=e,k$3;const f=l.length;l.length=e;for(let n=f;n<l.length;n++)l[n]=c;return k$3}throw new t$6(r,e$7.InvalidParameter,a)}))},F.functions.includes=function(r,o){return F.standardFunction(r,o,((i,u,s)=>{if(V$5(s,2,2,r,o),Y$5(s[0])){const n=s[1];return s[0].findIndex((t=>X$5(t,n)))>-1}if(E$3(s[0])){const n=s[1];return s[0].toArray().findIndex((t=>X$5(t,n)))>-1}throw new t$6(r,e$7.InvalidParameter,o)}))},F.functions.slice=function(r,s){return F.standardFunction(r,s,((l,f,d)=>{if(V$5(d,1,3,r,s),Y$5(d[0])){const e=re$5(v$2(d[1],0)),a=re$5(v$2(d[2],d[0].length));if(isNaN(e)||!1===L$3(e))throw new t$6(r,e$7.InvalidParameter,s);if(isNaN(a)||!1===L$3(a))throw new t$6(r,e$7.InvalidParameter,s);return d[0].slice(e,a)}if(E$3(d[0])){const e=d[0],a=re$5(v$2(d[1],0)),c=re$5(v$2(d[2],e.length()));if(isNaN(a)||!1===L$3(a))throw new t$6(r,e$7.InvalidParameter,s);if(isNaN(c)||!1===L$3(c))throw new t$6(r,e$7.InvalidParameter,s);return e.toArray().slice(a,c)}throw new t$6(r,e$7.InvalidParameter,s)}))},F.functions.splice=function(n,t){return F.standardFunction(n,t,((n,t,r)=>{const e=[];for(let o=0;o<r.length;o++)Y$5(r[o])?e.push(...r[o]):E$3(r[o])?e.push(...r[o].toArray()):e.push(r[o]);return e}))},F.functions.top=function(r,i){return F.standardFunction(r,i,((u,s,l)=>{if(V$5(l,2,2,r,i),Y$5(l[0]))return re$5(l[1])>=l[0].length?l[0].slice(0):l[0].slice(0,re$5(l[1]));if(E$3(l[0]))return re$5(l[1])>=l[0].length()?l[0].slice(0):l[0].slice(0,re$5(l[1]));throw new t$6(r,e$7.InvalidParameter,i)}))},F.functions.first=function(n,t){return F.standardFunction(n,t,((r,o,i)=>(V$5(i,1,1,n,t),Y$5(i[0])?0===i[0].length?null:i[0][0]:E$3(i[0])?0===i[0].length()?null:i[0].get(0):null)))},\"sync\"===F.mode&&(F.functions.sort=function(n,t){return F.standardFunction(n,t,((r,e,o)=>I(n,t,o,!1)))},F.functions.any=function(n,t){return F.standardFunction(n,t,((r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t);for(const n of a){const t=u(n);if(_$4(t)&&!0===t)return !0}return !1}))},F.functions.all=function(n,t){return F.standardFunction(n,t,((r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t);for(const n of a){if(!0!==u(n))return !1}return !0}))},F.functions.none=function(n,t){return F.standardFunction(n,t,((r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t);for(const n of a){if(!0===u(n))return !1}return !0}))},F.functions.reduce=function(n,t){return F.standardFunction(n,t,((r,o,i)=>{V$5(i,2,3,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t);return 2===i.length?0===a.length?null:a.reduce(((n,t)=>{const r=u(n,t);return n=void 0!==r&&r!==k$3?r:null})):a.reduce(((n,t)=>{const r=u(n,t);return n=void 0!==r&&r!==k$3?r:null}),i[2])}))},F.functions.map=function(n,t){return F.standardFunction(n,t,((r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t),c=[];for(const n of a){const t=u(n);void 0!==t&&t!==k$3?c.push(t):c.push(null);}return c}))},F.functions.filter=function(n,t){return F.standardFunction(n,t,((r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t),c=[];for(const n of a){!0===u(n)&&c.push(n);}return c}))}),\"async\"===F.mode&&(F.functions.sort=function(n,t){return F.standardFunctionAsync(n,t,((r,e,o)=>I(n,t,o,!0)))},F.functions.any=function(n,t){return F.standardFunctionAsync(n,t,(async(r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t);for(const n of a){const t=await u(n);let r=null;if(r=C$5(r)?await t:t,_$4(r)&&!0===r)return !0}return !1}))},F.functions.all=function(n,t){return F.standardFunctionAsync(n,t,(async(r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t);for(const n of a){const t=await u(n);let r=null;if(r=C$5(r)?await t:t,!0!==r)return !1}return !0}))},F.functions.none=function(n,t){return F.standardFunctionAsync(n,t,(async(r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t);for(const n of a){const t=await u(n);let r=null;if(r=C$5(r)?await t:t,!0===r)return !1}return !0}))},F.functions.filter=function(n,t){return F.standardFunctionAsync(n,t,(async(r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t),c=[];for(const n of a){const t=await u(n);let r=null;r=C$5(r)?await t:t,!0===r&&c.push(n);}return c}))},F.functions.reduce=function(n,t){return F.standardFunctionAsync(n,t,((r,o,i)=>{V$5(i,2,3,n,t);const a=i[1].createFunction(n),c=m(i[0],n,t);let l=null;if(i.length>2){const n=v$2(i[2],null);l=c.reduce((async(n,t)=>{let r=await n;return void 0!==r&&r!==k$3||(r=null),a(r,t)}),Promise.resolve(n));}else {if(0===c.length)return null;l=c.reduce((async(n,t,r)=>{if(r<=1)return a(n,t);let e=await n;return void 0!==e&&e!==k$3||(e=null),a(e,t)}));}return l.then((n=>void 0!==n&&n!==k$3?n:null))}))},F.functions.map=function(n,t){return F.standardFunctionAsync(n,t,(async(r,o,i)=>{V$5(i,2,2,n,t);const u=i[1].createFunction(n),a=m(i[0],n,t),c=[];for(const n of a){const t=await u(n);let r=null;r=C$5(r)?await t:t,void 0!==r&&r!==k$3?c.push(r):c.push(null);}return c}))});}", "title": "" }, { "docid": "a5e68be16b1e6df1210ab376dc3a08f8", "score": "0.46520084", "text": "function pipe(...fns) {\n // TODO: rewrite above reduce to for cycle\n // urcite to bude vracat funkciu\n // len ju nejako musite poskladat\n // ako ? musite vediet precitat ten reduce hore\n let r=function(){};\n return r;\n}", "title": "" }, { "docid": "e196773f5b2edfe96ae4d945bf262927", "score": "0.464508", "text": "function bu(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var n, r;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(i) {\n switch (i.label) {\n case 0:\n return n = O(t), e ? (n.Nh.delete(2 /* IsSecondary */), [ 4 /*yield*/ , Jo(n) ]) : [ 3 /*break*/ , 2 ];\n\n case 1:\n return i.sent(), [ 3 /*break*/ , 5 ];\n\n case 2:\n return (r = e) ? [ 3 /*break*/ , 4 ] : (n.Nh.add(2 /* IsSecondary */), [ 4 /*yield*/ , $o(n) ]);\n\n case 3:\n i.sent(), r = n.kh.set(\"Unknown\" /* Unknown */), i.label = 4;\n\n case 4:\n r, i.label = 5;\n\n case 5:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "10a923361177f5f40972bbc4859c5096", "score": "0.46386698", "text": "async function subscribeToAtopic() {\n let streamService = new StreamService(process.env.MICRO_API_TOKEN);\n let rsp = await streamService.subscribe({\n topic: \"events\",\n });\n console.log(rsp);\n}", "title": "" }, { "docid": "40583ae323645f051f59634758f93920", "score": "0.4637334", "text": "function ts(a,b){this.L=[];this.Ba=a;this.ia=b||null;this.H=this.C=!1;this.F=void 0;this.ea=this.Ea=this.O=!1;this.N=0;this.vg=null;this.J=0}", "title": "" }, { "docid": "db88e34bfcf1fdafd7bd32cfc9fb42c4", "score": "0.4636199", "text": "function reduce(event, merge, initial) {\n var output = initial;\n return map(event, function (e) {\n output = merge(output, e);\n return output;\n });\n }", "title": "" }, { "docid": "1d9f3539c246c726a3916161374f6871", "score": "0.46316552", "text": "function vc(t) {\n for (var e, i, o, s = [], u = 1; u < arguments.length; u++) s[u - 1] = arguments[u];\n t = (0,_firebase_util__WEBPACK_IMPORTED_MODULE_0__.getModularInstance)(t);\n var a = {\n includeMetadataChanges: !1\n }, c = 0;\n \"object\" != typeof s[c] || ia(s[c]) || (a = s[c], c++);\n var h, f, d, p = {\n includeMetadataChanges: a.includeMetadataChanges\n };\n if (ia(s[c])) {\n var y = s[c];\n s[c] = null === (e = y.next) || void 0 === e ? void 0 : e.bind(y), s[c + 1] = null === (i = y.error) || void 0 === i ? void 0 : i.bind(y), \n s[c + 2] = null === (o = y.complete) || void 0 === o ? void 0 : o.bind(y);\n }\n if (t instanceof $u) f = zu(t.firestore, ua), d = Yt(t._key.path), h = {\n next: function(e) {\n s[c] && s[c](gc(f, t, e));\n },\n error: s[c + 1],\n complete: s[c + 2]\n }; else {\n var v = zu(t, Xu);\n f = zu(v.firestore, ua), d = v._query;\n var m = new pc(f);\n h = {\n next: function(t) {\n s[c] && s[c](new Ha(f, m, v, t));\n },\n error: s[c + 1],\n complete: s[c + 2]\n }, Xa(t._query);\n }\n return function(t, e, i, o) {\n var s = this, u = new yu(o), a = new Is(e, u, i);\n return t.asyncQueue.enqueueAndForget((function() {\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__awaiter)(s, void 0, void 0, (function() {\n var e;\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__generator)(this, (function(n) {\n switch (n.label) {\n case 0:\n return e = vs, [ 4 /*yield*/ , Au(t) ];\n\n case 1:\n return [ 2 /*return*/ , e.apply(void 0, [ n.sent(), a ]) ];\n }\n }));\n }));\n })), function() {\n u.Wo(), t.asyncQueue.enqueueAndForget((function() {\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__awaiter)(s, void 0, void 0, (function() {\n var e;\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__generator)(this, (function(n) {\n switch (n.label) {\n case 0:\n return e = ms, [ 4 /*yield*/ , Au(t) ];\n\n case 1:\n return [ 2 /*return*/ , e.apply(void 0, [ n.sent(), a ]) ];\n }\n }));\n }));\n }));\n };\n }(aa(f), d, p, h);\n}", "title": "" }, { "docid": "ba1673ecbb7b71019ff1fbe8731ef25a", "score": "0.4630351", "text": "subscribe (fn) {\n const subs = this._subscribers\n if (subs.indexOf(fn) < 0) {\n subs.push(fn)\n }\n return () => {\n const i = subs.indexOf(fn)\n if (i > -1) {\n subs.splice(i, 1)\n }\n }\n }", "title": "" }, { "docid": "09f4911a00397dcc9f890e24a53ba5da", "score": "0.46291184", "text": "function toSlateOps(events) {\n return events.flatMap(toSlateOp);\n}", "title": "" }, { "docid": "ce7faf2206047a876b0f2e916e9dc472", "score": "0.462679", "text": "function AggregateFunction(namespace) {\n classCallCheck(this, AggregateFunction);\n\n if (namespace !== internal$1) {\n throw new Error();\n }\n var scope = internal$1(this);\n\n for (var _len = arguments.length, targets = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n targets[_key - 1] = arguments[_key];\n }\n\n scope.targets = targets;\n }", "title": "" }, { "docid": "79c17a3e5357d18c874ba99104a59a19", "score": "0.46184346", "text": "function b() {\n bar$.subscribe(\n x => console.log('next ' + x),\n err => console.log(err),\n () => console.log('done')\n )\n}", "title": "" }, { "docid": "49b68d9eb219c2b1a29f1ba498075e87", "score": "0.46182778", "text": "static _enqueue_aggregate(buffer_in, buffer_out, count, aggregation_factor) {\n buffer_out.set(buffer_out.subarray(count));\n for (let i = buffer_out.length - count, offset_in = 0; i < buffer_out.length; i++, offset_in += aggregation_factor) {\n buffer_out[i] = buffer_in[offset_in];\n }\n }", "title": "" }, { "docid": "64683f0914363550da731cedfa872b64", "score": "0.46166", "text": "function ts(a,b){this.O=[];this.Ea=a;this.la=b||null;this.J=this.C=!1;this.H=void 0;this.ha=this.Ha=this.V=!1;this.R=0;this.Ug=null;this.L=0}", "title": "" }, { "docid": "66166a7f9c5263e3ea41df050390ddb0", "score": "0.4615856", "text": "function zu(t, e, n, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var i, o, u, s, a, c;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(h) {\n switch (h.label) {\n case 0:\n // PORTING NOTE: On Web only, we inject the code that registers new Limbo\n // targets based on view changes. This allows us to only depend on Limbo\n // changes when user code includes queries.\n return t.$l = function(e, n, r) {\n return function(t, e, n, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var i, o, u;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(s) {\n switch (s.label) {\n case 0:\n return i = e.view.fl(n), i.lc ? [ 4 /*yield*/ , ho(t.bh, e.query, \n /* usePreviousResults= */ !1).then((function(t) {\n var n = t.documents;\n return e.view.fl(n, i);\n })) ] : [ 3 /*break*/ , 2 ];\n\n case 1:\n // The query has a limit and some docs were removed, so we need\n // to re-run the query against the local store to make sure we\n // didn't lose any good docs that had been past the limit.\n i = s.sent(), s.label = 2;\n\n case 2:\n return o = r && r.Fe.get(e.targetId), u = e.view.wi(i, \n /* updateLimboDocuments= */ t.Ll, o), [ 2 /*return*/ , (es(t, e.targetId, u.Il), \n u.snapshot) ];\n }\n }));\n }));\n }(t, e, n, r);\n }, [ 4 /*yield*/ , ho(t.bh, e, \n /* usePreviousResults= */ !0) ];\n\n case 1:\n return i = h.sent(), o = new Uu(e, i.Rc), u = o.fl(i.documents), s = Tn.$e(n, r && \"Offline\" /* Offline */ !== t.onlineState), \n a = o.wi(u, \n /* updateLimboDocuments= */ t.Ll, s), es(t, n, a.Il), c = new Mu(e, n, o), [ 2 /*return*/ , (t.vl.set(e, c), \n t.Sl.has(n) ? t.Sl.get(n).push(e) : t.Sl.set(n, [ e ]), a.snapshot) ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "98ee5b0c7b00ced161c5711bd9253ae9", "score": "0.4613909", "text": "function subscribe( topic, func ) {\n if (!topics[topic]) {\n topics[topic] = [];\n }\n topics[topic].push({\n func: func\n });\n }", "title": "" }, { "docid": "0f9557755bf1bcc12447696ea0a9e38b", "score": "0.46112287", "text": "function ss(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var n, r, i;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(o) {\n switch (o.label) {\n case 0:\n return [ 4 /*yield*/ , ho((n = O(t)).bh, e.query, \n /* usePreviousResults= */ !0) ];\n\n case 1:\n return r = o.sent(), i = e.view.Al(r), [ 2 /*return*/ , (n.Ll && es(n, e.targetId, i.Il), \n i) ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "3d45bf85fc46ce18e3fac35c47439e1d", "score": "0.46037978", "text": "function reduce(parent$, fn, startValue) {\n\t\tvar aggregate = startValue;\n\t\tvar newStream = stream();\n\t\tfunction reduceValue(value) {\n\t\t\taggregate = fn(aggregate, parent$.value);\n\t\t\tnewStream(aggregate);\n\t\t}\n\t\tif (parent$.value !== undefined) {\n\t\t\treduceValue(parent$.value);\n\t\t}\n\t\tparent$.listeners.push(reduceValue);\n\t\treturn newStream;\n\t}", "title": "" }, { "docid": "dc2a19900ccaf9653be0e9a382604a22", "score": "0.45973867", "text": "function uo(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var n, r, i, o;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(u) {\n switch (u.label) {\n case 0:\n return n = x(t), r = n.Ho, i = n.Ic, [ 4 /*yield*/ , n.persistence.runTransaction(\"Handle user change\", \"readonly\", (function(t) {\n // Swap out the mutation queue, grabbing the pending mutation batches\n // before and after.\n var o;\n return n.Ho.bi(t).next((function(u) {\n return o = u, r = n.persistence.Ko(e), \n // Recreate our LocalDocumentsView using the new\n // MutationQueue.\n i = new eo(n.Tc, r, n.persistence.Wo()), r.bi(t);\n })).next((function(e) {\n for (var n = [], r = [], u = _n(), s = 0, a = o\n // Union the old/new changed keys.\n ; s < a.length; s++) {\n var c = a[s];\n n.push(c.batchId);\n for (var f = 0, h = c.mutations; f < h.length; f++) {\n var l = h[f];\n u = u.add(l.key);\n }\n }\n for (var p = 0, d = e; p < d.length; p++) {\n var v = d[p];\n r.push(v.batchId);\n for (var y = 0, m = v.mutations; y < m.length; y++) {\n var g = m[y];\n u = u.add(g.key);\n }\n }\n // Return the set of all (potentially) changed documents and the list\n // of mutation batch IDs that were affected by change.\n return i.Zo(t, u).next((function(t) {\n return {\n mc: t,\n Ac: n,\n Rc: r\n };\n }));\n }));\n })) ];\n\n case 1:\n return o = u.sent(), [ 2 /*return*/ , (n.Ho = r, n.Ic = i, n.fc.ac(n.Ic), o) ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "259262539b30a8200312d0fcfbb5bb41", "score": "0.45959103", "text": "function Wu(t, e, n) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var r, i, o, u;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(s) {\n switch (s.label) {\n case 0:\n r = _s(t), s.label = 1;\n\n case 1:\n return s.trys.push([ 1, 5, , 6 ]), [ 4 /*yield*/ , function(t, e) {\n var n, r = x(t), i = $.now(), o = e.reduce((function(t, e) {\n return t.add(e.key);\n }), _n());\n return r.persistence.runTransaction(\"Locally write mutations\", \"readwrite\", (function(t) {\n return r.Ic.Zo(t, o).next((function(o) {\n n = o;\n for (\n // For non-idempotent mutations (such as `FieldValue.increment()`),\n // we record the base state in a separate patch mutation. This is\n // later used to guarantee consistent values and prevents flicker\n // even if the backend sends us an update that already includes our\n // transform.\n var u = [], s = 0, a = e; s < a.length; s++) {\n var c = a[s], f = Ke(c, n.get(c.key));\n null != f && \n // NOTE: The base state should only be applied if there's some\n // existing document to override, so use a Precondition of\n // exists=true\n u.push(new Qe(c.key, f, Ct(f.proto.mapValue), Fe.exists(!0)));\n }\n return r.Ho.Pi(t, i, u, e);\n }));\n })).then((function(t) {\n var e = t.Ns(n);\n return {\n batchId: t.batchId,\n oi: e\n };\n }));\n }(r.Sh, e) ];\n\n case 2:\n return i = s.sent(), r.pl.xa(i.batchId), function(t, e, n) {\n var r = t.Ol[t.currentUser.R()];\n r || (r = new an(P)), r = r.Ht(e, n), t.Ol[t.currentUser.R()] = r;\n }(r, i.batchId, n), [ 4 /*yield*/ , as(r, i.oi) ];\n\n case 3:\n return s.sent(), [ 4 /*yield*/ , mu(r.gl) ];\n\n case 4:\n return s.sent(), [ 3 /*break*/ , 6 ];\n\n case 5:\n return o = s.sent(), u = Sr(o, \"Failed to persist write\"), n.reject(u), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "323e03bb226eb313407760276ac4d07a", "score": "0.45955652", "text": "function subscribe(){\n\n\tvar args = [].slice.call(arguments);\n\tvar next = args.pop();\n\tvar filter = {\"interaction.interaction.tags\":new RegExp( query, 'i')};\n\n\n\n\t// connect to MongoDB\n\trequire('mongodb').MongoClient.connect('mongodb://'+mongo_server_url+'/'+mongo_db, function(err, db){\n\n\t\t\t// make sure you have created capped collection \"messages\" on db \"test\"\n\t\t\tconsole.log(\"going for colletcion\")\n\t\t\tdb.collection(mongo_collection, function(err, coll) {\n\n\t\t\t\t// seek to latest object\n\t\t\t\tvar seekCursor = coll.find(filter).sort({$natural: -1}).limit(1);\n\t\t\t\tseekCursor.nextObject(function(err, latest) {\n\t\t\t\t\tif (latest) {\n\t\t\t\t\tfilter._id = { $gt: latest._id }\n\t\t\t\t\t}\n\n\t\t\t\t\t// set MongoDB cursor options\n\t\t\t\t\tvar cursorOptions = {\n\t\t\t\t\t\ttailable: true,\n\t\t\t\t\t\tawaitdata: true,\n\t\t\t\t\t\tnumberOfRetries: -1\n\t\t\t\t\t\t};\n\n\t\t\t\t// create stream and listen\n\t\t\t\tstream = coll.find(filter, cursorOptions).sort({$natural: -1}).stream();\n\t\t\t\tconsole.log(\"QUERY \" +query)\n\t\t\t\tconsole.log(\"some data found\"+stream)\n\t\t\t\t// call the callback\n\t\t\t\tstream.on('data', next);\n\t\t\t\t});\n\t\t\t});\n\n\t});\n\n}", "title": "" }, { "docid": "61265d554c737edbbad58a7e592076d5", "score": "0.45898816", "text": "function Sink() {}", "title": "" }, { "docid": "11b6abd73d2db2d3d33b7b3b66ce9a3a", "score": "0.4588566", "text": "function Ts(){}", "title": "" }, { "docid": "b836b0f40b0b16e46613114f6e6a15c9", "score": "0.45880044", "text": "async function transcribe(buffer) {\n\tvosk._rec_.acceptWaveform(buffer);\n\tconst ret = vosk._rec_.result().text;\n\tconsole.log('vosk:', ret);\n\treturn ret;\n}", "title": "" }, { "docid": "896815ba2d3f42e525acf8e800c518f9", "score": "0.45852703", "text": "function Fs(t, e) {\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__awaiter)(this, void 0, void 0, (function() {\n var n, i;\n return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__generator)(this, (function(r) {\n switch (r.label) {\n case 0:\n n = F(t), r.label = 1;\n\n case 1:\n return r.trys.push([ 1, 4, , 6 ]), [ 4 /*yield*/ , Qi(n.localStore, e) ];\n\n case 2:\n return i = r.sent(), \n // Update `receivedDocument` as appropriate for any limbo targets.\n e.targetChanges.forEach((function(t, e) {\n var r = n.Co.get(e);\n r && (\n // Since this is a limbo resolution lookup, it's for a single document\n // and it could be added, modified, or removed, but not a combination.\n P(t.addedDocuments.size + t.modifiedDocuments.size + t.removedDocuments.size <= 1), \n t.addedDocuments.size > 0 ? r.bo = !0 : t.modifiedDocuments.size > 0 ? P(r.bo) : t.removedDocuments.size > 0 && (P(r.bo), \n r.bo = !1));\n })), [ 4 /*yield*/ , Ys(n, i, e) ];\n\n case 3:\n // Update `receivedDocument` as appropriate for any limbo targets.\n return r.sent(), [ 3 /*break*/ , 6 ];\n\n case 4:\n return [ 4 /*yield*/ , pi(r.sent()) ];\n\n case 5:\n return r.sent(), [ 3 /*break*/ , 6 ];\n\n case 6:\n return [ 2 /*return*/ ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "e7dc58cea8fa1b6e8c44616aece6a4b1", "score": "0.45848888", "text": "function Hu(t, e, n, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var i, o, u, s, a, c;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(f) {\n switch (f.label) {\n case 0:\n // PORTING NOTE: On Web only, we inject the code that registers new Limbo\n // targets based on view changes. This allows us to only depend on Limbo\n // changes when user code includes queries.\n return t.Bl = function(e, n, r) {\n return function(t, e, n, r) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __awaiter */ \"b\"])(this, void 0, void 0, (function() {\n var i, o, u;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[/* __generator */ \"d\"])(this, (function(s) {\n switch (s.label) {\n case 0:\n return i = e.view.dl(n), i._c ? [ 4 /*yield*/ , vo(t.Sh, e.query, \n /* usePreviousResults= */ !1).then((function(t) {\n var n = t.documents;\n return e.view.dl(n, i);\n })) ] : [ 3 /*break*/ , 2 ];\n\n case 1:\n // The query has a limit and some docs were removed, so we need\n // to re-run the query against the local store to make sure we\n // didn't lose any good docs that had been past the limit.\n i = s.sent(), s.label = 2;\n\n case 2:\n return o = r && r.Oe.get(e.targetId), u = e.view.Ei(i, \n /* updateLimboDocuments= */ t.$l, o), [ 2 /*return*/ , (os(t, e.targetId, u.ml), \n u.snapshot) ];\n }\n }));\n }));\n }(t, e, n, r);\n }, [ 4 /*yield*/ , vo(t.Sh, e, \n /* usePreviousResults= */ !0) ];\n\n case 1:\n return i = f.sent(), o = new ju(e, i.Pc), u = o.dl(i.documents), s = Dn.Be(n, r && \"Offline\" /* Offline */ !== t.onlineState), \n a = o.Ei(u, \n /* updateLimboDocuments= */ t.$l, s), os(t, n, a.ml), c = new zu(e, n, o), [ 2 /*return*/ , (t.Sl.set(e, c), \n t.Dl.has(n) ? t.Dl.get(n).push(e) : t.Dl.set(n, [ e ]), a.snapshot) ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "2496ce1d0ae6b3a57c72244d72569e2f", "score": "0.45821005", "text": "_emit(subject, predicate, object, graph) {\n this._callback(null, this._quad(subject, predicate, object, graph || this.DEFAULTGRAPH));\n }", "title": "" }, { "docid": "2496ce1d0ae6b3a57c72244d72569e2f", "score": "0.45821005", "text": "_emit(subject, predicate, object, graph) {\n this._callback(null, this._quad(subject, predicate, object, graph || this.DEFAULTGRAPH));\n }", "title": "" }, { "docid": "2496ce1d0ae6b3a57c72244d72569e2f", "score": "0.45821005", "text": "_emit(subject, predicate, object, graph) {\n this._callback(null, this._quad(subject, predicate, object, graph || this.DEFAULTGRAPH));\n }", "title": "" }, { "docid": "9855ef3f450213ca4070d70db37d451c", "score": "0.45819885", "text": "summarize() {}", "title": "" }, { "docid": "c9af6077fc56f1079930093066ee1d82", "score": "0.4558714", "text": "function reduce(accumulator, currentValue){\n return accumulator + currentValue;\n }", "title": "" }, { "docid": "a61da495b241a12b8bd9631967190b8f", "score": "0.45581764", "text": "getData() {\n this.authService.getAllInvoices().subscribe((clients) => {\n Object(rxjs__WEBPACK_IMPORTED_MODULE_2__[\"of\"])(clients.map(client => new src_app_models_invoice_model__WEBPACK_IMPORTED_MODULE_25__[\"Invoice\"](client))).subscribe(clientes => {\n console.log('123213123');\n console.log(clientes);\n this.subject$.next(clientes);\n });\n });\n }", "title": "" }, { "docid": "51195183bd85cde33479b2f6694af17b", "score": "0.4557914", "text": "function Fu(t, e) {\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__awaiter\"])(this, void 0, void 0, (function() {\n var n, r, i, o, u, s;\n return Object(tslib__WEBPACK_IMPORTED_MODULE_3__[\"__generator\"])(this, (function(a) {\n switch (a.label) {\n case 0:\n return n = ys(t), (o = n.vl.get(e)) ? (\n // PORTING NOTE: With Multi-Tab Web, it is possible that a query view\n // already exists when EventManager calls us for the first time. This\n // happens when the primary tab is already listening to this query on\n // behalf of another tab and the user of the primary also starts listening\n // to the query. EventManager will not have an assigned target ID in this\n // case and calls `listen` to obtain this ID.\n r = o.targetId, n.Vl.Oa(r), i = o.view.Rl(), [ 3 /*break*/ , 4 ]) : [ 3 /*break*/ , 1 ];\n\n case 1:\n return [ 4 /*yield*/ , ao(n.bh, he(e)) ];\n\n case 2:\n return u = a.sent(), s = n.Vl.Oa(u.targetId), r = u.targetId, [ 4 /*yield*/ , zu(n, e, r, \"current\" === s) ];\n\n case 3:\n i = a.sent(), n.Ll && tu(n.yl, u), a.label = 4;\n\n case 4:\n return [ 2 /*return*/ , i ];\n }\n }));\n }));\n}", "title": "" }, { "docid": "dd35439c56021024df9e0d9e3c522e6a", "score": "0.45572868", "text": "function subscribe(partitionName, listener, arrKeys, listenerName) {\n if (typeof listener !== 'function') {\n (0, _util.error)('subscribe listener argument is not a function.');\n }\n if (!Array.isArray(arrKeys)) {\n arrKeys = [arrKeys];\n }\n if (_store !== null) {\n if (_typeof(_store[partitionName]) === undefinedString) {\n (0, _util.error)(partitionName + ' is an invalid partition.');\n }\n _store[partitionName].subscribe(listener, arrKeys, listenerName);\n } else {\n _subscribers.push({ partitionName: partitionName, listener: listener, arrKeys: arrKeys, listenerName: listenerName });\n }\n}", "title": "" }, { "docid": "bb6a54e253526348a0e11dca19801471", "score": "0.45547336", "text": "subscribeRaw(customTopic, callback) {\r\n\t return this.internalSubscribe(customTopic, false, callback);\r\n\t }", "title": "" }, { "docid": "2140a703aa5625f763b946424b653aea", "score": "0.45527598", "text": "function _letSubscribersKnow() {\n callbacks.forEach(cb => cb())\n}", "title": "" }, { "docid": "7a1babc9932d2100b015ab4b240940e7", "score": "0.45496857", "text": "function reduce(item) {\n const source = item._source;\n const { event } = source;\n\n // Additional event verbatim fields\n const eventVerbatim = removeUndefined({\n eventRemarks: source.verbatim.core['http://rs.tdwg.org/dwc/terms/eventRemarks']\n });\n\n // Handle seedbank extension\n let seedbankRecord;\n const seedbankExtension = source.verbatim.extensions?.['http://ala.org.au/terms/seedbank/0.1/SeedbankRecord'];\n\n // Ensure the seed bank extension exists before mapping the verbatim values\n if (seedbankExtension) {\n const [seedbankVerbatim] = seedbankExtension;\n seedbankRecord = removeUndefined({\n id: event.seedbankRecord?.id,\n eventID: seedbankVerbatim['http://rs.tdwg.org/dwc/terms/eventID'],\n degreeOfEstablishment: seedbankVerbatim['http://rs.tdwg.org/dwc/terms/degreeOfEstablishment'],\n accessionNumber: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/accessionNumber'],\n seedPerGram: event.seedbankRecord?.seedPerGram,\n formInStorage: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/formInStorage'],\n quantityInGrams: event.seedbankRecord?.quantityInGrams,\n quantityCount: event.seedbankRecord?.quantityCount,\n purityPercentage: event.seedbankRecord?.purityPercentage,\n dateCollected: event.seedbankRecord?.dateCollected,\n dateInStorage: event.seedbankRecord?.dateInStorage,\n storageTemperatureInCelsius: event.seedbankRecord?.storageTemperatureInCelsius,\n storageRelativeHumidityPercentage: event.seedbankRecord?.storageRelativeHumidityPercentage,\n publicationDOI: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/publicationDOI'],\n preStorageTreatment: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/preStorageTreatment'],\n primaryStorageSeedBank: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/primaryStorageSeedBank'],\n primaryCollector: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/primaryCollector'],\n plantForm: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/plantForm'],\n duplicatesReplicates: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/duplicatesReplicates'],\n collectionPermitNumber: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/collectionPermitNumber'],\n thousandSeedWeight: event.seedbankRecord?.thousandSeedWeight,\n numberPlantsSampled: event.seedbankRecord?.numberPlantsSampled,\n storageBehaviour: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/storageBehaviour'],\n esRatio: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/esRatio'],\n dormancyClass: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/dormancyClass'],\n testDateStarted: event.seedbankRecord?.testDateStarted,\n testLengthInDays: event.seedbankRecord?.testLengthInDays,\n collectionFill: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/collectionFill'],\n numberGerminated: event.seedbankRecord?.numberGerminated,\n germinationRateInDays: event.seedbankRecord?.germinationRateInDays,\n adjustedGerminationPercentage: event.seedbankRecord?.adjustedGerminationPercentage,\n viabilityPercentage: event.seedbankRecord?.viabilityPercentage,\n numberFull: event.seedbankRecord?.numberFull,\n numberEmpty: event.seedbankRecord?.numberEmpty,\n numberTested: event.seedbankRecord?.numberTested,\n numberNotViable: event.seedbankRecord?.numberNotViable,\n preTestProcessingNotes: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/preTestProcessingNotes'],\n pretreatment: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/pretreatment'],\n mediaSubstrate: seedbankVerbatim['http://ala.org.au/terms/seedbank/0.1/mediaSubstrate'],\n nightTemperatureInCelsius: event.seedbankRecord?.nightTemperatureInCelsius,\n dayTemperatureInCelsius: event.seedbankRecord?.dayTemperatureInCelsius,\n darkHours: event.seedbankRecord?.darkHours,\n lightHours: event.seedbankRecord?.lightHours,\n }); \n }\n\n return removeUndefined({\n ...source.event,\n ...source.metadata,\n ...source.derivedMetadata,\n ...eventVerbatim,\n seedbankRecord\n });\n}", "title": "" } ]
eb5a3611810588dbd54c011eecd2e7f1
Given a surface to render to this function renders the map and the best path if relevant. mapWidth/mapHeight are the dimensions of the client window.
[ { "docid": "cc554181d16896c528645eeddedbb801", "score": "0.5496653", "text": "render(mapWidth, mapHeight) {\r\n this.canvas.clearRect(0, 0, mapWidth, mapHeight);\r\n\t\t// Render the map.\r\n\t\tthis.bobMap.render(mapWidth, mapHeight, this.canvas);\r\n\t\t// Render the best route.\r\n\t\tthis.bobBrain.memoryRender(mapWidth, mapHeight, this.canvas);\r\n // Render additional information.\r\n this.canvas.fillStyle = \"#000\";\r\n\t\tthis.canvas.fillText(\"Generation: \" + (this.generation), 5, 15);// generation minus 1?\r\n\t\tif (!this.busy) {\r\n\t\t\tthis.canvas.fillText(this.START, mapWidth / 2 - (this.START.length * 3), mapHeight - 5);\r\n\t\t\tthis.bobMap.drawGates(mapWidth, mapHeight, this.canvas);\r\n\t\t} else {\r\n\t\t\tthis.canvas.fillText(this.STOP, mapWidth / 2 - (this.START.length * 3), mapHeight - 5);\r\n\t\t}\r\n }", "title": "" } ]
[ { "docid": "4bb06bd3b42bf16d4a6c697db8c0d695", "score": "0.6380314", "text": "function renderMap() {\n var halfWidth, halfHeight;\n //if (isIP(document.location.hash.substr(1).split(',')[0])) {\n setHash(self.options.ip);\n //}\n self.$tiles.css({\n left: self.mapCenter[0] - self.xy[0] + 'px',\n top: self.mapCenter[1] - self.xy[1] + 'px'\n });\n self.widthTiles = Math.floor(\n window.innerWidth / self.tileSize / 2\n ) * 2 + 3;\n self.heightTiles = Math.floor(\n window.innerHeight / self.tileSize / 2\n ) * 2 + 3;\n halfWidth = self.widthTiles / 2,\n halfHeight = self.heightTiles / 2;\n Ox.loop(-Math.floor(halfHeight), Math.ceil(halfHeight), function(dy) {\n Ox.loop(-Math.floor(halfWidth), Math.ceil(halfWidth), function(dx) {\n var xy = [\n self.xy[0] + dx * self.tileSize,\n self.xy[1] + dy * self.tileSize\n ];\n if (\n xy[0] >= 0 && xy[0] < self.mapSize\n && xy[1] >= 0 && xy[1] < self.mapSize\n ) {\n renderTile(getIPByXY(xy));\n }\n });\n });\n updateWorld();\n $('.OxTooltip').remove();\n }", "title": "" }, { "docid": "53b39052fa6aa74cb6e5ed53d0bcfeda", "score": "0.6225209", "text": "function prerenderMapImage() {\n mapImage = document.createElement('canvas');\n mapImage.width = MAP_IMAGE_SIZE;\n mapImage.height = MAP_IMAGE_SIZE;\n\n const mapCtx = mapImage.getContext('2d');\n\n // Start with blue water\n mapCtx.fillStyle = '#163849';\n mapCtx.fillRect(0, 0, MAP_IMAGE_SIZE, MAP_IMAGE_SIZE);\n\n let minHeight = 10000;\n let maxHeight = 0;\n\n for (let z = PLAYABLE_MIN_Z; z < PLAYABLE_MAX_Z; z += TILE_SIZE) {\n for (let x = PLAYABLE_MIN_X; x < PLAYABLE_MAX_X; x += TILE_SIZE) {\n let height = gameMap.getY(x, z);\n if (height > 0) {\n minHeight = Math.min(minHeight, height);\n maxHeight = Math.max(maxHeight, height);\n }\n }\n }\n\n for (let z = PLAYABLE_MIN_Z; z < PLAYABLE_MAX_Z; z += TILE_SIZE) {\n for (let x = PLAYABLE_MIN_X; x < PLAYABLE_MAX_X; x += TILE_SIZE) {\n const y1 = gameMap.getY(x, z);\n const y2 = gameMap.getY(x + TILE_SIZE, z);\n const y3 = gameMap.getY(x + TILE_SIZE, z + TILE_SIZE);\n const y4 = gameMap.getY(x, z + TILE_SIZE);\n const ya = (y1 + y2 + y3 + y4) / 4;\n if (ya <= 0) {\n continue;\n }\n\n const dx1 = convertXToMapX(x);\n const dy1 = convertZToMapY(z);\n const dx2 = convertXToMapX(x + TILE_SIZE);\n const dy2 = convertZToMapY(z + TILE_SIZE);\n\n const v = Math.min(1.0, 0.4 + 0.7 * (ya - minHeight) / (maxHeight - minHeight));\n mapCtx.fillStyle = HSVtoRGB(110.0 / 360.0, 0.4, v);\n mapCtx.beginPath();\n mapCtx.rect(dx1, dy1, dx2 - dx1, dy2 - dy1);\n mapCtx.fill();\n }\n }\n}", "title": "" }, { "docid": "0746ab33d19b957ef97456d719817e33", "score": "0.61544657", "text": "drawMap() {\n const { x, y } = this.player;\n\n this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n const {\n tileset, size, viewport, objects,\n } = this.config.map;\n\n const divider = {\n background: tileset.width / tileset.tile.width,\n foreground: objects.width / tileset.tile.width,\n };\n\n const tileCrop = {\n x: x - Math.floor(0.5 * viewport.x),\n y: y - Math.floor(0.5 * viewport.y),\n };\n\n // Drawing the map row by column.\n for (let column = 0; column <= viewport.y; column += 1) {\n for (let row = 0; row <= viewport.x; row += 1) {\n const tileToFind = (((column + tileCrop.y) * size.x) + row) + tileCrop.x;\n const backgroundTile = this.background[tileToFind] - 1;\n const foregroundTile = (this.foreground[tileToFind] - 1) - 252;\n\n // Get the correct tile to draw\n const tile = {\n clip: {\n background: {\n x: Math.floor(backgroundTile % divider.background) * tileset.tile.width,\n y: Math.floor(backgroundTile / divider.background) * tileset.tile.height,\n },\n foreground: {\n x: Math.floor(foregroundTile % divider.foreground) * tileset.tile.width,\n y: Math.floor(foregroundTile / divider.foreground) * tileset.tile.height,\n },\n },\n pos: {\n x: row * tileset.tile.width,\n y: column * tileset.tile.height,\n },\n width: tileset.tile.width,\n height: tileset.tile.height,\n };\n\n // Draw the background (terrain)\n this.context.drawImage(\n this.images.terrainImage, // The Image() instance\n tile.clip.background.x, // Coordinate to clip the X-axis\n tile.clip.background.y, // Coordinate to clip the Y-axis\n tile.width, // How wide, in pixels, to clip the sub-rectangle\n tile.height, // How tall, in pixels, to clip the sub-rectangle\n tile.pos.x, // Position the clipped picture along the X-axis\n tile.pos.y, // Position the clipped picture along the Y-axis\n tile.width, // The width, in pixels, to draw the image\n tile.height, // The height, in pixels, to draw the image\n );\n\n // Draw the foreground (objects)\n if (foregroundTile > -1) {\n this.context.drawImage(\n this.images.objectImage, // The Image() instance\n tile.clip.foreground.x,\n tile.clip.foreground.y,\n tile.width,\n tile.height,\n tile.pos.x,\n tile.pos.y,\n tile.width,\n tile.height,\n );\n }\n }\n }\n }", "title": "" }, { "docid": "c6986339ae0b3f9b46ba9b25c41edd5a", "score": "0.6146136", "text": "function renderMap() {\n\n function getPos(el) {\n // yay readability\n for (var lx=0, ly=0;\n el != null;\n lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent);\n return {x: lx,y: ly};\n }\n\n function createDrawingCanvas() {\n canvas = document.createElement(\"canvas\");\n canvas.id = this.imageId + \"canvas\";\n console.log(\"Created a canvas with id: \" + canvas.id);\n canvas.style.position = \"absolute\";\n\n var checkTime = 100; //100 ms interval\n var check = setInterval(function() {\n if (image.offsetWidth === 0) // The image is hidden, so don't bother rendering a canvas.\n {\n canvas.style.left = \"-1px\";\n canvas.style.top = \"-1px\";\n canvas.width = \"0px\";\n canvas.height = \"0px\";\n \n } else \n { \n var position = getPos(image);\n if (canvas.style.left !== position.x+\"px\" || canvas.style.top !== position.y+\"px\")\n {\n canvas.style.left = position.x + \"px\";\n canvas.style.top = position.y + \"px\";\n canvas.width = image.width;\n canvas.height = image.height;\n renderMap.call(canvas.imageMapAug);\n }\n }\n\n }, checkTime);\n canvas.zIndex = 2000;\n canvas.imageMapAug = this;\n }\n\n var imageId = this.imageId;\n var mapId = this.mapId;\n\n var image = document.getElementById(imageId);\n if (image === null) throw \"Image with id \" + imageId + \" not found.\";\n var canvas = document.getElementById(imageId + \"canvas\");\n if (canvas === null) {\n createDrawingCanvas.call(this);\n canvas.onclick = clickOnImage;\n document.body.appendChild(canvas);\n }\n var ctx = canvas.getContext(\"2d\");\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n var map = document.getElementById(this.mapId);\n if (map === null) {\n throw \"Found no map elements with id \" + mapId;\n }\n var childNodes = Array.from(map.childNodes);\n var fillColor = this.fillColor;\n childNodes.forEach(function (child) {\n if (child.nodeType !== Node.TEXT_NODE && child.nodeType !== Node.COMMENT_NODE) {\n if (child.getAttribute(toggleAttribute) == 1) {\n draw(ctx, child.getAttribute(\"coords\").split(\",\"), fillColor);\n }\n }\n });\n\n }", "title": "" }, { "docid": "21748fe713dc15fc7e23106e48df74c7", "score": "0.60915375", "text": "function render_Surface(density_map) {\n \n push();\n \n stroke(43, 74, 83);\n strokeWeight(2);\n noFill();\n \n for(let x = 0; x < width / square_size; x ++) {\n for(let y = 0; y < height / square_size; y ++) {\n \n // grab the 4 corners of the square and determin whether they're in our out of the surface\n let tl = density_map[x ][y ] >= surface_threshold;\n let tr = density_map[x+1][y ] >= surface_threshold;\n let bl = density_map[x ][y+1] >= surface_threshold;\n let br = density_map[x+1][y+1] >= surface_threshold;\n \n // convert the 4 bools into a single binary string\n let binary_rep = tl ? '0' : '1';\n binary_rep += tr ? '0' : '1';\n binary_rep += br ? '0' : '1';\n binary_rep += bl ? '0' : '1';\n \n // conver the binary representation into an index\n let index = parseInt(binary_rep, 2);\n \n // look up the rules for this index in the squares.js file\n let connections = index_to_square[index];\n \n // draw the given connections\n push();\n \n if (connections) {\n let prev_absX = -1;\n let prev_absY = -1;\n for(let i = 0; i < connections.length; i += 4) {\n \n let p1_x = connections[i];\n let p1_y = connections[i+1];\n let p2_x = connections[i+2];\n let p2_y = connections[i+3];\n \n let d1 = density_map[p1_x][p1_y];\n let d2 = density_map[p2_x][p2_y];\n \n p1_x *= square_size;\n p1_y *= square_size;\n p2_x *= square_size;\n p2_y *= square_size;\n \n p1_x += x * square_size;\n p1_y += y * square_size;\n p2_x += x * square_size;\n p2_y += y * square_size;\n \n // let t = (surface_threshold - d1) / (d2 - d1);\n \n // let absX = p1_x + t * (p2_x - p1_x);\n // let absY = p1_y + t * (p2_y - p1_y);\n \n let absX = lerp(p1_x, p2_x, 0.5);\n let absY = lerp(p1_y, p2_y, 0.5);\n \n if (prev_absX != -1) {\n \n line(absX, absY, prev_absX, prev_absY);\n prev_absX = -1;\n \n } else {\n prev_absX = absX;\n prev_absY = absY;\n }\n\n }\n }\n \n pop();\n \n }\n \n }\n \n pop();\n \n}", "title": "" }, { "docid": "4aa27b052adfbe587d6f5246da7959b0", "score": "0.6056894", "text": "function render() {\n\tvar containerWidth = $('#interactive-content').width();\n\n if (!containerWidth) {\n containerWidth = DEFAULT_WIDTH;\n }\n\n if (containerWidth <= MOBILE_BREAKPOINT) {\n isMobile = true;\n } else {\n isMobile = false;\n }\n\n // What kind of map are we making?\n var configuration = configure(containerWidth);\n\n // Render the map!\n renderMap(configuration, {\n container: '#graphic',\n width: containerWidth,\n data: topoData\n });\n\n // Resize\n fm.resize();\n}", "title": "" }, { "docid": "16e68aa6c46a7f9405ee287ebbd3e68f", "score": "0.5859841", "text": "function renderMap(map){\n\tfor (var r = 0; r <= map.tiles.length; r++) {\n if (map.tiles[r] !== undefined) {\n for (var b = 0; b <= map.tiles[r].length; b++) {\n if (map.tiles[r][b] !== undefined) {\n map.tiles[r][b].image.x = r * map.tileSize;\n map.tiles[r][b].image.y = b * map.tileSize;\n map.container.addChild(map.tiles[r][b].image);\n }\n }\n }\n }\n}", "title": "" }, { "docid": "554b7ac59d8d85ddc912f25674e30cbf", "score": "0.5782854", "text": "function renderMap(options) {\r\n\tvar start = new Date().getTime();\r\n\toptions = options || {};\r\n\r\n\t// New re-centering crap\r\n\tif (center.movedX !== 0 || center.movedY !== 0) {\r\n\t\t// Apply translation to wx/wy\r\n\t\tcenter.wx -= center.movedX;\r\n\t\tcenter.wy += center.movedY;\r\n\t\t// convert wxy to wm\r\n\t\tvar newWm = wxyToWm(center.wx, center.wy);\r\n\t\tcenter.wmx = newWm.x;\r\n\t\tcenter.wmy = newWm.y;\r\n\t\t// convert wm to lat/lon\r\n\t\tvar newLatlon = wmToWgs(center.wmx, center.wmy);\r\n\t\tcenter.lat = newLatlon.lat;\r\n\t\tcenter.lon = newLatlon.lon;\r\n\t\t// Reset moved values\r\n\t\tcenter.movedX = 0;\r\n\t\tcenter.movedY = 0;\r\n\t\tcenterLayersOnViewport();\r\n\t}\r\n\r\n\toffset = findXyOffset(center);\r\n\tsyo = mapElement.clientHeight - offset.y;\r\n\tctx.clearRect(0, 0, canvas.width, canvas.height);\r\n\tsetBounds();\r\n\tsetVisibleStates();\r\n\t//visibleStates.forEach(function(vs) { renderPriSec(vs); });\r\n\trenderStates();\r\n\trenderCities();\r\n\t//renderShapefile(usTest, { 'filterFeature': primaryRoadsFilter });\r\n\talignTerrainWithLayerContainer();\r\n\tconsole.log('render time: ' + (new Date().getTime() - start) + 'ms')\r\n}", "title": "" }, { "docid": "7427126da9227bf0af7c23d8327f4286", "score": "0.5733828", "text": "function mapRender(layer) {\n if (tilesReady) {\n\n //camera extent parameters\n let startCol = Math.floor(camera.x / map.tileSize);\n let endCol = startCol + (camera.width/map.tileSize);\n if (endCol >= map.cols) {\n endCol = 31;\n }\n if (startCol <= 0) {\n startCol = 0;\n }\n let startRow = Math.floor(camera.y/map.tileSize);\n let endRow = startRow + (camera.height/map.tileSize);\n let offsetX = -camera.x + startCol * map.tileSize;\n let offsetY = -camera.y + startRow * map.tileSize;\n\n //iterate through and draw the map tiles\n for (let c = startCol; c <= endCol; c++) {\n for (let r = startRow; r <= endRow; r++) {\n let tile = map.getTile(layer,c,r);\n\n //get tile in Image\n let imgRow = Math.floor(tile / 32); //source y\n let imgPos = tile % 32; //source x\n let x = (c - startCol) * map.tileSize + offsetX;\n let y = (r - startRow) * map.tileSize + offsetY;\n if (tile !== 0) {\n ctx.drawImage(\n tileImg, //Image\n (imgPos -1) * map.tileSize, //source x\n imgRow * map.tileSize, //source y\n map.tileSize, //source width\n map.tileSize, //source height\n Math.round(x), //target x\n Math.round(y), //target y\n map.tileSize, //target width\n map.tileSize //target height\n );\n }\n }\n }\n }\n }", "title": "" }, { "docid": "1a18544350742a290bff7dbc3d579a54", "score": "0.57214695", "text": "drawMap() {\n this.ctx.clearRect(0, 0, 750, 600);\n this.ctx.globalAlpha = 0.01;\n this.ctx.lineWidth = 8;\n this.ctx.beginPath();\n this.ctx.strokeStyle = \"#ff0000\";\n this.ctx.fillStyle = \"#ff0000\";\n this.ctx.moveTo(130, 30);\n this.ctx.lineTo(330, 30);\n this.ctx.lineTo(330, 190);\n this.ctx.lineTo(220, 190);\n this.ctx.lineTo(220, 435);\n this.ctx.lineTo(250, 435);\n this.ctx.lineTo(250, 500);\n this.ctx.lineTo(250, 435);\n this.ctx.lineTo(310, 435);\n this.ctx.moveTo(350, 435);\n this.ctx.lineTo(420, 435);\n this.ctx.moveTo(460, 435);\n this.ctx.lineTo(525, 435);\n this.ctx.lineTo(525, 195);\n this.ctx.lineTo(475, 195);\n this.ctx.moveTo(440, 195);\n this.ctx.lineTo(420, 195);\n this.ctx.lineTo(420, 30);\n this.ctx.lineTo(625, 30);\n this.ctx.lineTo(625, 190);\n this.ctx.lineTo(550, 190);\n this.ctx.stroke();\n this.ctx.moveTo(550, 182);\n this.ctx.fillRect(575, 185, 15, 130);\n this.ctx.fillRect(555, 185, 170, 15);\n this.ctx.fillRect(710, 197, 10, 230);\n this.ctx.fillRect(720, 430, -160, 10);\n this.ctx.fillRect(595, 430, -18, -95);\n this.ctx.moveTo(635, 425);\n this.ctx.lineTo(635, 585);\n this.ctx.lineTo(465, 585);\n this.ctx.lineTo(465, 475);\n this.ctx.lineTo(440, 475);\n this.ctx.moveTo(415, 475);\n this.ctx.lineTo(370, 475);\n this.ctx.lineTo(370, 585);\n this.ctx.lineTo(455, 585);\n this.ctx.lineTo(250, 585);\n this.ctx.lineTo(250, 515);\n this.ctx.moveTo(245, 585);\n this.ctx.lineTo(110, 585);\n this.ctx.lineTo(110, 425);\n this.ctx.stroke();\n this.ctx.fillRect(35, 435, 145, -15);\n this.ctx.fillRect(35, 435, -15, -225);\n this.ctx.fillRect(160, 415, 20, -80);\n this.ctx.fillRect(22, 205, 110, -20);\n this.ctx.moveTo(135, 200);\n this.ctx.lineTo(160, 200);\n this.ctx.lineTo(160, 240);\n this.ctx.lineTo(180, 200);\n this.ctx.lineTo(180, 190);\n this.ctx.lineTo(130, 190);\n this.ctx.lineTo(130, 30);\n this.ctx.moveTo(415, 190);\n this.ctx.lineTo(415, 260);\n this.ctx.lineTo(340, 260);\n this.ctx.lineTo(340, 190);\n this.ctx.moveTo(220, 425);\n this.ctx.lineTo(210, 425);\n this.ctx.stroke();\n this.ctx.moveTo(510, 189);\n this.ctx.fillRect(510, 189, 15, 230);\n this.ctx.fillRect(510, 196, -30, -10);\n this.ctx.closePath();\n }", "title": "" }, { "docid": "0f82d0ebb99d3bf5b8aeee8b806a0932", "score": "0.570711", "text": "function drawMap() {\n\tdomContext.drawImage(mapCanvas,\n\t 0, 0, mapCanvas.width, mapCanvas.height,\n\t viewport.x, viewport.y, viewport.width, viewport.height);\n}", "title": "" }, { "docid": "0411660e26c0f7d84dad8910c3986bce", "score": "0.5699937", "text": "memoryRender(width, height, canvas) {\r\n\t\tconst border = 20;\r\n\t\tconst blockSizeX = (width - 2 * border) / this.mapWidth;\r\n const blockSizeY = (height - 2 * border) / this.mapHeight;\r\n canvas.fillStyle = \"#00F\";\r\n canvas.strokeStyle = \"#FF0\";\r\n\t\tfor (let y = 0; y < this.mapHeight; y++) {\r\n\t\t\tfor (let x = 0; x < this.mapWidth; x++) {\r\n let dir = 0;\r\n let val = 0;\r\n if (this.memory[y][x] > 0) {\r\n dir = ((this.memory[y][x] - 1) / 10) - 1;\r\n val = 1;\r\n } else {\r\n continue;\r\n }\r\n\t\t\t\t// Calculate the corners of each cell.\r\n\t\t\t\tconst left = border + (blockSizeX * x);\r\n\t\t\t\tconst top = border + (blockSizeY * y);\r\n // Draw a blue path.\r\n \r\n\t\t\t\tif (val == 1) {\r\n canvas.fillRect(left, top, blockSizeY, blockSizeY);\r\n \r\n canvas.beginPath();\r\n\t\t\t\t\tswitch (dir) {\r\n\t\t\t\t\tcase 0:// North\r\n canvas.moveTo(left + blockSizeX / 2, top);\r\n canvas.lineTo(left + blockSizeX, top + blockSizeY);\r\n canvas.lineTo(left, top + blockSizeY);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 1://South\r\n canvas.moveTo(left + blockSizeX / 2, top + blockSizeY);\r\n canvas.lineTo(left + blockSizeX, top);\r\n canvas.lineTo(left, top);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 2:// East\r\n canvas.moveTo(left + blockSizeX, top + blockSizeY / 2);\r\n canvas.lineTo(left, top + blockSizeY);\r\n canvas.lineTo(left, top);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 3:// West\r\n canvas.moveTo(left, top + blockSizeY / 2);\r\n canvas.lineTo(left + blockSizeX, top + blockSizeY);\r\n canvas.lineTo(left + blockSizeX, top);\r\n\t\t\t\t\t\tbreak;\r\n }\r\n canvas.closePath();\r\n canvas.stroke();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n }", "title": "" }, { "docid": "37fa0fbe3cbe2a64ad2c76f4975fde5d", "score": "0.56721526", "text": "function drawMap() {\r\n \r\n // clear map and draw grid\r\n\r\n ctx.clearRect( 0, 0, WIDTH, HEIGHT );\r\n\r\n var currentSquare, w, h, i;\r\n // this loop draws the current map state\r\n for( w = 0; w < HCOUNT; w++ )\r\n {\r\n ctx.save();\r\n ctx.translate( w * SQ, 0 ); // Move the canvas horizontally\r\n for( h = 0; h < VCOUNT; h++ )\r\n {\r\n currentSquare = Map[w][h];\r\n ctx.save();\r\n ctx.translate( 0, h * SQ ); // Move the canvas vertically\r\n if( currentSquare === 2) \r\n {\r\n ctx.fillStyle = object.fill;\r\n ctx.fillRect( 0, 0, SQ, SQ );\r\n \r\n }\r\n else if( typeof currentSquare === 'string' ) \r\n {\r\n ctx.fillStyle = currentSquare;\r\n ctx.fillRect( 0, 0, SQ, SQ );\r\n \r\n }\r\n ctx.restore();\r\n }\r\n ctx.restore();\r\n }\r\n // draws the grid\r\n for( i = 1; i < WIDTH; i++ )\r\n line( i*SQ, 0, i*SQ, HEIGHT );\r\n for( i = 1; i < HEIGHT; i++ )\r\n line( 0, i*SQ, WIDTH, i*SQ );\r\n\r\n}", "title": "" }, { "docid": "250ad56cd9ae8c685f0b88336852e026", "score": "0.5650587", "text": "function draw( toCanvas) {\n\n\t\tif (ready == true) {\n\n\t\t\tvar tilesetID = mapDefaults[_ID].tileset;\n\t\t\tvar tileset = game.maping.Tilesets.get(tilesetID);\n\n\t\t\t// Map z Length\n\t\t\tvar mll = mapData.length;\n\n\t\t\t//TODO Replaces hard limits with min and max boundries\n\t\t\t//Window.game.Boundaries.maxColumn.c\n\t\t\t// draw the lowest layer of tiles then build up\n\t\t\tfor ( var l = 0; l < mll; l++ ) {\n\t\t\t\tif ( typeof mapData[l] == 'object' ) { // check to make sure that there is not a null layer\n\t\t\t\t\t// Map row Length\n\t\t\t\t\tvar mrl = mapData[l].length - 1; // width of world\n\n\t\t\t\t\t//loops x backwards thought the tiles to draw them back to front\n\t\t\t\t\tfor ( var r = mrl; r > 0; r-- ) {\n\t\t\t\t\t\tif ( typeof mapData[l][r] == 'object' ) { // check to make sure that there is not a null layer\n\t\t\t\t\t\t\t//Map y Length\n\t\t\t\t\t\t\tvar mcl = mapData[l][r].length - 1; // dept of the world TODO add null protection\n\n\t\t\t\t\t\t\t//loops y backwards thought the tiles to draw them back to front\n\t\t\t\t\t\t\tfor (var c = mcl; c > 0; c--) {\n\t\t\t\t\t\t\t\tif ( typeof mapData[l][r][c] == 'object' ) { // check to make sure that there is not a null layer\n\t\t\t\t\t\t\t\t\t// get the Tile we are currently working with\n\t\t\t\t\t\t\t\t\tvar map_tile = mapData[l][r][c]; // current map tile\n\n\t\t\t\t\t\t\t\t\tvar cur_tile = tileset.tileData[map_tile.type]; // current tileset tile\n\n\t\t\t\t\t\t\t\t\tvar draw = addOffset(TranslateMatrixToPixel(r, c, cur_tile.width, cur_tile.length), game.core.Offset, game.core.Offset);\n\n\t\t\t\t\t\t\t\t\tdrawImageByCenter(toCanvas, game.resources.getImage(tileset.image), draw.x, draw.y, cur_tile.offsetWidth, cur_tile.offsetLength, cur_tile.width, cur_tile.length);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn true; // Draw as been completed returns true\n\n\t\t} else {\n\n\t\t\treturn false; // Draw was skipped return false\n\n\t\t}\n\t}", "title": "" }, { "docid": "41bb812b7bb4546a82792ce667503745", "score": "0.5639901", "text": "function render_landscape()\n\t{\n\t\tvar terrain_IMG = terrain_canvas.data.create();\n\t\t\n\t\tvar height = {\n\t\t\tmap: height_map.data(),\n\t\t\trange: height_map.getHeightRange(),\n\t\t\tsize: height_map.getSize()\n\t\t};\n\n\t\tvar climate = {\n\t\t\tmap: temp_map.data(),\n\t\t\tsize: temp_map.getSize()\n\t\t};\n\n\t\tvar normalizer = 100 / height.range;\n\t\tvar sea_level = Math.round( sea_line / normalizer );\n\t\tvar tree_level = Math.round( tree_line / normalizer );\n\n\t\t// Generate random city centers and\n\t\t// roads separately before the heightmap\n\t\tgenerate_cities( sea_level, tree_level );\n\t\tgenerate_roads( sea_level );\n\n\t\theight_map.scan( function( y, x, elevation ) {\n\t\t\t// Scale [elevation] to [0 - 100] for use by the tile coloration formulas\n\t\t\televation = Math.round( elevation * normalizer );\n\n\t\t\tvar temp_x = y % climate.size;\n\t\t\tvar temp_y = x % climate.size;\n\t\t\tvar temperature = 5 + climate.map[temp_y][temp_x];\n\t\t\tvar is_sunny = (\n\t\t\t\t( elevation < sea_line ) ?\n\t\t\t\t\tfalse\n\t\t\t\t:\n\t\t\t\t\t( elevation < sea_line+6 || tile_is_lit( height.map, y, x ) )\n\t\t\t);\n\n\t\t\tvar tile_RGB = {\n\t\t\t\tred: color.elevation.red( elevation ) + color.temperature.red( temperature, elevation ) + ( is_sunny ? 0 : -20 ),\n\t\t\t\tgreen: color.elevation.green( elevation ) + color.temperature.green( temperature, elevation ) + ( is_sunny ? 0 : -20 ),\n\t\t\t\tblue: color.elevation.blue( elevation ) + color.temperature.blue( temperature, elevation ),\n\t\t\t\talpha: 255\n\t\t\t};\n\n\t\t\t// Special coloration for shoreline tiles\n\t\t\tif ( elevation > sea_line - 6 && elevation < sea_line + 6 ) {\n\t\t\t\tif ( tile_just_above( height.map, y, x, sea_level - 1 ) ) {\n\t\t\t\t\ttile_RGB.red += 20;\n\t\t\t\t\ttile_RGB.green += 20;\n\t\t\t\t} else\n\t\t\t\tif ( tile_just_below( height.map, y, x, sea_level ) ) {\n\t\t\t\t\ttile_RGB.green += 50;\n\t\t\t\t\ttile_RGB.blue += 40;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Render coastal roads to [city_canvas]\n\t\t\tif ( elevation > sea_line + 2 && elevation < sea_line + 6 && Generator.random() < 0.1 ) {\n\t\t\t\tvar light_reduction = Generator.random( 0, 20 ) + ( elevation !== sea_line + 4 ? 20 : 0 );\n\t\t\t\tvar road_RGB = {\n\t\t\t\t\tred: color.presets.city.r - light_reduction,\n\t\t\t\t\tgreen: color.presets.city.g - light_reduction,\n\t\t\t\t\tblue: color.presets.city.b - light_reduction\n\t\t\t\t};\n\n\t\t\t\tcity_canvas.draw.rectangle( x, y, 1, 1 ).fill( rgb( road_RGB.red, road_RGB.green, road_RGB.blue ) );\n\t\t\t}\n\n\t\t\tvar pixel = terrain_IMG.getPixelIndex( x, y );\n\t\t\tterrain_IMG.write( pixel, tile_RGB );\n\t\t} );\n\n\t\tterrain_canvas.data.put( terrain_IMG );\n\t\ttime_canvas.data.put( terrain_canvas.data.get() );\n\t}", "title": "" }, { "docid": "b0e9ae5f4f1d0cbd28606260a7094c84", "score": "0.56382805", "text": "function DrawMap()\r\n{\r\n //debugSprite.tileSheet = mapTilesetTileSheet; //debug walls\r\n \r\n const scrollx = TruncateDecimal( camX ) % tileSizeWidthPx;\r\n const scrolly = TruncateDecimal( camY ) % tileSizeHeightPx;\r\n\r\n for( let drawY = -1; drawY <= screenHeightTiles + 1; drawY++ )\r\n {\r\n const searchY = drawY + TruncateDecimal( camY / tileSizeHeightPx );\r\n\r\n for( let drawX = -1; drawX <= screenWidthTiles + 1; drawX++ )\r\n {\r\n const searchX = drawX + TruncateDecimal( camX / tileSizeWidthPx );\r\n\r\n //bounds check\r\n if ( searchX < 0 || searchY < 0 || searchX >= mapSizeWidthTiles || searchY >= mapSizeHeightTiles )\r\n continue;\r\n \r\n const index = searchX + searchY * mapSizeWidthTiles;\r\n const x = drawX * tileSizeWidthPx - scrollx;\r\n const y = drawY * tileSizeHeightPx - scrolly;\r\n \r\n for( let i = 0; i < mapData.layers.length; i++ )\r\n {\r\n //note: ignore tile zero and offset the ids by -1. workarounds with working with Tiled\r\n const tmpAttributesIndex = CheckMapData( mapData.layers[i].data[index] - 1 );\r\n if ( tmpAttributesIndex <= 0 || !mapTileSetTileAttributes[tmpAttributesIndex].visible )\r\n continue;\r\n\r\n mapTileSetTileAttributes[tmpAttributesIndex].sprite.x = x;\r\n mapTileSetTileAttributes[tmpAttributesIndex].sprite.y = y;\r\n mapTileSetTileAttributes[tmpAttributesIndex].sprite.depth = mapData.layers[i].properties.depth;\r\n\r\n AddDrawQueue( mapTileSetTileAttributes[tmpAttributesIndex].sprite );\r\n }\r\n \r\n //debug walls\r\n /*\r\n if ( MapIsSolid( searchX, searchY ) )\r\n {\r\n debugSprite.x = x;\r\n debugSprite.y = y;\r\n AddDrawQueue( debugSprite );\r\n }\r\n */\r\n\r\n }\r\n }\r\n}", "title": "" }, { "docid": "f067c037d1d4e4c2b7cac1d0a7cc5a90", "score": "0.56259197", "text": "function drawMap() {\n //find offset to where drawing must start\n var xIncrease = cursorOffscreenX\n var yIncrease = cursorOffscreenY\n for (var x = xIncrease; x < xIncrease + SCREEN_TILES_X; ++x) {\n for (var y = yIncrease; y < yIncrease + SCREEN_TILES_Y; ++y) {\n drawImage(currentMap.img, \n toRealX(x), toRealY(y),\n tileWidth(), tileHeight(),\n currentMap.tile[x][y].x*(1+TILE_DIMENSION)+1, \n currentMap.tile[x][y].y*(1+TILE_DIMENSION)+1, \n TILE_DIMENSION, TILE_DIMENSION)\n }\n }\n}", "title": "" }, { "docid": "233eec2417da66877e647631480ea474", "score": "0.5591277", "text": "async function captureMap(el,callback){\r\n cl('captureMap expecting rendering');\r\n var styleback, datasize, b64img, r, necessaires = 1,ms=100,waits=0;\r\n el=el||'.heremap';callback=callback||nf;\r\n r=document.querySelector('#dashCap');\r\n styleback=$(el).attr('style');\r\n /*could be even wider than ever .... */\r\n //here map capture map and markers\r\n//$(el).attr('style','').addClass('fullScreen');hereMap.map.getViewPort().resize();necessaires=2;//Passée derrière\r\n//So we get the second rendering en mode FullScreen, de toutes façons 2 car on doit attendre que la copie soit rendue\r\n $(el).attr('style','').addClass('hidden');\r\n while(toload.length!=0 || !rendered || document.querySelectorAll('canvas').length<1) {waits+=ms;await new Promise(r => setTimeout(r,ms));}//cl(rendered,renderingSteps,necessaires,document.querySelectorAll('canvas').length);\r\n cl('waited:',waits,',rendering steps:',renderingSteps);\r\n await new Promise(r => setTimeout(r,400));//Make sure All Duplicated Png Markers are loaded !!!\r\n\r\n //while(renderingSteps<necessaires || document.querySelectorAll('canvas').length<1) {cl(renderingSteps,necessaires,document.querySelectorAll('canvas').length);await new\r\n // Promise(r => setTimeout(r,2000));}\r\n// rendered maps\r\n//await new Promise(r => setTimeout(r,4000));\r\n//wait a little , nope ? surveiller les chargements réseau du navigateur ?\r\n hereMap.map.capture(function(cap){\r\n //$('#adresse').val()\r\n _mapName='';\r\n if(typeof session['hid']!='undefined')_mapName+='-hid='+session['hid'];\r\n if(typeof uid!='undefined')_mapName+='-uid='+uid;\r\n if(typeof post['adresse']!='undefined')_mapName+='-adress='+post['adresse'];\r\n if(typeof post['perimetre']!='undefined')_mapName+='-perimetre='+post['perimetre'];\r\n if(typeof post['residence']!='undefined')_mapName+='-residence='+post['residence'];\r\n _mapName += '-rs=' + renderingSteps;\r\n renderingSteps = rendered = 0;\r\n\r\n //_mapName='uid:'+uid+'-'+location.pathname+'-'+mapName;\r\n\r\n r.innerHTML='';r.appendChild(cap);\r\n cap=document.querySelectorAll('canvas')[0];//First one dans la dom\r\n b64img=cap.toDataURL('image/jpeg');\r\n /*\r\n cap=document.querySelectorAll('canvas')[0];//First one dans la dom\r\n b64img=cap.toDataURL('image/jpeg');\r\n $.ajax({\"url\":\"/z/receptor.php\",\"method\":\"POST\",\"data\":{\"name\":_mapName,\"img\":b64img}}).done(function(e) {\r\n $.ajax({\"url\":\"/updateHistory\",\"method\":\"POST\",\"data\":{\"hid\":session['hid'],\"mapName\":e}}).done(function(e) {\r\n cl('updated',e);\r\n });\r\n callback(e);\r\n });\r\n */\r\n\r\n $(el).removeClass('hidden').attr('style',styleback);\r\n //r.innerHTML='';\r\n datasize=b64img.length;\r\n //console.log(datasize);\r\n $.ajax({\"url\":\"/z/ajax.php\",\"method\":\"POST\",\"data\":{\"name\":_mapName,\"img\":b64img}}).done(function(e) {\r\n $.ajax({\"url\":\"/updateHistory\",\"method\":\"POST\",\"data\":{\"hid\":session['hid'],\"mapName\":e}}).done(function(e) {\r\n cl('updated',e);\r\n });\r\n callback(e);cl(e);\r\n });\r\n //$('#dashCap').css({\"z-index\":9999});\r\n }, [], 0, 0, 1400, 1400);\r\n}", "title": "" }, { "docid": "a2fb74f72f283f5f80fd3e5e745077dd", "score": "0.5556372", "text": "function displayMap(width, height) {\n\n scale = window.innerWidth / maxWidth;\n path = d3.geo.path();\n\n svg = d3.select(\"#map-display\").append(\"svg\")\n .attr(\"width\", width)\n .attr(\"height\", height);\n\n g = svg.append(\"g\")\n .attr(\"id\", \"states\");\n\n d3.json(\"statesData.json\", function(data) {\n gunTraceData = data;\n });\n\n d3.json(\"statesMap.json\", function(json) {\n g.selectAll(\"path\")\n .data(json.features)\n .enter().append(\"path\")\n .attr(\"d\", path)\n .on(\"click\", highlightState)\n .on(\"focus\", paintScores());\n resizeMap(width, height); // Enables resizing based on screen size/resolution\n });\n}", "title": "" }, { "docid": "36991dffaa6224ea6b7f68bfd7d14d50", "score": "0.55240345", "text": "function fitMapToWindow() {\n var oldWidth = parseInt(mapImageCanvas.style.width || mapImageCanvas.width, 10),\n oldHeight = parseInt(mapImageCanvas.style.height || mapImageCanvas.height, 10),\n newDims = getOptimalDimensions(oldWidth, oldHeight, window.innerWidth, Infinity);\n\n resize(newDims.width, newDims.height);\n }", "title": "" }, { "docid": "a62019352f8c3b947a0762a509191fe9", "score": "0.5517183", "text": "function renderMap(venue, level, rname, rx, ry) {\n roomcenter.lat = rx;\n roomcenter.lng = ry;\n $scope.zoomerImage = Zoomer.zoom_image(\"inline-view\", 'maps/assets/' + venue + '/level_' + level + '/tile_{z}_{x}_{y}.png', 6000, 6000);\n //$scope.zoomerImage = FullZoomer.zoom_image(\"full-view\",'maps/assets/' + venue + '/level_' + level + '/tile_{z}_{x}_{y}.png',6000,6000);\n }", "title": "" }, { "docid": "9c6f4156173bec1827a7d0ef91988fd0", "score": "0.54890954", "text": "function prerender() {\n if (tileEngine.layers) {\n tileEngine.layers.forEach(layer => {\n layerMap[layer.name] = layer;\n\n if (layer.visible !== false) {\n tileEngine._r(layer, offscreenContext);\n }\n });\n }\n }", "title": "" }, { "docid": "9c6f4156173bec1827a7d0ef91988fd0", "score": "0.54890954", "text": "function prerender() {\n if (tileEngine.layers) {\n tileEngine.layers.forEach(layer => {\n layerMap[layer.name] = layer;\n\n if (layer.visible !== false) {\n tileEngine._r(layer, offscreenContext);\n }\n });\n }\n }", "title": "" }, { "docid": "59c52dce4e509ef4edf90fd45b6b8682", "score": "0.5483512", "text": "function render_map( $el ) {\n\n var styles = [{\"featureType\":\"landscape\",\"stylers\":[{\"saturation\":-100},{\"lightness\":65},{\"visibility\":\"on\"}]},{\"featureType\":\"poi\",\"stylers\":[{\"saturation\":-100},{\"lightness\":51},{\"visibility\":\"simplified\"}]},{\"featureType\":\"road.highway\",\"stylers\":[{\"saturation\":-100},{\"visibility\":\"simplified\"}]},{\"featureType\":\"road.arterial\",\"stylers\":[{\"saturation\":-100},{\"lightness\":30},{\"visibility\":\"on\"}]},{\"featureType\":\"road.local\",\"stylers\":[{\"saturation\":-100},{\"lightness\":40},{\"visibility\":\"on\"}]},{\"featureType\":\"transit\",\"stylers\":[{\"saturation\":-100},{\"visibility\":\"simplified\"}]},{\"featureType\":\"administrative.province\",\"stylers\":[{\"visibility\":\"off\"}]},{\"featureType\":\"water\",\"elementType\":\"labels\",\"stylers\":[{\"visibility\":\"on\"},{\"lightness\":-25},{\"saturation\":-100}]},{\"featureType\":\"water\",\"elementType\":\"geometry\",\"stylers\":[{\"hue\":\"#ffff00\"},{\"lightness\":-25},{\"saturation\":-97}]}];\n\n\n // var\n var $markers = $el.find('.marker');\n\n // vars\n var args = {\n scrollwheel : false,\n zoom : 16,\n center : new google.maps.LatLng(0, 0),\n mapTypeId : google.maps.MapTypeId.ROADMAP,\n styles: styles\n };\n\n // create map \n var map = new google.maps.Map( $el[0], args);\n\n // add a markers reference\n map.markers = [];\n\n // add markers\n $markers.each(function(){\n\n add_marker( $(this), map );\n\n });\n\n // center map\n center_map( map );\n\n }", "title": "" }, { "docid": "9354f8e263e628dcae0c048a9091567c", "score": "0.54829675", "text": "function renderCubeMap() {\n\n //Map Edge Color\n c.strokeStyle=\"#000000\";\n //Map Edge Width\n c.lineWidth=cmLW;\n\n k=1/2;\n\n CMtopBotFaces();\n CMmiddleFaces();\n\n}", "title": "" }, { "docid": "488635f7cd50cbc0e2f2bf5778edea2a", "score": "0.54796576", "text": "function drawMap(validMap) {\r\n\tlet rowsCount = validMap[0];\r\n\tlet columnsCount = validMap[1];\r\n\tlet tileSize = 60; // Size in pixels, must be changed in css also if modified here\r\n\tlet tileSpacing = 0; // Spacing in pixels\r\n\tlet mapHtml = \"\";\r\n\tlet divId = \"\";\r\n\r\n\t// Empty div contair so we can drw the map in it\r\n\tworkBench.innerHTML = \"\";\r\n\tworkBenchWdith = (rowsCount * (tileSize + tileSpacing));\r\n\tworkBenchHeight = (columnsCount * (tileSize + tileSpacing));\r\n\r\n\tif (workBenchWdith < 200)\r\n\t\tworkBenchWdith = 200;\r\n\r\n\tworkBench.style.width = workBenchWdith;\r\n\tworkBench.style.height = workBenchHeight;\r\n\r\n\t// Loop through and draw tiles\r\n\tfor (var column = 1; column <= columnsCount; column++) {\r\n\t\tmapGraph[column] = [];\r\n\t\tfor (var row = 1; row <= rowsCount; row++) {\r\n\t\t\tdivId = column + \"-\" + row;\r\n\t\t\tmapGraph[column][row] = divId;\r\n\t\t\tif ((column + row) % 2 == 0) {\r\n\t\t\t\tmapHtml += '<div id=\"' + divId + '\" class=\"tile1 baseTile\">' + divId + '</div>';\r\n\t\t\t} else {\r\n\t\t\t\tmapHtml += '<div id=\"' + divId + '\"class=\"tile2 baseTile\">' + divId + '</div>';\r\n\t\t\t}\r\n\t\t}\r\n\t\tmapHtml += '<br/>';\r\n\t};\r\n\tworkBench.innerHTML = mapHtml;\r\n}", "title": "" }, { "docid": "1c68fa0e12df320fc76a8d8d384ce768", "score": "0.54747486", "text": "function onResize()\n{\n\n /* Layouting algorithm:\n * - if there is enough space (> 800x800px) or no tool window is shown -> display the tool window as a 400x400 overlay (smaller if the tool window requires less space), and let the GL canvas cover the whole screen\n * - if there is not enough space and a tool window is shown:\n * - if the screen is in landscape mode --> display the tool window as\n * a side pane covering the left 400px (less if it needs less space) \n * of the screen at full height, and the GL canvas to cover the \n * remaining space\n * - if the screen is in portrait mode --> display the tool window as\n * a top pane covering the top 400px (less if it needs less space)\n * of the screen at full width, and the GL canvas to cover the\n * remaining space\n *\n * A tool window needs less than the alotted space, if:\n * - for a div with html content: if its content fits into less than the\n * alotted space (as determined by the browser's layout engine)\n * - for the layout div: it will determine its space needs using its own\n * algorithm base on the layout image aspect ratio\n * - for the map div: it will always cover all of the available space\n */\n\n var wnd = myToolbar ? myToolbar.getActiveWindow() : undefined;\n var anyToolbarVisible = (wnd && wnd.target);\n var activeDiv = anyToolbarVisible;\n //dummy element so that the existence of activeDiv is guaranteed for the following code \n if (!activeDiv)\n activeDiv = {style:{offsetTop:\"72px;\", offsetHeight:\"0px\"}};\n \n var mode = \"overlay\";\n\n if (mqSaveSpace.matches && anyToolbarVisible)\n mode = (mqLandscape.matches) ? \"side\" : \"top\";\n \n switch ( mode )\n {\n case \"overlay\":\n canvasContainer.style.left = \"0px\";\n canvasContainer.style.top = \"0px\";\n activeDiv.className = \"toolWindow toolOverlay\";\n activeDiv.style.maxHeight = \"\"\n\n\n if (activeDiv == mapDiv)\n { \n mapDiv.className = \"toolWindow toolOverlay leaflet-container leaflet-fade-anim\";\n mapDiv.style.width = \"400px\";\n mapDiv.style.height = \"400px\";\n }\n if (activeDiv == layoutDiv)\n {\n ApartmentMap.resize( 400, 400);\n }\n \n break;\n case \"side\":\n canvasContainer.style.top = \"0px\";\n activeDiv.style.maxHeight = \"\"\n \n activeDiv.className = \"toolWindow toolSide\";\n if (activeDiv == mapDiv)\n {\n mapDiv.className = \"toolWindow toolSide leaflet-container leaflet-fade-anim\";\n mapDiv.style.width = \"400px\";\n mapDiv.style.height = \"\"; \n }\n\n if (activeDiv == layoutDiv)\n ApartmentMap.resize( 400, window.innerHeight - 72);\n\n canvasContainer.style.left = (activeDiv.offsetLeft + activeDiv.offsetWidth) + \"px\";\n break;\n \n case \"top\":\n canvasContainer.style.left = \"0px\";\n activeDiv.className = \"toolWindow toolTop\";\n activeDiv.style.height = \"\"\n activeDiv.style.width = \"\";\n activeDiv.style.maxHeight = \"400px\"\n \n if (activeDiv == mapDiv)\n {\n mapDiv.className = \"toolWindow toolTop leaflet-container leaflet-fade-anim\";\n mapDiv.style.width = \"\";\n mapDiv.style.height= \"400px\";\n }\n\n if (activeDiv == layoutDiv)\n ApartmentMap.resize( window.innerWidth, 400);\n\n canvasContainer.style.top = activeDiv.offsetTop + activeDiv.offsetHeight + \"px\";\n\n break;\n }\n \n divDisclaimer.style.left = canvasContainer.style.left;\n\n var aspect = webGlCanvas.clientWidth / webGlCanvas.clientHeight;\n\n /* Render the 3D view at half the device's native pixel count.\n This is a compromise between having a high resolution 3D view (even for\n devices with a high devicePixelRatio) and still being fast enough for smooth\n interaction. \n */\n \n webGlCanvas.height = webGlCanvas.clientHeight * window.devicePixelRatio / Math.sqrt(2);\n webGlCanvas.width = webGlCanvas.clientWidth * window.devicePixelRatio / Math.sqrt(2);\n \n VicinityMap.onChangeSize();\n ApartmentMap.resize();\n\n \n scheduleFrameRendering();\n}", "title": "" }, { "docid": "3dc0fd86e659a794f3bbfde9cb3994c1", "score": "0.54412913", "text": "function draw () {\n if (dfMapData.loaded) {\n if (window.keyIsPressed === true && (window.key === '=' || window.key === '+' || window.key === '-')) { zoom() }\n\n // setup zoom information\n if (originalImgWidth === 0) { // not loaded\n originalImgWidth = dfMapData.mapData[0].width * dfMapData.tileWidth\n originalImgHeight = dfMapData.mapData[0].height * dfMapData.tileHeight\n imgWidth = originalImgWidth * scale\n imgHeight = originalImgHeight * scale\n // return;\n }\n\n window.background(0)// Make background black\n\n if (dfMapData.mapData[idx] !== undefined && dfMapData.mapData[idx].loaded === false && !dfMapData.mapData[idx].loading) {\n dfMapData.getLayer(idx)\n return\n }\n if (dfMapData.mapData[idx] === undefined || dfMapData.mapData[idx].img === undefined) { return }\n const img = dfMapData.getLayer(idx)\n window.image(img, imageX, imageY, imgWidth, imgHeight)\n\n const selectorWidth = dfMapData.tileWidth * scale\n const selectorHeight = dfMapData.tileHeight * scale\n\n // draw selector\n const curCenterX = window.width / 2 - imageX\n const curCenterY = window.height / 2 - imageY\n const selectedX = window.floor(curCenterX / (dfMapData.tileWidth * scale))\n const selectedY = window.floor(curCenterY / (dfMapData.tileHeight * scale))\n\n window.stroke(255, 0, 0)\n window.strokeWeight(window.max(scale, 2))\n window.noFill()\n window.rect(imageX + selectorWidth * selectedX, imageY + selectorHeight * selectedY, selectorWidth, selectorHeight)\n window.stroke(255, 255, 0)\n const crosshairSize = 5\n window.strokeWeight(2)\n window.line(window.width / 2 - crosshairSize, window.height / 2, window.width / 2 + crosshairSize, window.height / 2)\n window.line(window.width / 2, window.height / 2 - crosshairSize, window.width / 2, window.height / 2 + crosshairSize)\n\n // text\n window.stroke(255)\n window.noFill()\n window.strokeWeight(1)\n window.textFont('Helvetica', 12)\n window.textAlign(window.LEFT)\n window.text('Layer: ' + dfMapData.mapData[idx].depth, 20, 20)\n\n // debug code for seeing all tiles\n // loadPixels();\n // let xT = 0, yT = 0;\n // let wPixels = dfMapData.tileWidth;\n // let hPixels = dfMapData.tileHeight;\n // for (let i = 0; i < dfMapData.numTiles; i++) {\n\n // let cols = dfMapData.tiles[i];\n // for (let y = 0; y < hPixels; y++) {\n // for (let x = 0; x < wPixels; x++) {\n // let idx = x * 4 + y * 4 * wPixels;\n // pixels[(xT * wPixels * 4) + x * 4 + (y + yT * hPixels) * width * 4] = cols[idx];\n // pixels[(xT * wPixels * 4) + x * 4 + (y + yT * hPixels) * width * 4 + 1] = cols[idx + 1];\n // pixels[(xT * wPixels * 4) + x * 4 + (y + yT * hPixels) * width * 4 + 2] = cols[idx + 2];\n // pixels[(xT * wPixels * 4) + x * 4 + (y + yT * hPixels) * width * 4 + 3] = cols[idx + 3];\n // }\n // }\n // xT++;\n // if (xT >= width / wPixels) {\n // xT = 0;\n // yT++;\n // if (yT >= height / hPixels)\n // break;\n // }\n // }\n // updatePixels();\n\n if (dragged) {\n window.fill(0, 0, 0, 200)\n window.textFont('Helvetica', 30)\n window.textAlign(window.CENTER, window.CENTER)\n window.rect(0, 0, window.width, window.height)\n window.fill(255)\n window.text('DROP FDF-MAP FILE HERE', window.width / 2, window.height / 2)\n }\n } else {\n window.background(0)\n window.textFont('Helvetica', 20)\n window.textAlign(window.CENTER, window.CENTER)\n window.stroke(255)\n window.fill(255)\n\n window.text('Loading...', window.width / 2, window.height / 2)\n }\n}", "title": "" }, { "docid": "b0748800d9e7202f6293fa3ecbee9f1d", "score": "0.5431561", "text": "render(width, height, canvas) {\r\n\t\tcanvas.fillStyle = \"#FFF\";\r\n\t\tcanvas.clearRect(0, 0, width, height);\r\n\t\tlet border = 20;\r\n\r\n\t\tconst blockSizeX = (width - 2 * border) / this.mapWidth;\r\n\t\tconst blockSizeY = (height - 2 * border) / this.mapHeight;\r\n\r\n\t\tcanvas.fillStyle = \"#000\";\r\n\t\tfor (let y = 0; y < this.mapHeight; y++) {\r\n\t\t\tfor (let x = 0; x < this.mapWidth; x++) {\r\n \r\n\t\t\t\t// Calculate the corners of each cell.\r\n\t\t\t\tconst left = border + (blockSizeX * x);\r\n\t\t\t\tconst top = border + (blockSizeY * y);\r\n\t\t\t\t// Draw a black rectangle if this is a wall.\r\n\t\t\t\tif (this.map[y][x] == 1) {\r\n //console.log([left, top, blockSizeX, blockSizeY])\r\n canvas.fillRect(left, top, blockSizeX, blockSizeY);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n }", "title": "" }, { "docid": "ce24acc7d0bbb9f23c2bd7d3c9ae4780", "score": "0.5416874", "text": "function updateMapLayerDisplay() {\n updateVars();\n var newLoc;\n if(mustScale) {\n newLoc = encodeURIComponent(`${newLngMin},${newLatMin},${newLngMax},${newLatMax}`);\n // Base plane (O - Lat - Lng)\n redrawDynamicGridHelper(baseOXYGridHelper, sizeLat, sizeLng, newSizeX, newSizeZ);\n\n // Plane along Longitude axis (O - Time - Lng)\n redrawDynamicGridHelper(baseOYZGridHelper, sizeLng, sizeTime, newSizeZ, newSizeY);\n\n // Plane along Latitude axis (O - Time - Lat)\n redrawDynamicGridHelper(baseOXZGridHelper, sizeLat, sizeTime, newSizeX, newSizeY);\n\n // Update CUnit size\n dimensionX = sizeLat/newSizeX;\n dimensionY = sizeTime/newSizeY;\n dimensionZ = sizeLng/newSizeZ;\n }\n else {\n newLoc = encodeURIComponent(`${LNG_MIN},${LAT_MIN},${LNG_MAX},${LAT_MAX}`);\n resetScene();\n }\n\n updateBrushSizeFilter();\n\n //console.log(decodeURIComponent(newLoc));\n var url = ('https://www.openstreetmap.org/export/embed.html?bbox=LOCATION&amp;layers=MAPTYPE').replace(\"LOCATION\", newLoc).replace(\"MAPTYPE\", maptype);\n document.getElementById(\"OSMLayer\").setAttribute(\"src\", url);\n}", "title": "" }, { "docid": "908cf37af8503255920aabc886e89969", "score": "0.54156345", "text": "function drawMinimap() {\n\n\t// HUD\n\tlet HUDwidth = display.HUDwidth * display.interfaceScale;\n\tlet HUDheight = display.HUDheight * display.interfaceScale;\n\tlet viewPadding = display.viewPadding * display.interfaceScale;\n\tlet textSpacing = display.textSpacing * display.interfaceScale;\n\n\tlet planetSize = HUDheight * 0.75;\n\tlet HUDpadding = HUDheight * 0.125;\n\tlet labelSpacing = planetSize/4.5;\n\n\tlet textSize = 16*display.interfaceScale;\n\tlet resourceSize = 10*display.interfaceScale;\n\n\t// MAP\n\tlet zoom = display.zoom;\n\tlet mapSize = planetSize;\n\tlet mapScaleSize = 10000;\n\tlet mapZoom = mapScaleSize / mapSize / 1.5;\n\n\t// RECT\n\tlet rectOptions = {\n\t\talpha: 0.2,\n\t\tright: viewPadding\n\t}\n\n\t// ARC\n\tlet optionsCircle = {\n\t\toutline: true,\n\t\toutlineWidth: 10,\n\t\toutlineColor: rocket.closestPlanet.strokeColor, \n\t\tglow: false,\n\t\tglowColor: rocket.closestPlanet.color,\n\t\talpha: 0.5\n\t}\n\n\t// Draw minimap center (player)\n\tdrawRoundedRect(canvas.width - HUDwidth - viewPadding, canvas.height - HUDheight - viewPadding, HUDwidth, HUDheight, 5, \"grey\", rectOptions);\n\n\t// Draw the white map edge\n\tctx.save();\n\tctx.beginPath();\n\tctx.lineWidth = 3;\n ctx.strokeStyle = \"white\";\n\tctx.arc((canvas.width - HUDwidth - viewPadding + HUDpadding + planetSize/2), \n\t(canvas.height - HUDheight - viewPadding + HUDpadding + planetSize/2),\n\t planetSize/2, 0, Math.PI*2);\n\tctx.stroke();\n\tctx.fillStyle = \"#1d2951\"\n\tctx.fill();\n\tctx.closePath();\n\tctx.beginPath();\n\tctx.arc((canvas.width - HUDwidth - viewPadding + HUDpadding + planetSize/2), \n\t(canvas.height - HUDheight - viewPadding + HUDpadding + planetSize/2),\n\t planetSize/2, 0, Math.PI*2);\n\tctx.fillStyle = \"grey\"\n\tctx.globalAlpha = 0.2;\n\tctx.clip();\n\tctx.fill();\n\tctx.closePath();\n\t\n\t// Draw the planets\n\tfor (var i = 0; i < planets.length; i++) {\n\t\tif(getDistance(planets[i].pos.x, planets[i].pos.y, rocket.pos.x, rocket.pos.y) < mapScaleSize/2 + planets[i].radius) {\n\t\t\t\n\t\t\tdrawCircle((canvas.width - HUDwidth - viewPadding + HUDpadding + planetSize/2) + ((planets[i].pos.x - rocket.pos.x) / mapZoom),\n\t\t\t(canvas.height - HUDheight - viewPadding + HUDpadding + planetSize/2) + ((planets[i].pos.y - rocket.pos.y) / mapZoom), planets[i].radius/mapZoom, planets[i].color);\n\n\t\t}\n\t}\n\n\tctx.restore(); // Restore before clipping the drawing area\n\n\t// Draw rocket position on minimap\n\tdrawTriangle((canvas.width - HUDwidth - viewPadding + HUDpadding + planetSize/2), (canvas.height - HUDheight - viewPadding + HUDpadding + planetSize/2), 4, 7, rocket.angle, \"white\");\n\n\t// Sort planet list by distance\n\tvar sortedPlanetList = [];\n\tvar planetList = [].concat(planets);\n\tfor (var i = 0; i < 5; i++) {\n\t\tvar selectPlanet = undefined;\n\t\tvar distance = Infinity;\n\t\tfor (var j = 0; j < planetList.length; j++) {\n\t\t\tif(planetDist(rocket, planetList[j]) < distance) {\n\t\t\t\tdistance = dist(planetList[j].pos, rocket.pos) - planetList[j].radius - rocket.height/2;\n\t\t\t\tselectPlanet = j;\n\t\t\t}\n\t\t}\n\n\t\tsortedPlanetList.push(planetList[selectPlanet]);\n\t\tplanetList.splice(selectPlanet, 1);\n\t}\n\n\t// Display List - OPTIMIZE FOR LATER\n\tfor (let i = 0; i < 5; i++) {\n\t\tlet distance = Math.max(0, round(planetDist(rocket, sortedPlanetList[i])));\n\t\tdrawText(\n\t\t\tsortedPlanetList[i].name + \" [\" + (distance > 1000 ? round(distance / 1000, 2) + \"km]\" : distance + \"m]\"), \n\t\t\tcanvas.width - HUDwidth - viewPadding + planetSize + HUDpadding*2,\n\t\t\tcanvas.height - viewPadding - HUDheight + HUDpadding + labelSpacing*i, \n\t\t\ttextSize + \"px Arial\", \"white\", \"left\", \"top\"\n\t\t);\n\t}\n\tfor (let i = 0; i < 5; i++) {\n\t\tlet distance = Math.max(0, round(planetDist(rocket, sortedPlanetList[i])));\n\t\tdrawText(\n\t\t\tsortedPlanetList[i].resource.type, \n\t\t\tcanvas.width - HUDwidth - viewPadding + planetSize + HUDpadding*2,\n\t\t\tcanvas.height - viewPadding - HUDheight + HUDpadding + labelSpacing*i - 12*display.interfaceScale, \n\t\t\tresourceSize + \"px Arial\", \"grey\", \"left\", \"top\"\n\t\t);\n\t}\n}", "title": "" }, { "docid": "f0ede2c933e597925aa025f91fdfb487", "score": "0.5400365", "text": "function Render() {\n tickCount++;\n\n // Render the main canvas\n RenderCanvas()\n\n // Render map 4 times per second as its pretty laggy \n if (tickCount % (TICKS_PER_SECOND / 4) == 0) {\n RenderMap();\n tickCount = 0;\n }\n}", "title": "" }, { "docid": "345d54f0003352a09077be81a191d141", "score": "0.53944474", "text": "function drawMap(inx, iny, layer, hori, vert){\n let county = 0;\n for(let coordy = starty;coordy<endy;coordy+=tilesize){\n let countx = 0;\n for(let coordx = startx;coordx<endx;coordx+=tilesize){\n let y = Math.floor(iny)-vertviewdist+county;\n let x = Math.floor(inx)-horiviewdist+countx;\n let temp = map.layers[layer][y][x];\n if(temp !== 0){\n let sourcex = ((temp-1)%8)*32;\n let sourcey = (Math.floor((temp-1)/8))*32;\n let posx = coordx+(Math.floor(inx)-inx)*tilesize;\n let posy = coordy+(Math.floor(iny)-iny)*tilesize;\n ctx.drawImage(worldTiles, sourcex, sourcey, tilesize, tilesize, Math.round(posx), Math.round(posy), tilesize, tilesize);\n }\n countx++;\n }\n county++;\n }\n}", "title": "" }, { "docid": "b67e0d883a4d84f5ede5a2acddc6171d", "score": "0.536581", "text": "function drawMap() {\n\n mapCtx.clearRect(0, 0, gameMap.mapPixelSize, gameMap.mapPixelSize);\n\n // Draw the grid cells.\n for (let i = 0; i < gameMap.mapRects.length; i += 1) {\n drawMapRect(mapCtx, gameMap.mapRects[i]);\n }\n\n // Draw the player location.\n drawCircle(mapCtx, player.x, player.y, 5);\n}", "title": "" }, { "docid": "7d3be6d0e9e5a72292a8396c5a3fd703", "score": "0.5346504", "text": "function drawInitMap(){\n\tvar miniMap = $(\"#minimap\")[0];\n\tminiMap.width = width * miniMapScale + 1;\n\tminiMap.height = height * miniMapScale + 1;\n\tvar cxt = miniMap.getContext(\"2d\");\n\tcxt.strokeStyle = \"rgba(200,200,200,1)\";\n\tfor (var x=0;x<=width;x++) {\n\t\tcxt.moveTo(x * miniMapScale,0);\n\t\tcxt.lineTo(x * miniMapScale, height * miniMapScale);\n\t\tcxt.stroke();\n\t}\n\tfor (var y=0;y<=height;y++) {\n\t\tcxt.moveTo(0, y * miniMapScale);\n\t\tcxt.lineTo(width * miniMapScale, y * miniMapScale);\n\t\tcxt.stroke();\n\t}\n}", "title": "" }, { "docid": "c82daef241533e67e8be0e6b750d10a1", "score": "0.5338753", "text": "function cw_drawFloor() {\n ctx.strokeStyle = \"#000\";\n ctx.fillStyle = \"#666\";\n ctx.lineWidth = 1/zoom;\n ctx.beginPath();\n\n outer_loop:\n for(var k = Math.max(0,last_drawn_tile-20); k < cw_floorTiles.length; k++) {\n var b = cw_floorTiles[k];\n for (f = b.GetFixtureList(); f; f = f.m_next) {\n var s = f.GetShape();\n var shapePosition = b.GetWorldPoint(s.m_vertices[0]).x;\n if((shapePosition > (camera_x - 5)) && (shapePosition < (camera_x + 10))) {\n cw_drawVirtualPoly(b, s.m_vertices, s.m_vertexCount);\n }\n if(shapePosition > camera_x + 10) {\n last_drawn_tile = k;\n break outer_loop;\n }\n }\n }\n ctx.fill();\n ctx.stroke();\n}", "title": "" }, { "docid": "485d406af3e3a072aa758d8502160d2b", "score": "0.53362644", "text": "render()\n {\n ASSERT(mainContext != this.context); // must call redrawEnd() after drawing tiles\n\n // flush and copy gl canvas because tile canvas does not use gl\n this.flushGLBeforeRender && glEnable && glCopyToContext(mainContext);\n \n // draw the entire cached level onto the main canvas\n const pos = worldToScreen(this.pos.add(vec2(0,this.size.y*this.scale.y)));\n mainContext.drawImage\n (\n this.canvas, pos.x, pos.y,\n cameraScale*this.size.x*this.scale.x, cameraScale*this.size.y*this.scale.y\n );\n }", "title": "" }, { "docid": "cf1b7392d78c6b154e94a4b57706bf4b", "score": "0.5322263", "text": "function preDrawMap() {\n const kindOfCase = getKindOfCase()\n\n const color = document.getElementById('colorpicker').value\n\n const strokecolor = document.getElementById('colorOutline').value\n\n const max = getMax(data, kindOfCase)\n\n drawMap(kindOfCase, color, strokecolor, max)\n}", "title": "" }, { "docid": "a1b380e6a37c88ca6cb139e5de3457e7", "score": "0.53134036", "text": "function drawMap() {\n for (var eachRow = 0; eachRow < 8; eachRow++) {\n for (var eachCol = 0; eachCol < 8; eachCol++) {\n mapArrayIndex = rowColToArrayIndex(eachCol, eachRow);\n if (mapArray[mapArrayIndex] === 0) {\n $('#container').append('<div class=\"grass\"></div>');\n } else if (mapArray[mapArrayIndex] === 1) {\n $('#container').append('<div class=\"breakable\" id= block'+breakableIndex[breakableIndexCurrent]+ '></div>');\n breakableIndexCurrent ++;\n } else if (mapArray[mapArrayIndex] === 2) {\n $('#container').append('<div class=\"unbreakable\" ></div>');\n }\n }\n }\n }", "title": "" }, { "docid": "bf4502672d55910fe65654372eac1c08", "score": "0.5309502", "text": "function render() {\n // clear context\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n // draw map\n for (row = 0; row < NUM_ROWS; row++) {\n for (col = 0; col < NUM_COLUMNS; col++) {\n ctx.drawImage(Resources.get(Map[row]), col * TILE_WIDTH, row * TILE_HEIGHT);\n }\n }\n // draw player and other objects\n renderEntities();\n DrawScore();\n // render floating text boxes\n RenderFloaters();\n // draw paused text\n if(paused)\n DrawPaused();\n }", "title": "" }, { "docid": "911be45b22e8fe4021777fbf106b68a0", "score": "0.52993184", "text": "function mapRender(){\n var distance_map = Ext.getCmp('storesMap');\n distance_map.rendered = false;\n distance_map.render();\n }", "title": "" }, { "docid": "ac85914fc66d6c52026055f07d4aaa79", "score": "0.52897906", "text": "renderGoogleMap(apikey, zoom) {\n let staticMapString;\n let map = this.mapObject;\n // zoom = this.mapObject.zoomSettings.shouldZoomInitially ? this.mapObject.markerZoomFactor : zoom;\n zoom = this.mapObject.tileZoomLevel;\n let x;\n let y;\n let totalSize = Math.pow(2, zoom) * 256;\n x = (map.mapAreaRect.width / 2) - (totalSize / 2);\n y = (map.mapAreaRect.height / 2) - (totalSize / 2);\n let centerPoint = new Point(null, null);\n let diffX = 0;\n let diffY = 0;\n let position = convertTileLatLongToPoint(centerPoint, zoom, { x: x, y: y }, this.isMapCoordinates);\n if (map.zoomModule && map.zoomSettings.enable) {\n diffX = map.zoomModule.mouseDownLatLong['x'] - map.zoomModule.mouseMoveLatLong['x'];\n diffY = map.zoomModule.mouseDownLatLong['y'] - map.zoomModule.mouseMoveLatLong['y'];\n }\n let panLatLng = map.pointToLatLong(position.x - diffX, position.y - diffY);\n map.centerPosition.latitude = panLatLng['latitude'];\n map.centerPosition.longitude = panLatLng['longitude'];\n let mapWidth;\n let mapHeight;\n if (Object(_syncfusion_ej2_base__WEBPACK_IMPORTED_MODULE_0__[\"isNullOrUndefined\"])(parseInt(map.width, 10))) {\n mapWidth = parseInt(map.width, 10) - 22;\n }\n else {\n mapWidth = Math.round(map.mapAreaRect.width);\n }\n if (Object(_syncfusion_ej2_base__WEBPACK_IMPORTED_MODULE_0__[\"isNullOrUndefined\"])(parseInt(map.height, 10))) {\n mapHeight = parseInt(map.height, 10) - 22;\n }\n else {\n mapHeight = Math.round(map.mapAreaRect.height);\n }\n let eleWidth = mapWidth > 640 ? (mapWidth - 640) / 2 : 0;\n let eleHeight = mapHeight > 640 ? (mapHeight - 640) / 2 : 0;\n let center;\n let mapType = (map.layers[map.layers.length - 1].staticMapType).toString().toLowerCase();\n if (map.centerPosition.latitude && map.centerPosition.longitude) {\n center = map.centerPosition.latitude.toString() + ',' + map.centerPosition.longitude.toString();\n }\n else {\n center = '0,0';\n }\n staticMapString = 'https://maps.googleapis.com/maps/api/staticmap?size=' + mapWidth + 'x' + mapHeight +\n '&zoom=' + zoom + '&center=' + center + '&maptype=' + mapType + '&key=' + apikey;\n document.getElementById(this.mapObject.element.id + '_tile_parent').innerHTML\n = '<div id=\"' + this.mapObject.element.id + '_StaticGoogleMap\"' + 'style=\"position:absolute; left:' + eleWidth + 'px; top:'\n + eleHeight + 'px\"><img src=\"' + staticMapString + '\"></div>';\n }", "title": "" }, { "docid": "91a6c9ce5b089d998a6efbd3214b31e1", "score": "0.52808976", "text": "displayMap(){\n fill(this.mapColor);\n this.polygon(this.x,this.y,this.r,this.SIDES); \n }", "title": "" }, { "docid": "ed609546464b3d5bf569451c3066771c", "score": "0.5279132", "text": "function mapBootEngine(){\n\t// Rederer\n\tmapEngine=new THREE.WebGLRenderer({\n\t\tcanvas: mapCanvas,\n\t\talpha:true,\n\t\tantialias: true,\n\t\tsortObjects:true,\n\t});\n\tvar options = {\n\t\tformat : THREE.RGBFormat,\n\t\tantialias: true,\n\t\tsortObjects:true,\n\t\talpha:true,\n\t\ttype : /(iPad|iPhone|iPod)/g.test(navigator.userAgent) ? THREE.HalfFloatType : THREE.FloatType\n\t};\n\tmapEngine.autoClear=false; // Clear prior render before new render\n\t\n\tmapEngine.setClearColor(0x000000, 0);\n\tmapEngine.setPixelRatio(window.devicePixelRatio);\n\tmapEngine.setSize(mapW/mapQuality.screenResPerc, mapH/mapQuality.screenResPerc);\n\t\n\tmapScene = new THREE.Scene();\n\tmapScene.background = new THREE.Color(0,0,0);\n\t\n\taspectRatio = mapCanvas.width / mapCanvas.height;\n\tmapCam = new THREE.PerspectiveCamera(60,aspectRatio, 1, 10000);\n\n\t\n\t///////////////////////////////////////////////////\n\t// -- GEOMETRY -- -- -- -- -- -- -- -- -- -- -- //\n\t///////////////////////////////////////////////////\n\t// Texture needs\n\tvar textureList;\n\tvar transformList;\n\ttexLoader = new THREE.ImageLoader();\n\tobjRaycast = new THREE.Raycaster();\n\n\t//var perspectiveGeo = map_loadSceneFBX(\"perspectiveGeo05.fbx\", null,'p01',mapScene);\n\t//map_loadSceneFBX(objPath, applyShader=null,meshKey,addToScene){\n\n\t// When the video object loads, set the videoTexture mesh object's height and width\n\tinputVideo = document.getElementById(\"inputVideo\");\n\tinputVideo.onloadedmetadata=(e)=>{\n\t\tinputVideo.play();\n\t}\n\t\n\t// This will not work without a web server!\n\tif(window.location.href.indexOf(\"file://\")==-1){\n\t\tinputVideo.src=\"texturePackTest.mov\";\n\t}\n\t\n\tinputVideo.play();\n\tconsole.log(inputVideo);\n\tvidTexture=new THREE.VideoTexture(inputVideo);\n\tvidTexture.minFilter=THREE.LinearFilter;\n\tvidTexture.magFilter=THREE.LinearFilter;\n\tvidTexture.format=THREE.RGBFormat;\n\t\n\t// Create the video texture object\n\tcreateVideoTextureObject();\n\n\tcreateProjectedObject();\n\tcreateHoloTriangles();\n\n\tvar coreGeo = new THREE.SphereGeometry(1100, 32, 64);\n\tvar coreGeo2 = new THREE.SphereGeometry(950, 32, 64);\n\tvar coreGeo3 = new THREE.SphereGeometry(900, 24, 24);\n\t\n\tvar coreMesh = new THREE.Mesh( coreGeo, coreTextureMaterial );\n\tvar coreMesh2 = new THREE.Mesh( coreGeo2, coreTextureMaterial );\n\tvar coreMesh3 = new THREE.Mesh( coreGeo3, voidMaterial );\n\n\tcoreMesh.rotation.set( 0.2,0,0.4);\n\tcoreMesh2.rotation.set( 0.4,0,0.6);\n\n\tcoreMesh.position.set(0, 1500,-3400);\n\tcoreMesh2.position.set(0, 1501,-3400);\n\tcoreMesh3.position.set(0, 1502,-3400);\n\n\tmapScene.add( coreMesh3 );\n\tmapScene.add( coreMesh2 );\n\tmapScene.add( coreMesh );\n\n\tgeoList['cloud3']=coreMesh3;\n\tgeoList['cloud2']=coreMesh2;\n\tgeoList['cloud1']=coreMesh;\n\n\n\n\t///////////////////////////////////////////////////\n\t// -- LIGHTS -- -- -- -- -- -- -- -- -- -- -- -- //\n\t///////////////////////////////////////////////////\n\n\t//Shadow Maps-\n\tmapEngine.shadowMap.enabled = false;\n\t// Low quality shadows\n\t//\tmapEngine.shadowMap.type=THREE.BasicShadowMap;\n\t// Higher quality shadows\n\t//\tmapEngine.shadowMap.type=THREE.PCFSoftShadowMap;\n\t\n\t// Some lights maybe\n\tvar ambLight=new THREE.AmbientLight(0xffffff,.07);\n\tlightList.push(ambLight);\n\tmapScene.add(ambLight);\n\tvar dirLight=new THREE.DirectionalLight(0xffffff,.4);\n\tdirLight.position.set(1000,550,1200);\n\tlightList.push(dirLight);\n\tmapScene.add(dirLight);\n\tvar dirLightB=new THREE.DirectionalLight(0xffffff,.2);\n\tdirLightB.position.set(-500,750,1500);\n\tlightList.push(dirLightB);\n\tmapScene.add(dirLightB);\n\t\n}", "title": "" }, { "docid": "7ea559dab40aa4fdb824cdb4d9aa193e", "score": "0.5276893", "text": "function drawMap() {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//\r\n\tcontext.clearRect(0,0,window.innerWidth, window.innerHeight);\t\t\t\t// clear the canvas so that links don't build up.\r\n\tfor(var i=0;i<global_areaArray.length;i++) {\t\t\t\t\t\t\t\t// loop through areas\r\n\t\tvar area = document.getElementById(i);\t\t\t\t\t\t\t\t\t// grab area display button with current id [i]\r\n\t\ttry {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// encapsulated in a try statement as Object.keys errors if there are no keys\r\n\t\t\tvar keys = Object.keys(global_areaArray[i].destinations);\t\t\t// grab keys of destinations\r\n\t\t\tfor(var j=0;j<keys.length;j++) {\t\t\t\t\t\t\t\t\t// loop through keys\r\n\t\t\t\tvar destId;\t\t\t\t\t\t\t\t\t\t\t\t\t\t// grab the destination area id, uses if statement as there are two formats of save files (the one where it can be locked [which is incomplete functionality, though I would consider fleshing out properly for the next version] and the one that doesn't have the locked variable)\r\n\t\t\t\tif((x = global_areaArray[i].destinations[keys[j]][0]) != undefined) {\r\n\t\t\t\t\tdestId = x;\t\t\t\t\t\t\t\t\t\t\t\t\t// the locked format\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tdestId = global_areaArray[i].destinations[keys[j]];\t\t\t// the unlocked version\r\n\t\t\t\t}\r\n\t\t\t\t// originally had code to prevent redrawing of lines, though realised that it will probably remove lines which are shared between areas. Will consider rewriting it for the next version.\r\n\t\t\t\tvar pan = document.getElementById(\"pan\");\t\t\t\t\t\t// grab pan \r\n\t\t\t\tvar dest = document.getElementById(destId);\t\t\t\t\t\t// grab element which id corresponds to destId\r\n\t\t\t\tcontext.beginPath();\t\t\t\t\t\t\t\t\t\t\t//begin path for mindmap join. Uses offset from area/dest and pan so that canvas draws it as if from the view of the content viewport -- required as canvas doesn't move, which is good, because otherwise it'd have to constantly resize and that would be horrible.\r\n\t\t\t\tcontext.moveTo(area.offsetLeft + pan.offsetLeft + 10, area.offsetTop + pan.offsetTop + 10);\r\n\t\t\t\tcontext.lineTo(dest.offsetLeft + pan.offsetLeft + 10, dest.offsetTop + pan.offsetTop + 10);\r\n\t\t\t\tcontext.stroke();\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch (err) {};\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// try statement didn't run without the catch, so seems like required syntax\r\n\t}\r\n}", "title": "" }, { "docid": "cdf6cca60c18b6acc8e3e146f6074447", "score": "0.52749467", "text": "function constrainMap(E)\n{\n var VPbounds, URL;\n\n while(!(VPbounds = map.getBounds()))\n ; // Hmmm! Busy wait?\n \n // Check that overlay corners are within ViewPort\n if( !VPbounds.intersects(corners.Bounds[resolution])){\n if(confirm(\"Map Outside ViewPort\\nReCentre?\")){\n map.setView(corners.Centre[resolution]);\n }\n }\n centre = map.getCenter();\n zoom = map.getZoom();\n doUrl();\n}", "title": "" }, { "docid": "613efe8df3bb6f714369d40f0403082e", "score": "0.52658087", "text": "function showMap() {\n\n var URL = '9.jpg';\n\n var texture = THREE.ImageUtils.loadTexture(URL, undefined, function () {\n });\n texture.minFilter = THREE.LinearFilter;\n //console.log(texture);\n var geometry = new THREE.PlaneGeometry(terrainWidth, terrainHeight, origTerrainWidth - 1, origTerrainHeight - 1);\n var material = new THREE.MeshPhongMaterial({\n\tmap: texture,\n\tside: THREE.DoubleSide\n });\n \n var ground = new THREE.Mesh(geometry, material);\n ground.rotation.x = -Math.PI / 2;\n\n map = ground;\n scene.add(map);\n\n showExternalData();\n\n //\n // Ready to show the scene for the user\n //\n render();\n}", "title": "" }, { "docid": "24bca95d9a0af471232680d85c3a1ec0", "score": "0.5236701", "text": "drawMap(map /*maporigin = vMath.vec2()*/) {\n const gl = this.ctx;\n const shader = this._shaders.texturedRect;\n\n if (map.texture.initialized === false) {\n map.texture.glTextureID = this._initTexture(map.texture.source.img);\n map.texture.initialized = true;\n }\n\n gl.useProgram(shader.program);\n\n const vertexPositionAttribute = shader.attribs.aVertexPosition;\n const textureCoordinateAttribute = shader.attribs.aTextureCoord;\n const pUniform = shader.uniforms.uPMatrix;\n const mvUniform = shader.uniforms.uMVMatrix;\n const texSampler = shader.uniforms.uSampler;\n const alpha = shader.uniforms.uAlpha;\n\n const verticesBuffer = shader.buffers.vertices;\n\n const ortherMatrix = mMath.orthographic(0, this._resolution.x, this._resolution.y, 0, 0, 10);\n const pMatrix = new Float32Array(mMath.flatten(ortherMatrix));\n const tMatrix = new Float32Array(mMath.flatten(mMath.compose().done()));\n\n gl.uniformMatrix4fv(pUniform, false, pMatrix);\n gl.uniformMatrix4fv(mvUniform, false, tMatrix);\n\n gl.enableVertexAttribArray(vertexPositionAttribute);\n gl.enableVertexAttribArray(textureCoordinateAttribute);\n\n gl.bindTexture(gl.TEXTURE_2D, this._textures[map.texture.glTextureID]);\n gl.uniform1i(texSampler, 0);\n gl.uniform1f(alpha, 1.0);\n\n // vertex and texture data are interleaved (XYZ UV)\n gl.bindBuffer(gl.ARRAY_BUFFER, verticesBuffer);\n gl.vertexAttribPointer(vertexPositionAttribute, 3, gl.FLOAT, false, 20, 0); // 20 = 5 * sizeof(float)\n gl.vertexAttribPointer(textureCoordinateAttribute, 2, gl.FLOAT, false, 20, 12);// 12 = 3 * sizeof(float)\n\n map.buffers.forEach((layer) => {\n\n const {vertex} = layer;\n\n gl.bufferData(gl.ARRAY_BUFFER, vertex, gl.STATIC_DRAW);\n\n gl.drawArrays(gl.TRIANGLES, 0, vertex.length / 5);\n\n });\n }", "title": "" }, { "docid": "30b84d4fc8ef4b8a92c17934d8e0e0c3", "score": "0.5222692", "text": "function preRenderImage() {\n var tile, tileset, image, x, y, sx, sy, tileOffset, w;\n\n // draw each layer in order\n for (var i = 0, layer; layer = tileEngine.layers[layerOrder[i]]; i++) {\n for (var j = 0, len = layer.data.length; j < len; j++) {\n tile = layer.data[j];\n\n // skip empty tiles (0)\n if (!tile) {\n continue;\n }\n\n tileset = getTileset(tile);\n image = tileset.image;\n\n x = (j % width) * tileWidth;\n y = (j / width | 0) * tileHeight;\n\n tileOffset = tile - tileset.firstGrid;\n w = image.width / tileWidth;\n\n sx = (tileOffset % w) * tileWidth;\n sy = (tileOffset / w | 0) * tileHeight;\n\n offscreenContext.drawImage(\n image,\n sx, sy, tileWidth, tileHeight,\n x, y, tileWidth, tileHeight\n );\n }\n }\n }", "title": "" }, { "docid": "f3fae3fc1eecf1b8dd6e3cb1f886a00e", "score": "0.52184707", "text": "function renderEntity(e) {\n if (isOutOfScreen(e)) {\n return;\n }\n c.strokeStyle = \"black\";\n c.beginPath();\n c.rect(\n (e.x + map.x) * meta.tilesize * meta.ratio | 0,\n (e.y + map.y) * meta.tilesize * meta.ratio | 0,\n e.w * meta.tilesize * meta.ratio | 0,\n e.h * meta.tilesize * meta.ratio | 0\n );\n c.closePath()\n c.stroke();\n}", "title": "" }, { "docid": "1f2a9ea8f8f5b76531978d45f7cfb413", "score": "0.51934934", "text": "function calculateSize(maps) {\n let containerWidth = maps.element.clientWidth;\n let containerHeight = maps.element.clientHeight;\n let parentHeight = maps.element.parentElement.clientHeight;\n let parentWidth = maps.element.parentElement.clientWidth;\n let containerElementWidth = stringToNumber(maps.element.style.width, containerWidth);\n let containerElementHeight = stringToNumber(maps.element.style.height, containerWidth);\n if (maps.width === '0px' || maps.width === '0%' || maps.height === '0%' || maps.height === '0px') {\n maps.availableSize = new Size(0, 0);\n }\n else {\n maps.availableSize = new Size(stringToNumber(maps.width, containerWidth) || containerWidth || containerElementWidth || 600, stringToNumber(maps.height, containerHeight) || containerHeight || containerElementHeight || (maps.isDevice ?\n Math.min(window.innerWidth, window.innerHeight) : 450));\n }\n}", "title": "" }, { "docid": "7f81c312e8d20f1d3e01dc8501db9b51", "score": "0.5190489", "text": "function startRenderer() {\n map = new google.maps.Map(document.getElementById('map'), {\n center: {lat: 52.379189, lng: 4.899431},\n zoom: 6,\n mapTypeId: google.maps.MapTypeId.ROADMAP,\n styles: [\n {elementType: 'geometry', stylers: [{color: '#242f3e'}]},\n {elementType: 'labels.text.stroke', stylers: [{color: '#242f3e'}]},\n {elementType: 'labels.text.fill', stylers: [{color: '#746855'}]},\n {\n featureType: 'administrative.locality',\n elementType: 'labels.text.fill',\n stylers: [{color: '#d59563'}]\n },\n {\n featureType: 'poi',\n elementType: 'labels.text.fill',\n stylers: [{color: '#d59563'}]\n },\n {\n featureType: 'poi.park',\n elementType: 'geometry',\n stylers: [{color: '#263c3f'}]\n },\n {\n featureType: 'poi.park',\n elementType: 'labels.text.fill',\n stylers: [{color: '#6b9a76'}]\n },\n {\n featureType: 'road',\n elementType: 'geometry',\n stylers: [{color: '#38414e'}]\n },\n {\n featureType: 'road',\n elementType: 'geometry.stroke',\n stylers: [{color: '#212a37'}]\n },\n {\n featureType: 'road',\n elementType: 'labels.text.fill',\n stylers: [{color: '#9ca5b3'}]\n },\n {\n featureType: 'road.highway',\n elementType: 'geometry',\n stylers: [{color: '#746855'}]\n },\n {\n featureType: 'road.highway',\n elementType: 'geometry.stroke',\n stylers: [{color: '#1f2835'}]\n },\n {\n featureType: 'road.highway',\n elementType: 'labels.text.fill',\n stylers: [{color: '#f3d19c'}]\n },\n {\n featureType: 'transit',\n elementType: 'geometry',\n stylers: [{color: '#2f3948'}]\n },\n {\n featureType: 'transit.station',\n elementType: 'labels.text.fill',\n stylers: [{color: '#d59563'}]\n },\n {\n featureType: 'water',\n elementType: 'geometry',\n stylers: [{color: '#17263c'}]\n },\n {\n featureType: 'water',\n elementType: 'labels.text.fill',\n stylers: [{color: '#515c6d'}]\n },\n {\n featureType: 'water',\n elementType: 'labels.text.stroke',\n stylers: [{color: '#17263c'}]\n }\n ]\n });\n\n map.addListener('click', function(){\n if(flightPath !== undefined) flightPath.setMap(null); // Clear selected flightpath on click\n });\n\n // Hide flight info by default\n showFlightInfo(false);\n\n // Start the data loop\n requestClientData();\n setInterval(requestClientData, 1000 * 10);\n }", "title": "" }, { "docid": "9c783a8144a4aeb2a3c811a5f0f7414d", "score": "0.51736504", "text": "function drawMap(map){\n\tscaleX = ctx.canvas.width/map[0].length;\n\tscaleY = ctx.canvas.height/map.length;\n\n\n\t$(map).each(function(i){\n\t\tvar y = this;\n\t\t$(y).each(function(j){\n\t\t\tvar valeur = this[0];\n\t\t\t// case vide\n\t\t\tif(valeur == 1){\n\t\t\t\tctx.drawImage(block1,j*scaleX,i*scaleY,scaleX,scaleY);\n\t\t\t}\n\t\t\telse if(valeur == 2){\n\t\t\t\tctx.drawImage(block2,j*scaleX,i*scaleY,scaleX,scaleY);\n\t\t\t}\n\t\t\telse if(valeur == 3){\n\t\t\t\tctx.drawImage(block3,j*scaleX,i*scaleY,scaleX,scaleY);\n\t\t\t}\n\t\t\telse if(valeur == 4){\n\t\t\t\tctx.drawImage(block4,j*scaleX,i*scaleY,scaleX,scaleY);\n\t\t\t}\n\n\t\t});\n\t});\n}", "title": "" }, { "docid": "10ae9493b1c792aeae9696475db24087", "score": "0.51715356", "text": "function createMap() {\n\n // Creates various objects from json strings\n // layoutObject = JSON.parse(layout);\n // segmentsList = JSON.parse(segments);\n // stationsList = JSON.parse(stations);\n // theoricReflectorsList = JSON.parse(theoricReflectors);\n\n // imagePath = 'images' + layoutObject.Background.BackgroundImagePath.replace('.', '');\n // imagePath = \"./map.bag_edited1.png\";\n imagePath = \"./uqm_map_full.png\";\n imageObject = new Image();\n imageObject.src = imagePath;\n // document.body.appendChild(imageObject);\n // IMAGE IS LOADED why use this shit?? to confirm that we load the image??? wtf\n imageObject.onload = function () {\n\n // imageHeight = imageObject.height;\n // imageWidth = imageObject.width;\n\n // MAP OBEJCT\n map = L.map('map', {\n fullscreenControl: true,\n minZoom: -10,\n maxZoom: 4,\n center: [0, 0],\n // zoom: -2,\n contextmenu: true,\n contextmenuWidth: 140,\n crs: L.CRS.Simple // used to change to euclidean coordinates\n });\n\n var myButton = new L.Control.Button(myButtonOptions).addTo(map);\n\n // var southWest = map.unproject([0, imageHeight], map.getMaxZoom());\n // var northEast = map.unproject([imageWidth, 0], map.getMaxZoom());\n // var bounds = new L.LatLngBounds(southWest, northEast);\n // var bounds = [[-26.5,-25/2], [1021.5,1023/2]];\n //\n\n //ok so we specify coordinates of the image in here where we have an\n // euclidean frame with left down corner y,x position and right top corner with y,x easy fucking peasy\n var bounds = [[-26.5, -25], [1021.5, 1023]]; //set this with the resolution*height or width not manually\n // var bounds = [[0,0], [1000,1000]];\n console.log(bounds[0][0]);\n marginBounds=[[bounds[0][0]-margin, bounds[0][0]-margin],[bounds[1][0]+margin,bounds[1][1]+margin]];\n // bounds = bounds\n //bounds in pixels\n // var southWest = map.unproject([0, imageHeight], map.getMaxZoom());\n // var northEast = map.unproject([imageWidth, 0], map.getMaxZoom());\n // var bounds = new L.LatLngBounds(southWest, northEast);\n\n\n\n // LOAD IMAGE AS MAP\n L.imageOverlay(imagePath, bounds).addTo(map);\n map.fitBounds(bounds);\n\n // SET PIXEL MODE// This limits our view. We cant go after this limit. like padding\n // set this to another value so you can scroll the map higher or lower than it should\n map.setMaxBounds(marginBounds);\n // map.fitBounds(bounds);\n\n var sol = L.latLng([145, 175.2]); // position in lat lng of the center to view\n L.marker(sol).addTo(map);\n // map.setView( [70, 1000], 1);\n var zero = L.latLng([0, 0]);\n L.marker(zero).addTo(map);\n\n var zero = L.latLng([450, 50]); //lat lng = y x\n L.marker(zero).addTo(map);\n\n var zero = L.latLng([50, 450]);\n L.marker(zero).addTo(map);\n\n // var zero=L([50,450]);\n // L.marker(zero).addTo(map);\n\n // map.on('click', function(e) { \n // var popLocation= e.latlng;\n // var popup = L.popup()\n // .setLatLng(popLocation)\n // .setContent('oi'+popLocation)\n // .openOn(map); \n // });\n\n\n // map.on(\"click\", function(e) {\n // var latlng = e.latlng;\n // // var pixelPosition = map.latLngToLayerPoint(latlng);\n // var pixelPosition= map.project(latlng,map.getMaxZoom());\n // alert(\"LatLng = \" + latlng + \"\\n Pixel position = \" + pixelPosition);\n // });\n\n\n// console.log(map.getPixelOrigin());\n marker = L.marker([0, 0]).addTo(map);\n\n };\n\n}", "title": "" }, { "docid": "dcbcfdab83850c3ec1f1b4eff1d0987d", "score": "0.5167101", "text": "function redraw() {\n clearContext(ctx);\n\n ctx.drawImage(mapDrawer.canvas, 0, 0);\n\n let pathScale = pathDrawer.getScaleFactor();\n ctx.scale(1 / pathScale, 1 / pathScale);\n ctx.drawImage(pathDrawer.canvas, 0, 0);\n ctx.scale(pathScale, pathScale);\n\n if(location) {\n usingOwnTransform(ctx, (ctx, transform) => {\n location.draw(ctx, transform);\n });\n }\n }", "title": "" }, { "docid": "612bfb026825435601f4c220a85ed017", "score": "0.5166769", "text": "function getMapDimensions() {\n var map = document.getElementById('mapImg');\n\n var height = map.naturalHeight; //calculate the height of the map\n height = (height / (boxWidth + gridWidth)) - 2;\n for (var i = 0; i < height; i++)\n rows.push((i + 1) + \"\");\n\n var width = map.naturalWidth; //calculate the width of the map\n width = (width / (boxWidth + gridWidth)) - 2;\n cols = columnNames.slice(0, width);\n\n updateProgressBar();\n initializeTerrain();\n }", "title": "" }, { "docid": "95181feb4ec0a8cb6814da725436c24c", "score": "0.5164404", "text": "function boundMap(pz) {\n var map = document.getElementById('map-container');\n var t = pz.getTransform();\n var maxX = 0;\n var maxY = 0;\n var minX = w - map.clientWidth*t.scale;\n var minY = h - map.clientHeight*t.scale;\n\n console.log(t);\n\n if (t.x < minX) {\n pz.moveTo(minX, t.y);\n // pz.getTransform().x = minX;\n } else if (t.x > maxX) {\n pz.moveTo(maxX, t.y);\n // pz.getTransform().x = maxX;\n }\n\n if (t.y < minY) {\n pz.moveTo(t.x, minY);\n } else if (t.y > maxY) {\n pz.moveTo(t.x, maxY);\n }\n}", "title": "" }, { "docid": "405ea10ee18947e99fbd349ced6cd00e", "score": "0.5151224", "text": "function createRender() {\n removeRender();\n createPlayerMapImage(mapImageCanvas, fowCanvas);\n }", "title": "" }, { "docid": "f5fe77d654e38bf6a23f3b9180eb3700", "score": "0.5139424", "text": "function Gw2Map() {\n\t// data locals\n\tvar dboMapInfo = {};\n\tvar dboMapZone = {};\n\tvar dboMapRegion = {};\n\tvar dboMapItem = {};\n\tvar dboPublicRegistry = {};\n\tvar dboPoints = {};\n\tvar pimg2tile = {};\n\tvar tile2pimg = {};\n\n\t// locals\n\tvar minZoom = 5;\n\tvar maxZoom = 11;\n\n\tvar markerZoom = 9;\n\tvar waypointZoom = 8;\n\n\tvar mapSize = 0;\n\n\t//var startMapPos = {x: mapSize/2, y: mapSize/2};\n\tvar startMapZoom = 8;\n\n\tvar markersStartVisible = startMapZoom > markerZoom;\n\n\n\n\n\tvar max_zoom = function(){\n\t\treturn maxZoom;\n\t};\n\n\tvar ll2p = function(latlng){\n\t\tvar p = fromLatLngToPoint(latlng, max_zoom());\n\t\tp.x -= (mapSize*8), p.y -= (mapSize*8);\n\t\treturn p;\n\t};\n\n\tvar p2ll = function(point){\n\t\tpoint.x += (mapSize*8), point.y += (mapSize*8);\n\t\treturn fromPointToLatLng(point, max_zoom());\n\t};\n\n\tfunction toLatLng(x,y){\n\t\treturn p2ll(new google.maps.Point(x, y));\n\t}\n\n// Map Declaration\n\tvar gmap;\n\n\n// to translate map coordinates to pixel coordinates to display the mouse-over div for map items\n\n\tvar pixelOverlay;\n// functions to drive the map\n\n\n\tfunction get_caves(pimg) {\n\t\treturn function(coords,zoom){\n\t\t\tvar zOffset = 4;\n\t\t\tvar offset = (1 << (zoom - 1));\n\t\t\tvar actualX = coords.x - offset;\n\t\t\tvar actualY = coords.y - offset;\n\t\t\tvar actualZ = zoom - zOffset;\n\t\t\tif (actualZ != 7) return \"\";\n\t\t\tfor (var i in pimg2tile[pimg]) {\n\t\t\t\tvar pos = pimg2tile[pimg][i].split(\",\");\n\t\t\t\tif (actualX == pos[0] && actualY == pos[1]) {\n\t\t\t\t\treturn \"http://tiles.teichroeb.net/out/pimgs/\"+pimg+\"/\"+actualX+\"/\"+actualY+\".png\";\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn \"\";\n\t\t};\n\t}\n\tfunction get_caves_layer(layer) {\n\t\treturn function(coords,zoom){\n\t\tvar zOffset = 4;\n\t\tvar offset = (1 << (zoom - 1));\n\t\tvar actualX = coords.x - offset;\n\t\tvar actualY = coords.y - offset;\n\t\tvar actualZ = zoom - zOffset;\n\t\tvar pos = actualX + \",\" + actualY;\n\t\tif (actualZ != 7) {\n\t\t\tif (layer == 0) {\n\t\t\t\treturn \"http://tiles.teichroeb.net/out/tiles/1/1/\"+actualZ+\"/\"+actualX+\"/\"+actualY+\".png\";\n\t\t\t} else {\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t}\n\t\tif (pos in tile2pimg) {\n\t\t\tvar pimgs = tile2pimg[pos];\n\t\t\tvar pimg = \"\";\n\t\t\tvar num = 0;\n\t\t\tfor (var i in pimgs) {\n\t\t\t\tvar nextpimg = pimgs[i];\n\t\t\t\tif ((layer == 1 && !(nextpimg in layers)) || layers[nextpimg] == layer) {\n\t\t\t\t\tpimg = nextpimg;\n\t\t\t\t\t++num;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (num == 1) {\n\t\t\t\treturn \"http://tiles.teichroeb.net/out/pimgs/\"+pimg+\"/\"+actualX+\"/\"+actualY+\".png\";\n\t\t\t} if (num > 1) {\n\t\t\t\treturn \"http://tiles.teichroeb.net/red.png\";\n\t\t\t}\n\t\t}\n\t\treturn \"\";\n\t};\n\t}\n\n\tvar get_tile = function(coords,zoom){\n\t\tvar zOffset = 4;\n\t\tvar offset = (1 << (zoom - 1));\n\t\tvar actualX = coords.x - offset;\n\t\tvar actualY = coords.y - offset;\n\t\tvar actualZ = zoom - zOffset;\n\t\tif(actualY < 0 || actualX < 0 || actualY >= (1 << actualZ) || actualX >= (1 << actualZ)){\n\t\t\treturn \"\";\n\t\t}\n\t\treturn \"http://tiles2.teichroeb.net/1/1/\"+actualZ+\"/\"+actualX+\"/\"+actualY+\".jpg\";\n\t};\n\n\tvar pathStyleNormal = {\n\t\teditable: false,\n\t\tmap: gmap,\n\t\tsuppressUndo: true,\n\t\tzIndex: 9,\n\t\tstrokeOpacity: 1,\n\t\tstrokeWeight: 3,\n\t\tstrokeColor: '#4F4',\n\t};\n\n\tvar pathStyleUnderground = {\n\t\teditable: false,\n\t\tmap: gmap,\n\t\tsuppressUndo: true,\n\t\tzIndex: 9,\n\t\tstrokeOpacity: 0,\n\t\tstrokeWeight: 2,\n\t\tstrokeColor: '#F62',\n\t\ticons: [{\n\t\t\ticon: {\n\t\t\t\tpath: 'M 1,-2 1,2 -1,2 -1,-2 z',\n\t\t\t\tfillOpacity: 1,\n\t\t\t\tstrokeWeight: 0,\n\t\t\t},\n\t\t\toffset: '0px',\n\t\t\trepeat: '12px',\n\t\t}],\n\t};\n\n\n// defining map settings\n\n\tvar tile_size = new google.maps.Size(256,256);\n\n\tvar tyria, caves, caves2;\n\n\tvar mapMarkers = {};\n\n\n\tvar dboMapPaths = {}; // paths indexed by zoneid, eventually from an external file\n\t// for testing\n\n\tvar iconTypes = {};\n\n\tvar editing = false;\n\tvar myPath;\n\n\tthis.changeLayer = function(pimg, newlayer) {\n\t\tlayers[pimg] = newlayer;\n\t\tfor (var i = 0; i < numLayers; ++i) {\n\t\t\tgmap.overlayMapTypes.setAt(i, gmap.overlayMapTypes.getAt(i));\n\t\t}\n\t}\n\n\tthis.changeToOverlay = function(pimg) {\n\t\tvar caves = new google.maps.ImageMapType({\n\t\t\tmaxZoom: 11,\n\t\t\talt: \"caves\",\n\t\t\tname: \"caves\",\n\t\t\ttileSize: tile_size,\n\t\t\tgetTileUrl: get_caves(pimg)\n\t\t});\n\t\tgmap.mapTypes.set(\"3\", caves);\n\t\tgmap.overlayMapTypes.setAt(numLayers, caves);\n\t\tvar output = \"\";\n\t\tfor (var i = 0; i < numLayers + 1; ++i) {\n\t\t\toutput += '<input onclick=\"gw2map.changeLayer('+pimg+', '+(i-1)+');\" type=button value=\"'+(i-1)+'\">';\n\t\t}\n\n\t\t$(\"#panel2\").html(output);\n\t}\n\n\tthis.create = function() {\n\t\tgmap = new google.maps.Map(document.getElementById(\"gw2map\") , {\n\t\t\tdisableDoubleClickZoom: true,\n\t\t\tzoom: startMapZoom,\n\t\t\tminZoom: minZoom,\n\t\t\tmaxZoom: maxZoom,\n\t\t\tstreetViewControl: false,\n\t\t\tmapTypeControl: true,\n\t\t\tzoomControlOptions: {\n\t\t\t\tposition: google.maps.ControlPosition.RIGHT_BOTTOM,\n\t\t\t},\n\t\t\t/*mapTypeControlOptions: {\n\t\t\t\tposition: google.maps.ControlPosition.LEFT_BOTTOM,\n\t\t\t\tmapTypeIds: [\"1\",\"2\"]\n},*/\n\t\t\tpanControl: false,\n\t\t\tbackgroundColor: '#000',\n\t\t\tmapTypeId: \"1\", // string for gmaps' sake\n\t\t});\n\n\t\tpixelOverlay = new google.maps.OverlayView();\n\t\tpixelOverlay.draw = function(){};\n\t\tpixelOverlay.setMap(gmap);\n\n\t\ttyria = new google.maps.ImageMapType({\n\t\t\tmaxZoom: 11,\n\t\t\talt: \"Tyria\",\n\t\t\tname: \"Tyria\",\n\t\t\ttileSize: tile_size,\n\t\t\tgetTileUrl: get_tile\n\t\t});\n\n\t\tgmap.mapTypes.set(\"1\",tyria);\n\t\tgmap.overlayMapTypes.insertAt(0, null);\n\t\tfor (var i = numLayers - 1; i >= 0; --i) {\n\t\t\tvar caves2 = new google.maps.ImageMapType({\n\t\t\t\tmaxZoom: 11,\n\t\t\t\talt: \"caves\",\n\t\t\t\tname: \"caves\",\n\t\t\t\ttileSize: tile_size,\n\t\t\t\tgetTileUrl: get_caves_layer(i)\n\t\t\t});\n\t\t\tgmap.overlayMapTypes.insertAt(0, caves2);\n\t\t\tconsole.log(i);\n\t\t}\n//\t\tgmap.mapTypes.set(\"2\",caves2);\n\t\t//gmap.mapTypes.set(\"3\",caves2);\n\n\t\tmapMarkers['waypoint'] = new Array();\n\t\tmapMarkers['landmark'] = new Array();\n\t\tmapMarkers['task'] = new Array();\n\t\tmapMarkers['skill'] = new Array();\n\t\tmapMarkers['vista'] = new Array();\n\n\t\ticonTypes[\"waypoint\"] = {\n\t\t\turl: \"images/icon_waypoint.png\",\n\t\t\tanchor: new google.maps.Point(14,14),\n\t\t\tscaledSize: new google.maps.Size(28,28),\n\t\t};\n\n\t\ticonTypes[\"waypointHover\"] = {\n\t\t\turl: \"images/icon_waypoint_hover.png\",\n\t\t\tanchor: new google.maps.Point(14,14),\n\t\t\tscaledSize: new google.maps.Size(28,28),\n\t\t};\n\n\t\ticonTypes[\"landmark\"] = {\n\t\t\turl: \"images/icon_POI.png\",\n\t\t\tanchor: new google.maps.Point(11,11),\n\t\t\tscaledSize: new google.maps.Size(22,22),\n\t\t};\n\n\t\ticonTypes[\"vista\"] = {\n\t\t\turl: \"images/icon_vista.png\",\n\t\t\tanchor: new google.maps.Point(11,11),\n\t\t\tscaledSize: new google.maps.Size(22,22),\n\t\t};\n\n\t\ticonTypes[\"skill\"] = {\n\t\t\turl: \"images/icon_skillpoint.png\",\n\t\t\tanchor: new google.maps.Point(11,11),\n\t\t\tscaledSize: new google.maps.Size(22,22),\n\t\t};\n\n\t\ticonTypes[\"task\"] = {\n\t\t\turl: \"images/icon_heart.png\",\n\t\t\tanchor: new google.maps.Point(11,11),\n\t\t\tscaledSize: new google.maps.Size(22,22),\n\t\t};\n\n\t\tMarkerMan = new MarkerManager(gmap, {borderPadding: 0});\n\t\tgoogle.maps.event.addListener(MarkerMan, 'loaded', function(){\n\t\t\tfor(var key in mapMarkers){\n\t\t\t\tif(key == 'waypoint'){\n\t\t\t\t\tMarkerMan.addMarkers(mapMarkers[key], waypointZoom);\n\t\t\t\t}else{\n\t\t\t\t\tMarkerMan.addMarkers(mapMarkers[key], markerZoom);\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tMarkerMan.refresh();\n\t\t});\n\n\t\t$('#map_title').hide();\n\n\t\tgoogle.maps.event.addListener(gmap, 'dblclick', function(e){\n\t\t\tvar p = ll2p(e.latLng);\n\t\t\tupdateCurrentZone(p);\n\t\t\tif (typeof URLquery.edit != 'undefined') {\n\t\t\t\tif (editing) {\n\t\t\t\t\tediting = false;\n\t\t\t\t} else {\n\t\t\t\t\tediting = true;\n\t\t\t\t\tmyPath = new MapPath(gmap, {\n\t\t\t\t\t\ttypes: [pathStyleNormal, pathStyleUnderground],\n\t\t\t\t\t\tvertices: [{pos: e.latLng, type: 0}]\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t});\n\n\t\tgoogle.maps.event.addListenerOnce(gmap, 'idle', function(){\n\t\t\t// need to resize to have the whole map show\n\t\t\treadyToStart();\n\n\t\t});\n\n\t\tgoogle.maps.event.addListener(gmap, 'rightclick', function(e){\n\t\t\tvar numTiles = 1 << gmap.getZoom() - 4;\n\t\t\tvar worldCoordinate = ll2p(e.latLng);\n\t\t\tvar coord = {};\n\t\t\tcoord.x = Math.floor((worldCoordinate.x/mapSize)*numTiles );\n\t\t\tcoord.y = Math.floor((worldCoordinate.y/mapSize)*numTiles );\n\n\t\t\tconsole.log('TileX:' +coord.x+' - TileY:'+coord.y);\n\n\t\t\tif (gmap.getZoom() == 11) {\n\t\t\t\tvar index =coord.x + \",\" + coord.y;\n\t\t\t\tvar pimgs = tile2pimg[index];\n\t\t\t\tvar output = \"\";\n\t\t\t\tfor (var i in pimgs) {\n\t\t\t\t\tvar pimg = pimgs[i];\n\t\t\t\t\toutput += '<input onclick=\"gw2map.changeToOverlay('+pimg+');\" type=button value=\"Use '+pimg+'\">';\n\t\t\t\t}\n\t\t\t\t$(\"#panel\").html(output);\n\t\t\t}\n\n\t\t\tif (editing == true) {\n\t\t\t\tmyPath.push(e.latLng, 0);\n\t\t\t}\n\t\t});\n\n\t\tupdateControls();\n\t}\n\n\n\tfunction makeOverFunc(target){\n\t\treturn function(e){\n\t\t\t// waypoint icon\n\t\t\tif(target.mapItem.type == \"waypoint\"){\n\t\t\t\ttarget.setIcon(iconTypes['waypointHover']);\n\t\t\t}\n\t\t\t// task special name\n\t\t\tif(target.mapItem.type == \"task\"){\n\t\t\t\t$('#hover_window').html(target.mapItem.name + String.fromCharCode(160,160) + \"<font style='color:#BBB;font-size:0.9em;'>(\" + target.mapItem.level + \")</font>\");\n\t\t\t}else{\n\t\t\t\t$('#hover_window').html(target.mapItem.name);\n\t\t\t}\n\t\t\t// show pop-up text\n\t\t\t$('#hover_window').stop().fadeIn({\n\t\t\t\tduration:200,\n\t\t\t\tqueue: false,\n\t\t\t});\n\t\t\t// get future position and current size of textbox\n\t\t\tvar proj = pixelOverlay.getProjection();\n\t\t\tvar pixel = proj.fromLatLngToContainerPixel(target.getPosition());\n\t\t\tvar docWidth = $(window).width();\n\t\t\tvar floatWidth = $('#hover_window').width();\n\t\t\t// if textbox is going to overflow, flip it to go the other direction\n\t\t\tif(Math.round(pixel.x) + floatWidth + 20 >= docWidth){\n\t\t\t\t$('#hover_window').css({\n\t\t\t\t\ttop: (Math.round(pixel.y) - 45) + \"px\",\n\t\t\t\t\tleft: (Math.round(pixel.x) - (floatWidth + 10) ) + \"px\",\n\t\t\t\t});\n\t\t\t}else{ // otherwise go normal direction\n\t\t\t\t$('#hover_window').css({\n\t\t\t\t\ttop: (Math.round(pixel.y) - 45) + \"px\",\n\t\t\t\t\tleft: (Math.round(pixel.x) + 0) + \"px\",\n\t\t\t\t});\n\t\t\t}\n\n\n\n\t\t};\n\t}\n\n\tfunction makeOutFunc(target){\n\t\treturn function(e){\n\t\t\tif(target.mapItem.type == \"waypoint\"){\n\t\t\t\ttarget.setIcon(iconTypes['waypoint']);\n\t\t\t}\n\t\t\t$('#hover_window').stop().fadeOut({\n\t\t\t\tduration:200,\n\t\t\t\tqueue: false,\n\t\t\t});\n\t\t};\n\t}\n\n\tfunction makeClickFunc(target){\n\t\treturn function(e){\n\t\t\t$('#dialog_title').text(target.mapItem.name);\n\n\t\t\tvar url = window.location.pathname + \"?target=\" + target.mapItem.pubid;\n\n\t\t\tvar output = \"<p>Direct Link: <a href='\"+url+\"' onClick='return gw2map.clickTarget(event, \\\"\"+url+\"\\\");'>\" + target.mapItem.pubid + \"</a></p>\";\n\n\t\t\tif(target.mapItem.type == \"waypoint\" || target.mapItem.type == \"landmark\"){\n\t\t\t\toutput += \"<p>Chat Code: \" + toChatCode(target.mapItem.itemid).replace('&', '&amp;') + \"</p>\";\n\n\t\t\t\toutput += \"<p>ID Code: \" + target.mapItem.itemid;\n\t\t\t}\n\n\t\t\t$('#dialog_content').html(output);\n\n\t\t\tif(!$('#dialog_window').is(':visible'))\n\t\t\t{\n\t\t\t\t$('#dialog_window').fadeIn();\n\n\t\t\t\t$('#dialog_window').css({\n\t\t\t\t\t'left': (($(window).width() - $('#dialog_window').width())/2) + 'px',\n\t\t\t\t\t'top': (($(window).height() - $('#dialog_window').height())/2) + 'px'\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction gotoTarget(target) {\n\t\twindow.history.pushState({},\"\", target);\n\t\tURLquery = loadQuery();\n\t\tprocessTarget();\n\t}\n\n\tthis.clickTarget = function(event, target) {\n\t\tif (event.button != 0) {\n\t\t\treturn true;\n\t\t}\n\t\tgotoTarget(target);\n\t\treturn false;\n\t}\n\n\n\tvar startCount = 0;\n\tfunction readyToStart() {\n\t\t++startCount;\n\t\tif (startCount == 2) {\n\t\t\tShowUI();\n\t\t\tAddItemToControl(\"default\", \"Guild Wars 2 Traveller\", 'images/icon_waypoint.png', \"Double-click a zone to get started\", \"linear-gradient(to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.8) 100%)\");\n\n\t\t\tgoogle.maps.event.trigger(gmap, 'resize');\n\t\t\tgmap.setCenter(toLatLng(mapSize/2,mapSize/2));\n\n\t\t\tprocessTarget();\n\t\t}\n\t}\n\n\tthis.dataLoaded = function(data) {\n\t\tdboMapInfo = data.get('dboMapInfo');\n\t\tdboMapZone = data.get('dboMapZone');\n\t\tdboMapRegion = data.get('dboMapRegion');\n\t\tdboMapItem = data.get('dboMapItem');\n\t\tdboPublicRegistry = data.get('dboPublicRegistry');\n\t\tdboPoints = data.get('dboPoints');\n\t\tpimg2tile = data.get('pimg2tile');\n\t\ttile2pimg = data.get('tile2pimg');\n\t\tprocessData();\n\n\t\treadyToStart();\n\t}\n\n\tfunction processTarget() {\n\t\tvar pos = {};\n\t\tvar zoom;\n\t\t// process target\n\t\tif(typeof URLquery.target != 'undefined'){\n\t\t\tfor(var i = 0; i < URLquery.target.length; ++i)\n\t\t\t{\n\t\t\t\t// try each target in order\n\t\t\t\t// is it an pubid target?\n\t\t\t\tif(URLquery.target[i] in dboPublicRegistry)\n\t\t\t\t{\n\t\t\t\t\tvar entry = dboPublicRegistry[URLquery.target[i]];\n\t\t\t\t\tif(entry.type == \"item\"){\n\t\t\t\t\t\tvar itemData = dboMapItem[entry.localid];\n\t\t\t\t\t\tpos = itemData.pos;\n\t\t\t\t\t\tUpdateTitle(itemData.name);\n\t\t\t\t\t\tif(typeof URLquery.zoom == 'undefined'){\n\t\t\t\t\t\t\tzoom = maxZoom;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}else if(entry.type == \"zone\"){\n\t\t\t\t\t\tvar zoneData = dboMapZone[entry.localid];\n\t\t\t\t\t\tpos = {x: (zoneData.area.right + zoneData.area.left) / 2, y: (zoneData.area.bottom + zoneData.area.top) / 2};\n\t\t\t\t\t\tUpdateTitle(zoneData.name);\n\t\t\t\t\t\tif(typeof URLquery.zoom == 'undefined'){\n\t\t\t\t\t\t\tzoom = maxZoom;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}else if(entry.type == \"region\"){\n\t\t\t\t\t\tvar regionData = dboMapRegion[entry.localid];\n\t\t\t\t\t\tpos = regionData.label;\n\t\t\t\t\t\tUpdateTitle(regionData.name);\n\t\t\t\t\t\tif(typeof URLquery.zoom == 'undefined'){\n\t\t\t\t\t\t\tzoom = maxZoom;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}else\n\t\t\t\t{\n\t\t\t\t\t// position data, check if formatted as \"number,number\"\n\t\t\t\t\tvar match = URLquery.target[i].match(/(\\d.*)\\,(\\d.*)/);\n\n\t\t\t\t\tif(match){\n\t\t\t\t\t\tvar tempX = parseInt(match[1], 10);\n\t\t\t\t\t\tvar tempY = parseInt(match[2], 10);\n\t\t\t\t\t\tif(tempX && tempY){\n\t\t\t\t\t\t\tpos = {x: tempX, y: tempY};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(typeof pos.x !== 'undefined' && typeof pos.y !== 'undefined')\n\t\t{\n\t\t\tgmap.setCenter(toLatLng(pos.x,pos.y));\n\t\t}else{\n\t\t\tUpdateTitle(); // set to default\n\t\t}\n\n\t\t// process zoom\n\t\tif(typeof URLquery.zoom != 'undefined'){\n\t\t\tfor(var i = 0; i < URLquery.zoom.length; ++i){\n\t\t\t\tvar tempZoom = parseInt(URLquery.zoom[i]);\n\t\t\t\tif(tempZoom && tempZoom >= minZoom && tempZoom <= maxZoom){\n\t\t\t\t\tzoom = tempZoom;\n\t\t\t\t\tmarkersStartVisible = startMapZoom > markerZoom;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(typeof zoom !== 'undefined'){\n\t\t\tgmap.setZoom(zoom);\n\t\t}\n\n\t}\n\n\tfunction processData() {\n\t\tmapSize = Math.max(dboMapInfo.size.x, dboMapInfo.size.y);\n\n\t\tfor(var key in dboMapRegion) {\n\t\t\tvar region = dboMapRegion[key];\n\n\t\t\tnew MapLabel({\n\t\t\t\tmap: gmap,\n\t\t\t\tfontColor: '#d6bb70',\n\t\t\t\tfontSize: 24,\n\t\t\t\tfontFamily: 'Menomonia',\n\t\t\t\tstrokeWeight: 3,\n\t\t\t\tstrokeColor: '#000',\n\t\t\t\tmaxZoom: 6,\n\t\t\t\tminZoom: 6,\n\t\t\t\tposition: toLatLng(region.label.x, region.label.y),\n\t\t\t\ttext: region.name,\n\t\t\t\tzIndex: 100,\n\t\t\t});\n\t\t}\n\n\t\tfor(var key in dboMapZone) {\n\t\t\tdboMapPaths[key] = {};\n\t\t\tdboMapPaths[key]['0'] = {name: \"Map Exploration\"};\n\t\t}\n\t\t// for each zone\n\t\tfor(var key in dboMapZone){\n\t\t\tvar zone = dboMapZone[key];\n\n\t\t\tnew MapLabel({\n\t\t\t\tmap: gmap,\n\t\t\t\tfontColor: '#d6bb70',\n\t\t\t\tfontSize: 24,\n\t\t\t\tfontFamily: 'Menomonia',\n\t\t\t\tstrokeWeight: 3,\n\t\t\t\tstrokeColor: '#000',\n\t\t\t\tmaxZoom: 9,\n\t\t\t\tminZoom: 7,\n\t\t\t\tposition: toLatLng((zone.area.left + zone.area.right) / 2, (zone.area.top + zone.area.bottom) / 2),\n\t\t\t\ttext: zone.name,\n\t\t\t\tlevel: zone.level.min == 0 ? null : \"(\" + zone.level.min + \" - \" + zone.level.max + \")\",\n\t\t\t\tlevelColor: '#777',\n\t\t\t\tlevelSize: 20,\n\t\t\t\tzIndex: 100,\n\t\t\t});\n\t\t}\n\n\t\tfor(var key in dboMapItem){\n\t\t\tvar item = dboMapItem[key];\n\n\t\t\tvar itemName = item.name;\n\t\t\tif(item.type == 'task'){\n\t\t\t\titemName += String.fromCharCode(160,160) + \"<font style='color:#BBB;font-size:0.9em;'>(\" + item.level + \")</font>\";\n\t\t\t}\n\n\t\t\tif(typeof iconTypes[item.type] != 'undefined'){\n\t\t\t\tvar tempMarker = new google.maps.Marker({\n\t\t\t\t\tposition: toLatLng(item.pos.x, item.pos.y),\n\t\t\t\t\tdraggable: false,\n\t\t\t\t\ticon: iconTypes[item.type],\n\t\t\t\t\tmapItem: item,\n\t\t\t\t\tzIndex: 100,\n\t\t\t\t});\n\n\t\t\t\tgoogle.maps.event.addListener(tempMarker, \"mouseover\", makeOverFunc(tempMarker));\n\t\t\t\tgoogle.maps.event.addListener(tempMarker, \"mouseout\", makeOutFunc(tempMarker));\n\t\t\t\tgoogle.maps.event.addListener(tempMarker, \"click\", makeClickFunc(tempMarker));\n\n\t\t\t\tmapMarkers[item.type].push(tempMarker);\n\t\t\t}\n\t\t}\n\n\n\t\tfor (key in dboPoints) {\n\t\t\tvar line = dboPoints[key];\n\t\t\tvar verts = [];\n\t\t\tfor (var vertkey in line.vertices) {\n\t\t\t\tvar vert = line.vertices[vertkey];\n\t\t\t\tverts.push({\n\t\t\t\t\t\t\t\tpos: p2ll(new google.maps.Point(vert.x, vert.y)),\n\t\t\t\t\t\t\t\ttype: vert.type,\n\t\t\t\t\t\t\t});\n\t\t\t}\n\t\t\tvar myPath = new MapPath(gmap, {\n\t\t\t\ttypes: [pathStyleNormal, pathStyleUnderground],\n\t\t\t\tvertices: verts\n\t\t\t});\n\t\t}\n\t}\n\n\tvar MarkerMan;\n\n\t// map center\n\t// hold map in place\n\t/*google.maps.event.addListener(gmap, 'center_changed', function(){\n\t\tvar bounds = gmap.getBounds();\n\t\tvar ne = ll2p(bounds.getNorthEast());\n\t\tvar sw = ll2p(bounds.getSouthWest());\n\t\tvar pos = ll2p(gmap.getCenter());\n\t\t//console.log(\"center: \" + pos.x + \", \" + pos.y);\n\t\t//console.log(\"NE: \" + ne.x + \", \" + ne.y);\n\t\t//console.log(\"SW: \" + sw.x + \", \" + sw.y);\n\n\t\tvar force = false;\n\n\t\tif(sw.y - ne.y >= mapSize){\n\t\t\tif(pos.y != mapSize/2){\n\t\t\t\tpos.y = mapSize/2;\n\t\t\t\tforce = true;\n\t\t\t}\n\t\t}else if(ne.y < 0){\n\t\t\tpos.y -= ne.y;\n\t\t\tforce = true;\n\t\t}else if(sw.y > mapSize){\n\t\t\tpos.y -= (sw.y - mapSize);\n\t\t\tforce = true;\n\t\t}\n\n\t\tif(ne.x - sw.x >= mapSize){\n\t\t\tif(pos.x != mapSize/2){\n\t\t\t\tpos.x = mapSize/2;\n\t\t\t\tforce = true;\n\t\t\t}\n\t\t}else if(sw.x < 0){\n\t\t\tpos.x -= sw.x;\n\t\t\tforce = true;\n\t\t}else if(ne.x > mapSize){\n\t\t\tpos.x -= (ne.x - mapSize);\n\t\t\tforce = true;\n\t\t}\n\n\t\tif(force == true){\n\t\t\t//console.log(\"set center: \" + pos.x + \", \" + pos.y);\n\t\t\tgmap.setCenter(p2ll(pos));\n\n\t\t}\n\n\t});*/\n\n\t// detect zone stuff\n\n\tvar currentZone = null;\n\tvar isEditMode = false;\n\tvar isLocked = false;\n\n\tfunction updateControls(){\n\t\t//RemoveAllItemsFromControl();\n\t\tif(currentZone != null){\n\t\t\t// get paths in the zone\n\t\t\tif(currentZone.zoneid in dboMapPaths && dboMapPaths[currentZone.zoneid].length != 0){\n\t\t\t\tvar currentPaths = dboMapPaths[currentZone.zoneid];\n\t\t\t\tfor(var key in currentPaths){\n\t\t\t\t\tvar path = currentPaths[key];\n\t\t\t\t\tAddItemToControl(currentZone.zoneid, currentZone.name, 'images/icon_vista.png', path.name, \"linear-gradient(to right, rgba(0,128,0,0) 0%, rgba(0,128,0,0.5) 100%)\");\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tAddItemToControl(currentZone.zoneid, currentZone.name, 'images/icon_heart.png', \"There are no paths for this zone\", \"linear-gradient(to right, rgba(128,0,0,0) 0%, rgba(128,0,0,0.8) 100%)\");\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction updateCurrentZone(p){\n\t\tif(currentZone == null ||\n\t\t\t(\n\t\t\t\tcurrentZone.area.top >= p.y ||\n\t\t\t\tcurrentZone.area.bottom <= p.y ||\n\t\t\t\tcurrentZone.area.left >= p.x ||\n\t\t\t\tcurrentZone.area.right <= p.x\n\t\t\t))\n\t\t{\n\t\t\tfor(var key in dboMapZone){\n\t\t\t\tvar zone = dboMapZone[key];\n\n\t\t\t\tif(zone.area.top < p.y &&\n\t\t\t\t\tzone.area.bottom > p.y &&\n\t\t\t\t\tzone.area.left < p.x &&\n\t\t\t\t\tzone.area.right > p.x)\n\t\t\t\t{\n\t\t\t\t\tcurrentZone = zone;\n\t\t\t\t\t//$('#map_title').show()\n\t\t\t\t\t//$('#map_title_content').text(zone.name);\n\n\t\t\t\t\tupdateControls();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//currentZone = null;\n\t\t\t//updateControls();\n\t\t\t//$('#map_title').hide();\n\t\t}\n\t};\n\n}", "title": "" }, { "docid": "bab6b1bc4bd6cef9ad784fae4b2ac676", "score": "0.5127055", "text": "function loadMap() {\n console.log(\"LOADING ROOM... \"+ _searched_rooms[_index][0].label);\n _floor = _searched_rooms[_index][1]; // we assign the floor number to this global variable in order to decide what map to show later on.\n _sameFloor = true; // we want to load the desstination image first and in the front side of the jQuery flip plugin.\n _allowYOUlabel = false; // we reset the boolean\n if (!_front) {switchMaps();} // we reset the variable to its original value\n if (_personRoomTouched) {clearTimeout(_personRoomTouchedTimerID); _personRoomTouchedTimerID = setTimeout(function() {_personRoomTouched = false;}, 1000);} // This prevents the liveSearchResults div from appearing when a SPA page is changed and a search is still on the go.\n $(window.location.hash + \" input.input_search_bar\")[0].value = _searched_rooms[_index][0].label; // Write the number of the room in the searchbar\n\n retrieveMap(_floor, function () { // Here we are retrieving the map corresponding to the floor given by the room[] array.\n locateUser(); // This call executes all the algorithms to locate the person on the map (trilateration, drawing points and labels etc.)\n\n // We draw the orange destination image point on the map and the corresponding label too:\n var dest_circle = document.getElementById(\"destinationPoint_circle\");\n var dest_label = document.getElementById(\"p_dest_label\");\n dest_circle.style.visibility=\"visible\";\n dest_circle.style.left = parseInt(_searched_rooms[_index][0].x) - 35 +_paddingMap +\"px\"; // '35' is the radius of the circle's image declared at map.html. It is necessary to make the circle centered.\n dest_circle.style.top = parseInt(_searched_rooms[_index][0].y) - 35 +_paddingMap +\"px\"; // '35' is the radius of the circle's image declared at map.html. It is necessary to make the circle centered.\n dest_label.style.left= parseInt(_searched_rooms[_index][0].x) + 40 +_paddingMap +\"px\";\n dest_label.style.top= parseInt(_searched_rooms[_index][0].y) + 40 +_paddingMap +\"px\";\n dest_label.innerHTML=_searched_rooms[_index][0].label;\n dest_label.style.visibility=\"visible\";\n _destX = _searched_rooms[_index][0].x; // Coordinate X of destination office/room\n _destY = _searched_rooms[_index][0].y; // Coordinate Y of destination office/room\n\n // Now, we pan over the floor image to show the corresponding spot to the user:\n // This is done thanks to the Event Listener attached to the 'img' DOM element with Id: \"map\".\n // So, at this moment in the code, panANDzoom should be called!\n\n // Now, at the end, we try to silently log in to user's Google account in case he/she logged in before:\n silentLoginOAuth();\n });\n}", "title": "" }, { "docid": "6d2c70d67a8ccd414530d2c58a763fcf", "score": "0.5122067", "text": "function renderMap()\n{\n\tme = new google.maps.LatLng(latLoc, longLoc);\n\tmap.panTo(me);\n request.open(\"GET\", \"http://mbtamap.herokuapp.com/mapper/rodeo.json\", true);\n request.send(null);\n request.onreadystatechange = callback;\n}", "title": "" }, { "docid": "f0c5477e1f39e0704c2b28d8130a3790", "score": "0.51218253", "text": "function calculateMapSize()\n{\n return {\n height: Math.floor((innerHeight - (innerHeight / 100 * 7)) / cellSize),\n width: Math.floor(window.innerWidth / cellSize),\n }\n}", "title": "" }, { "docid": "5ac56e525332e25e1578a5be5741d969", "score": "0.5110765", "text": "function drawMap() {\n map = document.createElement('div');\n\n let tiles = createTiles(gameData);\n for (let tile of tiles) {\n map.appendChild(tile);\n }\n\n document.body.appendChild(map);\n}", "title": "" }, { "docid": "9e3cf0735d169e03088c5a162211ef7b", "score": "0.5110217", "text": "render() {\n\n const mapstyles = {\n width: '75%',\n height: '50%',\n marginLeft: 'auto',\n marginRight: 'auto'\n \n };\n \n this.GetBoundies();\n return (\n // takes in various parameters for\n\n <Map\n onClick={this.onMapClicked}\n google={this.props.google}\n style={mapstyles}\n initialCenter={{\n lat: this.state.lat,\n lng: this.state.lng\n }}\n center={{\n lat: this.state.lat,\n lng: this.state.lng\n }}\n bounds={window.bounds}\n >\n {this.props.properties.map(property => (\n <Marker\n Key={property.guid}\n onClick={(props, marker) =>\n this.onMarkerClick(props, marker, property.guid)\n }\n position={{ lat: property.lat, lng: property.lng }}\n />\n ))}\n <InfoWindow\n marker={this.state.activeMarker}\n visible={this.state.showingInfoWindow}\n >\n <div>\n <p>{this.state.InforMarkerAddress}</p>\n </div>\n </InfoWindow>\n </Map>\n );\n }", "title": "" }, { "docid": "daff17c84738107980540f71289ebedc", "score": "0.51041704", "text": "function sizeMap() {\n var containerWidth = $(\"#mapContainer\").width();\n var containerHeight = (containerWidth / 1.4);\n // $log.debug(\"vmap width:\", containerWidth, \" height:\", containerHeight);\n // console.log(\"vmap width:\", containerWidth, \" height:\", containerHeight);\n $('#vmap').css({\n 'width': containerWidth,\n 'height': containerHeight\n });\n }", "title": "" }, { "docid": "82ac08eb5b04be6f221f2682a5ea4110", "score": "0.5091294", "text": "function drawDirectionsMap(){\n showLoading(\"Preparazione mappa\");\n try{\n\n var mapContent = $(\"#map_directions_canvas\");\n //Svuoto gli elementi\n mapContent.empty();\n $(\"#directionsPanel\").empty();\n\n mapContent.css(\"height\", $(window).height() / 2);\n mapContent.css(\"width\", $(window).width() - 30);\n\n goToDirectionsMap();\n \n }catch(e) {\n hideLoading();\n debugAlert(e.toString());\n }\n}", "title": "" }, { "docid": "c606236bf8fe830cc9f8a0f7b96359a5", "score": "0.50882757", "text": "_RenderShapeCanvas( _region )\n {\n let _obj = _region.obj_mimagemap;\n let _coords = _region.obj_mimagemap_coords;\n let _context = _obj.canvas_context;\n\n _context.beginPath();\n \n switch( _region.shape )\n {\n case 'poly':\n\n _context.moveTo( _coords[0], _coords[1] );\n\n for( let x = 2; x < _coords.length; x+=2 )\n _context.lineTo( _coords[x], _coords[x+1] );\n\n _context.lineTo( _coords[0], _coords[1] );\n\n break;\n\n case 'rect':\n _context.rect( _coords[0], _coords[1], _coords[2]-_coords[0], _coords[3]-_coords[1] );\n break;\n\n case 'circ':\n case 'circle':\n _context.arc( _coords[0], _coords[1], _coords[2], 0, 2 * Math.PI, false );\n break;\n }\n\n _context.closePath();\n\n if( _region.obj_imagemap_stroke_width > 0 )\n {\n _context.lineWidth = _region.obj_imagemap_stroke_width;\n _context.strokeStyle = _region.obj_imagemap_stroke_color;\n _context.stroke();\n }\n\n if( _region.obj_imagemap_fill_color.length > 3 )\n {\n _context.fillStyle = _region.obj_imagemap_fill_color;\n _context.fill();\n }\n\n }", "title": "" }, { "docid": "29960c02e9b7c6eca17064c0c1a82605", "score": "0.5085554", "text": "function drawMap() {\n\t\tvar map = L.map('container').setView([47.505, -121.09], 7);\n\n\t\tL.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', \n\t\t\t{attribution: '&copy; <a href=\"http://osm.org/copyright\">' \n\t\t\t+ 'OpenStreetMap</a> contributors'}).addTo(map);\n\n\t\tgetData(map);\n\t}", "title": "" }, { "docid": "021b90511b542c70019d6dd44b4293c0", "score": "0.50803816", "text": "render() {\n if (!this.map) {\n return;\n }\n this.map.renderLayer('dynamic');\n this.player.render();\n this.balls.forEach((ball) => {\n ball.render();\n });\n }", "title": "" }, { "docid": "af2b526197d08d567982fd1fd31e5c0d", "score": "0.50703245", "text": "function _drawMap(svg, render) {\n\trender.rivers = getRivers(render.h, 0.01);\n\trender.coasts = contour(render.h, 0);\n\tdrawPaths(svg, 'river', render.rivers);\n\tdrawPaths(svg, 'coast', render.coasts);\n\tvisualizeSlopes(svg, render);\n\tvisualizeCities(svg, render);\n\tdrawLabels(svg, render);\n}", "title": "" }, { "docid": "ee12dba848f275f4e6f034832d429f28", "score": "0.5065263", "text": "function PrintMap() {\n const WorldMap = document.getElementById(\"WorldMap\"),\n World = WorldMap.getContext(\"2d\"),\n Width = WorldMap.width * 0.2,\n Height = WorldMap.height * 0.2;\n World.globalAlpha = 1;\n\n function TileImagePainter(x, y, image) {\n if (typeof OWImages[image] !== 'undefined') {\n World.drawImage(OWImages[image], WorldMap.width * (0.2 * x), WorldMap.height * (0.2 * y), Width, Height);\n } else if (typeof Tiles_images[image] !== \"undefined\") {\n World.drawImage(Tiles_images[image], WorldMap.width * (0.2 * x), WorldMap.height * (0.2 * y), Width, Height);\n } else {\n TilePainter(x, y);\n }\n }\n\n function TilePainter(x, y) {\n World.fillStyle = Settings.MapColor;\n World.fillRect(WorldMap.width * (0.2 * x), WorldMap.height * (0.2 * y), Width, Height);\n\n World.fillStyle = Settings.BorderColor;\n World.strokeRect(WorldMap.width * (0.2 * x), WorldMap.height * (0.2 * y), Width, Height);\n }\n // Tool to highlight current map on mini-map\n function CurrentTile(x, y) {\n World.globalAlpha = 0.5;\n World.fillStyle = \"red\";\n World.fillRect(WorldMap.width * (0.2 * x), WorldMap.height * (0.2 * y), Width, Height);\n }\n World.fillStyle = \"black\";\n World.fillRect(0, 0, WorldMap.width, WorldMap.height);\n\n World.strokeStyle = \"red\";\n switch (player.Area) {\n case \"First\":\n TileImagePainter(0, 1, \"OWStart\");\n TileImagePainter(1, 1, \"OWRTC\"); //RTC1\n TileImagePainter(1, 0, \"OWBandit\"); //Bandit\n TileImagePainter(1, 2, \"OWRTC2\"); //RTC2\n TileImagePainter(2, 2, \"OWCity\"); //City\n TileImagePainter(3, 2, \"OWRTH\"); //RTH\n TileImagePainter(2, 3, \"OWForest\"); //Forest\n TileImagePainter(2, 4, \"OWForest2\"); //Forest2\n TileImagePainter(3, 1, \"OWRTW\"); //RTW\n TileImagePainter(3, 0, \"OWRTW2\"); //RTW2\n TileImagePainter(4, 0, \"OWWitch\"); //Witch\n World.font = \"2em Arial\";\n if (typeof MapIcons.skull_01 !== 'undefined') {\n World.drawImage(MapIcons.skull_01, WorldMap.width * 0.25, WorldMap.height * 0.05, Width / 2, Height / 2);\n } else {\n World.strokeText(\"B\", WorldMap.width * 0.27, WorldMap.height * 0.17, Width / 2, Height / 2);\n }\n if (House.Owned == true) {\n TilePainter(4, 2, WorldMap.width * 0.2, WorldMap.height * 0.2);\n if (typeof MapIcons.Home !== 'undefined') {\n World.drawImage(MapIcons.Home, WorldMap.width * 0.85, WorldMap.height * 0.45, Width / 2, Height / 2);\n } else {\n World.strokeText(\"H\", WorldMap.width * 0.87, WorldMap.height * 0.57);\n }\n }\n\n World.font = \"1em Arial\";\n World.strokeText(\"⇩\", WorldMap.width * 0.485, WorldMap.height)\n\n\n switch (player.Map) {\n case \"Start\":\n CurrentTile(0, 1);\n break;\n case \"RoadToCity\":\n CurrentTile(1, 1);\n break;\n case \"Bandit\":\n CurrentTile(1, 0);\n break;\n case \"RoadToCity2\":\n CurrentTile(1, 2);\n break;\n case \"City\":\n CurrentTile(2, 2);\n break;\n case \"RoadToHome\":\n CurrentTile(3, 2);\n break;\n case \"RoadToWitch\":\n CurrentTile(3, 1);\n break;\n case \"RoadToWitch2\":\n CurrentTile(3, 0);\n break;\n case \"Witch\":\n CurrentTile(4, 0);\n break;\n case \"Forest\":\n CurrentTile(2, 3);\n break;\n case \"Forest2\":\n CurrentTile(2, 4);\n break;\n }\n break;\n case \"Second\":\n TileImagePainter(2, 0, \"OWPTO\");\n TileImagePainter(1, 0, \"OWCave1\");\n TileImagePainter(0, 0, \"Cave2\");\n TileImagePainter(0, 1, \"Cave3\");\n TileImagePainter(0, 2, \"Cave4\");\n TileImagePainter(2, 1, \"OWPTO2\");\n TileImagePainter(2, 2, \"OWOutlaws\");\n TileImagePainter(3, 1, \"OWFarm\");\n World.font = \"2em Arial\";\n World.strokeText(\"O\", WorldMap.width * 0.46, WorldMap.height * 0.57);\n World.strokeText(\"F\", WorldMap.width * 0.66, WorldMap.height * 0.37);\n\n World.font = \"1em Arial\";\n World.strokeText(\"⇧\", WorldMap.width * 0.485, WorldMap.height * 0.07)\n\n switch (player.Map) {\n case \"PathToOutlaws\":\n CurrentTile(2, 0);\n break;\n case \"PathToOutlaws2\":\n CurrentTile(2, 1);\n break;\n case \"Farm\":\n CurrentTile(3, 1);\n break;\n case \"Outlaws\":\n CurrentTile(2, 2);\n break;\n case \"Cave1\":\n CurrentTile(1, 0);\n break;\n case \"Cave2\":\n CurrentTile(0, 0);\n break;\n case \"Cave3\":\n CurrentTile(0, 1);\n break;\n case \"Cave4\":\n CurrentTile(0, 2);\n break;\n }\n break;\n case \"Mountain\":\n TileImagePainter(1, 2, \"MountainShrinePath\");\n TileImagePainter(0, 2, \"MountainShrine\");\n TileImagePainter(2, 2, \"MountainStart\");\n TileImagePainter(2, 3, \"MountainClimb\");\n TileImagePainter(2, 4, \"MountainClimb2\");\n TileImagePainter(3, 4, \"MountainClimb3\");\n TileImagePainter(4, 4, \"MountainClimb4\");\n TileImagePainter(4, 3, \"MountainClimb5\");\n TileImagePainter(4, 2, \"MountainClimb6\");\n TileImagePainter(4, 1, \"MountainClimb7\");\n TileImagePainter(4, 0, \"MountainClimb8\");\n TileImagePainter(3, 0, \"MountainClimb9\");\n TileImagePainter(2, 0, \"MountainPlateau\");\n //World.font = \"1em Arial\";\n //World.strokeText(\"⇧\", WorldMap.width * 0.485, WorldMap.height * 0.07)\n //World.strokeText(\"⇦\", 0, WorldMap.height * 0.525)\n switch (player.Map) {\n case \"MountainStart\":\n CurrentTile(2, 2);\n break;\n case \"MountainShrinePath\":\n CurrentTile(1, 2);\n break;\n case \"MountainShrine\":\n CurrentTile(0, 2);\n break;\n case \"MountainClimb\":\n CurrentTile(2, 3);\n break;\n case \"MountainClimb2\":\n CurrentTile(2, 4);\n break;\n case \"MountainClimb3\":\n CurrentTile(3, 4);\n break;\n case \"MountainClimb4\":\n CurrentTile(4, 4);\n break;\n case \"MountainClimb5\":\n CurrentTile(4, 3);\n break;\n case \"MountainClimb6\":\n CurrentTile(4, 2);\n break;\n case \"MountainClimb7\":\n CurrentTile(4, 1);\n break;\n case \"MountainTribe\":\n CurrentTile(3, 1);\n break;\n case \"MountainClimb8\":\n CurrentTile(4, 0);\n break;\n case \"MountainClimb9\":\n CurrentTile(3, 0);\n break;\n case \"MountainPlateau\":\n CurrentTile(2, 0);\n break;\n }\n break;\n }\n}", "title": "" }, { "docid": "863afaa372c2dd3f0a3911f7edf4abe4", "score": "0.50564927", "text": "function screen (){\r\n\tvar x, y = 0;\r\n\tvar wall;\r\n\tvar floor;\r\n\tvar bloc;\r\n\tvar solid;\r\n\t\r\n\tfor (x = 0; x < 11; x++) {\r\n\t\tfor(y = 0; y < 11; y++) {\r\n\t\t\tif (grille[y][x] === 1) {\r\n\t\t\t\t//pour créer le mur\r\n\t\t\t\twall = document.createElement('div');\r\n\t\t\t\twall.setAttribute(\"class\", \"wall\");\r\n\t\t\t\tmap.appendChild(wall);\r\n\t\t\t\t//taille pour le mur en pixel\r\n\t\t\t\twall.style.top = y * 64 + 'px';\r\n\t\t\t\twall.style.left = x * 64 +'px';\r\n\t\t\t\t//img background\r\n\t\t\t\twall.style.backgroundImage = \"url(img/greyblock.png)\";\r\n\t\t\t}\r\n\t\t\tif (grille[y][x] === 2) {\r\n\t\t\t\t//pour créer le mur\r\n\t\t\t\tfloor = document.createElement('div');\r\n\t\t\t\tfloor.setAttribute(\"class\", \"floor\");\r\n\t\t\t\tmap.appendChild(floor);\r\n\t\t\t\t//taille pour le mur en pixel\r\n\t\t\t\tfloor.style.top = y * 64 + 'px';\r\n\t\t\t\tfloor.style.left = x * 64 +'px';\r\n\t\t\t\tfloor.style.backgroundImage = \"url(img/background.png)\";\r\n\t\t\t}\r\n\t\t\tif (grille[y][x] === 3) {\r\n\t\t\t\t//pour créer le mur\r\n\t\t\t\tbloc = document.createElement('div');\r\n\t\t\t\tbloc.setAttribute(\"class\", \"bloc\");\r\n\t\t\t\tmap.appendChild(bloc);\r\n\t\t\t\t//taille pour le mur en pixel\r\n\t\t\t\tbloc.style.top = y * 64 + 'px';\r\n\t\t\t\tbloc.style.left = x * 64 +'px';\r\n\t\t\t\tbloc.style.backgroundImage = \"url(img/block.png)\";\r\n\t\t\t}\r\n\t\t\tif (grille[y][x] === 4) {\r\n\t\t\t\t//pour créer le mur\r\n\t\t\t\tsolid = document.createElement('div');\r\n\t\t\t\tsolid.setAttribute(\"class\", \"solid\");\r\n\t\t\t\tmap.appendChild(solid);\r\n\t\t\t\t//taille pour le mur en pixel\r\n\t\t\t\tsolid.style.top = y * 64 + 'px';\r\n\t\t\t\tsolid.style.left = x * 64 +'px';\r\n\t\t\t\tsolid.style.backgroundImage = \"url(img/solidBlock.png)\";\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}", "title": "" }, { "docid": "fcbcad47f046da210dc1fe49ecfa512f", "score": "0.5056005", "text": "function setMapSize() {\n $('#stations-map').height($('#stations-map').parent().height())\n\n // get map parent element - which provides the correct dimensions for the map\n const rect = document.getElementById('stations-map-wrap').getBoundingClientRect();\n\n const messsageElem = document.getElementById('stations-map-message');\n // get map parent element - which provides the correct dimensions for the map\n if (messsageElem) {\n const rect = document.getElementById('stations-map-wrap').getBoundingClientRect();\n messsageElem.style.left = `${(rect.right - rect.left)/3}px`;\n messsageElem.style.top = `-${((rect.bottom - rect.top)/2)}px`;\n }\n\n // set size of map overlay\n if (document.querySelector('.esri-view-root')) {\n document.querySelector('.esri-view-root').style.minWidth = `${rect.width}px`;\n document.querySelector('.esri-view-root').style.maxWidth = `${rect.width}px`;\n document.querySelector('.esri-view-root').style.height = `${rect.height}px`;\n }\n\n // set size of map overlay\n if (document.querySelector('.esri-view-user-storage')) {\n document.querySelector('.esri-view-user-storage').style.minWidth = `${rect.width}px`;\n document.querySelector('.esri-view-user-storage').style.maxWidth = `${rect.width}px`;\n }\n\n // set size of map\n if (document.querySelector('#stations-map')) {\n document.querySelector('#stations-map').style.minWidth = `${rect.width}px`;\n document.querySelector('#stations-map').style.maxWidth = `${rect.width}px`;\n document.querySelector('#stations-map').style.width = `${rect.width}px`;\n document.querySelector('#stations-map').style.height = `${rect.height}px`;\n }\n\n // get graph parent element - which provides the correct dimensions for the graph\n const graphRect = document.getElementById('stations-graph-wrap').getBoundingClientRect();\n let graphWidth = graphRect.width;\n\n // when smaller than 900 (full size)\n // expand graphs to cover 100%\n if (graphRect.width <= 882) {\n graphWidth = graphRect.width;\n }\n\n // set size of temp chart\n if (graphRect.width <= 900) {\n if (document.querySelector('#stations-graph-row')) {\n document.querySelector('#stations-graph-row').style.height = `350px`;\n document.querySelector('#stations-graph-row').style.minHeight = `350px`;\n }\n }\n\n // set size of temp chart\n if (document.querySelector('#thresholds-container')) {\n document.querySelector('#thresholds-container').style.minWidth = `${graphWidth}px`;\n document.querySelector('#thresholds-container').style.maxWidth = `${graphWidth}px`;\n document.querySelector('#thresholds-container').style.width = `${graphWidth}px`;\n document.querySelector('#thresholds-container').style.height = `${graphRect.height}px`;\n document.querySelector('#thresholds-container').style.maxHeight = `${graphRect.height}px`;\n }\n\n // set size of map\n if (document.querySelector('.chartjs-size-monitor')) {\n document.querySelector('.chartjs-size-monitor').style.minWidth = `${graphWidth}px`;\n document.querySelector('.chartjs-size-monitor').style.maxWidth = `${graphWidth}px`;\n document.querySelector('.chartjs-size-monitor').style.width = `${graphWidth}px`;\n document.querySelector('.chartjs-size-monitor').style.height = `${graphRect.height}px`;\n }\n }", "title": "" }, { "docid": "b3a1bd71994412d9ed2c90c2ba5e4358", "score": "0.5052229", "text": "function AWORLD_ProduceMap2(props) {\n\n let lat = props.lat;\n let lon = props.lon;\n let lod = props.lod;\n let size = props.size;\n let elevation = props.elevation;\n let scene = props.scene;\n let terrainProvider = props.terrainProvider;\n\n // Get index\n let position = Cesium.Cartographic.fromDegrees(lon,lat);\n let xy = terrainProvider.tilingScheme.positionToTileXY(position,lod);\n\n // get a spread of elevation terrain tiles around the player\n // TODO deal with wraparound\n // TODO don't get tiles twice\n // TODO flush tiles that are far away now\n // TODO remember tiles\n let x = xy.x;\n let y = xy.y;\n for(let i=0;i<4;i++) {\n for(let j=0;j<4;j++) {\n let terrainProps = {\n \t scene:scene,\n terrainProvider:terrainProvider,\n u:i*size, v:(3-j)*size, uvrange:size*4,\n lat:lat,lon:lon,lod:lod,\n x:x+i, y:y+j, i:(i-2), j:(j-2),\n size:size,\n elevation:elevation,\n };\n AWORLD_ProduceTerrainTile(terrainProps);\n return; // TODO unleash\n }\n }\n}", "title": "" }, { "docid": "de6364f5aa4637eca9d37c49aa4b0ff5", "score": "0.5040035", "text": "buildMap()\n {\n context.save();\n if(this.mapLoaded != null)\n {\n this.map = this.mapLoaded;\n }\n\n\n for(let i = 0; i < this.map.length; i++)\n {\n for(let j = 0; j < this.map[i].length; j++)\n {\n if(this.map[i][j] == 0)\n {\n let img = new Image();\n img.src = 'img/grass.png';\n context.drawImage(img, this.tileSize*i, this.tileSize*j);\n }\n if(this.map[i][j] == 1)\n {\n context.fillStyle = \"rgb(32, 160, 53)\";\n context.fillRect(this.tileSize*i, this.tileSize*j, this.tileSize, this.tileSize);\n }\n if(this.map[i][j] == 2)\n {\n let img = new Image();\n img.src = 'img/mountain.png';\n context.drawImage(img, this.tileSize*i, this.tileSize*j);\n }\n if(this.map[i][j] == 3)\n {\n context.fillStyle = \"rgb(56, 152, 255)\";\n context.fillRect(this.tileSize*i, this.tileSize*j, this.tileSize, this.tileSize);\n }\n if(this.map[i][j] == 4)\n {\n if(this.basePlayer1 != null) {\n if (this.basePlayer1.getX() === i && this.basePlayer1.getY() === j) {\n let img = new Image();\n img.src = 'img/baseBlue.png';\n context.drawImage(img, this.tileSize * i, this.tileSize * j);\n }\n if (this.basePlayer2.getX() === i && this.basePlayer2.getY() === j) {\n let img = new Image();\n img.src = 'img/baseRed.png';\n context.drawImage(img, this.tileSize * i, this.tileSize * j);\n }\n }\n }\n }\n }\n\n //Now that the map is drawn, we place the cursor\n if(this.timeToBlink > 60)\n {\n this.blinkCursor = !this.blinkCursor;\n this.timeToBlink = 0;\n }\n if(this.blinkCursor) {\n context.fillStyle = \"rgba(220, 237, 33, 0.5)\";\n context.fillRect(this.tileSize * this.cursorPosX, this.tileSize * this.cursorPosY, this.tileSize, this.tileSize);\n }\n if(!this.blinkCursor)\n {\n context.fillStyle = \"rgba(220, 237, 33, 1)\";\n context.fillRect(this.tileSize * this.cursorPosX, this.tileSize * this.cursorPosY, this.tileSize, this.tileSize);\n }\n this.timeToBlink++;\n\n context.restore();\n }", "title": "" }, { "docid": "1dd2f07f7a6156cb41b8004c6629de04", "score": "0.50253344", "text": "renderMinimap(gameShapes, cameraPos) {\n let w = MINIMAP_WIDTH;\n let h = MINIMAP_HEIGHT;\n let margin = MINIMAP_MARGIN;\n let ctx = this.ctx;\n let scale = MINIMAP_SCALE;\n\n ctx.save();\n\n ctx.translate(this.width - margin - w, margin);\n\n ctx.strokeStyle = '#1A6D29';\n ctx.strokeRect(0, 0, w, h);\n\n ctx.beginPath();\n ctx.lineTo(w, 0);\n ctx.lineTo(w, h);\n ctx.lineTo(0, h);\n ctx.lineTo(0, 0);\n ctx.clip();\n\n ctx.fillStyle = '#000';\n ctx.fillRect(0, 0, w * 2, h * 2);\n\n ctx.scale(1 / scale, 1 / scale);\n\n // Wow this should probably be prerendered!\n renderMinimapGravityGrid(ctx, cameraPos, w, h, scale, this.uiEffectInfo.planets);\n\n ctx.translate(-cameraPos.x + (w / 2 * scale), -cameraPos.y + (h / 2 * scale));\n\n _.each(gameShapes, (shape) => {\n if (shape.drawOnMinimap) {\n shape.beforeRender(ctx);\n shape.renderMinimap(ctx);\n shape.afterRenderMinimap(ctx);\n }\n });\n\n ctx.restore();\n }", "title": "" }, { "docid": "a36187fab419665fcc63b98cfe8ea82c", "score": "0.5023868", "text": "function drawMap(map) {\n // remove non-continental states\n map.objects.states.geometries = map.objects.states.geometries.filter(isContinental);\n\n // run topojson on remaining states and adjust projection\n let land = topojson.merge(map, map.objects.states.geometries);\n\n // use null projection; data is already projected\n let path = d3.geoPath();\n\n // draw base map\n g.basemap.append(\"path\")\n .datum(land)\n .attr(\"class\", \"land\")\n .attr(\"d\", path);\n // draw interior borders\n g.basemap.append(\"path\")\n .datum(topojson.mesh(map, map.objects.states, (a, b) => a !== b))\n .attr(\"class\", \"border interior\")\n .style('stroke','#202020')\n .attr(\"d\", path);\n\n // draw exterior borders\n g.basemap.append(\"path\")\n .datum(topojson.mesh(map, map.objects.states, (a, b) => a === b))\n .style('stroke','#202020')\n .attr(\"class\", \"border exterior\")\n .attr(\"d\", path);\n}", "title": "" }, { "docid": "4635720035068d1534f6b39182d1623d", "score": "0.50232565", "text": "function DrawFloorMap() {\n var getDOM = localStorage.getItem('floorzonemap');\n $(\"#floorZone\").html(getDOM);\n }", "title": "" }, { "docid": "a6e9e98ed132144060336026e7ed7521", "score": "0.5021609", "text": "function draw(boundaries) {\n\n projection\n .scale(1)\n .translate([0,0]);\n\n // Compute the correct bounds and scaling from the topoJSON\n var b = path.bounds(topojson.feature(boundaries, boundaries.objects[units]));\n var s = .95 / Math.max((b[1][0] - b[0][0]) / width, (b[1][1] - b[0][1]) / height);\n var t;\n\n var area = $(\"input[name='area']:checked\").val();\n if (area === \"lon\") {\n t = [((width - s * (b[1][0] + b[0][0])) / 2.25), (height - s * (b[1][1] + b[0][1])) / 2];\n } else if (area === \"gb\") {\n t = [((width - s * (b[1][0] + b[0][0])) / 1.95), (height - s * (b[1][1] + b[0][1])) / 2];\n } else {\n t = [((width - s * (b[1][0] + b[0][0])) / 1.85), (height - s * (b[1][1] + b[0][1])) / 2];\n }\n\n projection\n .scale(s)\n .translate(t);\n\n // Add an area for each feature in the topoJSON (constituency)\n g.selectAll(\".area\")\n .data(topojson.feature(boundaries, boundaries.objects[units]).features)\n .enter().append(\"path\")\n .attr(\"class\", \"area\")\n .attr(\"id\", function(d) {return d.id})\n .attr(\"d\", path)\n .on(\"mouseenter\", function(d){ return select(d) })\n .on(\"mouseleave\", function(d){ return deselect(d) });\n\n // Add a boundary between areas\n g.append(\"path\")\n .datum(topojson.mesh(boundaries, boundaries.objects[units], function(a, b){ return a !== b }))\n .attr('d', path)\n .attr('class', 'boundary');\n}", "title": "" }, { "docid": "6961179360f0ce8f91fbaf881485f44c", "score": "0.50147116", "text": "function GenerateObjectMap(mapWidth, map){\r\n var width = mapWidth;\r\n var height = map.length / width;\r\n\r\n /* 0 - SB, 1 - C, 2 - SE\r\n 3 - G, 4 - D, 5 - S, 6 - W, 7 - CB\r\n 8 9 10 11 12\r\n 13 - L, 14 - S, 15 - DB */\r\n\r\n var objectMap = new Array(width*height);\r\n var surface = 0;\r\n\r\n /* 0 - Nothing\r\n 1 - Player\r\n 2 - Enemy */\r\n\r\n /* place enemies (NOT FULLY IMPLEMENTED) and locates the surface of the game map */\r\n for(i = 0; i < width; i++){\r\n for(j = 0; j < height; j++){\r\n var temp = map[j * width + 1];\r\n var num = noisy.randomNumber(0, 10);\r\n if(temp < 3){\r\n if(temp == 2 && j > 0){\r\n if(num > 9.8)\r\n objectMap[j-1 * width + i] = 2;\r\n }\r\n }\r\n else if(temp > 2 && temp < 13){\r\n if(surface == 0)\r\n surface = j-1;\r\n if(temp == 7 || temp == 12){\r\n if(num > 9.8)\r\n objectMap[j * width + i] = 2;\r\n }\r\n }\r\n else{\r\n if(temp == 15){\r\n if(num > 9.8)\r\n objectMap[j * width + i] = 2;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /*Place player in the middle*/\r\n objectMap[surface * width + width/2] = 1;\r\n return objectMap;\r\n }", "title": "" }, { "docid": "c65602bbd9f0c46c0fa3343f6bce65b0", "score": "0.50143063", "text": "function draw(){\n drawscreen=\"\";\n for(var i=0; i<map.length;i++){\n for(var j=0; j<map[i].length;j++){\n if (map[i][j]==1){\n drawscreen+=wall;\n } else if (map[i][j]==2){\n drawscreen+=coin;\n } else if(map[i][j]==0){\n drawscreen+=yellowdot;\n } else if(map[i][j]==3){\n drawscreen+=empty;\n }\n }\n }\n // console.log(drawscreen);\n mapDiv.innerHTML=drawscreen;\n}", "title": "" }, { "docid": "22d5cb8587fa53dde39a0adef7d6d23d", "score": "0.5006126", "text": "function printMap(map) {\n var consoleMap=\"\";\n document.getElementById('surface').innerHTML = \"\";\n for (i = 0; i < 10; i++) {\n for (j = 0; j < 10; j++) {\n if (myRover.position[0] === i && myRover.position[1] === j) {\n map[i][j] = myRover.direction;\n document.getElementById('surface').innerHTML += \"<img id='\"+myRover.name+\"' src='images/\" + myRover.name + myRover.direction + \".png' style='top: \"+ (myRover.position[0] * 50) + \"px ;left: \"+(myRover.position[1] * 50)+ \"px;'/>\";\n } else if ((autoRover.position[0] === i && autoRover.position[1] === j) && autoRoverOn) {\n map[i][j] = autoRover.direction.toLowerCase();\n document.getElementById('surface').innerHTML += \"<img id='\"+autoRover.name+\"' src='images/\" + autoRover.name + autoRover.direction + \".png' style='top: \"+ (autoRover.position[0] * 50) + \"px ;left: \"+(autoRover.position[1] * 50)+ \"px;'/>\";\n } else if (map[i][j] === \"X\") {\n document.getElementById('surface').innerHTML += \"<img class='obstacle' style='top: \"+ (i*50) +\"px; left: \"+ (j*50) +\"px;' src='images/stone.png' alt=''/>\";\n }\n consoleMap += map[i][j];\n }\n consoleMap += \"\\n\";\n }\n console.log(consoleMap);\n document.getElementById('surface').innerHTML += '<div id=\"map\"><pre>'+consoleMap+'</pre></div>';\n}", "title": "" }, { "docid": "bbafa7f51ddd861b5e53bcf7e72ec22d", "score": "0.5003022", "text": "function drawmap() {\r\n\r\n var mainroot = {};\r\n //color code array for namespace,streams and expressions\r\n var colorcode = [{\r\n name: \"namespace\",\r\n color: \"#009999\"\r\n }, {\r\n name: \"datasources\",\r\n color: \"#0000b3\"\r\n }, {\r\n name: \"expressions\",\r\n color: \"#871287\"\r\n }, {\r\n name: \"output\",\r\n color: \"#00cc00\"\r\n }];\r\n if (watchdata.namespace !== \"\") {\r\n mainroot = {\r\n \"name\": \"\",\r\n \"color\": colorcode[0].color,\r\n \"children\": []\r\n };\r\n mainroot.name = watchdata.namespace;\r\n //streams node\r\n if (watchdata.stream !== \"\") {\r\n (mainroot.children).push({\r\n \"name\": watchdata.stream,\r\n \"color\": colorcode[1].color,\r\n \"children\": []\r\n });\r\n }\r\n\r\n var expressions = watchdata.expressions;\r\n var parent;\r\n parent = mainroot.children[0];\r\n //expressions node\r\n for (var i = 0; i < expressions.length; i++) {\r\n (parent.children).push({\r\n \"name\": expressions[i].tag,\r\n \"color\": colorcode[2].color,\r\n \"children\": []\r\n });\r\n parent = parent.children[0];\r\n\r\n }\r\n\r\n //publishers node\r\n\r\n for(key in watchdata.publishers)\r\n {\r\n if(Object.keys(watchdata.publishers[key]).length!=0)\r\n {\r\n parent.children.push({\r\n \"name\":key,\r\n \"color\": colorcode[3].color,\r\n \"children\": []\r\n })\r\n\r\n }}\r\n\r\n root = mainroot;\r\n root.x0 = height / 2;\r\n root.y0 = 0;\r\n update(root);\r\n scope.root = root;\r\n\r\n }\r\n\r\n }", "title": "" }, { "docid": "a8756239155713c7c84207a5a5adc40d", "score": "0.49984497", "text": "updateViewPort(x, y, width, height) {\n if (this._viewPort.width === width && this._viewPort.height === height && this._viewPort.x === x && this._viewPort.y === y) {\n return;\n }\n\n this._viewPort.x = x;\n this._viewPort.y = y;\n this._viewPort.width = width;\n this._viewPort.height = height; // if map's type is iso, reserve bottom line is 2 to avoid show empty grid because of iso grid arithmetic\n\n let reserveLine = 1;\n\n if (this._layerOrientation === _tiledTypes.Orientation.ISO) {\n reserveLine = 2;\n }\n\n const vpx = this._viewPort.x - this._offset.x + this._leftDownToCenterX;\n const vpy = this._viewPort.y - this._offset.y + this._leftDownToCenterY;\n let leftDownX = vpx - this._leftOffset;\n let leftDownY = vpy - this._downOffset;\n const rightTopX = vpx + width + this._rightOffset;\n const rightTopY = vpy + height + this._topOffset;\n const leftDown = this._cullingRect.leftDown;\n const rightTop = this._cullingRect.rightTop;\n if (leftDownX < 0) leftDownX = 0;\n if (leftDownY < 0) leftDownY = 0; // calc left down\n\n this._positionToRowCol(leftDownX, leftDownY, _tempRowCol); // make range large\n\n\n _tempRowCol.row -= reserveLine;\n _tempRowCol.col -= reserveLine; // insure left down row col greater than 0\n\n _tempRowCol.row = _tempRowCol.row > 0 ? _tempRowCol.row : 0;\n _tempRowCol.col = _tempRowCol.col > 0 ? _tempRowCol.col : 0;\n\n if (_tempRowCol.row !== leftDown.row || _tempRowCol.col !== leftDown.col) {\n leftDown.row = _tempRowCol.row;\n leftDown.col = _tempRowCol.col;\n this._cullingDirty = true;\n } // show nothing\n\n\n if (rightTopX < 0 || rightTopY < 0) {\n _tempRowCol.row = -1;\n _tempRowCol.col = -1;\n } else {\n // calc right top\n this._positionToRowCol(rightTopX, rightTopY, _tempRowCol); // make range large\n\n\n _tempRowCol.row++;\n _tempRowCol.col++;\n } // avoid range out of max rect\n\n\n if (_tempRowCol.row > this._rightTop.row) _tempRowCol.row = this._rightTop.row;\n if (_tempRowCol.col > this._rightTop.col) _tempRowCol.col = this._rightTop.col;\n\n if (_tempRowCol.row !== rightTop.row || _tempRowCol.col !== rightTop.col) {\n rightTop.row = _tempRowCol.row;\n rightTop.col = _tempRowCol.col;\n this._cullingDirty = true;\n this.markForUpdateRenderData();\n }\n }", "title": "" }, { "docid": "133151ce37efa268050fddb62a928be8", "score": "0.49949145", "text": "function Map() {\n\n return (\n <KeplerGl\n id=\"mainMap\"\n mapboxApiAccessToken={process.env.REACT_APP_MAPBOX_API_TOKEN}\n width={window.innerWidth}\n height={window.innerHeight}>\n </KeplerGl>\n );\n}", "title": "" }, { "docid": "83682eca0dd14aef64fb232056ffecc7", "score": "0.49919868", "text": "function zoomFullHandler() {\n\n var xModNative = window.app.globalConfig.map_width / window.innerWidth;\n var yModNative = window.app.globalConfig.map_height / window.innerHeight;\n var modAxis = window.app.globalConfig.map_width >= \n window.app.globalConfig.map_height ? \"x\" : \"y\";\n\n var currentTransform = context.getTransform();\n context.setTransform(1/currentTransform);\n context.setTransform(1/(modAxis == \"x\" ? xModNative : yModNative));\n\n var currentTranslate = context.getTranslate();\n map.setTranslate(\n currentTranslate[0] * -1,\n currentTranslate[1] * -1,\n );\n map.setTranslate(205, 300);\n\n\n map.draw();\n }", "title": "" }, { "docid": "03bb1fe3e24efec10d870c280fc29960", "score": "0.49874777", "text": "function showMap() {\n if (_sameFloor) {\n // We show the image as a unique map. This could mean that the user and the room are at the same floor.\n var map = document.getElementById(\"map\");\n map.src = _reva;\n $(\".jqueryFlip-front_floor p\").html(ordinal_suffix_of(_floor) + \" <br><span>floor</span>\");\n } else {\n // We show the image as a second map/floor. This means clearly, that the user and the room are not at the same floor.\n var map_sourcepoint = document.getElementById(\"map_sourcepoint\");\n map_sourcepoint.src = _reva;\n $(\".jqueryFlip-back_floor p\").html(ordinal_suffix_of(_currentfloor) + \" <br><span>floor</span>\");\n }\n\n // This inner function just writes \"th\", \"nd\" and \"rd\" whenever it is required based on the ordinality of the number given\n function ordinal_suffix_of(i) {\n var j = i % 10,\n k = i % 100;\n if (j == 1 && k != 11) {\n return i + \"st\";\n }\n if (j == 2 && k != 12) {\n return i + \"nd\";\n }\n if (j == 3 && k != 13) {\n return i + \"rd\";\n }\n return i + \"th\";\n }\n}", "title": "" }, { "docid": "fe7ba50ec3f2e8cea1ee3f8ca8ad76f8", "score": "0.49835718", "text": "function Minimap() {\n this.canvas = document.getElementById('minimap');\n var ctx = this.canvas.getContext('2d');\n this.texture = new Image();\n this.WIDTH;\n this.HEIGHT;\n this.startx = 0;\n this.starty = 0;\n \n this.init = function() {\n this.texture.src = \"/res/dumped_map_image.png\";\n \n this.texture.onload = function() {\n ctx.drawImage(this, 400, 600, this.canvas.width, this.canvas.height, 0, 0, this.canvas.width, this.canvas.height);\n }\n\n }\n\n this.render = function(pos) {\n\n\t\tctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n\t\t \n\t\tctx.fillStyle = \"#00FFFF\";\n\t\tctx.fillRect(0,0,this.canvas.width,this.canvas.height);\n\t\n\t\tvar x = 0;\n\t\tvar y = 0;\n\t\n\t\tvar sx = pos.x - this.canvas.width/2;\n\t\tvar sy = pos.y - this.canvas.height/2;\n\t\n\t\tvar swidth = this.canvas.width;\n\t\tvar sheight = this.canvas.height;\n\t\n\t\tvar width = swidth;\n\t\tvar height = sheight;\n\t\n\t\tif(sx < 0) {\n\t\t\tx = Math.abs(sx);\n\t\t\tswidth = this.canvas.width + sx;\n\t\t\twidth = swidth;\n\t\t\tsx = 0;\n\t\t}if(sy < 0) {\n\t\t\ty = Math.abs(sy);\n\t\t\tsheight = this.canvas.height + sy;\n\t\t\theight = sheight;\n\t\t\tsy = 0;\n\t\t};\n\t\n\t\tif(sx > this.texture.width-this.canvas.width) {\n\t\t\tswidth = this.texture.width-sx;\n\t\t\twidth = swidth;\n\t\t}if(sy > this.texture.height-this.canvas.height) {\n\t\t\tsheight = this.texture.height-sy;\n\t\t\theight = sheight;\n\t\t}\n\t\n\t\t//var swidth = 200;\n\t\t//var sheight = 200;\n\t\n\t\t//var width = 200;\n\t\t//var height = 200;\n\t\n\t\tctx.drawImage(this.texture, sx, sy,swidth, sheight, x, y, width, height);\n\t\t\n\t\t//crosshair\n\t\tctx.fillStyle = \"#000000\";\n\t\tctx.fillRect((this.canvas.width/2)-4, (this.canvas.height/2)-1, 8, 2);\n\t\tctx.fillRect((this.canvas.width/2)-1, (this.canvas.height/2)-4, 2, 8);\n \t\tthis.sx = sx;\n \t\tthis.sy = sy;\n }\n \n}", "title": "" }, { "docid": "f5bef6ea5ea3dd24e853d81047a5ea20", "score": "0.4981919", "text": "async function prepare() {\n // Download world map and set desired projection\n world = await loadWorld(topoJsonUrl);\n displays.left.projection = projections.azimuthal;\n displays.right.projection = projections.complexLog;\n\n displays.left.projection.rotate(renderParams.currentRotation);\n displays.right.projection.rotate(renderParams.currentRotation);\n\n // Fit size based on projection\n displays.left.projection.fitSize([renderParams.width, renderParams.height], world.outline);\n displays.right.projection.fitSize([renderParams.width, renderParams.height], projections.complexLog.preclip().polygon());\n displays.left.baseScale = displays.left.projection.scale();\n displays.right.baseScale = displays.right.projection.scale();\n\n // Path generators\n displays.left.path = d3.geoPath(displays.left.projection);\n displays.right.path = d3.geoPath(displays.right.projection);\n\n // Main displays to render the map onto\n displays.left.svg = d3.select(\"div#display_left\")\n .append(\"div\")\n .classed(\"svg-container\", true) \n .append(\"svg\")\n .attr(\"preserveAspectRatio\", \"xMinYMin meet\")\n .attr(\"viewBox\", `0 0 ${renderParams.width} ${renderParams.height}`)\n .classed(\"svg-content-responsive\", true);\n displays.right.svg = d3.select(\"div#display_right\")\n .append(\"div\")\n .classed(\"svg-container\", true) \n .append(\"svg\")\n .attr(\"preserveAspectRatio\", \"xMinYMin meet\")\n .attr(\"viewBox\", `0 0 ${renderParams.width} ${renderParams.height}`)\n .classed(\"svg-content-responsive\", true);\n\n // SVG background\n displays.left.svg_background = displays.left.svg.append(\"g\").append(\"rect\");\n displays.right.svg_background = displays.right.svg.append(\"g\").append(\"rect\");\n const svgs_backgrounds = concat(displays.left.svg_background, displays.right.svg_background);\n svgs_backgrounds.attr(\"id\", \"background\").attr(\"fill\", style.backgroundFill).attr(\"stroke\", style.backgroundStroke)\n svgs_backgrounds.attr(\"width\", renderParams.width).attr(\"height\", renderParams.height);\n\n // SVG countries\n displays.left.svg_countries = displays.left.svg.append(\"g\").selectAll(\"path\").data(world.countries.features).enter().append(\"path\");\n displays.right.svg_countries = displays.right.svg.append(\"g\").selectAll(\"path\").data(world.countries.features).enter().append(\"path\");\n const svgs_countries = concat(displays.left.svg_countries, displays.right.svg_countries);\n svgs_countries.attr(\"id\", \"countries\").attr(\"fill\", style.countriesFill).attr(\"stroke\", style.countriesStroke);\n\n // SVG graticule\n displays.left.svg_graticule = displays.left.svg.append(\"g\").append(\"path\").datum(world.graticule);\n displays.right.svg_graticule = displays.right.svg.append(\"g\").append(\"path\").datum(world.graticule);\n const svgs_graticules = concat(displays.left.svg_graticule, displays.right.svg_graticule);\n svgs_graticules.attr(\"id\", \"graticule\").attr(\"fill\", \"none\").attr(\"stroke\", style.graticuleStroke);\n\n // SVG outline\n displays.left.svg_outline = displays.left.svg.append(\"g\").append(\"path\").datum(world.outline);\n displays.right.svg_outline = displays.right.svg.append(\"g\").append(\"path\").datum(world.outline);\n const svgs_outlines = concat(displays.left.svg_outline, displays.right.svg_outline);\n svgs_outlines.attr(\"id\", \"outline\").attr(\"fill\", \"none\").attr(\"stroke\", style.outlineStroke);\n\n // Viewport clip visualization\n displays.left.svg_clipPoly = displays.left.svg.append(\"g\").append(\"path\").datum(projections.complexLog.preclip().polygon ? projections.complexLog.preclip().polygon() : \"\");\n displays.right.svg_clipPoly = displays.right.svg.append(\"g\").append(\"path\").datum(projections.complexLog.preclip().polygon ? projections.complexLog.preclip().polygon() : \"\");\n const svgs_clipPolys = concat(displays.left.svg_clipPoly, displays.right.svg_clipPoly);\n svgs_clipPolys.attr(\"id\", \"viewportClip\").attr(\"fill\", \"none\").attr(\"stroke\", \"#ff0000\");\n\n // Left-display center cross\n const crossSize = 20;\n displays.left.svg_center = displays.left.svg.append(\"g\");\n displays.left.svg_center.append(\"line\")\n .attr(\"x1\", renderParams.width / 2 - crossSize / 2)\n .attr(\"x2\", renderParams.width / 2 + crossSize / 2)\n .attr(\"y1\", renderParams.height / 2)\n .attr(\"y2\", renderParams.height / 2);\n displays.left.svg_center.append(\"line\")\n .attr(\"x1\", renderParams.width / 2)\n .attr(\"x2\", renderParams.width / 2)\n .attr(\"y1\", renderParams.height / 2 - crossSize / 2)\n .attr(\"y2\", renderParams.height / 2 + crossSize / 2);\n displays.left.svg_center.selectAll(\"line\")\n .attr(\"stroke\", \"red\")\n .attr(\"stroke-width\", 2);\n\n // Longitude and latitude controls\n const longitudeTextbox = d3.select(\"input#longitude\");\n const latitudeTextbox = d3.select(\"input#latitude\");\n longitudeTextbox.property(\"value\", renderParams.currentRotation[0]);\n latitudeTextbox.property(\"value\", renderParams.currentRotation[1]);\n // Transition to clicked position\n function rotationTransition(lambda, phi) {\n renderParams.currentRotation = [-lambda, -phi];\n longitudeTextbox.property(\"value\", renderParams.currentRotation[0]);\n latitudeTextbox.property(\"value\", renderParams.currentRotation[1]);\n\n d3.interrupt(\"rotation\");\n d3.transition(\"rotation\").duration(1000).tween(\"rotate\", function() {\n const rotationInterpolatorLeft = d3.interpolate(displays.left.projection.rotate(), renderParams.currentRotation);\n const rotationInterpolatorRight = d3.interpolate(displays.right.projection.rotate(), renderParams.currentRotation);\n \n return function(t) {\n displays.left.projection.rotate(rotationInterpolatorLeft(t));\n displays.right.projection.rotate(rotationInterpolatorRight(t));\n displays.left.projection.fitSize([renderParams.width, renderParams.height], world.outline);\n displays.right.projection.fitSize([renderParams.width, renderParams.height], projections.complexLog.preclip().polygon());\n displays.left.baseScale = displays.left.projection.scale();\n displays.right.baseScale = displays.right.projection.scale();\n displays.left.projection.scale(displays.left.scaleFactor * displays.left.baseScale);\n displays.right.projection.scale(displays.right.scaleFactor * displays.right.baseScale);\n update();\n }\n }).transition();\n }\n displays.left.svg.on(\"mousedown\", function () {\n const [lambda, phi] = displays.left.projection.invert(d3.mouse(this));\n rotationTransition(lambda, phi);\n });\n displays.right.svg.on(\"mousedown\", function () {\n const [lambda, phi] = displays.right.projection.invert(d3.mouse(this));\n rotationTransition(lambda, phi);\n });\n longitudeTextbox.on(\"change\", () => {\n rotationTransition(-longitudeTextbox.property(\"value\"), renderParams.currentRotation[1]);\n });\n latitudeTextbox.on(\"input\", () => {\n rotationTransition(renderParams.currentRotation[0], -latitudeTextbox.property(\"value\"));\n });\n\n // Hover information about world coordinates\n let tooltip = d3.select(\"body\").append(\"div\").attr(\"class\", \"tooltip\").style(\"opacity\", 0);\n function showTooltip(display) {\n return function() {\n const [mouseX, mouseY] = d3.mouse(this);\n const [lambda, phi] = display.projection.invert([mouseX, mouseY]);\n\n tooltip.transition()\t\t\n .duration(0)\t\t\n .style(\"opacity\", 0.94);\t\t\n tooltip.html(lambda.toFixed(5) + \"<br>\" + phi.toFixed(5))\t\n .style(\"left\", (d3.event.pageX + 5) + \"px\")\t\t\n .style(\"top\", (d3.event.pageY - 35) + \"px\");\n }\n }\n function hideTooltip() {\t\t\n tooltip.transition()\t\t\n .duration(0)\t\t\n .style(\"opacity\", 0)\n }\t\n displays.left.svg.on(\"mousemove\", showTooltip(displays.left));\t\n displays.left.svg.on(\"mouseout\", hideTooltip);\n displays.right.svg.on(\"mousemove\", showTooltip(displays.right));\t\n displays.right.svg.on(\"mouseout\", hideTooltip);\n\n // Graticule checkbox\n const graticuleCheckbox = d3.select(\"input#graticuleCheckbox\");\n graticuleCheckbox.property(\"checked\", renderParams.showGraticule);\n graticuleCheckbox.on(\"change\", () => {\n renderParams.showGraticule = graticuleCheckbox.property(\"checked\");\n svgs_graticules.attr(\"visibility\", renderParams.showGraticule ? \"visible\" : \"hidden\");\n });\n \n // Outline checkbox\n const outlineCheckbox = d3.select(\"input#outlineCheckbox\");\n outlineCheckbox.property(\"checked\", renderParams.showOutline);\n outlineCheckbox.on(\"change\", () => {\n renderParams.showOutline = outlineCheckbox.property(\"checked\");\n svgs_outlines.attr(\"visibility\", renderParams.showOutline ? \"visible\" : \"hidden\");\n });\n\n // Center checkbox\n const centerCheckbox = d3.select(\"input#centerCheckbox\");\n centerCheckbox.property(\"checked\", renderParams.showCenter);\n displays.left.svg_center.attr(\"visibility\", renderParams.showCenter ? \"visible\" : \"hidden\");\n centerCheckbox.on(\"change\", () => {\n renderParams.showCenter = centerCheckbox.property(\"checked\");\n displays.left.svg_center.attr(\"visibility\", renderParams.showCenter ? \"visible\" : \"hidden\");\n });\n\n // Color checkbox, triggers re-render\n const colorCheckbox = d3.select(\"input#colorCheckbox\");\n colorCheckbox.property(\"checked\", renderParams.doColorCountries);\n colorCheckbox.on(\"change\", () => {\n renderParams.doColorCountries = colorCheckbox.property(\"checked\");\n update();\n });\n\n // Complex log clip poly checkbox\n const clipPolyCheckbox = d3.select(\"input#clipPolyCheckbox\");\n clipPolyCheckbox.property(\"checked\", renderParams.showViewportClip);\n svgs_clipPolys.attr(\"visibility\", renderParams.showViewportClip ? \"visible\" : \"hidden\");\n clipPolyCheckbox.on(\"change\", () => {\n renderParams.showViewportClip = clipPolyCheckbox.property(\"checked\");\n svgs_clipPolys.attr(\"visibility\", renderParams.showViewportClip ? \"visible\" : \"hidden\");\n });\n\n // Scale range slider and number\n function updateScale(display, scaleFactor) {\n display.scaleFactor = scaleFactor;\n display.scaleRange.property(\"value\", display.scaleFactor);\n display.scaleNumber.property(\"value\", display.scaleFactor);\n display.projection.scale(display.scaleFactor * display.baseScale);\n\n update();\n }\n displays.left.scaleRange = d3.select(\"input#scaleRangeLeft\");\n displays.left.scaleNumber = d3.select(\"input#scaleNumberLeft\");\n updateScale(displays.left, renderParams.defaultScaleFactor);\n displays.left.scaleRange.on(\"input\", () => {\n updateScale(displays.left, +displays.left.scaleRange.property(\"value\"));\n });\n displays.left.scaleNumber.on(\"input\", () => {\n updateScale(displays.left, +displays.left.scaleNumber.property(\"value\"));\n });\n displays.right.scaleRange = d3.select(\"input#scaleRangeRight\");\n displays.right.scaleNumber = d3.select(\"input#scaleNumberRight\");\n updateScale(displays.right, renderParams.defaultScaleFactor);\n displays.right.scaleRange.on(\"input\", () => {\n updateScale(displays.right, +displays.right.scaleRange.property(\"value\"));\n });\n displays.right.scaleNumber.on(\"input\", () => {\n updateScale(displays.right, +displays.right.scaleNumber.property(\"value\"));\n });\n\n\n // Complex log translation button\n d3.select(\"button#upButton\").on(\"click\", function() {\n const [x, y] = displays.right.projection.translate();\n displays.right.projection.translate([x, y - 10]);\n update();\n });\n d3.select(\"button#downButton\").on(\"click\", function() {\n const [x, y] = displays.right.projection.translate();\n displays.right.projection.translate([x, y + 10]);\n update();\n });\n}", "title": "" }, { "docid": "6b486a2f4dc537485c740286d5f2508d", "score": "0.49799788", "text": "function FW_Screen_Map() {\r\n\tpMain.rows[0].cells[0].childNodes[1].innerHTML += '<form></form>';\r\n\t\r\n\tvar mapX = (parseInt(document.forms[2].elements[0].value)-7);\r\n\tvar mapY = (parseInt(document.forms[2].elements[1].value)-7);\r\n\r\n\tvar oMap = document.getElementById('map');\r\n\toMap.style.width=\"800px\";\r\n\toMap.style.height=\"570px\";\r\n\toMap.style.background = 'url(\"http://joshdb.com/k46/GM/loading.gif\") no-repeat 50% 50%';\r\n\toMap.innerHTML = '';\r\n\r\n\tvar tRect = document.getElementById('topoRect');\r\n\ttRect.style.width = '68px';\r\n\ttRect.style.height = '68px';\r\n\t\r\n\tvar tRectTop = tRect.style.top;\r\n\ttRectTop = tRectTop.substring(0, tRectTop.length - 2);\r\n\ttRectTop = parseInt(tRectTop) - 19;\r\n\t\r\n\tvar tRectLeft = tRect.style.left;\r\n\ttRectLeft = tRectLeft.substring(0, tRectLeft.length - 2);\r\n\ttRectLeft = parseInt(tRectLeft) - 18;\r\n\t\r\n\ttRect.style.top = tRectTop + \"px\";\r\n\ttRect.style.left = tRectLeft + \"px\";\r\n\t\r\n\tGM_xmlhttpRequest({\r\n\t\tmethod: 'GET',\r\n\t\turl: baseURL + '/game.php?village=' + vID + '&screen=map&xml&start_x=' + mapX + '&start_y=' + mapY + '&size_x=15&size_y=15',\r\n\t\theaders: {\r\n\t\t\t'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',\r\n\t\t\t'Accept': 'text/html',\r\n\t\t},\r\n\t\tonload: function(responseDetails) {\r\n\t\t\toMap.innerHTML = responseDetails.responseText;\r\n\t\t}\r\n\t});\r\n}", "title": "" }, { "docid": "cd4ff72d07d60a8021d9158e1c2db927", "score": "0.49789608", "text": "function drawMap(map) {\n // remove non-continental states\n map.objects.states.geometries = map.objects.states.geometries.filter(isContinental);\n\n // run topojson on remaining states and adjust projection\n let land = topojson.merge(map, map.objects.states.geometries);\n\n // use null projection; data is already projected\n let path = d3.geoPath();\n\n // draw base map\n g.basemap.append(\"path\")\n .datum(land)\n .attr(\"class\", \"land\")\n .attr(\"d\", path);\n\n // draw interior borders\n g.basemap.append(\"path\")\n .datum(topojson.mesh(map, map.objects.states, (a, b) => a !== b))\n .attr(\"class\", \"border interior\")\n .attr(\"d\", path);\n\n // draw exterior borders\n g.basemap.append(\"path\")\n .datum(topojson.mesh(map, map.objects.states, (a, b) => a === b))\n .attr(\"class\", \"border exterior\")\n .attr(\"d\", path);\n}", "title": "" }, { "docid": "096798140738acdb681ca484f80fa2ab", "score": "0.4978193", "text": "function displayMap(){\n initMap();\n}", "title": "" }, { "docid": "a523781d05633db9ae797c079edb95be", "score": "0.49696583", "text": "function drawMap(){\n\n //### clear the canvas\n\n //### draw game elements\n \n }", "title": "" }, { "docid": "e6692197bf2b3fb2363ca080859b10b4", "score": "0.4964057", "text": "draw(context) {\r\n\t\t\r\n // if the map changes, load the new map\r\n if(this.engine.stageProps.level != this.level) {\r\n this.load();\r\n }\r\n \r\n\t\tthis.tiles.forEach((tile) => {\r\n context.fillStyle = tile.color;\r\n\t\t\tcontext.beginPath();\r\n context.rect(tile.x, tile.y, tile.width, tile.height);\r\n context.fill();\r\n context.closePath();\r\n\t\t});\r\n }", "title": "" }, { "docid": "9e731a309633afb9a9ef49da0a4b6f24", "score": "0.49498475", "text": "function initMap() {\r\n\r\n // Set map width\r\n var mapDiv = wrapper.find(\".czMap\");\r\n mapDiv.width(mapDiv.parent().width() - mapDiv.next().width())\r\n mapDiv.height(window.innerHeight - wrapper.find(\".under\").outerHeight())\r\n\r\n // Center of CZ\r\n var center = SMap.Coords.fromWGS84(15.472962, 49.817492);\r\n\r\n // Load map\r\n var map = new SMap(JAK.gel(mapDiv[0]), center, 8);\r\n\r\n // Set zoom by some points\r\n var points = [\r\n SMap.Coords.fromWGS84(13.2883104, 50.6347454),\r\n SMap.Coords.fromWGS84(18.322215, 49.1988972),\r\n ];\r\n var result = map.computeCenterZoom(points, false);\r\n map.setZoom(result[1]);\r\n\r\n // Add controls\r\n map.addDefaultLayer(SMap.DEF_BASE).enable();\r\n map.addDefaultControls();\r\n\r\n // Add image layer\r\n var imageLayer = new SMap.Layer.Image(); \r\n map.addLayer(imageLayer, false); \r\n imageLayer.enable();\r\n $(imageLayer.getContainer()[0].parentElement).addClass(\"mapy-layers\");\r\n\r\n // Add HTML layer\r\n var htmlLayer = new SMap.Layer.HUD();\r\n map.addLayer(htmlLayer, false);\r\n htmlLayer.enable();\r\n htmlLayer.addItem($(\"<h2 class=\\\"time-holder\\\"></h>\")[0], { top: \"-2px\", right: \"100px\"}, true);\r\n\r\n return imageLayer;\r\n }", "title": "" }, { "docid": "9abd5bee9e28ded17c3d04e2c6608654", "score": "0.4949389", "text": "function loadMap() {\r\n destroyOldObjects();\r\n createThis.physics.world.TILE_BIAS = 64; \r\n\r\n var currentTilemapKey = currentLevelID + 'Tilemap';\r\n\r\n createThis.map = createThis.make.tilemap({ key: currentTilemapKey });\r\n \r\n //set Boundary\r\n gameWidth = createThis.map.widthInPixels;\r\n gameHeight = createThis.map.heightInPixels;\r\n createThis.physics.world.setBounds(0, 0, gameWidth + (200 * playerShip), gameHeight, 64, true, true, false, false);\r\n\r\n //Render background. \r\n background = createThis.add.image(1024, 576, backgroundLayer0);\r\n background.setOrigin(1,1);\r\n background.scrollFactorX = 0;\r\n background.scrollFactorY = 0;\r\n background.setDepth(-100);\r\n\r\n if (backgroundLayer0 == 'bgSky') {\r\n backgroundClouds = createThis.add.image(0, 576, 'bgClouds');\r\n backgroundClouds.setOrigin(0,1);\r\n backgroundClouds.scrollFactorX = 0.2;\r\n backgroundClouds.scrollFactorY = 0;\r\n backgroundClouds.setDepth(-95);\r\n }\r\n\r\n if (backgroundLayer1 !== undefined) {\r\n backgroundLayer1Image = createThis.add.image(0, 576, backgroundLayer1);\r\n backgroundLayer1Image.setOrigin(0,1);\r\n backgroundLayer1Image.scrollFactorX = 0.4;\r\n backgroundLayer1Image.scrollFactorY = 0;\r\n backgroundLayer1Image.setDepth(-95);\r\n }\r\n\r\n //Draw tileset/objects\r\n var tileset = createThis.map.addTilesetImage(\"tilesheet-extruded\", \"tiles\", 64, 64, 1, 2);\r\n var mapLayerBG = createThis.map.createStaticLayer(\"Layer_bg\", tileset, 0, 0);\r\n mapLayer = createThis.map.createStaticLayer(\"Layer\", tileset, 0, 0);\r\n mapLayer.setDepth(-40);\r\n mapLayerBG.setDepth(-50);\r\n\r\n //Spawn player.\r\n var playerSpawnPoint = createThis.map.findObject(\"Objects\", obj => obj.name === \"Player Spawn\");\r\n player = createThis.physics.add.sprite(playerSpawnPoint.x, playerSpawnPoint.y, playerSprite);\r\n player.setCollideWorldBounds(true);\r\n \r\n mapLayer.setCollisionByProperty({ collides: true });\r\n createThis.physics.add.collider(player, mapLayer);\r\n\r\n //Player animations. \r\n createThis.anims.create({\r\n key: 'jasonRight',\r\n frames: createThis.anims.generateFrameNumbers('jason', { start: 0, end: 11 }),\r\n frameRate: 10,\r\n repeat: -1\r\n });\r\n createThis.anims.create({\r\n key: 'jasonAttackRight',\r\n frames: createThis.anims.generateFrameNumbers('jason', { start: 12, end: 29 }),\r\n frameRate: 30,\r\n repeat: -1\r\n });\r\n createThis.anims.create({\r\n key: 'jasonIdleRight',\r\n frames: createThis.anims.generateFrameNumbers('jason', { start: 0, end: 0 }),\r\n frameRate: 10,\r\n repeat: -1\r\n });\r\n\r\n //Medea animations. \r\n createThis.anims.create({\r\n key: 'medeaIdleRight',\r\n frames: createThis.anims.generateFrameNumbers('medeaSprite', { start: 0, end: 0 }),\r\n frameRate: 10,\r\n repeat: -1\r\n });\r\n createThis.anims.create({\r\n key: 'medeaWalkRight',\r\n frames: createThis.anims.generateFrameNumbers('medeaSprite', { start: 0, end: 7 }),\r\n frameRate: 10,\r\n repeat: -1\r\n });\r\n\r\n //Keyboard input.\r\n cursors = createThis.input.keyboard.createCursorKeys();\r\n attackKey = createThis.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Z);\r\n jumpKey = createThis.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.X);\r\n talkKey = createThis.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.C);\r\n\r\n if (playerShip) {\r\n player.body.allowGravity = false;\r\n }\r\n\r\n parseLevelDialogue();\r\n if (currentLevelID != 'endCutscene'){\r\n parseHealthBar();\r\n }\r\n\r\n spawnObjects();\r\n\r\n playerCheckForPortal(); \r\n\r\n //Camera\r\n if (!playerShip) {\r\n createThis.cameras.main.startFollow(player, false, 0.05, 0.03);\r\n } else {\r\n playerOffset = createThis.physics.add.sprite(playerSpawnPoint.x + playerShipOffsetX, playerSpawnPoint.y, playerSprite);\r\n createThis.cameras.main.startFollow(playerOffset, true, 1, 1);\r\n playerOffset.alpha = 0; \r\n playerOffset.allowGravity = 0; \r\n }\r\n createThis.cameras.main.setBounds(0, 0, createThis.map.widthInPixels, createThis.map.heightInPixels);\r\n\r\n playerAlive = true;\r\n}", "title": "" }, { "docid": "799f7c03a74471d8fa67306f8b223c45", "score": "0.49439648", "text": "function _updateRenderInfo () {\n // get local render information. update if appropriate.\n var loc = $game.$map.masterToLocal(_info.x, _info.y)\n if (loc) {\n var prevX = loc.x * $game.TILE_SIZE + _info.prevOffX * $game.STEP_PIXELS\n var prevY = loc.y * $game.TILE_SIZE + _info.prevOffY * $game.STEP_PIXELS\n var curX = loc.x * $game.TILE_SIZE + _info.offX * $game.STEP_PIXELS\n var curY = loc.y * $game.TILE_SIZE + _info.offY * $game.STEP_PIXELS\n\n _renderInfo.prevX = prevX\n _renderInfo.prevY = prevY\n _renderInfo.srcX = _info.srcX\n _renderInfo.srcY = _info.srcY\n _renderInfo.curX = curX\n _renderInfo.curY = curY\n }\n}", "title": "" }, { "docid": "1e55bccf2f3f02bd007f871b8c444302", "score": "0.49385378", "text": "function AWORLD_ProduceMap(props) {\n let terrainProvider = new Cesium.CesiumTerrainProvider({\n requestVertexNormals : true, \n url:\"https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles\",\n });\n setTimeout(function() { props.terrainProvider = terrainProvider; AWORLD_ProduceMap2(props); },2000);\n}", "title": "" }, { "docid": "d0511d8c9943175fb718ebcb7ec66160", "score": "0.49372494", "text": "function Map() {\n\tconst { tiles, width } = useStoreState();\n\tconst height = tiles.length / width;\n\n\tconst output = [];\n\tfor (let y = 0; y < height; y += 1) {\n\t\tfor (let x = 0; x < width; x += 1) {\n\t\t\tconst index = y * width + x;\n\t\t\tconst style = {\n\t\t\t\tposition: \"absolute\",\n\t\t\t\theight: 16,\n\t\t\t\twidth: 16,\n\t\t\t\tleft: x * 16,\n\t\t\t\ttop: y * 16,\n\t\t\t\tbackground: tiles[index] ? \"black\" : \"lightgreen\"\n\t\t\t};\n\t\t\toutput.push(<div key={index} style={style} />);\n\t\t}\n\t}\n\treturn <>{output}</>;\n}", "title": "" }, { "docid": "ac7a0ab4f2fc2a5c817e5d944d140bf8", "score": "0.49366838", "text": "function paintMap(lat,lng){\n if(lat === undefined || lng === undefined){\n lat = 45.1075;\n lng = 7.6690;\n }\n app.map = new google.maps.Map(document.getElementById('map'), {\n zoom: 12,\n center: new google.maps.LatLng(lat, lng),\n mapTypeId: google.maps.MapTypeId.ROADMAP,\n draggable: true,\n fullscreenControl: true,\n fullscreenControlOptions: {\n position: google.maps.ControlPosition.LEFT_BOTTOM,\n },\n styles: [{\n \"featureType\": \"administrative\",\n \"elementType\": \"all\",\n \"stylers\": [{\n \"visibility\": \"on\"\n }, {\n \"lightness\": 33\n }]\n }, {\n \"featureType\": \"landscape\",\n \"elementType\": \"all\",\n \"stylers\": [{\n \"color\": \"#f2e5d4\"\n }]\n }, {\n \"featureType\": \"poi.park\",\n \"elementType\": \"geometry\",\n \"stylers\": [{\n \"color\": \"#c5dac6\"\n }]\n }, {\n \"featureType\": \"poi.park\",\n \"elementType\": \"labels\",\n \"stylers\": [{\n \"visibility\": \"on\"\n }, {\n \"lightness\": 20\n }]\n }, {\n \"featureType\": \"road\",\n \"elementType\": \"all\",\n \"stylers\": [{\n \"lightness\": 20\n }]\n }, {\n \"featureType\": \"road.highway\",\n \"elementType\": \"geometry\",\n \"stylers\": [{\n \"color\": \"#c5c6c6\"\n }]\n }, {\n \"featureType\": \"road.arterial\",\n \"elementType\": \"geometry\",\n \"stylers\": [{\n \"color\": \"#e4d7c6\"\n }]\n }, {\n \"featureType\": \"road.local\",\n \"elementType\": \"geometry\",\n \"stylers\": [{\n \"color\": \"#fbfaf7\"\n }]\n }, {\n \"featureType\": \"water\",\n \"elementType\": \"all\",\n \"stylers\": [{\n \"visibility\": \"on\"\n }, {\n \"color\": \"#acbcc9\"\n }]\n }]\n\n });\n}", "title": "" } ]
d00562d67707c77d41ca141b0883c71a
Check user and password before keeping up.
[ { "docid": "87c8e01a8cba1a52683057e8bb10554d", "score": "0.0", "text": "function checkUser(user, password) {\n return new Promise((reso, rej) => {\n db.collection(\"users\").findOne({ email: user }, function(err, results) {\n console.log(results);\n if (results === null) {\n rej(`${user} Not exist`);\n } else if (!bcrypt.compareSync(password, results.password)) {\n rej(\"Password is incorrect\");\n } else {\n reso(results);\n }\n });\n });\n}", "title": "" } ]
[ { "docid": "3c7f34cee7bec20fa224ec22c69385b7", "score": "0.6519132", "text": "function checkValues(){\n checkCurrentPassword();\n checkPassword();\n checkPasswordConfirm();\n if(checkPassword() === true && checkPasswordConfirm() === true){\n changePassword();\n }\n}", "title": "" }, { "docid": "41120c1635e49da4b07684ac2455efc8", "score": "0.6303161", "text": "function checkPassword () {\n uiState = stateBuilder.run(uiState);\n advisorsOptics.updateFromState(uiState);\n console.log('uiState update: ', uiState);\n continueButtonOptic(uiState);\n}", "title": "" }, { "docid": "0af57852a72db9da7671d19cfdecd55c", "score": "0.62927586", "text": "function tryAuth(next) {\n var username = app.config.get('username');\n\n app.auth(function (err) {\n //\n // Attempt to get the password three times.\n // Increment the auth attempts\n //\n tries += 1;\n\n if (err) {\n if (tries >= 3) {\n app.log.error('Three failed login attempts');\n app.log.info('Would you like to reset your password?');\n return offerReset(username);\n }\n\n return setupAuth(next);\n }\n\n app.config.save(function (err) {\n return err ? next(err) : next();\n });\n });\n }", "title": "" }, { "docid": "34c9bd754a06c6efc4ed309b64af9738", "score": "0.6152628", "text": "function test_provision_bad_password() {}", "title": "" }, { "docid": "c558517a8a1ec69752bf488296c09c02", "score": "0.60919726", "text": "function checkPassword(password) {\r\n return password === config.server.password;\r\n}", "title": "" }, { "docid": "6313d721ad2326ed784843029ce79676", "score": "0.60805196", "text": "function checkNewUserValidity(username, pass, passRep){\r\n\t\t\r\n\t\tif( checkParamSize(username, \"Username\") < 0 || checkParamSize(pass, \"Password\") < 0){\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tif(pass != passRep){\r\n\t\t\tlet logErrorDiv = document.getElementById(\"errorLog\");\r\n\t\t\tlogErrorDiv.innerHTML = \"passwords dont match.\";\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\treturn -1;\r\n\t\t\r\n\t}", "title": "" }, { "docid": "de2d046ae3a9c9d65259f1a317af401c", "score": "0.6058832", "text": "function checkUserAndPass(username, password, callback){\n\tusersModel.findOne({'username': username})\n\t.populate('study')\n\t.exec(function(err, objUser){\n\t\tif(err) return console.log('Error en query: '+err);\n\t\tvar valido = bcrypt.compare(password, objUser.password);\n\n\t\tif(objUser.token != '' || !objUser.activo) valido=false;\n\t\treturn callback(valido, objUser);\n\t});\t\n}", "title": "" }, { "docid": "afe17423fb1229681ba2e62b6b4842e2", "score": "0.6054385", "text": "function validCred(userId, password) {return goodId(userId) && goodPassword(password) && matching(userId, password)}", "title": "" }, { "docid": "6153401e42e1d165ba2c69e3fe407364", "score": "0.60518605", "text": "function attemptLoginWithPassword() {\n var tempGH = new GitHub({\n username: $(\"#github-user\").val(),\n password: $(\"#github-password\").val()\n });\n verifyIfAuthSucceded(tempGH);\n }", "title": "" }, { "docid": "382637e46d457691fe029e3dca1b8b8d", "score": "0.60223264", "text": "function exePassword() {\n\n\t\tif (server) return;\n\n\t\tStory.log(\"Please enter a password:\");\n\t\tcommand._capture = {\n\t\t\tcheck: null,\n\t\t\tsuccess: function(x) {\n\t\t\t\tClient.characterPass = x;\n\t\t\t\tStory.append(\" \" + x);\n\t\t\t\tStory.log(\"You now exist!\");\n\t\t\t\tStory.space();\n\t\t\t\tcommand._capture = null;\n\t\t\t\tsendToServer({\n\t\t\t\t\ttype: \"new\",\n\t\t\t\t\tname: Client.characterName,\n\t\t\t\t\tpass: Client.characterPass\n\t\t\t\t});\n\t\t\t},\n\t\t\tfail: function() {\n\t\t\t\tStory.log(\"Try again:\");\n\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "0278a0a27cdf4de9adad62f6eae926e6", "score": "0.5956329", "text": "function login(){\n\tvalidateUser()\n}", "title": "" }, { "docid": "5b0bc42fc8f585e6834763225ab97f17", "score": "0.59542847", "text": "function checkUser(username, password) {\n //Check the username\n if(username != document.getElementById(\"username\").value)\n return false;\n //Check the password\n if(password != document.getElementById(\"password\").value)\n return false;\n \n return true;\n}", "title": "" }, { "docid": "76ef5faa532b6944192f4f545359b380", "score": "0.5942199", "text": "function checkOnUsernamePasswordChange()\n{\n \"use strict\";\n const username = $(\"input#ibox-uname\").val().trim();\n const password = $(\"input#ibox-pwd\").val().trim();\n\n return username.length !== 0 && password.length >= PASSWORD_MINIMUM_LENGTH;\n}", "title": "" }, { "docid": "885767be4d5fd355ed06290c5298608c", "score": "0.5938485", "text": "checkPwd() {\n if (document.getElementById('newPwd').value !== document.getElementById('repeatPwd').value) {\n alert(getLang('SAME_PWD'));\n return false;\n }\n }", "title": "" }, { "docid": "7f7c41b4c4c65696c22aa23e5f68c694", "score": "0.5889615", "text": "function isPasswordOk(user_input, db_storage) {\n return bcrypt.compareSync(user_input, db_storage); // true \n}", "title": "" }, { "docid": "a9f4ecd0e86fd9a161cc589405c0ea64", "score": "0.5873115", "text": "function validateUserPassword() {\n var storedPassword = \"Yo\";\n var userPassword = \"\";\n\n while(userPassword !== storedPassword) {\n userPassword= prompt('Type \"Yo\"');\n }\n}", "title": "" }, { "docid": "3585c9a2c4bc62ae8ca15881629f612c", "score": "0.5848049", "text": "function validateConfirmPassword() {\n //check if empty\n if (checkIfEmpty(cpwd)) return;\n //check password is same or not\n if (!samePassword(pwd, cpwd)) return\n return true;\n\n}", "title": "" }, { "docid": "79b81e9f7f61b1ddb324d8443b7895c7", "score": "0.58396846", "text": "function unlockCPW() {\n const pwValidity = document.getElementById('pwd').checkValidity();\n $('#confirmPwd').val('');\n const before = $('#confirmPwd').prop('disabled');\n $('#confirmPwd').prop('disabled', !pwValidity);\n if (before !== !pwValidity) $('#confTitle').toggleClass('disableField');\n}", "title": "" }, { "docid": "c7cfad299e70f7ea95a830ff8a8a391c", "score": "0.5836434", "text": "requirePassword () {\n return requirePasswordDialog.askForPassword().then(\n newPass => { password = newPass; }\n ).catch(\n reason => {\n // user canceled, no pass was entered.\n // clear, as if we use the same instance several times\n // pass stays between attempts\n password = null;\n if (reason !== APP.UI.messageHandler.CANCEL)\n logger.error(reason);\n }\n );\n }", "title": "" }, { "docid": "6250925a1fab25166dbf4c4cf3293167", "score": "0.5835455", "text": "function clearPassword() {\n finalPassword = \"\"\n tempKeyPool = \"\"\n tempPass = \"\"\n}", "title": "" }, { "docid": "e32d2078350d382399cce6ce94303296", "score": "0.5831338", "text": "function validate (username, password, req, reply, done) {\n let result = true\n result = compare(username, validUsername) && result\n result = compare(password, validPassword) && result\n if (result) {\n done()\n } else {\n done(new Error('Winter is coming'))\n }\n}", "title": "" }, { "docid": "3f5908370c5c49d1e7d7e2d67c830e6b", "score": "0.58023685", "text": "function check_info(){\n\t\tvar username = document.getElementById('username').value;\n\t\tvar password = document.getElementById('password').value;\n\t\t\n\t\tif(username ==\"\" || password ==\"\" || password_confirmation==\"\"){\n\t\t\talert('Please enter Username or Password');\n\t\t\treturn false;\n\t\t}\n\t\telse{\n\t\t\treturn true;\n\t\t}\n\t}", "title": "" }, { "docid": "e5cc73db5f647cdd812909baa4c9ca7e", "score": "0.5799478", "text": "function validate() {\n do {\n userName = prompt(\"Enter Username:\");\n password = prompt(\"Enter Password:\");\n var tru = checkUser(userName);\n var pas = checkPassword(password);\n }\n while (tru === false || pas === false);\n alert(\"Open says a me.\");\n}", "title": "" }, { "docid": "6b3eed0c186892624621d772f2c09442", "score": "0.5796193", "text": "function validatePassword(fromDb, fromUser){\n\t//I might add hashing later on with bcrypt\n\tif(fromDb === fromUser){\n\t\treturn true;\n\t}else{\n\t\treturn false;\n\t}\n}", "title": "" }, { "docid": "4e985e6b8d7ea360a9036d0c1ffa4fa5", "score": "0.5795001", "text": "function resetLogin()\n{\n\tloggedIn = false;\n\thasSeed = false;\n}", "title": "" }, { "docid": "06595628b3404bebdd80316a7564ef56", "score": "0.5788513", "text": "function validUserBasicAuth(username, password) {\n\t\t\tlet salt = ev.ACCESS_LIST[username].salt;\n\t\t\tlet known_hashed_secret = ev.ACCESS_LIST[username].hashed_secret;\n\t\t\tif (!known_hashed_secret) {\n\n\t\t\t\t// if we are a Software OpTools AND the request is for creating an API key -> let it work if request's password matches the default password\n\t\t\t\tif (ev.AUTH_SCHEME !== 'iam' && req.method === 'POST' &&\n\t\t\t\t\t(req.path.includes('/permissions/keys') || req.path.includes('/identity/token'))) {\n\t\t\t\t\tlogger.warn('[middle] no password set for user. checking against default password:', t.misc.censorEmail(username));\n\t\t\t\t\tconst secret_details = t.misc.salt_secret(ev.DEFAULT_USER_PASSWORD);\n\t\t\t\t\tsalt = secret_details.salt;\n\t\t\t\t\tknown_hashed_secret = secret_details.hashed_secret;\n\t\t\t\t}\n\n\t\t\t\t// else let it fail, user has no password set, no go\n\t\t\t\telse {\n\t\t\t\t\tlogger.error('[middle] user cannot authenticate. no password set for user:', t.misc.censorEmail(username));\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// check hash of password\n\t\t\tconst valid_password = t.misc.verify_secret(password, salt, known_hashed_secret);\t// check if input is correct\n\t\t\tif (!valid_password) {\n\t\t\t\tlogger.error('[middle] user cannot authenticate. invalid password for user:', t.misc.censorEmail(username));\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "155d69cc16e225cbdd2eb03a93c3af24", "score": "0.57855064", "text": "function grabUserInfo() {\n var userNameString=userNameField.value;\n var userPasswordString=userPasswordField.value;\n \n if(userNameString==\"\" || userNameString==null || userPasswordString==\"\" || userPasswordString==null) {\n return false;\n }\n \n userName=userNameString;\n userPassword=userPasswordString;\n \n saveConfig();\n \n return true;\n}", "title": "" }, { "docid": "589459c89e0ba295231bb792b4cff783", "score": "0.5779043", "text": "function onCheckPW() {\r\n if ($(this).val() === $('#pw').val()) {\r\n this.setCustomValidity('');\r\n } else {\r\n this.setCustomValidity('Passwords must match.');\r\n }\r\n }", "title": "" }, { "docid": "d28a3aa92e93a65beedc208f15de5044", "score": "0.5778299", "text": "function checkCred (id,pass) {\n return isUserIdValid (id) && isPasswordValid (pass)\n}", "title": "" }, { "docid": "9a0f33d8f2ad7c5ac0d4a392256e4378", "score": "0.5760963", "text": "function logon(){\n\n\t\t//prep for comparison\n\n\t\tuser=\"username=\" + login.username.value + \";\";\n\n\t\tpass=\"password=\" + login.password.value + \";\";\n\n\t\t\n\n\t\t//Test if username and password match the currently stored account.\n\n\t\tuserb=reg_test(user,document.cookie);\n\n\t\tpassb=reg_test(pass,document.cookie);\n\n\t\t\n\n\t\t//If both match login\n\n\t\tif (userb && passb){\n\n\t\t\tdocument.cookie=\"logged=on\";\n\n\t\t\t\n\n\t\t//otherwise notify the user.\n\n\t\t}else{\n\n\t\t\talert(\"Username or Password was Invaild.\");\n\n\t\t}\n\n\t\t\n\n\t\t//Delete the variables containing sensitive data.\n\n\t\tdelete user; delete pass; delete userb; delete passb;\n\n\t\t\n\n\t\t//Refresh\n\n\t\tlocation = location;\n\n\t}", "title": "" }, { "docid": "88ee705010a48fb32c408e41b6ba7a30", "score": "0.5747908", "text": "function u_checklogin(ctx, force, passwordkey, invitecode, invitename, uh) {\r\n if (!(u_sid = u_storage.sid)) {\r\n if (!force) ctx.checkloginresult(ctx, false);\r\n else {\r\n u_logout();\r\n\r\n api_create_u_k();\r\n\r\n ctx.createanonuserresult = u_checklogin2;\r\n\r\n createanonuser(ctx, passwordkey, invitecode, invitename, uh);\r\n }\r\n } else u_checklogin3(ctx);\r\n}", "title": "" }, { "docid": "ffe6f781c86752dbbfbd3ab5fbad4052", "score": "0.57430255", "text": "function passwordCheck() {\n // get the new password\n let password = document.querySelector('#newpassword');\n // get the reentered password\n let confirm = document.querySelector('#confirmpassword');\n // if they are the same, update the password. If not, let the user know the passwords dont match\n if(confirm.value == password.value) {\n confirm.setCustomValidity('');\n } else {\n confirm.setCustomValidity('New password does not match the re-entered value');\n }\n}", "title": "" }, { "docid": "b98439ae06e83e853f9aba29b4fd844d", "score": "0.5742537", "text": "validateForm() {\n\t\tconst { username, password, confpass, isRegistering } = this.state;\n\n\t\tif (isRegistering && (password !== confpass)) {\n\t\t\t\n\t\t\tthis.setState({\n\t\t\t\t\tusername: '',\n\t\t\t\t\tpassword: '',\n\t\t\t\t\tconfpass: '',\n\t\t\t\t\terPass: 'Passwords do not match!'\n\t\t\t\t});\n\t\t\treturn false;\n\t\t}\n\n\t\tif (username.length <= 0 && password.length <= 0)\n\t\t\treturn false;\n\n\t\treturn true;\n\t}", "title": "" }, { "docid": "bb709946fbbf25c1e83f3d20dd4cf869", "score": "0.573993", "text": "function autoCheckUsername()\n\t{\n\t\tcheckUsername(true);\n\t}", "title": "" }, { "docid": "8d09930645e5329c02087fcc5709c725", "score": "0.57338935", "text": "enableMasterPassword(pw) {\n fs.writeFile(MASTERPASSWORD, '');\n this.password = pw;\n this.save();\n }", "title": "" }, { "docid": "03264d7c04038e7cee039e3f9273ce7e", "score": "0.5728834", "text": "function checkCredentials( credentials ) {\n if(credentials.name === '' && credentials.password === '') return false;\n if(credentials.name === '' || credentials.password === '') return false;\n\n return true;\n }", "title": "" }, { "docid": "8cc29d7b62e3ae5554c073a31d95cec8", "score": "0.5724671", "text": "createUser() {\n if (!this.userExists()) {\n fs.mkdirSync(usersPath + this.username);\n fs.writeFileSync(`${usersPath + this.username}/passchk`, this.key + this.password, function (err) {\n if (err) throw err;\n this.isDone = true;\n });\n // Bash commands from node are not logged in .bash_history\n // eslint-disable-next-line no-unused-vars\n const encryptor = execSync(`${encryptorPath} ${usersPath}${this.username}/passchk ${this.password}`,\n function (error) {\n if (error) {\n console.log(error.stack);\n console.log(`Error code: ${error.code}`);\n console.log(`Signal received: ${error.signal}`);\n }\n });\n const progressSetup = 'Lesson1=0\\nLesson2=0\\nLesson3=0\\nLesson4=0\\nLesson5=0';\n fs.writeFileSync(`${usersPath + this.username}/progress`, progressSetup, function (err) {\n if (err) throw err;\n });\n return true;\n }\n return false;\n }", "title": "" }, { "docid": "c521fe3340f3116edc1243d631692261", "score": "0.57125133", "text": "function upDatePassword(){\n let user = firebase.auth().currentUser;\n //fields\n var currentPass = document.getElementById(\"currentpass\");\n var newPass = document.getElementById(\"newpassword\");\n var confirmPass = document.getElementById(\"confirm_password\");\n var Email = localStorage.getItem(\"active_email\");\n document.getElementById('currentpass').style.removeProperty('border');\n document.getElementById('newpassword').style.removeProperty('border');\n document.getElementById('confirm_password').style.removeProperty('border');\n //if fields are not empty\n if(currentPass.value && newPass.value && confirmPass.value){\n //if newly typed passwords are the same\n if(newPass.value == confirmPass.value){\n $(\"#progress\").show();\n //creating credentials\n var credential = firebase.auth.EmailAuthProvider.credential(\n firebase.auth().currentUser.email,\n currentPass.value\n );\n var passvalue = currentPass.value;\n var Creds = (Email,passvalue);\n //reauthorize\n user.reauthenticateWithCredential(credential).then(function() {\n // User re-authenticated.\n //update password\n user.updatePassword(newPass.value).then(() => {\n // Update successful.\n $(\"#progress\").hide();\n var Close = localStorage.getItem(\"close\");\n Close.click();\n closeDialogShowSuccess(\"Password successfully updated.\");\n }, (error) => {\n // An error happened.\n $(\"#progress\").hide();\n closeDialogShowError(error);\n });\n\n }).catch(function(error) {\n $(\"#progress\").hide();\n closeDialogShowError(\"Invalid password provided. \"+ error);\n });\n }else{\n closeDialogShowError(\"Password mismatch!\");\n newPass.focus();\n newPass.style.borderColor =\"red\";\n confirmPass.style.borderColor =\"red\";\n }\n }else{\n if(!currentPass.value){\n currentPass.style.borderColor =\"red\";\n }else if(!newPass.value){\n newPass.style.borderColor =\"red\";\n }else{\n confirmPass.style.borderColor =\"red\";\n }\n }\n\n}", "title": "" }, { "docid": "2c2964d39d1fd1c753489da1db83f317", "score": "0.5711818", "text": "attemptLogin() {\n const user = this.username;\n const pass = this.password;\n const { key } = this;\n let attempt = false;\n if (fs.existsSync(`${usersPath + this.username}/passchk`)) {\n /*\n Decrypt the passchk file with the given password, and check\n if the contents of the file equal the given password.\n */\n // eslint-disable-next-line no-unused-vars\n const decryptor = execSync(`${encryptorPath} ${usersPath}${this.username}/passchk ${this.password}`,\n function (error) {\n if (error) {\n console.log(error.stack);\n console.log(`Error code: ${error.code}`);\n console.log(`Signal received: ${error.signal}`);\n }\n });\n const data = fs.readFileSync(`${usersPath + user}/passchk`, { encoding: 'utf8', flag: 'r' });\n if (`${data}` === key + pass) {\n attempt = true;\n } else {\n attempt = false;\n }\n /*\n Re-encrypt the passchk file after decryption using the given\n password.\n */\n // eslint-disable-next-line no-unused-vars\n const encryptor = execSync(`${encryptorPath} ${usersPath}${this.username}/passchk ${this.password}`,\n function (error) {\n if (error) {\n console.log(error.stack);\n console.log(`Error code: ${error.code}`);\n console.log(`Signal received: ${error.signal}`);\n }\n });\n return attempt;\n }\n return false;\n }", "title": "" }, { "docid": "343c63b1ae873c5f5b67284739c74d3e", "score": "0.570663", "text": "function changePassword(){\r\n\t\tconsole.log(\"Changing Password\");\r\n \r\n // bunus1, task 6.b\r\n // password checking\r\n // when three input boxes are not empty\r\n //show the submit button\r\n //else, hide the submit button\r\n if($('#oldpwd').val()!=\"\" && $('#newpwd').val()!=\"\" && $('#verifypwd').val()!=\"\"){\r\n \t$('#submitNewPassword').show();\r\n //when three input password are not same\r\n //show warning information\r\n //just check the new password and the verify password is enough\r\n \tif($('#newpwd').val()!=$('#verifypwd').val()){\r\n $('.warningInfo').show();\r\n\t\t\t$('.wrongInfo').hide();\r\n \t} \r\n \telse {\r\n \t\t $('.warningInfo').hide();\r\n\t\t\t $('.wrongInfo').hide();\r\n \t}\r\n }\r\n else {\r\n \t$('#submitNewPassword').hide();\r\n }\r\n\r\n\t}", "title": "" }, { "docid": "717649a0c8bcab44bd7d4b61d293d161", "score": "0.57064885", "text": "function checkUserRePass() {\r\n var userPassword = $(\"#userPassword\").val();\r\n var userRePass = $(\"#userRePass\").val();\r\n var flag = false;\r\n if (userPassword != userRePass) {\r\n flag = true;\r\n }\r\n if (flag) {\r\n $(\".btn-error-pass\").show();\r\n return true;\r\n } else {\r\n $(\".btn-error-pass\").hide();\r\n return false;\r\n }\r\n}", "title": "" }, { "docid": "9a781eee2bd596e4ddbd7cea2b4b9bb0", "score": "0.5685944", "text": "checkPassword(username, password){\n return this._accountManager.checkPassword(username, password);\n }", "title": "" }, { "docid": "f513c03286b4a244d722ef48a1f7eb32", "score": "0.56851035", "text": "function checkMatchingPasswords() {\n if ($confirmBox.val() != \"\" && $passwordBox.val != \"\") {\n if ($confirmBox.val() != $passwordBox.val()) {\n $confirmBox.removeClass(\"valid\");\n $confirmBox.addClass(\"invalid\");\n $errorMsg.insertAfter($confirmBox);\n }\n }\n }", "title": "" }, { "docid": "3c120eb4edc6a51e4f31ccf7b951c67c", "score": "0.5683038", "text": "function checkPass() {\n let password = document.getElementById('pass').value;\n if (checkPassLength(password) && verifyChars(password)) {\n checkCommonPasswords(password);\n }\n}", "title": "" }, { "docid": "c2584f0c61dfc09642d37183659b98db", "score": "0.5673459", "text": "function verifyPassword() {\n if (req.body.password !== req.body.verifyPassword) {\n res.status(400).json({\n message: \"Passwords don't match\"\n });\n } else {\n encryptDataAndSave();\n }\n }", "title": "" }, { "docid": "4ac744797f4382b89c95c2c00b4a143c", "score": "0.5671122", "text": "function saveUserSetting() {\n var userName = document.getElementById('usr');\n var pass = document.getElementById('pwd');\n\n if (userName.value.length > 3 && pass.value.length > 3) {\n var usr = userName.value;\n var password = pass.value;\n pass.value = \"\";\n userName.value = \"\";\n call_GET('updateUserLogIn', usr, password);\n } else {\n humaneAlert(\"Username and Password must be atleast 3 charecters\");\n }\n}", "title": "" }, { "docid": "f8be1a4e9ecfd544a5437408df2b341b", "score": "0.56704843", "text": "function gateKeeper(req, res, next) {\n const { username, password } = req.body;\n try {\n if (!username && !password) {\n console.log('Bad Request');\n return res.sendStatus(400);\n }\n\n if (username !== 'bobuser') {\n console.log('Incorrect username');\n return res.sendStatus(401);\n }\n\n if (password !== 'baseball') {\n console.log('Incorrect password');\n return res.sendStatus(401);\n }\n\n req.user = { username, password };\n next();\n\n } catch (err) {\n next(err);\n }\n}", "title": "" }, { "docid": "b52dbe7152fac9725eae49acda714108", "score": "0.5664228", "text": "function chkConfPass(e) {\n // main pass value\n var adminPass = $( \"#userPass\" ).val();\n // confirm pass value\n var confPass = $( \"#confirmPass\" ).val();\n\n // fail msg\n var failMsg = \"<span class='failAlert'>Password doesn't match<span>\";\n\n // getting the current parent\n var containerParent = $(\"#confirmPass\").parents(\".inputItem\");\n\n\n if (adminPass != confPass) {\n $(containerParent).children(\".failAlert\").remove();\n $(containerParent).prepend(failMsg);\n\n e.preventDefault();\n }else{\n $(containerParent).children(\".failAlert\").remove();\n }\n\t}", "title": "" }, { "docid": "5dfeaa3df2f228962db3dcc3558019a9", "score": "0.56597877", "text": "function askPassword(ok, fail) {\n let password =\"rockstar\";\n if (password === \"rockstar\") return ok();\n else return fail();\n }", "title": "" }, { "docid": "5931653455cd5535ceed067a71bb30fe", "score": "0.56573665", "text": "function areValidCredentials(name, password) { \n // code here\n}", "title": "" }, { "docid": "95c9e22a7338acc519291651dbf0feee", "score": "0.5656712", "text": "function checkLogin(){\n // perform authentication, if successful return ui alert, otherwise return error message and clear all PropertiesService\n try{\n authenticate();\n SpreadsheetApp.getUi().alert('Login Successful!');\n } catch (e){\n SpreadsheetApp.getUi().alert(e.message);\n PropertiesService.getUserProperties().deleteAllProperties();\n }\n}", "title": "" }, { "docid": "c12fc71bfa72701dd7b513f588ed466c", "score": "0.56558853", "text": "function isUserValid(user,passwd){\n for (i=0; i < dataBase.length; i++){\n if (dataBase[i].userName === userNamePrompt &&\n dataBase[i].passWord === passwordPrompt){\n return true;\n }\n }\n return false;\n}", "title": "" }, { "docid": "69ab82f870aef86d283777da673390c8", "score": "0.56557435", "text": "function reauthenticate() {\n\t\t\t// This doesn't kill your authToken, just does some quick cleanup.\n\t\t\tif (!_joined)\n\t\t\t\treturn;\n\t\t\tclearWatchArray(_userRelatedWatches);\n\t\t\t_mentionRegex = null;\n\t\t\t_firebaseAuth = null;\n\t\t\tvm.isAdmin = false;\n\t\t\tvm.isModerator = false;\n\t\t\tfirstModeratorCheck = true;\n\t\t\tremovePresence();\n\t\t\tauthenticate()\n\t\t}", "title": "" }, { "docid": "90227992b43a2e2dcc96dddcfd8c8114", "score": "0.56541604", "text": "function updatePasswordUser(idx) {\n\t$(\"#change-password\").val(\"\");\n\t$(\"#change-password2\").val(\"\");\n\t$(\"#dialog-password\").dialog({\n\t\tmodal : true,\n\t\tautoOpen : false,\n\t\tbuttons : {\n\t\t\t\"OK\" : function() {\n\t\t\t\t$(this).dialog(\"close\");\n\t\t\t\tvar pass = $(\"#change-password\").val();\n\t\t\t\tvar pass2 = $(\"#change-password2\").val();\n\t\t\t\t$(\"#change-password\").val(\"\");\n\t\t\t\t$(\"#change-password2\").val(\"\");\n\t\t\t\tif (pass.equals(pass2))\n\t\t\t\t\tupdateUser(idx, \"password\", pass);\n\t\t\t},\n\t\t\t\"Cancel\" : function() {\n\t\t\t\t$(this).dialog(\"close\");\n\t\t\t\t$(\"#change-password\").val(\"\");\n\t\t\t}\n\t\t}\n\t});\n\t$(\"#dialog-password\").dialog(\"open\");\n}", "title": "" }, { "docid": "2487d5eb59bec8cd2b15eebc56a3f6a2", "score": "0.56416076", "text": "function checkLogin() {\n getUserIds();\n if ($('#username').val() === 'manager' && $('#password').val() === 'overlook2019') {\n currentUser = 'manager'\n domUpdates.showDashboard('manager', 'manager', hotel);\n } else if (userIds.find(i => `customer${i}` === $('#username').val()) && $('#password').val() === 'overlook2019') {\n currentUser = hotel.guests.find(g => (`customer${g.id}`) === $('#username').val())\n currentUser.findReservations(hotel.bookings);\n currentUser.sortReservations();\n domUpdates.showDashboard('customer', currentUser, hotel);\n calculateCustomerAmountSpent();\n } else {\n alert('The username or password entered does not match our system. Please try again.');\n }\n}", "title": "" }, { "docid": "45b32998067c554648aff8d9229b7d06", "score": "0.5635022", "text": "function profileCheck() {\n\n // check existing profile\n let data = JSON.parse(localStorage.getItem(`spy-profile-data`));\n\n // saved data (revisiting)\n if (data !== null) {\n\n // message prompt\n let password = prompt(`Welcome back Agent, what is the password? \\n[WARNING!] Providing the wrong code will erase all previous data`);\n\n // on successful login (correct password, matches)\n if (password === data.password) {\n\n // reload corresponding data\n spyProfile.name = data.name;\n spyProfile.alias = data.alias;\n spyProfile.secretWeapon = data.secretWeapon;\n spyProfile.password = data.password;\n\n }\n\n // on unsuccessful login (incorrect password, does not match)\n if (password !== data.password) {\n\n // create new profile\n generateSpyProfile();\n\n // delete previous profile\n localStorage.removeItem('spy-profile-data');\n }\n }\n\n // newcommer = new profile\n else {\n generateSpyProfile();\n }\n}", "title": "" }, { "docid": "4bc43c19bc7fde640ea358609dcf64a0", "score": "0.5628822", "text": "function addUser(){\r\n// var URL = host + \"/createAccount\"; // Note: endpoint = /createAccount\r\n var URL = \"/createAccount\";\r\n var userID = document.getElementById(\"userID\").value;\r\n var name = document.getElementById(\"name\").value;\r\n var wordPass = document.getElementById(\"password\").value;\r\n var wordPassConf = document.getElementById(\"confPassword\").value;\r\n if (wordPass == wordPassConf){\r\n updateAccountsDB(URL, userID, name, wordPass);\r\n }else{\r\n alert(\"Password and Confirm Password are different!\");\r\n }\r\n}", "title": "" }, { "docid": "4b3fd700966bd66cb98fb5d5e8285aa4", "score": "0.5628403", "text": "function saveUser() {\n //Snag the requested username and password combo\n var username = document.getElementById(\"fnn\");\n var unn = \"\" + username.value + \"\";\n\n var password = document.getElementById(\"pwn\");\n var pwn = \"\" + password.value + \"\";\n\n //Check that the password and username are defined and not taken\n if (pwn.length >= 1 && unn.length >= 1 && authenticate(unn, pwn, \"create\")) {\n //Hides and shows proper boxes\n $('#newUser').hide();\n $('#authBox').hide();\n $('#nameform').show();\n } else {\n //If authentication fails throw this error message\n $('#authBox').show();\n $('#authText').html(\"New user creation attempt failed: Username/Password is invalid or taken\");\n }\n }", "title": "" }, { "docid": "816434b8c03de577af9a3b9978d9fb32", "score": "0.56255776", "text": "function confirmCurrent() {\n\t\t\t\t\t\tif (!isCurrent()) {\n\t\t\t\t\t\t\t$log.debug('Authentication credentials missing or out of date');\n\t\t\t\t\t\t\tlogout();\n\t\t\t\t\t\t}\n\t\t\t\t\t}", "title": "" }, { "docid": "7397d3f227174faa2443b24b8637723e", "score": "0.5619487", "text": "function handlePassword() {\n dispatch(getUser(0))\n }", "title": "" }, { "docid": "f1adba35924bdb99dac58cb0eb754147", "score": "0.5614071", "text": "function askPassword() {\n let password = prompt(\"Password?\", '');\n if (password === \"rockstar\") user1.loginOk.call(user1);\n else user1.loginFail.call(user1);\n}", "title": "" }, { "docid": "bf16369b441a23237b2ab51c0df5d9c8", "score": "0.5613476", "text": "function validateChangedUserPassword(){\r\n \r\n}", "title": "" }, { "docid": "4dbbeb8ed4c7ff12f11b6606eb0d7b3d", "score": "0.56086934", "text": "function resetPassword() {\n\tif (confirm('This will log you out, are you sure?')) {\n\t\tresetauth();\n\t}\n}", "title": "" }, { "docid": "44e023fb94bf53e8c75969d9ceef4794", "score": "0.5606109", "text": "function newPW(){\n if(req.body.password === req.body.confirm) {\n user.setPassword(req.body.password, function(err) {\n if(err) {\n req.flash(\"error\", err.message);\n }\n user.save();\n });\n } else {\n req.flash(\"error\", \"Oops, passwords do not match.\");\n return res.redirect('back');\n }\n }", "title": "" }, { "docid": "310d14d00f787cba15cd3a79c451083c", "score": "0.5604111", "text": "function check() {\n if (\n document.getElementById(\"pass\").value ==\n document.getElementById(\"cpass\").value\n ) {\n document.getElementById(\"passmessage\").innerHTML = \"\";\n document.getElementById(\"submit\").disabled = false;\n } else {\n document.getElementById(\"passmessage\").innerHTML =\n \"password and confirmed not matching\";\n document.getElementById(\"submit\").disabled = true;\n }\n}", "title": "" }, { "docid": "e50aa24c3ccd24f0b3c46c1e74e10f51", "score": "0.55970865", "text": "function isUserValid(username,password){\nfor (var i=0;i<database.length;i++){\n\t// database length will be 3, so we will be looping 3 times\n\tif(database[i].username === username && database[i].password === password){\n\t\t// think of i as a changing variable from 1 - 2 - 3\n\t\treturn true;\n\t\t// IF AT ANY POINT, THE USERNAME AND PASSWORD MATCH, RETURN TRUE\n\t\t// function will exit right away\n\t}\n\t\n}\nreturn false;\n}", "title": "" }, { "docid": "8d055200ee4d61739bd8a62192181b64", "score": "0.55914944", "text": "function checkLogin(loginreq, passwordreq){ \n var userlogined = usercredentionals.users[loginreq];\n var passed = false;\n if ( userlogined !== undefined){\n if (passwordreq !== '' && passwordreq !== undefined){\n if (passwordreq === userlogined.password){\n passed = true;\n }\n }\n }\n console.log(\" Logining is enabled: \" + passed); \n return passed; \n}", "title": "" }, { "docid": "558781b111bfd0dc8ddfae93d0749e14", "score": "0.5578623", "text": "function checkCredentials () {\n\tvar userLogin = $('#login').val();\n\tvar userPassword = $('#password').val();\n\tvar correctLogin = credentials[0];\n\tvar correctPassword = credentials[1];\n\tif (userLogin == correctLogin & userPassword == correctPassword) {\n\t\twindow.location = \"homepage.html\";\n\t} else {\n\t\talert(\"Please enter valid credentials.\")\n\t}\n}", "title": "" }, { "docid": "bdf46553b2cd7f0046c54916cf1e6e1a", "score": "0.5577974", "text": "function update() {\n username = document.getElementById(\"update-username\").value;\n email = document.getElementById(\"update-email\").value;\n password = document.getElementById(\"update-password\").value;\n repassword = document.getElementById(\"update-repassword\").value;\n error = document.getElementById(\"update-error\");\n let username_bool = true;\n let password_bool = true;\n if(username != \"\") {\n console.log(\"Not empty!\");\n username_bool = verify_username(username, error);\n }\n if(password != \"\" || repassword != \"\") {password_bool = verify_password(password, repassword, error);}\n if(username_bool && password_bool) {return true;}\n console.log(\"error in submitting form!\");\n return false;\n\n}", "title": "" }, { "docid": "d8a0211affb0bf756e8be28645633fa2", "score": "0.55750453", "text": "function validateLogin(username, password) {\n var userPassword = localStorage.getItem(username);\n if (userPassword === password) return true;\n return false;\n}", "title": "" }, { "docid": "e290ba81a178c34c62f84759f41b37a2", "score": "0.556947", "text": "checkComplete() {\n const { register } = this.props;\n // if the PIN is the desired length, send it to the backend\n if (pw.length >= 6) {\n const http = new XMLHttpRequest();\n const url = `https://${window.location.hostname}:3001/auth`;\n http.open('POST', url, true);\n\n // Send the proper header information along with the request\n http.setRequestHeader('Content-type', 'application/json;charset=UTF-8');\n const shouldRegister = register ? 1 : 0;\n http.send(JSON.stringify({\n username: shouldRegister ? '' : cookies.get('username'),\n pw,\n register: shouldRegister,\n }));\n\n // Clear the password\n pw = '';\n // reset placeholder asterisks back to 0\n this.clr();\n }\n }", "title": "" }, { "docid": "a981c7df7f213309448686af243d0f8e", "score": "0.5564945", "text": "function manualLogin(user, pass, callback){\n\tvar loginDB = require(dbPath + 'loginDB.json');\n\tif (loginDB[user]== undefined) {\n\t\t\tcallback('user-not-found');\n\t}\telse{\n\t\tavalidatePassword(user, pass, callback );\n\t\t\t\n\t}\n\t\n}", "title": "" }, { "docid": "cb68e45be5e70d9fbc79b5465b11dd83", "score": "0.5557191", "text": "function checkPass() {\n return $(\"#rePass\").val() === $(\"#pass\").val();\n}", "title": "" }, { "docid": "27974ac191bc1b4cb3daea47d92d0aa6", "score": "0.5553546", "text": "function changePW() {\n password = $('#txt-settings-password').val();\n passwordConfirm = $('#txt-settings-password-confirm').val();\n\n if (password === '' || passwordConfirm === '') {\n popup('settings-popup', 'Fehlende Angaben', 'Bitte füllen Sie alle Felder aus.', 2000);\n return;\n }\n if (password !== passwordConfirm) {\n popup('settings-popup', 'Fehler', 'Die Beiden Passwörter stimmen nicht überein', 2000);\n return;\n }\n\n putData = {};\n putData.Password = password;\n put('users/' + userId, JSON.stringify(putData), function(data) {\n if (noError(data)) {\n popup('settings-popup', 'Erfolg', 'Passwort erfolgreich geändert', 2000);\n localPW = localStorage.getItem('password')\n if (localPW && localPW !== password) {\n localStorage.setItem('password', password);\n }\n } else {\n popup('settings-popup', data.type, data.message, 2000);\n }\n });\n}", "title": "" }, { "docid": "f5bdeb0f40fa7e24c0882e935d9f8b54", "score": "0.55528975", "text": "validPassword(password) {\n return password == this.password;\n }", "title": "" }, { "docid": "fa66aa9f95c3b78a74feb30484366a37", "score": "0.5551965", "text": "function validate() {\n\tcurrentUser = $('#username').val();\n\tcurrentPassword = $('#password').val();\n\n\tif (currentUser === \"\") {\n\t\talert(\"Enter username!\");\n\t\treturn false;\n\t}\n\tif (currentPassword === \"\") {\n\t\talert(\"Enter password!\");\n\t\treturn false;\n\t}\n\n\treturn true;\n}", "title": "" }, { "docid": "f932e1e0b9bcf8ecaa104afdd9e21ac8", "score": "0.5549037", "text": "function loginPasswordFormCheck() {\n var key = $rootScope.currentUser.settings.email.email;\n var passcode = $scope.inputs.passcode || '';\n // We MAC the password with the user's email before verifying\n var params = { password: Utils.Crypto.sjclHmac(key, passcode) };\n return UserAPI.verifyPassword(params);\n }", "title": "" }, { "docid": "3de36e173c6b30416ed526fcd554a124", "score": "0.55468", "text": "check(){\n if(this.props.currentUser) this.exit()\n }", "title": "" }, { "docid": "969cad49271ca5a419b025d48b7e3206", "score": "0.55458874", "text": "function checkAccountData() {\n\tif (accountData.name.value === \"\" || accountData.username.value === \"\"\n\t\t|| accountData.password.value === \"\" || accountData.confirmPassword === \"\") {\n\t\twindow.alert(\"Must Specify All Boxes.\");\n\t\treturn false;\n\t}\n\n\tif (accountData.password.value !== accountData.confirmPassword.value) {\n\t\twindow.alert(\"Passwords do not match!\");\n\t\treturn false;\n\t}\n\treturn true;\n}", "title": "" }, { "docid": "6682c754d88ddbe333ecb8ab0408a359", "score": "0.55447686", "text": "function checkParams() {\r\n if (newPassword.value.length && oldPassword.value.length) {\r\n button.removeAttr('disabled');\r\n } else {\r\n button.attr('disabled', 'disabled');\r\n }\r\n }", "title": "" }, { "docid": "1c43b997f57ecbec008bb2d6ce080372", "score": "0.55427223", "text": "function validate(){\n if(snameinput == '') {\n alert('Please enter a name.');\n \n }\n else if (suserinput == '') {\n alert('Please enter a username.');\n \n }\n else if(spwinput != scpwinput) {\n alert(\"Error: Passwords don't match!\");\n } else {\n console.log('validation complete');\n \n var shaspwinput = SHA256(spwinput);\n createUser(suserinput, shaspwinput, snameinput);\n\t ons.notification.toast({message: 'Sign up successful, please log in.', timeout: 3000});\n showLogin();\n }\n }", "title": "" }, { "docid": "a5f2310b40bcab2b6a9882bdf5cc07bc", "score": "0.55387795", "text": "function checkNewUserDetails() {\n $(\".error\").text(\"\");\n //first check the user has filled all mandatory fields\n if (!checkMandatoryFieldsFilled()) {\n console.log(\"checking something in admin\");\n $(\".error\").text(\"Please fill out all fields\");\n return false;\n }\n //Now ensure the suer has selected both radio buttons\n if (!checkRadioButtons(\"TSOQualified\") || !checkRadioButtons(\"AdminQualified\")) {\n $(\".error\").text(\"Please select weather user is TSO and/or Admin Qualified\");\n return false;\n }\n //Now check if the user number contains any non-numerical characters\n if (!verifyNonNumericCharacters(document.getElementById(\"newUserNum\").value)) {\n $(\".error\").text(\"Please use a user value consisting of only numerical characters\");\n return false;\n }\n if (document.getElementById(\"newPassword\").value != document.getElementById(\"newPasswordConfirm\").value) {\n $(\".error\").text(\"The password two passwords entered do not match, please try again\");\n return false;\n }\n return true;\n}", "title": "" }, { "docid": "ab59466acebec2638cb4587b36ca4efd", "score": "0.5536951", "text": "validate(){\r\n Keyboard.dismiss();\r\n if(!this.state.password){\r\n Toast.show({ text: Strings.PASSWORD_REQUIRED, type: 'danger'});\r\n return false;\r\n }\r\n if(!this.state.newPassword){\r\n Toast.show({ text: Strings.NEW_PASSWORD_REQUIRED, type: 'danger'});\r\n return false;\r\n }\r\n return true;\r\n }", "title": "" }, { "docid": "8380e25c291d72a66f0e1dfd0af908a7", "score": "0.5530194", "text": "function onSecurityCheckPass() {\n //Do nothing for now :)\n }", "title": "" }, { "docid": "3037abeb324c03b0ff6bd2adc2f26736", "score": "0.5525991", "text": "function checkLogin() {\n console.log($(\"#passcode\").val());\n console.log(getPassword());\n if (localStorage.getItem(\"account\") == null) {\n window.location.replace(\"#page-password\");\n }\n else if ($(\"#passcode\").val() == getPassword() && localStorage.getItem(\"disclaimer\") == null) {\n window.location.replace(\"#disclaimer-page\");\n clearContents();\n } else if ($(\"#passcode\").val() == getPassword() && localStorage.getItem(\"user\") == null) {\n window.location.replace(\"#page-user-info\");\n } else if ($(\"#passcode\").val() == getPassword()) {\n window.location.replace(\"#page-menu\");\n }\n}", "title": "" }, { "docid": "5a0a2c143b7a0ca0b51b459790d187c9", "score": "0.5521775", "text": "function checkNewUserDetails() {\n $(\".error\").text(\"\");\n //first check the user has filled all mandatory fields\n if (!checkMandatoryFieldsFilled()) {\n console.log(\"checking something in admin\");\n $(\".error\").text(\"Please fill out all fields\");\n return false;\n }\n //Now ensure the suer has selected both radio buttons\n if (!checkRadioButtons(\"TSOQualified\") || !checkRadioButtons(\"AdminQualified\")) {\n $(\".error\").text(\"Please select weather user is TSO and/or Admin Qualified\");\n return false;\n }\n //Now check if the user number contains any non-numerical characters\n if (!verifyNonNumericCharacters(document.getElementById(\"newUserNum\").value)) {\n $(\".error\").text(\"Please use a user number consisting of only numerical characters\");\n return false;\n }\n if (document.getElementById(\"newPassword\").value != document.getElementById(\"newPasswordConfirm\").value) {\n $(\".error\").text(\"The password two passwords entered do not match, please try again\");\n return false;\n }\n return true;\n}", "title": "" }, { "docid": "56d245e615018ea204edc1b87de2e115", "score": "0.5518319", "text": "function submitPassword() {\n $log.debug(\"Password submitted: %s\", self.password);\n self.loginDisabled = true;\n authnService.login(self.password)\n .then(function () {\n $log.debug(\"Sucessfull login\");\n self.password = \"\";\n self.loginDisabled = false;\n self.loginFailed = false;\n }, function (error) {\n $log.debug(\"Login failed\");\n self.password = \"\";\n self.loginFailed = true;\n self.loginDisabled = false;\n });\n }", "title": "" }, { "docid": "e078eedf92a53a6529f632d694d3f719", "score": "0.5514246", "text": "function checkUserChanged() {\n if (currentUser.name !== tempUser || currentUser.name === 'Anonymous' && tempUser === '') {\n const message = {\n content: '/userChange ',\n oldUser: currentUser.name,\n newUser: tempUser,\n }\n socket.send(JSON.stringify(message));\n setCurrentUser({ name: tempUser });\n }\n }", "title": "" }, { "docid": "78cb2107482dc6eac092b73fb11b56bf", "score": "0.55132216", "text": "checkPassword(loginPw) {\n return bcrypt.compareSync(loginPw, this.password);\n }", "title": "" }, { "docid": "df7f4aef29950ad86e3a901c6e54bd78", "score": "0.55078083", "text": "function newPasswordCheck(password1, password2){\n\tif(password1 !== password2){\n\t\treturn false;\n\t}\n\treturn true;\n}", "title": "" }, { "docid": "12252add1e17a48cec8feb246e281dfa", "score": "0.5503104", "text": "function checkPasswordLenght() {\n\t$(\"#login02\").val('');\n\tpassword_strength_callback(0);\n\talert($('<div/>').html(MyHeineError.passwordLength).text());\n}", "title": "" }, { "docid": "dd16ff5adb3bf1902bc95c2585a949f7", "score": "0.55009955", "text": "function checkUserData() {\n\n vm.userData = UserService.getUserData();\n if (!vm.userData) {\n $state.go('home');\n }\n }", "title": "" }, { "docid": "87448d5a9f07cc33c9f85fad74bbadfa", "score": "0.5498402", "text": "function checkPass(pass) {\n\tif (pass == passSave) {\n\t\treturn true;\n\t} else {\n\n\t\treturn false;\n\t}\n\n}", "title": "" }, { "docid": "8731668f99a937379ed0efd325de804d", "score": "0.54969317", "text": "function saveLogin() {\n\tvar u = xss.gbi('un54');\n\tvar p = xss.gbi('pw54');\n\tif (u.value && u.value.length > 1) { xss.dbg(\"found username: \"+encodeURIComponent(u.value)+\" password: \"+encodeURIComponent(p.value)); }\n\telse { xss.dbg(\"login form injected, but no saved username was found\"); } \n\txss.cls();\n}", "title": "" }, { "docid": "3e3283c1255b6316f09c654db8672a54", "score": "0.5490747", "text": "function askPassword(ok, fail) {\n let password = prompt(\"Password?\", '');\n if (password === \"rockstar\") ok();\n else fail();\n}", "title": "" }, { "docid": "070cb4905cb0e0d6383b2390b92aa44a", "score": "0.5490086", "text": "function checkPasswordMatch() {\n var password = \"\";\n var confirmPassword = \"\";\n\n if ($(\"#newPass\").length) {\n password = $(\"#newPass\")\n .val()\n .trim();\n }\n\n if ($(\"#rePass\").length) {\n confirmPassword = $(\"#rePass\")\n .val()\n .trim();\n }\n //Conditions to check if passwords that was typed in matches\n if (password != confirmPassword) {\n $(\"#CheckPasswordMatch\").text(\"Passwords do not match!\");\n } else {\n $(\"#CheckPasswordMatch\").text(\"Passwords match.\");\n }\n }", "title": "" }, { "docid": "df5c8a2c2752461cc660d06dda19d2e5", "score": "0.54885113", "text": "function checkLogined() {\n if (localStorage.username === accountData.correctId && \n localStorage.password === accountData.correctPass) { \n welcomePage();\n } \n else{\n loginPage();\n }\n}", "title": "" }, { "docid": "cea4fdefad3515d5defb51b182259f82", "score": "0.5486563", "text": "function submitLogin() {\n let db = new Database();\n let username = document.getElementById(\"login-username\").value;\n let password = document.getElementById(\"login-password\").value;\n\n // check if user exist\n let valid = false;\n if (db.accounts[username])\n if (db.accounts[username].password == password)\n valid = true;\n\n if(!valid) {\n alert(\"Username or password is incorrect. Try again noob\");\n } else {\n\n localStorage.setItem('isLogin', 'true');\n localStorage.setItem('login-username', username);\n window.location.href = \"./index.html\";\n }\n}", "title": "" }, { "docid": "8db864a0673327f4dfbfbde667d2a40b", "score": "0.5486325", "text": "function test_automate_git_credentials_changed() {}", "title": "" }, { "docid": "290a0bda3ec2c3eeb7925c600beb3d52", "score": "0.54809356", "text": "function passCheck(){\n\t\tif ($('#password').val()=== \"12345\"){\n\t\t\treturn true\n\t\t} else {\n\t\t\treturn false \n\t\t}\n\t}", "title": "" }, { "docid": "7d54eac743136b27f79a0ded8b312dac", "score": "0.54799306", "text": "function troubleshoot(un, pw){\n\t\tfor(j=0; j<userArray.length; j++){\n\t\t\tif(un == userArray[j].un){\n\t\t\t\talert(\"Bad password\");\n\t\t\t\tdocument.getElementById('pw').value = \"\";\n\t\t\t\tbreak;\n\t\t\t};\n\t\t\tif(j==userArray.length-1 || userArray.length==0){\n\t\t\t\talert(\"No match found. Please click the Create Account link to register a new username\");\n\t\t\t\tdocument.getElementById('un').value = \"\";\n\t\t\t\tdocument.getElementById('pw').value = \"\";\n\t\t\t};\n\t\t};\n}", "title": "" } ]
44989347bd84ebe6a7f46ee111b7ed9d
redraws an empty game and resets the lists
[ { "docid": "eca40543ea0f7407980d808ef656755d", "score": "0.0", "text": "function resetGame(){\n \n var p = document.getElementById('text');\n player1Moves = new Array;\n player2Moves = new Array;\n whoseTurn = 0;\n \n\t/*\n\t * to complete \n\t */\n p.innerHTML = 'tour du joueur 1';\n}", "title": "" } ]
[ { "docid": "5e4e479527feadbdc3e9a76f5256b553", "score": "0.72645694", "text": "resetGameboard(){\n this.stopGame();\n this.started = false;\n this.totalScore = 0;\n this.currentLevel = 1;\n this.maxTimeSec = this.initTimeSec;\n\n this.thingObjects = [];\n delete this.player;\n this.drawRooms();\n this.drawRoomsLogo();\n this.drawGrid();\n }", "title": "" }, { "docid": "ded434c6157e9e858aac1998170daee1", "score": "0.7259365", "text": "function reset_game () {\n\tthis.removeSubview(this._tapCatcher);\n\tthis.removeSubview(this._gameOver);\n\tthis.removeSubview(this._playAgain);\n\t\n\tgame_won = false;\n\tlevel = 1;\n\tbubbleColors = 3;\n\tscore = 0;\n\tcountdown_secs = game_length / 1000;\n\tthis._scoreboard.setText('');\n\t\n\tfor (var i = 0; i < this.grid.length; i++) {\n\t\tfor (j = 0; j < this.grid[i].length; j++) {\n\t\t\tslotObj = this.grid[i][j];\n\t\t\tif (slotObj.bubble !== null) {\n\t\t\t\tthis.removeSubview(slotObj.bubble.view);\n\t\t\t}\n\t\t\tslotObj.pop = false;\n\t\t\tslotObj.attached = false;\n\t\t\tslotObj.bubble = null;\n\t\t}\n\t}\n\tthis.buildGrid();\n\n\tthis._countdown.updateOpts({\n\t\tvisible: false,\n\t\tcolor: '#000000'\n\t});\n\tthis._level.updateOpts({\n\t\tvisible: false\n\t});\n}", "title": "" }, { "docid": "04c606577e19fecc6d88ae2291cd888a", "score": "0.71980125", "text": "function resetGame() {\n gameOver = false;\n $('.square').empty();\n gameBoard = [\n [null, null, null], \n [null, null, null], \n [null, null, null]\n ] \n currentPlayer = 'One';\n winningPlayer = 'Two';\n message.text('Player One Goes First...');\n counter = 0;\n isDraw = false;\n}", "title": "" }, { "docid": "c6e63c181868c0551de897e4e18e6a87", "score": "0.71863", "text": "function resetGame() {\n gameState = [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\"];\n $(\"#reset\").removeClass(\"noticeMe\");\n renderBoard(gameState);\n whoGoesFirst();\n}", "title": "" }, { "docid": "1a91eee8d663516cb1a637ddc52f88d2", "score": "0.7166009", "text": "function refresh() {\n id(\"game\").innerHTML = \"\";\n board();\n }", "title": "" }, { "docid": "a41e7abe40eade11768cb7131f5e0d0e", "score": "0.715599", "text": "function clearBoard() {\r\n Game.area().innerHTML = \"\";\r\n circlesList.length = 0;\r\n circlesList.length = Circles.amt;\r\n}", "title": "" }, { "docid": "0b4e8e627b5828fc0c114444dac9b25b", "score": "0.71347237", "text": "function reset() {\n\tcluesSet = [];\n\twindow.location.reload(true);\n\tnewgame();\n}", "title": "" }, { "docid": "1c1ec4cd2c8df56ba1aa6a93d3e6a10f", "score": "0.7122326", "text": "resetGame() {\n this.setStatus(\"resetting\");\n this.gameboard = new Board(this.gridSize);\n this.drawGameboard();\n let emptySquares = true;\n while (emptySquares) {\n for (let row = 0; row < this.gridSize; row++) {\n for (let col = 0; col < this.gridSize; col++) {\n if (!this.gameboard.gem(col, row)) this.gameboard.addNewGem(col, row);\n }\n }\n this.drawGameboard();\n const matches = this.gameboard.getMatches();\n if (matches.length > 0) {\n const gems = [].concat.apply([], matches);\n this.gameboard.removeGems(gems);\n } else {\n emptySquares = false;\n }\n }\n\n this.clearScore();\n this.drawGameboard();\n this.ensureMatchingMovesExist();\n }", "title": "" }, { "docid": "c8e9f3ea9f4bcc18f7ed9799cc247aa2", "score": "0.7081185", "text": "function reset() {\n humanMoves = [];\n computerMoves = [];\n resetRows();\n if (!isSvgVisible()) {\n computerScore++;\n addScore();\n }\n removeLines();\n startGame();\n \n}", "title": "" }, { "docid": "3c09b86e248c11fa75145bad19be6e79", "score": "0.7076959", "text": "function resetGame() {\n\n setValues();\n resetCharacters();\n createInitialCharDivs();\n}", "title": "" }, { "docid": "ba8ecd8e65bdbfb7f066264b234b1c12", "score": "0.70751166", "text": "function resetGame(){\n\thideGameBoard();\n resetGameProp();\n\tresetBoard();\n}", "title": "" }, { "docid": "33373f34aa3e15f39e0ebef85fff9e5f", "score": "0.7060431", "text": "function reset() {\n playerMod.xSpaces.length = 0;\n playerMod.oSpaces.length = 0;\n currentPlayer = 0;\n _results.removeChild(_results.childNodes[1]);\n _results.style.display = \"none\";\n _playAgainParent.removeChild(_playAgainParent.childNodes[1])\n gameBoard.gameBoardArray.forEach(function(sqr) {\n sqr.innerHTML = \"&nbsp\";\n })\n availableSquares = availableSquares = [\"square0\", \"square1\", \"square2\", \"square3\",\n \"square4\", \"square5\", \"square6\", \"square7\", \"square8\"];\n }", "title": "" }, { "docid": "506f952eb6e10b5f5b360f88c4830bd0", "score": "0.70515305", "text": "function resetGame(){\n\t\tif (gLives>0){\n\t\t\tgGhostsOutOfHouse = [];\n\t\t\t\n\t\t\tinitialiseSprites();\n\t\t\n\t\t\t// We have to reattach keydown because we temporarily remove it when pacman dies\n\t\t\tattachKeydown();\n\t\t\tattachClick();\n\t\t\n\t\t\tsetReadyText();\n\t\t}\n\t}", "title": "" }, { "docid": "b0c146b12dee394b255c7735c68b90b4", "score": "0.70481366", "text": "function reset_game() {\n position = [[\"?\",\"?\",\"?\"],[\"?\",\"?\",\"?\"],[\"?\",\"?\",\"?\"]];\n update_game(position);\n $(\".cell\").removeClass(\"visited\");\n currentPlayer = 'X';\n winner = null;\n update_message();\n}", "title": "" }, { "docid": "c10160e3cf74b9f8fe431180ab4c20e2", "score": "0.703991", "text": "function resetGame() {\n //Recreate DOM elements\n holder = $('<div>').addClass('holder2048');\n content = $('<div>').addClass('container').appendTo(holder);\n for (var i = 0; i < rowNum; i++) {\n for (var j = 0; j < colNum; j++) {\n //Reset matrix\n //This is for the borders of each cell.\n $('<div>').addClass('box').attr({\n\t\t levelValue: classifyBlock(matrix[i][j]),\n\t\t value: matrix[i][j]\n\t\t }).css({\n\t\t left: j * 14 + \"px\",\n\t\t top: i * 14 + \"px\",\n\t\t opacity: 1\n\t\t }).text(matrix[i][j]).appendTo(content);\n }\n }\n selectedNode = getSelectedNodeNum();\n $(\"#NodesinGPoints\").text(nodesinGPoints);\n $(\"#SelectedNode\").text(selectedNode);\n $(\"#movements\").text(movementList.toString());\n $(\"#stepsNum\").text(movementList.length+\" Steps\");\n //movementList = [];\n //Create the first box on board\n //createBox();\n //Insert game holder and anything to whoever calls this function\n _this.html(holder);\n }", "title": "" }, { "docid": "4bbf82def0075c0f7861ed62eb83567e", "score": "0.701793", "text": "function resetGame(){\n\tboxes.forEach(element => {\n\t\telement.style.backgroundColor = neutralColor;\n\t})\n\tresetArray();\n\tgameState = false;\n\tmsg.innerHTML = 'Game reset!';\n}", "title": "" }, { "docid": "6f8cb0950224b9fa72cc55ebe778532f", "score": "0.70092505", "text": "function resetGame() {\n ticTacToe = [\n [\"\", \"\", \"\"],\n [\"\", \"\", \"\"],\n [\"\", \"\", \"\"]\n ];\n return content.innerHTML = renderBoard(ticTacToe)\n }", "title": "" }, { "docid": "5f6a47840d655bf4f4f64d95597ffcb3", "score": "0.7008413", "text": "function draw_updated_game_status() {\r\n the_game_board.innerHTML = '';\r\n draw_the_snake(the_game_board);\r\n draw_the_food(the_game_board);\r\n}", "title": "" }, { "docid": "d7c3e2fba6dcf44d1256cab63b5ac9c0", "score": "0.69733185", "text": "function resetGame()\n{\n gameState = PLAY;\n mainCyclist.changeAnimation(\"cyclying\", mainRacerImg1);\n restart.visible = false;\n gameOver.visible = false;\n distance = 0;\n pinkCG.destroyEach();\n yellowCG.destroyEach();\n redCG.destroyEach();\n}", "title": "" }, { "docid": "58dc4e78c5955f5e861fa8cfc1a1a516", "score": "0.6970253", "text": "function clearGame() {\n game.currentGame = [];\n game.count = 0;\n addCount();\n }", "title": "" }, { "docid": "776aea5c5377396afd416dfed9455d03", "score": "0.6958259", "text": "function reset(){\n cells = [];\n gameOver = 0;\n document.getElementById(\"gameboard\").innerHTML = \"\";\n cellFactory();\n document.getElementById(\"whosUp\").innerHTML = whosTurn;\n}", "title": "" }, { "docid": "c985aa0ee694505bfb2ce17a6e616d75", "score": "0.6940956", "text": "function resetGame() {\n if (reset === true) {\n missed = 0;\n for (let i = 0; i < lifeBar.length; i += 1) {\n lifeBar[i].src = \"images/liveHeart.png\";\n }\n for (let i = 0; i < letters.length; i += 1) {\n letters[i].className = \"letter\";\n }\n for (let i = 0; i < buttons.length; i += 1) {\n buttons[i].className = \"\";\n buttons[i].disabled = false;\n }\n const li = document.querySelectorAll(\".letter, .space\");\n for (let i = 0; i < li.length; i += 1) {\n ul.removeChild(li[i]);\n }\n const newPhraseArray = getRandomPhraseAsArray(phrases);\n addPhraseToDisplay(newPhraseArray);\n }\n }", "title": "" }, { "docid": "66a350f48a62110736e71c28157938b7", "score": "0.6932192", "text": "function reset() {\n //Reset all of the variables except pieces. Keep those the same.\n gamelist = [\"holder\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\"];\n game = \"play\"; \n\n //Generate new board\n gameboard();\n\n //Let computer start game off\n ai(computer, user);\n }", "title": "" }, { "docid": "2e349dc258a0d7730a465f8a14947b2f", "score": "0.6931178", "text": "function reset() {\n drawAll(\"light\");\n playing = true;\n }", "title": "" }, { "docid": "2ed19eed2055cbf2f0bb47924887732b", "score": "0.6931044", "text": "function resetGame() { }", "title": "" }, { "docid": "f79bb6476dbfeb847937e16e2ea44df2", "score": "0.6902974", "text": "function redrawBoard() {\n\t// Delete all pieces\n\twhile (gPieces.firstElementChild) {\n\t\tgetTileFromPiece(gPieces.firstElementChild).addEventListener(\"click\", tileClicked);\n\t\tgPieces.removeChild(gPieces.firstElementChild);\n\t}\n\t// Redraw all pieces based on game board position\n\tdrawPieces();\n}", "title": "" }, { "docid": "342b18910a795061d16fe3e20fb5806f", "score": "0.68897295", "text": "function reset() {\n\t\tlives = 6;\n\t\tlettersGuessed = [];\n\t\tnewGame = true;\n\t\t}", "title": "" }, { "docid": "fa4aa184a38bb9a636c911e0519db50c", "score": "0.6880424", "text": "function resetGame(){\n\t\tturns = [];\n\t\tusedSlots = [];\n\t\tplayerScore = 0;\n\t\tcomputerScore = 0;\n\t\t$('#playerScore').text('-');\n\t\t$('#computerScore').text('-');\n\t\t$('.squares').text('');\n\t\t$('#winnerText').text('');\n\t\tplayersTurn = true;\n\t\tcount = 0;\n\t}", "title": "" }, { "docid": "7d2e2b1de5c13ea6b3bc8e00d7da9dfc", "score": "0.68643236", "text": "function resetGame() {\n setPlayer1Games(0);\n setPlayer2Games(0);\n setCurrentPlayer(1);\n setGameState([\n [0, 0, 0],\n [0, 0, 0],\n [0, 0, 0],\n ]);\n }", "title": "" }, { "docid": "06fd84172a981315fc31b08da3251149", "score": "0.6854487", "text": "function restart() {\n rows = 6;\n cols = 6;\n grid = [];\n whosTurn = \"b\";\n winner = null;\n bKoList = [];\n wKoList = [];\n\n for (let i = 0; i < cols; i++) {\n grid[i] = [];\n for (let j = 0; j < rows; j++) {\n grid[i][j] = \"empty\";\n }\n }\n createCanvas(600, 700);\n clearAndDrawBoard();\n showHint();\n}", "title": "" }, { "docid": "a75ffb611e566d039079f6aa9face308", "score": "0.68469274", "text": "function resetGame() {\n openedCells = 0;\n totalCells = 0;\n k = 0;\n arr = [];\n alreadyThere = [];\n setupGame();\n document.querySelector('h2').textContent = `Beware: ${bombNumber} Bombs`;\n document.querySelector('#bomb').src = 'https://media.giphy.com/media/X92pmIty2ZJp6/giphy.gif';\n document.querySelector('#bomb1').src = 'https://media.giphy.com/media/X92pmIty2ZJp6/giphy.gif'\n document.querySelector('#bomb').style.visibility = 'hidden';\n document.querySelector('#bomb1').style.visibility = 'hidden';\n document.querySelector('#container').addEventListener('click', revealBox);\n document.querySelector('body').addEventListener('contextmenu', rightClick);\n}", "title": "" }, { "docid": "14ca147bca0d4bc08a68cbb6a3eb2a83", "score": "0.6843882", "text": "function refresh(){\n chosenCards = [];\n cardsSelected = [];\n newBoard();\n }", "title": "" }, { "docid": "e10cec587e3d97f58f89c1dec9dd8b6a", "score": "0.6843717", "text": "function resetGame() {\n for (var i=0; i < cars.length; i++) {\n cars[i].clicked = false\n };\n setGameStarted(false);\n resetTimer()\n resetStats()\n }", "title": "" }, { "docid": "eb30cc7b813ce5d748b13c6702fdb809", "score": "0.68400544", "text": "function resetGame() {\r\n\r\n\t/**\r\n\t* Chose a random phrase from an array of phrases\r\n\t* @param {array} list of strings to select from\r\n\t* @return {string} selected phrase\r\n\t*/\r\n\tfunction getRandomPhraseAsArray(arr) {\r\n\t\treturn arr[Math.floor(Math.random() * arr.length-1) + 1];\r\n\t}\r\n\t\r\n\t/**\r\n\t* Take the chose phrase, generate the game display as Li's using creatLi() function. Append to #phrase ul\r\n\t* Reset the phrase between rounds\r\n\t* @param {string} The phrase to be used\r\n\t*/\t\r\n\tfunction addPhraseToDisplay(arrChars) {\r\n\t\tphraseUl.innerHTML = ''; //reset between rounds\r\n\t\tfor (let i = 0; i < arrChars.length ; i++) {\r\n\t\t\tphraseUl.appendChild(createLi(arrChars[i]));\r\n\t\t}\r\n\t}\r\n\r\n\t// Resets for repeat games\r\n\tlettersLi = [];\r\n\tvictory.style.display = '';\r\n\toverlay.style.display = '';\r\n\tmissed = 0\r\n\tfor (key in keys) {\r\n\t\t// Reset the keyboard\r\n\t\tkeys[key].disabled = false;\r\n\t\tkeys[key].style = '';\r\n\t}\r\n\tfor (i in tries) {\r\n\t\ttries[i].style = '';\r\n\t}\r\n\r\n\tlet phraseArray = getRandomPhraseAsArray(phrases);\r\n\taddPhraseToDisplay(phraseArray);\t\r\n\tconsole.log(phraseArray); // For stuck players!\r\n}", "title": "" }, { "docid": "59adc7e6ed0e56961dda64b78aa7efd7", "score": "0.683857", "text": "function _partialReset() {\n playerMod.xSpaces.length = 0;\n playerMod.oSpaces.length = 0;\n currentPlayer = 0;\n gameBoard.gameBoardArray.forEach(function(sqr) {\n sqr.innerHTML = \"&nbsp\";\n })\n availableSquares = availableSquares = [\"square0\", \"square1\", \"square2\", \"square3\",\n \"square4\", \"square5\", \"square6\", \"square7\", \"square8\"];\n }", "title": "" }, { "docid": "ca004b0baa99b4ed221b6470107961c8", "score": "0.68333817", "text": "function resetBoard (){\n document.querySelector(\".board\").innerHTML = \" \";\n board = {cells:[]}\n startGame()\n}", "title": "" }, { "docid": "ab1617de060ea281a34debb5f5a08339", "score": "0.6831441", "text": "function resetGame() {\n var i;\n\n // Reset flags and states to the \"start\" values\n gameOver = false;\n victoryFlag = false;\n turnCount = 0;\n currentPlayer = PLAYER_ONE;\n message = getPlayerName(PLAYER_ONE) + \" starts the game\";\n messageNode.innerHTML = message;\n\n // Reset all line sums to 0\n lineSums = [];\n for (i = 0; i < (GRID_SIZE * 2) + 2; i += 1) {\n lineSums.push(0);\n }\n\n // Clear the DOM \"square\" elements\n for (i = 0; i < squares.length; i += 1) {\n while (squares[i].lastChild) {\n squares[i].removeChild(squares[i].lastChild);\n squares[i].className = \"square\";\n }\n }\n}", "title": "" }, { "docid": "285c79c5c1f1665a8eded75e8909eb77", "score": "0.6830161", "text": "function resetGame()\n\t{\n\t\t// checks if listeners are on or not\n\t\tif(!listenersOn)\n\t\t{\n\t\t\tfor(let arrow of arrows)\n\t\t\t{\n\t\t\t\tarrow.addEventListener(\"click\", fillCell);\n\t\t\t}\n\t\t\tlistenersOn = true;\n\t\t}\n\t\t\n\t\t// resets all of the cells to default\n\t\tfor(let i = 0; i < numRows; i++)\n\t\t{\n\t\t\tfor (let j = 0; j < numCols; j++)\n\t\t\t{\n\t\t\t\tcells[i][j].className = 'cell';\n\t\t\t}\n\t\t}\n\t\t\n\t\t// resets player color\n\t\tplayerColor = \"cellFilledRed\";\n\t\tdocument.querySelector(\"#messenger p\").innerHTML = \"It is currently the Red player's turn.\";\n\t}", "title": "" }, { "docid": "f2a6d20eeb9d61708abd2667daddd14c", "score": "0.6826278", "text": "function clearBoard(){\n\t\tturns = [];\n\t\tusedSlots = [];\n\t\tplayersTurn = true;\n\t\tcount = 0;\n\t\tsetTimeout(function(){\n\t\t\t$('.squares').text('');\n\t\t},500);\n\t}", "title": "" }, { "docid": "89497e03ba4d767f4f3ec24c482525c1", "score": "0.68014693", "text": "function reset_game(){\n if (freeze)\n return;\n reset_stats();\n games_played++;\n display_stats();\n match_types = [];\n first_card_clicked = null;\n second_card_clicked = null;\n}", "title": "" }, { "docid": "b38b0fc9e96cdb4ed3a30ab8179e312a", "score": "0.67984027", "text": "function resetGame(){\n\n //remove DOM hand\n handContainer.removeChild(handContainer.children[0]);\n //reset points\n points = 0;\n //empty deck\n myDeck = [];\n //empty hand\n myHand.hand = [];\n //empty selected array\n myHand.selected = [];\n //empty discarded array\n discarded = [];\n\n //TODO: EMPTY DISCARDED DOM\n\n\n //reset switches to 0\n switches = 0;\n //initialize game\n initializeGame();\n}", "title": "" }, { "docid": "144e7366a0e34b79fa792af10599f71b", "score": "0.6781866", "text": "function resetUI () {\n\tmyWins = 0;\n\tmyLosses = 0;\n\tmyHealth = 0;\n\tmyAttack = 0;\n\tyourWins = 0;\n\tyourLosses = 0;\n\tyourHealth = 0;\n\tyourCounter = 0;\n\tfirstChallenger = 0;\n\t$('.shown-picture').remove();\n\t$('.opponent-display').remove();\n\t$('.shown-vanquished').remove();\n\t$('.shown-health').remove();\n\t$('.challengers').remove();\n\tdrawMyWins(myWins);\n\tdrawMyLosses(myLosses);\n\tdrawMyHealth(myHealth);\n\tdrawMyAttack(myAttack);\n\tdrawYourWins(yourWins);\n\tdrawYourLosses(yourLosses);\n\tdrawYourHealth(yourHealth);\n\tdrawYourCounter(yourCounter);\n\tdsplWinnerBoard();\n}", "title": "" }, { "docid": "7f9183af05965fd8d354d87b6962645f", "score": "0.67807", "text": "function resetGame(){\r\n\r\n\tmissed = 0;\r\n\tdisableKeyboard(false);\r\n\tremovePhraseFromDisplay();\r\n\tconst phraseArray = getRandomPhraseAsArray(phrases);\r\n\taddPhraseToDisplay(phraseArray);\r\n\tbody[0].classList.remove(\"win\");\r\n\tbody[0].classList.remove(\"lose\");\r\n\t\r\n\r\n\tdiv.textContent = \" \";\r\n\t//addButton();\t\r\n\tlet ol = document.getElementsByTagName('ol')[0];\r\n\tfor (let i = 0; i < 5; i++){\r\n\t\t\tconst liveHeart = document.createElement(\"IMG\");\r\n\t\t\tliveHeart.setAttribute(\"src\", \"images/liveHeart.png\");\r\n\t\t\tliveHeart.setAttribute(\"width\", \"30\");\r\n\t\t\tliveHeart.setAttribute(\"height\", \"35\");\r\n\t\t\tlet list = document.createElement('li');\r\n\t\t\tlist.appendChild(liveHeart);\r\n\t\t\tlist.className = \"tries\";\r\n\t\t\tol.appendChild(list);\r\n\t}\r\n\t\r\n}", "title": "" }, { "docid": "dcf3fc1684117e200ad65544cc3dd79b", "score": "0.6774828", "text": "function resetBoard() {\n\n openCardsList = [];\n addToDeck();\n resetMoves();\n resetTimer();\n resetStars();\n}", "title": "" }, { "docid": "ecaaf8bd64b90cd00bbff9534b9c6830", "score": "0.67669743", "text": "function resetGame() {\n\t\t$(\".flipper\").css(\"transform\", \"rotateY(0deg)\");\n\t\tmoves = 0;\n\t\t$(\".moves\").text(singularMoveText(moves));\n\t\tclearInterval(myTimer);\n\t\tseconds = 0;\n\t\tminutes = 0;\n\t\tperfectMatch = 0;\n\t\t$(\".timer\").text(`${formatTime(minutes)} : ${formatTime(seconds)}`);\n\t\t$(\".one-star\").hide();\n\t\t$(\".two-stars\").hide();\n\t\t$(\".three-stars\").show();\n\t\t$(\".modal-backdrop\").hide();\n\t\tshuffleCards();\n\t\tlastSelectedCard = null;\n\t}", "title": "" }, { "docid": "52ddb143fa8070d62ebd0904cd3528d7", "score": "0.67658716", "text": "function playAgain(){\n\t\t$('div.cell').empty();\n\t\t$('div.cell.highlighted').removeClass('highlighted');\n\t\t$('div#gameboard').addClass('hidden');\n\t\t$('div#pagain').removeClass('hidden');\n\t}", "title": "" }, { "docid": "ecfaf3573404a71d63dfee4ac7fb6589", "score": "0.67547363", "text": "function reset(){\n\t\tplayground.context.fillStyle = \"#ccc\";\n\t\tplayground.context.fillRect(0,0,600,500);\n\t\tplayground.ui.reset();\n\t\tplayground.value_changed = doNothing;\n\t\tplayground.vars = {};\n\t}", "title": "" }, { "docid": "7018ad7be738d3b65009976d211eee70", "score": "0.6743491", "text": "function reset() {\n // there is no opened shell\n setOpenedShell(DEFAULT_OPENED_SHELL);\n // position default\n setPositions([options[0]]);\n // random ball position\n setBallPosition(getRandomNumber(SHELLS_NUMBER));\n // game started\n setGameStarted(true);\n\n // set new victories record with default value null\n // this array could be used for counting victories for the user\n const newVictories = [...victories];\n newVictories.push(null);\n setVictories(newVictories);\n }", "title": "" }, { "docid": "2d837609872b520178bf788357de0bca", "score": "0.6734264", "text": "function clearBoard() {\n initBoard();\n refresh();\n}", "title": "" }, { "docid": "f4f0efad8f30c4dd1f0426cbd277e87e", "score": "0.6721057", "text": "function redrawGameItem() {\n $(paddle1.id).css(\"top\", paddle1.positionY);\n $(paddle2.id).css(\"top\", paddle2.positionY);\n $('#ball').css(\"top\", ball.positionY);\n $('#ball').css(\"left\", ball.positionX);\n }", "title": "" }, { "docid": "504acc103f684134d2a61685ccbb5ebb", "score": "0.67100215", "text": "function newGame() {\n\t$('#count').empty();\n\t$('#guessList').closest('li').remove();\n\t$('#feedback').remove()\n}", "title": "" }, { "docid": "5d174f493602b86187fe9ff326cb520b", "score": "0.67083013", "text": "function reset(){\r\n listOfWalkers = new Array();\r\n listOfSpawners = new Array();\r\n listOfBlocks = new Array();\r\n clearIntervals();\r\n // reset arrays as needed\r\n jjfLIB.drawRect(ctx, 0,0,width, height, \"whitesmoke\", false);\r\n jjfLIB.drawGrid(ctx, lineColor, xCellCount, yCellCount, gridXOffset, gridYOffset, width, height);\r\n }", "title": "" }, { "docid": "66bbe1684e764aef338a282b3ede982a", "score": "0.6708182", "text": "function restartGame() {\n document.getElementById(\"grid\").innerHTML = null;\n printMessage(generateGrid());\n message.style.animation = \"none\";\n turn = null;\n markedCells = 0;\n }", "title": "" }, { "docid": "6e673ae39f20297a08486eb7eb435249", "score": "0.67028445", "text": "resetGameboard() {\r\n\t\tthis.missed = 0;\r\n\t\tlet liElements = document.querySelectorAll('#phrase ul');\r\n\t\tlet listItems = document.getElementsByClassName(\"tries\");\r\n\t\tliElements[0].innerHTML = \" \";\r\n\t\tlet keys = document.getElementsByClassName(\"key\");\r\n\t\tfor (let j = 0; j < keys.length; j++) {\r\n\t\t\tif (keys[j].classList.contains('wrong') || keys[j].classList.contains('chosen')) {\r\n\t\t\t\tkeys[j].disabled = false;\r\n\t\t\t\tkeys[j].classList.remove(\"wrong\");\r\n\t\t\t\tkeys[j].classList.remove(\"chosen\");\r\n\t\t\t}\r\n\t\t}\r\n\t\t//this for loop loops through lost heart elements and changes them back to live hearts\r\n\t\tfor (let i = 0; i < listItems.length; i++) {\r\n\t\t\tlistItems[i].firstElementChild.src = \"images/liveHeart.png\";\r\n\t\t}\r\n\t}", "title": "" }, { "docid": "5fe94bc42da4af28dd04c03fb1f36572", "score": "0.6697319", "text": "function resetGame() {\n //reset deck\n deck = shuffle(newDeck());\n //reset hands\n dealerHand = [];\n playerHand = [];\n //reset points\n $(\"#player-points\").text(\"\");\n $(\"#dealer-points\").text(\"\");\n $(\"#messages\").text(\"\");\n //reset board to empty\n $(\"#player-hand\").html(\"\");\n $(\"#dealer-hand\").html(\"\");\n}", "title": "" }, { "docid": "b7e0fbbccda8d662a5baf7c347529630", "score": "0.6693893", "text": "function resetGame() {\n for (var i = 0; i < state.length; i++) {\n state[i] = \"\";\n squares[i].innerHTML = \"\";\n }\n}", "title": "" }, { "docid": "cf5ad4280933279425a8275fe6b5e0b2", "score": "0.6690127", "text": "function reloadGame() {\n\t// clear the list\n\twhile (numbersGroup.firstChild)\n\t\tnumbersGroup.removeChild(numbersGroup.firstChild);\n\t// populate based on config\n\tfor (var i = 0; i < gameConfig['count'] && i < 50; i++) {\n\t\tnumbersGroup.appendChild(document.createElement(\"br\"));\n\t\tvar input = document.createElement(\"input\");\n\t\tinput.setAttribute(\"type\", \"text\");\n\t\tinput.setAttribute(\"id\", \"number\" + i);\n\t\tinput.setAttribute(\"class\", \"form-control\");\n\t\tinput.setAttribute(\"placeholder\", \"0\");\n\t\tnumbersGroup.appendChild(input);\n\t}\n\tattemptsLabel.innerHTML = \"10 attempts remain.\";\n}", "title": "" }, { "docid": "db167b10f14c0c0ec15a3b779e3dc6cd", "score": "0.668409", "text": "function reset() {\r\n squares = [];\r\n toggleDialogVisibility(false);\r\n cells.forEach(cell => cell.innerHTML = \"\");\r\n}", "title": "" }, { "docid": "75a95bf3a8af2f6dc672215248df2d8b", "score": "0.66840124", "text": "function reset() {\n win = false;\n clearInterval(intervalCount);\n clearActiveSelect();\n solution = [];\n for (let i = 0; i < colorBalls.length; i++) {\n colorBalls[i].style.backgroundColor = \"#854e1e\";\n }\n for (let i = 0; i < pegs.length; i++) {\n pegs[i].style.backgroundColor = \"#a0622c\";\n }\n if ((aR !== (0 || undefined)) && (aR < 98)) {\n deactivateRow();\n }\n resetAria();\n aR = 0;\n pegColors = [];\n solutionCover.style.width = \"67.5%\";\n currentWidth = 67.5;\n hintCount = 0;\n score = 0;\n message.textContent = \"Good luck!\";\n resetTime();\n removeRows();\n runGame();\n}", "title": "" }, { "docid": "5fb60d8002beaaa9aa46ec8ef5c05c0f", "score": "0.6673009", "text": "function drawGame() {\n\n\t//check whether the screen still has monster, list.cFlag = 1\n\tfor (g = 0; g < list.items.length; g++) {\n\t\tif (list.items[g].isSelected) {\n\t\t\tlist.cFlag = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\tlist.cFlag = 0;\n\t}\n\n\t//choose new random monsters when the screen has no monster\n\tif (list.cFlag == 0) {\n\n\t\tlist.cFlag = 1;\n\t\tvar preNum = [];\n\n\t\tfor (var g = 0; g < list.selectNum; g++) {\n\t \t\tvar check = 1;\n\n\t\t\twhile (check == 1) {\n\n\t\t\t\tvar x = list.items.length - Math.floor(Math.random()*8 + 1);\n\n\t\t\t\tcheck = 0;\n\t\t\t\tfor (var h = 0; h < g; h++) {\n\t\t\t\t\tif (x == preNum[h]) {\n\t\t\t\t\t\tcheck = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (check == 0) {\n\t\t\t\t\tlist.items[x].isSelected = true;//choose this monster to draw\n\n\t\t\t\t\tpreNum[g] = x;\n\t\t\t\t}\n\t \t\t}\n\n\t\t}\n\n\t\tif (list.selectNum < cList.StageList[cList.currentStage].maxMonsterNum) {\n\t\t\tlist.selectNum++;\n\t\t}\n\t}\n\n\n\t//draw chosen monsters\n\tfor (var g = 0; g < list.items.length; g++) {\n\t\tif (list.items[g].isSelected) {\n\t\t\tlist.items[g].draw(ctx);\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "8737f5c5abb494513f83c8b7c1cc5df9", "score": "0.66715825", "text": "function resetBoard() {\n\t// Reset Cards\n\tfor(let i=0; i<cards.length; i++){\n\t\tconst board = document.getElementById(\"game-board\");\n\t\tboard.removeChild(board.childNodes[0]);\n\t}\n\n\t// Reset Result Board\n\tconst results = document.getElementById(\"result-board\");\n\twhile (results.firstChild) {\n\t results.removeChild(results.lastChild);\n\t}\n\tresults.classList.remove(\"results\");\n\n\t// Reset cardsInPlay tracker\n\tcardsInPlay = [];\n\n\t// Reset board\n\tcreateBoard();\n}", "title": "" }, { "docid": "2dd225b450d4f5f43560413a9b039542", "score": "0.6669085", "text": "function gameOver() {\n\t// Remove all elements from the game div before resfreshing\n\twhile(game.firstChild) {\n\t\tgame.removeChild(game.lastChild);\n\t}\n\t// Refresh page\n\tlocation.reload();\n}", "title": "" }, { "docid": "a8effa60a7d5ec0e7f73b90946ea64d5", "score": "0.66654867", "text": "function reset() {\n\t\tif ( !gameOver() ) {\n\t\t\tclearInterval(shotInt);\n\t\t}\n\n\t\tcells = JSON.parse(JSON.stringify(defCells));\n\t\tavailableCells = totalCells;\n\t\tshipsAlive = Object.keys(ships).length;\n\t\tshots = 0;\n\t\t$('#board').find('.cell').removeClass('hit');\n\t\t$('#fired, #left').text('');\n\t\tswitchStatus(false);\n\t}", "title": "" }, { "docid": "151296699e7cd43916a9451fcb1bf9e5", "score": "0.6660657", "text": "function resetGame() {\n simonSettings.clearPlayer();\n simonSettings.resetCount();\n simonSettings.resetSequence();\n clearInterval(endHighLight);\n clearInterval(timeOut);\n stopSequence();\n if(beepSound.getSound() === true) {\n beepSound.stop();\n }\n count.innerHTML = '--';\n simonSettings.setPanelsActive(false);\n drawBoard();\n }", "title": "" }, { "docid": "20f938e650ff03bf544a2946bc2a6972", "score": "0.6660209", "text": "function ResetGame () {\n\t \t// reset game data for a new game\n\t }", "title": "" }, { "docid": "0a19f89302960cc9154d26cd64b94c2f", "score": "0.66588223", "text": "function resetGame() {\n this.aGameOfChess = {\n whoseTurn: 'white'\n }\n var whoseTurn = this.aGameOfChess.whoseTurn;\n var grid = new Board(whoseTurn),\n table = document.getElementById('chessBoard');\n cells = document.getElementsByClassName('cell'),\n figures = document.getElementsByClassName('figure'),\n title = document.getElementById('title');\n potentialMoves = [],\n forEach = Array.prototype.forEach,\n ls = this.localStorage;\n table.innerHTML = '';\n ls.setItem('aGameOfChess', JSON.stringify({\n pieces: pieces,\n moves: []\n }));\n var chess = getState();\n grid.draw().placePieces(chess.pieces);\n forEach.call(figures, function(figure) {\n prepareFigure(figure);\n });\n}", "title": "" }, { "docid": "0082d3c1f0511e863aaeab055c8d5016", "score": "0.6653266", "text": "function resetGame() {\n\n // Set the gamestate to ready\n gamestate = gamestates.ready;\n\n // Reset game over\n gameover = false;\n\n // Create the level\n createLevel();\n\n // Find initial clusters and moves\n findMoves();\n findClusters();\n }", "title": "" }, { "docid": "bb134ac117755748f76ec5d0840c455f", "score": "0.6653215", "text": "function draw() {\n\t\twinner = determineWinner();\n\n\t\tif (!winner) {\n\t\t\tif (current.length > 0) {\n\t\t\t\tplayer = current[Math.floor(Math.random()*current.length)];\n\t\t\t} else if (through.length > 0) {\n\t\t\t\tredraw();\n\t\t\t\tdraw();\n\t\t\t} else {\n\t\t\t\t//No one is through\n\t\t\t\tcurrent = losers;\n\t\t\t\tlosers = new Array();\n\t\t\t\tdraw();\n\t\t\t}\n\t\t}\n\t\treload();\n\t}", "title": "" }, { "docid": "68d8dd3b833370d3749dcf1e51afb856", "score": "0.66499645", "text": "function clearGameData() {\n gameData.size = { rows: 5, cols: 5 };\n gameData.boardState.length = 0;\n gameData.currentPlayersTurn = 1;\n gameData.players.length = 0;\n gameData.targetScore = 100;\n canvasCtx.clearRect(0,0,canvas.width, canvas.height);\n}", "title": "" }, { "docid": "e374e5ca9375844151b790fcdd5ce004", "score": "0.66467655", "text": "function reDraw() {\n for (var i = 0; i < objArray.length; i++) {\n objArray[i].color = randomColor();\n if (objArray[i].width) {\n objArray[i].draw(objArray[i].x, objArray[i].y, objArray[i].color, objArray[i].width, true);\n }\n else {\n objArray[i].draw(objArray[i].x, objArray[i].y, objArray[i].color, objArray[i].radius, true);\n }\n }\n behindTheScenesColor();\n}", "title": "" }, { "docid": "35b9cba07b1b876991c3a1049fe913b8", "score": "0.6646418", "text": "function resetBoard() {\n for (var i = 0; i < boardCells.length; i++) {\n boardCells[i].dataset.type = EMPTY_CELL;\n boardCells[i].innerHTML = '';\n }\n addCirclesFirstTime(); //dodanie 3 kulek\n }", "title": "" }, { "docid": "3c19c61299a86d5ce6e3cedd57e7ecf2", "score": "0.664499", "text": "function refreshGame() {\n openCards = [];\n moves = 0;\n stars = 3;\n gameStarted = false;\n stopTimer();\n $(\".moves\").text(moves);\n $(\".stars\").html('<li><i class=\"fa fa-star\"></i></li> <li><i class=\"fa fa-star\"></i></li> <li><i class=\"fa fa-star\"></i></li>');\n newCards = shuffle(cards).slice();\n $(\".deck\").empty();\n for (var i = 0; i < cards.length; i++) {\n $(\".deck\").append(newCards[i].cloneNode(true));\n }\n}", "title": "" }, { "docid": "a8a19654fdf025032cdc1e9fc6db3dd2", "score": "0.6644386", "text": "function gameReset(){\n $score.text('0');\n $matchStatus.css('display', 'none');\n score = 0;\n delay = 0;\n $userArray =[];\n $squareSequence =[];\n randomColor=[];\n // function clearDisplay() {\n // console.log('cleardisplay im hit');\n // for (var i = 0; i < $lis.length; i++) {\n // const singleSquare = $lis[i];\n // setTimeout(() => {\n // $(singleSquare).css('background-color', `${originColor}`);\n // }, 2000);\n // }\n // }\n clearDisplay();\n }", "title": "" }, { "docid": "35bfd828074938d2eed14b431fe22211", "score": "0.6640858", "text": "function resetGame(){\n\n for(var a = 0; a < currIDList.length; a++){\n var country = currIDList[a];\n\n if(countryPolys[country] != null) countryPolys[country].setMap(null);\n if(gameMarkers[country] != null) gameMarkers[country].setMap(null);\n }\n countryPolys = {};\n gameMarkers = {};\n\n currIDList = [];\n\n }", "title": "" }, { "docid": "dc426068ebf02de42c2b2f8c6b12a551", "score": "0.6638176", "text": "function resetGame() {\n cheater = false;\n moveCounter = 0;\n resetButton.style.display = \"none\";\n easyButton.style.display = \"block\";\n normalButton.style.display = \"block\";\n hardButton.style.display = \"block\";\n testButton.style.display = \"block\";\n while (threePanels[0].firstChild) {\n threePanels[1].appendChild(threePanels[0].firstChild);\n }\n while (threePanels[2].firstChild) {\n threePanels[1].appendChild(threePanels[2].firstChild);\n }\n for (let i = 0; i < 6; i++) {\n threePanels[0].appendChild(anyBox[i]);\n anyBox[i].style.margin = \"2px 0px\";\n }\n panelContainer.style.display = \"flex\";\n winScreen.style.display = \"none\";\n moveCounter = 0;\n moveCounterBox[0].innerHTML = moveCounter;\n moveCounterBox[1].innerHTML = moveCounter;\n}", "title": "" }, { "docid": "5bde0360d4dec1423967d06d0706fdd5", "score": "0.66239744", "text": "function reset() {\n gameData.cards.player.splice(0);\n gameData.cards.dealer.splice(0);\n gameData.numCardsSelected = 0;\n gameData.betAmount = 5;\n playerHand.innerHTML = '';\n dealerHand.innerHTML = '';\n gameStatus.innerHTML = '';\n payoutDisplay.innerHTML = '';\n drawButton.innerHTML = 'Hold';\n betAmountDisplay.innerHTML = ' × 5';\n\n setUpRound();\n }", "title": "" }, { "docid": "237c2bc42290434ddbae913caa3f4dc8", "score": "0.66229486", "text": "function resetGame() {\n document.location.reload();\n }", "title": "" }, { "docid": "e54e4d7ab62cae9ee0e97aa37c1a9698", "score": "0.6617886", "text": "function resetGame() {\n\tclickedCards = [];\n matchedCards = [];\n resetCards();\n shuffleDeck();\n\tresetTime();\n\tresetMoves();\n\tresetStars();\n}", "title": "" }, { "docid": "4cfc41c0fdca8884ddcfc4ec5ee84b1f", "score": "0.6616514", "text": "function reset() {\n turns = [\"#\", \"#\", \"#\", \"#\", \"#\", \"#\", \"#\", \"#\", \"#\"];\n count = 0;\n $(\".tic\").text(\"#\");\n gameOn = false;\n }", "title": "" }, { "docid": "09c2ac39947a25d7caf88a995d4341f6", "score": "0.66163635", "text": "function resetGame() {\n guessesRemaining = guesses;\n gameStarted = false;\n currentWordIndex = Math.floor(Math.random() * (wordList.length));\n guessedLetters = [];\n guessingWord = [];\n for (var i = 0; i < wordList[currentWordIndex].length; i++) {\n guessingWord.push(\" _ \");\n }\n document.getElementById(\"gameover\").style.visibility = \"hidden\";\n document.getElementById(\"you-win\").style.visibility = \"hidden\";\n document.getElementById(\"start\").style.visibility = \"hidden\";\n updateDisplay();\n }", "title": "" }, { "docid": "c458d5c9ee5f710b63b58eadabfa1bbb", "score": "0.6613876", "text": "function resetGame(){\n for (var i = 0; i < deck.length; i++) {\n $(\".card\").remove();\n }\n resetStars();\n deck = [];\n\t moves = 0;\n stopTimer();\n resetMoves(moves);\n newGame();\n }", "title": "" }, { "docid": "ae11e85507dc148ef402584d86c8a1f6", "score": "0.66136277", "text": "function clear(){\n for (i=0; i<modlist.length; i++)\n twtlist[modlist[i]].color = getdefcolor(modlist[i]);\n modlist = [];\n ctx.clearRect(0, 0, width, height);\n}", "title": "" }, { "docid": "b75bf10093f04db5d6f9c990f39c0882", "score": "0.6613137", "text": "function reGame() {\n allReset();\n popupStyle.visibility = \"hidden\";\n overlayStyle.visibility = \"hidden\"\n chooseSide.style.display = 'block';\n tictactoeBody.style.display = 'none';\n boardReset.style.display = \"block\";\n gameReset.style.display = \"none\";\n}", "title": "" }, { "docid": "f1774256a0d0c8b42b09bc5e5f247415", "score": "0.6612064", "text": "function clearOldGame() {\n\t\t\t\t// empty the feedback space\n\t\t\t\t$('h2#feedback').empty();\n\t\t\t\t// set number of guesses to 0\n\t\t\t\tvar count = 0;\n\t\t\t\t// display count\n\t\t\t\t$('#count').html(count);\n\t\t\t\t// clear the list of previous guesses\n\t\t\t\t$('ul#guessList').empty();\n\t\t\t\t\t\t//newGame = true;\n\t\t\t\t\t\t//return newGame;\n\t\t}", "title": "" }, { "docid": "f69dd13d6ac438d79ece0503166938dd", "score": "0.66107816", "text": "function resetBoard() {\n defeatedEnemies = 0;\n heroSelected = false;\n defenderSelected = false;\n gameReady = false;\n\n hero.ap = hero.baseAP;\n\n $('#hero-attack, #defender-attack').empty();\n $('#game-status').empty();\n $('#hero-hp, #defender-hp').attr('style', 'width: 100%;').attr('class', 'progress-bar progress-bar-success');\n\n $('.char-select').show();\n $('#replay, #attack, #status, .char-arena').hide();\n\n setBoard();\n }", "title": "" }, { "docid": "6a4d5021cd8512317cad0a9d9f5a9a5b", "score": "0.6610297", "text": "function draw(){\n //Remove Previous Pieces from Snake\n gameBoard.innerHTML = ''\n \n drawSnake(gameBoard);\n drawFood(gameBoard);\n}", "title": "" }, { "docid": "858a40d5df1e4e192803ae748191e3d1", "score": "0.66100615", "text": "function reloadGame(){\n\t\t// Assign fresh live variables\n\t\tgameIsRunning = false;\n\t\twindow.gameIsPaused = false;\n\t\tgJabbaArray = repopulateFoodArray();\n\t\tgLives = TOTAL_LIVES;\n\t\tgScore = 0;\n\t\tgEatenDotCount = 0;\n\t\tgStage = 0;\n\t\t\n\t\t// If we had jsAngular/React we could skip having to update ui explicitly\n\t\tupdateLives(gLives);\n\t\tupdateStage(gStage);\n\t\tupdateScore(gScore);\n\t\t\n\t\tresetGame();\n\t}", "title": "" }, { "docid": "9c95460ae365998f8fbf6f9a7ea87474", "score": "0.66086465", "text": "function gameReset() { \n for (var i=0; i < board.length; i++) \n board[i].innerText = \"\";\n player = \"X\";\n hndlPlayer.innerText = \"X\";\n empty = 9;\n gameover = false;\n\t// added resetting font color\n\tfor (var j = 0; j < board.length; j++) {\n\t\tboard[j].style.color = \"black\";\n\t}\t\n}", "title": "" }, { "docid": "5659d01ce33a60ab8de075316010ea8e", "score": "0.66069937", "text": "function clearBoard() {\n\tfor (var i = 0; i < gBoard.length; i++) {\n\t\tfor (var j = 0; j < gBoard[0].length; j++) {\n\t\t\tif (gBoard[i][j].gameElement !== null) {\n\n\t\t\t\t// update model\n\t\t\t\tgBoard[i][j].gameElement = null;\n\n\t\t\t\t// update dom\n\t\t\t\trenderCell({ i: i, j: j }, '');\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "9de36aa004ac61350176b4c1d9884b5c", "score": "0.6606247", "text": "function reset() {\n context.clearRect(0, 0, canvasWidth, canvasHeight);\n initParams();\n drawChessBoard();\n textContainer.innerText = 'on commence';\n over = false;\n me = true;\n}", "title": "" }, { "docid": "01cb856e1c291bb6d4f4404a643a9e24", "score": "0.66051215", "text": "function resetGame() {\n // Reset game progress\n gameStarted = false;\n heating = false;\n verticalVelocity = 5;\n horizontalVelocity = 5;\n balloonX = 0;\n balloonY = 0;\n fuel = 100;\n\n introductionElement.style.opacity = 1;\n restartButton.style.display = \"none\";\n\n trees = [];\n for (let i = 1; i < window.innerWidth / 50; i++) generateTree();\n\n backgroundTrees = [];\n for (let i = 1; i < window.innerWidth / 30; i++) generateBackgroundTree();\n\n draw();\n}", "title": "" }, { "docid": "eef8ebf6650673f868338610f26a0f63", "score": "0.6602541", "text": "function reset() {\r\n page.showPreGame();\r\n gmUI.reset();\r\n }", "title": "" }, { "docid": "17410fbbdd71d84637a68b3efc4d9f65", "score": "0.6594807", "text": "function reset() {\n stop();\n init();\n reDraw(true);\n}", "title": "" }, { "docid": "80a4777440ec606b0bc2f91099b19549", "score": "0.65912056", "text": "function resetGame() {\n // reset game variables to initial conditions\n playerOActive = true;\n playerXActive = false;\n gameOver = false;\n xWins = false;\n oWins = false;\n oSpaces = [];\n xSpaces = [];\n\n //reset dynamically added classes and images\n $('.box').removeProp('style');\n $('#player1').addClass('active');\n $('#player2').removeClass('active');\n $('.box-filled-1').removeClass('box-filled-1');\n $('.box-filled-2').removeClass('box-filled-2');\n $('.screen-win').removeClass('screen-win-one');\n $('.screen-win').removeClass('screen-win-two');\n $('.screen-win').removeClass('screen-win-tie');\n }", "title": "" }, { "docid": "b13bdb36834a0cff8a54e0a3f874f08d", "score": "0.65902996", "text": "function resetGame(){\n //først sætter vi alle løberes tider til 0\n runners.map(runner => runner.time = 0)\n //vi nulstiller timeren, og sætter de andre variabler og tekster tilbage til 0\n window.clearInterval(timer)\n milliseconds = 0\n timerDiv.html('0:00')\n winnerDiv.html('').removeClass('in')\n showStats()\n}", "title": "" }, { "docid": "a056c4f8ecf0b5fde4f1cc6b37c96be3", "score": "0.65886045", "text": "function gameReset(){\n\tvar board = document.getElementById('game-board');\n\tboard.innerHTML = '';\n\tgenerateCards();\n}", "title": "" }, { "docid": "e9d11d257fcb84d3e173ee1cb2603d87", "score": "0.6587124", "text": "clearGame() {\r\n this.turn = 0;\r\n this.gameRunning = false;\r\n this.pieces = [];\r\n this.animator.clear();\r\n this.gameSequence.clear();\r\n }", "title": "" }, { "docid": "c54bfd38809293693019412d36e9ef70", "score": "0.6586491", "text": "function resetBoard() {\n board.forEach(function(box, boxId) {\n const div = document.getElementById(`box${boxId}`); \n div.style.backgroundColor= \"\";\n div.innerText = \"\";\n board[boxId] = null;\n });\n turn = 1;\n winner = null;\n renderBoard();\n getBackground();\n init();\n \n \n}", "title": "" }, { "docid": "b596639173e67b7f0a115e536a38143f", "score": "0.658355", "text": "function resetGame() {\n changeStatus('initial');\n current_status = 'initial';\n }", "title": "" }, { "docid": "fd7a1c4c13c78647e697adaf1ad0c789", "score": "0.6580919", "text": "function resetGame() {\n\tlocation.reload();\t\n}", "title": "" }, { "docid": "3ced81b9c47000da178b31e50d01f37a", "score": "0.65799457", "text": "function newGame() {\n spaces.forEach(\n function(space) {\n space.value = '';\n space.style.backgroundColor = 'green';\n })\n clearDebugging();\n turnNumber = 0;\n gameInProgress = true;\n clearGameMemory();\n}", "title": "" } ]
083ad409cd4a062a640328383695e1e9
Get photos from Unsplash API
[ { "docid": "f84a9389a313fe2d5b155f8310c343b1", "score": "0.6486049", "text": "async function getPhotos() {\n \n // on enlève l'eventuelle erreur de chargement qui aurait pu être là précédemment\n oupsError.hidden = true;\n\n try {\n const response = await fetch(apiUrl);\n photosArray = await response.json();\n console.log(photosArray);\n displayPhotos();\n } catch (error) {\n // Catch Error Here\n console.log(error);\n // on commence par retirer tous les éléments du container, en cas de nouvelle erreur\n while (oupsError.firstChild) {\n oupsError.removeChild(oupsError.firstChild);\n }\n // on créé les éléments à ajouter au container\n const iconError = document.createElement('i');\n iconError.classList.add('fas' , 'fa-exclamation-circle' , 'fa-5x');\n const h2Error = document.createElement('h2');\n const textError = document.createTextNode(\"Oups... Something went wrong... we've probably asked too much to the API, please try again later ;-)\");\n h2Error.appendChild(textError);\n oupsError.appendChild(iconError);\n oupsError.appendChild(h2Error);\n loader.hidden = true;\n oupsError.hidden = false;\n }\n }", "title": "" } ]
[ { "docid": "c87e761b0b5b1a81cc45cfb995d566f0", "score": "0.7902115", "text": "async function getPhotos() {\n try {\n const response = await fetch(unsplashUrl);\n photosArray = await response.json();\n displayPhotos();\n } catch (error) {\n // catch error \n }\n}", "title": "" }, { "docid": "83897637badc0d09e60427c0269ceaae", "score": "0.7877228", "text": "async function getPhotos(){\n try{ \n const uri = `https://api.unsplash.com/photos/random/?client_id=${accessKey}&count=${count}`; \n const response = await fetch(uri);\n const data = await response.json();\n displayPhotos(data);\n }catch(err){\n console.log(err)\n }\n\n}", "title": "" }, { "docid": "900f4e84cf6135465e683a5f5a1b48f4", "score": "0.78282475", "text": "async function getPhotos() {\n try {\n const response = await fetch(unsplashApiUrl);\n photosArray = await response.json();\n displayPhotos();\n if(isInitialLoad) {\n setNewCountApiUrl(30);\n isInitialLoad = false;\n }\n } catch (error) {\n // Catch Error\n }\n}", "title": "" }, { "docid": "4e2bc99e2a9cb2ff6e8a3609c24f3356", "score": "0.77995837", "text": "async function getImagesFromUnsplash() {\n try {\n const response = await fetch(unsplashApiUrl);\n imagesArray = await response.json();\n displayImages();\n if (initialLoad) {\n updateApiUrlWithNewContent(30);\n initialLoad = false;\n }\n } catch (error) {\n // Catch errors here\n alert(\"An error occurred while loading images. Try refreshing the page.\");\n }\n}", "title": "" }, { "docid": "9924657dd76790b8b33a8c88e44eeb34", "score": "0.7709652", "text": "async function getPhotos() {\n try {\n const response = await fetch(apiUrl);\n const photoArray = await response.json();\n displayPhotos(photoArray);\n } catch (error) {\n console.log(error);\n loader.hidden = true;\n imageContainer.innerText = \"Unsplash API Error\";\n }\n}", "title": "" }, { "docid": "775a0ead25a93bfaf73133b88def473c", "score": "0.7452474", "text": "async function getPhotos() {\n try {\n const apiUrl = intialLoad\n ? generateApiUrl(INITIAL_COUNT)\n : generateApiUrl(COUNT);\n\n const response = await fetch(apiUrl);\n photosArray = await response.json();\n displayPhotos();\n loader.hidden = false;\n } catch (e) {\n console.log(\"Getting Photos From API Failed\", e);\n }\n}", "title": "" }, { "docid": "800d024cd805bc25654f13eb0266833d", "score": "0.7385846", "text": "function fetchImages() {\n\tisLoading = true\n\tdisplayLoader(isLoading)\n\tfetch(`https://api.flickr.com/services/rest/?method=flickr.photos.search&in_gallery=true&api_key=97a2010d6449784728e75b5b59424c57&tags=clouds&extras=owner_name%2C+views&sort=interestingness-desc&per_page=18&page=${currentPage}&format=json&nojsoncallback=1`)\n\t\t.then(response => response.json())\n\t\t.then (data => printImages(data.photos.photo))\n\t\t.then(() => {\n\t\t\tisLoading = false\n\t\t\tdisplayLoader(isLoading)\n\t\t})\n\t\t.catch(error => {\n\t\t\tisLoading = false\n\t\t\tdisplayLoader(isLoading)\n\t\t\thandleErrors()\n\t\t\tconsole.log(error)\n\t\t})\n}", "title": "" }, { "docid": "c6ddb1d4a907903209b6bbc652099d87", "score": "0.7336646", "text": "async function getPhotos(){\n try{\n const response = await fetch(unsplashUrl);\n photoArray = await response.json();\n displayPhotos();\n }catch(error) {\n // Catch error here\n console.log(error);\n }\n}", "title": "" }, { "docid": "97809ac263aea30f4e0a31037daa22ea", "score": "0.72886467", "text": "async function searchPhotos() {\n const response = await fetch(url, {\n headers: {\n Accept: \"application/json\",\n Authorization: `${key}`,\n },\n });\n const result = await response.json();\n return result;\n }", "title": "" }, { "docid": "3009107ae302798ade67a7bcaa6b57da", "score": "0.723516", "text": "async function getPhotos(){\n\ttry {\n\t\tconst response = await fetch (apiURL);\n\t\tphotosArray = await response.json();\n\t\tdisplayPhotos();\n\t}\tcatch (error){\n\n\t}\n}", "title": "" }, { "docid": "aa382909758d0fd6a9ca7393a32f7433", "score": "0.72317004", "text": "async fetchPhotos(page) {\n\t\tawait axios\n\t\t\t.get(\n\t\t\t\t`https://api.unsplash.com/search/photos/?page=${page}&query=${this.props.queryvalue}&per_page=${this.state.perPage}/&client_id=${key}`\n\t\t\t)\n\t\t\t.then((res) => {\n\t\t\t\tconsole.log(res);\n\t\t\t\tif (res.data.results) {\n\t\t\t\t\tthis.setState({\n\t\t\t\t\t\tfilterImages: res.data.results,\n\t\t\t\t\t\ttotalPhotos: res.headers[\"x-total\"],\n\t\t\t\t\t\tcurrentPage: page,\n\t\t\t\t\t\tno_data: false,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthis.setState({\n\t\t\t\t\t\tno_data: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t}", "title": "" }, { "docid": "da73b2505f0c47f8121487ddeb8ae4c1", "score": "0.7222069", "text": "async function getPhotos(){\n try{\n const response = await fetch(apiUrl);\n const data = await response.json();\n photos = data.map( img => {\n return {\n description: img.alt_description,\n likes: img.likes,\n date: img.created_at,\n author: img.user.name,\n url: img.urls.regular,\n link: img.links.html,\n }\n });\n displayPhotos();\n if(isInitialLoad){\n updateAPIURLWithNewCount(15);\n isInitialLoad = false;\n }\n }catch(error){\n console.log(error);\n }\n}", "title": "" }, { "docid": "61316af5d972a734b60d2fe65a0424d5", "score": "0.7190353", "text": "async function getPhotos() {\n try {\n const response = await fetch(apiUrl);\n PHOTOS_ARRAY = await response.json();\n\n displayPhotos();\n } catch (error) {}\n}", "title": "" }, { "docid": "3dc75d59c41b9d626e8f5aa9c0b7dead", "score": "0.7150096", "text": "function getPhotos(numImages, order, replace) {\n let randomImageIndex = Math.floor(Math.random() * totalPages);\n currPage = randomImageIndex;\n console.log('Getting photos...from page ' + randomImageIndex);\n\n // Client Access ID from your unsplash app dashboard\n const clientID = ''; //'client_id=XXX'\n\n // Query api for a single page of photos\n var params = {\n page : randomImageIndex,\n per_page : numImages,\n order_by : order\n }\n\n // teststst\n $.ajax({\n type: \"get\",\n url: `https://api.unsplash.com/photos/?${clientID}`,\n crossDomain: true,\n cache: false,\n dataType: \"json\",\n contentType: \"application/json; charset=UTF-8\",\n data: params,\n success: function(photoList, textStatus, xhr) {\n var totalPhotos = xhr.getResponseHeader(\"X-Total\");\n totalPages = Math.floor(totalPhotos / numImages) - 1;\n console.log('Total pages: ' + totalPages);\n console.log('Total photos: ' + totalPhotos);\n //console.log('Num photos this page: ' + xhr.getResponseHeader(\"X-Per-Page\"));\n\n // Clear photo DOM elements if refreshing\n if (replace) {\n $('#photos').html('');\n }\n\n\n $.each(photoList, function(index, value) {\n // Get attributes from json\n var avatar = value.user.profile_image.small;\n var name = value.user.name;\n var bio = value.user.bio;\n if (bio === null) {bio = 'No Bio'}\n var imageURL = value.urls.regular;\n var dl = value.links.download;\n var likes = value.likes;\n var col = value.color;\n\n // Make Elements\n //\n // Item Container\n var itemEl = document.createElement('div');\n itemEl.className = 'photo-item';\n itemEl.title = dl;\n itemEl.style.backgroundColor = col;\n itemEl.innerHTML = \n `\n <div class=\"sel-item\"></div>\n <div class=\"nameContainer\">\n <img src=\"${avatar}\" class=\"avatar\" height=\"26\" width=\"26\">\n <h1 class=\"name\" title=\"author\">${name}</h1>\n </div>\n <h2 class=\"likes\" title=\"likes\">${likes}</h2>\n <p class=\"bio\" title=\"bio\">${bio}</p>\n `;\n // Photo container\n var photoEl = document.createElement('div');\n photoEl.className = 'photo-image';\n photoEl.title = imageURL;\n var imgEl = document.createElement('div');\n imgEl.className = 'imgLoading';\n $(photoEl).hide(); // Hide image to fadeIn later onLoad\n photoEl.style.backgroundImage = 'url(' + imageURL + ')';\n itemEl.appendChild(imgEl);\n photoEl.addEventListener( \"load\", imgLoaded(photoEl, imgEl) ); // Listen for done loading event to fade-in\n\n // Build DOM\n //\n // Add photo image to item container\n itemEl.appendChild(photoEl);\n // Add photo item to gallery container\n $('#photos').append(itemEl);\n });\n },\n error: function (xhr, textStatus, errorThrown) {\n console.log(errorThrown);\n }});\n}", "title": "" }, { "docid": "763bc36ab1e1fb7bf63fda1d4a2d2f84", "score": "0.7102222", "text": "function getPics(v){\n fetch(`https://api.unsplash.com/search/photos?query=${v}&client_id=26466f28b131dd4faf1de40f6fdad48db8620e6172ff77f8c0b459e6ea421d2f`)\n .then(function(response) {\n return response.json();\n })\n .then(function(myJson) {\n console.log(myJson);\n //$(\".pic\").html('')\n let html=\"\"\n for (let i=0; i<4; i++) {\n //$(\".pic\").append(`<img src= ${myJson.results[i].urls.thumb}/>`)\n let slide=`<div class=\"mySlides fade\" style=\"background-image: url(${myJson.results[i].urls.regular})\">\n <div class=\"numbertext\">${i} of 4</div>\n \n \n </div>`\n html+=slide\n \n }\n $(\".slideshow-container\").html(html)\n slideIndex = 0;\n showSlides();\n\n \n });\n}", "title": "" }, { "docid": "4923842ef91d85c43140749da1b1c432", "score": "0.70786923", "text": "async function getPhotos() {\n try {\n const res = await fetch(apiURL)\n photosArray = await res.json()\n displayPhotos()\n } catch (e) {\n console.error(e)\n }\n}", "title": "" }, { "docid": "dfd2c6d837280ce8c0f8dfd7ad5ddac6", "score": "0.7041629", "text": "async function getPhotos() {\r\n try {\r\n const response = await fetch(apiUrl);\r\n photosArray = await response.json();\r\n displayPhotos();\r\n } catch (error) {\r\n // Catch Error Here\r\n }\r\n }", "title": "" }, { "docid": "1c19460b94d57b433dbf4157e7329eef", "score": "0.6980684", "text": "function getImage() {\n $.ajax({\n method: \"GET\",\n url: `https://api.unsplash.com/photos/random?client_id=${API_KEY}&query=motivational+quotes&w=1024&h=768`,\n // take out the entire \"success\" function as a callback\n success: onSuccess,\n error: function (err) {\n console.log(err);\n },\n });\n}", "title": "" }, { "docid": "b979a03600bda05a8f6c7e3dc97af1b4", "score": "0.69750625", "text": "function fetchUnsplash (keyword) {\n const unsplashRequest = new XMLHttpRequest();\n const unsplashClientID = unsplashAPIKey;\n const requestURL = `https://api.unsplash.com/search/photos?` +\n `orientation=landscape&` +\n `page=1&` +\n `query=${keyword}`;\n unsplashRequest.open('GET', requestURL);\n unsplashRequest.setRequestHeader('Authorization', `Client-ID ${unsplashClientID}`);\n unsplashRequest.onload = addPhoto;\n unsplashRequest.send();\n}", "title": "" }, { "docid": "72784e0d9b6d1e60ba7d0361ba351a0a", "score": "0.6966749", "text": "function unsplashURL() {\n thumbs.innerHTML = \"\";\n\n return getWeatherDes().then(function(weatherDes) {\n const picURL = `https://api.unsplash.com/search/photos?query=${weatherDes}&client_id=a6f56ab9923955bf32f1a926a91b817078e4d6ec9e5b6fa61b173e8ef799afde`;\n const makeThumb = item => {\n return `\n <a class=\"thumbs__link\" href=\"${item.urls.regular}\">\n <img class=\"thumbs__link__img\" src=${item.urls.thumb}>\n </a>\n `;\n };\n\n fetch(picURL)\n .then(function(response) {\n return response.json();\n })\n .then(function({ results }) {\n // access JSONimg to capture the thumbnail URL source for each object\n thumbs.innerHTML = results.map(makeThumb).join(\"\");\n });\n });\n }", "title": "" }, { "docid": "39d905fe2b866e77d5dd1e5b3a5a9e11", "score": "0.6904493", "text": "function callUnsplashApi(cat, num) {\n $.ajax({\n url:\n 'https://api.unsplash.com/photos/random?client_id=57ec7e31d50ff96bfc45480b25a75ebc00b710583c46b4763aad264d54172a6b&w=600&h=400&count=1&query=' +\n cat,\n method: 'GET',\n }).then(getResults);\n\n // Store the returned category image in local storage\n function getResults(results) {\n console.log(results);\n localStorage.setItem('catPic' + num, results[0].urls.small);\n }\n }", "title": "" }, { "docid": "375062a4b3421d96a637b62b4a55d9a4", "score": "0.68991643", "text": "function getImages_() {\n return apiHelperService.getCall('photos');\n }", "title": "" }, { "docid": "428090cbf30c95cb06e81ba1a4eb82ef", "score": "0.686794", "text": "function getPublicPhotos(): Promise<Detail[]> {\n return new Promise((resolve, reject) => {\n const callback = generateRandomName();\n\n window[callback] = (data) => {\n resolve(data.items);\n delete window[callback];\n }\n\n var script = document.createElement('script');\n script.addEventListener('error', (err) => reject(err));\n script.src = publicPhotosUrl + '&jsoncallback=' + callback;\n document.querySelector('head').appendChild(script);\n });\n}", "title": "" }, { "docid": "01f30f9840a98511e479f0f4cbcfeb3a", "score": "0.68556625", "text": "loadPhotos() {\n return __awaiter(this, void 0, _promise2.default, function* () {\n return Photo_1.Photo.loadFromPhotoInfoListUrl(this.getApiClient(), this.getPhotosLink());\n });\n }", "title": "" }, { "docid": "ebf33db6d08907caa4ccb25f010f8e08", "score": "0.6850275", "text": "async function getImages() {\n const proxyUrl = 'https://vast-shore-57584.herokuapp.com/';\n const apiUrl = `https://wallhaven.cc/api/v1/search?categories=110&purity=110&sorting=random&seed=${seed}`;\n try {\n const response = await fetch(proxyUrl + apiUrl);\n\n let data = await response.json();\n imagesArray = Object.values(data);\n imagesArray = imagesArray[0];\n displayImages();\n } catch (error) {\n // I have nothing here yet\n }\n}", "title": "" }, { "docid": "fb987e7da8cfa2337d56455036eff414", "score": "0.6834379", "text": "async function getPhotos() {\n try{\n const response = await fetch(apiURL) ; \n photosArray = await response.json();\n displayPhotos();\n }catch(error){\n\n }\n}", "title": "" }, { "docid": "f91b408ea1aba3a8932a9ee1547e0cb8", "score": "0.6828555", "text": "listPhotos (context) {\n axios\n .get(\n 'https://api.unsplash.com/photos?order_by=latest&per_page=12',\n {\n headers: {\n Authorization: context.getters.getKey\n }\n }\n )\n .then((response) => {\n context.commit('SET_PHOTOS', response.data)\n })\n }", "title": "" }, { "docid": "dd120ba7517c6159791ccd637f258db1", "score": "0.68101466", "text": "unsplashRequest(query, page) {\n if ( page === undefined ) {\n page = 1;\n }\n \n //si la recherche est vide on ne fait pas de requete et on passe un tableau vide à la fonction\n if ( query === '' ) {\n return buildGallery([]);\n //avec return, on s'arrete là\n }\n this.query = query;\n this.currentPage = parseInt(page);\n //on recupere les éléments en PHP afin de garder secret les identifiants de connexion à unsplash\n fetch('/admin/photosFromUnsplash/' + this.query + '/' + parseInt(this.currentPage))\n .then( (response) => {\n response.json().then( (response) => {\n //on construit la gallerie d'images avec le resultat de la requete \n this.buildGallery(response.results, response.page, response.totalPages);\n })\n })\n .catch( (err) => console.log(err) );\n \n }", "title": "" }, { "docid": "827f6c27b20996afedb4b9d80d8e680c", "score": "0.679499", "text": "async function getPhotosFromAPI() {\n try {\n const response = await fetch(apiUrl);\n photosArray = await response.json();\n displayPhotos();\n } catch (error) {\n console.log('Oops! an error occured', error); \n }\n}", "title": "" }, { "docid": "5214ed6e4a1e93c1c896709bd508ea1f", "score": "0.6752177", "text": "function getPhotogsPictures() {\n return fetch(URL + 'pictures')\n .then(resp => resp.json())\n .then(picData => filterPics(picData))\n}", "title": "" }, { "docid": "cfc5a259d235ba65d2d0e766bd58d577", "score": "0.67278683", "text": "function fetchImagesAPI(searchInput, page ) {\n \n return fetch(`https://pixabay.com/api/?q=${searchInput}&page=${page}&key=${API_KEY}&image_type=photo&orientation=horizontal&per_page=12`)\n .then(response => {\n if (response.ok) {\n return response.json()\n }\n return Promise.reject(new Error(`не удалось найти изображение по запросу ${searchInput}`))\n })\n}", "title": "" }, { "docid": "f41d1133dd036ab3f8d1555761909d9e", "score": "0.67230225", "text": "async function getPhotos() {\n try {\n const response = await fetch(apiUrl);\n // const data = await response.json(); // returns array of ${count} objects\n photosArray = await response.json(); // store inside an array state\n displayPhotos();\n } catch (error) {\n console.log(error)\n }\n}", "title": "" }, { "docid": "196afca0e3cba4128674dedbe8252874", "score": "0.67111754", "text": "async function curatedPhotos() {\n fetchLink = 'https://api.pexels.com/v1/curated?per_page=15&page=1';\n const data = await fetchApi(fetchLink);\n generatePictures(data);\n}", "title": "" }, { "docid": "93afa544259a8c26a7212fa068c951e8", "score": "0.67044425", "text": "function loadRecentImages() {\n var method = \"flickr.photos.getRecent\";\n bildgalleri.flickrService.getRecent().then(function (response) {\n var result = JSON.parse(response);\n var result = result.photos.photo;\n appendImages(result);\n\n }, function (error) {\n console.log(\"something went wrong\")\n });\n }", "title": "" }, { "docid": "3f34fb10dc7fbd5d30c9ee07fd019990", "score": "0.66879076", "text": "async function getphotos(){\n\n try{\n\n const response= await fetch(apiurl);\n photosArray= await response.json();\n displayphotos();\n }\n catch(error){\n\n }\n\n}", "title": "" }, { "docid": "f02cbb597f9ee916151afafb2e95e5ff", "score": "0.66854334", "text": "function getDataFromApi(query) {\ncards.style.display = 'none';\nloader.style.display = 'block';\n\nfetch(`https://api.unsplash.com/search/photos?client_id=B6kV49xFR9VbGZucm37yUL5uSG-KjKyv8u5h1ZrB7f0&query=${query}&per_page=8`)\n .then(res => res.json())\n .then(data => {\n data.results.forEach((items,index)=>{\n const li = document.createElement('div');\n //This creates a classname list\n li.classList.add('list')\n li.innerHTML = \n `<img src=${items.urls.thumb} class=\"img\"/>\n <h4>${items.user.username}</h4>\n <p>${items.user.location}</p>`\n \n // this puts the images on the card\n cards.append(li);\n\n\n // This makes the modal functional once you click on an image\n li.addEventListener('click', () => {\n modal.style.display = \"block\";\n modalImg.src = items.urls.regular;\n caption.innerHTML = `${items.user.first_name}\n ${items.user.last_name}\n <br>\n ${items.user.location} \n `;\n caption.style.textAlign = \"left\";\n})\n\n })\n})\n.finally(data => {\n cards.style.display = 'block';\n loader.style.display = 'none';\n}) \n}", "title": "" }, { "docid": "0956a48c86938384383a6b43879a3b32", "score": "0.6675219", "text": "function getPics(query) {\n API.getData(query)\n .then((res) => setResults(res.data.results))\n .catch((err) => console.log(err));\n }", "title": "" }, { "docid": "901064c82cc8c7df105211904ad73054", "score": "0.6665826", "text": "async function getPhotos(){\r\n try {\r\n const response =await fetch(apiUrl);\r\n photosarray=await response.json();\r\n displayPhotos();\r\n // console.log(photosarray);\r\n // console.log(data);\r\n } catch (e) {\r\n //catch the error\r\n console.log('e');\r\n getPhotos();\r\n}\r\n}", "title": "" }, { "docid": "7a67d6af76e3337683a9efc5bc91506c", "score": "0.6637114", "text": "async function getImages(text, numberOfImages){\n \n const apiKey = '19d3e6e0acfe9c438f368e2c2bab1c5d';\n const baseUrl = 'https://api.flickr.com/services/rest';\n let method = 'flickr.photos.search';\n \n //api_key need to be in exact format from flickr\n let url = `${baseUrl}?api_key=${apiKey}&method=${method}&text=${text}&per_page=${numberOfImages}&format=json&nojsoncallback=1`;\n\n let resp = await fetch(url);\n let data = await resp.json();\n \n return data.photos;\n}", "title": "" }, { "docid": "f07527fe1efe4a1e94f2b9cf90cc7eda", "score": "0.6630643", "text": "async function getPhotos() {\n \n try {\n const response = await fetch(apiUrl);\n photosArr = await response.json();\n displayPhotos();\n \n } catch(err) {\n \n console.log(err);\n loader.hidden = true;\n const error = document.createElement('h1');\n error.style.color = '#ff2f2b'\n error.innerText = 'Error Loading Images.';\n imageContainer.appendChild(error);\n }\n}", "title": "" }, { "docid": "8b1edf46c936b169224be4b3203cec10", "score": "0.6609759", "text": "function getBaconyPics() {\n return $.ajax({\n url: \"https://api.gettyimages.com/v3/search/images?orientations=Horizontal&phrase=meat\",\n headers: { 'Api-Key': \"9qgr2g33nbuhwzhaez8v43kc\" }\n })\n}", "title": "" }, { "docid": "31f89ae89763473e0d4df07a7ade68ff", "score": "0.65994555", "text": "async function getPhotos(){\n try{\n\n //retrieve JSON data from API\n const response = await fetch(apiUrl);\n photosArray = await response.json();\n\n \n // call function to display photos \n displayPhotos();\n\n if(isInitialLoad){\n updateAPIURL(30);\n isInitialLoad = false;\n };\n\n\n } catch(error){\n //catch error here\n }\n}", "title": "" }, { "docid": "d1b0d552448200862b7ee2c6b43966d9", "score": "0.65955794", "text": "loadOwls() {\n this.setState({loading: true, owls: []});\n axios.get(`https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=` + apiKey + `&tags='+true+owl+'&format=json&nojsoncallback=1`,\n {\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n },\n credentials: 'include'\n })\n .then(response => {\n this.setState({ \n owls: response.data.photos.photo.slice(0, 25),\n loading: false});\n })\n .catch(error => {\n this.setState({loading: false});\n });\n }", "title": "" }, { "docid": "89ec024b87ea5a6314a576291ae0b028", "score": "0.65944374", "text": "async function getPhotos() {\n try {\n const response = await fetch(apiUrl)\n photosArray = await response.json()\n displayPhotos()\n\n } catch (error) {\n //catch error here\n }\n}", "title": "" }, { "docid": "7a3e9d36a25ca84bd17f717d1b983580", "score": "0.65788543", "text": "function loadREST () {\n fetch ('https://picsum.photos/list')\n\n .then (function (response) { //type of response?\n return response.json () //i sa REST API isto json\n })\n\n .then(function (data) {\n console.log (data);\n\n let html = '';\n data.forEach (function (image) { //make a url to be a link in anew window\n html += `<li>\n <a target=\"_blank\" href=\"${image.post_url}\">View Image</a> \n ${image.author} \n </li>`\n })\n document.getElementById ('result').innerHTML = html;\n })\n\n .catch (function (error){\n console.log (error);\n })\n\n \n \n\n\n\n}", "title": "" }, { "docid": "bca33c1bcbf676d6bea9a9c3eb17bf3e", "score": "0.6558137", "text": "function requestPhotos() {\n return {\n type: FETCH_PHOTOS_PENDING\n };\n}", "title": "" }, { "docid": "e2b1e554eaaf66a22afa9c34d6951c79", "score": "0.6546818", "text": "function cargarAPI(){\n\n fetch('https://picsum.photos/list')\n .then(function(imagenes){\n \n console.log(imagenes);\n return imagenes.json(); \n })\n\n .then (function(imagenes){\n\n let html='';\n\n imagenes.forEach(function(img){\n\n html +=`\n\n <li>\n <a target=\"_blank\" href=\"${img.post_url}\"> ir a la imagen</a>\n ${img.author}\n </li>\n `;\n });\n\n document.getElementById(\"resultado\").innerHTML=html;\n })\n\n .catch(function(error){\n console.log(error);\n });\n}", "title": "" }, { "docid": "59a3c987d0af1056cd7e73bebe0588c3", "score": "0.6524038", "text": "function getPhotos() {\n $.ajax({\n url: \"https://api.nasa.gov/mars-photos/api/v1/rovers/\" + roverName + \"/photos?earth_date=\" + photoDate + \"&api_key=Bjd4d9v5oIk2XvFo5LoqMnNbD8FLmddlFrXHu4k8\",\n method: \"GET\"\n }).then(function(response) {\n var pics = response.photos\n for(var j = 0; j < pics.length; j++) {\n var mastCam = pics[j].camera.name.includes(\"MAST\");\n var panCam = pics[j].camera.name.includes(\"PANCAM\");\n if(mastCam === true || panCam === true){\n var imgSrc = response.photos[j].img_src\n };\n imgObj.push({imgSrc});\n };\n sortPhotos();\n });\n}", "title": "" }, { "docid": "59d41a9c79e765301a7e0c4419818faf", "score": "0.6506842", "text": "async function getPhotos() {\n // show loader\n const loader = document.querySelector(\".loader\");\n loader.classList.remove(\"hidden\");\n\n // increment page variable by 1\n page++;\n\n dataFetching = true;\n // fetch from API\n const response = await fetch(`${API_URL}&page=${page}`);\n\n // response to json\n const photos = await response.json();\n\n // hide loader\n loader.classList.add(\"hidden\");\n\n // push new images that we got from API to allPhotos array\n allPhotos.push(...photos);\n\n // add new images to DOM\n photos.forEach((photo, i) => {\n const content = document.createElement(\"div\");\n content.className = \"single-image-wrapper\";\n\n const linkPortfolio = photo.user?.portfolio_url\n ? `<a href=\"${photo.user.portfolio_url}\" target=\"_blank\">Portfolio</a>`\n : \"<span>This user has no portfoio</span>\";\n\n const insta = photo.user?.social?.instagram_username\n ? `<a href=\"https://instagram.com/${photo.user.social?.instagram_username}\" target=\"_blank\"><i class=\"fab fa-instagram\"></i> ${photo.user.social?.instagram_username}</a>`\n : \"\";\n\n const twitter = photo.user?.social?.twitter_username\n ? `<a href=\"https://twitter.com/${photo.user.social?.twitter_username}\" target=\"_blank\"><i class=\"fab fa-twitter\"></i> ${photo.user.social?.twitter_username}</a>`\n : \"\";\n\n const paypal = photo.user?.social?.paypal_email\n ? `<span><i class=\"fab fa-paypal\"></i> ${photo.user.social?.paypal_email}</span>`\n : \"\";\n\n content.innerHTML = `<div class=\"single-image\" data-id=\"${photo.id}\">\n <figure class=\"img-figure\">\n <img src=\"${photo.urls.small}\" alt=\"${\n photo.alt_description ? photo.alt_description : \"this photo has no alt\"\n }\" class=\"images\" />\n </figure>\n <div class=\"img-footer\">\n <div class=\"footer-wrapper\">\n <div class=\"profile\"> \n <img src=\"${\n photo.user.profile_image.small\n }\" alt=\"profile-image\">\n <span class=\"username\">${photo.user.username}</span>\n </div>\n <div class=\"info\">\n <a href=\"${\n photo.links.download\n }\" class=\"fas fa-link photo-link\" target=\"_blank\"></a>\n <span>${photo.downloads}</span>\n <i class=\"fas fa-arrow-down\"></i>\n <span>${photo.likes}</span>\n <i class=\"far fa-thumbs-up\"></i>\n </div>\n </div>\n <div class=\"profile-extra\">\n <hr/>\n <div class=\"profile-extra__portfolio\">\n ${linkPortfolio}\n </div>\n <div class=\"profile-extra__social\">\n ${insta} <br>\n ${twitter} ${paypal}\n </div>\n </div>\n </div>\n </div>`;\n\n imageContainer.appendChild(content);\n });\n\n dataFetching = false;\n}", "title": "" }, { "docid": "886a4e6a5a104aee3070aea47d311ba1", "score": "0.6502444", "text": "search() {\n /* per_page indica las imagenes que quiero */\n fetch(`${endpoint}?query=${this.query}&per_page=20&client_id=${clientid}`)\n .then(response => {\n return response.json()\n }).then(jsonResponse => {\n console.log(jsonResponse);\n this.setState({\n /**\n * imprimo el json y lo asigno\n */\n images: jsonResponse.results\n })\n })\n }", "title": "" }, { "docid": "77e41291d14ddfd1662234308b03bed5", "score": "0.6500401", "text": "fetchData() {\n api.getPhotos(this.state.currentPage)\n .then((jsonRes) => this.handleResponse(jsonRes))\n .catch((err) => {\n this.setState({\n isLoading: false,\n error: `There was an error: ${err}`\n })\n });\n }", "title": "" }, { "docid": "1aaa9d09028af720348bb9140f070702", "score": "0.6498337", "text": "function getPhotos(i,url) {\n getAllData(url, function(resp) {\n var url;\n var photos = JSON.parse(resp).response.venue.photos; \n var getSinglePhoto = document.getElementById(`photo_${i+1}`);\n if (!photos.groups.length) {\n url = \"assets/images/image-not-available.jpg\"; \n }else{\n url = `${photos.groups[0].items[0].prefix}` + 350 + \"x\" + 250 + `${photos.groups[0].items[0].suffix}`;\n } \n getSinglePhoto.src = url;\n });\n}", "title": "" }, { "docid": "89a5114f556b958561fc01ff83411ae4", "score": "0.6484768", "text": "function _get() {\n // 1.\n return new Promise((resolve, reject) => {\n if (_cache.size) {\n resolve(_cache);\n } else {\n let params = {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json'\n }\n };\n fetch('https://api.500px.com/v1/photos/search?term=kitten&feature=popular&only=11&include_store=0' +\n '&tags=0&include_states=0&image_size=3&consumer_key=UpwVHaShpniIM00n77hIPTsjWc8tLV4RfTay9PqJ', params)\n .then(_checkStatus)\n .then(_parseJSON)\n .then(json => {\n resolve(json.photos);\n }).catch(e => {\n reject(e);\n });\n }\n });\n }", "title": "" }, { "docid": "5efca83fdab8d1915445fd2a33d0dc3a", "score": "0.64808685", "text": "async function getphotos(){\n try {\n const response = await fetch(apiUrl); //await request from api url \n photosarray= await response.json(); // the response will run thruough the json message and returned as json \n displayPhotos();\n } catch (error) {\n // catch Error Here \n }\n}", "title": "" }, { "docid": "d5406254afe6ad263f9479a781c76643", "score": "0.6475922", "text": "function getTaggedPhotos(country) {\n\n fetch(\"https://api.tumblr.com/v2/tagged?tag=\" + country + \"&api_key=Q18H9I0fuqNF1J86vkDWUZuGgFl5OJ2CsN2nJO6UWQqA1mhJES\")\n .then(function(response) {\n return response.json(); //this gets the json object from within the original json file\n })\n\n .then(function(result) {\n \n \t// will clear image list before loading the next one\n list.innerHTML = \" \";\n\n\t const items = result.response;\n\n\t for (let i = 0; i < items.length; i++){\n\t\t const item = items[i];\n \n if(item.photos != undefined) {\n const altSizes = item.photos[0].alt_sizes;\n const imgSrc = altSizes[altSizes.length - 2].url;\n\n\t\t const img = document.createElement(\"img\");\n\t\t img.src = imgSrc;\n\n\t\t const li = document.createElement(\"li\");\n\t\t li.appendChild(img);\n\t\t // li.innerHTML = imgSrc;\n list.appendChild(li);\n\t }\n }\n\n })\n }", "title": "" }, { "docid": "5740d9149f49b62e098bb86412fd93bb", "score": "0.64461446", "text": "async function fetchImages({ query = '', page = 1, perPage = 12 }) {\n const { data } = await axios.get(\n `?q=${query}&page=${page}&key=${API_KEY}&image_type=photo&orientation=horizontal&per_page=${perPage}`,\n );\n return data.hits;\n}", "title": "" }, { "docid": "948f7bbedf599b71d8e1cda191a0a279", "score": "0.6441256", "text": "async function getRandomImageJson() {\r\n const baseUrl = 'https://api.unsplash.com/photos/random?featured=true&content_filter=high&orientation=landscape';\r\n const url = `${baseUrl}&client_id=${process.env.UNSPLASH_CLIENT_ID}`;\r\n const imageJson = (await axios.get(url)).data;\r\n return imageJson;\r\n}", "title": "" }, { "docid": "5b742cd45a28c9e03c06ed4853819e61", "score": "0.64338595", "text": "function getPhotos()\n{\n\tFB.api('/me/photos', function(response) {\n\t var str = '<ul class=\"fb_photo\">';\n\t $.each(response.data,function (){\n\t\tstr += formatPhotoElement(this.picture,this.source);\n\t });\n\t str += '</ul>';\n\t document.getElementById(\"myfb_photo\").innerHTML=str;\n\t});\n}", "title": "" }, { "docid": "aa525d1ce120efb047430e1450ce4bcd", "score": "0.64302707", "text": "async function getPhotos() {\n try {\n const response = await fetch(apiUrl);\n\n // receiving data from the API\n photoArray = await response.json();\n displayPhotos();\n } catch (error) {\n // Catch Error Here\n }\n}", "title": "" }, { "docid": "eedb6e27bece070dae2cf5d804413071", "score": "0.64260745", "text": "loadData(search) {\n const path = `https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=${apiKey}&tags=${search}&per_page=24&format=json&nojsoncallback=1`;\n return (\n axios.get(path)\n .then(response => {\n this.setState({\n photos: response.data.photos.photo,\n search: search,\n loading: false\n });\n })\n .catch(error => {\n console.log('Error fetching and parsing data', error); \n })\n );\n\n }", "title": "" }, { "docid": "79049d01c767e569a58dc3fa9a809deb", "score": "0.64256257", "text": "function getAlbum(url,callback)\n{\n var r=new XMLHttpRequest();\n r.open(\"GET\",`https://api.imgur.com/3/album/${url}/images`);\n\n r.onreadystatechange=()=>{\n if (r.readyState==4)\n {\n callback(JSON.parse(r.response));\n }\n };\n\n r.setRequestHeader(\"Authorization\",\"Client-ID 28bf65f46c4de3c\");\n r.send();\n}", "title": "" }, { "docid": "13bfd6f87895d47d4dca046b3cf9d218", "score": "0.6422705", "text": "FetchImages(){\n var searchTerm=this.state.InputText;\n fetch('https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=22b7d5bde5eb0e61538db8f0206e48a6&tags='+searchTerm+'&per_page=100&page=1&format=json&nojsoncallback=1')\n .then(function(response){\n return response.json();\n })\n .then(function(jsonObject){\n alert(JSON.stringify(jsonObject));\n let imageArray = jsonObject.photos.photo.map((pic) => {\n var imageSrc = 'https://farm'+pic.farm+'.staticflickr.com/'+pic.server+'/'+pic.id+'_'+pic.secret+'.jpg';\n return(\n <img alt=\"image\" src={imageSrc}></img>\n )\n })\n this.setState({images: imageArray});\n }.bind(this))\n}", "title": "" }, { "docid": "8fe6329638e64e8ff296aea04b0a5a7a", "score": "0.6419016", "text": "getPhotos() {\n ScrapbookApi.getUserPhotos(this.state.token, this.state.userId)\n .then(ApiUtils.checkStatus)\n .then((r) => {\n return r.json();\n })\n .then((r) => {\n photos = r;\n this.setState({\n dataSource: this.state.dataSource.cloneWithRows(photos),\n photos,\n loaded: true,\n });\n })\n .catch(e => console.log(e));\n }", "title": "" }, { "docid": "b2e202d4558f92ccd95a921a9c574b2d", "score": "0.64077854", "text": "function getCoverPhotos(albums) {\n for (var i = 0; i < albums.length; i++) {\n var album = albums[i];\n if (!album.id) { continue; }\n\n var albumPath = '/' + album.id + '/?access_token='+ACCESS_TOKEN;\n var getObj = https.get({\n host: 'graph.facebook.com',\n path: albumPath\n }, function(res) {\n var body = \"\";\n res.on('data', function(chunk) {\n body += chunk;\n });\n res.on('end', function() {\n try {\n var data = JSON.parse(body);\n var coverPhotoId = data.cover_photo\n } catch (err) {\n console.log('Cover photos:', err.message);\n }\n });\n });\n errorNoOp(getObj);\n }\n}", "title": "" }, { "docid": "b3bb57fb4348f35f35cb76a177ae467d", "score": "0.6405528", "text": "function fetchPhotos(){\n fetch('http://localhost:3001/api/v1/photos')\n .then(response => response.json())\n .then(photoJSON => {\n photoJSON.data.forEach(photo => {\n const attributes = photo.attributes;\n let newPhoto = new Photo(attributes.image_url, attributes.artist_name, photo.id);\n allPhotos.push(newPhoto);\n })\n })\n .then(() => {\n let mainDiv = document.getElementById('main');\n mainDiv.innerHTML = allPhotos[0].render();\n setInterval(nextPhoto, 3000);\n });\n}", "title": "" }, { "docid": "ea56b97cade74ed137c896143641ce53", "score": "0.6393788", "text": "function allPhotos() {\r\n sendHttpRequest(method, update_url + imgDate, mode).then((test) => {\r\n date_change();\r\n if (data.photos.length < 1) {\r\n // alert(\"we are here\");\r\n errorImage(\"flex\");\r\n disableCamera();\r\n removeChild();\r\n loadingImg(\"none\");\r\n // disableImage();\r\n console.log(\"no data found for this date!\");\r\n } else {\r\n errorImage(\"none\");\r\n data = test;\r\n urlIndex = 0;\r\n removeChild();\r\n showPic();\r\n getImageUrl();\r\n fetchCamera();\r\n }\r\n });\r\n}", "title": "" }, { "docid": "b000f70437ea4804b0261f1a96adea2b", "score": "0.6384635", "text": "function getPhotos(source) {\n // Retrieve image file location from specified source\n navigator.camera.getPicture(onPhotoURISuccesss, onFail, { quality: 50,\n\tdestinationType: destinationType.FILE_URI,\n\tsourceType: source });\n}", "title": "" }, { "docid": "61877af9e2f59c63ce28ea2e2c79406c", "score": "0.6360735", "text": "function init() {\n getPhotos();\n}", "title": "" }, { "docid": "8d111b9b37977328e7e5fbd53192953a", "score": "0.6354286", "text": "async function getPhotos() {\n try {\n const response = await fetch(apiUrl);\n photosArray = await response.json();\n displayPhotos();\n if (!isInitialLoaded) {\n updateAPIUrl(picCount);\n }\n isInitialLoaded = true;\n //console.log(photosArray); \n } catch (error) {\n // Catch ERROR here \n\n }\n}", "title": "" }, { "docid": "62cbd8f99bf38bf0344a9cc0822861d8", "score": "0.63515383", "text": "getImages(metadataCallback, imageCallback) {\n const params = new URLSearchParams(window.location.search);\n let date = moment.utc() // now\n // Can pass date to URL if desired\n if (params.get('date')) {\n date = moment(params.get('date'))\n }\n const folderPrefix = date.format('YYYY-MM-DD')\n \n this.getObjects(metadataCallback, imageCallback, folderPrefix)\n }", "title": "" }, { "docid": "2b416d3d4143fd09155159f72069e521", "score": "0.63361806", "text": "function Img4 (search) {\nreturn new Promise ( (resolve,reject) => {\n \n \n // function callback is an argument of request \nfunction callback(err, response, body) {\n \n if (err) {console.err()}\n \n if (!err && response.statusCode == 200) {\n body = body['photos']['photo'].map(image => {\n return {\n url: image['url_z'],\n title: image['title'],\n\n };\n });\n resolve(body);\n\n } else\n reject();\n\n}\n\n//options of request from Flickr\nvar options = {\n url: 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=84057f4de27df6cf716b4202f1dd2a1b&format=json&nojsoncallback=1&text='+search+'&extras=url_z',\n json: true,\n }\n //execute our request\nrequest(options,callback);\n\n}\n\n);\n}", "title": "" }, { "docid": "265f2f215a466f14dbfbf7b565ec76c8", "score": "0.6330343", "text": "function getImages(capitalCity){\r\n // Flickr api hr hämtar vi bilderna \r\n var url = \"https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9bb1ef3285f869282ecc5e8ff9526ad5&per_page=100&tags=\" + capitalCity + \"&extras=url_c%2C+url_m%2C+url_q\"\r\n // Här stter vi värder på capitalCity beroende på vad som väljs\r\n var capitalCity = capitalCity;\r\n // Här skapar vi en JSON callback funktion\r\n $.getJSON(url + \"&format=json&jsoncallback=?\", function(data){\r\n\r\n // Här skapar jag en image array med bilder från flickr som har de mått jag vill ha.\r\n var imageArray = [];\r\n for(var i = 0; i < data.photos.photo.length; i++){\r\n for(var i in data.photos.photo){\r\n // Här kollar vi så att bild proportionen är 500x333px om det är det så lggs de till i arrayn\r\n if(data.photos.photo[i].width_m === \"500\" && data.photos.photo[i].height_m === \"333\"){\r\n imageArray.push(data.photos.photo[i].url_m)\r\n }\r\n } \r\n } // <- end for loop\r\n \r\n \r\n \r\n var photoHTML = '<ul>';\r\n \r\n $.each(imageArray, function(i, photo){\r\n photoHTML += '<li>';\r\n \r\n photoHTML += '<img src=\"' + photo + '\"></li>';\r\n });\r\n photoHTML += '</ul>';\r\n $('#photos').html(photoHTML);\r\n \r\n });\r\n \r\n }", "title": "" }, { "docid": "cb134778add91883b40b5df3f31c7ac2", "score": "0.63290346", "text": "function getPhotos(){\n\t\t\tif(!isLoading){\n\t\t\t\tisLoading = true;\n\t\t\t\t$('#loading').fadeIn();\n\t\t\t // get the information of photos\n\t\t\t\t$.ajax({\n\t\t\t\t\turl: settings.server + '?' + decodeURIComponent($.param(settings.params)),\n\t\t\t\t\ttype: 'GET',\n\t\t\t\t\tcache: true,\n\t\t\t\t\tdataType: 'jsonp',\n\t\t\t\t\tsuccess: function(data) {\n\t\t\t\t\t\tif(!data.photos){\n\t\t\t\t\t\t\talert('Message from Flickr: '+data.message);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t$('#loading').fadeOut();\n\t\t\t\t\t\t// get current page\n\t\t\t\t\t\tcurrentPage = data.photos.page;\n\t\t\t\t\t\t// get total pages\n\t\t\t\t\t\ttotalPages = data.photos.pages;\n\t\t\t\t\t\t// redefine max page\n\t\t\t\t\t\tmaxPages = Math.min(maxPages, totalPages);\n\t\t\t\t\t\t// shuffle array\n\t\t\t\t\t\tif(settings.shuffle){\n\t\t\t\t\t\t\tdata.photos.photo.sort(function() { return 0.5 - Math.random() });\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// the list of photos\n\t\t\t\t\t\t$.merge(photos, data.photos.photo);\n\t\t\t\t\t\t// insert rows\n\t\t\t\t\t\tfor(var i=1; i <= settings.rows; i++){\n\t\t\t\t\t\t\tme.append($('<div/>',{'class':rowClassName}));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpagesLoaded++;\n\t\t\t\t\t\t// update the rows\n\t\t\t\t\t\tupdateRows();\n\t\t\t\t\t\tisLoading = false;\n\t\t\t\t\t}\n\t\t\t\t});\t\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "a0fdfdf068e67fe366cf076acbe62c6f", "score": "0.6323867", "text": "async function getPhotos() {\r\n try {\r\n const response = await fetch(apiUrl);\r\n photoArray = await response.json();\r\n displayPhotos()\r\n\r\n } catch (error) {\r\n // Catch Error Here\r\n\r\n }\r\n}", "title": "" }, { "docid": "531619cdaa88b4d8be1a8832e31527b3", "score": "0.6323339", "text": "function unsplashApi(req, res, next) {\n console.log(`[${req.uuid}] -API- `);\n let url = unsplashEndpoint + req.params[0];\n if (req.query) {\n url += `?`;\n for (const key in req.query) {\n url += `${key}=${req.query[key]}&`;\n }\n url = url.slice(0, -1);\n console.log(req.params);\n console.log(url.split('unsplash/'));\n }\n console.log(`[${req.uuid}] -API PASSTHROUGH- ${url}`);\n fetch(url, {\n method: 'get',\n headers: {\n Authorization: 'Client-ID ' + unsplashKey,\n },\n })\n .then(raw => raw.json())\n .then(json => {\n // console.log(json);\n return json;\n })\n .then(json => res.json(json))\n .catch(err =>\n console.log(`[${req.uuid}] -API PASSTHROUGH- FAILED. ${err}`)\n );\n}", "title": "" }, { "docid": "4d6c7531f168f3af6e4a01b301877dbf", "score": "0.63157123", "text": "_requestImages() {\n fetch('images.json')\n .then(response => {\n return response.json();\n })\n .then(\n json => {\n this._fetchImages(json)\n })\n }", "title": "" }, { "docid": "eb27068c5ef60da0bab511e4b15f1319", "score": "0.6303549", "text": "function searchImages() {\r\n\t$.getJSON(flickrApiSearch, flickrSearchOptions, getPhotos);\r\n}", "title": "" }, { "docid": "d2462d284f57297014ee00bcb6064a94", "score": "0.62919587", "text": "function getImagesFromSearch(url) {\n fetch(url, { method: \"GET\" })\n .then((response) => {\n if (response.ok) {\n return response.json();\n } else {\n throw new Error(response.statusText);\n }\n })\n .then((data) => {\n let imagesArray = data.results;\n let newHTML = imagesArray.map(\n (item) =>\n `<div class=\"item\"><img style=\"border-radius: 15px; \" src=${item.urls.regular}></img></div>`\n );\n document.getElementById(\"hold\").innerHTML = newHTML.join(\"\");\n })\n .catch((error) => {\n console.log(error);\n });\n}", "title": "" }, { "docid": "0fd24501b514386d4355db10de28ab27", "score": "0.6288409", "text": "showImageOptions () {\n return fetch('https://shielded-springs-75726.herokuapp.com/photos').then( (data) => {\n console.log('success showImageOptions', data);\n // do something with the data, display etc.\n });\n }", "title": "" }, { "docid": "45305df8cebfce2922733aeffaa83076", "score": "0.62847954", "text": "function getData() { // fetch image details list and call success and error callback.\r\n var baseUrl = \"https://picsum.photos/list\"; // this is the base url for fetch image details list.\r\n $.getJSON(baseUrl , initSlide, error); \r\n }", "title": "" }, { "docid": "bfe406a75da6d687b3593433bce9eece", "score": "0.62652606", "text": "async function getPhotos(){\n try {\n const response = await fetch(apiUrl)\n photosArray = await response.json();\n displayPhotos(photosArray)\n }\n catch (err){\n // Catch Error Here...\n }\n}", "title": "" }, { "docid": "b8b6d2b2634b6ef1965c145d68a7a435", "score": "0.6259368", "text": "getImages(place) {\n /*\n Create the flickr URL using the parameters needed to get photos and some infos\n Photos API method => https://www.flickr.com/services/api/flickr.photos.search.html \n */\n let flickrPhotosRequest = 'https://api.flickr.com/services/rest/?method='+\n 'flickr.photos.search&api_key=3ec41c2ca6c30eae649009aa1310d949&format=json&nojsoncallback=1&'+\n '&tags=' + place.tags + '&lat=' + place.lat + '&lon='+ place.lng + '&per_page=8&radius=5&sort=relevance&extras=owner_name';\n\n let photoData = [];\n\n //make AJAX call (https://reactjs.org/docs/faq-ajax.html)\n fetch(flickrPhotosRequest)\n .then(res => res.json())\n .then(\n (result) => {\n result.photos.photo.forEach(photo => {\n let farmId = photo.farm;\n let serverId = photo.server;\n let secret = photo.secret;\n let size = 'q';\n let photoId = photo.id;\n let ownername = photo.ownername;\n\n /*\n Construct the source URL to a photo => Source: https://www.flickr.com/services/api/misc.urls.html\n */\n let url = 'https://farm'+ farmId + '.staticflickr.com/'+\n serverId +'/'+ photoId + '_'+ secret + '_'+ size + '.jpg';\n\n photoData.push({url: url, ownerName: ownername});\n });\n place.photos = photoData;\n this.setState({placeSelected: place, error: ''});\n },\n\n /*\n If there's an error on Ajax call, set the error message\n */ \n (error) => {\n this.setState({error: {message: 'Sorry, the Flickr search API is not currently available!'}})\n }\n );\n }", "title": "" }, { "docid": "98475ddaea85bf52f1e0c1ea31423a76", "score": "0.6254883", "text": "function fetchApi() {\n fetch(\"https://jsonplaceholder.typicode.com/photos/?_limit=5\") // \"/?_limit=5\" limits the data to 5 objects, BUT it is unique to this API provider\n .then((response) => response.json())\n .then((data) => {\n console.log(data);\n let userCard = \"<h2>Images API response </h2>\";\n data.forEach((img) => {\n let { albumId, id, title, url, thumbnailUrl } = img;\n userCard += `\n <div id=${id}>\n <img src=${thumbnailUrl} >\n <h3>${title}</h3>\n <img src=${url} alt=${title}>\n </div>\n `;\n });\n document.querySelector(\".result\").innerHTML = userCard;\n // userCard = document.querySelector(\".result\").innerHTML;\n })\n .catch((err) => console.log(err));\n}", "title": "" }, { "docid": "7ac4d4dc4c756027876f2c491339343d", "score": "0.6247804", "text": "getPhotos (user_id) {\n const types = ['wall', 'profile']\n const typeToSearch = types[Math.floor(Math.random() * types.length)]\n\n return new Promise ((resolve, reject) => {\n if (!user_id) return reject('No user id provided')\n this.vk.call('photos.get', {\n owner_id: user_id,\n album_id: typeToSearch,\n extended: 1,\n rev: 1\n }).then(res => {\n const { count , items } = res\n if (count === 0) {\n return reject()\n }\n\n console.log(res)\n\n items.forEach((item, index, array) => {\n array[index] = item.id\n })\n return resolve(res)\n })\n .catch(e => {\n new ErrorResolver({\n error: e,\n object: user_id\n })\n return reject(e)\n })\n })\n }", "title": "" }, { "docid": "6f56feaf40738d8abd17b84b09438e6f", "score": "0.6234737", "text": "function get_images(query) {\n $.getJSON('https://api.flickr.com/services/rest/?method=flickr.photos.search'\n + '&api_key=' + FLICKR_API_KEY\n + '&tags=' + query\n + '&safe_search=1'\n + '&per_page=100'\n + '&format=json'\n + '&extras=url_q'\n + '&jsoncallback=?',\n function(response) {\n // Move the search form to the top of the page by adding a class called 'sticky'\n if (!$('#search').hasClass('sticky')) {\n $('#search').addClass('sticky');\n }\n\n // Clear the image container (just in case there were other images in it from previous searches)\n clear_image_container();\n\n var images = response.photos.photo;\n for (var i = 0; i < images.length; i++) {\n var image = images[i];\n add_image_to_image_container(image);\n }\n });\n}", "title": "" }, { "docid": "9997e45bc7e953c7abcb717a3b444098", "score": "0.62265474", "text": "fetchPhotosInstantly(page = 1) {\n const input = document.getElementById(\"input\");\n\n if(input.value.length === 0)\n {\n this.setState(\n {\n pictures:[]\n }\n )\n }\n if(input.value.length !== 0)\n {\n \n this.setState({ pictures: [] });\n this.pictures = []\n fetch(URL + SECRET + \"&tags=\" + input.value + \"&page=\" + page + QUERY)\n .then(response => response.json())\n .then(j => this.createImageArray(j));\n }\n \n \n }", "title": "" }, { "docid": "e36655c9dac6c12681b07a72b96e77c4", "score": "0.6216174", "text": "function resolvePhotoUrls(photos) {\n \tvar photoUrls = photos.photo.map(function(photo) {\n var farm = photo.farm;\n var id = photo.id;\n var secret = photo.secret;\n var server = photo.server;\n\n return {\n \turl: 'https://farm' + farm + '.staticflickr.com/' + server + '/' + id + '_' + secret + '.jpg',\n id: id\n };\n });\n\n return photoUrls;\n }", "title": "" }, { "docid": "019affac669a439f738a6f4213de3a5d", "score": "0.6214499", "text": "function getFlickrPhotos() {\n $.ajax({\n dataType: 'json',\n url: 'https://api.flickr.com/services/rest/?method=flickr.photos.search&name=value&api_key=8f85fae7b30b1d0fa402c01a4972c763&format=json&nojsoncallback=1&text=Patagonia,Argentina&content_type=1&safe_search=1&tags=Argentina,Patagonia',\n method: 'get',\n success: function(response){\n var responseObj = response.photos;\n for(var i = 0; i < 12; i++) {\n var farmId = responseObj.photo[i].farm;\n var photoId = responseObj.photo[i].id;\n var serverId = responseObj.photo[i].server;\n var secret = responseObj.photo[i].secret;\n var $img = $('<img>');\n $img.attr('src','https://farm'+ farmId + '.staticflickr.com/'+ serverId + '/' + photoId + '_' + secret + '.jpg');\n console.log($img);\n $img.appendTo($galleryContainer);\n }\n },\n error: function(response) {\n var $galleryContainer = $('#gallery-container');\n var $noPhotos = $('<p>').text('Unfortunately, we are experiencing technical difficulties. Please try again' +\n ' later.');\n $galleryContainer.append($noPhotos);\n }\n });\n}", "title": "" }, { "docid": "a7d234116fbc29a9d164d253f61561a0", "score": "0.6205669", "text": "function getPicture() {\n const params = {\n api_key: 'IptJpzC6QdzZTggB5pgKm6BLb4B8b8mjoHktBJgf'\n };\n const queryString = formatQueryParams(params);\n const url = apodUrl + '?' + queryString;\n fetch(url)\n .then((response) => {\n if (response.ok) {\n return response.json();\n }\n throw new Error(response.statusText);\n })\n .then((responseJson) => {\n displayPicture(responseJson)\n })\n .catch((err) => {\n $('#js-error-message').text(`Something went wrong: ${err.message}`);\n });\n}", "title": "" }, { "docid": "b38f5839891a04f1a2f55f89dfa91c7c", "score": "0.61883235", "text": "fetchPhotosOnScroll(page) {\n const input = document.getElementById(\"input\");\n fetch(URL + SECRET + \"&tags=\" + input.value + \"&page=\" + page + QUERY)\n .then(response => response.json())\n .then(j => this.createImageArray(j));\n\n }", "title": "" }, { "docid": "341a85ef5ad44a6535e3c5b301c7b8b6", "score": "0.6172372", "text": "function getImages() {\n apiurl = \"https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=1606c88155db3961eabe6a2b653d8b41&per_page=\" + perPage + \"&content_type=\" + contentType + \"&text=\" + searchText + \"&tags=\" + searchTags + \"&is_commons&extras&safe_search=\" + safeSearchLevel + \"&format=json&nojsoncallback=1\";\n $.getJSON(apiurl, function(json) {\n rawData = json;\n console.log(json);\n document.getElementById(\"content\").innerHTML = \"\";\n for (var i = 0; i < 10; i++) {\n console.log(i);\n photoItem = json.photos.photo[i]\n photoURL = \"https://farm\" + photoItem.farm + \".staticflickr.com/\" + photoItem.server + \"/\" + photoItem.id + \"_\" + photoItem.secret + \"_h.jpg\";\n document.getElementById(\"content\").innerHTML += \"<p><a href='\" + photoURL + \"' target='_blank'><img src='\" + photoURL + \"' width='100%' height='auto' /></a><br /><a href='https://www.flickr.com/photos/\" + photoItem.owner + \"/\" + photoItem.id + \"' target='_blank'>(source)</a></p>\";\n }\n });\n}", "title": "" }, { "docid": "78b97e558436ebd1bc9102876dae67b4", "score": "0.6168919", "text": "function jsonFlickrApi(rsp) {\n var imagesLoaded = 0,\n totalImages = rsp.photos.photo.length;\n window.rsp = rsp;\n\n // Photo source URLs: https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}_[mstzb].jpg\n for (var i=0; i < rsp.photos.photo.length; i++) {\n // Current picture\n pic = rsp.photos.photo[i];\n\n // URLs for displaying large square thumbnails and big size pictures\n t_url = \"http://farm\"+pic.farm+\".static.flickr.com/\"+pic.server+\"/\"+pic.id+\"_\"+pic.secret+\"_\"+\"q.jpg\";\n b_url = \"http://farm\"+pic.farm+\".static.flickr.com/\"+pic.server+\"/\"+pic.id+\"_\"+pic.secret+\"_\"+\"b.jpg\";\n\n // Create and set attributes to elements\n var link = document.createElement(\"a\");\n link.setAttribute('class', \"image-link hide\");\n\n var img = document.createElement(\"img\");\n img.setAttribute('src', t_url);\n img.setAttribute('alt', pic.title);\n img.setAttribute('data-b-src', b_url); // link to big size image\n img.setAttribute('class', \"thumbnail\");\n\n // Open images in modal\n img.onclick = function() {\n bigSrc = this.getAttribute('data-b-src');\n alt = this.getAttribute('alt');\n initModal(bigSrc, alt);\n }\n // When error occurs during loading, subtract 1 from totalImages\n img.onerror = function() {\n totalImages--;\n showImages(imagesLoaded, totalImages);\n }\n // When an image is loaded, add 1 to imagesLoaded\n img.onload = function() {\n imagesLoaded++;\n showImages(imagesLoaded, totalImages);\n }\n\n // Add img to image-link, append to gallery container (id=\"root\")\n link.appendChild(img);\n document.getElementById('root').appendChild(link);\n }\n}", "title": "" }, { "docid": "52f4374ae7607610cfcaefd10e66b749", "score": "0.61687243", "text": "getPictures() {\n flickrService(this.state).then((responsePhotoObject) => {\n if (!responsePhotoObject) return\n const photosWithURLS = responsePhotoObject.photos.photo.map((photoObj) => {\n photoObj.photoURL = this.constructImageURL(photoObj, \"c\")\n return photoObj\n })\n this.setState({\n photos: photosWithURLS,\n total: responsePhotoObject.photos.total,\n currentNumber: 0,\n isPhotoButtonDisabled: true\n })\n })\n setTimeout(() => this.setState({ isPhotoButtonDisabled: false }), 10000);\n }", "title": "" }, { "docid": "64aef71ef04b197d9cbbe6f65c670f32", "score": "0.6166496", "text": "function getImages(query) {\n\t\t$(\"#gallery li\").fadeOut('slow').empty();\n\t\tvar key = \"0021bb748b9d7a9088b17356d94f6ded\";\n\t\t$.ajax({\n\t\t\turl: \"https://api.flickr.com/services/rest/\",\n\t\t\tdata: {\n\t\t\t\tmethod: \"flickr.photos.search\",\n\t\t\t\tapi_key: key,\n\t\t\t\ttag_mode: \"all\",\n\t\t\t\ttext: \"illustration \"+query,\n\t\t\t\tsort: \"relevance\",\n\t\t\t\tformat: \"json\",\n\t\t\t\tper_page: 20,\n\t\t\t\tpages: 1,\n\t\t\t\tnojsoncallback: 1\n\t\t\t},\n\t\t\tcrossDomain: true,\n\t\t\tsuccess: function(response) {\n\t\t\t\tvar photos = response.photos.photo;\n\t\t\t\tconsole.log('CLIENT getting photos from flickr');\n\t\t\t\tfor (var i = 0; i < photos.length; i++) {\n\t\t\t\t\tvar p = photos[i];\n\t\t\t\t\tvar farm = p.farm;\n\t\t\t\t\tvar server = p.server;\n\t\t\t\t\tvar id = p.id;\n\t\t\t\t\tvar secret = p.secret;\n\t\t\t\t\tvar picture = \"http://farm\"+farm+\".static.flickr.com/\"+server+\"/\"+id+\"_\"+secret+\"_q.jpg\";\n\t\t\t\t\t$(\"#gallery ul\").append(\"<li><a><img src='\"+picture+\"'/><p class='caption'>I choose you!</p></a></li>\").fadeIn();\n\t\t\t\t\t// $('#gallery li').addClass('choose-cover');\n\t\t\t\t\t$('#gallery a').addClass('flickr-image');\n\t\t\t\t\t$('#gallery img').addClass('flickr');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t$(\"#flickr-form input[name=search]\").val('');\n\t\treturn false;\n\t}", "title": "" }, { "docid": "297c651fb129e3f89b6402e5b6b42ba2", "score": "0.6155545", "text": "function getAlbumImagesData(data) {\n return $.ajax({\n 'url': self._apiUrl,\n type: 'get',\n dataType: 'jsonp',\n data: data\n });\n }", "title": "" }, { "docid": "f57876d835abb9ee774eb6fc46446ac3", "score": "0.6150464", "text": "function findPhotos( ){\r\n \r\n for (var i in albumId)\r\n {\r\n \r\n fetch(\"https://jsonplaceholder.typicode.com/photos?albumId=\"+albumId[i]).then(function(response){\r\n return response.json();\r\n }).then(function(myJson){\r\n // console.log(myJson);\r\n for(var j in myJson)\r\n {\r\n \r\n\t if(myJson[j].id !== null && myJson[j].url !== null)\r\n\t {\r\n\t \t//storing the photos of respective user in a array\r\n\t\t\tphotoId.push(myJson[j].id);\t\t\t\r\n\t\t\tphotoURL.push(myJson[j].url);\r\n\t\t\t\r\n\t\t}\r\n\t \r\n\t}\r\n \r\n })\r\n \r\n }\r\n \t//prints the photoId and PhotoUrl to the console \r\n \tconsole.log(\"*****All the associated photograph links of: \"+userI+\"******\");\r\n \tconsole.log(photoURL);\r\n \t//console.log(photoId);\r\n \t\r\n }", "title": "" }, { "docid": "c2e31a71dcc96bcc96768e3ff210893c", "score": "0.6148553", "text": "function getPhotos(position) {\n var lat = position.coords.latitude;\n var long = position.coords.longitude;\n var radius = '10mi';\n var searchOptions = {\n geo: lat + ',' + long + ',' + radius,\n only: 'Landscapes',\n sort: 'rating',\n rpp: 28\n };\n\n // Ask 500px for photos and check if we got any back\n _500px.api('/photos/search', searchOptions, function(response) {\n if (response.data.photos.length === 0) {\n // no results\n console.log(\"No photos found.\");\n } else {\n console.log(\"I found photos!\");\n handePhotoArray(response.data.photos);\n };\n });\n }", "title": "" }, { "docid": "6676f9928844a6596080b3b9bd87cb2e", "score": "0.6143792", "text": "function fetchingImages() {\n\tfetch(IMAGES_URL)\n\t\t.then((response) => {\n\t\t\treturn response.json();\n\t\t})\n\t\t.then((json) => {\n\t\t\tIMAGES = json;\n\t\t\trenderImages(json);\n\t\t});\n}", "title": "" }, { "docid": "6e3bb37d21572145ed07cb9ad949fe65", "score": "0.61313146", "text": "function jsonFlickrApi(res){\n\tvar photosLength = res.photos.photo.length;\n\tvar photos = res.photos.photo;\n\n\tdocument.getElementById(\"images-container\").innerHTML = '';\n\tdocument.getElementById(\"modal-windows\").innerHTML = '';\n\n\tvar view = new View();\n\tvar searchResults = {};\n\n\tsearchResults.key = \"search-results\";\n\tsearchResults.images = [];\n\n\tfor(var i=0; i<photosLength; i++){\n\t\tvar img = new Img(photos[i].id, photos[i].farm, photos[i].server, photos[i].secret);\n\t\timg.createImgUrl(\"s\");\n\t\timg.createImgUrl(\"q\");\n\t\timg.createImgUrl(\"b\");\n\n\t\tsearchResults.images.push(img);\n\t\tsessionStorage.setItem(searchResults.key, JSON.stringify(searchResults));\n\t}\n\tview.loadSearchResults();\n}", "title": "" }, { "docid": "0090fdcc136ad74be9a58c0413eca5cd", "score": "0.612852", "text": "function getPhotoURL(photos){ \n if(photos){\n return photos[0].getUrl({'maxWidth': 800, 'maxHeight': 150}); \n }\n}", "title": "" } ]
c1dc161b2650fba31ed017f6ad6cefde
return a public interface
[ { "docid": "17c66b8d8fc6b4fae45bd6befc30e3d4", "score": "0.0", "text": "function procWait(show){\r\n \tvar uploadWait = document.getElementById(\"uploadWait\");\r\n \tvar contextFile = document.getElementById(\"contextFile\");\r\n \tcontextFile.style.display = show?\"none\":\"block\";\r\n\t\tuploadWait.style.display = show?\"block\":\"none\";\r\n\t\t\r\n\t\t//启动监听 upload.js\r\n\t\tstartProgress();\r\n\t\t\r\n\t\tif(!show){\r\n \tdocument.getElementById(\"fjName\").value = \"\";\r\n \tdocument.getElementById(\"fileDiv\").innerHTML = \"<input type=\\\"file\\\" name=\\\"uploadFile\\\" id=\\\"uploadFile\\\" style=\\\"height:20px\\\" size=\\\"30\\\" onKeyDown=\\\"return false;\\\" onpaste=\\\"return false;\\\"/>\";\r\n \tdocument.getElementById(\"fjDiscription\").value = \"\";\r\n\t\t}\r\n }", "title": "" } ]
[ { "docid": "8a3c688468e9cb872e03c315d4f0e8b1", "score": "0.65277594", "text": "getPublicInstance(inst) {\n throw new Error(\"getPublicInstance is not implemented\")\n }", "title": "" }, { "docid": "cf6998142157522e8b4bbb6d8f5549d1", "score": "0.6440389", "text": "function ThirdPartyInterface() {}", "title": "" }, { "docid": "0b15cfd47c2003259d0502a0ca374347", "score": "0.6413415", "text": "function createInterface(diy, editor) {}", "title": "" }, { "docid": "5c0f364dfe52c6ac950b842e91241829", "score": "0.6350725", "text": "getPublicInstance(inst) {\n return inst;\n }", "title": "" }, { "docid": "1b47de04009042521d5f327f8ef740e4", "score": "0.63273084", "text": "function interface_doc(){\n}", "title": "" }, { "docid": "e9ac42348b8ba8368622d818792096d8", "score": "0.6315811", "text": "function EndpointInterface() {}", "title": "" }, { "docid": "88f7fcc3cf15e3f3a8e5f6a49d6ba60d", "score": "0.61767846", "text": "function InterfaceThis() {\n this.a = 12;\n}", "title": "" }, { "docid": "192a14c6b0f464e8a504330efdb5541d", "score": "0.6121422", "text": "function Interface()\n{\n CGFinterface.call(this);\n}", "title": "" }, { "docid": "500e43702ed2570c694a9ff616281b04", "score": "0.6092161", "text": "function interfaceProvider() {\n\n var Interface = function(name, methods) {\n\n if (arguments.length != 2) {\n throw new Error(\"Interface constructor called with \" + arguments.length + \"arguments, but expected exactly 2.\");\n }\n\n if(typeof(arguments[0]) !== 'string')\n {\n throw new Error(\"Interface constructor expects first argument as String!\");\n }\n\n if(!(arguments[1] instanceof Array))\n {\n throw new Error(\"Interface constructor expects method arguments as Array!\");\n }\n\n this.name = name;\n this.methods = [];\n\n for (var i = 0, len = methods.length; i < len; i++) {\n if (typeof methods[i] !== 'string') {\n throw new Error(\"Interface constructor expects method names to be passed in as a string.\");\n }\n\n this.methods.push(methods[i]);\n }\n\n\n };\n\n // Static class method.\n Interface.ensureImplements = function(object) {\n if (arguments.length < 2) {\n throw new Error(\"Function Interface.ensureImplements called with \" + arguments.length + \"arguments, but expected at least 2.\");\n }\n\n for (var i = 1, len = arguments.length; i < len; i++) {\n var _interface = arguments[i];\n if (_interface.constructor !== Interface) {\n throw new Error(\"Function Interface.ensureImplements expects arguments two and above to be instances of Interface.\");\n }\n\n for (var j = 0, methodsLen = _interface.methods.length; j < methodsLen; j++) {\n var method = _interface.methods[j];\n if (!object[method] || typeof object[method] !== 'function') {\n throw new Error(\"Function Interface.ensureImplements: object does not implement the \" + _interface.name + \"_interfacee. Method \" + method + \" was not found.\");\n }\n }\n }\n };\n\n return {\n define : function (name, methods) { return new Interface(name, methods); },\n ensureImplements : Interface.ensureImplements\n };\n }", "title": "" }, { "docid": "b8ac7d2b40b68fd41a8464379ca4a9de", "score": "0.60664916", "text": "function gi(object,iface){\n\t\t\treturn object.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(iface)\n\t\t}", "title": "" }, { "docid": "186bccacd4f4cced42324845279d478d", "score": "0.6060978", "text": "function implementIDLInterface(o) {\n let name = o.name || \"\";\n let superclass = o.superclass;\n let constructor = o.init || function() {};\n let constants = o.constants || {};\n let members = o.members || {};\n let prototype, interfaceObject;\n\n // Set up the prototype object\n prototype = superclass ? O.create(superclass.prototype) : {};\n\n // The interface object is supposed to work with instanceof, but is \n // not supposed to be callable. We can't conform to both requirements\n // so we make the interface object a function that throws when called.\n interfaceObject = function() { \n throw new TypeError(name + \" is not (supposed to be) a function\");\n };\n\n // Retain references to the prototype and interface objects for internal use\n constructor.prototype = prototype;\n constructor.publicInterface = interfaceObject\n\n // WebIDL says that the interface object has this prototype property\n defineHiddenConstantProp(interfaceObject, \"prototype\", prototype);\n\n // WebIDL also says that the prototype points back to the interface object\n // instead of the real constructor.\n defineHiddenProp(prototype, \"constructor\", interfaceObject);\n\n // Constants must be defined on both the prototype and interface objects\n // And they must read-only and non-configurable\n for(let c in constants) {\n let value = constants[c];\n defineConstantProp(prototype, c, value);\n defineConstantProp(interfaceObject, c, value);\n }\n\n // Now copy attributes and methods onto the prototype object.\n // Members should just be an ordinary object. Attributes should be\n // defined with getters and setters. Methods should be regular properties.\n // This will mean that the members will all be enumerable, configurable\n // and writable (unless there is no setter) as they are supposed to be.\n for(let m in members) {\n // Get the property descriptor of the member\n let desc = O.getOwnPropertyDescriptor(members, m);\n\n // Now copy the property to the prototype object\n O.defineProperty(prototype, m, desc);\n }\n\n // If the interface does not already define a toString method, add one.\n // This will help to make debugging easier.\n // XXX: I'm not sure if this is legal according to WebIDL and DOM Core.\n if (!hasOwnProperty(members, \"toString\")) {\n prototype.toString = function() { return \"[object \" + name + \"]\"; };\n }\n\n // Finally, return the constructor\n // Note that this method does not export the interface object to\n // the global object. The caller should get the interface object (from the\n // interface property of the constructor) and export it appropriately.\n return constructor;\n}", "title": "" }, { "docid": "cb004cc1df3a5d689d437b1ee31318c8", "score": "0.59621286", "text": "get implementation() { return wrap(unwrap(this).implementation); }", "title": "" }, { "docid": "0d86a64972f7ef9bf16a9453695cefb1", "score": "0.592913", "text": "createInterface(nameConfigOrCallback, configuror) {\n const configure = typeof nameConfigOrCallback === \"function\" ? nameConfigOrCallback : configuror;\n const friendlyName = typeof nameConfigOrCallback === \"string\" ? nameConfigOrCallback : nameConfigOrCallback && \"friendlyName\" in nameConfigOrCallback ? nameConfigOrCallback.friendlyName || defaultFriendlyName : defaultFriendlyName;\n const respectConnection = typeof nameConfigOrCallback === \"string\" ? false : nameConfigOrCallback && \"respectConnection\" in nameConfigOrCallback ? nameConfigOrCallback.respectConnection || false : false;\n\n const Interface = function (target, property, index) {\n if (target == null || new.target !== undefined) {\n throw new Error(`No registration for interface: '${Interface.friendlyName}'`);\n }\n\n if (property) {\n DI.defineProperty(target, property, Interface, respectConnection);\n } else {\n const annotationParamtypes = DI.getOrCreateAnnotationParamTypes(target);\n annotationParamtypes[index] = Interface;\n }\n };\n\n Interface.$isInterface = true;\n Interface.friendlyName = friendlyName == null ? \"(anonymous)\" : friendlyName;\n\n if (configure != null) {\n Interface.register = function (container, key) {\n return configure(new ResolverBuilder(container, key !== null && key !== void 0 ? key : Interface));\n };\n }\n\n Interface.toString = function toString() {\n return `InterfaceSymbol<${Interface.friendlyName}>`;\n };\n\n return Interface;\n }", "title": "" }, { "docid": "c2a2d6e80f49eac3c0d798061612977c", "score": "0.5906173", "text": "buildInterface(object/*: Interface*/) { // eslint-disable-line no-unused-vars\n throw new TypeError('The `buildInterface` method should be overriden')\n }", "title": "" }, { "docid": "f4eee913d0252dd26a7d427e2a73cb59", "score": "0.5890869", "text": "function returnIface ( callback ) {\n return function () {\n callback.apply(this, arguments);\n return iface;\n };\n }", "title": "" }, { "docid": "f4eee913d0252dd26a7d427e2a73cb59", "score": "0.5890869", "text": "function returnIface ( callback ) {\n return function () {\n callback.apply(this, arguments);\n return iface;\n };\n }", "title": "" }, { "docid": "f4eee913d0252dd26a7d427e2a73cb59", "score": "0.5890869", "text": "function returnIface ( callback ) {\n return function () {\n callback.apply(this, arguments);\n return iface;\n };\n }", "title": "" }, { "docid": "0eb2f71721c396f7e0032806b1a5a1a0", "score": "0.57729775", "text": "function CCIN(cName, ifaceName)\r\n{\r\n return Cc[ cName].createInstance( Ci[ ifaceName]);\r\n}", "title": "" }, { "docid": "16bc9d01f5715a7813c3044902551d1a", "score": "0.5763491", "text": "function publicAPI() {\n // Call extend or Object.assign or use ...\n Object.assign(me, {\n getWidth: function () {\n return width;\n },\n\n getFieldParam: function () {\n return \"\";\n }\n });\n }", "title": "" }, { "docid": "f0628112ba27297c370642bef7691771", "score": "0.57599247", "text": "get interface_id() {\n return this._interface_id;\n }", "title": "" }, { "docid": "0a1df59ecead281be5277b7d0ae695d0", "score": "0.57476395", "text": "_parseInterfaceDeclaration(declaration: Object): InterfaceDefinition {\n const def: InterfaceDefinition = {\n kind: 'interface',\n name: declaration.id.name,\n location: this._locationOfNode(declaration),\n constructorArgs: null,\n staticMethods: new Map(),\n instanceMethods: new Map(),\n };\n\n invariant(declaration.body.type === 'ObjectTypeAnnotation');\n const properties = declaration.body.properties;\n for (const property of properties) {\n invariant(property.type === 'ObjectTypeProperty');\n\n if (!isPrivateMemberName(property.key.name)) {\n const {name, type} = this._parseInterfaceClassMethod(property);\n invariant(!property.static, 'static interface members are a parse error');\n this._validateMethod(property, name, type, false);\n this._defineMethod(name, type, def.instanceMethods);\n }\n }\n if (!def.instanceMethods.has('dispose')) {\n throw this._error(declaration, 'Remotable interfaces must include a dispose method');\n }\n return def;\n }", "title": "" }, { "docid": "13d56ca49e5f141f994a07b565add444", "score": "0.5712001", "text": "initImpl() {}", "title": "" }, { "docid": "b46324dba8bf56772bd14e492b67838a", "score": "0.5663762", "text": "interface() {\n if (this._interface != null) {\n return this._interface;\n }\n return this._interface = readline.createInterface(this.settings.stdin, this.settings.stdout);\n }", "title": "" }, { "docid": "d3b05c8bffce662bbea4e2c1a20a9aa2", "score": "0.56589913", "text": "function OpenInterface(pkg, meta, that) {\n $init$OpenInterface();\n if (that===undefined)that=new OpenInterface.$$;\n that._pkg = pkg;\n var _mm=meta.$$metamodel$$;\n if (_mm === undefined) {\n //it's a metamodel\n that.meta=meta;\n that.tipo=_findTypeFromModel(pkg,meta);\n _mm = that.tipo.$$metamodel$$;\n if (typeof(_mm)==='function') {\n _mm=_mm();\n that.tipo.$$metamodel$$=_mm;\n }\n } else {\n //it's a type\n that.tipo = meta;\n if (typeof(_mm)==='function') {\n _mm=_mm();\n meta.$$metamodel$$=_mm;\n }\n that.meta = get_model(_mm);\n }\n that.name_=_mm.d[_mm.d.length-1];\n that.toplevel_=_mm.$cont === undefined;\n InterfaceDeclaration$meta$declaration(that);\n return that;\n}", "title": "" }, { "docid": "19c42abe3fa79d056fcd8a914492bad6", "score": "0.5643198", "text": "function MyInterface() {\n //call CGFinterface constructor\n CGFinterface.call(this);\n}", "title": "" }, { "docid": "7b39cb90c4cd9c37088af555a5554280", "score": "0.56033784", "text": "getInterfaceLanguage() {\n return interfaceLanguage;\n }", "title": "" }, { "docid": "1e59e11101113904815e68b4b0172994", "score": "0.5563011", "text": "readPublicAPIs(classtypes, isinterface) {\n if (!classtypes) {\n return;\n }\n let publicClasses = {};//{apis:{}, methods: {}, events:{}};\n //filtering and retrieving public APIs from each module\n for (let classtype of classtypes) {\n if (classtype && classtype.children && classtype.name) {\n publicClasses[classtype.name] = this.readClassAPIs(classtype, isinterface);\n }\n }\n return publicClasses;\n }", "title": "" }, { "docid": "0b24688c1a0b490af6b787542c580353", "score": "0.5559396", "text": "function document_elementInterface(name, namespace) {\n return ElementImpl_1.ElementImpl;\n}", "title": "" }, { "docid": "e7aacea65dee768537e592b9b0d2f670", "score": "0.55536354", "text": "function toInterface(V, I) {\n //If Type(V) is not Object, then throw a TypeError.\n if (ECMAScript.Type(V !== 'Object')) {\n throw new TypeError();\n }\n //If V is a platform object that implements I, then return the IDL interface type value that represents a reference to that platform object.\n if (classType(V) === 'platform object') {}\n //If V is a user object that is considered to implement I according to the rules in section 4.7, then return the IDL interface type value that represents a reference to that user object.\n //Throw a TypeError.\n //The result of converting an IDL interface type value to an ECMAScript value is the Object value that represents a reference to the same object that the IDL interface type value represents.\n }", "title": "" }, { "docid": "b42494e9780666fe6e51defdab4a36d0", "score": "0.5547606", "text": "function userInterface(){\n var self = this;\n}", "title": "" }, { "docid": "0df744a573cd73938c372d3463208f84", "score": "0.5504689", "text": "async getPublicObject() {\n const html = this.status === 'PUBLIC' ? (await this.parseRender()).html : null;\n return {\n id: this.id,\n status: this.status,\n authorName: this.author ? this.author.username : null,\n ipAddress: this.author ? null : this.ipAddress,\n html,\n createdAt: this.createdAt,\n updatedAt: this.updatedAt,\n hiderName: this.hider ? this.hider.username : null,\n };\n }", "title": "" }, { "docid": "60eb21a9d2c530135f3a0b6ad66a59b9", "score": "0.54847074", "text": "function Ic(){}", "title": "" }, { "docid": "d49ef8acebbe16280d5b294ee29c3f2a", "score": "0.54786104", "text": "function getInterfaceType() {\n\treturn window.interfaceType;\n}", "title": "" }, { "docid": "6f762c4165d5e7711901c39922b46a3a", "score": "0.5458533", "text": "function createSpecificationInterface() {\n return createSpecificationSimple();\n //return createSpecificationComplex();\n // return createSpecificationWritten();\n\t// return strToDOM(yourInterfaceHTML);\n}", "title": "" }, { "docid": "b79fc5ec723329a5209a559bd86062f6", "score": "0.5448432", "text": "function InterfaceController()\n{\n this.prototype = new Element();\n this.id = createElement(\"InterfaceController\");\n \n this.setCallback = function( callback /* str */)\n {\n return setInterfaceCallback( callback );\n };\n \n this.addGPIO = function( pin , mode)\n {\n return perform(\"addGPIO\" , this.id , [ pin , mode ]);\n };\n \n this.writeGPIO = function( pin , value )\n {\n return perform(\"writeGPIO\" , this.id , [ pin , value ]);\n };\n this.listenKeyboard = function()\n {\n return perform(\"listenKeyboard\" , this.id , 0);\n };\n\n \n \n}", "title": "" }, { "docid": "db0c17ad5d85a3e9399d18add1ed0b82", "score": "0.5418228", "text": "get public() {\n return new Libp2pCryptoPublicKey(this.key.public);\n }", "title": "" }, { "docid": "e48d3fed93ce5fe2bb23f1842387b89d", "score": "0.54138124", "text": "function selfImplement() {\n //implement thyself.\n var idl = 'interface WebIDL : ECMAScript {' +\n ' stringifier DOMString wee();' +\n ' static void test(string WebIDL, object object);' +\n ' static object implement(string WebIDL);' +\n '};';\n hooks = implement(WebIDLParser.parse(idl));\n }", "title": "" }, { "docid": "8c73b0663962fafa8b34751101e6e4fa", "score": "0.5402711", "text": "function package(protected) { // !!!\n 'use strict';\n var implements; // !!!\n\n interface: // !!!\n while (true) {\n break interface; // !!!\n }\n\n function private() { } // !!!\n}", "title": "" }, { "docid": "533ed48d896956b4fba91a6b9535a83d", "score": "0.53847736", "text": "function CreateIDEObjectType()\r\n{\r\n\treturn new IDEObjectType();\r\n}", "title": "" }, { "docid": "533ed48d896956b4fba91a6b9535a83d", "score": "0.53847736", "text": "function CreateIDEObjectType()\r\n{\r\n\treturn new IDEObjectType();\r\n}", "title": "" }, { "docid": "533ed48d896956b4fba91a6b9535a83d", "score": "0.53847736", "text": "function CreateIDEObjectType()\r\n{\r\n\treturn new IDEObjectType();\r\n}", "title": "" }, { "docid": "8ec04b23191f68b4d55ebc51aa1ea47f", "score": "0.5373968", "text": "addInterface(iface) {\n // late binding and avoid cyclic, aka, weak \n Object.defineProperty(iface, 'dobj', { get: () => this })\n Object.defineProperty(iface, 'dbus', { get: () => this.dbus })\n this.ifaces.push(iface)\n return this\n }", "title": "" }, { "docid": "6d9ad5b7ef0ea4003d37814e675494e5", "score": "0.53723836", "text": "swim() {\n MxI.$raiseNotImplementedError(IFish, this);\n }", "title": "" }, { "docid": "0b2066dd546c1612f79f85d5dc93d8a5", "score": "0.5331356", "text": "function Ih(a){this.o=a}", "title": "" }, { "docid": "32b255461ff2364d70d4aafac278f7f0", "score": "0.5325098", "text": "get public() {\n return new PublicKey(this.pubKey);\n }", "title": "" }, { "docid": "12cbf3696b55a914f7c8f3911c261d17", "score": "0.52997124", "text": "function Factory() {}", "title": "" }, { "docid": "d3bd474b4831812c6700a2296daf1cec", "score": "0.5243532", "text": "function initInterface()\r\n\t{\r\n\t\tapp.loadInterface(\"InterfaceLogin\");\r\n\t}", "title": "" }, { "docid": "ed481de415c607e89ffee57b3984897b", "score": "0.52331585", "text": "init() {\n throw new TypeError('not implemented');\n }", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "2e8d085083f6cda9e59658afef2c032e", "score": "0.5227724", "text": "function CreateIDEObjectType()\n{\n\treturn new IDEObjectType();\n}", "title": "" }, { "docid": "159f28db391aa4605dc223cc9273437a", "score": "0.52098775", "text": "getPublicInstance(instance) {\n log('getPublicInstance');\n if (instance == null) {\n return null;\n }\n console.log(instance)\n return instance != null && instance.props.toJSON(instance);\n }", "title": "" }, { "docid": "48d5bae87e6d696a381dce142f80df60", "score": "0.5197432", "text": "toString(){\n\t\treturn 'not implemented';\n\t}", "title": "" }, { "docid": "8a9bb3c01edfc2541dad786ec2c7fd51", "score": "0.51689905", "text": "function Abstract () {\n}", "title": "" }, { "docid": "7b5b56feedbdea0e818fdc98ffaf3c46", "score": "0.51557994", "text": "function CreateIDEObjectType() {\n return new IDEObjectType();\n}", "title": "" }, { "docid": "72b6b3a981208dffee0e1bb63c61d15c", "score": "0.51490325", "text": "function proxyWrapperFromInterface(interfaceInfo){\n return function(bus, name, object, asyncCallback, cancellable) {\n var obj = new Gio.DBusProxy({ g_connection: bus,\n g_interface_name: interfaceInfo.name,\n g_interface_info: interfaceInfo,\n g_name: \"org.usbguard\",\n g_object_path: object });\n if (!cancellable)\n cancellable = null;\n if (asyncCallback)\n obj.init_async(GLib.PRIORITY_DEFAULT, cancellable, function(initable, result) {\n let caughtErrorWhenInitting = null;\n try {\n initable.init_finish(result);\n } catch(e) {\n caughtErrorWhenInitting = e;\n }\n\n if (caughtErrorWhenInitting === null) {\n asyncCallback(initable, null);\n } else {\n asyncCallback(null, caughtErrorWhenInitting);\n }\n });\n else\n obj.init(cancellable);\n return obj;\n };\n}", "title": "" }, { "docid": "a3cad2c9cb7c0b9ae5c2b199aab97141", "score": "0.51357096", "text": "function __serverInterface__init__() {\n logDebug(\"builtin package 'serverInterface' loaded\");\n}", "title": "" }, { "docid": "29f687ae42b3c4159ee6e9961403b538", "score": "0.51287323", "text": "function CCIN(cName, ifaceName) {\n return Cc[cName].createInstance(Ci[ifaceName]);\n}", "title": "" }, { "docid": "9d81fbdc03db3322420562b1ccac8a4c", "score": "0.51253", "text": "getInterfacePort() {\n return this.interfacePort;\n }", "title": "" }, { "docid": "9f7184a9564f752a62c07d29e7658258", "score": "0.5123591", "text": "function NXObject() {}", "title": "" }, { "docid": "ae5ec575f0d81dc9d8a11e4e1ada94ed", "score": "0.511236", "text": "_parseClassDeclaration(declaration: Object): InterfaceDefinition {\n if (this._fileType === 'import') {\n throw this._error(declaration, 'Exported class in imported RPC file');\n }\n\n const def: InterfaceDefinition = {\n kind: 'interface',\n name: declaration.id.name,\n location: this._locationOfNode(declaration),\n constructorArgs: [],\n staticMethods: new Map(),\n instanceMethods: new Map(),\n };\n\n const classBody = declaration.body;\n for (const method of classBody.body) {\n if (method.kind === 'constructor') {\n def.constructorArgs = method.params.map(param => this._parseParameter(param));\n if (method.returnType) {\n throw this._error(method, 'constructors may not have return types');\n }\n } else {\n if (!isPrivateMemberName(method.key.name)) {\n const {name, type} = this._parseClassMethod(method);\n const isStatic = Boolean(method.static);\n this._validateMethod(method, name, type, isStatic);\n this._defineMethod(name, type, isStatic ? def.staticMethods : def.instanceMethods);\n }\n }\n }\n if (!def.instanceMethods.has('dispose')) {\n throw this._error(declaration, 'Remotable interfaces must include a dispose method');\n }\n return def;\n }", "title": "" }, { "docid": "3c5b7f7ea4a355a3b318db8a030022d7", "score": "0.51029456", "text": "init() {\n\t\t// Could be implemented\n\t}", "title": "" }, { "docid": "6f2c2bf94ac87469a7bab5e403031c76", "score": "0.50988543", "text": "getAshar(){\n throw new Error('Should be implemented');\n }", "title": "" }, { "docid": "842f0d53cae033345fd52d8a31266374", "score": "0.50979793", "text": "publicMethod() {\n console.log('The public can see me!');\n }", "title": "" }, { "docid": "5d3509c0350743e184f616d9959d388e", "score": "0.5091942", "text": "function generateInterfaceHeader (state, name, cast) {\n\n\tvar obj = resolveType(state, name);\n\n\t// de-dup them\n\tvar externs = _.uniq(state.externs[obj.type]||[]).sort(),\n\t\timports = _.uniq(state.imports[obj.type]||[]).sort(),\n\t\tincludes = _.uniq(state.includes[obj.type]||[]).sort(),\n\t\ttypedefs = _.uniq(state.typedefs[obj.type]||[]).sort();\n\n\tname = obj.mangledName;\n\n\tsortOutSystemFrameworks(state,imports,includes);\n\n\treturn ejs.render(header_template, {\n\t\tname: name,\n\t\tentry: obj.object || {},\n\t\tstate: state,\n\t\tobject: obj,\n\t\texterns: externs,\n\t\timports: imports,\n\t\t_includes: includes,\n\t\ttypedefs: typedefs,\n\t\textra_includes: (obj.object && obj.object.extra_includes) || [],\n\t\tcast: cast,\n\t\tclassprefix: state.classprefix\n\t});\n}", "title": "" }, { "docid": "1bd5369c9192e313f7170e1542388ba1", "score": "0.5080462", "text": "function fromProtocol() {}", "title": "" }, { "docid": "4f15ffdc9c8ea8ea17e4d12309c57d9e", "score": "0.507687", "text": "get onIOPub() {\n return this._iopub;\n }", "title": "" }, { "docid": "66716aeeeede61a6e881f1866a96521a", "score": "0.50590205", "text": "getSubuh(){\n throw new Error('Should be implemented');\n }", "title": "" }, { "docid": "168eafc74a0bfb0b7ea6b508540243a9", "score": "0.5042436", "text": "function create_document() {\n return new DocumentImpl_1.DocumentImpl();\n}", "title": "" }, { "docid": "28d9467815a1822d4752f64ef4d42e02", "score": "0.5041827", "text": "_default() {\n return {\n insight() {\n statistics.sendSubGenEvent('generator', 'service-dotnet', { interface: this.useInterface });\n }\n };\n }", "title": "" }, { "docid": "571570324d2d17cfca0fe2cdc53a8ec2", "score": "0.5038494", "text": "function oi(){var e=this;Ve()(this,{$interaction:{enumerable:!0,get:function(){return e.$olObject}},$map:{enumerable:!0,get:function(){return e.$services&&Tt()(e.$services)}},$view:{enumerable:!0,get:function(){return e.$services&&e.$services.view}},$interactionsContainer:{enumerable:!0,get:function(){return e.$services&&e.$services.interactionsContainer}}})}", "title": "" }, { "docid": "c63bf851c3dfb6ba423749481bfb6893", "score": "0.5036212", "text": "function InterfaceDeclaration(node, print) {\n this.push(\"interface \");\n this._interfaceish(node, print);\n}", "title": "" }, { "docid": "54b354cf2f91e85e1e20ab27a32c3f51", "score": "0.50088334", "text": "function initInterface(){\r\n\t// graphicalManager tendrá las funciones directamente\r\n\twebinosMgr = new webinosManager();\r\n\tserverMgr = new serverManager();\r\n\tdataMgr = new dataManager();\r\n}", "title": "" }, { "docid": "a12bfcf7386f8648d9fa3bdca8db6dcc", "score": "0.50047046", "text": "function nonInterfaceDemo(person) {\n console.log(person.firstName + \" \" + person.lastName);\n}", "title": "" }, { "docid": "36f009146f17afdf3ac20daa704022fa", "score": "0.4997784", "text": "function Publication2(title, author, pubDate) {\n var publicAPI = {\n print() {\n console.log(`\n Title: ${title}\n By: ${author}\n ${pubDate}\n `);\n },\n };\n return publicAPI;\n}", "title": "" }, { "docid": "800a528942e6f2d991353db15021657a", "score": "0.49946868", "text": "get public() {\n return this.getBooleanAttribute('public');\n }", "title": "" }, { "docid": "5c8fd2f5bacd5e03c0e7f21c8ea55b18", "score": "0.49936745", "text": "notImplemented () {\n throw new Error('Not Implemented')\n }", "title": "" }, { "docid": "bc59675e062db80bbc83dfeefc19b505", "score": "0.49905464", "text": "get isMapPublic() {\n return this.i.isMapPublic;\n }", "title": "" }, { "docid": "e12f7833f396e98bb1179b774ccf4156", "score": "0.4986486", "text": "getIsya(){\n throw new Error('Should be implemented');\n }", "title": "" }, { "docid": "f665f2140c81dad3bc419065cc6129f4", "score": "0.49861598", "text": "function CreateInterface(interface_skeleton){\n createLayerLoadMenu(interface_skeleton);\n createChartsControlMenu(interface_skeleton);\n createBottomBarButton();\n createLegend();\n}", "title": "" }, { "docid": "83ee52141f7da1f1f2e43b4f95bc5576", "score": "0.49844828", "text": "function getDefinedInterface(uid, sensor) {\n if (sensor && typeof(uid) !== 'undefined') {\n connection = sensor.connections.find(c => c.interfaceUid === uid);\n return connection;\n }\n}", "title": "" } ]
75b704841fe81bf9de679680bcbbe0aa
bind() can also be used with something called as "currying" currying can be used to evaluate function with multiple arguments into sequence of functions with single argument let's see an example let's say we have a simple function which adds two numbers
[ { "docid": "74eee93645b6b0870df9870c9a9e5b1d", "score": "0.0", "text": "function add(a, b){\n return a + b\n}", "title": "" } ]
[ { "docid": "cc295ea1f202e1e444035693851f7a71", "score": "0.73474395", "text": "function bind$1(func,context){return function(){return func.apply(context,arguments);};}", "title": "" }, { "docid": "be0efd0dbe10a7ece2c956a9139de967", "score": "0.72278905", "text": "function simpleBind(context,fn){return function(value){fn.call(context,value);};}", "title": "" }, { "docid": "622acfc4df672c9375f5234df8531cf6", "score": "0.7196584", "text": "function bind(fun) {\n return applyBind(fun, slice(arguments, 1));\n}", "title": "" }, { "docid": "6c8c04c08666b7b566eb081ffed9e596", "score": "0.71879363", "text": "function myBind(func, context, ...firstArgs) {\n return function(...secondArgs) {\n func.apply(context, [...firstArgs, ...secondArgs]);\n };\n // return (...args) => func.apply(context, args);\n}", "title": "" }, { "docid": "9cbccbc5207ce7faab588da60d8688a0", "score": "0.7046205", "text": "function curry(fn) {\n return function(a) {\n return function(b) {\n return fn(a,b);\n }\n }\n}", "title": "" }, { "docid": "e7ef140a6c3137615e581a5ed2f47902", "score": "0.70370626", "text": "function curry(funct, num1){\n return function(num2){\n return funct(num1, num2);\n };\n}", "title": "" }, { "docid": "944a136c62c4d5c8c513d73c72fac920", "score": "0.70298547", "text": "function bind(func, thisArg) {\n var curryArgs = Array.prototype.slice.call(arguments, 2);\n return function() {\n var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));\n return func.apply(thisArg, args);\n };\n }", "title": "" }, { "docid": "dee3329d17865b928808536bed469a1d", "score": "0.7007589", "text": "function our_bind(f, arg1) {\n\treturn function(arg2) {\n\t\treturn f(arg1, arg2);\n\t};\n}", "title": "" }, { "docid": "ea1d7701d85ddbb4148da8347251bcd5", "score": "0.69927406", "text": "function curry(fn, x) {\n return function(y){\n return fn(x,y);\n };\n}", "title": "" }, { "docid": "da3f86bb1903f50160ea67df50247d5c", "score": "0.6974976", "text": "function bind(f,x) {\r\n return function() {\r\n return f.apply(x,arguments);\r\n };\r\n}", "title": "" }, { "docid": "f4eff33a3f881c51ceb1cc07940ac568", "score": "0.69557744", "text": "function curry(fn, first) {\n return function (second) {\n return fn(first,second);\n };\n}", "title": "" }, { "docid": "d61416c2a3b6ba272c247b694e953bf8", "score": "0.6898629", "text": "function curry(fun, ...first) {\r\n return function(...second) {\r\n\treturn fun(...first, ...second);\r\n }\r\n}", "title": "" }, { "docid": "280277f01c3cdb568cb506f0107f686e", "score": "0.6890969", "text": "function myBind(func, context) {\n return function(...args) {\n return func.apply(context, args);\n };\n}", "title": "" }, { "docid": "7a42b43ee1981c599158551b0211e7de", "score": "0.6855325", "text": "function myBind(func, context) {\n return function(...args) {\n func.apply(context, args);\n }\n}", "title": "" }, { "docid": "f906432e7efab0ee4927567b6fd6a9b0", "score": "0.68243146", "text": "function curry(binary, first){\n return function(second){\n return binary(first,second);\n }\n}", "title": "" }, { "docid": "4003b7e51be3c760cbb937f1afb50192", "score": "0.6801719", "text": "function curry( func ) {\n var args = aps.call( arguments, 1 );\n \n return function() {\n return func.apply( this, args.concat( aps.call( arguments ) ) );\n };\n }", "title": "" }, { "docid": "f658ad29241697a80fae7691146ed046", "score": "0.6778082", "text": "function currySum (s1, s2) {\n let theSum = s1 + s2;\n\n return function (param) {\n return param + theSum;\n }\n}", "title": "" }, { "docid": "85ef4b15e5c9ec1efdee179140c59165", "score": "0.67605174", "text": "function curry(fn,scrope){\n\tscrope = scrope || window;\n\tvar args = [];\n\tfor(var i= 2; i< arguments.length; i ++){\n\t\targs.push(arguments[i]);\n\t}\n\n\treturn function(){\n\t\tvar otherArgs = [];\n\t\tfor(var i =0; i< arguments.length; i++){\n\t\t\totherArgs.push(arguments[i]);\n\t\t}\n\t\tvar argsTotal = args.concat(otherArgs);\n\t\t\n\t\tfn.apply(scrope,argsTotal);\n\t}\n\n}", "title": "" }, { "docid": "9af567dffa2c8e50932c26bbfa8ab181", "score": "0.6755549", "text": "function _curry (fn) {\n return function (a, b) {\n return arguments.length === 1 ? function (b) { return fn(a, b) } : fn(a, b)\n }\n}", "title": "" }, { "docid": "683acdfaa22e2a97663cf4f158811d71", "score": "0.673703", "text": "function bind(func, context){\n return function(){\n var args = Array.prototype.slice.call(arguments);\n return func.apply(context, args);\n }\n}", "title": "" }, { "docid": "a6f25c1e2d332a1b3d7fb3021b1760e2", "score": "0.6736674", "text": "function curry(fn){return function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var last=args[args.length-1];if(typeof last==='function'){return fn.apply(undefined,args);}return function(Component){return fn.apply(undefined,args.concat([Component]));};};}", "title": "" }, { "docid": "68a26b8bbc9ebfbf15fadd887a743b36", "score": "0.6730726", "text": "function curry(func, x){\n return function(y){\n return func(x, y);\n }\n}", "title": "" }, { "docid": "a2ef6386eb1616efb8bcabf3c55a9670", "score": "0.67029196", "text": "function curry(func) {\n return function(a) {\n return function(b) {\n return func(a, b);\n }\n }\n}", "title": "" }, { "docid": "a2e46b0e438d2795207c04e9a10ffbe9", "score": "0.6695235", "text": "function bind(context) {\n\tvar self = this; // \"trapped\" function reference\n\t// only if there is more than an argument\n // we are interested into more complex operations\n // this will speed up common bind creation\n // avoiding useless slices over arguments\n\tif (1 < arguments.length) {\n\t // extra arguments to send by default\n var $arguments = slice.call(arguments, 1);\n return function () {\n return self.apply(\n context,\n // thanks @kangax for this suggestion\n arguments.length ?\n // concat arguments with those received\n $arguments.concat(slice.call(arguments)) :\n // send just arguments, no concat, no slice\n $arguments\n );\n };\n }\n\t// optimized callback\n\treturn function () {\n // speed up when function is called without arguments\n return arguments.length ? self.apply(context, arguments) : self.call(context);\n };\n }", "title": "" }, { "docid": "740bef9d1ce39cc7039ea29770d47209", "score": "0.66843003", "text": "function bind(cons /*, args... */) {\n var args = __slice.call(arguments, 1);\n return function() {\n return cons.apply(this, args);\n };\n}", "title": "" }, { "docid": "69161ccdeff584524ba0c3982551e2e0", "score": "0.66768605", "text": "chain(fn) {\n\t\treturn this.bind(fn);\n\t}", "title": "" }, { "docid": "a7ac0b8df265eb231a655983d9d7ffe9", "score": "0.6664834", "text": "function bind(context) {\n var self = this; // \"trapped\" function reference\n // only if there is more than an argument\n // we are interested into more complex operations\n // this will speed up common bind creation\n // avoiding useless slices over arguments\n if (1 < arguments.length) {\n // extra arguments to send by default\n var $arguments = slice.call(arguments, 1);\n return function () {\n return self.apply(\n context,\n // thanks @kangax for this suggestion\n arguments.length ?\n // concat arguments with those received\n $arguments.concat(slice.call(arguments)) :\n // send just arguments, no concat, no slice\n $arguments\n );\n };\n }\n // optimized callback\n return function () {\n // speed up when function is called without arguments\n return arguments.length ? self.apply(context, arguments) : self.call(context);\n };\n }", "title": "" }, { "docid": "016fae31d899d23c31adccbebea45baf", "score": "0.66624665", "text": "function curry(fn) {\n const arity = fn.length;\n\n return function $curry(...args) {\n if (args.length < arity) {\n return $curry.bind(null, ...args);\n }\n\n return fn.call(null, ...args);\n };\n}", "title": "" }, { "docid": "016fae31d899d23c31adccbebea45baf", "score": "0.66624665", "text": "function curry(fn) {\n const arity = fn.length;\n\n return function $curry(...args) {\n if (args.length < arity) {\n return $curry.bind(null, ...args);\n }\n\n return fn.call(null, ...args);\n };\n}", "title": "" }, { "docid": "016fae31d899d23c31adccbebea45baf", "score": "0.66624665", "text": "function curry(fn) {\n const arity = fn.length;\n\n return function $curry(...args) {\n if (args.length < arity) {\n return $curry.bind(null, ...args);\n }\n\n return fn.call(null, ...args);\n };\n}", "title": "" }, { "docid": "a9452fcfedafcb6ccb77457df07b2a82", "score": "0.6662453", "text": "function bind(fn, ctx) {\n return function (a) {\n var l = arguments.length;\n return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);\n };\n}", "title": "" }, { "docid": "a9452fcfedafcb6ccb77457df07b2a82", "score": "0.6662453", "text": "function bind(fn, ctx) {\n return function (a) {\n var l = arguments.length;\n return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);\n };\n}", "title": "" }, { "docid": "9bc6da4d46e5b0096adbd2ec9e11fab9", "score": "0.6645426", "text": "function curry(binary ,first){\n return liftf(binary)(first)\n}", "title": "" }, { "docid": "da4f46b1f734d3d0c423f3f72d29e61e", "score": "0.6637566", "text": "function bind(fn, thisArg) {\n return function () {\n return fn.apply(thisArg, arguments);\n };\n}", "title": "" }, { "docid": "09dd8a20cb55a8852bf07053e50c3b6a", "score": "0.6630241", "text": "function myBind(func, context, ...partials) {\n return function(...args) {\n let allArgs = args.concat(partials);\n return func.apply(context, allArgs);\n }\n}", "title": "" }, { "docid": "08777c57a4375c5751a1ed3007ac8e13", "score": "0.66281307", "text": "function bind(fn, o) {\n var args = [].slice.call(arguments, 2)\n return function() {\n return fn.apply(o, args.concat(arguments));\n };\n}", "title": "" }, { "docid": "7a917ee258e9e1c67dce2624aba96273", "score": "0.66153544", "text": "function curry(binary, x) {\n\n return function (y) {\n\n return binary(x, y);\n };\n\n }", "title": "" }, { "docid": "792b83bca35b3663f0f2961af5efab7a", "score": "0.6613839", "text": "function curry(f, a) {\n return function(b) {\n return f(a,b);\n };\n}", "title": "" }, { "docid": "2be2e7bda3d9ff9d152a225ad4d51670", "score": "0.6607777", "text": "function bind(fn) {\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n var that = this;\n // use the native Function#bind if it's available\n return fn.bind ? fn.bind.apply(fn, [that].concat(args)) : function () {\n return fn.apply(that, args.concat([].slice.call(arguments, 0)));\n };\n }", "title": "" }, { "docid": "49e0430d081d3e0149491748072b1af0", "score": "0.660429", "text": "function curry2(fn) {\n return function (firstArg) {\n return function (secondArg) {\n return fn(firstArg, secondArg)\n }\n }\n}", "title": "" }, { "docid": "e31b78deeace12266f5b5273604e1e41", "score": "0.6599419", "text": "function bind(context, fn) {\n return function (...args) {\n fn.apply(context, args)\n }\n}", "title": "" }, { "docid": "b7b94212e21c72641c49d2ba41f54681", "score": "0.6594553", "text": "function bind(context, fn) {\n return function (...args) {\n fn.apply(context, ...args)\n }\n}", "title": "" }, { "docid": "5e059e5826eee8eeb2ef1dc8e7c3a70b", "score": "0.6573844", "text": "function bind(func, context) {\n return function () {\n \n func.apply(context, arguments);\n };\n}", "title": "" }, { "docid": "7d6634b0d47d1dbdaed9ead23f857c07", "score": "0.6569221", "text": "function bindBU(func, b) {\n switch (b.length) {\n case 0: return (arg) => func(arg);\n case 1: return (arg) => func(b[0], arg);\n case 2: return (arg) => func(b[0], b[1], arg);\n case 3: return (arg) => func(b[0], b[1], b[2], arg);\n case 4: return (arg) => func(b[0], b[1], b[2], b[3], arg);\n case 5: return (arg) => func(b[0], b[1], b[2], b[3], b[4], arg);\n case 6: return (arg) => func(b[0], b[1], b[2], b[3], b[4], b[5], arg);\n case 7: return (arg) => func(b[0], b[1], b[2], b[3], b[4], b[5], b[6], arg);\n case 8: return (arg) => func(b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], arg);\n default: return (arg) => func(...b, arg);\n }\n}", "title": "" }, { "docid": "b26e775caed1c24fa28ef0b660ec9791", "score": "0.65537435", "text": "function bind(cons /*, args... */ ) {\n var args = __slice.call(arguments, 1);\n return function() {\n return cons.apply(this, args);\n };\n }", "title": "" }, { "docid": "763b2185e6e6905372fd124e1b59ace8", "score": "0.65445143", "text": "function curry (fun, x){\n\treturn function second(y){\n\t\treturn fun(x, y);\n\t};\n}", "title": "" }, { "docid": "b0a4a2e751420ee560d12a161c3d5ddf", "score": "0.65406734", "text": "function bind(value, thisp) {\n var args = array_slice(arguments, 2);\n return function bound() {\n var allArgs = args.concat(array_slice(arguments));\n return apply(value, thisp, allArgs);\n };\n}", "title": "" }, { "docid": "ccf8ce2efa0df746d6d45714ecc7ce44", "score": "0.6538776", "text": "function our_bind_2(f) {\n\treturn function our_bind_2_() {\n\t\tvar args = Array.prototype.slice.call(arguments);\n\t\tvar self = args.shift();\n\t\tif(self !== undefined) {\n\t\t\tthrow new TypeError(\"We don't support this argument yet!\");\n\t\t}\n\t\targs.unshift(f);\n\t\treturn impls[args.length].apply(self, args);\n\t};\n}", "title": "" }, { "docid": "f667eb3781787af8d47ceb746b67cb17", "score": "0.65244126", "text": "function curry2 (f) {\n return x1 => x2 => f(x1, x2)\n}", "title": "" }, { "docid": "b69dd56153f8ba349bfc1fc748497da3", "score": "0.6522613", "text": "function bind(fn, o){\n return function () {\n fn.call(o);\n };\n}", "title": "" }, { "docid": "df3b8932ecba9ca10ea34d90801f38db", "score": "0.6506439", "text": "function curryLecture(func) {\n func = func || this; //just because we are using it in task2\n var arity = func.length;\n return function g() {\n var args = [].slice.call(arguments);\n if(args.length === arity) {\n return func.apply(undefined, args);\n }\n return function() {\n var newArgs = [].slice.call(arguments);\n return g.apply(undefined, args.concat(newArgs));\n };\n };\n}", "title": "" }, { "docid": "bde79c1b7cf2992a41ae8563043e6d14", "score": "0.64911264", "text": "function bindB(func, b) {\n switch (b.length) {\n case 0: return () => func();\n case 1: return () => func(b[0]);\n case 2: return () => func(b[0], b[1]);\n case 3: return () => func(b[0], b[1], b[2]);\n case 4: return () => func(b[0], b[1], b[2], b[3]);\n case 5: return () => func(b[0], b[1], b[2], b[3], b[4]);\n case 6: return () => func(b[0], b[1], b[2], b[3], b[4], b[5]);\n case 7: return () => func(b[0], b[1], b[2], b[3], b[4], b[5], b[6]);\n case 8: return () => func(b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]);\n default: return () => func.apply(undefined, b);\n }\n}", "title": "" }, { "docid": "2b9cc992d733d3a31ed0afd8b7bf3a6e", "score": "0.6481735", "text": "function curry(f, a) {\n return (b) => {\n return f(a, b);\n }\n}", "title": "" }, { "docid": "7958551cbb43a43b09b60b5eb97faa91", "score": "0.6479376", "text": "function bind(fn, thisArg) {\n return function wrap() {\n return fn.apply(thisArg, arguments);\n };\n}", "title": "" }, { "docid": "965cf157761a9c0c3e45ea6c0a0025c4", "score": "0.6478687", "text": "function bind(fn, ctx) {\n var partial = (arguments.length > 2 ? slice.call(arguments, 2) : null)\n var f = function() {\n var args = (partial ? partial.concat(slice.call(arguments)) : arguments)\n return fn.apply(ctx, args)\n }\n f.__func__ = fn\n f.__context__ = ctx\n return f\n}", "title": "" }, { "docid": "2b01a6c2fdfe89c979558325b0bd4b68", "score": "0.6476708", "text": "function curry2(func) {\r\n return function(secondArg) {\r\n return function(firstArg) {\r\n return func(firstArg, secondArg);\r\n };\r\n };\r\n}", "title": "" }, { "docid": "1a4704f85b4949083c3d5b3ac9b95016", "score": "0.64698994", "text": "function curry1(fn, ...args) {\n return (..._arg) => {\n return fn(...args, ..._arg);\n }\n}", "title": "" }, { "docid": "9a11bde9a84bf292e3bd0f28e8f48ebb", "score": "0.6447033", "text": "function curry(fn) {\n return function() {\n for (\n var _len = arguments.length, args = new Array(_len), _key = 0;\n _key < _len;\n _key++\n ) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n\n if (typeof last === \"function\") {\n return fn.apply(void 0, args);\n }\n\n return function(Component) {\n return fn.apply(void 0, args.concat([Component]));\n };\n };\n }", "title": "" }, { "docid": "79dea626554ce891bfb331147c51983d", "score": "0.6434451", "text": "function simpleBind(context, fn) {\n\t return function(value) {\n\t fn.call(context, value);\n\t };\n\t }", "title": "" }, { "docid": "30e0b32a2e3d61de55b03ac1f1ccca54", "score": "0.64335036", "text": "function add (a,b,c){\n if (arguments.length < this.add.length) {\n return curry(this.add,arguments,this);\n }\n return a+b+c;\n}", "title": "" }, { "docid": "a7ee3e4feae200b75e3877a977270c25", "score": "0.64289546", "text": "function curryIt(fn) {\r\n return function ax(a) {\r\n return function bx(b) {\r\n return function cx(c) {\r\n return fn(a,b,c);\r\n }\r\n }\r\n }\r\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "348b64969875393c225e4c9487a5d4e5", "score": "0.6425834", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n if (typeof last === 'function') {\n return fn.apply(undefined, args);\n }\n return function (Component) {\n return fn.apply(undefined, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "83124598c0b99ec3cae75d81a8bb767f", "score": "0.64024293", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n\n if (typeof last === 'function') {\n return fn.apply(void 0, args);\n }\n\n return function (Component) {\n return fn.apply(void 0, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "83124598c0b99ec3cae75d81a8bb767f", "score": "0.64024293", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n\n if (typeof last === 'function') {\n return fn.apply(void 0, args);\n }\n\n return function (Component) {\n return fn.apply(void 0, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "83124598c0b99ec3cae75d81a8bb767f", "score": "0.64024293", "text": "function curry(fn) {\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var last = args[args.length - 1];\n\n if (typeof last === 'function') {\n return fn.apply(void 0, args);\n }\n\n return function (Component) {\n return fn.apply(void 0, args.concat([Component]));\n };\n };\n}", "title": "" }, { "docid": "7d07a303168344ce0db0926d694f02e6", "score": "0.6383357", "text": "function bind ( fn, thisObject ) {\n return function () {\n return fn.apply( thisObject, arguments );\n };\n }", "title": "" }, { "docid": "1300f55bda9ae296bd0ac262f4cf652f", "score": "0.6381941", "text": "function bind(fn,ctx){function boundFn(a){var l=arguments.length;return l?l>1?fn.apply(ctx,arguments):fn.call(ctx,a):fn.call(ctx);}// record original fn length\nboundFn._length=fn.length;return boundFn;}", "title": "" }, { "docid": "1300f55bda9ae296bd0ac262f4cf652f", "score": "0.6381941", "text": "function bind(fn,ctx){function boundFn(a){var l=arguments.length;return l?l>1?fn.apply(ctx,arguments):fn.call(ctx,a):fn.call(ctx);}// record original fn length\nboundFn._length=fn.length;return boundFn;}", "title": "" }, { "docid": "1300f55bda9ae296bd0ac262f4cf652f", "score": "0.6381941", "text": "function bind(fn,ctx){function boundFn(a){var l=arguments.length;return l?l>1?fn.apply(ctx,arguments):fn.call(ctx,a):fn.call(ctx);}// record original fn length\nboundFn._length=fn.length;return boundFn;}", "title": "" }, { "docid": "1300f55bda9ae296bd0ac262f4cf652f", "score": "0.6381941", "text": "function bind(fn,ctx){function boundFn(a){var l=arguments.length;return l?l>1?fn.apply(ctx,arguments):fn.call(ctx,a):fn.call(ctx);}// record original fn length\nboundFn._length=fn.length;return boundFn;}", "title": "" }, { "docid": "5c54226c8eea1a8337c309e15b4b9f36", "score": "0.6357034", "text": "function simpleBind(context, fn) {\r\n\t\treturn function(value) {\r\n\t\t\tfn.call(context, value);\r\n\t\t};\r\n\t}", "title": "" }, { "docid": "459b84f36a887f552066aa06e557cdc3", "score": "0.63561785", "text": "function curriedFunction(a, b) {\n y = a + b;\n return c => y + c;\n}", "title": "" }, { "docid": "e75fed5127c9402ca90564d7d75bd28a", "score": "0.63416207", "text": "function bind$1(fn, ctx) {\n function boundFn(a) {\n var l = arguments.length;\n return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);\n }\n // record original fn length\n boundFn._length = fn.length;\n return boundFn;\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" }, { "docid": "be1c9c93e38a106c2168bdb3ccb00e1e", "score": "0.6334279", "text": "function simpleBind(context, fn) {\n return function(value) {\n fn.call(context, value);\n };\n }", "title": "" } ]
f1fc2fea7993188c44815dec253ae476
If the number button was clicked, update the quantity state in redux.
[ { "docid": "8604f48eb117b2f4b75db7364815d854", "score": "0.8030617", "text": "function handleClick(number) {\n dispatch(setQuantity(number));\n }", "title": "" } ]
[ { "docid": "f0095bf671a5135463ae89cab10a6cf6", "score": "0.7212677", "text": "clickAumentarQuantidade()\n {\n this.setState({\n item_quantity: (this.state.item_quantity + 1)\n });\n }", "title": "" }, { "docid": "34db9ddb6078922bf35f783811420968", "score": "0.7099303", "text": "function onQuantityChange(quantity) {\n if (!isNaN(quantity)) {\n /*--------------*/\n const action_updateQuantity = updateQuantity(quantity);\n dispatch(action_updateQuantity);\n /*--------------*/\n }\n }", "title": "" }, { "docid": "56e26c515940e96c4f9539102c5dab2c", "score": "0.7052362", "text": "function quantityHandler(action, index) {\n // const newItems = cartItems[index];\n let currentQty = qty;\n\n if (action == \"more\") {\n currentQty = currentQty < book.quantity ? currentQty + 1 : currentQty;\n } else if (action == \"less\") {\n currentQty = currentQty > 1 ? currentQty - 1 : 1;\n }\n // cartItems[index] = newItems;\n setQty(currentQty);\n // AsyncStorage.setItem(\"@cartList\", JSON.stringify(cartItems));\n refresh();\n }", "title": "" }, { "docid": "3d8f11c229bb941c40c144cb27808a57", "score": "0.7040844", "text": "function updateQuantity(state, action) {\n const { isAdd, product } = action.payload;\n const newState = {\n ...state,\n items: state.items\n .map((item) => {\n if (item.id === product.id) {\n if (isAdd) {\n item.quantity++;\n } else {\n item.quantity = Math.max(0, item.quantity - 1);\n if (item.quantity === 0) {\n toast.error(`${item.name} removed from cart`, {\n position: \"bottom-left\",\n });\n return null;\n }\n }\n }\n return item;\n })\n // filter out nulls\n .filter((item) => item !== null),\n };\n\n // update counts\n const { totalQuantity, totalAmount } = getUpdatedCounts(newState);\n\n return {\n ...newState,\n totalQuantity,\n totalAmount,\n };\n}", "title": "" }, { "docid": "ccc24c08d2f9e8149460bb538c7a9956", "score": "0.70212805", "text": "function NumberCircleButton({ number }) {\n \n const dispatch = useDispatch();\n\n // If the number button was clicked, update the quantity state in redux. \n function handleClick(number) {\n dispatch(setQuantity(number));\n }\n\n return (\n <div className=\"NumberCircleButton\" onClick={() => handleClick(number)}>\n <p className=\"Number-Circle-Text\">{ number }</p>\n </div>\n )\n}", "title": "" }, { "docid": "06f3d71e408938e5f68a8878b9537388", "score": "0.69393957", "text": "handleQuantityChange(event) {\n const target = event.target;\n const value = target.value;\n\n this.setState({ quantityAdded: value });\n }", "title": "" }, { "docid": "6cd8e89857e1bfbd3531f5abf04481bc", "score": "0.68881434", "text": "function numberSelected(num){\n //Store (Append) it into number\n state.num = state.num + num\n console.log('state.num :>> ', state.num);\n renderDisplay()\n}", "title": "" }, { "docid": "90fa88331035c8ba88f2172b4259ab2d", "score": "0.6870166", "text": "_increaseQuantity(_id){\n this.props.updateCart(_id, 1, this.props.cart);\n }", "title": "" }, { "docid": "5f736779fe10aaa68914117d8faa3181", "score": "0.6711197", "text": "function cartNumbers(product, action) {\r\n let productNumbers = localStorage.getItem('cartNumbers');\r\n productNumbers = parseInt(productNumbers);\r\n console.log(productNumbers);\r\n\r\n let cartItems = localStorage.getItem('productsInCart');\r\n cartItems = JSON.parse(cartItems);\r\n\r\n if( action ) {\r\n localStorage.setItem(\"cartNumbers\", productNumbers - 1);\r\n document.querySelector('.naV_icons span').textContent = productNumbers -1;\r\n console.log(\"action running\");\r\n } else if( productNumbers ) {\r\n localStorage.setItem(\"cartNumbers\", productNumbers + 1);\r\n document.querySelector('.naV_icons span').textContent = productNumbers + 1;\r\n } else {\r\n localStorage.setItem(\"cartNumbers\", 1);\r\n document.querySelector('.naV_icons span').textContent = 1;\r\n }\r\n setItems(product);\r\n}", "title": "" }, { "docid": "b883e99ca5cbd7622e4c3f3c4e6a970b", "score": "0.6671003", "text": "handleQuantityChange(event){\n this.setState({newquantity: event.target.value})\n}", "title": "" }, { "docid": "66fb60c1908611963611d4ba7ebbc1c1", "score": "0.658956", "text": "function quantityChanged(event) {\n let input = event.target\n if (isNaN(input.value) || input.value <= 0) input.value = 1\n updateCartTotal()\n}", "title": "" }, { "docid": "d3313807ff3c22d86fc9af41596412e8", "score": "0.65853196", "text": "function quantityChanged(event) {\n let input = event.target;\n if (isNaN(input.value) || input.value <= 0) {\n input.value = 1;\n }\n updateCartTotal();\n\n}", "title": "" }, { "docid": "2dc9a19d37596b0864a8de8be285d025", "score": "0.65572715", "text": "onQuantityChange(event)\n {\n this.setState({orders_quantity:event.target.value})\n }", "title": "" }, { "docid": "1a744c5775ddcb9ded76f130f6ad88ae", "score": "0.6552442", "text": "trackQty(state,{event,index}) {\n\n // this line updates the value of the property 'amount' of the objects pushed to the 'numItems' array so that the discounted price could show from the cart when the quantity input value is changed.\n\n state.numItems[index].amount = event.target.value\n }", "title": "" }, { "docid": "abec56d6447f1b397389525414a6b3ba", "score": "0.6547439", "text": "handleUpdateCart(e, id, quantity) {\n let cart = this.state.cart;\n let newQuantity = 0;\n e.preventDefault();\n for (var i = 0; i < cart.length; i ++){\n if (id == cart[i].id){\n cart[i].quantity = quantity;\n newQuantity = newQuantity + cart[i].quantity;\n } else {\n newQuantity = newQuantity + cart[i].quantity;\n }\n }\n\n this.setState({\n cart: cart,\n quantity: newQuantity\n }, () => {\n this.handleTotal()\n })\n }", "title": "" }, { "docid": "6376886bb36af6fa18440654d26cf9f8", "score": "0.6543277", "text": "function quantityChanged(event) {\n let input = event.target;\n if (isNaN(input.value) || input.value <= 0) {\n input.value = 1;\n }\n updateCartTotal();\n}", "title": "" }, { "docid": "a2ed23a2fe17db301d6335ce962c6738", "score": "0.65374327", "text": "onChangeQuantity(value) {\n this.setState({\n selected_quantity: value\n });\n }", "title": "" }, { "docid": "dbfd656054f42c33c29ad203cd7f2cd0", "score": "0.6526897", "text": "onPressNumButton (num) {\n if (this.state.number.length === this.numberMap['inputCount']) {\n return;\n }\n let numberPhone = this.state.number + num;\n this.setState({\n number: numberPhone\n });\n this.checkButtonActive(numberPhone);\n }", "title": "" }, { "docid": "a6a72fd96c11c7479d3a3bbfd6126128", "score": "0.65229815", "text": "function _updateModalQty() {\n $(\".add-to-cart\").on(\"click\", function () {\n var qtyValue = $(\".numeric-stepper > input\").val();\n $(\".js-product-qty\").text(qtyValue);\n });\n }", "title": "" }, { "docid": "a60f8986b3adefdfe69ac22428c6ff61", "score": "0.6516047", "text": "function increaseQuantity() {\n const quantity = parseInt($(\"#sumTotalQuantity\").text()) + 1;\n $(\"#sumTotalQuantity\").text(quantity);\n }", "title": "" }, { "docid": "47119901d2b0b8cc9ede2dda0e87f9e0", "score": "0.65011877", "text": "function quantityChanged(e){//Al clickear, modificará la cantidad\n let input = e.target\n if(input.value <= 0){\n input.value = 1;\n }\n updateShoppingCartTotal(); //Y se modifica la cantidad.\n}", "title": "" }, { "docid": "1d4febe871ad35c22276ddf85bbe9487", "score": "0.649687", "text": "handleChange (event) {\n this.setState({\n quantity: event.target.value\n })\n }", "title": "" }, { "docid": "08cb0f5905877b9e46570cc092550485", "score": "0.64915514", "text": "changeQty(event) {\n this.setState({currentQty: event.target.value});\n return false;\n }", "title": "" }, { "docid": "e8517e864929e488adf621d8e68dedd5", "score": "0.64879286", "text": "addToCart(title){\n if (this.state.sizeSelected && this.state.colorSelected) {\n this.props.addToCart(\n title,\n this.props.match.params.prodid,\n this.state.color,\n this.state.size,\n this.state.quantity,\n this.state.price\n )\n //this.props.updateCartQuantity(this.state.quantity)\n //do I reset state quantity here?? state resets on rerender\n }\n }", "title": "" }, { "docid": "954619c2b58b9da4bd3a95d1ae0b6019", "score": "0.6437087", "text": "function productQuantity() {\n\t\t$('.add').click(function () {\n\t\t\tif ($(this).prev().val()) {\n\t\t\t\t$(this).prev().val(+$(this).prev().val() + 1);\n\t\t\t}\n\t\t});\n\t\t$('.sub').click(function () {\n\t\t\tif ($(this).next().val() > 1) {\n\t\t\t\tif ($(this).next().val() > 1) $(this).next().val(+$(this).next().val() - 1);\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "e49c89f876f9a165c280b1566d2a483b", "score": "0.6436568", "text": "updateNumber(newNumber){\n this.setState({\n currentNumber: newNumber.target.value\n })\n }", "title": "" }, { "docid": "9897bfb1ec4e45f0c4c5c134aaa2537d", "score": "0.6428903", "text": "function updateQty() {\n\t\n}", "title": "" }, { "docid": "f2be7f6587d6525dca7ac45f536a209a", "score": "0.6403311", "text": "_decreaseQuantity(_id, quantity){\n if(quantity > 1) {\n this.props.updateCart(_id, -1, this.props.cart); \n }\n }", "title": "" }, { "docid": "b6b5b33e901bcd177540ad94d86cb260", "score": "0.63897437", "text": "function editTheQuantity(event) {\n var Qinputelement = event.target;\n if (isNaN(Qinputelement.value) || Qinputelement.value <= 0) {\n Qinputelement.value = 1;\n }\n updatefoodcart();\n}", "title": "" }, { "docid": "fdeaa0c92a7cc6e6665358e9fb0ceff3", "score": "0.63881606", "text": "changeQty (state, { product, qty }) {\n let cartProduct = state.cart.find(prod => prod._id === product._id)\n cartProduct.quantity = qty\n\n state.cartLength = 0\n if (state.cart.length > 0) {\n state.cart.map(product => {\n state.cartLength += product.quantity\n })\n }\n\n let indexOfProduct = state.cart.indexOf(cartProduct)\n state.cart.splice(indexOfProduct, 1, cartProduct)\n }", "title": "" }, { "docid": "0c597b03137a67e8b6f307d2d42d4a32", "score": "0.6375133", "text": "_updateQuantity(event) {\n const $target = $(event.currentTarget);\n const $quantity = $target.closest('[data-product-quantity]').find('[data-product-quantity-input]');\n const min = parseInt($quantity.prop('min'), 10);\n const max = parseInt($quantity.prop('max'), 10);\n let newQuantity = parseInt($quantity.val(), 10);\n\n this.cartAddAlert.clear();\n this.cartOptionAlert.clear();\n\n if ($target.is('[data-quantity-increment]') && (!max || newQuantity < max)) {\n newQuantity = newQuantity + 1;\n } else if ($target.is('[data-quantity-decrement]') && newQuantity > min) {\n newQuantity = newQuantity - 1;\n }\n\n $quantity.val(newQuantity);\n }", "title": "" }, { "docid": "45afadc87f050af2d10b2d6ddd446303", "score": "0.63676393", "text": "function changeSkuQuantity(){\n\t$(\".quantity-button\").on(\"click\", function() {\n\n\t\tvar $button = $(this);\n\t\tvar oldValue = $button.parent().find(\".quantity-number\").val();\n\t\tvar maxValue = $button.parent().find(\".quantity-number\").data('max-value');\n\n\t\tif ($button.hasClass(\"add\")) {\n\t\t\tvar newVal = parseFloat(oldValue) + 1;\n\n\t\t\tif (maxValue && newVal > maxValue) {\n\t\t\t\tnewVal = maxValue;\n }\n\t\t} else {\n\n\t\t\tif (oldValue > 1) {\n\t\t\t\tvar newVal = parseFloat(oldValue) - 1;\n\t\t\t} else {\n\t\t\t\tnewVal = 1;\n\t\t\t}\n\t\t}\n\n $button.parent().find(\".quantity-number\").val(newVal);\n\n\t});\n\n\t$('.quantity-number').blur(function() {\n\n\t\tvar minValue = 1;\n\t\tvar $input = $(this);\n\t\tvar inputValue = $input.val();\n\t\tvar maxValue = $input.data('max-value');\n\n\t\tif (maxValue && inputValue > maxValue) {\n\t\t\t$input.val(maxValue);\n\t\t}\n\n\t\tif (inputValue < minValue) {\n\t\t\t$input.val(minValue);\n\t\t}\n\t});\n}", "title": "" }, { "docid": "9f391324d86e387a46c8abf4df7f9d28", "score": "0.6360947", "text": "function changeCount(event) {\n const target = event.target;\n\n if (target.classList.contains('counter-button')) {\n const food = cart.find((item) => item.id === target.dataset.id);\n if (target.classList.contains('counter-minus')) {\n food.count--;\n if (food.count === 0) {\n cart.splice(cart.indexOf(food), 1); // исправление бага ухода в минус цены товара\n }\n }\n if (target.classList.contains('counter-plus')) food.count++;\n renderCart();\n }\n}", "title": "" }, { "docid": "f0c5e3eae5e969dca06a0c821568dbcc", "score": "0.6306972", "text": "updateItemQuantity(){\n let quantity = parseInt(this.state.newquantity);\n let productcode = parseInt(this.state.itemtoedit);\n axios.put(`/api/cart/${this.props.cartid}`, {quantity, productcode}).then(()=> {\n alert('Quantity Updated')\n this.setState({edit:false}, this.getCart())\n })\n}", "title": "" }, { "docid": "814dbb2565397aede10332bce5c3074e", "score": "0.62957865", "text": "function quantityChanged(event) {\n let input = event.target\n if (isNaN(input.value) || input.value <= 0) { //Nan = to check if the input is a number or not, and input.value <= 0 is to make sure the nu,ber added is positive\n input.value = 1 //lowest number to be able to add should be one\n }\n}", "title": "" }, { "docid": "4b15e17523c900c1207fdae3d1eee3e5", "score": "0.6272409", "text": "function quantityChanged(event) {\n var input = event.target;\n\n //If the value in the input is either 'null' or less than zero, change it to 1.\n if (isNaN(input.value) || input.value <= 0) {\n input.value = 1;\n }\n\n // Call 'updateCartTotal()' function\n updateCartTotal();\n}", "title": "" }, { "docid": "07f134c9fbf71a6352784e747c0a907d", "score": "0.6266399", "text": "plusQty() {\n if (this.props.product) {\n let stock = this.props.product.stocks[0].qty;\n let currentQty = parseFloat(this.state.currentQty);\n let addQtyIncrement = this.getProductStockService(this.props.product)\n .getAddQtyIncrement(this.props.product);\n currentQty = NumberHelper.addNumber(currentQty, addQtyIncrement);\n if (currentQty > stock.qty) {\n currentQty = stock.qty;\n }\n let validateQty = this.validateQty(this.props.product, currentQty);\n if (validateQty) {\n this.setState({currentQty: String(currentQty)});\n }\n this.collectPrice(this.props.product, currentQty);\n this.qty_element.value = String(currentQty);\n }\n }", "title": "" }, { "docid": "b18bd34c1a0b9807d2b260ac79aebc99", "score": "0.6265339", "text": "buttonClick(e) {\n let pressedButton = e.target.innerHTML;\n if (!this.state.finished) {\n if (this.state.number == \"0\") {\n this.setState({\n number: pressedButton });\n\n } else {\n let number = this.state.number + pressedButton;\n this.setState({\n number });\n\n }\n } else\n this.setState({\n number: pressedButton,\n finished: false });\n\n }", "title": "" }, { "docid": "cd8a2daf2e2f0e1eecf10bcca285b359", "score": "0.6251216", "text": "handleChangeQuantity(id, e) {\n let newTotal = {\n [id] : e.target.value\n }\n this.setState({\n selectedItem: {\n ...this.state.selectedItem,\n ...newTotal\n }\n })\n }", "title": "" }, { "docid": "eb658c94b68731d3bc5dd7433c52b874", "score": "0.62499785", "text": "handleInputChange(evt) {\n const newQuantity = Number(evt.target.value);\n this.callUpdateQuantity(newQuantity);\n }", "title": "" }, { "docid": "082d0f8dd4fa3019c8c26f61877bf04f", "score": "0.62499267", "text": "function quantityChanged( event ) {\n var input = event.target;\n if ( isNaN( input.value ) || input.value <= 0 ) {\n input.value = 1;\n }\n updateCartTotal();\n}", "title": "" }, { "docid": "fd0fb5ff452dbb649f1311ee6f376b31", "score": "0.6247334", "text": "function quantityChanged(event) {\n console.log(\"quantityChanged\")\n var input = event.target\n if (isNaN(input.value) || input.value <= 0) {\n input.value = 1\n }\n updateCartTotal()\n}", "title": "" }, { "docid": "c9299149531a6d56e6189b25158cb5f1", "score": "0.62448454", "text": "function addQty() {\n let newQty = qty + 1;\n setQty(newQty);\n setItem(true);\n }", "title": "" }, { "docid": "18f56be58357537a06990c5d8653a52d", "score": "0.62442815", "text": "add(num) {\n return this.increment(\"quantity\", { by: num });\n }", "title": "" }, { "docid": "f7c3f93ade2e4a159bd04fbd95740816", "score": "0.62363243", "text": "increment (state,payload) {\n this.state.cart.push(payload);\n }", "title": "" }, { "docid": "895cbbb9241167cf1b918d1d1827ef3a", "score": "0.6234336", "text": "function updateQuantity(index, quantity, target){\n let answer = false\n ,cartItems = getCartItems()\n ;\n //console.log(cartItems);\n //console.log(index);\n //console.log(quantity);\n //console.log(target);\n //console.log(cartItems[index].price);\n if( quantity == 0){\n let answer = confirm( \"Would you like to remove this from your cart?\\n\" );\n if( answer ){\n removeItemFromCart(index);\n // delay is necessary for sessionStorage to catch up\n setTimeout(buildCart,500);\n }\n }\n \n if( !answer && quantity !=0 ){\n cartItems[index].quantity = Number(quantity);\n sessionStorage.setItem(\"cartItems\", JSON.stringify(cartItems));\n }\n \n if( typeof(target) == \"string\" && target.length ){\n $( \"#\"+target ).html(\"$\" + getSubtotal(cartItems[index].price, quantity));\n }\n \n updateSummaryTotals();\n}", "title": "" }, { "docid": "2188f0b90d78dce6ae1f1966eaa1c3c0", "score": "0.6232256", "text": "handleCartAdd(name, price, size, image, id, quantity) {\n let cart = this.state.cart;\n let newQuantity = this.state.quantity + 1;\n let item = {\n name: name,\n price: price,\n size: size,\n image: image,\n id: id,\n quantity: quantity\n }\n\n if(cart.length == 0){\n cart.push(item);\n } else {\n for (var i = 0; i < cart.length; i++){\n if (item.id == cart[i].id){\n cart[i].quantity = cart[i].quantity + 1;\n break\n } else if (i == cart.length - 1){\n cart.push(item);\n break\n }\n }\n }\n\n this.setState({\n cart: cart,\n quantity: newQuantity\n }, () => {\n this.handleTotal()\n })\n }", "title": "" }, { "docid": "9d9a2f0fb7ec9bcd2f9457b2488ec6e8", "score": "0.6192603", "text": "function changeNumberOfUnits(action, id){\n cart = cart.map((item) => {\n let oldNumberOfUnits = item.numberOfUnits\n\n if(item.id === id){\n if(action === \"minus\" && oldNumberOfUnits > 1){\n oldNumberOfUnits--;\n }\n else if(action === \"plus\"){\n oldNumberOfUnits++;\n }\n }\n\n // return object where are if old number is changed it will change if not - not change\n return{\n ...item,\n numberOfUnits: oldNumberOfUnits,\n }\n\n });\n\n updateCart();\n}", "title": "" }, { "docid": "5909be2379e807021c7f778d8fb4134c", "score": "0.6187579", "text": "updateQuantity(post, newQuantity) {\n // Field to send to /api/v3/posts/:post_id\n const field = {\n quantity: parseInt(newQuantity),\n };\n\n // Make API request to Rogue to update the quantity on the backend\n const request = this.api.patch(`api/v3/posts/${post['id']}`, field);\n\n request.then(result => {\n // Update the state\n this.setState(previousState => {\n const newState = { ...previousState };\n newState.posts[post['id']].quantity = result.data['quantity'];\n\n return newState;\n });\n });\n\n // Close the modal\n this.hideHistory();\n }", "title": "" }, { "docid": "3b236bff60a16dea17c62a3730a79431", "score": "0.61823505", "text": "function displayBagsQuantity() {\n const $bagsNumbInput = $(\"#quantityInput\");\n // $bagsNumbInput.val(1);\n $bagsNumbInput.on('change', function () {\n const $classBagsNum = $(\"#bagsNumber\");\n let quantityVal = $(this).val();\n $(\"#quantity\").text(quantityVal);\n\n switch (quantityVal) {\n case \"1\":\n $classBagsNum.text(bagNumber[0]);\n getSelectedCategories(categoryIdInputArray);\n break;\n case \"2\":\n case \"3\":\n case \"4\":\n $classBagsNum.text(bagNumber[1]);\n getSelectedCategories(categoryIdInputArray);\n break;\n default:\n $classBagsNum.text(bagNumber[2]);\n getSelectedCategories(categoryIdInputArray);\n break;\n }\n });\n }", "title": "" }, { "docid": "49ddda0f0d6bd0afea06ef29a3262395", "score": "0.61632526", "text": "handleQuantityFieldChange(event) {\n this.setState({\n quantityFieldValue: event.target.value\n });\n }", "title": "" }, { "docid": "3cf9c51ef762e747074256e323c0aa39", "score": "0.61586195", "text": "handleCountClick(e){\n // console.log(e);\n if (e.target.id === 'add'){\n this.setState({\n count: this.state.count + 1\n });\n }\n else if (e.target.id === 'sub'){\n this.setState({\n count: this.state.count - 1\n });\n }\n else if (e.target.id === 'reset'){\n this.setState({\n count: 0\n });\n }\n }", "title": "" }, { "docid": "1c9c3dbd5b891112b848c9b893562b89", "score": "0.61473465", "text": "clickDiminuirQuantidade()\n {\n if(this.state.item_quantity === 1)\n return false;\n\n this.setState({\n item_quantity: (this.state.item_quantity - 1)\n });\n }", "title": "" }, { "docid": "bb33029ade0b02165d9b0bf10d40e7a2", "score": "0.612575", "text": "render() {\n return (\n <div className=\"counter\">\n {/* If use Redux */}\n {/* <button className=\"minus\" onClick={this.props.handleMinus}> - </button>\n <input type=\"text\" value={this.props.order} onChange={() => true} />\n <button className=\"plus\" onClick={this.props.handlePlus}> + </button> */}\n\n {/* If use props from Product and local function */}\n {/* <button className=\"minus\" onClick={this.handleMinus}> - </button>\n <input type=\"text\" value={this.state.order} onChange={() => true}/>\n <button className=\"plus\" onClick={this.handlePlus}> + </button> */}\n\n {/* Jika */}\n <button className=\"minus\" onClick={() => this.props.dispatch({ type: \"MINUS_ORDER\" })}> - </button>\n <input type=\"text\" value={this.props.state.totalOrder} onChange={() => true} />\n <button className=\"plus\" onClick={() => this.props.dispatch({ type: \"PLUS_ORDER\" })}> + </button>\n\n </div>\n )\n }", "title": "" }, { "docid": "a266396f847cdd6c9c283b559f572e4b", "score": "0.61252403", "text": "function cartNumbers(product) {\n let productNumbers = localStorage.getItem(\"cartNumbers\");\n productNumbers = parseInt(productNumbers);\n\n if (productNumbers) {\n localStorage.setItem(\"cartNumbers\", productNumbers + 1);\n document.querySelector(\".view-cart-button span\").textContent =\n \"(\" + (productNumbers + 1) + \")\";\n } else {\n localStorage.setItem(\"cartNumbers\", 1);\n document.querySelector(\".view-cart-button span\").textContent =\n \"(\" + 1 + \")\";\n }\n\n setItems(product);\n}", "title": "" }, { "docid": "5b3d411f3ebfa64134df6d5f166e1799", "score": "0.61211926", "text": "function changeProductQuantity(productId, quantity){\n //TODO\n}", "title": "" }, { "docid": "18e4fe80bf5d28d301067c9863683488", "score": "0.61187035", "text": "function increaseNumberOfItemsInTheCart() {\n\n if ((event.target.textContent) == 'ADD TO CART') {\n numberOfSelectedItems.textContent = ++numberOfSelectedItems.textContent;\n } \n if((event.target.textContent) == 'REMOVE FROM CART'){\n numberOfSelectedItems.textContent = --numberOfSelectedItems.textContent;\n }\n}", "title": "" }, { "docid": "0657bf3da9ef667990fbd793727ebc52", "score": "0.6113704", "text": "setValue(genre, action){\n // console.log(`${genre} ${action}`);\n let curState;\n if(action === 'plus'){\n if(this.state[genre] < 10 && this.state.totalPoints < 30){\n this.setState((prevState)=> {\n curState = {[genre]: prevState[genre] + 1};\n if(this.props.saveToRedux){\n this.props.saveToRedux(curState);\n }\n return {[genre]: prevState[genre] + 1, totalPoints: prevState.totalPoints + 1};\n });\n }\n }\n if(action === 'minus'){\n if(this.state[genre] > 0 && this.state.totalPoints > 0){\n this.setState((prevState)=> {\n curState = {[genre]: prevState[genre] - 1};\n if(this.props.saveToRedux){\n this.props.saveToRedux(curState);\n }\n return {[genre]: prevState[genre] - 1, totalPoints: prevState.totalPoints - 1};\n });\n }\n }\n }", "title": "" }, { "docid": "47e7b12b96558768dde927d87208a444", "score": "0.6109888", "text": "function addQuantity(event) {\n let totalQuantity = event.data.product.quantity + 1;\n event.data.product.quantity = totalQuantity;\n event.data.input[0].value = totalQuantity;\n localStorage.setItem(\"cart\", JSON.stringify(productsInCart));\n let productSum = calculateProductSum(event.data.product);\n event.data.price[0].textContent = productSum + \" sek\";\n renderSum();\n}", "title": "" }, { "docid": "680c3f609217a4c86c40de5fca54dedd", "score": "0.6107631", "text": "function AddQuantity() {\n let selection = $(this).siblings('.unit-name').text();\n let newCount = parseInt($(this).siblings(\".unit-quantity\").text()) + 1;\n $(this).siblings(\".unit-quantity\").text(newCount);\n orderList.push(selection);\n FinalPrice();\n }", "title": "" }, { "docid": "35024cd7443c003b3e2d88fd44453d66", "score": "0.61051214", "text": "function updateTicketQuantity(event, newQuantity) {\n let parentElement = event.target.closest(\"#ticket-input\");\n let previousQuantity = parentElement.querySelector(\"#ticket-count\").value;\n // convert quantity from string to integer\n previousQuantity = parseInt(previousQuantity, 10);\n let updatedQuantity = previousQuantity + newQuantity;\n\n // if quantity value is zero. stop decreasing.\n if (updatedQuantity < 0) {\n return;\n }\n\n parentElement.querySelector(\"#ticket-count\").value = updatedQuantity;\n\n // update subtotal, vat and total values\n let subtotal = updateSubtotal();\n let vat = updateVat();\n updateTotal(subtotal, vat);\n}", "title": "" }, { "docid": "147166b838e7450eed5e154931a7cf8c", "score": "0.61049336", "text": "function quantityChanged(event){\n let input = event.target\n if( input.value <=0 || isNaN(input.value)){\n input.value = 1;\n }\n updateTotalPrice();\n}", "title": "" }, { "docid": "ba477276d87470c8986f064d0f9aa6d9", "score": "0.60697037", "text": "function updateQuantity(num_units, iid) {\n connection.query('UPDATE Products SET stock_quantity = stock_quantity -? WHERE item_id = ?', [num_units, iid], function (error, results, fields) {\n\n // startOverPromt();\n });\n}", "title": "" }, { "docid": "93f8fe4707fc0f6c55b08c26bfe065db", "score": "0.60667264", "text": "function updateCartCount(quantity) {\n\tcartItemCount += parseInt(quantity);\n\tdocument.getElementById(\"shoppingCartCount\").innerHTML = cartItemCount;\n}", "title": "" }, { "docid": "56b063b0f4fd697bd0a22575a5a8e0f2", "score": "0.6036255", "text": "function addQuantity(product, quantity) {\n connection.query(\n \"UPDATE products SET stock_quantity = ? WHERE item_id = ?\",\n [product.stock_quantity + quantity, product.item_id],\n function(err, res) {\n // Let the user know the purchase was successful, re-load loadProducts\n console.log(\"\\nSuccessfully added \" + quantity + \" \" + product.product_name + \"'s!\\n\");\n managerMenu();\n }\n );\n}", "title": "" }, { "docid": "bc4167c564f9e038fea746193c21c268", "score": "0.60281247", "text": "function fieldQuantityHandler(event) {\n var productId = parseInt($(this).closest('.cart-item').data('product-id'), 10);\n var variantId = parseInt($(this).closest('.cart-item').data('variant-id'), 10);\n var product = collectionProductsHash[productId];\n\n var variant = product.variants.filter(function (variant) {\n return variant.id === variantId;\n })[0];\n\n var cartLineItem = findCartItemByVariantId(variant.id);\n var quantity = event.target.value;\n\n if (cartLineItem) {\n updateVariantInCart(cartLineItem, quantity);\n }\n }", "title": "" }, { "docid": "2aea736f2635792ff1bd3c7494653157", "score": "0.602302", "text": "addToCart(state, payload) {\n state.cart.push(Number(payload))\n }", "title": "" }, { "docid": "e43b108e8f76b05d206917ed2b4d9806", "score": "0.6018836", "text": "handleSubmit (event) {\n event.preventDefault()\n //passing in 'this' was also floated\n this.props.addToCart(this.props.selectedProduct.id, this.state.quantity)\n //I don't think we need to re-set quantity back to 1. I think it shold stay whatever the user selected.\n // this.setState({\n // quantity: 1\n // })\n }", "title": "" }, { "docid": "f6f23ab89741fa05d8e72bbc83193aeb", "score": "0.6002344", "text": "@action updateQuantity(productId) {\n // First we get the products that ARE NOT the selected product\n let otherProducts = this.cart.products.filter(p => { return p.id != productId; });\n // Then we get the product who's quantity is going to be updated\n let thisProduct = this.cart.products.findBy('id', productId);\n // Create a new array of new length with existing product\n let newQuantity = parseInt(document.getElementById(`${productId}-dropdown`).value);\n // Fill it\n let newQuantityProductArray = new Array(newQuantity).fill(thisProduct);\n // Concat the other products with the new array of new quantity\n this.cart.products = [].concat(otherProducts, newQuantityProductArray);\n\n // Gross\n }", "title": "" }, { "docid": "69ed86f6e5a9203cf8ec55852fc1e5d7", "score": "0.6001187", "text": "nahdleValueChange(e){\n console.log(e.target.value);\n this.setState({\n qty:e.target.value\n })\n }", "title": "" }, { "docid": "d8bd895b9707c3f5ffae84e0cf722db6", "score": "0.598657", "text": "function handleNumberBtn() {\n\n // clear the terminal if asked\n if (shouldClearTerminal) {\n clearTerminal()\n shouldClearTerminal = false\n }\n\n setTerminalValue(getTerminal().value + this.innerHTML)\n }", "title": "" }, { "docid": "8ec5a968dc39e44bb87decbbe71c0883", "score": "0.596615", "text": "handleChange(item) {\n return e => {\n this.setState(\n {\n id: item.id,\n product_id: item.product_id,\n quantity: e.currentTarget.value\n },\n () => this.props.updateCartItem(this.state)\n );\n };\n }", "title": "" }, { "docid": "186e8b08a23e06ee4bcc08f0c8f3ecd1", "score": "0.5961141", "text": "function Increase()\r\n{\r\n let quantity = document.getElementById(\"quantity\").innerHTML;\r\n document.getElementById(\"quantity\").innerHTML = ++quantity;\r\n}", "title": "" }, { "docid": "0312dc25fcd89da4e8adcee760d90d0b", "score": "0.5956695", "text": "function changeQuantityProduct() {\n var $trProduct = $(this).parents('tr');\n var $btnWithDiscount = $trProduct.find('button.discount');\n var data = {\n 'code': $trProduct.data('code'),\n 'with_discount': $btnWithDiscount.data('discount'),\n 'quantity': Number($(this).val())\n };\n ajaxChangeProduct(data, url_change_product, 'post');\n}", "title": "" }, { "docid": "d3936294a4bdf28daa3920aa2300fc44", "score": "0.5955609", "text": "function IncreNum(){\n setCount(count+1); //Updating the value on button click\n //Whatever value generated by 'setCount' methos,will get automatically maped to 'count'\n }", "title": "" }, { "docid": "f4367cf2ee5683730bf309fcbf68ee0f", "score": "0.59529716", "text": "onNumberChange(state){\n var modifiedNumber = state.number\n if(modifiedNumber){\n var existing = this.state.numbers.filter(\n (number) => number.id === modifiedNumber.id\n )\n if(existing.length){\n this.state.numbers.splice(\n this.state.numbers.indexOf(existing[0]), 1, Object.assign({}, modifiedNumber))\n }\n\n this.trigger(this.state)\n }\n }", "title": "" }, { "docid": "77f46d5836854ae6ab9cde84f7392d6c", "score": "0.5940296", "text": "function cartNumbers(product, check) {\n let productNumbers = localStorage.getItem('cartNumbers');\n productNumbers = parseInt(productNumbers);\n //if the first time click on cart set the productNumber to 1 else plus 1\n if (productNumbers) {\n if (check == 1) {\n localStorage.setItem('cartNumbers', productNumbers + 1);\n //document.querySelectorAll('.cart span').textContent = productNumbers + 1;\n } else if (check == 0) {\n localStorage.setItem('cartNumbers', productNumbers - 1);\n }\n } else {\n localStorage.setItem('cartNumbers', 1);\n //document.querySelectorAll('.cart span').textContent = 1;\n }\n setItem(product, check);\n}", "title": "" }, { "docid": "bc5b2657be80cb58802294efd841f85a", "score": "0.5928334", "text": "function buttonPressed(number) {\n addToDisplay(number);\n}", "title": "" }, { "docid": "99080a5278f755a265abfa09740c02b4", "score": "0.5927522", "text": "function ProductCarts({ image, title, price, id, quantity, amount }) {\r\n const [{ basket }, dispatch] = useStateValue(0);\r\n\r\n const removeitem = () => {\r\n dispatch({\r\n type: \"REMOVE_FROM_CART\",\r\n id: id,\r\n image: image,\r\n title: title,\r\n price: price,\r\n quantity: quantity,\r\n amount: amount,\r\n });\r\n };\r\n\r\n const addToBasket = () => {\r\n dispatch({\r\n type: \"ADD_TO_BASKET\",\r\n item: {\r\n id: id,\r\n title: title,\r\n image: image,\r\n price: price,\r\n quantity: quantity,\r\n amount: amount,\r\n },\r\n });\r\n };\r\n const decreasecart = () => {\r\n dispatch({\r\n type: \"DECREASE\",\r\n item: {\r\n id: id,\r\n title: title,\r\n image: image,\r\n price: price,\r\n quantity: quantity,\r\n amount: amount,\r\n },\r\n });\r\n };\r\n return (\r\n <div className=\"container row\">\r\n <div className=\" col md-6 productcartdetails\">\r\n <img className=\"productcart_imagepro\" src={image} alt=\"\" />\r\n <div className=\"productcartinfo\">\r\n <p className=\"productcart_title\">{title}</p>\r\n\r\n <p className=\"productcartprice\">\r\n <small>$</small>\r\n\r\n <strong>{price}</strong>\r\n </p>\r\n\r\n <button className=\"remove_button\" onClick={removeitem}>\r\n REMOVE TO CART\r\n </button>\r\n\r\n <div>\r\n <button className=\"increase\" onClick={addToBasket}>\r\n +\r\n </button>\r\n {quantity}\r\n <button className=\"decrease\" onClick={decreasecart}>\r\n -\r\n </button>\r\n </div>\r\n <p> Total amount:${amount}</p>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}", "title": "" }, { "docid": "6251984663204e11c5eece8093435d1f", "score": "0.5925388", "text": "function onClick() {\n // dispatch(counterActions.counterAction);\n //setCounter(counter + 1);\n //this.props.actions.counter(counter);\n // dispatch(counterActions.counterAction(counter));\n }", "title": "" }, { "docid": "199a9f9b0728aebd81ef5a25a3e9acdf", "score": "0.59057766", "text": "function ItemCount({ stock, initial, onAdd }) {\n const [counter, setCounter] = useState(initial);\n\n // SE CREAN LAS FUNCIONES DE LOS BOTONES\n function incrementar() {\n if (counter < stock) {\n setCounter(counter + 1);\n }\n }\n\n function decrementar() {\n if (counter > initial) {\n setCounter(counter - 1);\n }\n }\n\n return (\n <>\n <div className=\"cardCounter\">\n {/* // VALOR DEL CONTADOR */}\n <button\n className=\"btnCounter\"\n // * CAPTURA EL CLICK Y ACTIVA LA FUNCION DECREMENTAR\n onClick={decrementar}\n >\n <FontAwesomeIcon\n className=\"minusCircle\"\n icon=\"minus-circle\"\n />\n </button>{\" \"}\n <p className=\"counterNumber\"> {counter} </p>\n <button\n className=\"btnCounter\"\n // * CAPTURA EL CLICK Y ACTIVA LA FUNCION INCREMENTAR\n onClick={incrementar}\n >\n <FontAwesomeIcon\n className=\"plusCircle\"\n icon=\"plus-circle\"\n />\n </button>\n </div>\n <div className=\"cardCounter\">\n <button className=\"add\" onClick={() => onAdd(counter)}>\n Agregar al Carrito\n </button>{\" \"}\n </div>{\" \"}\n \n </>\n );\n}", "title": "" }, { "docid": "ea788257a33e48f8355ffdc8683de446", "score": "0.5904692", "text": "function changeQuantityOfProduct(rowNumber, order){\n\tif (order[rowNumber].quantity == 0) removeProduct(rowNumber, order);\n\telse {\n\t\tvar quantity='<td>' + order[rowNumber].quantity + '</td>', name='<td>' + order[rowNumber].name + '</td>' + '<td>' + order[rowNumber].price + '€</td>';\n\t\t$('#orderTable tr').eq(rowNumber).html(quantity + name + DECREMENT_BUTTON_HTML);\n\t}\n\t$(\".totalPrice\").html(sessionStorage[\"orderPrice\"]);\n}", "title": "" }, { "docid": "eae9a13f32836db7a88643e6458d8065", "score": "0.5900639", "text": "function QuantityPlus(el) {\n var qtyInput = $(el).parent('.plus-minus-box').find(\"input\");\n\n // increase by 1\n let newVal = parseInt($(qtyInput).val() ) + 1;\n qtyInput.val(newVal);\n\n}", "title": "" }, { "docid": "af78fb036670d7855ff4c1f9cf339881", "score": "0.58975357", "text": "setquantity(index, id, value, item) {\n console.log(\"prod Qty\", value)\n console.log(\"product data\", this.state.fetcheddata.data[index])\n // checking that updated qty of product is matched to existing qty for avoiding more hits to API \n if (value == this.state.fetcheddata.data[index].quantity)\n return\n this.state.fetcheddata.data[index].quantity = value\n this.setState({ Loading: true })\n let formData = new FormData();\n formData.append(\"product_id\", id)\n formData.append(\"quantity\", value)\n GlobalAPI(editcart, \"POST\", formData, null, response => {\n if (response.status == 200) {\n Vibration.vibrate(200)\n this.state.fetcheddata.total = this.state.fetcheddata.total - this.state.fetcheddata.data[index].product.sub_total\n // console.log(\"subtotal\", this.state.fetcheddata.data[index].product.sub_total)\n var cost = this.state.fetcheddata.data[index].product.cost\n var total = cost * value\n // this.state.fetcheddata.total = this.state.fetcheddata.total - this.state.fetcheddata.total - this.state.fetcheddata.data[index].product.sub_total\n item.product.sub_total = total\n this.state.fetcheddata.total = this.state.fetcheddata.total + total\n // console.log(\"cost\", total)\n Toast.show({\n text: 'Quantity Updated.',\n duration: 2000,\n type: \"success\"\n })\n this.setState({\n Loading: false,\n }\n );\n }\n },\n error => {\n this.setState({\n Loading: false,\n })\n Toast.show({\n text: 'No Internet Connection.',\n duration: 2000,\n type: \"danger\"\n })\n console.log(error)\n }\n )\n return true\n }", "title": "" }, { "docid": "5c8c2ec56f339d8a26f81a8881aa9f71", "score": "0.58936256", "text": "countManipulations (action) {\n console.log(action)\n switch(action) {\n case 'Add1':\n // setstate callback gets previous state and props as args (previousState, props) =>\n this.setState((previousState) => { return { count: previousState.count + 1 } })\n return\n case 'Sub1':\n this.setState((previousState) => { return { count: previousState.count - 1 }})\n return\n case 'Add5':\n this.setState((previousState) => { return { count: previousState.count + 5 }})\n return \n case 'Sub5':\n this.setState((previousState) => { return { count: previousState.count - 5 } } )\n }\n\n }", "title": "" }, { "docid": "8cb55c99390a55095b8a95601b694f7b", "score": "0.58874255", "text": "qtyChange(movie, value, formatId) {\n var cartArray = JSON.parse(localStorage.getItem('cartList'));\n \n for(var i=0; i<cartArray.length; i++) {\n if (cartArray[i].movieId === movie.id && cartArray[i].formatId === formatId) {\n cartArray[i].qty = value;\n }\n }\n localStorage.setItem('cartList', JSON.stringify(cartArray));\n this.setState({\n cartList: cartArray\n });\n this.getCart();\n }", "title": "" }, { "docid": "f5a28d704248d06eafe993853fab2bfc", "score": "0.5881047", "text": "increment(e) {\n const current = this.state;\n current.counter += 1;\n this.setState(current);\n }", "title": "" }, { "docid": "16981de4d19d31944c760c238fa7ef67", "score": "0.5880893", "text": "function cartNumber(product) {\n let productNumbers = localStorage.getItem('cartNumbers');\n\n productNumbers = parseInt(productNumbers);\n\n if (productNumbers) {\n localStorage.setItem('cartNumbers', productNumbers + 1);\n document.querySelector('.shopping-cart span').textContent = productNumbers + 1;\n } else {\n localStorage.setItem('cartNumbers', 1);\n document.querySelector('.shopping-cart span').textContent = 1;\n }\n\n setItems(product);\n}", "title": "" }, { "docid": "c07d75fd49e9fe79dba19e002f065694", "score": "0.587843", "text": "_onPressButton() {\n let count = this.state.counter + 1;\n this.setState({ counter: count });\n }", "title": "" }, { "docid": "61c508779551df4c432e47dd7aa095bf", "score": "0.5876937", "text": "function updateCounter() {\n\tlet quantityElement = document.getElementById('quantity');\n let itemCount = document.getElementById('itemCount');\n if (itemCount.textContent !== '') {\n itemCount.textContent =\n parseInt(itemCount.textContent) + parseInt(quantityElement.value);\n console.log(quantityElement.value);\n } else {\n itemCount.textContent = parseInt(quantityElement.value);\n }\n}", "title": "" }, { "docid": "47ac2a6a4024913e00e83ce653541371", "score": "0.5875352", "text": "renderQuantity( itemId, quantity, listId, unit ) {\n if( this.state.editMode === false) {\n return( quantity );\n }\n else {\n console.log( 'Edit Mode State:', this.state )\n if ( listId === this.state.editList ) {\n if( itemId === this.state.editItem ) {\n return <>\n <input\n type=\"number\"\n value={this.state.editQuantity}\n onChange={event => this.handleChange(event, itemId, listId)}\n id=\"edit-quantity-input\"> \n </input>\n </>\n }\n else {\n return( quantity );\n }\n }\n else {\n return( quantity );\n }\n }\n }", "title": "" }, { "docid": "334e373cdc6718a34b299cd9ec37f031", "score": "0.58711994", "text": "function plusButton(index){\r\n if(cartContent[index].quantity < 9 ){\r\n limitCounter += 1\r\n displayCounterLocal += 1\r\n console.log(\"+1\")\r\n cartContent[index].quantity += 1\r\n if (index == \"0\"){\r\n perso0 += 1\r\n }else if(index == \"1\"){\r\n perso1 += 1\r\n }else if(index == \"2\"){\r\n perso2 += 1\r\n }else if(index == \"3\"){\r\n perso3 += 1\r\n }else if(index == \"4\"){\r\n perso4 += 1\r\n }else if(index == \"5\"){\r\n perso5 += 1\r\n }\r\n updatediv()\r\n }else{\r\n alert(\"Your maximum of 9 items is reached\")\r\n }\r\n}", "title": "" }, { "docid": "987b84eae0b6738001d41a177b98841d", "score": "0.5869622", "text": "onClick() {\n this.setState({\n name: 'Yoohoo!! is clicked for ',\n value: this.state.value + 1\n })\n }", "title": "" }, { "docid": "33868d583946e5a8c915a0cb41d2fe5b", "score": "0.5863824", "text": "minusQty() {\n if (this.props.product) {\n let currentQty = parseFloat(this.state.currentQty);\n let addQtyIncrement = this.getProductStockService(this.props.product)\n .getAddQtyIncrement(this.props.product);\n currentQty = NumberHelper.minusNumber(currentQty, addQtyIncrement);\n if (currentQty < addQtyIncrement) {\n currentQty = addQtyIncrement;\n }\n this.validateQty(this.props.product, currentQty);\n this.setState({currentQty: String(currentQty)});\n this.collectPrice(this.props.product, currentQty);\n this.qty_element.value = currentQty;\n }\n }", "title": "" }, { "docid": "64f93fe34017ed81ac567ade67fa613d", "score": "0.585659", "text": "function setAmountClicked() {\n const theInput = this.parentElement.querySelector(\"input\");\n if (this.classList.contains(\"minus\") && theInput.value >= 1) {\n theInput.value--;\n } else if (this.classList.contains(\"plus\")) {\n theInput.value++;\n document.querySelector(\"#order p\").classList.remove(\"error\");\n }\n}", "title": "" }, { "docid": "5d47e9463fe21ee9dbaa73807ff84dc9", "score": "0.58522606", "text": "function updateMessageCounter(action, num) {\n var message_count = parseInt($('.message-counter').text());\n switch (action) {\n case '+':\n if (isNaN(message_count)) {\n $('.message-counter').text(num);\n } else {\n $('.message-counter').text(message_count + num);\n }\n break;\n case '-':\n if (message_count - num < 1) {\n $('.message-counter').text('');\n } else {\n $('.message-counter').text(message_count - num);\n }\n break;\n }\n}", "title": "" }, { "docid": "1ae87949ae5ba24dd5687b5a13eeff19", "score": "0.5849824", "text": "function cartNumbers(product){\n let productNumbers = localStorage.getItem('cartNumbers');\n\n productNumbers = parseInt(productNumbers);\n\n // console.log(productNumbers);\n\n //if item exist, add one\n if(productNumbers){\n localStorage.setItem('cartNumbers', productNumbers + 1);\n document.querySelector('.cart span').textContent = productNumbers + 1;\n }else{ //else, make it one\n localStorage.setItem('cartNumbers', 1);\n document.querySelector('.cart span').textContent = 1;\n }\n setItems(product);\n}", "title": "" }, { "docid": "dae3a6da78661e8c61b381c69c217d1f", "score": "0.5849087", "text": "addCartItem (state, product) {\n if (product.id in state.cart) {\n state.cart[product.id].quantity++\n } else {\n state.cart[product.id] = {\n ...product,\n quantity: 1\n }\n }\n state.cartTotalItems++\n }", "title": "" }, { "docid": "4b4f0c2b45155de92470c726ce2c652c", "score": "0.58433646", "text": "handleMultiplier () {\n this.setState({ myNum: this.state.myNum * 10 });\n this.setState({ myNum2: this.state.myNum2 * 10 });\n }", "title": "" }, { "docid": "8837ad35228dc0fc6ad8c3443a640f03", "score": "0.5843099", "text": "function increase(productID, button) {\n //access the function 'increaseProductAmount' from nettbutikk_base.js\n store.increaseProductAmount(productID)\n let amount = store.getShoppingCartElementById(productID).amount\n updateAmountLabel(amount, button.parentElement.parentElement)\n let decreaseButton = button.parentElement.querySelector('.button-deactivate-wrapper')\n // Increase should always activate button\n activateButton(decreaseButton)\n updateData()\n}", "title": "" } ]
d824d7f359ca74480cef8be77a2b9cf8
TOOLTIP PLUGIN DEFINITION =========================
[ { "docid": "707692eacd6cf691cd7330a5538c5dc6", "score": "0.0", "text": "function Plugin(option) {\n return this.each(function () {\n var $this = $(this)\n var data = $this.data('bs.tooltip')\n var options = typeof option == 'object' && option\n\n if (!data && option == 'destroy') return\n if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n if (typeof option == 'string') data[option]()\n })\n }", "title": "" } ]
[ { "docid": "c5d8f266cfc9588c33c7baa8a84f81c2", "score": "0.7224154", "text": "function uitooltipfn(){\n\tjQuery.widget.bridge('uitooltip', jQuery.ui.tooltip);\n\t//jQuery.widget.bridge(\"tlp\", jQuery.ui.tooltip);\n jQuery('.mk-member').uitooltip();\n}", "title": "" }, { "docid": "c5e8aab5623e819181a232d5b03a8d3f", "score": "0.69535863", "text": "function bindTooltip(){\n bindTooltipSkin(\".b-tooltip, .b-panel-icons-item a,.b-tool, .b-image-nav, .b-help, .b-title\",\"qtip-light\");\n }", "title": "" }, { "docid": "5f6cde95534c26e30853cb770b0b3d0f", "score": "0.68889034", "text": "constructor() {\n this.$el = $(TOOLTIP_CONTENT);\n this.$el.appendTo('body');\n this.hide();\n }", "title": "" }, { "docid": "513b3ebef495e59299b831a039b53d2b", "score": "0.6857685", "text": "function initializeTips() {\n logger.info(\"GDP:root.js::initializeTips(): Initializing Tips.\");\n $(\".tooltip img\").hover(\n function() {\n $(this).attr('src', 'images/question-mark-hover.png');\n\t\t},\n function() {\n $(this).attr('src', 'images/question-mark.png');\n\t\t}\n\t);\n $(\".tooltip\").tipTip({\n 'maxWidth': '50%',\n 'delay': 100,\n 'fadeIn' : Constant.ui.fadeSpeed,\n 'fadeOut' : Constant.ui.fadeSpeed,\n 'fadeOutDelay' : Constant.ui.tip.fadeout.timeout,\n 'keepAlive' : true,\n 'activation' : 'click', \n 'enter': function() { // keep alive\n logger.trace('Showing tip');\n $(\"#tiptip_content\").css('text-align', 'left');\n }\n });\n}", "title": "" }, { "docid": "d86fa9e1d06052aa2c1a4412c0496027", "score": "0.68052894", "text": "function tooltip() {\n link_title(\"a.tip\", \"tooltip\");\n}", "title": "" }, { "docid": "06903c76ba4c748e6983e25fe3e7a8c8", "score": "0.67824954", "text": "function Ct(e,t){var o=st();o.className=\"tippy-popper\",o.id=\"tippy-\".concat(e),o.style.zIndex=\"\"+t.zIndex,t.role&&o.setAttribute(\"role\",t.role);var r=st();r.className=\"tippy-tooltip\",r.style.maxWidth=t.maxWidth+(\"number\"==typeof t.maxWidth?\"px\":\"\"),r.setAttribute(\"data-size\",t.size),r.setAttribute(\"data-animation\",t.animation),r.setAttribute(\"data-state\",\"hidden\"),St(r,\"add\",t.theme);var i=st();return i.className=\"tippy-content\",i.setAttribute(\"data-state\",\"hidden\"),t.interactive&&gt(o,r),t.arrow&&r.appendChild(ut(t.arrowType)),t.animateFill&&(r.appendChild(yt()),r.setAttribute(\"data-animatefill\",\"\")),t.inertia&&ht(r),mt(i,t),r.appendChild(i),o.appendChild(r),o}", "title": "" }, { "docid": "7f1d0515d53b53477044452ba1fb70ef", "score": "0.6699419", "text": "function setupTooltips() {\n\t\t\t\t$this.find('.comment-likes a[rel=tooltip]').tooltip();\n\t\t\t}", "title": "" }, { "docid": "a88e28ffaa5bd93d7b8c338e84fd1b69", "score": "0.66739726", "text": "function setupTooltip(number, letter) {\r\n eval(\"var tooltip_\"+letter+number+\" = new Tooltip('\"+letter+\"trigger_\"+number+\"', '\"+letter+\"tooltip_\"+number+\"')\");\r\n\t /*Event.observe(window,\"load\",function() {\r\n\t $$(\"*\").findAll(function(node){\r\n\t return node.getAttribute('title');\r\n\t }).each(function(node){\r\n\t new Tooltip(node,node.title);\r\n\t node.removeAttribute(\"title\");\r\n\t });\r\n\t });*/\r\n}", "title": "" }, { "docid": "f0d942caf3379290ab4de389de20404d", "score": "0.6663568", "text": "function createRolloverTips() {\n\n\tvar alt;\n\tvar href;\n\tvar prod;\n\tvar title;\n\tvar desc;\n\tvar label;\n\tvar bubbleContent;\n\n\t$('.editorial_wrapper area[class~=\"rollover\"]').each( function(i) {\n\t\tvar $this = $(this);\n\n\t\thref = $this.attr(\"href\");\n\t\talt = $this.attr(\"alt\");\n\t\ttitle = '';\n\t\tdesc = '';\n\t\tlabel = '';\n\t\tif ( alt !== undefined )\n\t\t{\n\t\t\t// console.log(alt);\n\t\t\tprod = alt.split(\"|\");\n\t\t\ttitle = prod[0];\n\t\t\tdesc = prod[1];\n\t if( prod.length > 1 ) {\n\t label = prod[2];\n\t }\n\t // console.log(label);\n\t\t}\n\n \tbubbleContent = buildBubble(href, title, desc, label, $this);\n\n \t$this.qtip({\n \t\tcontent: {\n\t\t \ttext: bubbleContent\n\t\t },\n\t\t events: {\n\t\t render: function(event, api) { //this event is triggered when the tooltip is rendered (not on page load and only once)\n\t\t \tconsole.log(\"!!!RENDERING TOOLTIP!!!\");\n\t\t updateTip($this);\n\t\t }\n\t\t },\n\t\t style: {\n\t\t classes: 'qtip-matches'\n\t\t },\n\t\t position: {\n\t\t my: 'center center', // Position my top left...\n\t\t at: 'center center' // at the bottom right of...\n\t\t },\n\t\t show: {\n\t\t solo: true\n\t\t // delay: 200\n\t\t },\n\t\t hide: {\n\t\t fixed: true\n\t\t //delay: 100\n\t\t }\n \t});\n\t});\n}", "title": "" }, { "docid": "3ff230a7846eb950c0020d26cf62b4ad", "score": "0.6659906", "text": "function Plugin(option){return this.each(function(){var $this=$(this);var data=$this.data('bs.tooltip');var options=(typeof option===\"undefined\"?\"undefined\":_typeof(option))=='object'&&option;if(!data&&/destroy|hide/.test(option))return;if(!data)$this.data('bs.tooltip',data=new Tooltip(this,options));if(typeof option=='string')data[option]();});}", "title": "" }, { "docid": "ec79e8bbdcdfc2b8565fad229bf3db53", "score": "0.6615234", "text": "function Tooltip(params) {\n var el = dom(params.target)[0];\n\n var tooltip = document.createElement('div');\n tooltip.classList.add('tooltip');\n tooltip.classList.add(params.type);\n tooltip.innerHTML = params.content;\n\n // Create tip\n\n if(typeof params.tip !== 'undefined' && params.tip != false) {\n var tip = document.createElement('div');\n tip.className = 'tip';\n\n switch(params.tipPosition) {\n case 'left':\n tip.style.left = '2%';\n break;\n case 'center':\n case 'middle':\n tip.style.left = '50%';\n break;\n case 'right':\n tip.style.left = '93%';\n break;\n default:\n tip.style.left = '50%';\n }\n\n tooltip.appendChild(tip);\n\n var tipHeight = tooltip.offsetHeight;\n }\n\n\n var show = function() {\n if(this.position == 'top') {\n var parentEl = this.el.parentNode;\n parentEl.insertBefore(tooltip, this.el);\n tooltip.style.top = '-2px';\n if(typeof tip !== 'undefined') {\n dom(tip).addClass('top');\n tip.style.top = tooltip.offsetHeight;\n }\n\n if(this.overlay) {\n // Calculating absolute position of the overlayed tooltip\n var offsetTop = this.el.offsetTop - this.tooltip.offsetHeight - 5;\n dom(this.tooltip).addClass('tooltip-overlay');\n dom(this.tooltip).css('top', offsetTop);\n }\n\n } else {\n tooltip.style.top = '2px';\n dom(tooltip).insertAfter(el);\n if(typeof tip !== 'undefined') {\n dom(tip).addClass('bottom');\n tip.style.top = '-10px';\n }\n\n if(this.overlay) {\n // Calculating absolute position of the overlayed tooltip\n var offsetTop = this.el.offsetTop + this.el.offsetHeight + 5;\n dom(this.tooltip).addClass('tooltip-overlay');\n dom(this.tooltip).css('top', offsetTop);\n }\n }\n\n dom(this.tooltip).addClass('tooltip-fadein');\n\n if(typeof params.timeout !== 'undefined') {\n window.setTimeout(hide, params.timeout);\n }\n }\n\n var hide = function() {\n dom(tooltip).addClass('tooltip-fadeout');\n dom(tooltip).removeClass('tooltip-fadein');\n window.setTimeout(function(){\n dom(tooltip).remove();\n }, 300);\n }\n\n var toggle = function() {\n dom(this.tooltip).hasClass('tooltip-fadein') ? this.hide() : this.show();\n }\n\n return {\n hide: hide,\n show: show,\n toggle: toggle,\n tooltip: tooltip,\n el: el,\n overlay: params.overlay,\n position: params.position,\n tip: tip,\n tipHeight: tipHeight\n };\n}", "title": "" }, { "docid": "c65a527b4345779c117c7ff16d89a640", "score": "0.65979075", "text": "function createTooltipHelp(idOfElement, contentOfTooltip) {\n\tAUI().ready('aui-tooltip', 'aui-io-plugin', function(A) {\n\t\tnew A.Tooltip({\n\t\t\ttrigger : '#' + idOfElement,\n\t\t\tbodyContent : Liferay.Language.get(contentOfTooltip),\n\t\t}).render();\n\t});\n}", "title": "" }, { "docid": "6503fcc809d25bfe59a75a3605d6c4fe", "score": "0.6587073", "text": "function Plugin(option){return this.each(function(){var $this=$(this);var data=$this.data('bs.tooltip');var options=_typeof(option)=='object'&&option;if(!data&&/destroy|hide/.test(option))return;if(!data)$this.data('bs.tooltip',data=new Tooltip(this,options));if(typeof option=='string')data[option]();});}", "title": "" }, { "docid": "720d89e2d82872afa13ec06359da1589", "score": "0.65778834", "text": "function initializeTooltips(){\n $('.owner-detail').tooltip({\n title: getTooltipContent,\n html: true,\n container: 'body'\n });\n}", "title": "" }, { "docid": "1dad5aae9d503e5630c104ba20c18529", "score": "0.6548983", "text": "function tooltipfn(){\n jQuery('[data-km-toggle=\"tooltip\"]').tooltip({\n placement : 'bottom',\n trigger : 'hover'\n });\n}", "title": "" }, { "docid": "a530fdbb5c01f5ad665f6b4831c1ff04", "score": "0.6540481", "text": "function setToolTip() {\n\t$(\"[title]\").tooltip({ track: true });\n\t}", "title": "" }, { "docid": "e6613c8b22cb4bfd648dd3d19e609d10", "score": "0.6526132", "text": "tooltip({ replace = false, position = null, size = null, spaced = null, text = '', fontName = '14pt Verdana', duration = null, event = new EventData(this.R.get.events_tooltipDismissed), background = null, fontColor = null }) {\n // Set the default\n spaced = spreadToObject(spaced, new BABYLON.Vector2(0, 0))\n if ((duration === null) || (duration.constructor !== Promise)) {\n if ((duration !== null) && (duration.constructor === Number)) {\n duration = delay(duration)\n } else {\n duration = (new Deferred()).promise\n }\n }\n\n const guiCanvas = this.get('GUI')\n guiCanvas.levelVisible = true\n\n const brownColor = [112 / 255, 102 / 255, 98 / 255, 0.95]\n\n let tooltips = this.get('tooltips', [])\n if (tooltips.constructor === Object) {\n tooltips = [tooltips]\n }\n const id = tooltips.length + 1\n\n let tooltip = null\n if (replace && tooltips.length) {\n tooltip = tooltips[tooltips.length - 1]\n } else if (tooltips.length) {\n for (const temptool of tooltips) {\n if (typeof temptool.box !== 'undefined') {\n temptool.box.zOrder = (id - temptool.id) * 0.01\n temptool.text.zOrder = ((id - temptool.id) * 0.01) - 0.001\n }\n if ((typeof temptool.disposed !== 'undefined') && (temptool.disposed)) {\n temptool.box.zOrder = 0.001\n temptool.text.zOrder = 0\n tooltip = temptool\n background = spreadToObject(background, new BABYLON.Color4(...brownColor))\n break\n }\n }\n }\n\n\n if (tooltip !== null) {\n tooltip.text.levelVisible = true\n tooltip.box.levelVisible = true\n\n tooltip.text.text = text\n\n const tempPosition = tooltip.box.position.add(sizeToVec(tooltip.box.size).scale(0.5))\n if (size === null) {\n tooltip.box.width = tooltip.text.size.width + 24\n tooltip.box.height = tooltip.text.size.height + 24\n } else {\n tooltip.box.width = size.width\n tooltip.box.height = size.height\n }\n\n if (background !== null) {\n background = spreadToObject(background, new BABYLON.Color4(...brownColor))\n const brush = BABYLON.Canvas2D.GetSolidColorBrush(background)\n tooltip.box.fill = brush\n }\n\n fontColor = spreadToObject(fontColor, new BABYLON.Color4(1, 1, 1, 1))\n\n tooltip.text.defaultFontColor = fontColor\n\n\n position = spreadToObject(position, tempPosition)\n const nextPos = position.subtract(sizeToVec(tooltip.box.size).scale(0.5).add(spaced))\n // TODO make a bounding function to make sure the tooltip is visible depending on the rendersize the position and size of the tooltip\n tooltip.box.position = nextPos\n tooltip.promise = duration\n tooltip.event = event\n tooltip.disposed = false\n } else {\n position = spreadToObject(position, new BABYLON.Vector2(0, 0))\n\n const sizeDefault = spreadToObject(size, new BABYLON.Size(300, 300))\n\n // const normalColor = [202 / 255, 64 / 255, 0, 0.95]\n\n // let fontSuperSample = true\n // let fontSignedDistanceField = false\n // if (background === null) {\n // fontSuperSample = false\n // fontSignedDistanceField = true\n // }\n\n const fontSuperSample = false\n const fontSignedDistanceField = true\n background = spreadToObject(background, new BABYLON.Color4(...brownColor))\n fontColor = spreadToObject(fontColor, new BABYLON.Color4(1, 1, 1, 1))\n\n const brush = BABYLON.Canvas2D.GetSolidColorBrush(background)\n\n const tooltipBox = new BABYLON.Rectangle2D({\n parent: guiCanvas,\n id: `tooltipBox${tooltips.length}`,\n // position: position.subtract(size.scale(0.5).add(spaced)),\n width: sizeDefault.width,\n height: sizeDefault.height,\n // border: brush,\n // borderThickness: 2,\n fill: brush,\n })\n\n const tooltipText = new BABYLON.Text2D(text, {\n parent: tooltipBox,\n id: `tooltipText${tooltips.length}`,\n marginAlignment: 'h: center, v:center',\n defaultFontColor: fontColor,\n fontSuperSample,\n fontSignedDistanceField,\n fontName,\n })\n\n if (size === null) {\n tooltipBox.width = tooltipText.size.width + 24\n tooltipBox.height = tooltipText.size.height + 24\n }\n\n tooltipBox.position = position.subtract(sizeToVec(tooltipBox.size).scale(0.5).add(spaced))\n\n\n tooltip = { box: tooltipBox, text: tooltipText, promise: duration, id, disposed: false, event }\n\n\n this.set('tooltips', tooltips.concat(tooltip))\n }\n\n duration.then(() => {\n if (tooltip.promise === duration) {\n this.hideTooltip(tooltip)\n }\n if (event.constructor === EventData) {\n event.happenedAt = this.timeInMs\n this.addEvent(event)\n }\n })\n\n return tooltip\n }", "title": "" }, { "docid": "9c307f688886d350961a8b45122aa189", "score": "0.6520307", "text": "function createToolTip(target,ttip,title,anchor,trackMouse){\n Ext.create('Ext.tip.ToolTip',{\n target: target, //Target to apply ToolTip (id of the component in which ttip has to be applied.)\n html: ttip, //ToolTip message\n title:title, //Title of ToolTip\n anchor: anchor, //Position of ToolTip\n trackMouse: trackMouse//Move with mouse or not\n });\n}", "title": "" }, { "docid": "e2765109c91fd210211a58e9498d8f95", "score": "0.65178484", "text": "showToolTip_(event) {\n this.updateToolTip_(event);\n }", "title": "" }, { "docid": "772ae9fdee3d3d99e381510ac05e3f60", "score": "0.64938486", "text": "function initTooltips() {\n /// <summary>\n /// initialize tooltips for the datagrid\n /// </summary>\n popupManager.registerPopup(sectionNode, \"hoverIntent\",\n function () {\n if (this.target.attr(\"title\")) {\n if (this.target.isOverflowed()) {\n this.target.tooltipster({ theme: '.tooltipster-dark' }).tooltipster(\"show\");\n } else {\n this.target.removeAttr(\"title\");\n }\n }\n },\n {\n handleSelector: \".point-name, .category-name, .title-span\",\n useAria: false,\n timeout: 500\n }\n );\n }", "title": "" }, { "docid": "3d7056f0956720ecca9a2cf7d7a01f2d", "score": "0.64905006", "text": "function EllipsisToolTipOnSlider() {\n //debugger;\n\n // ellipsis\n $('.description:not(.tooltip-temp)').dotdotdot({\n ellipsis: ' ..........'\n });\n\n // tool tip - append\n var ellipsisShortDescriptionElements = $('.description:contains(\" ..........\")');\n\n for (var i = 0; i < ellipsisShortDescriptionElements.length; i++) {\n\n var shortDescription = ellipsisShortDescriptionElements[i].innerHTML;\n var longDescription = ellipsisShortDescriptionElements[i].title;\n\n // vtipRight - right side\n shortDescription = shortDescription.replace('..........', '...<div title=\"' + longDescription + '\" class=\"ui-icon ui-icon-newwin vtipRight\" style=\"float: right; margin-right: 8px; margin-top: 7px; border: 0px solid black;\"></div>');\n\n ellipsisShortDescriptionElements[i].innerHTML = shortDescription;\n }\n\n // add new class to make it unique\n $('.description').addClass('tooltip-temp');\n\n // remove title\n $('.description').removeAttr(\"title\");\n\n // call tool tip functionality\n // right hand side tool tip\n vtipRight();\n}", "title": "" }, { "docid": "32b00caf8fd335c43130b60fdef5f626", "score": "0.6487378", "text": "function initializeTooltips(){\n $('.reservation-detail').tooltip({\n title: getTooltipContent,\n html: true,\n container: 'body'\n });\n}", "title": "" }, { "docid": "dcecae33d90bd61e11c7b0cf8e1f3916", "score": "0.6482671", "text": "function addHelp()\n{\n\tvar helps = [\n\t\t[ \"#countryHelp\",\t\t\"Select the countries to display data for.\",\t\t\t\t\t\t\t\t\t\t\t\t\"left center\",\t\t\"right center\" ],\n\t\t[ \"#viewHelp\",\t\t\t\"Select which view to show.\",\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"left center\",\t\t\"right center\" ],\n\t\t[ \"#filterHelp\",\t\t\"Select the specific filters to apply to the data.\",\t\t\t\t\t\t\t\t\t\t\"left center\",\t\t\"right center\" ],\n\t\t[ \"#eventHelp\",\t\t\t\"Opens a window to select the events to display data for.\",\t\t\t\t\t\t\t\t\t\"left center\",\t\t\"right center\" ],\n\t\t[ \"#versionHelp\",\t\t\"Select the version of the vis to display. Please change these based on the survey.\",\t\t\"left center\",\t\t\"right center\" ],\n\t\t[ \"#helpIcon\",\t\t\t\"Help will popup in these tooltips!\",\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"bottom center\",\t\"top center\" ],\n\t\t[ \"#helpIcon2\",\t\t\t\"Help will popup in these tooltips!\",\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"bottom center\",\t\"top center\" ],\n\t\t[ \"#axisHelp\",\t\t\t\"Select which x-axis to use.\",\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"left center\",\t\t\"right center\" ],\n\t\t[ \"#paletteHelp\",\t\t\"Change the colore palette.\",\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"left center\",\t\t\"right center\" ]\n\t];\n\t\n\tfor( var h in helps )\n\t\t$(helps[h][0]).qtip( { content: { text: helps[h][1] }, style: { classes: \"qtip-dark\" }, position: { my: helps[h][2], at: helps[h][3] }, show: { delay: 0 } } )\n}", "title": "" }, { "docid": "f3f49c5a7dd188e7826f608bcbbfa2fd", "score": "0.6459841", "text": "function createToolTips() {\n\n // get the array of tooltips to add if element exists on page.\n var arrToolTips = dataToolTips();\n\n // cycle through array of tooltips.\n $.each(arrToolTips, function(index, obj) {\n\n // look for the matching url.\n if (window.location.href.indexOf(obj.urlIncludes) > -1) {\n\n // check if this is an exception.\n if (obj.theElement.indexOf(\"find.\") > -1) {\n\n // the element does not have a class so we have to look for the\n // html within the element.\n\n // what we will be looking for.\n var theSearchString = \"\";\n\n // split the input string.\n var arrString = obj.theElement.split(\".\");\n\n // we want the second element.\n theSearchString = arrString[1];\n\n // check to see if there is punctuation.\n if (arrString.length == 3) {\n switch (arrString[2]) {\n case \"colon\":\n // append to the string.\n theSearchString += \":\";\n break;\n }\n }\n\n // search for a span with the string.\n var spanSearchResult = $(\"span:contains(\" + theSearchString + \")\");\n\n // decide where to display the img.\n if (obj.isBefore) {\n $(spanSearchResult).before(buildToolTipHtml(obj));\n }\n else {\n $(spanSearchResult).after(buildToolTipHtml(obj));\n }\n }\n else {\n // add the html before the element specified.\n if (obj.isBefore) {\n $(obj.theElement).before(buildToolTipHtml(obj));\n }\n else {\n $(obj.theElement).after(buildToolTipHtml(obj));\n }\n }\n\n }\n }); // end $.each(arrToolTips)\n\n // Grab all elements with the class \"help_div\"\n // make them qtip objects.\n $('.help_div').each(function() { // Notice the .each() loop, discussed below\n $(this).qtip({\n content: {\n text: $(this).next('div') // Use the \"div\" element next to this for the content\n },\n style: {\n classes: 'qtip-dark'\n }\n });\n });\n}", "title": "" }, { "docid": "2314c8b6f88f78686a37318bb8fcbcdc", "score": "0.6453694", "text": "function setUpTips() {\n\tvar tipsButton = $('#tips');\n\n\t// show first hint if tips are enabled\n\tif (APP.tipsEnabled) { \n\t\t$(APP.categoryID).attr('placeholder', \n\t\t\t'');\n\t}\n\t\t\n\t// set up tick handler (toggles style and hint presence)\n\n\t// $('#tips').click(function() {\n\n\t// \tAPP.tipsEnabled = !APP.tipsEnabled;\n\t\t\n\t// \tif (APP.tipsEnabled) {\n\n\t// \t\t$(APP.categoryID).attr('placeholder', '(put category here)');\n\t// \t\t$(APP.subjectID).attr('placeholder', '(put query here)');\n\t// \t\t$(APP.resultsID).attr('placeholder', \n\t// \t\t\t'(start typing here to see result)');\n\n\t// \t\ttipsButton.html(\"&nbsp;&nbsp;&nbsp;X\");\n\t// \t\ttipsButton.css({\"color\":\"#9E9E9E\",\"text-shadow\":\"0 0 3px #fff\"});\n\t// \t} else {\n\t// \t\ttipsButton.html(\"Tips\");\n\t// \t\ttipsButton.css({\"color\":\"#9F9F9F\",\"text-shadow\":\"none\"});\n\t// \t\t$(APP.categoryID).attr('placeholder', '');\n\t// \t\t$(APP.subjectID).attr('placeholder', '');\n\t// \t\t$(APP.resultsID).attr('placeholder', '');\n\t// \t}\n\n\t// });\n}", "title": "" }, { "docid": "6d23752745dbbabbcdfe764ed3c129e0", "score": "0.64516413", "text": "function tooltip(e) {\n\t//TODO\n}", "title": "" }, { "docid": "cd146d0949eac8df8de74866a3535e32", "score": "0.6423498", "text": "function tooltipInit() {\n\tjQuery(\"[data-toggle='tooltip']\").tooltip();\n}", "title": "" }, { "docid": "ffa71e650fb22e072342ca344b4fbb9d", "score": "0.6401511", "text": "function Tooltip() {\n _classCallCheck(this, Tooltip);\n\n this.$el = (0, _jquery2.default)(TOOLTIP_CONTENT);\n this.$el.appendTo('body');\n this.hide();\n }", "title": "" }, { "docid": "ffa71e650fb22e072342ca344b4fbb9d", "score": "0.6401511", "text": "function Tooltip() {\n _classCallCheck(this, Tooltip);\n\n this.$el = (0, _jquery2.default)(TOOLTIP_CONTENT);\n this.$el.appendTo('body');\n this.hide();\n }", "title": "" }, { "docid": "280c9d5076d105ad64259806b829dfef", "score": "0.6391984", "text": "function getHelp() {\n\tvar msg = \"Choose a description for the error you are correcting. Please be as specific as possible while still accurately capturing the error you have identified.\";\n\t$(\"#help\" + num_corr).qtip({\n\t\tcontent : msg,\n\t\tshow : { when : 'mouseover', effect : { type : 'slide', length : '500' } },\n\t\thide : { when : 'mouseout', effect : { type : 'slide', length : '500' } },\n\t\tposition : { target : $(\"#orig\"), corner : { target : 'topMiddle', tooltip : 'topMiddle' } },\n\t\tstyle : { width : { max : 1000 }, name : 'blue' },\n\t\tapi : { beforeShow : function() { hasHelpQtip = true; }, beforeDestroy : function() { hasHelpQtip = false; } }\n\t});\n}", "title": "" }, { "docid": "919c75dea97bcfb502da5fe7e54aa651", "score": "0.637977", "text": "function initTooltip(bookTable) {\n var nodes = $(bookTable.fnGetNodes());\n nodes.each(function() {\n $(this).qtip({\n content: {\n text: 'Loading...',\n ajax: {\n url: _BASE_URL + '/book/tooltip/'+this.id,\n data: 'format=json',\n dataType: 'json',\n success: function(data) {\n var content = 'SYNOPSIS:<br/>';\n content += data[0].Synopsis;\n this.set('content.text', content);\n }\n }\n },\n position: {\n my: 'bottom left',\n at: 'top center',\n target: 'event'\n },\n style: {\n classes: 'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'\n },\n widget: true,\n width: 500,\n show: {\n delay: 1000,\n effect: function(offset) {\n $(this).fadeIn(500);\n }\n\n }\n })\n })\n}", "title": "" }, { "docid": "dbad9c5917113c79a7dda6dcbb3f5b3f", "score": "0.63737214", "text": "function holdTooltip() {\n ttHoldIt = 1;\n swapTooltip('true');\n ttHoldIt = 0;\n}", "title": "" }, { "docid": "9ee65a4d2958bbe420a5ee6fb9606a3a", "score": "0.63651425", "text": "function e(t){var e,i;this.qTipTitle=null,this.qTipText=null,this.qTipInnerHTML=null,null!=(i=/^\\(tooltip: ?(.+)\\|(.+)(?=\\))\\)$/.exec(t.text()))&&3==i.length?(this.qTipTitle=i[1],this.qTipText=i[2],e=/^(.+)\\|/,this.qTipInnerHTML=(i[1]+\"|\"+i[2]).replace(e,\"\")):null!=(i=/^(.+)\\|(.+)$/.exec(t.text()))&&3==i.length?(this.qTipTitle=i[1],this.qTipText=i[2],e=/^(.+)\\|/,this.qTipInnerHTML=t.html().replace(e,\"\")):(this.qTipText=t.text(),this.qTipInnerHTML=t.html())}", "title": "" }, { "docid": "40349913bbd3ed367d88499873152328", "score": "0.63638175", "text": "function loadTiptip() {\n\t$('.tip').tipTip({\n\t\tdefaultPosition : 'top',\n\t\tdelay : 0,\n\t\tmaxWidth : '500px'\n\t});\n}", "title": "" }, { "docid": "6b6eec881f26ff8ea242d2839c44ac0b", "score": "0.6341072", "text": "function org_zmail_example_customtooltip_HandlerObject() {\r\n}", "title": "" }, { "docid": "c2b82352ba1997725959d07351bb2393", "score": "0.63337994", "text": "function sample1bTip (event){\n\tTip('Show the JQPopup with the List of Links to <b>Google Analytics</b>');\n}", "title": "" }, { "docid": "5b4afde461ef493b4f31400813030a0f", "score": "0.6324806", "text": "function sample1aTip (event){\n\tTip('Show the TipFix with the List of Links to <b>Google Analytics</b>');\n}", "title": "" }, { "docid": "5af60a9ba1822b241704b9d4a0ec89da", "score": "0.63150626", "text": "generateToolTip() {\n //Order the data array\n let data = formatArray.collectionToTop(this.data, config.tooltipOrder);\n data = formatArray.collectionToBottom(data, config.tooltipReverseOrder);\n\n if (!(data) || data.length === 0) {\n return generate.noDataWarning(this.name);\n }\n\n //Ensure name is not blank\n this.validateName();\n\n //Generate the expand field option\n const expandFunction = this.displayMore();\n\n if (!(this.data)) { this.data = []; }\n return h('div.tooltip-image', [\n h('div.tooltip-heading', this.name),\n h('div.tooltip-internal', h('div', (data).map(item => generate.parseMetadata(item, true, expandFunction)), this))\n ]);\n }", "title": "" }, { "docid": "fab5a72335c0c7810e565fda045a2ed3", "score": "0.62954557", "text": "addTooltip () {\n let _this = this\n let advancedTexture = GUI.AdvancedDynamicTexture.CreateFullscreenUI('UI')\n\n let tooltip = new GUI.Rectangle('tooltip')\n tooltip.width = '100px'\n tooltip.height = '160px'\n tooltip.color = 'white'\n tooltip.thickness = 1\n tooltip.horizontalAlignment = 0\n tooltip.verticalAlignment = 0\n tooltip.background = '#adadad'\n tooltip.isVisible = false\n\n let button1 = GUI.Button.CreateSimpleButton('but', 'Translate')\n this._customTooltip(button1)\n tooltip.addControl(button1)\n button1.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.actualMod = _this.mod.TRANSLATE\n _this.activeMod()\n }\n _this.tooltip.isVisible = false\n })\n\n var button2 = GUI.Button.CreateSimpleButton('but', 'Rotate')\n this._customTooltip(button2)\n button2.top = '20px'\n tooltip.addControl(button2)\n button2.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.actualMod = _this.mod.ROTATE\n _this.activeMod()\n }\n _this.tooltip.isVisible = false\n })\n\n var button3 = GUI.Button.CreateSimpleButton('but', 'Scale')\n this._customTooltip(button3)\n button3.top = '40px'\n tooltip.addControl(button3)\n button3.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.actualMod = _this.mod.SCALE\n _this.activeMod()\n }\n _this.tooltip.isVisible = false\n })\n\n var input1 = new GUI.InputText()\n this._customTooltipInput(input1)\n input1.top = '60px'\n tooltip.addControl(input1)\n\n var button4 = GUI.Button.CreateSimpleButton('but', 'AplyX')\n this._customTooltip(button4)\n button4.top = '60px'\n button4.width = '50px'\n button4.horizontalAlignment = 1\n tooltip.addControl(button4)\n button4.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.doTransform(input1.text, 'X')\n }\n _this.tooltip.isVisible = false\n })\n\n var input2 = new GUI.InputText()\n this._customTooltipInput(input2)\n input2.top = '80px'\n tooltip.addControl(input2)\n\n var button5 = GUI.Button.CreateSimpleButton('but', 'AplyY')\n this._customTooltip(button5)\n button5.top = '80px'\n button5.width = '50px'\n button5.horizontalAlignment = 1\n tooltip.addControl(button5)\n button5.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.doTransform(input2.text, 'Y')\n }\n _this.tooltip.isVisible = false\n })\n\n var input3 = new GUI.InputText()\n this._customTooltipInput(input3)\n input3.top = '100px'\n tooltip.addControl(input3)\n\n var button6 = GUI.Button.CreateSimpleButton('but', 'AplyZ')\n this._customTooltip(button6)\n button6.top = '100px'\n button6.width = '50px'\n button6.horizontalAlignment = 1\n tooltip.addControl(button6)\n button6.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.doTransform(input3.text, 'Z')\n }\n _this.tooltip.isVisible = false\n })\n\n var button7 = GUI.Button.CreateSimpleButton('but', 'Remove')\n this._customTooltip(button7)\n button7.top = '120px'\n tooltip.addControl(button7)\n button7.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.remove()\n }\n _this.tooltip.isVisible = false\n })\n\n var button8 = GUI.Button.CreateSimpleButton('but', 'Toggle')\n this._customTooltip(button8)\n button8.top = '140px'\n tooltip.addControl(button8)\n button8.onPointerUpObservable.add(function (ev) {\n if (ev.buttonIndex === 0) {\n _this.toggle()\n }\n _this.tooltip.isVisible = false\n })\n\n advancedTexture.addControl(tooltip)\n return tooltip\n }", "title": "" }, { "docid": "0171d5f95c3ca27ea66db815659af3b2", "score": "0.6292585", "text": "function tooltipHover() {\n\n function hide() {\n\n timer = window.setTimeout(function () {\n removeTooltip();\n }, 500);\n\n }\n\n $('.reference').mouseover(function (event) {\n window.clearTimeout(timer);\n window.setTimeout(function () {\n createTooltip(event);\n }, settings.delayNo);\n });\n\n $('body').mouseover(function (event) {\n\n var hoverTarget;\n\n if ($('.rsw-tooltip').length) {\n\n mw.log(event.target);\n hoverTarget = $(event.target);\n\n if (hoverTarget.is('.rsw-tooltip, .rsw-tooltip *')) {\n window.clearTimeout(timer);\n return;\n }\n\n hide();\n\n }\n });\n\n }", "title": "" }, { "docid": "596bd1ca8ef1e99da2abb875a16501d9", "score": "0.62658226", "text": "get tooltipClass() { return this._tooltipClass; }", "title": "" }, { "docid": "7ec7880cd0ca01b4abf0a92440df74f5", "score": "0.62657225", "text": "function tooltips ( ) {\r\n\r\n\t\t// Tooltips are added with options.tooltips in original order.\r\n\t\tvar tips = scope_Handles.map(addTooltip);\r\n\r\n\t\tbindEvent('update', function(values, handleNumber, unencoded) {\r\n\r\n\t\t\tif ( !tips[handleNumber] ) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tvar formattedValue = values[handleNumber];\r\n\r\n\t\t\tif ( options.tooltips[handleNumber] !== true ) {\r\n\t\t\t\tformattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]);\r\n\t\t\t}\r\n\r\n\t\t\ttips[handleNumber].innerHTML = formattedValue;\r\n\t\t});\r\n\t}", "title": "" }, { "docid": "957b03b7dcf6cb585889b447247bf38a", "score": "0.6264814", "text": "function setMetaToolTips() {\n $scope.currentZpoint.metaData.metaData.forEach(function (metaField) {\n var tmpSrc = null,\n helpText = \"\";\n\n $scope.currentZpoint.metaData.srcProp.some(function (src) {\n if (metaField.srcProp === src.columnName) {\n tmpSrc = src;\n return true;\n }\n });\n if (mainSvc.checkUndefinedNull(tmpSrc) || mainSvc.checkUndefinedNull(tmpSrc.deviceMapping) || mainSvc.checkUndefinedNull(tmpSrc.deviceMappingInfo)) {\n\n return false;\n }\n metaField.haveToolTip = true;\n helpText += \"<b>Ячейка памяти прибора:</b> \" + tmpSrc.deviceMapping + \"<br><br>\";\n helpText += \"<b>Назначение:</b> <br> \" + tmpSrc.deviceMappingInfo;\n var targetElem = \"#srcHelpBtn\" + metaField.metaOrder + \"srcProp\";\n mainSvc.setToolTip(\"Описание поля источника\", helpText, targetElem, targetElem, 10, 500);\n });\n }", "title": "" }, { "docid": "13a41ca7096b20604ae91d08f165921a", "score": "0.6264168", "text": "function executeQToolTipQuery() {\n $(\".NameTooltip\").hover(function () {\n $(this).append('<div class=\"tooltip\"><p>Method/Function name</p></div>');\n }, function () {\n $(\"div.tooltip\").remove();\n });\n\n $(\".CycXTooltip\").hover(function () {\n $(this).append('<div class=\"tooltip\"><p>Cyclomatic complexity is a metric that tells how many different branches are possible inside a given function. This in turn tells the number of test cases needed to cover all the different paths possible inside the function</p> <p> Recomended upper limit : 20 </p></div>');\n }, function () {\n $(\"div.tooltip\").remove();\n });\n\n $(\".TimeXTooltip\").hover(function () {\n $(this).append('<div class=\"tooltip\"><p>Time complexity O(n)</p> <p> Recomended upper limit : 3 </p></div>');\n }, function () {\n $(\"div.tooltip\").remove();\n });\n\n $(\".MaxNTooltip\").hover(function () {\n $(this).append('<div class=\"tooltip\"><p>Maximum level of nexting in the function</p> <p> Recomended upper limit : </p> </div>');\n }, function () {\n $(\"div.tooltip\").remove();\n });\n\n $(\".NumLinesTooltip\").hover(function () {\n $(this).append('<div class=\"tooltip\"><p>Number of lines in the function. The </p> <p> Recomended upper limit : </p> </div>');\n }, function () {\n $(\"div.tooltip\").remove();\n });\n\n $(\".ParamSizeTooltip\").hover(function () {\n $(this).append('<div class=\"tooltip\"><p>This metric represents the number of fields in a method. Although a large number of fields is not necessarily an indication of bad code, it does suggest the possibility of grouping fields together and extracting classes</p> <p> Recomended upper limit : </p> </div>');\n }, function () {\n $(\"div.tooltip\").remove();\n });\n}", "title": "" }, { "docid": "1f427c04b2ba3b10b410f01aef50eb61", "score": "0.62503886", "text": "function Yt(e,t){/* ======================= 🔒 Private methods 🔒 ======================= */ /**\n * Positions the virtual reference near the cursor\n */function o(e){var t=D=e,o=t.clientX,r=t.clientY;if(z.popperInstance){// Ensure virtual reference is padded to prevent tooltip from\n// overflowing. Maybe Popper.js issue?\nvar i=kt(z.popper),n=z.props.arrow?4+(\"round\"===z.props.arrowType?18:16):4,p=ot([\"top\",\"bottom\"],i),s=ot([\"left\",\"right\"],i),l=p?Lo(n,o):o,d=s?Lo(n,r):r;p&&l>n&&(l=Oo(o,window.innerWidth-n)),s&&d>n&&(d=Oo(r,window.innerHeight-n));var c=z.reference.getBoundingClientRect(),m=z.props.followCursor,f=\"horizontal\"===m,h=\"vertical\"===m;z.popperInstance.reference=Ue({},z.popperInstance.reference,{getBoundingClientRect:function(){return{width:0,height:0,top:f?c.top:d,bottom:f?c.bottom:d,left:h?c.left:l,right:h?c.right:l}},clientWidth:0,clientHeight:0}),z.popperInstance.scheduleUpdate(),\"initial\"===m&&z.state.isVisible&&a()}}/**\n * Creates the tippy instance for a delegate when it's been triggered\n */function r(e){if(e){var o=Ve(e.target,z.props.target);o&&!o._tippy&&(Yt(o,Ue({},z.props,{content:nt(t.content,[o]),appendTo:t.appendTo,target:\"\",showOnInit:!0})),i(e))}}/**\n * Setup before show() is invoked (delays, etc.)\n */function i(e){if(C(),!z.state.isVisible){// Is a delegate, create an instance for the child target\nif(z.props.target)return r(e);if(X=!0,z.props.wait)return z.props.wait(z,e);// If the tooltip has a delay, we need to be listening to the mousemove as\n// soon as the trigger event is fired, so that it's in the correct position\n// upon mount.\n// Edge case: if the tooltip is still mounted, but then scheduleShow() is\n// called, it causes a jump.\ny()&&!z.state.isMounted&&document.addEventListener(\"mousemove\",o);var t=Qe(z.props.delay,0,Li.delay);t?M=setTimeout(function(){T()},t):T()}}/**\n * Setup before hide() is invoked (delays, etc.)\n */function n(){if(C(),!z.state.isVisible)return a();X=!1;var e=Qe(z.props.delay,1,Li.delay);e?I=setTimeout(function(){z.state.isVisible&&A()},e):N=requestAnimationFrame(function(){A()})}/**\n * Removes the follow cursor listener\n */function a(){document.removeEventListener(\"mousemove\",o)}/**\n * Cleans up old listeners\n */function p(){document.body.removeEventListener(\"mouseleave\",n),document.removeEventListener(\"mousemove\",W)}/**\n * Event listener invoked upon trigger\n */function s(e){!z.state.isEnabled||h(e)||(!z.state.isVisible&&(j=e.type,e instanceof MouseEvent&&(D=e)),\"click\"===e.type&&!1!==z.props.hideOnClick&&z.state.isVisible?n():i(e))}/**\n * Event listener used for interactive tooltips to detect when they should\n * hide\n */function l(e){var t=qe(e.target,function(e){return e._tippy}),o=Ve(e.target,Ai.POPPER)===z.popper,r=t===z.reference;o||r||_t(kt(z.popper),z.popper.getBoundingClientRect(),e,z.props)&&(p(),n())}/**\n * Event listener invoked upon mouseleave\n */function d(e){return h(e)?void 0:z.props.interactive?(document.body.addEventListener(\"mouseleave\",n),void document.addEventListener(\"mousemove\",W)):void n()}/**\n * Event listener invoked upon blur\n */function c(e){e.target!==z.reference||z.props.interactive&&e.relatedTarget&&z.popper.contains(e.relatedTarget)||n()}/**\n * Event listener invoked when a child target is triggered\n */function m(e){Ve(e.target,z.props.target)&&i(e)}/**\n * Event listener invoked when a child target should hide\n */function f(e){Ve(e.target,z.props.target)&&n()}/**\n * Determines if an event listener should stop further execution due to the\n * `touchHold` option\n */function h(e){var t=\"ontouchstart\"in window,o=ot(e.type,\"touch\"),r=z.props.touchHold;return t&&Mi&&r&&!o||Mi&&!r&&o}/**\n * Creates the popper instance for the instance\n */function b(){function e(e){z.props.flip&&!z.props.flipOnUpdate&&(e.flipped&&(z.popperInstance.options.placement=e.placement),at(z.popperInstance.modifiers,!1)),r.setAttribute(\"x-placement\",e.placement);var t=kt(z.popper),o=r.style;o.top=o.bottom=o.left=o.right=\"\",o[t]=Pt(z.props.distance);var i=n&&void 0!==n.padding?n.padding:4,a=\"number\"==typeof i,p=Ue({top:a?i:i.top,bottom:a?i:i.bottom,left:a?i:i.left,right:a?i:i.right},!a&&i);p[t]=a?i+z.props.distance:(i[t]||0)+z.props.distance,z.popperInstance.modifiers.filter(function(e){return\"preventOverflow\"===e.name})[0].padding=p}var t=z.props.popperOptions,o=z.popperChildren,r=o.tooltip,i=o.arrow,n=tt(t,\"preventOverflow\"),a=Ue({placement:z.props.placement},t,{modifiers:Ue({},t?t.modifiers:{},{preventOverflow:Ue({boundariesElement:z.props.boundary,padding:4},n),arrow:Ue({element:i,enabled:!!i},tt(t,\"arrow\")),flip:Ue({enabled:z.props.flip,// The tooltip is offset by 10px from the popper in CSS,\n// we need to account for its distance\npadding:z.props.distance+4,behavior:z.props.flipBehavior},tt(t,\"flip\")),offset:Ue({offset:z.props.offset},tt(t,\"offset\"))}),// This gets invoked when calling `.set()` and updating a popper\n// instance dependency, since a new popper instance gets created\nonCreate:function(o){e(o),t&&t.onCreate&&t.onCreate(o)},// This gets invoked on initial create and show()/scroll/resize update.\n// This is due to `afterPopperPositionUpdates` overwriting onCreate()\n// with onUpdate()\nonUpdate:function(o){e(o),t&&t.onUpdate&&t.onUpdate(o)}});z.popperInstance=new xi(z.reference,z.popper,a)}/**\n * Mounts the tooltip to the DOM, callback to show tooltip is run **after**\n * popper's position has updated\n */function u(e){var t=!y()&&!(\"initial\"===z.props.followCursor&&Mi);z.popperInstance?(!y()&&(z.popperInstance.scheduleUpdate(),t&&z.popperInstance.enableEventListeners()),at(z.popperInstance.modifiers,z.props.flip)):(b(),!t&&z.popperInstance.disableEventListeners()),z.popperInstance.reference=z.reference;var r=z.popperChildren.arrow;y()?(r&&(r.style.margin=\"0\"),D&&o(D)):r&&(r.style.margin=\"\"),Mi&&D&&\"initial\"===z.props.followCursor&&(o(D),r&&(r.style.margin=\"0\")),Tt(z.popperInstance,e);var i=z.props.appendTo;H=\"parent\"===i?z.reference.parentNode:nt(i,[z.reference]),H.contains(z.popper)||(H.appendChild(z.popper),z.props.onMount(z),z.state.isMounted=!0)}/**\n * Determines if the instance is in `followCursor` mode\n */function y(){return z.props.followCursor&&!Mi&&\"focus\"!==j}/**\n * Updates the tooltip's position on each animation frame\n */function g(){function e(){z.popperInstance&&z.popperInstance.scheduleUpdate(),z.state.isMounted?requestAnimationFrame(e):wt([z.popper],0)}wt([z.popper],Oi?0:z.props.updateDuration),e()}/**\n * Invokes a callback once the tooltip has fully transitioned out\n */function v(e,t){x(e,function(){!z.state.isVisible&&H&&H.contains(z.popper)&&t()})}/**\n * Invokes a callback once the tooltip has fully transitioned in\n */function w(e,t){x(e,t)}/**\n * Invokes a callback once the tooltip's CSS transition ends\n */function x(e,t){/**\n * Listener added as the `transitionend` handler\n */function o(e){e.target===r&&(xt(r,\"remove\",o),t())}// Make callback synchronous if duration is 0\n// `transitionend` won't fire otherwise\nvar r=z.popperChildren.tooltip;return 0===e?t():void(xt(r,\"remove\",Y),xt(r,\"add\",o),Y=o)}/**\n * Adds an event listener to the reference and stores it in `listeners`\n */function k(e,t){var o=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];z.reference.addEventListener(e,t,o),B.push({eventType:e,handler:t,options:o})}/**\n * Adds event listeners to the reference based on the `trigger` prop\n */function E(){z.props.touchHold&&!z.props.target&&(k(\"touchstart\",s,ji),k(\"touchend\",d,ji)),z.props.trigger.trim().split(\" \").forEach(function(e){\"manual\"===e||(z.props.target?\"mouseenter\"===e?(k(\"mouseover\",m),k(\"mouseout\",f)):\"focus\"===e?(k(\"focusin\",m),k(\"focusout\",f)):\"click\"===e?k(e,m):void 0:(k(e,s),\"mouseenter\"===e?k(\"mouseleave\",d):\"focus\"===e?k(Oi?\"focusout\":\"blur\",c):void 0))})}/**\n * Removes event listeners from the reference\n */function O(){B.forEach(function(e){var t=e.eventType,o=e.handler,r=e.options;z.reference.removeEventListener(t,o,r)}),B=[]}/**\n * Returns inner elements used in show/hide methods\n */function S(){return[z.popperChildren.tooltip,z.popperChildren.backdrop,z.popperChildren.content]}/* ======================= 🔑 Public methods 🔑 ======================= */ /**\n * Enables the instance to allow it to show or hide\n */ /**\n * Clears pending timeouts related to the `delay` prop if any\n */function C(){clearTimeout(M),clearTimeout(I),cancelAnimationFrame(N)}/**\n * Sets new props for the instance and redraws the tooltip\n */function L(e){e=e||{},dt(e,Li);var t=z.props,r=lt(z.reference,Ue({},z.props,e,{ignoreAttributes:!0}));r.ignoreAttributes=Je(e,\"ignoreAttributes\")?e.ignoreAttributes||!1:t.ignoreAttributes,z.props=r,(Je(e,\"trigger\")||Je(e,\"touchHold\"))&&(O(),E()),Je(e,\"interactiveDebounce\")&&(p(),W=et(l,e.interactiveDebounce||0)),Lt(z.popper,t,r),z.popperChildren=ft(z.popper),z.popperInstance&&(z.popperInstance.update(),Ti.some(function(t){return Je(e,t)})&&(z.popperInstance.destroy(),b(),!z.state.isVisible&&z.popperInstance.disableEventListeners(),z.props.followCursor&&D&&o(D)))}/**\n * Shortcut for .set({ content: newContent })\n */ /**\n * Shows the tooltip\n */function T(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:Qe(z.props.duration,0,Li.duration[1]);return z.state.isDestroyed||!z.state.isEnabled||Mi&&!z.props.touch?void 0:Je(z.reference,\"isVirtual\")||document.documentElement.contains(z.reference)?void(z.reference.hasAttribute(\"disabled\")||!1===z.props.onShow(z)||(// Prevent a transition if the popper is at the opposite placement\nz.popper.style.visibility=\"visible\",z.state.isVisible=!0,z.props.interactive&&z.reference.classList.add(\"tippy-active\"),wt([z.popper,z.popperChildren.tooltip,z.popperChildren.backdrop],0),u(function(){z.state.isVisible&&(!y()&&z.popperInstance.update(),wt([z.popper],P.updateDuration),wt(S(),e),z.popperChildren.backdrop&&(z.popperChildren.content.style.transitionDelay=Co(e/12)+\"ms\"),z.props.sticky&&g(),Et(S(),\"visible\"),w(e,function(){z.popperChildren.tooltip.classList.add(\"tippy-notransition\"),z.props.aria&&z.reference.setAttribute(\"aria-\".concat(z.props.aria),z.popper.id),z.props.onShown(z),z.state.isShown=!0}))}))):_();// Destroy tooltip if the reference element is no longer on the DOM\n// Do not show tooltip if the reference element has a `disabled` attribute\n}/**\n * Hides the tooltip\n */function A(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:Qe(z.props.duration,1,Li.duration[1]);z.state.isDestroyed||!z.state.isEnabled||!1===z.props.onHide(z)||(z.popperChildren.tooltip.classList.remove(\"tippy-notransition\"),z.props.interactive&&z.reference.classList.remove(\"tippy-active\"),z.popper.style.visibility=\"hidden\",z.state.isVisible=!1,z.state.isShown=!1,wt(S(),e),Et(S(),\"hidden\"),v(e,function(){X||a(),z.props.aria&&z.reference.removeAttribute(\"aria-\".concat(z.props.aria)),z.popperInstance.disableEventListeners(),z.popperInstance.options.placement=z.props.placement,H.removeChild(z.popper),z.props.onHidden(z),z.state.isMounted=!1}))}/**\n * Destroys the tooltip\n */function _(e){z.state.isDestroyed||(z.state.isMounted&&A(0),O(),delete z.reference._tippy,z.props.target&&e&&ze(z.reference.querySelectorAll(z.props.target)).forEach(function(e){e._tippy&&e._tippy.destroy()}),z.popperInstance&&z.popperInstance.destroy(),z.state.isDestroyed=!0)}var P=lt(e,t);// If the reference shouldn't have multiple tippys, return null early\nif(!P.multiple&&e._tippy)return null;/* ======================= 🔒 Private members 🔒 ======================= */ // The last trigger event type that caused the tippy to show\nvar j,D,M,I,N,Y,H,X=!1,B=[],W=0<P.interactiveDebounce?et(l,P.interactiveDebounce):l,R=Ni++,F=Ct(R,P),U=ft(F),z={// properties\nid:R,reference:e,popper:F,popperChildren:U,popperInstance:null,props:P,state:{// Is the instance currently enabled?\nisEnabled:!0,// Is the tippy currently showing and not transitioning out?\nisVisible:!1,// Has the instance been destroyed?\nisDestroyed:!1,// Is the tippy currently mounted to the DOM?\nisMounted:!1,// Has the tippy finished transitioning in?\nisShown:!1// Popper.js instance for the tippy is lazily created\n},// methods\nclearDelayTimeouts:C,set:L,setContent:function(e){L({content:e})},show:T,hide:A,enable:function(){z.state.isEnabled=!0}/**\n * Disables the instance to disallow it to show or hide\n */,disable:function(){z.state.isEnabled=!1},destroy:_};// The last mousemove event object created by the document mousemove event\nreturn E(),P.lazy||(b(),z.popperInstance.disableEventListeners()),P.showOnInit&&i(),!P.a11y||P.target||pt(e)||e.setAttribute(\"tabindex\",\"0\"),F.addEventListener(\"mouseenter\",function(e){z.props.interactive&&z.state.isVisible&&\"mouseenter\"===j&&i(e)}),F.addEventListener(\"mouseleave\",function(){z.props.interactive&&\"mouseenter\"===j&&document.addEventListener(\"mousemove\",W)}),e._tippy=z,F._tippy=z,z}", "title": "" }, { "docid": "e60d0ea09a10885457a115f69b1ca2ca", "score": "0.6243139", "text": "_updateTooltip (event, data) {\n let cedartip = document.getElementById(this._definition.tooltip.id);\n if (!data) {\n cedartip.style.display = 'none';\n return;\n }\n cedartip.style.top = `${event.pageY}px`;\n cedartip.style.left = `${event.pageX}px`;\n cedartip.style.display = 'block';\n\n let content = `<span class='title'>${this._definition.tooltip.title}</span><br />`;\n content += `<p class='content'>${this._definition.tooltip.content}</p>`;\n\n cedartip.innerHTML = content.replace(/\\{(\\w+)\\}/g, (match, $1) => {\n return data[$1];\n });\n }", "title": "" }, { "docid": "ec88cba11af6a23a2510d3ea04ebb993", "score": "0.62367535", "text": "function toolTip(id, dino) {\n\n $(\"#\" + id).attr(\"title\", dino.healthPoints + \" HP, \" + dino.attackPower + \" AP, \" + dino.counterAttack + \" CP\" );\n\n }", "title": "" }, { "docid": "a27541a18d3ae4b1fa4bd8ca9f779dc6", "score": "0.6216358", "text": "function userCluetip(dataset,index, list_width)\n{\n\tvar rest ='|';\n\tfor(var key in dataset){\n\t\tvar transKey=eval(\"Msg.\"+key);\n\t\tlist_info = transKey+\"(\"+ dataset[key]+\")\";\n\t\trest += list_info+\"<br/>\";\n\t}\n\t$(index).attr(\"title\", rest);\n\t$(index).cluetip({splitTitle: '|', width: list_width, showTitle: false, cluetipClass: 'cluetip',cursor:'pointer'});\n}", "title": "" }, { "docid": "c6783fd0c6ef002c842f8a7e04db2661", "score": "0.61999375", "text": "function sample2Tip (event){\n\tTip('Show the <b>Google Analytics Page</b> ');\n}", "title": "" }, { "docid": "5b68a1e8474ae4712f48e1ca7c8b3fff", "score": "0.61964595", "text": "function Plugin(option) {\n\t return this.each(function () {\n\t var $this = $(this)\n\t var data = $this.data('bs.tooltip')\n\t var options = typeof option == 'object' && option\n\n\t if (!data && /destroy|hide/.test(option)) return\n\t if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n\t if (typeof option == 'string') data[option]()\n\t })\n\t }", "title": "" }, { "docid": "2fe0fabb0247ca1e7879189fc9be920d", "score": "0.61925143", "text": "function showTooltip(content, event) {\n tt.style('opacity', 1.0)\n .html(content);\n updatePosition(event);\n }", "title": "" }, { "docid": "283713b45daf7ef047488e26478d4381", "score": "0.6186089", "text": "function tooltips ( ) {\n\n // Tooltips are added with options.tooltips in original order.\n var tips = scope_Handles.map(addTooltip);\n\n bindEvent('update', function(values, handleNumber, unencoded) {\n\n if ( !tips[handleNumber] ) {\n return;\n }\n\n var formattedValue = values[handleNumber];\n\n if ( options.tooltips[handleNumber] !== true ) {\n formattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]);\n }\n\n tips[handleNumber].innerHTML = '<span>' + formattedValue + '</span>';\n });\n }", "title": "" }, { "docid": "0647607cbbc3dbe99742e1e876eb9cdd", "score": "0.6185792", "text": "function cargarDescripcionTitulo(){\r\n\tjQuery('.home-sede .descripcion,.listado-columna-derecha .descripcion,.listado-columna-derecha > UL > LI:first-child .descripcionLista').each(function(){\r\n\t\tvar descripcion = jQuery(this).text(); \r\n\t\tjQuery('<span class=\"descripcionTitulo\" title=\"'+descripcion+'\">?</span>').insertAfter(jQuery(this));\r\n\t});\t\r\n\tjQuery('.home-sede SPAN.descripcionTitulo,.listado-columna-derecha SPAN.descripcionTitulo').qtip({\r\n\t\tposition:{my:'top right',at:'bottom center'},\r\n\t\tstyle:{classes:'ui-tooltip-shadow'}\r\n\t});\t\r\n}", "title": "" }, { "docid": "57c90651f33aadba0c3ed642234a559f", "score": "0.6182632", "text": "function prepareTooltip() {\n\t ttScope.title = attrs[prefix + 'Title'];\n\t if (contentParse) {\n\t ttScope.content = contentParse(scope);\n\t } else {\n\t ttScope.content = attrs[ttType];\n\t }\n\n\t ttScope.popupClass = attrs[prefix + 'Class'];\n\t ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;\n\n\t var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);\n\t var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);\n\t ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;\n\t ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;\n\t }", "title": "" }, { "docid": "8a12748f0aaa6f612d5b2bcb8ac51540", "score": "0.61813456", "text": "function tooltip() {\n $(\"#toggletooltip\").show();\n $(\"#toggletooltip\").delay(3000).fadeOut(500);\n}", "title": "" }, { "docid": "efccce874676c0df31fe63a71ff5bf4b", "score": "0.6177515", "text": "function tooltips ( ) {\n\n\t\t// Tooltips are added with options.tooltips in original order.\n\t\tvar tips = scope_Handles.map(addTooltip);\n\n\t\tbindEvent('update', function(values, handleNumber, unencoded) {\n\n\t\t\tif ( !tips[handleNumber] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar formattedValue = values[handleNumber];\n\n\t\t\tif ( options.tooltips[handleNumber] !== true ) {\n\t\t\t\tformattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]);\n\t\t\t}\n\n\t\t\ttips[handleNumber].innerHTML = formattedValue;\n\t\t});\n\t}", "title": "" }, { "docid": "efccce874676c0df31fe63a71ff5bf4b", "score": "0.6177515", "text": "function tooltips ( ) {\n\n\t\t// Tooltips are added with options.tooltips in original order.\n\t\tvar tips = scope_Handles.map(addTooltip);\n\n\t\tbindEvent('update', function(values, handleNumber, unencoded) {\n\n\t\t\tif ( !tips[handleNumber] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar formattedValue = values[handleNumber];\n\n\t\t\tif ( options.tooltips[handleNumber] !== true ) {\n\t\t\t\tformattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]);\n\t\t\t}\n\n\t\t\ttips[handleNumber].innerHTML = formattedValue;\n\t\t});\n\t}", "title": "" }, { "docid": "46efc78ccdb6371d802ad4c3d61b233d", "score": "0.61671585", "text": "generateExtendedToolTip() {\n //Order the data array\n let data = formatArray.collectionToTop(this.data, config.tooltipOrder);\n data = formatArray.collectionToBottom(data, config.tooltipReverseOrder);\n if (!(data)) data = [];\n\n if (!(data) || data.length === 0) {\n return generate.noDataWarning(this.name);\n }\n\n //Ensure name is not blank\n this.validateName();\n\n //Generate expansion and collapse functions \n const expandFunction = this.displayMore();\n const collapseFunction = this.displayLess();\n\n const getExpansionFunction = item => !this.isExpanded(item[0]) ? expandFunction : collapseFunction;\n\n if (!(this.data)) { this.data = []; }\n return h('div.tooltip-image', [\n h('div.tooltip-heading', this.name),\n h('div.tooltip-internal', h('div', (data).map(item => generate.parseMetadata(item, !this.isExpanded(item[0]), getExpansionFunction(item)), this)))\n ]\n );\n }", "title": "" }, { "docid": "6c363f45dcdf5eef06141dcefc9cf998", "score": "0.61640775", "text": "function displayToolTip() {\n //trace(\"displayToolTip\");\n //console.log(\"displayToolTip\");\n if (currentTimeDisplay) {\n myToolTip.hideToolTip();\n var offset = minimumVal; //Number(Model.getSegStartFrame()/Model.getFps());\n var currentTimeDisplayPercent = Math.round(\n ($(sliderElement)\n .children('.ui-slider-handle')\n .position().left /\n $(sliderElement).width()) *\n 100\n );\n txt =\n formatTimeForTooltip(\n (currentTimeDisplayPercent * (mediaDuration - offset)) / 100\n ) +\n ' / ' +\n formatTimeForTooltip(mediaDuration - offset);\n // = display current time for animation only ==\n if (myToolTip) {\n myToolTip.showToolTip(\n $(sliderElement).offset().top - 5,\n $(sliderElement).offset().left +\n $(sliderElement)\n .children('.ui-slider-handle')\n .position().left -\n 5,\n $(sliderElement)\n .children('.ui-slider-handle')\n .width(),\n txt\n );\n }\n }\n }", "title": "" }, { "docid": "2d76a81d24eee09cc25a874f94affaa1", "score": "0.6162858", "text": "get tooltip() {\n return this._tooltip;\n }", "title": "" }, { "docid": "70a11f6f6e3cad1187d497d2b74b4d89", "score": "0.61567086", "text": "_showTooltip(){\n this._tooltipVisible = true;\n this._render();\n }", "title": "" }, { "docid": "fe373e8d698e67fe1cbc3b79fd5e1c02", "score": "0.6153714", "text": "function setupToolTip()\n{\n tooltip = d3.select(\"body\").append(\"div\").attr(\"class\", \"toolTip\");\n linetooltip = d3.select(\"body\").append(\"div\").attr(\"class\", \"toolTip\");\n}", "title": "" }, { "docid": "dd3b48760315c3545a8efc3076d35bf6", "score": "0.6151832", "text": "function sample1OptTip (event){\n\tTip('Show the Box to Set <b>gaShortUrlList Option</b>');\n}", "title": "" }, { "docid": "4e98f6a70e9ce3344ce1065b1ff81965", "score": "0.6148929", "text": "function ready(){\r\n $('[data-toggle=\"tooltip\"]').tooltip();\r\n }", "title": "" }, { "docid": "272c2a27161e7b62a42ed787e0a8f57f", "score": "0.6143102", "text": "function Plugin(option) {\n\t return this.each(function () {\n\t var $this = $(this)\n\t var data = $this.data('bs.tooltip')\n\t var options = typeof option == 'object' && option\n\t\n\t if (!data && /destroy|hide/.test(option)) return\n\t if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n\t if (typeof option == 'string') data[option]()\n\t })\n\t }", "title": "" }, { "docid": "272c2a27161e7b62a42ed787e0a8f57f", "score": "0.6143102", "text": "function Plugin(option) {\n\t return this.each(function () {\n\t var $this = $(this)\n\t var data = $this.data('bs.tooltip')\n\t var options = typeof option == 'object' && option\n\t\n\t if (!data && /destroy|hide/.test(option)) return\n\t if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n\t if (typeof option == 'string') data[option]()\n\t })\n\t }", "title": "" }, { "docid": "272c2a27161e7b62a42ed787e0a8f57f", "score": "0.6143102", "text": "function Plugin(option) {\n\t return this.each(function () {\n\t var $this = $(this)\n\t var data = $this.data('bs.tooltip')\n\t var options = typeof option == 'object' && option\n\t\n\t if (!data && /destroy|hide/.test(option)) return\n\t if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n\t if (typeof option == 'string') data[option]()\n\t })\n\t }", "title": "" }, { "docid": "1480a11fd04a2e8574cedf5dd339fa2f", "score": "0.61427474", "text": "function com_zimbra_example_customtooltip_HandlerObject() {\r\n}", "title": "" }, { "docid": "d6536a90a94807818b385ff5e5916341", "score": "0.61368406", "text": "function tooltips() {\n // Tooltips are added with options.tooltips in original order.\n var tips = scope_Handles.map(addTooltip);\n\n bindEvent(\"update\", function(values, handleNumber, unencoded) {\n if (!tips[handleNumber]) {\n return;\n }\n\n var formattedValue = values[handleNumber];\n\n if (options.tooltips[handleNumber] !== true) {\n formattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]);\n }\n\n tips[handleNumber].innerHTML = formattedValue;\n });\n }", "title": "" }, { "docid": "d6536a90a94807818b385ff5e5916341", "score": "0.61368406", "text": "function tooltips() {\n // Tooltips are added with options.tooltips in original order.\n var tips = scope_Handles.map(addTooltip);\n\n bindEvent(\"update\", function(values, handleNumber, unencoded) {\n if (!tips[handleNumber]) {\n return;\n }\n\n var formattedValue = values[handleNumber];\n\n if (options.tooltips[handleNumber] !== true) {\n formattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]);\n }\n\n tips[handleNumber].innerHTML = formattedValue;\n });\n }", "title": "" }, { "docid": "fc4ebaaedffb928ca170f01f7385f47a", "score": "0.6135752", "text": "function dataToolTips() {\n\n // array to return.\n var arrToolTips = [];\n\n // create the tool tips.\n // buildToolTipObj(urlIncludes, theElement, theTip, isBefore)\n//Carver bimini product pages:\n arrToolTips.push(buildToolTipObj(\n 'carver-bimini-top-', 'find.Boot.colon', 'Add a heavy-duty storage boot to protect and secure your Carver bimini top when it\\'s not open or in use.', false));\n arrToolTips.push(buildToolTipObj(\n 'carver-bimini-top-', '.brace_kit','Brace kits hold bimini top up and out of the when folded. Includes two aluminum brace tubes, fittings, and mounting hardware.\\<br\\>\\<br\\>\\<img src=\\\"https://www.savvyboater.com/product_images/uploaded_images/bimini-top-brace-kit-280px.jpg\\\"\\>', true));\n arrToolTips.push(buildToolTipObj(\n 'carver-bimini-top-', '.slide_track_kit', 'Designed to slide a retracted Carver brand bimini top out of the way and into its storage position. Easy to mount on top or side.\\<br\\>\\<br\\>\\<img src=\\\"https://www.savvyboater.com/product_images/uploaded_images/bimini-top-slide-track-illustration.jpg\\\"\\>', true));\n arrToolTips.push(buildToolTipObj(\n 'carver-bimini-top-', 'find.Upgrades.colon', 'Durable stainless steel fittings with a sleek aesthetic. All necessary hardware included.', false));\n arrToolTips.push(buildToolTipObj(\n 'carver-bimini-top-', 'find.Frame.colon', 'Replace your bimini\\'s existing aluminum frame and nylon fittings with sleek stainless steel ones. All necessary hardware included.', false));\n arrToolTips.push(buildToolTipObj(\n 'bimini-top-', 'find.Mounting width.colon','The distance (width) between the mounting points for the bimini top.\\<br\\>\\<br\\>\\<img src=\\\"https://www.savvyboater.com/product_images/uploaded_images/bimini-top-width-200x148.jpg\\\"\\>', true));\n\n arrToolTips.push(buildToolTipObj(\n 'powerhouse-', 'find.Cord Length.colon', 'Maintains your motor\\'s efficiency and performance. Available in 25\\', 50\\', 100\\', 150\\' and 200\\' cord lengths.', false));\n arrToolTips.push(buildToolTipObj('kasco-', 'find.Select Cord Length', 'Maintains your motor\\'s efficiency and performance. Available in 25\\', 50\\' and 100\\' cord lengths.', false));\n arrToolTips.push(buildToolTipObj('taylor-', 'find.Cord Length', 'Maintains your motor\\'s efficiency and performance. Available in 50\\' and 100\\' (except 2HP) cord lengths.', false));\n\n arrToolTips.push(buildToolTipObj(\n 'carver-bimini-top-', 'find.Kit.colon', 'Choose material for your mounting kit', false));\n arrToolTips.push(buildToolTipObj(\n '-tower-bimini-top-', '.brace_kit', 'Brace kits hold bimini top up and out of the when folded. Includes two aluminum brace tubes, fittings, and mounting hardware.\\<br\\>\\<br\\>\\<img src=\\\"https://www.savvyboater.com/product_images/uploaded_images/bimini-top-brace-kit-280px.jpg\\\"\\>', true));\n arrToolTips.push(buildToolTipObj(\n '-pontoon-bimini-top-', 'find.Options.colon', 'A small cut-out centered on the rear bow allows mounting a running light. Zippered sleeves allow removal of the canvas for maintenance without disassembling the frame.', false));\n arrToolTips.push(buildToolTipObj('-pontoon-bimini-top-', 'find.Add-ons.colon', 'Brace kits hold bimini top up and out of the when folded. Includes two aluminum brace tubes, fittings, and mounting hardware.\\<br\\>\\<br\\>\\<img src=\\\"https://www.savvyboater.com/product_images/uploaded_images/bimini-top-brace-kit-280px.jpg\\\"\\>', false));\n\n//Westland bimini product pages:\n arrToolTips.push(buildToolTipObj('-st50-xs', 'find.Upgrades.colon', 'Add a heavy-duty storage boot to protect and secure your Westland bimini top when it\\'s not open or in use. OR<br> Add durable stainless steel fittings with a sleek aesthetic. All necessary hardware included.', false));\n arrToolTips.push(buildToolTipObj(\n 'westland-bimini-top', '.brace_kit', 'Brace kits hold bimini top up and out of the when folded. Includes two aluminum brace tubes, fittings, and mounting hardware.\\<br\\>\\<br\\>\\<img src=\\\"https://www.savvyboater.com/product_images/uploaded_images/bimini-top-brace-kit-280px.jpg\\\"\\>', true));\n arrToolTips.push(buildToolTipObj(\n 'westland-bimini-top', '.slide_track_kit', 'Slide tracks mount to the gunwale of your boat and allow your bimini top to slide into a more convenient, horizontal storage position. Bimini top slide track kits come with two tracks and all the necessary mounting hardware.\\<br\\>\\<br\\>\\<img src=\\\"https://www.savvyboater.com/product_images/uploaded_images/bimini-top-slide-track-illustration.jpg\\\"\\>', true));\n arrToolTips.push(buildToolTipObj('westland-bimini-top-', 'find.Upgrades.colon', 'Durable stainless steel fittings with a sleek aesthetic. All necessary hardware included.', false));\n\n\n // DEMO FOR BOAT COVER PAGE - Tooltip for just the input checkbox, no label.\n // arrToolTips.push(buildToolTipObj('-custom-boat-cover-', 'find.Pontoon Mooring Kit', 'this is a test', true, true));\n//cover product pages:\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Pontoon Mooring Kit', 'Adds breathability for the health of your boat. Includes 3 Vented Support Poles and 2 Sand Bag Kits.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58118/images/282872/pontoon_mooring_kit__71522.1491500666.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Support Pole - Snap End', 'This lightweight, telescoping pole supports your boat cover so water will run off and not pool, preventing dry rot and mildew. Includes a self-adhesive snap.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/48950/images/185426/carver-support-pole-60000__48932.1421441331.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Support Pole - Vent II', 'This support pole prevents water from pooling on your boat cover and provides an air-vent to reduce moisture, heat and mildew under the cover.\\<br\\>\\<br\\>\\<img src=\\https://cdn3.bigcommerce.com/s-uprkx/products/48952/images/185432/carver-support-pole-vented__36622.1421441337.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Support System', 'Eliminates virtually all possible areas that could collect water and allow it to pool, causing damage to the cover. Simple installation.\\<br\\>\\<br\\>\\<img src=\\https://cdn3.bigcommerce.com/s-uprkx/products/48949/images/185424/carver-support-system__89226.1421441327.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Rope Rachet', 'Allows you to tighten your cover to proper tension, then releases with a convenient thumb lever. Accommodates 1/4\" rope.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/48954/images/185438/carver-rope-ratchet__45251.1421441342.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Reinforcement/Repair Kit', 'Kit includes one yard self adhesive material. Use it to add extra padding to stress points from windshields, trolling motors, etc. or to patch wear areas and tears that may develop over time.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/48955/images/185439/carver-cover-repair-kit__62577.1421441344.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Rush production', 'Rush production does not include shipping time. Please allow for usual delivery time in addition to the 3 production days.', true, true));\n\n//Westland cover upsells\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Support Pole & Snap Patch', 'Supports cover to prevent water pooling. No cutting or sewing required. Includes self-adhesive snap patch.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/40427/images/257438/westland-snap-patch__25486.1421906376.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Snap Patch for Support Pole', 'This Westland self-adhesive snap patch is equipped with a female snap that is designed to snap to the top of the male snap on the Snap-style adjustable support pole.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/48962/images/257444/westland-snap-patch-only__48163.1421906379.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Tie-down Straps', 'Twelve straps made of durable black webbing and tough black nylon buckles easily adjust to keep your cover secure to your trailer or lift.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/40434/images/257446/westland-tie-down-straps__49796.1421906380.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Quick Cinch', 'A knot-free, quick and easy way to draw your boat cover rope as tight as possible. Thumb lever releases your rope quickly and easily.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/40429/images/257442/westland-quick-cinch__23496.1421906378.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Quick Cinch Pocket', 'This padded cover is 12\" long and completely encloses the 1/4\" Rope Cincher (Quick Cinch sold separately) to protect your boat from surface scratches.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/40430/images/257443/westland-quick-cinch-cover__24445.1421906378.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('-boat-cover-', 'find.Support Pole - Vent', 'Supports your cover to keep water from pooling outside and also provides ventilation to prevent moisture and mildew from forming on the inside.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/56266/images/272509/westland-vented-pole__90179.1442453283.1280.1280.jpg?c=2\\\"\\>', true, true));\n\n arrToolTips.push(buildToolTipObj('-bimini-top-', 'find.Rush production', 'Rush production does not include shipping time. Please allow for usual delivery time in addition to the 3 production days.', true, true));\n\n//Taylor Made fenders upsells\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Lines', 'Provides an adjustable and secure tie\\-off for your boat fenders. Package includes (2) 6\\' fender loc lines, 3/8\\\" in diameter.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50057/images/126146/taylor-fender-loc-lines__94345.1420741699.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Straps', 'A quick and easy way to adjust the height of your fenders\\! Made from 3/4\\\" Polyester webbing with UV protection and Marine grade Hook and Loop fasteners. Sold in pairs.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58962/images/286657/TM-hook-loop-fender-strap-1094__26405.1505761828.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Lock & Peg - 1/4', 'Makes hanging fenders fast and easy, for rope sizes up to 1/4\\\".\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58961/images/286659/TM-SS-fender-lock-1010__28459.1505761913.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Lock & Peg - SS', 'Provides secure and reliable mounting and allows the use of up to 1/2\\\" diameter rope.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58951/images/286669/ssfenderlock-1001__54714.1505762096.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Brackets', 'A quick and easy fender height adjustment. Mount securely to 7/8\\\" \\- 1\\\" railings or up to 1/4\\\" lifelines.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58959/images/286661/TM-rail-lifeline-fender-bracket-1097__40553.1505761969.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Clips: Lifeline', 'Use for hanging fenders, holding power cords. Brackets mount securely to your 3/16\\\" to 1/4\\\" lifelines. Sold in pairs.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58964/images/286655/TM-lifeline-fender-clip-1096__44768.1505761775.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Clip - 7/8', 'Use for hanging fenders, holding power cords. Clips that mount securely to your 7/8\\\" railings. Sold in pairs.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58960/images/286660/TM-rail-mount-fender-line-clip-1093__93008.1505761932.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Hanger: Line', 'Keep loose lines and power cords neatly in place. Durable PVC mounting band snaps over any rail, lifeline or stanchion. Snap the bottom section around your coil of rope or cord to secure. Measures 9 1/2\\\" in length.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58954/images/286666/TM-line-hanger-1006__00238.1505762048.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Hanger: Rail - Small', 'Makes it easy to adjust fender heights and locks in place with a jam cleat - no knots. Uses 1/4\\\" to 1/2\\\" line. Fits up to 1\\\" rails.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58956/images/286664/TM-rail-fender-hanger-1108__33923.1505762017.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Hanger: Rail - Large', 'Makes it easy to adjust fender heights and locks in place with a jam cleat - no knots. Uses 1/4\\\" to 1/2\\\" line. Fits up to 1.25\\\" rails.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58956/images/286664/TM-rail-fender-hanger-1108__33923.1505762017.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Hanger: Vertical Rail', 'Attaches to rails 7/8\\\" to 1\\\" in diameter with 2 screws and then grips the fender rope with its heavy duty teeth making rafting and docking easier than ever. Accepts rope size up to 5/8\\\".\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58963/images/286656/TM-vertical-rail-fender-hanger-1099__67669.1505761805.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Hanger: Racheting', 'Allows you to adjust your fender height from 6\\\" to 24\\\".\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58955/images/286665/TM-racheting-fender-hanger-1089__85227.1505762032.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Hanger: Quick Knot', 'Allows the quick placement of fenders anywhere there is something to tie off to, without having to tie a knot. Perfect for 1/4\\\" rope.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58958/images/286662/TM-quick-knot-fender-hanger-1098__79564.1505761986.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Tidy-Ups', 'Kits include (1) Tidy-Ups Fender Adjuster and (6) feet of 3/8\\\" solid braid polypropylene rope.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50056/images/126144/taylor-tidy-ups-kit-2__12894.1420741696.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Line Holders - 1.25', 'UV resistant vinyl strap securely holds rope, cords, etc. Fits 1\\\" - 1 1/4\\\" rails.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58953/images/286667/TM-tidy-ups-line-holders-1101__37970.1505762065.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Line Holders - 2', 'UV resistant vinyl strap securely holds rope, cords, etc. Fits 1 1/2\\\" - 2\\\" rails.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58953/images/286667/TM-tidy-ups-line-holders-1101__37970.1505762065.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Holders: 7\"-9\"', 'Holds any boat fender 7\\\" to 9\\\" in diameter. Includes set of 2 holders and mounting hardware.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50059/images/126148/taylor-fender-holder-3__55896.1420741704.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Holders: 9\"-11\"', 'Holds any boat fender 9\\\" to 11\\\" in diameter. Includes set of 2 holders and mounting hardware.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50059/images/126148/taylor-fender-holder-3__55896.1420741704.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Adjuster', 'Designed to fit 1\\\" square tube pontoon rails. Allows height adjustment for fender lines up to 3/8\\\". Set of 4 adjusters.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50062/images/126151/taylor-fender-adjuster-pontoon__09451.1420741713.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-made-', 'find.Fender Hanger Locks', 'Hang your center tube style boat fenders with ease. Fits 3/8\\\" diameter rope. Set of 3 hanger locks.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50052/images/126130/taylor-big-b-fender-hanger-1__61994.1420741675.1280.1280.jpg?c=2\\\"\\>', true, true));\n\n//for De-icers\n arrToolTips.push(buildToolTipObj('kasco-', 'find.Zinc', 'Fall Special: Free with any Kasco de-icer! Protects de-icer motor from erosion and corrosion.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50863/images/272791/kasco-deicer-zinc__12111.1443724047.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('kasco-', 'find.Thermostat', 'Saves energy and extends the life of your de-icer. Allows you to set desired on-off temperatures.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50867/images/283777/Kasco-Marine-C-10-Control-Panel-Web__80765.1498670574.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('kasco-', 'find.Dock Mount', 'Allows adjustable angles and 360 degree positioning. Mounts your Kasco De-icer to any dock or piling.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50869/images/283778/Kasco-Marine-Universal-Dock-Mount__43897.1498670648.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('kasco-', 'find.Float Mount', 'Mounts your Kasco De-icer to the bottom of any float. Automatically adjusts to varying water levels.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50870/images/272800/kasco-deicer-float-mount__51010.1443724058.1280.1280.jpg?c=2\\\"\\>', true, true));\n\n arrToolTips.push(buildToolTipObj('taylor-', 'find.Zinc', 'Protects de-icer motor from erosion and corrosion.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/59838/images/288871/41896P_Zinc_Anode__09710.1545162879.1280.1280.jpg\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-', 'find.Thermostat', 'Saves energy and extends the life of your de-icer. Allows you to set desired on-off temperatures.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/59836/images/288873/6215_Thermostat__24568.1545162911.1280.1280.jpg\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('taylor-', 'find.Float', 'Designed to be an attachment to help the de-icer float and shoot water out of the top. It keeps the deicer “lifted” at the surface and allows for water to be dispersed at the surface of the water line. \\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/59840/images/288869/6226_PolyPro_Float__48676.1545162848.1280.1280.jpg\\\"\\>', true, true));\n\n arrToolTips.push(buildToolTipObj('powerhouse-', 'find.Zinc', 'Protects de-icer motor from erosion and corrosion. Fits all Power House Ice Eater models\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50879/images/272833/powerhouse-ice-eater-zinc__86678.1443724441.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('powerhouse-', 'find.Thermostat', 'Saves energy and extends the life of your de-icer. Allows you to set desired on-off settings per day.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50885/images/272843/powerhouse-ice-eater-thermostat__07115.1443724455.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('powerhouse-', 'find.Dock Mount', 'Allows full 360 degree positioning. Mounts your Power House Ice-Eater to any dock or piling.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/58029/images/282302/powerhouse-ice-eater-dock-mount__59328.1476980430.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('powerhouse-', 'find.Timer', 'Saves energy and extends the life of your de-icer. Allows you to set desired on-off settings per day.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50887/images/272845/powerhouse-ice-eater-timer__28837.1443724457.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('powerhouse-', 'find.Screen Kit', 'Protects motor and propeller from harmful debris. Fits both intake and output openings.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50880/images/272834/powerhouse-ice-eater-screen-kit__02554.1443724443.1280.1280.jpg?c=2\\\"\\>', true, true));\n arrToolTips.push(buildToolTipObj('powerhouse-', 'find.Shallow Water Stand', 'Ideal for duck hunting and fishing. Mounts your ice-eater in shallow water. Fits both P750 and P1000 Ice Eater models.\\<br\\>\\<br\\>\\<img src=\\\"https://cdn3.bigcommerce.com/s-uprkx/products/50888/images/272859/mallard-view-ice-eater-stand-only__28337.1444319985.1280.1280.jpg?c=2\\\"\\>', true, true));\n // return the array\n return arrToolTips;\n}", "title": "" }, { "docid": "859a39dc13302baac68d563ffe2b9a0f", "score": "0.61275476", "text": "function prepareTooltip() {\n ttScope.title = attrs[prefix + 'Title'];\n if (contentParse) {\n ttScope.content = contentParse(scope);\n } else {\n ttScope.content = attrs[ttType];\n }\n\n ttScope.popupClass = attrs[prefix + 'Class'];\n ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;\n\n var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);\n var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);\n ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;\n ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;\n }", "title": "" }, { "docid": "859a39dc13302baac68d563ffe2b9a0f", "score": "0.61275476", "text": "function prepareTooltip() {\n ttScope.title = attrs[prefix + 'Title'];\n if (contentParse) {\n ttScope.content = contentParse(scope);\n } else {\n ttScope.content = attrs[ttType];\n }\n\n ttScope.popupClass = attrs[prefix + 'Class'];\n ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;\n\n var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);\n var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);\n ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;\n ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;\n }", "title": "" }, { "docid": "0bf7ea14c5d2ffc02aebf528fbb34d53", "score": "0.61254567", "text": "get tooltip()\n\t{\n\t\treturn this._tooltip;\n\t}", "title": "" }, { "docid": "0bf7ea14c5d2ffc02aebf528fbb34d53", "score": "0.61254567", "text": "get tooltip()\n\t{\n\t\treturn this._tooltip;\n\t}", "title": "" }, { "docid": "d2f73c32dfa8ad350abe4410fb9f1728", "score": "0.61250174", "text": "function Plugin(option) {\n return this.each(function() {\n var $this = $(this);\n var data = $this.data('nobix.tooltip');\n var options = typeof option == 'object' && option;\n\n if (!data && /destroy|hide/.test(option)) return;\n if (!data) $this.data('nobix.tooltip', (data = new Tooltip(this, options)));\n if (typeof option == 'string') data[option]();\n });\n }", "title": "" }, { "docid": "ecb7217eb36d025731ee34eb987bb9c6", "score": "0.61195725", "text": "setupElements(){m(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&this.bindAdvance(),this.setupTooltip()}", "title": "" }, { "docid": "c12bcadfbb9088a77292eeed152c7b49", "score": "0.6119543", "text": "function test_component_tooltip(){\n\t\t/* Calculate size box */\n\t\tvar c='<div style=\"margin-left:auto;margin-right:auto;width:200px;height:200px;\">';\n\t\tc+='<br/><br/><br/><br/>';\t\t\t\t\t\t\n\t\tc+='<div class=\"tooltip\" role=\"tooltip\"><div class=\"tooltip-arrow\"></div><div class=\"tooltip-inner tltp-test\" style=\"max-width:none; text-align:left;\"></div></div>\\' ';\t\t\t\t\t\t\t\n\t\tc+='</div>';\n\t\t$(\"#test-area\").html(c);\t\n\t\t/* load simple data in sync mode Ajax */\t\t\n\t\tif ($('input:radio[name=inlineRadioOptions]:checked').val()=='no') dataTest($(\"#source-data\").val(),0);\t\t\t\t\t\t\n\t\telse dataTest($(\"#source-data\").val(),$(\"#limit\").val()); \n\t\tc_height=$(\"#c_height\").html();\n\t\tc_width=$(\"#c_width\").html();\t\t\t\t\t\t\t\t\n\t\t/* Activate component */\n\t\tc='<div style=\"margin-left:auto;margin-right:auto;width:200px;height:200px;\">';\t\t\n\t\tc+='<br/><br/><br/><br/>';\n\t\tc+='<button type=\"button\" class=\"btn btn-default\" data-toggle=\"tooltip\" ';\n\t\tc+='data-template=\\'<div class=\"tooltip\" role=\"tooltip\"><div class=\"tooltip-arrow\"></div><div class=\"tooltip-inner tltp-test\" style=\"max-width:none; text-align:left;\"></div></div>\\' ';\n\t\tc+='id=\"example\">Tooltip on top</button>';\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tc+='</div>';\n\t\t/* Insert custom CSS style */\n\t\tc+='<style type=\"text/css\">';\n\t\tc+=$(\"#txt-css\").val();\n\t\tc+='</style>';\n\t\t$(\"#test-area\").html(c);\n\t\tvar animation_=(this.opt_animation=='true');\n\t\t$('#example').tooltip({title: my_title, html:true, animation: animation_, placement:this.opt_placement, delay: {show:this.opt_show, hide:this.opt_hide }, trigger: this.opt_trigger});\t\t\t\t\t\t\t\n\t}", "title": "" }, { "docid": "aadbe4fde4b6d2c4cedd299e1a42ba54", "score": "0.61163735", "text": "get tooltip() {\n return this._tooltip;\n }", "title": "" }, { "docid": "b1420424a75dbbd79637b94f7ff37cc2", "score": "0.6112996", "text": "function Plugin(option) {\n\t return this.each(function () {\n\t var $this = $(this)\n\t var data = $this.data('bs.tooltip')\n\t var options = typeof option == 'object' && option\n\n\t if (!data && /destroy|hide/.test(option)) return\n\t if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n\t if (typeof option == 'string') data[option]()\n\t })\n\t }", "title": "" }, { "docid": "b1420424a75dbbd79637b94f7ff37cc2", "score": "0.6112996", "text": "function Plugin(option) {\n\t return this.each(function () {\n\t var $this = $(this)\n\t var data = $this.data('bs.tooltip')\n\t var options = typeof option == 'object' && option\n\n\t if (!data && /destroy|hide/.test(option)) return\n\t if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n\t if (typeof option == 'string') data[option]()\n\t })\n\t }", "title": "" }, { "docid": "b1420424a75dbbd79637b94f7ff37cc2", "score": "0.6112996", "text": "function Plugin(option) {\n\t return this.each(function () {\n\t var $this = $(this)\n\t var data = $this.data('bs.tooltip')\n\t var options = typeof option == 'object' && option\n\n\t if (!data && /destroy|hide/.test(option)) return\n\t if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n\t if (typeof option == 'string') data[option]()\n\t })\n\t }", "title": "" }, { "docid": "88f68d872f6eccfabb6577b46ae3c3e2", "score": "0.61124545", "text": "function Plugin(option) {\n var args = Array.prototype.slice.call(arguments, 1);\n // display tooltip only over truncated elements\n return this.filter(':truncated').each(function() {\n var $el = $(this);\n var options = $.extend({}, HoverTruncated.DEFAULTS,\n (typeof option == 'object' && option) || {});\n var instance = $el.data(options.dataAttr);\n\n if (!instance) {\n if (option === 'destroy') return;\n instance = new HoverTruncated(this, options);\n $el.data(options.dataAttr, instance);\n }\n\n if (typeof option == 'string' && /destroy|show|hide|update/.test(option)) {\n instance[option].apply(instance, args);\n }\n });\n }", "title": "" }, { "docid": "4df7eb508275e570588837f19d036bd9", "score": "0.60997283", "text": "function Tooltip(el){\n this.el = el;\n this.ttHtml = this.el.getAttribute('data-ttHtml') || '';\n this.ttPos = this.el.getAttribute('data-ttPos') || 'right';\n this.ttWidth = this.el.getAttribute('data-ttWidth') || '300';\n var ttAutoClose = this.el.getAttribute('data-ttAutoClose') || 'on';\n\n if(!this.el.getElementsByClassName('tooltipEl')[0]){\n var tt = document.createElement(\"div\");\n tt.setAttribute('class','tooltipEl');\n tt.innerHTML = this.ttHtml;\n tt.setAttribute('style','width:'+this.ttWidth+'px;');\n this.el.appendChild(tt);\n\n var elWidth = this.el.offsetWidth;\n var elHeight = this.el.offsetHeight;\n var ttWidth = this.ttWidth;\n var ttHeight = tt.offsetHeight;\n\n var top = - ((ttHeight/2) - (elHeight/2));\n var left = - ((ttWidth/2) - (elWidth/2));\n\n if(window.innerWidth < 1024){\n tt.setAttribute('style','width:'+ttWidth+'px;top:'+(elHeight+10)+'px;left:'+left+'px;');\n }else{\n if(this.ttPos === 'top'){\n tt.setAttribute('style','width:'+ttWidth+'px;top:-'+(ttHeight+10)+'px;left:'+left+'px;');\n }else if(this.ttPos === 'bottom'){\n tt.setAttribute('style','width:'+ttWidth+'px;top:'+(elHeight+10)+'px;left:'+left+'px;');\n }else if(this.ttPos === 'left'){\n tt.setAttribute('style','width:'+ttWidth+'px;right:'+(elWidth+10)+'px;top:'+top+'px;');\n }else{\n tt.setAttribute('style','width:'+ttWidth+'px;left:'+(elWidth+10)+'px;top:'+top+'px;');\n }\n }\n tt.classList.add('tooltipElV');\n }\n\n if(ttAutoClose === 'on'){\n el.addEventListener('mouseout',function(event){\n if(typeof tt !== 'undefined' && tt.parentNode === el){\n el.removeChild(tt);\n }\n },false);\n }else{\n document.addEventListener('click',function(event){\n if(event.target !== el){\n if(typeof tt !== 'undefined' && tt.parentNode === el){\n el.removeChild(tt);\n }\n }\n },false);\n }\n\n}", "title": "" }, { "docid": "c7ad31ee7de5cb7c5bb6cb521c9e21c5", "score": "0.60977", "text": "_showTips (type, timestamp, item) {\n const msg = locale.get(item, this._transformTime(timestamp))\n window[`show${type}Message`](msg)\n }", "title": "" }, { "docid": "21e800cfa88bdb6215c71a9a0b4f4c2d", "score": "0.6092411", "text": "function prepareTooltip() {\n\t ttScope.title = attrs[prefix + 'Title'];\n\t if (contentParse) {\n\t ttScope.content = contentParse(scope);\n\t } else {\n\t ttScope.content = attrs[ttType];\n\t }\n\t\n\t ttScope.popupClass = attrs[prefix + 'Class'];\n\t ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;\n\t var placement = $position.parsePlacement(ttScope.placement);\n\t lastPlacement = placement[1] ? placement[0] + '-' + placement[1] : placement[0];\n\t\n\t var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);\n\t var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);\n\t ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;\n\t ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;\n\t }", "title": "" }, { "docid": "5fa7763fab68aaeaa29f946c7c11cf42", "score": "0.60890317", "text": "function triggerTooltip()\r\n{\r\n\t$('.tip-trigger').each(function(){ \r\n if($(this).next().hasClass('tooltip-content')){\r\n $(this).mouseenter(function(evt){\r\n if ( $(\".tooltip\").size() == 0 ) {\r\n tooltip = $('<div class=\"tooltip\" />'),\r\n tooltipContent = $(this).next('.tooltip-content').clone().removeClass('hide');\r\n }\r\n \r\n tooltip.append(tooltipContent);\r\n appendTooltip($(this), evt);\r\n })\r\n .mousemove(function(evt){\r\n positionTooltip($(this), evt);\r\n })\r\n .mouseleave(function(){\r\n hideTooltip($(this));\r\n });\r\n }\r\n else {\r\n return;\r\n }\r\n });\r\n}", "title": "" }, { "docid": "9ae699d3719e4695b0d824f76560308a", "score": "0.60868585", "text": "function Plugin(option) {\r\n return this.each(function () {\r\n var $this = $(this)\r\n var data = $this.data('bs.tooltip')\r\n var options = typeof option == 'object' && option\r\n\r\n if (!data && option == 'destroy') return\r\n if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\r\n if (typeof option == 'string') data[option]()\r\n })\r\n }", "title": "" }, { "docid": "9ae699d3719e4695b0d824f76560308a", "score": "0.60868585", "text": "function Plugin(option) {\r\n return this.each(function () {\r\n var $this = $(this)\r\n var data = $this.data('bs.tooltip')\r\n var options = typeof option == 'object' && option\r\n\r\n if (!data && option == 'destroy') return\r\n if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\r\n if (typeof option == 'string') data[option]()\r\n })\r\n }", "title": "" }, { "docid": "e48a694b8957d5b3c26e8454f640ea23", "score": "0.6085215", "text": "function activateTooltips() {\n $(\"[data-toggle='tooltip']\").tooltip()\n}", "title": "" } ]
b2b3dd1c0475432387ea9bef45928c1d
set, disable and/or enable buttons for dual XX watt (XXX) LED enviornment
[ { "docid": "60d26b96daea6357975d971e57e6c7f3", "score": "0.64182705", "text": "function set_1084_Env(){\r\n\tdocument.getElementById(\"2400\").checked=false;\r\n\tdocument.getElementById(\"2400\").disabled=true;\r\n}", "title": "" } ]
[ { "docid": "4262c843d4558fc0925fa7020291b459", "score": "0.7553797", "text": "function btn_set() {\n\t\tswitch (current_loc) {\n\t\t\tcase 0:\n\t\t\t\tif (loc[current_loc].loc_locked === true) {\n\t\t\t\t\tbtn_disable(\"all\");\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbtn_enable(\"btn0\");\n\t\t\t\t\tbtn_disable(\"btn1\",\"btn2\",\"btn3\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbtn_enable(\"btn0\",\"btn1\");\n\t\t\t\tbtn_disable(\"btn2\",\"btn3\");\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbtn_enable(\"all\");\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbtn_enable(\"btn0\",\"btn3\");\n\t\t\t\tbtn_disable(\"btn1\",\"btn2\");\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\tbtn_enable(\"btn1\",\"btn2\");\n\t\t\t\tbtn_disable(\"btn0\",\"btn3\");\n\t\t\t\tbreak;\n\t\t\tcase 5:\n\t\t\t\tbtn_enable(\"all\");\n\t\t\t\tbreak;\n\t\t\tcase 6:\n\t\t\t\tbtn_enable(\"btn2\",\"btn3\");\n\t\t\t\tbtn_disable(\"btn0\",\"btn1\");\n\t\t\t\tbreak;\n\t\t\tcase 7:\n\t\t\t\tif ((loc[current_loc].loc_visited > 1) && (loc[8].loc_locked === true)) {\n\t\t\t\t\tbtn_enable(\"btn2\");\n\t\t\t\t\tbtn_disable(\"btn0\",\"btn1\",\"btn3\");\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbtn_enable(\"btn0\",\"btn2\");\n\t\t\t\t\tbtn_disable(\"btn1\",\"btn3\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 8:\n\t\t\t\tbtn_enable(\"btn1\",\"btn2\");\n\t\t\t\tbtn_disable(\"btn0\",\"btn3\");\n\t\t\t\tbreak;\n\t\t\tcase 9:\n\t\t\t\tbtn_enable(\"btn0\",\"btn1\",\"btn3\");\n\t\t\t\tbtn_disable(\"btn2\");\n\t\t\t\tbreak;\n\t\t\tcase 10:\n\t\t\t\tbtn_enable(\"btn3\");\n\t\t\t\tbtn_disable(\"btn1\",\"btn2\",\"btn3\");\n\t\t\t\tbreak;\n\t\t\tcase 11:\n\t\t\t\tbtn_enable(\"btn2\");\n\t\t\t\tbtn_disable(\"btn0\",\"btn1\",\"btn3\");\n\t\t\t\tbreak;\n\t\t}\n\t}", "title": "" }, { "docid": "c4eafde8dc481210aa493344d2a55205", "score": "0.7086223", "text": "function setButtonsOn() {\n toggleStart = false;\n toggleEnd = false;\n document.getElementById(\"start\").disabled = false;\n document.getElementById(\"randWalls\").disabled = false;\n}", "title": "" }, { "docid": "0a9e3acee8d84a43e7b2f5abae531c0a", "score": "0.70714873", "text": "function enableButtons() {\n changeButtonsDisabled(RCALC_BUTTON, COLOR_WHITE, false);\n changeButtonsDisabled(RCALC_BUTTON_OPERATOR, COLOR_WHITE, false);\n}", "title": "" }, { "docid": "d183ed42daf2b757a1a603e84b0ef162", "score": "0.6890576", "text": "function toggleButtons() {\n rock.disabled = !rock.disabled;\n paper.disabled = !paper.disabled;\n scissor.disabled = !scissor.disabled;\n}", "title": "" }, { "docid": "47fac329ebba5337f9b1824a91d05452", "score": "0.6739006", "text": "function manual() {\n // switch manual watershed area on/off\n if(mode == 3) {\n mode = 0;\n }else{\n mode = 3;\n }\n changeButtons();\n}", "title": "" }, { "docid": "1dcf457cf1f7435a4dade28b64a12fa9", "score": "0.672321", "text": "function changeButtonState(flag) {\n\tif (flag == false) {\n\t\tif (self.IsNfc) {\n\t\t\tdocument.getElementById('disconnectBtn').disabled = false;\n\t\t\tdocument.getElementById('toolkitVersionBtn').disabled = false;\n\t\t\tdocument.getElementById('setNfcParams').disabled = false;\n\t\t\tdocument.getElementById('publicDataBtn').disabled = false;\n\t\t\tdocument.getElementById('verifyBioBtn').disabled = false;\n\t\t\treturn;\n\t\t}\n\t}\n\tvar buttons = document.getElementsByClassName(\"buttonInitial\");\n\tfor (let i = 0; i <= buttons.length - 1; i++) {\n\t\tbuttons[i].disabled = flag;\n\t}\n\tif (self.IsNfc === false) {\n\t\tdocument.getElementById('setNfcParams').disabled = true;\n\t}\n}", "title": "" }, { "docid": "24df8d0e2202a30dd2dcb0f2ef870d25", "score": "0.6680686", "text": "function setTurnOnOffBtn(){\n if(!$(\"#btnOnOff\").length){\n $(\"#btnBlacklist\").after(buttonOnOff);\n $(\"#btnOnOff\").css({\"background-color\": \"grey\", \"color\": \"darkgrey\"});\n var text = aus + getChatpartnerName();\n $(\"btnOnOff\").text(text);\n }else{\n var anText = an + getChatpartnerName();\n var ausText = aus + getChatpartnerName();\n var allow = permissionList[JSON.parse(getChatpartnerPhone())[1]];\n if($(\"#btnOnOff\").text().indexOf(aus) !== -1 && allow === \"yes\"){\n $(\"#btnOnOff\").css({\"background-color\": \"white\", \"color\": \"black\"});\n $(\"#btnOnOff\").text(anText);\n }else if(allow === \"yes\" && $(\"#btnOnOff\").text() !== anText){\n $(\"#btnOnOff\").text(anText);\n }\n\n if($(\"#btnOnOff\").text().indexOf(an) !== -1 && allow === \"no\"){\n $(\"#btnOnOff\").css({\"background-color\": \"grey\", \"color\": \"darkgrey\"});\n $(\"#btnOnOff\").text(ausText);\n }else if(allow === \"no\" && $(\"#btnOnOff\").text() !== ausText){\n $(\"#btnOnOff\").text(ausText);\n }\n }\n }", "title": "" }, { "docid": "006d2b0cf7fe63e81a23b65573f8bec9", "score": "0.66063565", "text": "function toggleCtrlState(){\n $(\".controls .btn\").toggleClass(\"disabled\");\n }", "title": "" }, { "docid": "08fd67c71bbddca7de32af77b6540f41", "score": "0.6583527", "text": "function index_clickTrunOnBtn() {\r\n\r\n $('#wifi_connection_button').html(create_button_html( common_turn_off + \" \" +wlan_label_wlan,\"wifi_turnOff_button\"));\r\n\r\n}", "title": "" }, { "docid": "d7205008fbdf380892e3425a10c6318b", "score": "0.653335", "text": "function enableLights() {\n submitCommand(\"on\");\n\n if(currentConfiguation.brightness===0) {\n currentConfiguation.brightness = 50;\n updateColor();\n }\n}", "title": "" }, { "docid": "eeebd5066e2f18429e0ddc485aa7284a", "score": "0.6515477", "text": "function disableBoard() {\n buttonOne.disabled = true;\n buttonTwo.disabled = true;\n buttonThree.disabled = true;\n buttonFour.disabled = true;\n buttonFive.disabled = true;\n}", "title": "" }, { "docid": "775940d8ee9df730ee1b6157ba16ab96", "score": "0.64969814", "text": "function trigger(val){\n\tbtn[0].disabled = val\n\trandom_btn.disabled = val\n\tbtn[1].disabled = val\n}", "title": "" }, { "docid": "67d75f2c929f942cf4cbe683b23a899c", "score": "0.64856267", "text": "function lightXonoff() {\n\t$('.lightController').on('click', function(){\n\t\tvar bulb = $(this).data('bulb');\n\t\tif($(this).hasClass('btn-primary')){\n\t\t\t$.ajax({\n\t\t\t type: 'PUT',\n\t\t\t url: allLights+bulb+'/state/',\n\t\t\t data: '{\"on\": false}'\n\t\t\t});\n\t\t}\n\t\tif($(this).hasClass('btn-default')){\n\t\t\t$.ajax({\n\t\t\t type: 'PUT',\n\t\t\t url: allLights+bulb+'/state/',\n\t\t\t data: '{\"on\": true, \"bri\": 254}'\n\t\t\t});\n\t\t}\n\tupdateEverything();\n\t});\n}", "title": "" }, { "docid": "40bd125d6a10a86baa1934aa5feeea78", "score": "0.6472582", "text": "function index_clickTrunOnBtn() {\r\n\r\n $('#wifi_connection_button').html(create_button_html( common_turn_off + \" \" +wlan_label_wlan,\"wifi_turnOff_button\"));\r\n ieRadiusBorder();\r\n\r\n}", "title": "" }, { "docid": "d58f72d63071d3b494f8ad44fef775f8", "score": "0.645398", "text": "function toggleShipController(on) {\n\trotateClockwiseBtn.disabled = on;\n\trotateCounterClockwiseBtn.disabled = on;\n\tthrustBtn.disabled = on;\n\tshootBtn.disabled = on;\n}", "title": "" }, { "docid": "c05d88bb5920b05239a725d2bf05af01", "score": "0.6448499", "text": "function disableLights() {\n currentConfiguation.ambiento = false;\n rainbowConfiguration.enabled = false;\n submitCommand(\"off\");\n}", "title": "" }, { "docid": "bf51d92a2983d27867f42219e94d9058", "score": "0.6426702", "text": "function set_1018_Env(){\r\n\tdocument.getElementById(\"2400\").checked=false;\r\n\tdocument.getElementById(\"2400\").disabled=true;\r\n}", "title": "" }, { "docid": "bf54708074faf502a8b88268fcadd7ca", "score": "0.6409208", "text": "function setup(){\nwire.writeBytes(0x21, 0x00); // 8x8 Bi-Color LED Matrix Set-up\nwire.writeBytes(0x81, 0x00); // Display on and no blinking\nwire.writeBytes(0xE7, 0x00); // Configures the brightness\n}", "title": "" }, { "docid": "ad0e4bb79bb956b6b02f36e14c5ee091", "score": "0.6393278", "text": "changeButtonsBarClickablity(){\n var state = false\n\n if(!this.shadowRoot.getElementById('homeBtn').disabled)\n state = true\n\n this.shadowRoot.getElementById('homeBtn').disabled = state\n this.shadowRoot.getElementById('ergoBtn').disabled = state\n this.shadowRoot.getElementById('clubBtn').disabled = state\n this.shadowRoot.getElementById('participantRankingBtn').disabled = state\n this.shadowRoot.getElementById('distanceBtn').disabled = state\n this.shadowRoot.getElementById('isterBtn').disabled = state\n this.shadowRoot.getElementById('mainBtn').disabled = state\n this.shadowRoot.getElementById('challengeManagerBtn').disabled = state\n }", "title": "" }, { "docid": "57fe1ee4dd7b1efb2c14fdfa8d042211", "score": "0.6378145", "text": "function SetDisconnectedButtons() {\r\n var closeButton = document.getElementById(\"DisconnectButton\");\r\n closeButton.className = \"button primary tight disabled\";\r\n var connectButton = document.getElementById(\"ConnectButton\");\r\n connectButton.className = \"button primary tight\";\r\n connectButton.style.opacity = 1;\r\n closeButton.style.opacity = .2;\r\n HideDeviceButtons();\r\n}", "title": "" }, { "docid": "3a1548ac40c5a4430f6287c3649a27cf", "score": "0.6377766", "text": "function enableDisableBtns() {\n switch (currentPhoto) {\n case FIRSTPHOTO:\n firstBtn.disabled = true;\n previousBtn.disabled = true;\n nextBtn.disabled = false;\n lastBtn.disabled = false;\n break;\n case LASTPHOTO:\n firstBtn.disabled = false;\n previousBtn.disabled = false;\n nextBtn.disabled = true;\n lastBtn.disabled = true;\n break;\n default:\n firstBtn.disabled = false;\n previousBtn.disabled = false;\n nextBtn.disabled = false;\n lastBtn.disabled = false;\n }\n }", "title": "" }, { "docid": "20902c0e379d4aae37c3f9f25a12f579", "score": "0.6345059", "text": "function set_2590_Env(){\r\n\tdocument.getElementById(\"2400\").checked=false;\r\n\tdocument.getElementById(\"2400\").disabled=false;\r\n}", "title": "" }, { "docid": "48cc62a770dc07c037fc409c46f619a0", "score": "0.6342168", "text": "function disableButtons(bool)\n{\n document.getElementById(\"RButton\").disabled = bool;\n document.getElementById(\"rButton\").disabled = bool;\n document.getElementById(\"LButton\").disabled = bool;\n document.getElementById(\"lButton\").disabled = bool;\n document.getElementById(\"UButton\").disabled = bool;\n document.getElementById(\"uButton\").disabled = bool;\n document.getElementById(\"DButton\").disabled = bool;\n document.getElementById(\"dButton\").disabled = bool;\n document.getElementById(\"FButton\").disabled = bool;\n document.getElementById(\"fButton\").disabled = bool;\n document.getElementById(\"BButton\").disabled = bool;\n document.getElementById(\"bButton\").disabled = bool;\n document.getElementById(\"RandomButton\").disabled = bool;\n document.getElementById(\"ScrambleButton\").disabled = bool;\n document.getElementById(\"unScrambleButton\").disabled = bool;\n}", "title": "" }, { "docid": "fc6e8a6ee4cf8ef30938b1c33a24fc07", "score": "0.63386726", "text": "function disableSettingButtons(){\n saveButton.className = \"btn--disabled\";\n saveButton.disabled = true;\n\n cancelButton.className = \"btn--disabled\";\n cancelButton.disabled = true;\n}", "title": "" }, { "docid": "3a19afac71068fd27b7e4faab60bc3f8", "score": "0.6318804", "text": "function disableButtons()\n\t{\n\t\tgetObject(\"btnUndo\").disabled = true;\n\t\tgetObject(\"btnDraw\").disabled = true;\n\t\tgetObject(\"btnResign\").disabled = true;\n\t}", "title": "" }, { "docid": "c64d9e8573d1cc9fb6395aae7b701660", "score": "0.6280899", "text": "function enableDisableButtons() {\n if (isTimerCounting) {\n sessionAmountSlider.disabled = true;\n sessionLengthSlider.disabled = true;\n breakLengthSlider.disabled = true;\n } else {\n sessionAmountSlider.disabled = false;\n sessionLengthSlider.disabled = false;\n breakLengthSlider.disabled = false;\n }\n}", "title": "" }, { "docid": "a76b089a798f74b28870bf192c5c8634", "score": "0.6270143", "text": "function disable()\r\n{\r\n ans1.disabled = true;\r\n ans2.disabled = true;\r\n ans3.disabled = true;\r\n ans4.disabled = true;\r\n document.querySelector(`#bmonay`).disabled = true;\r\n clearInterval(d1);\r\n clearInterval(d2);\r\n clearInterval(d3);\r\n // strtButton.disabled = true;\r\n}", "title": "" }, { "docid": "6b2c799c4b37d1ab58b8cdef405982a0", "score": "0.62658966", "text": "function index_clickTrunOnBtn() {\r\n\r\n if(g_module.cradle_enabled) {\r\n \t$('#scan_div').show();\r\n checkOffloadScanEnabled();\r\n } else {\r\n scanWifi();\r\n }\r\n $('#wifi_switch_button').html(create_button_html(common_turn_off, \"turnOff_button\"));\r\n ieRadiusBorder();\r\n\r\n}", "title": "" }, { "docid": "6e992ca2542cfdc421bfc0d9594bcb81", "score": "0.62592363", "text": "function disable_buttons() {\n for(var i=0;i<butts_algos.length;i++)\n {\n butts_algos[i].classList=[];\n butts_algos[i].classList.add(\"butt_locked\");\n\n butts_algos[i].disabled=true;\n inp_as.disabled=true;\n inp_gen.disabled=true;\n inp_aspeed.disabled=true;\n }\n}", "title": "" }, { "docid": "fe42d2ad893536a3a05023e16fd9a919", "score": "0.6258415", "text": "function changeLEDButton() {\n console.log(\"Button clicked\")\n \n led = webLedState; // Get previous web LED state\n\n // Toggle LED state and publish\n if(led.toString('utf-8') == 'false'){ // If previous LED state off\n client.publish(\"topic/digitalLed\", 'true') // Publish manual digital LED topic (ON)\n }\n else{ // Else (if previous LED state on)\n client.publish(\"topic/digitalLed\",'false') // Publish manual digital LED topic (OFF)\n }\n}", "title": "" }, { "docid": "ecd3a550878f06c3fa92d076c07e8f00", "score": "0.62532043", "text": "function disableBtns() {\n $(stopBtn).attr(\"disabled\", \"disabled\");\n $(settingsBtn).attr(\"disabled\", \"disabled\");\n setTimeout(function () {\n $(stopBtn).attr(\"disabled\", false);\n $(settingsBtn).attr(\"disabled\", false);\n }, 2500);\n }", "title": "" }, { "docid": "7c89cb959bc95bc02278e42991ddaecd", "score": "0.6244164", "text": "function set_2545_Env(){\r\n\tdocument.getElementById(\"2400\").checked=false;\r\n\tdocument.getElementById(\"2400\").disabled=false;\r\n}", "title": "" }, { "docid": "e34dd05c6eb134a9e21d1dc2f47da257", "score": "0.62432414", "text": "function setButtons() {\n\tsetDeleteButtons();\n\tsetReadToggle();\n}", "title": "" }, { "docid": "37b0ec09f999b30f40b56e1b3a7aee80", "score": "0.6236998", "text": "function changeButtons(){\n if(mode==1){\n document.getElementById('DelineateButton').value = \"Stop Delineating\";\n } else {\n document.getElementById('DelineateButton').value = \"Delineate\";\n }\n \n if(mode == 2){\n if(huctype == 12){\n document.getElementById('HUC12Button').value = \"Stop\";\n document.getElementById('HUC10Button').value = \"HUC 10\";\n document.getElementById('HUC8Button').value = \"HUC 8\";\n } else if (huctype == 10){\n document.getElementById('HUC12Button').value = \"HUC 12\";\n document.getElementById('HUC10Button').value = \"Stop\";\n document.getElementById('HUC8Button').value = \"HUC 8\";\n } else {\n document.getElementById('HUC12Button').value = \"HUC 12\";\n document.getElementById('HUC10Button').value = \"HUC 10\";\n document.getElementById('HUC8Button').value = \"Stop\";\n }\n } else {\n document.getElementById('HUC12Button').value = \"HUC 12\";\n document.getElementById('HUC10Button').value = \"HUC 10\";\n document.getElementById('HUC8Button').value = \"HUC 8\";\n }\n \n if(mode == 3){\n document.getElementById('switchtextarea').innerHTML = \"Click <input type='button' id='switch' value='Stop' onClick='manual();' /> to switch back to viewing mode\";\n\n } else {\n document.getElementById('switchtextarea').innerHTML = \"Click \" +\n \"<input type='button' id='switch' value='Start' onClick='manual();' />\" + \n \" to begin digitization.\";\n }\n \n if(loadedtools == 1){\n lut = document.getElementById('switchlandusetext');\n if(mode == 4){\n lut.innerHTML = \"Click to create corners for your desired area. Hover your\" +\n \" mouse over a point, and when a hand appears, press and drag the point for better fit, or click to remove the point.<br /><br />\" +\n \"Click <input type='button' id='switch' value='Stop' onClick='manualLanduse();' /> to switch back to viewing mode\";\n } else {\n lut.innerHTML = \"Click \" +\n \"<input type='button' id='switch' value='Start' onClick='manualLanduse();' />\" + \n \" to begin digitization.\";\n }\n }\n}", "title": "" }, { "docid": "e46e69b167241d17742b3049703dd296", "score": "0.62331", "text": "toggleButtonsDisabled(){\n buttonPlayer1.toggleAttribute('disabled');\n buttonPlayer2.toggleAttribute('disabled');\n }", "title": "" }, { "docid": "b9f0c3c0ed8e9d348c53690f9df6dbb8", "score": "0.6231438", "text": "function stopEnabled(btn) {\n \n}", "title": "" }, { "docid": "13062c4e84784edc599aed9035aaf066", "score": "0.62210363", "text": "function setupButton(pin, delta) {\n GPIO.set_mode(pin, GPIO.MODE_INPUT);\n GPIO.set_button_handler(pin, GPIO.PULL_UP, GPIO.INT_EDGE_NEG\n\t , 50 /*debounce ms*/\n\t , buttonPressed\n\t , delta);\n GPIO.enable_int(pin);\n}", "title": "" }, { "docid": "93f852c4f410d792c8c2a5cb4fa7e75e", "score": "0.62194824", "text": "function toggleControls(enabled) {\r\n id(\"queryCtrls\").disabled = (!enabled);\r\n id(\"scenario1Output\").disabled = (!enabled);\r\n if (enabled) {\r\n id(\"savekey\").className = \"action secondary\";\r\n id(\"runquery\").className = \"action\";\r\n\r\n } else {\r\n id(\"savekey\").className = \"action\";\r\n id(\"runquery\").className = \"action secondary\";\r\n }\r\n }", "title": "" }, { "docid": "53dcf2e96c22b0f2d1cb3b4fff5c0055", "score": "0.6211013", "text": "function toggleButton() {\n if (audioValue !== \"not selected\") {\n htmlElements.onOff.removeAttribute(\"disabled\");\n } else {\n htmlElements.onOff.setAttribute(\"disabled\", \"true\");\n }\n}", "title": "" }, { "docid": "88b4f8ae160ac35ed746eea39552c71f", "score": "0.6206744", "text": "function SwitchToggle(idx, switchcmd)\n{\n DomoticzAction(idx, \"switchlight\", switchcmd, null);\n}", "title": "" }, { "docid": "c48f8333501f35a4ed4e03c43404dac6", "score": "0.6204602", "text": "function enableMeetingActionButtons() {\n document.getElementById('call-controls').disabled = false;\n document.getElementById('dialer').disabled = false;\n document.getElementById('register').disabled = true;\n document.getElementById('unregister').disabled = false;\n}", "title": "" }, { "docid": "957e36d4d211df198fbca66af79fe0e1", "score": "0.6203585", "text": "function set_3590_Env(){\r\n\tdocument.getElementById(\"2400\").checked=false;\r\n\tdocument.getElementById(\"2400\").disabled=false;\r\n}", "title": "" }, { "docid": "95010a93e377169ee6d75519094843ff", "score": "0.62005115", "text": "function toggleW() {\n if(state == bone.LOW)\n state = bone.HIGH;\n else\n state = bone.LOW;\n \n bone.digitalWrite(ledPin01, state);\n}", "title": "" }, { "docid": "933e8f4eb0b2e14a9e515ac63c77e1e6", "score": "0.61998725", "text": "function set_status_led() {\n var led = document.getElementById('led_status');\n led.setAttribute('status', connection);\n}", "title": "" }, { "docid": "7bb0d9c6c6fa47f816869e1e8a648468", "score": "0.61964554", "text": "function setBtnState() {\n if (currentLoc === \"Room1\") {\n document.getElementById(\"btnWest\").disabled = true;\n document.getElementById(\"btnNorth\").disabled = false;\n document.getElementById(\"btnSouth\").disabled = true;\n document.getElementById(\"btnEast\").disabled = true;\n } else {\n if (currentLoc === \"Room2\") {\n document.getElementById(\"btnWest\").disabled = false;\n document.getElementById(\"btnNorth\").disabled = false;\n document.getElementById(\"btnSouth\").disabled = false;\n document.getElementById(\"btnEast\").disabled = true;\n } else {\n if (currentLoc === \"Room3\") {\n document.getElementById(\"btnWest\").disabled = true;\n document.getElementById(\"btnNorth\").disabled = false;\n document.getElementById(\"btnSouth\").disabled = false;\n document.getElementById(\"btnEast\").disabled = true;\n } else {\n if (currentLoc === \"Room4\") {\n document.getElementById(\"btnWest\").disabled = true;\n document.getElementById(\"btnNorth\").disabled = true;\n document.getElementById(\"btnSouth\").disabled = true;\n document.getElementById(\"btnEast\").disabled = true;\n } else {\n if (currentLoc === \"Room5\") {\n document.getElementById(\"btnWest\").disabled = true;\n document.getElementById(\"btnNorth\").disabled = true;\n document.getElementById(\"btnSouth\").disabled = true;\n document.getElementById(\"btnEast\").disabled = false;\n } else {\n if (currentLoc === \"Room6\") {\n document.getElementById(\"btnWest\").disabled = true;\n document.getElementById(\"btnNorth\").disabled = true;\n document.getElementById(\"btnSouth\").disabled = true;\n document.getElementById(\"btnEast\").disabled = true;\n } else {\n if (currentLoc === \"Room7\") {\n document.getElementById(\"btnWest\").disabled = true;\n document.getElementById(\"btnNorth\").disabled = true;\n document.getElementById(\"btnSouth\").disabled = true;\n document.getElementById(\"btnEast\").disabled = true;\n }\n }\n }\n }\n }\n }\n }\n }", "title": "" }, { "docid": "bf2e7aac1b6cd145d0599dff6d23efa1", "score": "0.61767626", "text": "function enableBtn(btn1, btn2, btn3, btn4) {\n if (btn2 === undefined && btn3 === undefined && btn4 === undefined) {\n btn1.disabled = false;\n } else if (btn3 === undefined && btn4 === undefined){\n btn1.disabled = false;\n btn2.disabled = false;\n } else if (btn4 === undefined){\n btn1.disabled = false;\n btn2.disabled = false;\n btn3.disabled = false;\n } else {\n btn1.disabled = false;\n btn2.disabled = false;\n btn3.disabled = false;\n btn4.disabled = false;\n }\n}", "title": "" }, { "docid": "44f634b8279f71a9efdcad0164dd8ca1", "score": "0.61749655", "text": "function toggleButtons() {\n\t\tif(timer === null) {\n\t\t\tdocument.getElementById(\"stopbutton\").disabled = true;\n\t\t\tdocument.getElementById(\"stopbutton\").style.backgroundColor = \"#D3D3D3\";\n\t\t\tdocument.getElementById(\"startbutton\").disabled = false;\n\t\t\tdocument.getElementById(\"startbutton\").style.backgroundColor = \"white\";\n\t\t}\n\t\telse {\n\t\t\tdocument.getElementById(\"startbutton\").disabled = true;\n\t\t\tdocument.getElementById(\"startbutton\").style.backgroundColor = \"#D3D3D3\";\n\t\t\tdocument.getElementById(\"stopbutton\").disabled = false;\n\t\t\tdocument.getElementById(\"stopbutton\").style.backgroundColor = \"white\";\n\t\t}\n\t}", "title": "" }, { "docid": "c5ff2b95405eaf0ba180bfaacf598ec0", "score": "0.6169502", "text": "function enableButtons() {\n buttons.forEach(elem => {\n elem.disabled = false;\n })\n}", "title": "" }, { "docid": "227a64e704ce01689087d1ac41daba08", "score": "0.61600417", "text": "function SetConnectedButtons() {\r\n var closeButton = document.getElementById(\"DisconnectButton\");\r\n closeButton.className = \"button primary tight\";\r\n closeButton.style.opacity = 1;\r\n var connectButton = document.getElementById(\"ConnectButton\");\r\n connectButton.className = \"button dark tight disabled\";\r\n connectButton.style.opacity = .2;\r\n HideDeviceButtons();\r\n}", "title": "" }, { "docid": "ed1ffc99ddd1e13eaf3c9d45396e5a4b", "score": "0.6158545", "text": "function toggleButtonHandler() {\n\t\n\tledOn = !ledOn;\n\tupdateLedDisplay();\n\t\n\t// The setled Particle cloud function takes a string of the state to set, either \"1\" or \"0\"\n\tvar arg = (ledOn ? \"1\" : \"0\");\n\t\n\tparticle.callFunction({ deviceId:deviceId, name: 'setled', argument: arg, auth: accessToken }).then(\n\t\tfunction(data) {\n\t\t\tconsole.log('setled success ', data);\n\t\t}, function(err) {\n\t\t\tconsole.log('setled error ', err);\n\t\t});\n\n\t\n}", "title": "" }, { "docid": "b209f701617fc42e22277ef4e3352980", "score": "0.61486405", "text": "function disableButtons() {\n document.getElementById('register').disabled = true;\n document.getElementById('unregister').disabled = true;\n}", "title": "" }, { "docid": "0fcf8cbc76481beb42c0816ce8256581", "score": "0.6140943", "text": "function set_3545_Env(){\r\n\tdocument.getElementById(\"2400\").checked=false;\r\n\tdocument.getElementById(\"2400\").disabled=false;\r\n}", "title": "" }, { "docid": "3e802db444d4e3cbbd20d32d9d82f503", "score": "0.61374676", "text": "function startButtons(){\n\tdocument.getElementById(\"start\").disabled = true;\n\tdocument.getElementById(\"stop\").disabled = false;\n\tdocument.getElementById(\"split\").disabled = false;\n\n}", "title": "" }, { "docid": "1d348030bfe3c932b0e9151b487d82f7", "score": "0.61364263", "text": "function belt_automode_is_false() {\n document.getElementById(\"belt_monitor_mode\").innerHTML = 'Manual control';\n document.getElementById(\"img_safety_button_belt\").src = \"img/run_belt_auto.png\";\n document.getElementById(\"img_safety_button_belt\").onclick = belt_make_automode_true;\n document.getElementById('belt_man_auto_switch').checked = false;\n document.getElementsByClassName('beltonoffswitch')[0].style.opacity = 1.0;\n document.getElementsByClassName('beltdirectionswitch')[0].style.opacity = 1.0;\n document.getElementsByClassName('beltspeedswitch')[0].style.opacity = 1.0;\n}", "title": "" }, { "docid": "138962aafcc9d183b8061fd6465e8b83", "score": "0.6135008", "text": "function setElementStatuSwitch(id){\n\t\t\t\tvar elt = getById(id);\n\t\t\t\telt.disabled = !elt.disabled;\n\t\t\t}", "title": "" }, { "docid": "32f1f0cea0478037c271fa2ff4c0866f", "score": "0.61172503", "text": "function set_4545_Env(){\r\n\tdocument.getElementById(\"2400\").checked=false;\r\n\tdocument.getElementById(\"2400\").disabled=false;\r\n}", "title": "" }, { "docid": "316925739b4266d0ba804372406f4457", "score": "0.6113856", "text": "function bleDisabled() {\n\t$(\"#status\").html(\"Enable Bluetooth first.\");\n}", "title": "" }, { "docid": "808ab26ff529421e967fad8bcd6f6b22", "score": "0.610976", "text": "function ant_switch_config_html()\n{\n // *_no_yes: 0 -> 'No', 1 -> 'Yes' in w3_switch() below\n var denyswitching_no_yes = ext_get_cfg_param('ant_switch.denyswitching', '', EXT_NO_SAVE)? 0:1;\n var denymixing_no_yes = ext_get_cfg_param('ant_switch.denymixing', '', EXT_NO_SAVE)? 0:1;\n var denymultiuser_no_yes = ext_get_cfg_param('ant_switch.denymultiuser', '', EXT_NO_SAVE)? 0:1;\n\text_admin_config(ant_switch_ext_name, 'Antenna switch',\n\t\tw3_divs('id-ant_switch w3-text-teal w3-hide', '',\n\t\t\t'<b>Antenna switch configuration</b>' +\n\t\t\t'<hr>' +\n\t\t\tw3_divs('', 'w3-container',\n\t\t\t\tw3_divs('', 'w3-margin-bottom',\n w3_divs('', '','If antenna switching is denied then users cannot switch antennas. Admin can always switch antennas from KiwiSDR ssh root console using /root/extensions/ant_switch/frontend/ant-switch-frontend script.'),\n w3_divs('', '', '<b>Deny antenna switching?</b> ' +\n w3_switch('', 'No', 'Yes', 'ant_switch.denyswitching', denyswitching_no_yes, 'ant_switch_conf_denyswitching')\n ),\n w3_divs('', '','If antenna mixing is denied then users can select only one antenna at time.'),\n w3_divs('', '', '<b>Deny antenna mixing?</b> ' +\n w3_switch('', 'No', 'Yes', 'ant_switch.denymixing', denymixing_no_yes, 'ant_switch_conf_denymixing')\n ),\n w3_divs('', '','If multiuser is denied then antenna switching is disabled when more than 1 user is online.'),\n w3_divs('', '', '<b>Deny multiuser switching?</b> ' +\n w3_switch('', 'No', 'Yes', 'ant_switch.denymultiuser', denymultiuser_no_yes, 'ant_switch_conf_denymultiuser')\n ),\n w3_divs('', '','<b>Thunderstorm</b><br>'),\n w3_button('','Ground all antennas immediately and deny switching', 'ant_switch_thunderstorm'), \n w3_divs('', '','<hr><b>Antenna buttons configuration</b><br>'),\n w3_divs('', '','Leave Antenna description field empty if you want to hide antenna button from users<br>'),\n\t\t\t\t\tw3_input_get_param('Antenna 1 description', 'ant_switch.ant1desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna 2 description', 'ant_switch.ant2desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna 3 description', 'ant_switch.ant3desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna 4 description', 'ant_switch.ant4desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna 5 description', 'ant_switch.ant5desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna 6 description', 'ant_switch.ant6desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna 7 description', 'ant_switch.ant7desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna 8 description', 'ant_switch.ant8desc', 'w3_string_set_cfg_cb', ''),\n\t\t\t\t\tw3_input_get_param('Antenna switch failure or unknown status decription', 'ant_switch.ant0desc', 'w3_string_set_cfg_cb', '')\n\t\t\t\t), '', ''\n\t\t\t)\n\t\t)\n\t);\n}", "title": "" }, { "docid": "8f250bf22b43d44dbd24db60d2254dd7", "score": "0.6104786", "text": "function stopButtons(){\n\tdocument.getElementById(\"start\").disabled = false;\n\tdocument.getElementById(\"stop\").disabled = true;\n\tdocument.getElementById(\"split\").disabled = true;\n\n}", "title": "" }, { "docid": "ee2f298fffd77fa4c5dde933f53e139b", "score": "0.61024433", "text": "function disableButton() {\n\t\t\tnorth_ClickDisabled();\n\t\t\tsouth_ClickDisabled();\n\t\t\teast_ClickDisabled();\n\t\t\twest_ClickDisabled();\n\t\t}", "title": "" }, { "docid": "8e8365210035ace2910cc3339094aa45", "score": "0.6084706", "text": "function enable_buttons(status) {\n if (status) {\n btn_guardar_factura.disabled = false\n btn_ver_factura.disabled = false\n } else {\n btn_guardar_factura.disabled = true\n btn_ver_factura.disabled = true\n }\n}", "title": "" }, { "docid": "ed11c3b9301ff60581c674c32bc6347c", "score": "0.60839224", "text": "function onOFF(){\r\n operation = '';\r\n\r\n if(!onOff){\r\n onOff = !onOff;\r\n screen.placeholder = 0\r\n btnOn.textContent = 'OFF';\r\n btnOn.style.background = \" rgb(155, 150, 86)\";\r\n screen.style.backgroundColor = '#BDB762';\r\n }else {\r\n onOff = !onOff;\r\n screen.value = ''\r\n screen.placeholder = ''\r\n screen.style.backgroundColor = '#BDB762';\r\n btnOn.textContent = 'ON';\r\n btnOn.style.background = \"rgb(255, 0, 0)\";\r\n }\r\n}", "title": "" }, { "docid": "bfb6b606554721fcf44ab44cb4756179", "score": "0.60651606", "text": "function disableButtons() {\n spells.forEach(spell => {\n spell.disabled = true;\n spell.style.background = \"rgba(0,0,0,0.4)\";\n });\n weapons.forEach(weapon => {\n weapon.disabled = true;\n weapon.style.background = \"rgba(0,0,0,0.4)\";\n });\n}", "title": "" }, { "docid": "e99a1febbed1cf95619f201c00e156ba", "score": "0.60483", "text": "function wfd(){\n startButton.disabled = false;\n}", "title": "" }, { "docid": "8c290aefecc73740450a7b7ea54c8b2f", "score": "0.604823", "text": "function onChangeEnableGPIOWakeupLPDS(inst, ui)\r\n{\r\n let subState = (!inst.enableGPIOWakeupLPDS);\r\n ui.wakeupGPIOTypeLPDS.hidden = subState;\r\n ui.wakeupGPIOSourceLPDS.hidden = subState;\r\n ui.wakeupGPIOFxnLPDS.hidden = subState;\r\n}", "title": "" }, { "docid": "4ecd204382781b72c69100a9bb64d49a", "score": "0.6039909", "text": "function toggleClick(option) {\n const buttons = document.querySelectorAll(\".breed\");\n switch (option) {\n case \"on\":\n for (let button of buttons) {\n button.disabled = false;\n }\n break;\n case \"off\":\n console.log(\"click toggle\")\n for (let button of buttons) {\n button.disabled = true;\n }\n break;\n }\n}", "title": "" }, { "docid": "98ce88546ee59b1dc08a2f12cc5b3338", "score": "0.6027745", "text": "function refreshButtons(butOn){\r\n\tif(butOn == undefined){butOn = true;}\r\n\r\n\t// check for active leds in frame\r\n\tvar\tledOnCount = 0,\r\n\t\tledColCount = 0,\r\n\t\tledCol = null;\r\n\r\n\tfor(var i=0; i<24; i++){\r\n\t\tvar codeRGB = ledFrame[i].r + ',' + ledFrame[i].g + ',' + ledFrame[i].b;\r\n\t\tif(!(codeRGB == '0,0,0')){\r\n\t\t\tledOnCount ++;\r\n\t\t\tif(codeRGB != ledCol){\r\n\t\t\t\tledColCount ++;\r\n\t\t\t\tledCol = codeRGB;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// check for inactive frames and frames with inactive leds in animation\r\n\tvar frameOffCount = 0;\r\n\tvar frameFillCount = 0;\r\n\tfor(var i=0; i<ledFrames.length; i++){\r\n\t\tvar colFrame = 0;\r\n\t\tvar ledOffCount = 0;\r\n\t\tfor(var j=0; j < ledFrames[i].length; j++){\r\n\t\t\tvar\tcR = Number(ledFrames[i][j].r),\r\n\t\t\t\tcG = Number(ledFrames[i][j].g),\r\n\t\t\t\tcB = Number(ledFrames[i][j].b);\r\n\r\n\t\t\tcolFrame += (cR + cG + cB);\r\n\t\t\tif(cR + cG + cB == 0){ledOffCount ++;}\r\n\t\t}\r\n\t\tif(ledOffCount > 0){frameFillCount ++;}\r\n\t\tif(colFrame == 0){frameOffCount ++;}\r\n\t}\r\n\r\n\tbut_copy_ani.disabled = true;\r\n\tbut_rename_ani.disabled = true;\r\n\tdropAnimation.disabled = true;\r\n\tbutPlay.disabled = true;\r\n\r\n\tbut_edit_fill.disabled = true;\r\n\tbut_edit_flow.disabled = true;\r\n\r\n\tdropFillType.disabled = true;\r\n\tdropFillRange.disabled = true;\r\n\tbut_color_acquire.disabled = true;\r\n\r\n\tbut_edit_undo.disabled = true;\r\n\tbut_edit_redo.disabled = true;\r\n\r\n\tbut_ani_open.disabled = true;\r\n\tbut_ani_store.disabled = true;\r\n\tbut_image_import.disabled = true;\r\n\r\n\tbut_frame_add.disabled = true;\r\n\tbut_frame_copy.disabled = true;\r\n\tbut_ani_fill_flow.disabled = true;\r\n\tbut_ani_fill_connect.disabled = true;\r\n\tbut_ani_delete.disabled = true;\r\n\r\n\tbut_select_editor.disabled = true;\r\n\r\n\tbut_frame_clock.disabled = true;\r\n\tbut_frame_counterclock.disabled = true;\r\n\tbut_frame_push.disabled = true;\r\n\tbut_frame_pull.disabled = true;\r\n\r\n\tbut_open_image.disabled = true;\r\n\tbut_import_accept.disabled = true;\r\n\tbut_import_cancel.disabled = true;\r\n\tbut_scan_direction.disabled = true;\r\n\r\n\tmenu_select_editor.style.visibility = 'hidden';\r\n\r\n\tif(!storeLeditorOn && !colorSelectionOn && !settingsOn) {\r\n\t\tbutPlay.disabled = false;\r\n\t}\r\n\r\n\tif(butOn && !playMode && !storeLeditorOn && !colorSelectionOn && !settingsOn) {\r\n\t\tbut_copy_ani.disabled = false;\r\n\t\tbut_rename_ani.disabled = false;\r\n\t\tdropAnimation.disabled = false;\r\n\r\n\r\n\t\tbut_ani_store.disabled = false;\r\n\t\tbut_ani_open.disabled = false;\r\n\t\tbut_image_import.disabled = false;\r\n\t\tif(count_frames < max_fields){\r\n\t\t\tbut_frame_add.disabled = false;\r\n\t\t\tbut_frame_copy.disabled = false;\r\n\t\t}\r\n\t\tif(frameOffCount > 0 && frameOffCount < ledFrames.length){\r\n\t\t\tbut_ani_fill_flow.disabled = false;\r\n\t\t\tbut_ani_fill_connect.disabled = false;\r\n\t\t}\r\n\t\tbut_ani_delete.disabled = false;\r\n\r\n\t\tbut_select_editor.disabled = false;\r\n\r\n\t\tif(ledOnCount > 0){\r\n\t\t\tbut_frame_clock.disabled = false;\r\n\t\t\tbut_frame_counterclock.disabled = false;\r\n\t\t\tbut_frame_push.disabled = false;\r\n\t\t\tbut_frame_pull.disabled = false;\r\n\t\t\tif(ledOnCount < 24 || (checkAllFrames.checked && frameFillCount > 0)){\r\n\t\t\t\tbut_edit_fill.disabled = false;\r\n\t\t\t\tbut_edit_flow.disabled = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tbut_open_image.disabled = false;\r\n\t\tbut_import_cancel.disabled = false;\r\n\t\tif(imgImport != null){\r\n\t\t\tbut_import_accept.disabled = false;\r\n\t\t\tbut_scan_direction.disabled = false;\r\n\t\t}\r\n\t\tdropFillType.disabled = false;\r\n\t\tdropFillRange.disabled = false;\r\n\t\tif(dropFillType.value != 'type_3'){\r\n\t\t\tbut_color_acquire.disabled = false;\r\n\t\t}\r\n\r\n\t\tif(undoPointer > 0){but_edit_undo.disabled = false;}\r\n\t\tif(undoPointer < undoList.length-1){but_edit_redo.disabled = false;}\r\n\t}\r\n}", "title": "" }, { "docid": "c891448663dae3496d9ce40bd18e181c", "score": "0.6022099", "text": "function changeButtons() {\n if (canMoveForward === false) {\n buttonStatus(\"#forwardButton\", \"off\");\n } else if (canMoveForward === true) {\n buttonStatus(\"#forwardButton\", \"on\");\n }\n\n if (canMoveBackward === false) {\n buttonStatus(\"#backwardButton\", \"off\");\n } else if (canMoveBackward === true) {\n buttonStatus(\"#backwardButton\", \"on\");\n }\n}", "title": "" }, { "docid": "ddf976c12f9c6403fccdd57f5023b8d9", "score": "0.6020016", "text": "function nightMode(e){\n if(nightModeButton.value==\"off\"){\n nightModeButton.setAttribute('value','on');\n document.querySelector(\".header\").style.backgroundColor = \"#000411\";\n document.querySelector(\".footer\").style.background = \"#000411\";\n document.querySelector(\"body\").style.backgroundColor = \"#000411\";\n document.querySelector(\"#light-theme\").id = 'dark-theme'\n }else{\n nightModeButton.setAttribute('value','off');\n document.querySelector(\".header\").style.backgroundColor = lightPalette[0];\n document.querySelector(\".footer\").style.background = lightPalette[1];\n document.querySelector(\"body\").style.backgroundColor = lightPalette[2];\n document.querySelector(\"#dark-theme\").id = 'light-theme'\n }\n}", "title": "" }, { "docid": "65e8f043fbab921d30a5b8fc9924acb9", "score": "0.6009032", "text": "function disable_buttons() {\n\tif( potato >= 50) {\n\t\tdocument.getElementById(\"chipButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"chipButton\").disabled = true;\n\t}\n\tif( potato >= 200 ) {\n\t\tdocument.getElementById(\"farmerButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"farmerButton\").disabled=true;\n\t}\n\tif(potato >= 500 ) {\n\t\tdocument.getElementById(\"farmButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"farmButton\").disabled = true;\n\t}\n\tif( potato >= 1500 ) {\n\t\tdocument.getElementById(\"factoryButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"factoryButton\").disabled = true;\n\t}\n\tif( potato >= 5000 ){\n\t\tdocument.getElementById(\"mcdonaldsButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"mcdonaldsButton\").disabled = true;\n\t}\n\tif( potato >= 10000 ){\n\t\tdocument.getElementById(\"spaceshipButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"spaceshipButton\").disabled = true;\n\t}\n\tif( potato >= 100000 ){\n\t\tdocument.getElementById(\"generatorButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"generatorButton\").disabled = true;\n\t}\n\tif( potato > 0 ){\n\t\tdocument.getElementById(\"resetButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"resetButton\").disabled = true;\n\t}\n}", "title": "" }, { "docid": "65e8f043fbab921d30a5b8fc9924acb9", "score": "0.6009032", "text": "function disable_buttons() {\n\tif( potato >= 50) {\n\t\tdocument.getElementById(\"chipButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"chipButton\").disabled = true;\n\t}\n\tif( potato >= 200 ) {\n\t\tdocument.getElementById(\"farmerButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"farmerButton\").disabled=true;\n\t}\n\tif(potato >= 500 ) {\n\t\tdocument.getElementById(\"farmButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"farmButton\").disabled = true;\n\t}\n\tif( potato >= 1500 ) {\n\t\tdocument.getElementById(\"factoryButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"factoryButton\").disabled = true;\n\t}\n\tif( potato >= 5000 ){\n\t\tdocument.getElementById(\"mcdonaldsButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"mcdonaldsButton\").disabled = true;\n\t}\n\tif( potato >= 10000 ){\n\t\tdocument.getElementById(\"spaceshipButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"spaceshipButton\").disabled = true;\n\t}\n\tif( potato >= 100000 ){\n\t\tdocument.getElementById(\"generatorButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"generatorButton\").disabled = true;\n\t}\n\tif( potato > 0 ){\n\t\tdocument.getElementById(\"resetButton\").disabled = false;\n\t}\n\telse {\n\t\tdocument.getElementById(\"resetButton\").disabled = true;\n\t}\n}", "title": "" }, { "docid": "a115cd5f2a7235e78710498dee9493fe", "score": "0.6004286", "text": "function initOff()\n{\n\t$(\"on_off_btns off_btn\").trigger(\"click\");\n}", "title": "" }, { "docid": "00a8d526b2ed08366378bf356fc2a1d4", "score": "0.6002575", "text": "function setUpBoardButtons () {\n if (info.isTimeForDeal() === false && info.noRequests > 0) {\n\n // Player turn change\n\n info.player = 2\n\n // Finding button index for selected button\n\n info.targetSecretButtonIndex = $(this).index()\n\n // Turning off button click handler\n\n $('#secrets button').off('click')\n\n // Reduce number of requests remaining\n\n info.noRequests -= 1\n $('#noRequests').html(info.noRequests)\n\n // Display Target choices to disclose or reject secret data point request\n\n $('.addChoices').show()\n\n // Timer reset for Target turn next\n\n info.seconds = 16\n clearInterval(info.intervalID)\n info.updateTime()\n $('.btw').addClass('col-md-offset-8')\n $('.btw h2').css('color', '#0ddeff')\n\n // If no more rejections remaining, hide the disclose button\n\n if (info.noDeclines === 0) {\n $('#no').hide()\n }\n }\n }", "title": "" }, { "docid": "9fb34a3b1227cf90a9d359cec347f7cc", "score": "0.5999702", "text": "function enableAllButtons()\n{\n for (var i = 1; i < 13; i++)\n {\n document.getElementById(\"button\" + i).disabled = false;\n }\n\n isCapturingMouse = false;\n}", "title": "" }, { "docid": "820f31a4c2ca47054cfdd5c47e8ca268", "score": "0.5998937", "text": "function btn_enable(button_e) {\n\t\tvar btn_ = \"\"\n\t\tif (button_e === \"all\") {\n\t\t\tfor (i = 0; i < 4; i++) {\n\t\t\t\tbtn_ = document.getElementById(\"btn\" + i);\n\t\t\t\tif (btn_.disabled === true) {\n\t\t\t\t\tbtn_.disabled = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tfor (i = 0, len = arguments.length; i < len; i++) {\n\t\t\t\tbtn_ = document.getElementById(arguments[i]);\n\t\t\t\tif (btn_.disabled === true) {\n\t\t\t\t\tbtn_.disabled = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "fe1bdd758d55a5dd9712f67416dd98db", "score": "0.5971972", "text": "function disableButtons(isDisabled) {\n rollButton.disabled = isDisabled;\n startAgainButton.disabled = isDisabled;\n}", "title": "" }, { "docid": "340445f80fcbd4c1089750771367d35b", "score": "0.59677726", "text": "disableAllButtons_() {\n this._permissionsBtn.disabled = true;\n this._deleteTokenBtn.disabled = true;\n this._getTokenBtn.disabled = true;\n }", "title": "" }, { "docid": "83f8662428b765abcfaabbaadeefd131", "score": "0.5963375", "text": "function setUpModeButtons() {\n easyButton.addEventListener(\"click\", function () {\n if (isHard) {\n isHard = false;\n easyButton.classList.add(\"modeChosen\");\n hardButton.classList.remove(\"modeChosen\");\n numColors = 3;\n reset();\n }\n });\n\n hardButton.addEventListener(\"click\", function () {\n if (!isHard) {\n isHard = true;\n hardButton.classList.add(\"modeChosen\");\n easyButton.classList.remove(\"modeChosen\");\n numColors = 6;\n reset();\n }\n });\n}", "title": "" }, { "docid": "ba777e1753b45643e1d76502fcb6c9f0", "score": "0.5961333", "text": "function enableBtns(thisBtnArray) {\n\n\t// console.log('');\n\t// console.log('PING! enableBtns triggered! thisBtnArray[0].id = ' + thisBtnArray[0].id);\n\n\tfor (var thisBtnIndex = 0; thisBtnIndex < thisBtnArray.length; thisBtnIndex++) {\n\n\t\t// console.log('thisBtnArray[thisBtnIndex].id = ' + thisBtnArray[thisBtnIndex].id);\n\n\t\t$('#' + thisBtnArray[thisBtnIndex].id).css('pointer-events', 'auto');\n\t}\n}", "title": "" }, { "docid": "47e30c3fd88b5ed8df3abcec9fcd35a6", "score": "0.59573966", "text": "function toggleButtons(state) {\n for (let i = 0; i < buttons.length; i++) {\n buttons[i].disabled = state;\n }\n}", "title": "" }, { "docid": "bfef80dc171e0181c417f09c59ea6594", "score": "0.59487945", "text": "function enableFF(){\n document.getElementById(\"btnFF\").disabled = false;\n}", "title": "" }, { "docid": "575d32769417ee9e2839b7d8ad24819c", "score": "0.5944115", "text": "function initTouchButtons() {\n\n changeButtonset=(function(){\n classHolder=document.getElementById(\"btns-markUsedButtonset\");\n var current=-1;\n\n // poll for pico8_gpio to check if PICO8-game wants a buttonset-change\n window.setInterval(function(){\n var from_pico8 = pico8_gpio[GPIO_BUTTONSET_INDEX];\n if(!!from_pico8) changeButtonset(from_pico8);\n },100);\n\n return function(buttonset_number){\n if(current!==buttonset_number) {\n touch_buttons = 0; // reset pico btns\n if(pico8_gpio[GPIO_BUTTONSET_INDEX]!==buttonset_number){\n pico8_gpio[GPIO_BUTTONSET_INDEX]=buttonset_number;\n }\n classHolder.className = \"buttonset-use-\" + buttonset_number;\n current=buttonset_number;\n }\n };\n\n }());\n changeButtonset(1); // set starting buttonset!\n\n var updatePressedClasses = (function() {\n var target = document.getElementById(\"btns-markPressed\");\n return function() {\n var classes=\"\",pressed=touch_buttons;\n for(var key_string in KEY) {\n if(KEY.hasOwnProperty(key_string) && ((pressed & KEY[key_string]) > 0)) classes+= \" pressed_\" + key_string;\n }\n target.className = classes;\n };\n\t}()),\n KEY = { L: 1, R: 2, U: 4, D: 8, O: 16, X: 32 },\n btnDown = function(key) { touch_buttons |= key; updatePressedClasses(); },\n btnUp = function(key) { touch_buttons &= ~key; updatePressedClasses(); },\n btnAxis = function(active_keys) {\n touch_buttons &= ~(KEY.U | KEY.D | KEY.L | KEY.R); // clear all axes\n for(var i=0; i<active_keys.length;i++) { touch_buttons |= active_keys[i]; }\n updatePressedClasses();\n },\n relTouchPosInEl = function(el, touch) {\n var rect = el.getBoundingClientRect();\n if(rect.width === 0 || rect.height === 0) return {x: 0, y: 0};\n return {\n x: Math.min(1, Math.max(0, (touch.clientX - rect.left) / rect.width)),\n y: Math.min(1, Math.max(0, (touch.clientY - rect.top) / rect.height))\n };\n },\n xAxisUpdate = function(el, touch) {\n if(!touch) return; // can occur when switching buttonsets\n var\n pos = relTouchPosInEl(el, touch),\n x_axis = 0, y_axis = 0;\n if(pos.x < .4) x_axis = KEY.L;\n if(pos.x > .6) x_axis = KEY.R;\n btnAxis([x_axis, y_axis]);\n },\n yAxisUpdate = function(el, touch) {\n if(!touch) return; // can occur when switching buttonsets\n var\n pos = relTouchPosInEl(el, touch),\n x_axis = 0, y_axis = 0;\n if(pos.y < .4) y_axis = KEY.U;\n if(pos.y > .6) y_axis = KEY.D;\n btnAxis([x_axis, y_axis]);\n },\n xyAxisUpdate = function(el, touch) {\n if(!touch) return; // can occur when switching buttonsets\n var\n pos = relTouchPosInEl(el, touch),\n x_axis = 0, y_axis = 0,\n x_range = .3, y_range = .3;\n if(pos.x < x_range) x_axis = KEY.L;\n if(pos.x > 1-x_range) x_axis = KEY.R;\n if(pos.y < y_range) y_axis = KEY.U;\n if(pos.y > 1-y_range) y_axis = KEY.D;\n btnAxis([x_axis, y_axis]);\n },\n axisEnd = function() { btnAxis([]); },\n killEvt = function(evt) { evt.preventDefault(); evt.stopPropagation(); },\n touchfinder=function(){\n var touchid=null;\n return {\n fillFromTouchStart:function(evt,el){\n var\n touches, touch,\n toucharea = el.getBoundingClientRect();\n\n console.log(toucharea.left, toucharea.right);\n\n if(touches = evt.changedTouches){\n for(var i=0; i<touches.length; i++){\n touch=touches[i];\n console.log(touch.clientX);\n if( // is correct touchpoint?\n (touch.clientX > toucharea.left - 10) &&\n (touch.clientX < toucharea.right + 10) &&\n (touch.clientY > toucharea.top - 10) &&\n (touch.clientY < toucharea.bottom + 10)\n ) {\n touchid=touch.identifier;\n return touch;\n }\n }\n }\n touchid=null;\n return null;\n },\n findFromTouchMove:function(evt){\n if(touchid === null) return null;\n var touches,touch;\n if(touches=evt.changedTouches) {\n\n for(var i=0; i<touches.length; i++){\n touch=touches[i];\n if(touch.identifier===touchid) { return touch; }\n }\n }\n return null;\n },\n clear:function(){ touchid = null; }\n };\n },\n addXAxis = function(el) {\n var find_my_touch=touchfinder();\n el.addEventListener(\"touchstart\", function(evt){ killEvt(evt); xAxisUpdate(el, find_my_touch.fillFromTouchStart(evt,el)); }, false);\n el.addEventListener(\"touchmove\", function(evt){ killEvt(evt); xAxisUpdate(el, find_my_touch.findFromTouchMove(evt)); }, false);\n el.addEventListener(\"touchend\", function(evt){ find_my_touch.clear(); killEvt(evt); axisEnd(); }, false);\n el.addEventListener(\"touchcancel\", function(evt){ find_my_touch.clear(); killEvt(evt); axisEnd(); }, false);\n },\n addYAxis = function(el) {\n var find_my_touch=touchfinder();\n el.addEventListener(\"touchstart\", function(evt){ killEvt(evt); yAxisUpdate(el, find_my_touch.fillFromTouchStart(evt,el)); }, false);\n el.addEventListener(\"touchmove\", function(evt){ killEvt(evt); yAxisUpdate(el, find_my_touch.findFromTouchMove(evt)); }, false);\n el.addEventListener(\"touchend\", function(evt){ find_my_touch.clear(); killEvt(evt); axisEnd(); }, false);\n el.addEventListener(\"touchcancel\", function(evt){ find_my_touch.clear(); killEvt(evt); axisEnd(); }, false);\n },\n addXYAxis = function(el) {\n var find_my_touch=touchfinder();\n el.addEventListener(\"touchstart\", function(evt){ killEvt(evt); xyAxisUpdate(el, find_my_touch.fillFromTouchStart(evt,el)); }, false);\n el.addEventListener(\"touchmove\", function(evt){ killEvt(evt); xyAxisUpdate(el, find_my_touch.findFromTouchMove(evt)); }, false);\n el.addEventListener(\"touchend\", function(evt){ find_my_touch.clear(); killEvt(evt); axisEnd(); }, false);\n el.addEventListener(\"touchcancel\", function(evt){ find_my_touch.clear(); killEvt(evt); axisEnd(); }, false);\n },\n addButton = function(el, key) {\n el.addEventListener(\"touchstart\", function(evt){ killEvt(evt); btnDown(key); }, false);\n el.addEventListener(\"touchmove\", killEvt, false);\n el.addEventListener(\"touchend\", function(evt){ killEvt(evt); btnUp(key); }, false);\n el.addEventListener(\"touchcancel\", function(evt){ killEvt(evt); btnUp(key); }, false);\n };\n\n var\n axisXs=document.getElementsByClassName(\"axis-leftRight\"),\n axisXYs=document.getElementsByClassName(\"axis-upDownLeftRight\"),\n axisYs=document.getElementsByClassName(\"axis-upDown\"),\n xBtns=document.getElementsByClassName(\"btn-fire-x\"),\n oBtns=document.getElementsByClassName(\"btn-fire-o\"),\n i;\n\n for(i=0; i<axisXs.length; i++){ addXAxis(axisXs[i]); }\n for(i=0; i<axisXYs.length; i++){ addXYAxis(axisXYs[i]); }\n for(i=0; i<axisYs.length; i++){ addYAxis(axisYs[i]); }\n for(i=0; i<xBtns.length; i++){ addButton(xBtns[i], KEY.X); }\n for(i=0; i<oBtns.length; i++){ addButton(oBtns[i], KEY.O); }\n\n // prevent \"tilt-zooming\" when accidentally touching between the buttons\n document.getElementById(\"btns-wrapper\").addEventListener(\"touchstart\", function(evt){ evt.preventDefault(); }, false);\n}", "title": "" }, { "docid": "5e3b744b13c077003dc3c31cd8cc7aee", "score": "0.59440386", "text": "function light(err, state) {\nconsole.log('err:',err);\nconsole.log('state:', state);\n // check the state of the button\n // 1 == pressed, 0 == not pressed\n if(state == 1) {\n // turn LED on\n led.writeSync(1);\n } else {\n // turn LED off\n led.writeSync(0);\n }\n\n}", "title": "" }, { "docid": "e091b119461ed382b71ec9f9b4c4497d", "score": "0.5943592", "text": "checkButtonsActive() {\n let nextAction = this.getService(\"ProtocolService\").getNextAction();\n\n if (nextAction === \"spin\") {\n\n if (this.getService(\"AutoPlayService\").isActive()) {\n this.handler.hideSettingsButton();\n this.handler.autoSpinActive = true;\n } else {\n this.handler.showAllButtons();\n }\n\n } else if (nextAction === \"respin\") {\n\n this.handler.hideSettingsButton();\n\n } else if (nextAction === \"freespin\") {\n\n this.handler.hideAdditionalButtons();\n\n } else if (nextAction === \"freespin_stop\") {\n\n if (this.getService(\"AutoPlayService\").isActive()) {\n //this.handler.hideSettingsButton();\n this.handler.autoSpinActive = true;\n } else {\n //this.handler.showAllButtons();\n }\n\n } else {\n\n this.handler.hideAllButtons();\n\n }\n }", "title": "" }, { "docid": "07f5998bc486d44f15241fb3e52d74fd", "score": "0.5941822", "text": "function setMonitorState(button, state) {\n if (state) {\n button.innerText = \"Monitorando\";\n udpPort.readonly = true;\n } else {\n button.innerText = \"Nao monitorando\";\n udpPort.readonly = false;\n }\n }", "title": "" }, { "docid": "704e0333d0f3522c9d7ed396fe5d73d2", "score": "0.5937183", "text": "function buttonStates ( state ) {\n switch ( state ) {\n case \"openedState\":\n openConnectionButton.attr ( \"disabled\", \"disabled\" );\n startMonitorButton.removeAttr ( \"disabled\" );\n stopMonitorButton.attr ( \"disabled\", \"disabled\" );\n closeServerConnectionButton.removeAttr ( \"disabled\" );\n break;\n \n case \"startedState\":\n openConnectionButton.attr ( \"disabled\", \"disabled\" );\n startMonitorButton.attr ( \"disabled\", \"disabled\" );\n stopMonitorButton.removeAttr ( \"disabled\" );\n closeServerConnectionButton.removeAttr ( \"disabled\" );\n break;\n \n case \"stoppedState\":\n openConnectionButton.attr ( \"disabled\", \"disabled\" );\n startMonitorButton.removeAttr ( \"disabled\" );\n stopMonitorButton.attr ( \"disabled\", \"disabled\" );\n closeServerConnectionButton.removeAttr ( \"disabled\" );\n break;\n \n case \"closedState\":\n openConnectionButton.removeAttr ( \"disabled\" );\n startMonitorButton.attr ( \"disabled\", \"disabled\" );\n stopMonitorButton.attr ( \"disabled\", \"disabled\" );\n closeServerConnectionButton.attr ( \"disabled\", \"disabled\" );\n break;\n \n default:\n message ( \"Huh!? what's just happened?\" );\n \n }\n }", "title": "" }, { "docid": "c17a3a90fa236b9328a2c7adfddc0f03", "score": "0.59336257", "text": "function controlsOnOff() {\n // dispaly roll down\n let dispCont = document.querySelector(\".container-display\");\n dispCont.classList.toggle(\"roll-up\");\n\n let ctrlBtnContainer = document.querySelector(\"#ctsls-container\");\n\n // hide the control panel\n let mainControlContainer = document.querySelector(\".controls\");\n mainControlContainer.classList.toggle(\"hide\");\n\n if (controlsLamp && runText.compareDisplay && !compareLamp) {\n // Switch Off\n compareLamp = true; // remember for next time if it was on\n runText.onOffCompareDispl();\n }\n if (!controlsLamp && !runText.compareDisplay && compareLamp) {\n // Switch On\n // if it was on before\n runText.onOffCompareDispl();\n compareLamp = false;\n }\n if (controlsLamp) {\n // hide the controls slider when the control panel is to hide\n ctrlBtnContainer.style.opacity = \"0\";\n footerMain.style.opacity = 0;\n\n controlsLamp = false;\n } else {\n // show the controls slider when the control panel is to show\n ctrlBtnContainer.style.opacity = \"1\";\n footerMain.style.opacity = 1;\n\n controlsLamp = true;\n }\n}", "title": "" }, { "docid": "d3d7f0dc528b09e3abdc9a4049fa66b3", "score": "0.59320843", "text": "togglePanelHotkeys() {\n self.enablePanelHotkeys = !self.enablePanelHotkeys;\n }", "title": "" }, { "docid": "84a98c879bff44acf213768bc70e0057", "score": "0.5930171", "text": "function EnableButtons() {\n\t\t$(\"#DivChoice1\").prop(\"disabled\",false);\n\t\t$(\"#DivChoice2\").prop(\"disabled\",false);\n\t\t$(\"#DivChoice3\").prop(\"disabled\",false);\n\t\t$(\"#DivChoice4\").prop(\"disabled\",false);\n\t}", "title": "" }, { "docid": "a1ac1318a740cc45fed532ae68a7984e", "score": "0.59211135", "text": "function toggleButtons(){\n\t\tif(showButtons){\n\t\t\t\n\t\t\tMobileUI.ui.find('#topBar').addClass('disabled');\n\t\t\tMobileUI.ui.find('#leftBar').addClass('disabled');\n\t\t\tMobileUI.ui.find('#rightBar').addClass('disabled');\n\t\t\t\n\t\t\tif(Session.TouchTargeting){\n\t\t\t\ttoggleTouchTargeting();\n\t\t\t}\n\t\t\t\n\t\t\tshowButtons = false;\n\t\t} else {\n\t\t\t\n\t\t\tMobileUI.ui.find('#topBar').removeClass('disabled');\n\t\t\tMobileUI.ui.find('#leftBar').removeClass('disabled');\n\t\t\tMobileUI.ui.find('#rightBar').removeClass('disabled');\n\t\t\t\n\t\t\tshowButtons = true;\n\t\t}\n\t}", "title": "" }, { "docid": "ca65e41cb31b477179310b9dd9db9572", "score": "0.591815", "text": "function setupControlButtons() {\r\n // button to start\r\n controls.startButton.addEventListener('click', startButtonHandler);\r\n \r\n // button to clear\r\n document.querySelector('#clear').addEventListener('click', clearButtonHandler);\r\n\r\n // button to set random initial state\r\n document.querySelector('#random').addEventListener('click', randomButtonHandler);\r\n}", "title": "" }, { "docid": "cfc1c2553537f5f27276b0072702a3ee", "score": "0.5915696", "text": "function disableButtons() {\n buttons.forEach(elem=> {\n elem.disabled = true;\n })\n }", "title": "" }, { "docid": "43cb6e094bffcd082403a890a4085feb", "score": "0.59156334", "text": "function buttonDisable(){\r\n\t\tswitch (currentLoc){\r\n\t\t//South off\r\n\t\t\tcase 0: document.getElementById(\"btnN\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = false; \r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = false;\t\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go SOUTH...\"\r\n\t\t\t\tbreak;\r\n\t\t//South West off\r\n\t\t\tcase 1: document.getElementById(\"btnN\").disabled = false; \r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go SOUTH or WEST...\"\r\n\t\t\t\tbreak;\r\n\t\t//South East off\r\n\t\t\tcase 2: document.getElementById(\"btnN\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go SOUTH or EAST...\"\t\t\t\t\r\n\t\t\t\tbreak;\r\n\t\t//East off\r\n\t\t\tcase 5: document.getElementById(\"btnN\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go EAST...\"\r\n\t\t\t\tbreak;\r\n\t\t//West off\r\n\t\t\tcase 3: document.getElementById(\"btnN\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go WEST...\"\t\t\t\t\r\n\t\t\t\tbreak;\r\n\t\t//East West North off\r\n\t\t\tcase 9: document.getElementById(\"btnN\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go NORTH, EAST, or WEST...\"\r\n\t\t\t\tbreak;\r\n\t\t//West North off\r\n\t\t\tcase 6: document.getElementById(\"btnN\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go NORTH or WEST...\"\r\n\t\t\t\tbreak;\r\n\t\t//East North off\r\n\t\t\tcase 8: document.getElementById(\"btnN\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"navError\").innerHTML = \"WARNING: You've reached the edge of the park. Don't try to go NORTH, EAST, or WEST...\"\r\n\t\t\t\tbreak;\r\n\t\t\tcase 1000: document.getElementById(\"btnN\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnTake\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnInventory\").disabled = true;\r\n\t\t\t\t\tdocument.getElementById(\"btnGo\").disabled = true;\r\n\t\t\t\tbreak;\r\n\t\t\tdefault: document.getElementById(\"btnN\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnS\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnE\").disabled = false;\r\n\t\t\t\t\tdocument.getElementById(\"btnW\").disabled = false;\r\n\t\t}\r\n\t}", "title": "" }, { "docid": "ade76f5a6798d694eb87e48f40fa99a8", "score": "0.5914513", "text": "function hwButtons (event) {\n\t$('.mybtn').unbind('click');\n\t$('.mybtn').click(function () {\n\t\t$(this).blur();\n\t});\n\n\t$('#tourButton').click(function () {\n\t\t$(this).prop('disabled', true);\n\t\t$('#archeryButton').prop('disabled', true);\n\t\t$('#swordButton').prop('disabled', true);\n\t\thiddenWorld.tour();\n\t});\n\n\t$('#archeryButton').click(function () {\n\t\tfromHWToCenter(archeryCenter,\n\t\t\t\t\t\t\t\t\t\t function () {\n\t\t\t\t\t\t\t\t\t\t\t$('#top-instructions').html(archeryHTML);\n\t\t\t\t\t\t\t\t\t\t\t$('#top-buttons').html(archeryButtonsHTML);\n\t\t\t\t\t\t\t\t\t\t\tarcheryButtons();\n\t\t\t\t\t\t\t\t\t\t\tif (archeryCenter.finished) {\n\t\t\t\t\t\t\t\t\t\t\t\t$('#startButton').prop('disabled', false);\n\t\t\t\t\t\t\t\t\t\t\t\t$('#top-instructions').html('Click <b>Restart training</b> to replay archery training');\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}, archeryEvents);\n\t});\n\n\t$('#swordButton').click(function () {\n\t\tfromHWToCenter(swordCenter,\n\t\t\t\t\t\t\t\t\t\t function () {\n\t\t\t\t\t\t\t\t\t\t \tvar str = mobile ? 'swipe' : 'drag the mouse';\n\t\t\t\t\t\t\t\t\t\t\t$('#top-instructions').html(swordHTML);\n\t\t\t\t\t\t\t\t\t\t\t$('#top-buttons').html(swordButtonsHTML);\n\t\t\t\t\t\t\t\t\t\t\tswordButtons();\n\t\t\t\t\t\t\t\t\t\t}, swordEvents);\n\t});\n\n\t$('#resetButton').click(function () {\n\t\t$('#tourButton').prop('disabled', false);\n\t\t$('#archeryButton').prop('disabled', false);\n\t\t$('#swordButton').prop('disabled', false);\n\t\tTWEEN.removeAll();\n\t\thiddenWorld.reset();\n\t});\n}", "title": "" }, { "docid": "b3d92171ea51ec3dafce0063c270a61c", "score": "0.5911373", "text": "toggle_buttons(state){\n let buttons = document.getElementsByClassName(\"button\");\n for(let i of buttons){\n i.disabled=state;\n }\n }", "title": "" }, { "docid": "a078d2dccea6cd5db8e24f8cd8b8e249", "score": "0.5907787", "text": "function disableBtn(){\n\tvender.setAttribute(\"disable\", true);\n\tvender.style.cursor=\"not allowed\";\n\tvender.setAttribute(\"class\", \"disabled\");\n}", "title": "" }, { "docid": "3e9d54ef57cb548aead9ac5a54088210", "score": "0.59066135", "text": "function group0onoff() {\n\t$('#allLights').on('click', function(){\n\t\tif($(this).hasClass('btn-primary')) {\n\t\t\t$.ajax({\n\t\t\t\ttype: 'PUT',\n\t\t\t\turl: allGroups+'0'+'/action/',\n\t\t\t\tdata: '{\"on\": false}'\n\t\t\t});\n\t\t\t$(this).addClass('btn-default').removeClass('btn-primary');\n\t\t} else {\n\t\t\t$.ajax({\n\t\t\t\ttype: 'PUT',\n\t\t\t\turl: allGroups+'0'+'/action/',\n\t\t\t\tdata: '{\"on\": true, \"bri\": 254}'\n\t\t\t});\n\t\t\t$(this).addClass('btn-primary').removeClass('btn-default');\n\t\t}\n\t\tupdateEverything();\n\t});\n}", "title": "" }, { "docid": "c60292f8596c066dfa54fc1ce117352a", "score": "0.5905093", "text": "function setElements(isDisable){\n\tdocument.getElementById(\"animationOpt\").disabled = isDisable;\n\tdocument.getElementById(\"stopbutton\").disabled =! isDisable;\n\tdocument.getElementById(\"startbutton\").disabled = isDisable;\n\tdocument.getElementById(\"turboChk\").disabled =! isDisable;\n\tdocument.getElementById(\"turboChk\").checked =! isDisable;\n\tdocument.getElementById(\"playarea\").readOnly = isDisable;\n}", "title": "" }, { "docid": "cb84be810d740a4e9ef2dbc21504aede", "score": "0.590312", "text": "function CustomMe(){\n //setColor('primary')\n setBtnDisable(true)\n }", "title": "" }, { "docid": "bc44d9830711b4041575980397838c04", "score": "0.58908546", "text": "function toggleLecturerMode() {\n lecturerMode = !lecturerMode;\n\n var data = new Object();\n data['enabled'] = lecturerMode;\n publishIWC(\"LecturerModeUpdate\", data);\n\n var btn = document.getElementById('btnLecturerMode');\n if (lecturerMode) {\n btn.innerHTML =\"Disable Lecturer Mode\";\n }\n else {\n btn.innerHTML =\"Enable Lecturer Mode\";\n }\n}", "title": "" } ]
7ba207e61a5111028e0bc3b4d549c0e7
Dictionary for node lookup. Ensures lookup in this.nodes by node id is fast and does not require a loop through the entire list of this.nodes each time. See this.getNodeById(nodeId) for the lookup function. Key: node.id Value: index in this.nodes
[ { "docid": "597c2ba315d371362764c4f57af46681", "score": "0.67626166", "text": "generateDictionary() {\n this.nodesDictionary = {}\n this.nodes.forEach((node, index) => {\n this.nodesDictionary[node.id] = index\n })\n }", "title": "" } ]
[ { "docid": "f098623effb6dcc784dc875d088067a8", "score": "0.6544756", "text": "function getNode(id) {\n return nodeMap[id];\n}", "title": "" }, { "docid": "c5d104cc37fd9a049749f7ae6d8b9a26", "score": "0.64201534", "text": "getNodeById(nodeId) { // nodeId = subreddit\n const index = this.nodesDictionary[nodeId]\n return this.nodes[index]\n }", "title": "" }, { "docid": "191a0d8a52c7e2f43aae5171e7a83909", "score": "0.6099608", "text": "function getNodeById(id){\n var node = null;\n // console.log(id);\n //nodes_static.forEach(function(e, i){\n sorted_kcs.forEach(function(e,i){ \n if (e.id == id){\n node = e;\n return;\n }\n });\n return node;\n}", "title": "" }, { "docid": "5a6d2560a5a9314bf63ab1265ae580f9", "score": "0.6055705", "text": "function NodeMap() {}", "title": "" }, { "docid": "07502e9a60635a7f324ef7d6431f6067", "score": "0.60169184", "text": "function mapNodes(nodes) {\n var nodesMap = d3.map();\n nodes.forEach(function(n) {\n nodesMap.set(n.id, n);\n });\n return nodesMap;\n }", "title": "" }, { "docid": "787a888de31183b8cac58fd8ab1934b0", "score": "0.59213686", "text": "function getNode( id )\n{\n\treturn nodes[id];\n}", "title": "" }, { "docid": "337c5b7ef3cbb4a73eb4c7871b1887a8", "score": "0.5812355", "text": "function nodeID(node_id) {\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].id == node_id)\n return nodes[i]; \n }\n}", "title": "" }, { "docid": "c8ed17477d743ec73c6016ef96d47d9b", "score": "0.58064353", "text": "getNodeData(nodeId) {\n if (!this.state.data) return null;\n for (let x of this.state.data.nodes) if (x.id === nodeId) return x;\n return null;\n }", "title": "" }, { "docid": "ed6fb7e84500782fc55b0752d42a28a3", "score": "0.57458234", "text": "function getNodeById(nodeId) {\n // this emulates the following line of code: return tree.nodes[nodeId];\n // this is necessary, because node IDs are sometimes passed as Strings and sometimes as numbers, which will lead to\n // trouble in FF 3.5 with enabled JIT. Please note that the loose comparison \"==\" must be used here rather than \"===\"\n nodeId = parseInt( nodeId );\n for (var currNode in tree.nodes) {\n if (currNode == nodeId) {\n return tree.nodes[ currNode ];\n }\n }\n return null;\n}", "title": "" }, { "docid": "73a2dd763f4c57d706691964784cc6fa", "score": "0.56634635", "text": "function getNode(id, hash) {\n\tfor (var i = 0; i < hash.length; ++i) { \n\t\tif(hash[i][\"id\"] == id) {\n \treturn hash[i];\n }\n\t};\n}", "title": "" }, { "docid": "341fe33687b0ca561bdb4e7ecc0326ef", "score": "0.55286634", "text": "getViewNode(nodeKey) {\n const searchNode = {};\n searchNode[NODE_KEY] = nodeKey;\n const i = this.getNodeIndex(searchNode);\n return this.state.graph.nodes[i];\n }", "title": "" }, { "docid": "1b48bca0944248b12a8548df644d50da", "score": "0.55234057", "text": "getNeighbors(node){\n let nodeIdx = this.nodes.indexOf(node);\n if (nodeIdx === -1){\n return null;\n }\n\n let neighbors = {};\n for (let i = 0; i < this.nodes.length; i++){\n if (this.edgeMap[nodeIdx][i]){\n neighbors[this.nodes[i]] = this.edgeMap[nodeIdx][i] ;\n }\n }\n return {\n value: node,\n edges: neighbors,\n };\n\n\n }", "title": "" }, { "docid": "54353e8fb519bbf2e82af62aaea65ee1", "score": "0.5514721", "text": "getNodeById(id) {\n for (let i = 0; i < this.nodes.length; i++)\n if (this.nodes[i].id == id)\n return this.nodes[i];\n\n return null;\n }", "title": "" }, { "docid": "e62fa1aeee5eeb420a4823da663c6162", "score": "0.55060285", "text": "function findNode(id){\n for(i in nodes){\n if (nodes[i].id == id) return nodes[i];\n }\n }", "title": "" }, { "docid": "6e4034b5d7601309140afbacb76dab89", "score": "0.5502753", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n }", "title": "" }, { "docid": "6e4034b5d7601309140afbacb76dab89", "score": "0.5502753", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n }", "title": "" }, { "docid": "6e4034b5d7601309140afbacb76dab89", "score": "0.5502753", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n }", "title": "" }, { "docid": "ac576d9e26b290651ebd136180246186", "score": "0.5490747", "text": "getViewNode(nodeKey) {\n\t\tconst searchNode = {};\n\n\t\tsearchNode[NODE_KEY] = nodeKey;\n\t\tconst i = this.getNodeIndex(searchNode);\n\n\t\treturn this.state.graph.nodes[i];\n\t}", "title": "" }, { "docid": "a6cee86c7818834e4ef280717f570026", "score": "0.5486269", "text": "function createNodeIndex(node)\r\n{\r\n nodeIndex[node.id] = node;\r\n\r\n var i;\r\n for(i = 0; i < node.childCount; i++)\r\n {\r\n createNodeIndex(node.children[i]);\r\n }\r\n}", "title": "" }, { "docid": "d9b2c77822ea6c719c15da17992f6666", "score": "0.5485999", "text": "getNode(pHash){if(!this._HashMap.hasOwnProperty(pHash))return false;return this._HashMap[pHash];}", "title": "" }, { "docid": "daa96941e5c409826056f138d1023139", "score": "0.54745334", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n }", "title": "" }, { "docid": "6df87985ca1a30f2fe0353dbbe5e0d69", "score": "0.5442759", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n}", "title": "" }, { "docid": "6df87985ca1a30f2fe0353dbbe5e0d69", "score": "0.5442759", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n}", "title": "" }, { "docid": "6df87985ca1a30f2fe0353dbbe5e0d69", "score": "0.5442759", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n}", "title": "" }, { "docid": "6df87985ca1a30f2fe0353dbbe5e0d69", "score": "0.5442759", "text": "function applyIdToMap(inst, map, node, nodeInfo) {\n if (nodeInfo.id) {\n map[nodeInfo.id] = node;\n }\n}", "title": "" }, { "docid": "19abc69ab25e15dc96a515998386ccab", "score": "0.54077166", "text": "getNodeForKey(key) {\n\n }", "title": "" }, { "docid": "3de2d00a12f75cbb8137eb2e09a26b43", "score": "0.5364687", "text": "getNode(name) {\n return this.nodeMap.get(name);\n }", "title": "" }, { "docid": "e6d05e8770573a8653745185164c368c", "score": "0.5319751", "text": "function getIENodeHash(node) {\n\t\t if (node && node.nodeType > 0) {\n\t\t switch (node.nodeType) {\n\t\t case 1: // Element\n\t\t return node.uniqueID;\n\t\t case 9: // Document\n\t\t return node.documentElement && node.documentElement.uniqueID;\n\t\t }\n\t\t }\n\t\t }", "title": "" }, { "docid": "e6d05e8770573a8653745185164c368c", "score": "0.5319751", "text": "function getIENodeHash(node) {\n\t\t if (node && node.nodeType > 0) {\n\t\t switch (node.nodeType) {\n\t\t case 1: // Element\n\t\t return node.uniqueID;\n\t\t case 9: // Document\n\t\t return node.documentElement && node.documentElement.uniqueID;\n\t\t }\n\t\t }\n\t\t }", "title": "" }, { "docid": "642c8f8be191631e2cb299e38d4ff309", "score": "0.53022337", "text": "findNodeIdx(nodeId) {\n const { nodes } = this.state;\n const i = nodes.findIndex(e => e.id === nodeId);\n if (i === -1) {\n // TODO: Learn idiomatic way of error handling in JS\n throw new Error(`node ${nodeId} not found`);\n }\n return i;\n }", "title": "" }, { "docid": "b6e6afb5652f0d94706334f3ff549530", "score": "0.52969384", "text": "function constructMaps() {\n var num_nodes = nodes.length;\n for (var i = 0; i < num_nodes; ++i) {\n var curr_node = nodes[i];\n key_node_map[curr_node.key] = curr_node;\n name_node_map[curr_node.name] = curr_node;\n }\n var num_links = links.length;\n for (var i = 0; i < num_links; ++i) {\n \tvar curr_link = links[i];\n \tvar key_pair = curr_link.sourceKey + \"-\" + curr_link.targetKey;\n \tkey_link_map[key_pair] = curr_link;\n }\n}", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "384c1ef6be1d248de4e62bfd6d538bec", "score": "0.52715814", "text": "function getIENodeHash(node) {\n\t if (node && node.nodeType > 0) {\n\t switch (node.nodeType) {\n\t case 1: // Element\n\t return node.uniqueID;\n\t case 9: // Document\n\t return node.documentElement && node.documentElement.uniqueID;\n\t }\n\t }\n\t }", "title": "" }, { "docid": "5405925ffa40a0eef209bb1140e9ade1", "score": "0.5261093", "text": "getNodeIndex(nodeId){\n let i;\n let found = false;\n for(i = 0; i < this.numNodes && !found; i++){\n if(this.nodes[i].getId() == nodeId){\n found = true;\n }\n }\n if(!found) { i = -1 };\n return i - 1;\n }", "title": "" }, { "docid": "8b48b63489dcc81541490b6cb5f0c2e2", "score": "0.5219736", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dd4fabcbe02dfd9c73ace7dc52bc7a4c", "score": "0.52132434", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dd4fabcbe02dfd9c73ace7dc52bc7a4c", "score": "0.52132434", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "2a2dd8457721ebad42248e1f10c5ce25", "score": "0.5176936", "text": "getNodeByCodeId(id) {\n\t\treturn this.graphView.getNodeByCodeId(id);\n\t}", "title": "" }, { "docid": "6b64fb1a1c79b8e7d7c9780a238b98c8", "score": "0.51707256", "text": "function findNodeById(array, nodeId) {\n return _.find(array, {id: nodeId});\n }", "title": "" }, { "docid": "d02d505b97cd690a99ebab1943d614ec", "score": "0.51653856", "text": "getPositions() {\n const ret = {};\n this.nodes.forEach(n => {\n ret[n.id] = { x: n.x, y: n.y, fixed: n.fixed };\n });\n return ret;\n }", "title": "" }, { "docid": "0ef1308f2f1481c6a7ff29f637620bce", "score": "0.5135102", "text": "getNode(id) {\n return this.processes[id];\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" }, { "docid": "dc54a3a3ade691900275d4f780e5fde3", "score": "0.5112035", "text": "function getIENodeHash(node) {\n if (node && node.nodeType > 0) {\n switch (node.nodeType) {\n case 1: // Element\n return node.uniqueID;\n case 9: // Document\n return node.documentElement && node.documentElement.uniqueID;\n }\n }\n }", "title": "" } ]
75c2c48e5fd1875c469f7d6cdde1daa2
POST Retrives refresh token from tsheets api after when expires on date is reached
[ { "docid": "229c6096ae8c254afed0c96bda25904b", "score": "0.7099769", "text": "requestTsheetsRefreshToken({commit, dispatch}) {\n const proxy = 'https://cors-anywhere.herokuapp.com/'\n const url = 'https://rest.tsheets.com/api/v1/grant'\n axios.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('tsheets_access_token')\n axios({\n method: 'post',\n url: proxy+url,\n data: {\n 'grant_type': \"refresh_token\",\n 'client_id': process.env.VUE_APP_TSHEETS_CLIENT_ID || \"7334d612a8cc42fe9b699f79e1f562e5\",\n 'client_secret': process.env.VUE_APP_TSHEETS_CLIENT_SECRET || \"45d60ca0fcee4cba901eadbfef5b46d8\",\n 'refresh_token': localStorage.getItem('tsheets_refresh_token')\n }\n }).then(res => {\n localStorage.tsheets_access_token = res.data.access_token\n localStorage.tsheets_refresh_token = res.data.refresh_token\n localStorage.tsheets_expires_in = res.data.expires_in\n localStorage.tsheets_company_id = res.data.company_id\n localStorage.tsheets_client_url = res.data.client_url\n localStorage.tsheets_user_id = res.data.user_id\n if(res.data.tsheets_expires_in) {\n setTimeout(() => {\n dispatch('requestTsheetsRefreshToken')\n }, res.data.tsheets_expires_in)\n }\n }).catch(err => {\n dispatch('removeTsheetItems')\n window.location.href = '/'\n console.log(err.response)\n })\n }", "title": "" } ]
[ { "docid": "8557fd0356f2a8dd3ca1fa6a168a4735", "score": "0.6896578", "text": "async function getAccessTokenByRefresh(){\n\n /*\n POST https://www.googleapis.com/oauth2/v4/token\n Content-Type: application/json\n\n {\n \"client_id\": <client_id>,\n \"client_secret\": <client_secret>,\n \"refresh_token\": <refresh_token>,\n \"grant_type\": \"refresh_token\"\n }\n */\n}", "title": "" }, { "docid": "82d83518ba360f954338cbc3bf520999", "score": "0.6805602", "text": "refreshTokens() {\n let body = buildRequestBody.call(this, {\n formBody: {\n 'grant_type': 'refresh_token',\n 'refresh_token': this.refreshToken\n }\n });\n\n return request(body)\n .then((data) => {\n try {\n let tokens = JSON.parse(data);\n\n this.accessToken = tokens.access_token;\n\n configModule.write([{\n key: 'bitbucket.accessToken',\n value: tokens.access_token\n }]);\n } catch (err) {\n throw new Error(`Cannot parse tokens. Stack trace: ${err}`);\n }\n })\n .catch((err) => {\n throw new Error(`Can not refresh access token by given refresh: ${this.refreshToken}. Stack trace: ${err}`);\n });\n }", "title": "" }, { "docid": "5ffd97025268b94f1db3ffd5ae77c2f7", "score": "0.6766035", "text": "requestTsheetsToken({commit, dispatch}) {\n const proxy = 'https://cors-anywhere.herokuapp.com/'\n const url = 'https://rest.tsheets.com/api/v1/grant'\n axios.defaults.headers.common['Authorization'] = 'Bearer ' + process.env.VUE_APP_TSHEETS_TOKEN\n axios({\n method: 'post',\n url: proxy+url,\n data: {\n 'grant_type': \"authorization_code\",\n 'client_id': process.env.VUE_APP_TSHEETS_CLIENT_ID,\n 'client_secret': process.env.VUE_APP_TSHEETS_CLIENT_SECRET,\n 'code': localStorage.getItem('tsheets_code'),\n 'redirect_uri': 'https://app.traxit.io'\n }\n }).then(res => {\n localStorage.tsheets_access_token = res.data.access_token\n localStorage.tsheets_refresh_token = res.data.refresh_token\n localStorage.tsheets_expires_in = res.data.expires_in\n localStorage.tsheets_company_id = res.data.company_id\n localStorage.tsheets_client_url = res.data.client_url\n localStorage.tsheets_user_id = res.data.user_id\n if(res.data.tsheets_expires_in) {\n setTimeout(() => {\n dispatch('requestTsheetsRefreshToken')\n }, res.data.tsheets_expires_in)\n }\n router.replace({'query': null})\n setTimeout(() => {\n commit('toggleTimesheet')\n }, 300)\n }).catch(err => {\n console.log(err.response)\n })\n }", "title": "" }, { "docid": "59148cbaf77e8f8d495fb08fb412daaa", "score": "0.67309123", "text": "static sendRefreshToken() {\n return axios.post(\n 'refresh-token',\n {},\n {\n headers: authHeader(true),\n }\n );\n }", "title": "" }, { "docid": "c185d6d5093c746f0a7e7a40761494b7", "score": "0.6651273", "text": "_doRefresh() {\n /* istanbul ignore next */\n if (this._log) this._log.trace('Performing token refresh attempt');\n\n return this._wsRawSubmit(\n 'POST',\n '/oauth2/token',\n {\n refresh_token: this._ws_token.refresh_token,\n grant_type: 'refresh_token'\n },\n {\n auth: {\n username: this.#clientId,\n password: this.#clientSecret\n }\n }\n );\n }", "title": "" }, { "docid": "23f70e15b3889d8b5b35b79602b10ebf", "score": "0.6648819", "text": "async refreshToken() {\n return await axios.post(apiUrl + '/api/accounts/refresh_token', {\n accessToken: accessToken,\n refreshToken: refreshToken\n }).then(response => {\n this.log.info('RefreshToken successful');\n accessToken = response.data.accessToken;\n refreshToken = response.data.refreshToken;\n expireTime = Date.now() + (response.data.expiresIn - (polltime * 2)) * 1000;\n\n this.log.debug(JSON.stringify(response.data));\n }).catch((error) => {\n this.log.error('RefreshToken error');\n this.log.error(error);\n });\n }", "title": "" }, { "docid": "e3f787f74dba21f1382b036ae8620de2", "score": "0.66343784", "text": "async refreshToken(_, { token: refresh_token }, { authUrl, apiUrl }) {\n const data = await request.post({\n uri: authUrl,\n form: {\n grant_type: 'refresh_token',\n refresh_token\n },\n json: true\n })\n\n const { data: user } = await request({\n uri: `${apiUrl}/v1/accounts`,\n json: true,\n headers: {\n Authorization: data.access_token\n }\n })\n\n return { ...data, user }\n }", "title": "" }, { "docid": "9f33a56afcc45d7b30b7a5e6e920228f", "score": "0.66288203", "text": "async refreshToken({request, response, auth}) {\n // user input\n // rules: Validators/Auth/RefreshToken\n const refreshToken = request.input('refresh_token')\n\n // generate token\n // abort request if refresh token is invalid or revoked\n let token\n try {\n token = await auth.generateForRefreshToken(refreshToken, {forSite: Config.get('auth.forSites.client')})\n } catch (e) {\n abort(httpCodes.badRequest)\n }\n\n return response.dataJSON(token)\n }", "title": "" }, { "docid": "56d78421847d38de2ea05dbcc5f2086b", "score": "0.66132385", "text": "async function refreshToken()\n{\n let req = new Request(\"https://www.strava.com/api/v3/oauth/token\");\n req.method=\"post\"\n req.headers = {\n \"Content-Type\": \"application/json\"\n }\n\n req.body= JSON.stringify({\n client_id:athlete.clientId,\n client_secret:athlete.clientSecret,\n refresh_token:athlete.refreshToken,\n grant_type:\"refresh_token\"\n })\n\n let out = await req.loadJSON()\n log(out)\n \n athlete.accessToken = out.access_token;\n athlete.refreshToken = out.refresh_token;\n// file.expiresAt = out.expires_at\n// log(file)\n getStats(); \n createWidget();\n \n}", "title": "" }, { "docid": "e123febede3665e0cba5a9e01e0b0473", "score": "0.66092426", "text": "async function refreshAccessToken() {\n let payload = '';\n try {\n payload = {\n grant_type: 'refresh_token',\n refresh_token: REFRESH_TOKEN,\n };\n // console.log('refreshAccessToken >> payload', payload);\n const result = await cronofyClient.refreshAccessToken(payload);\n // console.log('refreshAccessToken >> result', result);\n setAuthTokenInfo(result);\n }\n catch (err) {\n const context = {\n payload,\n err,\n };\n logInfo('Error! refreshAccessToken() >> Exception Detail', context);\n }\n}", "title": "" }, { "docid": "5d4b34e4894fb6c0970480ed962529c9", "score": "0.65779436", "text": "function refreshToken() {\n checkAuth(false, refreshLayer);\n}", "title": "" }, { "docid": "3adb975106f37e0c96bb5720786ac55f", "score": "0.6494545", "text": "refreshAuthToken(token) { }", "title": "" }, { "docid": "49ed06e83c0bdd6e5db0638a2ec94e0f", "score": "0.6481542", "text": "async renew(refreshToken) {\n let result = {};\n\n try {\n const discovery = await utils.getOidcDiscovery();\n const response = await axios.post(discovery.token_endpoint,\n qs.stringify({\n client_id: config.get('oidc.clientID'),\n client_secret: config.get('oidc.clientSecret'),\n grant_type: 'refresh_token',\n refresh_token: refreshToken,\n scope: discovery.scopes_supported\n }), {\n headers: {\n Accept: 'application/json',\n 'Cache-Control': 'no-cache',\n 'Content-Type': 'application/x-www-form-urlencoded',\n }\n }\n );\n\n log.verbose(arguments.callee.name, utils.prettyStringify(response.data));\n result.jwt = response.data.access_token;\n result.refreshToken = response.data.refresh_token;\n } catch (error) {\n log.error(arguments.callee.name, error.message);\n result = error.response.data;\n }\n\n return result;\n }", "title": "" }, { "docid": "5a1b41125670f561f80740fa0dbc7427", "score": "0.64708006", "text": "function getNewTokens(res) {\n let json = JSON.parse(res);\n let refreshToken = json.refresh_token;\n\n var options = {\n method: 'POST',\n url: 'https://bandcamp.com/oauth_token',\n headers:\n {\n 'cache-control': 'no-cache',\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n form:\n {\n grant_type: 'refresh_token',\n client_id: '211',\n client_secret: 'uYIOiB6Yv7MyNPbAZRHuQ4puooTu9qC5uzwpdmGjbpA=',\n refresh_token: `${refreshToken}`,\n undefined: undefined\n }\n };\n return options;\n}", "title": "" }, { "docid": "d7d14972ff8d9173cd65f328d31a7518", "score": "0.6457474", "text": "function getRefreshToken() {\n\t$.ajax({\n\t\turl: 'http://localhost:3000/refresh_token',\n\t\tdata: {\n\t\t\t'refresh_token': refresh_token\n\t\t}\n\t}).done(function(data) {\n\t\taccess_token = data.access_token;\n\t\tcurrentTimer = data.currentTimer;\t\n\t\tconsole.log(data);\n\t});\n}", "title": "" }, { "docid": "e8f752c70db2698ee84a235bbfefb231", "score": "0.6449725", "text": "refreshToken() {\n this.http.post('http://127.0.0.1:8000/api/token/refresh/', JSON.stringify({ refresh: this.refresh }), this.httpOptions).subscribe(data => {\n console.log('refresh success', data);\n this.updateData(data['access']);\n }, err => {\n console.error('refresh error', err);\n this.errors = err['error'];\n });\n }", "title": "" }, { "docid": "a92e94bab159200677da9cd2888f49fa", "score": "0.6424043", "text": "getRefreshTokens() {\n return HttpHelper.get('/accounts/me/refresh_tokens');\n }", "title": "" }, { "docid": "d9cfed6e52d0478734c314c5c52ac9c2", "score": "0.6385079", "text": "async refreshTokenNoCache(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n refreshToken) {\n const tokenPath = `service-accounts/${this.serviceAccountEmail}/token`;\n let data;\n try {\n const instanceOptions = {\n property: tokenPath,\n };\n if (this.scopes.length > 0) {\n instanceOptions.params = {\n scopes: this.scopes.join(','),\n };\n }\n data = await gcpMetadata.instance(instanceOptions);\n }\n catch (e) {\n e.message = `Could not refresh access token: ${e.message}`;\n this.wrapError(e);\n throw e;\n }\n const tokens = data;\n if (data && data.expires_in) {\n tokens.expiry_date = new Date().getTime() + data.expires_in * 1000;\n delete tokens.expires_in;\n }\n this.emit('tokens', tokens);\n return { tokens, res: null };\n }", "title": "" }, { "docid": "4232839863f3ebcf196075da7e1db0a4", "score": "0.63428843", "text": "function funcRefreshToken() {\n //let code = req.query.code || null\n let authOptions = {\n url: 'https://accounts.spotify.com/api/token',\n form: {\n //code: code,\n refresh_token: refresh_token, // my saved refresh token\n redirect_uri,\n grant_type: 'refresh_token'\n },\n headers: {\n 'Authorization': 'Basic ' + (new Buffer(\n SPOTIFY_CLIENT_ID + ':' + SPOTIFY_CLIENT_SECRET\n ).toString('base64'))\n },\n json: true\n }\n request.post(authOptions, function (error, response, body) {\n // Set all NEW tokens and expiration time\n access_token = body.access_token;\n expires_in = body.expires_in;\n })\n}", "title": "" }, { "docid": "f1e02559c254e41d8d9bfed7c9ace032", "score": "0.633737", "text": "refreshAuthToken(authInfo) {\n // We expect the original authInfo object used in the onboarding flow\n // not defining a brand new type for the Refresh() contract and re-using\n // what is defined for Onboarding()\n if (authInfo == undefined || authInfo == null || authInfo.length !== 2) {\n throw new OpenT2TError(401, OpenT2TConstants.InvalidAuthInfoInput);\n }\n\n var options = {\n url: 'https://connect.insteon.com/api/v2/oauth2/token',\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: 'grant_type=refresh_token&refresh_token=' + this._authTokens['refresh'].token + '&client_id=' + authInfo[0].client_id\n };\n\n return request(options).then((body) => {\n var tokenInfo = JSON.parse(body); // This includes refresh token, scope etc..\n\n // 'expires_in is in minutes', according to http://docs.insteon.apiary.io/#reference/authorization/authorization-grant\n var expiration = Math.floor((new Date().getTime() / 1000) + (tokenInfo.expires_in * 60));\n\n this._authTokens['refresh'].token = tokenInfo.refresh_token;\n this._authTokens['refresh'].expiration = expiration\n\n this._authTokens['access'].token = tokenInfo.access_token;\n this._authTokens['access'].expiration = expiration\n this._authTokens['access'].client_id = authInfo[0].client_id;\n\n return this._authTokens;\n\n });\n }", "title": "" }, { "docid": "ba0097bfacb9a8b75710a4c016f9652e", "score": "0.63370216", "text": "async refreshAccessToken() {\n\t\tthis.refreshingAccessToken = true;\n\n\t\tlet options = {\n\t\t\tmethod: 'GET',\n\t \theaders: {\n\t \t'Accept': 'application/json',\n\t \t'Content-Type': 'application/x-www-form-urlencoded'\n\t \t}\n\t\t};\n\n\t\tlet [response, payload] = await api.request(`${API_ENDPOINT}/auth/refresh-token`, options, this.getLocalAccessToken().value);\n\t\tif (!response.ok) {\n\t\t\treturn exception.throwFromResponse(payload);\n\t\t}\n\n\t\tthis.setLocalAccessToken(payload.data.token);\n\t\tthis.refreshingAccessToken = false;\n\t}", "title": "" }, { "docid": "f4d6e67540288799a1dfd1c4e2b00f9a", "score": "0.62961435", "text": "#checkAndRefreshToken () {\n const currTime = this.#getCurrTimeStamp()\n const isExpired = !this.#expires || this.#expires <= currTime\n\n if (isExpired) this.#createSignedToken(currTime)\n }", "title": "" }, { "docid": "8c3f9c059af45fc06e13ed255fe79f79", "score": "0.6287861", "text": "async getToken() {\n // If we don't have a refresh token yet, we need to make a call to get tokens.\n if (!this.refreshToken) {\n return this.getNewTokens();\n }\n\n // We have a refresh token, so let's try to fetch an access token using that.\n return this.overledger.refreshAccessToken(process.env.CLIENT_ID, process.env.CLIENT_SECRET, this.refreshToken)\n .then(response => response.data.access_token)\n .catch((error) => {\n // Lets assume the refresh token expired, so make a call to get a new set of tokens.\n log.error(error);\n return this.getNewTokens();\n });\n }", "title": "" }, { "docid": "af9ff0ef24771372654d8038f0f3f824", "score": "0.62514037", "text": "async getRefreshedAccessToken() {\n \n // Create the request to refresh tokens.\n const requestBody = new URLSearchParams({\n \"client_id\": NUHEAT_API_CLIENT_ID,\n \"client_secret\": NUHEAT_API_CLIENT_SECRET,\n \"grant_type\": \"refresh_token\",\n \"redirect_uri\": NUHEAT_API_REDIRECT_URI,\n \"refresh_token\": this.refreshToken,\n \"scope\": this.tokenScope\n });\n \n // Execute the refresh token request.\n const response = await this.fetch(NUHEAT_API_TOKEN_URI, {\n body: requestBody.toString(),\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\"\n },\n method: \"POST\"\n });\n \n if(!response) {\n return false;\n }\n \n // Grab the refresh token JSON.\n const token = await response.json();\n this.accessToken = token.access_token;\n this.accessTokenTimestamp = Date.now();\n this.refreshInterval = token.expires_in;\n this.refreshToken = token.refresh_token;\n this.tokenScope = token.scope ?? this.tokenScope;\n this.tokenType = token.token_type;\n \n // Refresh our tokens at seven minutes before expiration as a failsafe.\n this.refreshInterval -= 420;\n \n // Ensure we never try to refresh more frequently than every five minutes.\n if(this.refreshInterval < 300) {\n this.refreshInterval = 300;\n }\n \n // Update our authorization header.\n this.headers.set(\"Authorization\", token.token_type + \" \" + token.access_token);\n this.log.debug(\"NuHeatAPI: Successfully refreshed the NuHeat API access token.\");\n \n // We're done.\n return true;\n }", "title": "" }, { "docid": "6b639d8377a19d4727372c1adcbe9a82", "score": "0.6240135", "text": "function getAccessTokenFromRefreshToken() {\n\t$.ajax({\n\t\turl: tokenEndPoint,\n\t\tdata: {\n\t\t\trefresh_token: refreshToken,\n\t\t\tgrant_type: 'refresh_token',\n\t\t\tclient_id: client_id,\n\t\t\tclient_secret: client_secret\n\t\t},\n\t\tmethod: 'POST',\n\t\tsuccess: function (data) {\n\t\t\tconsole.log(data.access_token);\n\t\t\tconsole.log(data.refresh_token);\n\t\t\t$('#token').text(data.access_token);\n\t\t\t$('#refreshToken').text(data.refresh_token);\n\t\t\taccessToken = data.access_token;\n\t\t\trefreshToken = data.refresh_token;\n\t\t},\n\t\terror: function (err) {\n\t\t\talert(err.responseText);\n\t\t}\n\t})\n}", "title": "" }, { "docid": "b2635bb06f3981f004aa7b9ed08bbf76", "score": "0.6238124", "text": "refreshToken(){\n return api\n .refreshToken();\n }", "title": "" }, { "docid": "6da94a58995a5dca1bfbc2bb2fb1e247", "score": "0.62037086", "text": "handleRefreshToken() { \n fetch(`http://localhost:7777/refresh_token`, {\n method: 'GET',\n headers: {\n refresh_token: localStorage.getItem('refreshToken')\n }\n })\n .then(res => res.json())\n .then(\n (res) => {\n console.log(res);\n var dt = new Date();\n dt.setHours( dt.getHours() + 1);\n localStorage.setItem('accessToken', res.access_token);\n localStorage.setItem('expirationTime', dt);\n })\n\n\n }", "title": "" }, { "docid": "5ebf7b23e973932b044a6c77411e33c7", "score": "0.61986613", "text": "refreshAuthToken(authInfo) {\n if (!authInfo) {\n throw new OpenT2TError(401, OpenT2TConstants.InvalidAuthInfoInput);\n }\n\n if (authInfo.length !== 2) {\n // We expect the original authInfo object used in the onboarding flow\n // not defining a brand new type for the Refresh() contract and re-using\n // what is defined for Onboarding()\n throw new OpenT2TError(401, OpenT2TConstants.InvalidAuthInfoInput);\n }\n\n // POST oauth2/token\n var postPayloadString = JSON.stringify({\n 'client_id': authInfo[0].client_id,\n 'client_secret': authInfo[0].client_secret,\n 'grant_type': 'refresh_token',\n 'refresh_token': this._authTokens['refresh'].token,\n });\n\n return this._makeRequest(this._oAuthPath, \"POST\", postPayloadString, false).then((body) => {\n\n // _makeRequest() already returns a JSON representation of the POST response body\n // return the auth properties out in our own response back\n\n // there isn't a 'scopes' property returned as a result of this request according to\n // http://docs.wink.apiary.io/#reference/oauth/obtain-access-token/sign-in-as-user,-or-refresh-user's-expired-access-token\n // so am assuming the caller of this API will expect nulls\n\n var expiration = Math.floor(new Date().getTime() / 1000) + 86400 // Default to 24 hours (in seconds);\n // default to one year in seconds\n var refreshExpiration = Math.floor(new Date().getTime() / 1000) + 31557600;\n\n this._authTokens['refresh'].token = body.refresh_token;\n this._authTokens['refresh'].expiration = refreshExpiration;\n\n this._authTokens['access'].token = body.access_token;\n this._authTokens['access'].expiration = expiration;\n\n return this._authTokens;\n });\n }", "title": "" }, { "docid": "ac6c43a4d663d70782b89c181143f0d9", "score": "0.61875343", "text": "async function chechRefreshToken() {\n const result = await (\n await fetch('http://localhost:5000/api/auth/refresh_token', {\n method: 'POST',\n // mode: 'no-cors',\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n )\n\n setUser({\n accessToken: result.accessToken,\n });\n // setLoading(false);\n }", "title": "" }, { "docid": "fb7f3947a606aed3b52f5c29027b0577", "score": "0.61792004", "text": "static async refresh(token, req, rep) {\n try {\n const result = await firebase.auth().signInWithCustomToken(token);\n const idToken = await result.user.getIdToken();\n const customToken = await admin.auth().createCustomToken(result.user.uid);\n return rep.response({\n email: result.user.email,\n idToken,\n customToken\n }).code(200);\n } catch(err) {\n return rep.response('Too much time has gone by without refreshing. Please log in again to continue.' + err).code(401);\n }\n }", "title": "" }, { "docid": "5e429c458dbd9a43c5046e12ddedbe4c", "score": "0.6156334", "text": "async handleToken(callback = null) {\n var oauthState, url = Url.parse(this.request.url, true);\n if (!url.query.code) {\n return;\n }\n \n if (this.request.authSession && this.request.authSession.oauthState) {\n if (url.query.state !== this.request.authSession.oauthState.oauthStateCode) {\n throw new Error('Invalid request; state mismatch.');\n }\n oauthState = this.request.authSession.oauthState;\n delete this.request.authSession.oauthState;\n } else if (url.query.state) {\n throw new Error('Invalid request; unexpected \"state\" parameter.');\n }\n \n var options = {\n method: 'POST',\n url: this.endpoints.tokenUrl,\n headers: {'content-type': 'application/x-www-form-urlencoded'},\n form: {\n grant_type: 'authorization_code', // or refresh_token\n client_id: this.params.clientId,\n client_secret: this.params.clientSecret, // not needed for type refresh_token\n code: url.query.code, // not needed for type refresh_token\n redirect_uri: this.callbacks.loginUrl, // not needed for type refresh_token\n // refresh_token: the body.refresh_token in previous request\n },\n //headers: {'content-type': 'application/x-www-form-urlencoded'}, body: 'gdgdgd=333222', //or form: {}\n //headers: {'content-type': 'application/json'}, body: '{\"Hey\":\"Hello\"}',\n };\n var data = await _promise((resolve, reject) => {\n Request(options, (error, response, body) => {\n if (error || response.statusCode !== 200) {\n reject('Authentication error; ' + (error || body));\n return;\n }\n resolve(JSON.parse(body));\n });\n });\n \n var credentials = { ...data };\n if (data.id_token) {\n data.id_token = Jsonwebtoken.decode(data.id_token, {complete: true});\n // Verify signing algorithm - \"data.id_token.header.alg\" - HS256, RS256\n // Verify token audience claims - \"data.id_token.payload.aud\" - roughly this.params.clientId\n // Verify permissions (scopes) - \"data.id_token.payload.scopes\" - from the initiator request\n // Verify issuer claims - \"data.id_token.payload.iss\" - usually the domain part in this.endpoints.loginUrl\n // Verify expiration - \"data.id_token.payload.exp\" - must be after the current date/time\n // Starts a login session\n delete credentials.id_token;\n }\n if (callback) {\n credentials.identity = await callback(data);\n } else {\n credentials.identity = (data.id_token || {}).payload;\n }\n this.credentials = credentials;\n if (this.request.authSession && this.params.sesskey) {\n this.request.authSession.oauth = credentials;\n }\n // Redirect back to initiator URL\n if (oauthState && oauthState.initiatorURL !== this.request.url) {\n this.response.writeHead(302, {Location: oauthState.initiatorURL});\n this.response.end();\n return 302;\n }\n \n }", "title": "" }, { "docid": "e12c521f53f7d9a1cb5d59b2567358c3", "score": "0.6153732", "text": "async refreshAccessToken() {\n try {\n const query = {\n grant_type: 'refresh_token',\n client_id: this._parameters.client_id,\n client_secret: this._parameters.client_secret,\n refresh_token: this._parameters.refresh_token\n }\n const refreshUrl = config.oauth_url;\n console.log('URL refresh: ', refreshUrl);\n const res = await fetch(refreshUrl, {\n method: 'POST',\n body: JSON.stringify(query)\n })\n\n const refreshed = await res.json();\n\n if (refreshed.error) {\n throw refreshed;\n }\n console.log('Refreshed: ', refreshed);\n if (refreshed && !refreshed.error) {\n this._parameters.refresh_token = refreshed.refresh_token;\n this._parameters.access_token = refreshed.access_token;\n\n perguntadoresService.atualizarPerguntador({\n id: refreshed.user_id,\n access_token: refreshed.access_token,\n refresh_token: refreshed.refresh_token\n });\n\n return { access_token: this._parameters.access_token, refresh_token: this._parameters.refresh_token }\n }\n\n } catch (err) {\n return err;\n }\n }", "title": "" }, { "docid": "25344a1c9150dc7d834e71ef50134abd", "score": "0.6152653", "text": "function refresh() {\n return getAccessToken(process.env)\n .then(accessToken => ({ ACCESS_TOKEN: accessToken }))\n .then(config.save);\n}", "title": "" }, { "docid": "941abb87ca3fd78e7ddb2a2e96bd6502", "score": "0.6152193", "text": "async function refreshOauthToken() {\n const reponse = await fetch(\"https://id.twitch.tv/oauth2/token--data-urlencode?grant_type=refresh_token&refresh_token=\" + \"ovyi14126918nmgrfhqhw5t9jupl8v\" + \"&client_id=\" + CLIENT_ID_TWITCH + \"&client_secret=\" + CLIENT_SECRET, {\n method: \"POST\",\n\n })\n .then((response) => response.json())\n .then(data => {\n console.log(data);\n })\n }", "title": "" }, { "docid": "ff87cca586196699db2cb5b3055c7b94", "score": "0.6147421", "text": "async getNewTokens() {\n if (!this.overledger) {\n await this.startupSdk();\n }\n\n const refreshTokensResponse = await this.overledger.getTokensUsingClientIdAndSecret(\n process.env.USER_NAME,\n process.env.PASSWORD,\n process.env.CLIENT_ID,\n process.env.CLIENT_SECRET,\n );\n\n // Keep tokens so we can use later (refresh token).\n this.refreshToken = refreshTokensResponse.refreshToken;\n this.idToken = refreshTokensResponse.idToken;\n this.accessToken = refreshTokensResponse.accessToken;\n return this.accessToken;\n }", "title": "" }, { "docid": "cba1d7531e94b70780bc9ce892e689d1", "score": "0.6147077", "text": "function refresh(callback) {\n var params = { grant_type: 'refresh_token', refresh_token: this.token.refresh_token };\n var that = this;\n\n return core.api('POST', config.tokenPath, params).then(this.create).nodeify(callback);\n }", "title": "" }, { "docid": "75a0c0b5f895c4eaf1d54e88c8da9a32", "score": "0.61384076", "text": "async function refreshAuthToken(refreshToken, recordId) {\n const url='https://oauth2.googleapis.com/token';\n const formData=JSON.stringify({ \n 'refresh_token': refreshToken,\n 'client_id': '104634558751-1ti20v7urgs8r8cdcg36n67atp0sejin.apps.googleusercontent.com',\n 'client_secret': 'Tm-ImPRgwADm2a7ZJV-JzAWQ',\n 'grant_type': \"refresh_token\"\n });\n\n const res = await fetch(url,{\n method: 'POST',\n body: formData\n }).then((data)=> data.json())\n\n const newUrl='https://api.airtable.com/v0/appVzdOnR4SFUPs9G/oauth';\n const Body=JSON.stringify({\n \"records\": [\n {\n \"id\":recordId,\n \"fields\": {\n \"oauth-token\": res[\"access_token\"],\n \"expires_at\": (res[\"expires_in\"] * 1000) + Date.now()\n }\n }\n ]\n });\n const newParam={\n method: \"PATCH\",\n headers: new Headers({\n 'Authorization': \"Bearer keyv18eQNXnUD0Mdn\",\n 'Content-Type': \"application/json\"\n }),\n body: Body\n }\n\n const airtableRes = await fetch(newUrl,newParam).then((data)=> data.json())\n\n const newTimestamp = JSON.stringify(airtableRes[\"records\"][0][\"fields\"][\"expires_at\"]) ? JSON.stringify(airtableRes[\"records\"][0][\"fields\"][\"expires_at\"]) : '';\n\n if (newTimestamp > Date.now()) {\n return true;\n } else {\n return false;\n }\n}", "title": "" }, { "docid": "52fd3cf76dcce2dd2cada80687ec1c90", "score": "0.6134117", "text": "function getRefreshToken(refreshtoken, success, fail) {\n var xhr = new XMLHttpRequest();\n xhr.open('POST', 'https://accounts.spotify.com/api/token', false);\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n xhr.setRequestHeader('Authorization', 'Basic ' + spotify_secret);\n xhr.onload = function () {\n console.log(this);\n console.log('ResponseText', this.responseText);\n if (this.status == 200) {\n success(JSON.parse(this.responseText));\n } else {\n fail();\n }\n };\n\n xhr.send('grant_type=refresh_token&refresh_token=' + refreshtoken );\n}", "title": "" }, { "docid": "291ef44489d51805482df000b559c78d", "score": "0.61192685", "text": "function freshToken() {\n oauth2.clientCredentials\n .getToken(tokenConfig)\n .then((result) => {\n token = oauth2.accessToken.create(result);\n console.log(token.token.access_token)\n })\n .catch((error) => {\n console.log('Access Token error', error.response.data);\n });\n}", "title": "" }, { "docid": "9b4c45dfc1e1d20bf3a762b81bbacfbd", "score": "0.606212", "text": "function refreshToken(token) {\n\n // get new access token for refresh token request\n loginDatalayer.refreshToken(token)\n .then(function (response) {\n\n localStorage.setItem('accessToken', response.accessToken);\n\n var token = {\n 'Authorization': \"Bearer \" + localStorage.getItem('accessToken')\n }\n\n // user details API call\n userDetails(token);\n // console.log(response);\n }, function (status) {\n loginRequestSent = false;\n if (status === 401) {\n }\n });\n }", "title": "" }, { "docid": "d99d43990f45e204507c82f266fd67da", "score": "0.605178", "text": "refreshApiToken() {\n this.lastRefreshedApiTokenAt = moment();\n\n this.$http.put('/spark/token');\n }", "title": "" }, { "docid": "8f7169696afc44e63b73cbee37155b94", "score": "0.6045439", "text": "async function getNewOAuthToken() {\n try {\n const { data } = await refreshToken();\n if (data.success === false) throw new Error(data.message);\n return data.token;\n } catch (error) {\n console.error(error.message);\n }\n}", "title": "" }, { "docid": "6333cfa020768103697d3b1c6b62686e", "score": "0.6036616", "text": "function refresh(config, refreshToken, cb) {\n const tokenUrl = \"https://login.microsoftonline.com/common/oauth2/v2.0/token\";\n const scope = config.scopes.join(' ');\n const params = {\n \"client_id\": config.clientId,\n \"client_secret\": config.clientSecret,\n \"grant_type\": \"refresh_token\",\n \"refresh_token\": refreshToken,\n \"scope\": scope,\n };\n\n superagent\n .post(tokenUrl)\n .type('form')\n .send(params)\n .end((err, result) => {\n if (err)\n cb(err);\n else\n cb(null, result.body);\n });\n}", "title": "" }, { "docid": "329b515c64265979b3346f36f037cff2", "score": "0.6025653", "text": "refreshTokensRequestTokens(callbackContext, customParams) {\n let headers = new HttpHeaders();\n headers = headers.set('Content-Type', 'application/x-www-form-urlencoded');\n const authWellKnown = this.storagePersistanceService.read('authWellKnownEndPoints');\n const tokenEndpoint = authWellKnown === null || authWellKnown === void 0 ? void 0 : authWellKnown.tokenEndpoint;\n if (!tokenEndpoint) {\n return throwError('Token Endpoint not defined');\n }\n const data = this.urlService.createBodyForCodeFlowRefreshTokensRequest(callbackContext.refreshToken, customParams);\n return this.dataService.post(tokenEndpoint, data, headers).pipe(switchMap((response) => {\n this.loggerService.logDebug('token refresh response: ', response);\n let authResult = new Object();\n authResult = response;\n authResult.state = callbackContext.state;\n callbackContext.authResult = authResult;\n return of(callbackContext);\n }), catchError((error) => {\n const errorMessage = `OidcService code request ${this.configurationProvider.openIDConfiguration.stsServer}`;\n this.loggerService.logError(errorMessage, error);\n return throwError(errorMessage);\n }));\n }", "title": "" }, { "docid": "c458b5b724d693c4913d6aee41f6c725", "score": "0.6017826", "text": "async function refreshToken() {\n return fetch(tokenServerURL)\n .then((res) => {\n return res.json();\n })\n .then((json) => json.access_token)\n .catch((error) => {\n console.error(error);\n });\n}", "title": "" }, { "docid": "b295368a02d8c047e85e9cbaf3146145", "score": "0.6017038", "text": "async refreshToken(parent,{token},context,info){\n\n try {\n // verify refresh token\n const userId=await veifyRefreshToken(token)\n //generate new access token\n console.log(userId)\n const accToken=await signAccessToken(userId);\n //generate new refresh token\n const refToken=await signReferesToken(userId)\n // throw new Error(\"not valid\")\n return {accToken,refToken}\n } catch (error) {\n return error\n }\n }", "title": "" }, { "docid": "270a0472a329aa36cc8b8cf48d462c45", "score": "0.60033566", "text": "function renewToken(){\n $http.get('http://localhost:3000/renewToken').then(function(res){\n setToken(res.data);\n })\n }", "title": "" }, { "docid": "0b5ba9fdd8c69fffb5d21f7c8530b6d8", "score": "0.59924424", "text": "getRefreshToken(name = null) {\n let token = {};\n token['user'] = name;\n let n = Math.floor(Date.now() / 1000);\n token['iat'] = n;\n token['exp'] = n + (7 * 24 * 60 * 60);\n return JWT.sign(token, this.refreshPrivateKey + this.salt);\n }", "title": "" }, { "docid": "1e6be12bcf6e00d0d5ce91ca2fc4c36f", "score": "0.59863186", "text": "refreshToken() {\n console.log(\"Requesting refreshToken\");\n return axios({\n url: \"/refresh_token\",\n params: {\n refresh_token: this.getRefreshToken()\n }\n }).then(response => {\n console.log(\"response\", response);\n return response.data.access_token;\n });\n }", "title": "" }, { "docid": "3efbe6d91e75a3798498d322f8693e9e", "score": "0.5975834", "text": "function refreshToken(refresh_token) {\n console.log(\"getting refresh token\");\n if (refreshPromises[refresh_token]) {\n return refreshPromises[refresh_token];\n }\n\n // Note that the data in the request is different when getting a new token\n // via a refresh_token. grant_type = refresh_token, and do NOT include the\n // scope parameter in the request as it'll cause issues if you do.\n let formData = new FormData();\n formData.append('grant_type', 'refresh_token');\n formData.append('client_id', config.client_id);\n formData.append('client_secret', config.client_secret);\n formData.append('refresh_token', refresh_token);\n\n return(refreshPromises[refresh_token] = fetch(`${config.base}/oauth/token`, {\n method: 'post',\n headers: new Headers({\n 'Accept': 'application/json',\n }),\n body: formData,\n })\n .then(function(response) {\n return response.json();\n })\n .then((data) => {\n delete refreshPromises[refresh_token];\n\n if (data.error) {\n console.log('Error refreshing token', data);\n return false;\n }\n return saveToken(data);\n })\n .catch(err => {\n delete refreshPromises[refresh_token];\n console.log('API got an error', err)\n return Promise.reject(err);\n })\n );\n }", "title": "" }, { "docid": "9567997aeaac6b283b0ff5249d654c65", "score": "0.59596616", "text": "function getTokenFromRefreshToken(refresh_token, completion) {\n var token = oauth2.accessToken.create({ refresh_token: refresh_token, expires_in: 0});\n token.refresh(function(err, result) {\n if (err) {\n completion(err, null)\n return \n }\n completion(null, result)\n })\n}", "title": "" }, { "docid": "f589f1fffc909aa17f6bbdf7cf49cb34", "score": "0.5959294", "text": "obtainTokens() {\n let body = buildRequestBody.call(this, {\n formBody: {\n 'grant_type': 'client_credentials'\n }\n });\n\n return request(body)\n .then((data) => {\n try {\n let tokens = JSON.parse(data);\n\n this.accessToken = tokens.access_token;\n this.refreshToken = tokens.refresh_token;\n\n configModule.write([{\n key: 'bitbucket.accessToken',\n value: tokens.access_token\n }, {\n key: 'bitbucket.refreshToken',\n value: tokens.refresh_token\n }]);\n } catch (err) {\n throw new Error(`Cannot parse tokens. Stack trace: ${err}`);\n }\n })\n .catch((err) => {\n throw new Error(`Can not fetch client tokens. Stack trace: ${err}`);\n });\n }", "title": "" }, { "docid": "653fc0a0d44aa12227729cc3b0f3c5c9", "score": "0.59560347", "text": "requestTimesheet(context) {\n const proxy = 'https://cors-anywhere.herokuapp.com/'\n const url = 'https://rest.tsheets.com/api/v1/timesheets'\n axios.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('tsheets_access_token')\n axios({\n url: proxy+url,\n method: 'get',\n params: {\n 'user_ids': localStorage.tsheets_user_id,\n 'start_date': new Date().toJSON().slice(0,10),\n 'on_the_clock': true\n }\n }).then(res => {\n localStorage.tsheets_tsheet_id = Object.keys(res.data.results.timesheets)[0]\n context.commit('CURRENT_TIMESHEET', res.data.results.timesheets[localStorage.tsheets_tsheet_id])\n }).catch(err => {\n console.log(err.response)\n })\n }", "title": "" }, { "docid": "28f36a1fae79e48cf87cada27c858c98", "score": "0.59363973", "text": "refreshApiTokenEveryFewMinutes() {\n this.lastRefreshedApiTokenAt = moment();\n\n setInterval(() => {\n this.refreshApiToken();\n }, 240000);\n\n setInterval(() => {\n if (this.lastRefreshedApiTokenAt.diff(moment(), 'minutes') >= 5) {\n this.refreshApiToken();\n }\n }, 5000);\n }", "title": "" }, { "docid": "a3577a69d317bc1100da873700c66694", "score": "0.5930671", "text": "async function refresh() {\n\treturn new Promise(function (resolve, reject) {\n\t\tgetToken((c) => {\n\t\t\ttoken = c.token;\n\t\t\texpiry = parseInt(c.expiry);\n\n\t\t\tclient = MicrosoftGraph.Client.init({\n\t\t\t\tauthProvider: (done) => {\n\t\t\t\t\tdone(null, token); //first parameter takes an error if you can't get an access token\n\t\t\t\t}\n\t\t\t});\n\t\t\tsetTimeout(function () { refresh() }, (expiry * 1000)); //try to get a new token after <expiry>ms * 1000 ms\n\t\t\tresolve(token)\n\t\t});\n\t});\n}", "title": "" }, { "docid": "46ed85ad09ead68af736b090c81d278e", "score": "0.5930327", "text": "refreshSessionWithRefreshTokens() {\n const stateData = this.flowsDataService.getExistingOrCreateAuthStateControl('refresh-token');\n this.loggerService.logDebug('RefreshSession created. adding myautostate: ' + stateData);\n const refreshToken = this.authStateService.getRefreshToken();\n const idToken = this.authStateService.getIdToken();\n if (refreshToken) {\n const callbackContext = {\n code: null,\n refreshToken,\n state: stateData,\n sessionState: null,\n authResult: null,\n isRenewProcess: true,\n jwtKeys: null,\n validationResult: null,\n existingIdToken: idToken,\n };\n this.loggerService.logDebug('found refresh code, obtaining new credentials with refresh code');\n // Nonce is not used with refresh tokens; but Keycloak may send it anyway\n this.flowsDataService.setNonce(TokenValidationService.refreshTokenNoncePlaceholder);\n return of(callbackContext);\n }\n else {\n const errorMessage = 'no refresh token found, please login';\n this.loggerService.logError(errorMessage);\n return throwError(errorMessage);\n }\n }", "title": "" }, { "docid": "0e4b1c0c5d0d753db117494bd5c94b36", "score": "0.5918774", "text": "function getAccessToken (){\n\t\tvar request = new XMLHttpRequest();\n\t\trequest.open(\"POST\", \"https://login.live.com/oauth20_token.srf\", false);\n\t\trequest.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\n\t\trequest.onload = function() {\n\t\t\tif(this.status == 200 || this.status == 0){\n\t\t\t\toriginalFs.writeFileSync(__dirname + \"/../token.json\", this.responseText);\n\t\t\t}else{\n\t\t\t\tconsole.log(this.status);\n\t\t\t}\n\t\t};\n\n\t\trequest.send(\"grant_type=refresh_token\"\n\t\t\t\t\t+ \"&client_id=\" + JSON.parse(fs.readFileSync(__dirname + \"/oauth2Info.json\")).client_id\n\t\t\t\t\t+ \"&redirect_uri=\" + JSON.parse(fs.readFileSync(__dirname + \"/oauth2Info.json\")).redirect_uri\n\t\t\t\t\t+ \"&refresh_token=\" + JSON.parse(originalFs.readFileSync(__dirname + \"/../token.json\")).refresh_token);\n\t}", "title": "" }, { "docid": "dcb7b1b2e1da82295b5180311bcb80cd", "score": "0.58969134", "text": "async refreshToken (options) {\n throw new Error('method not implemented')\n }", "title": "" }, { "docid": "7609fa741ae22a717b46246d97cfad31", "score": "0.58794236", "text": "async function getAccessToken(res) {\n // Calculation of the remaining validity period in seconds\n\n const currentDate = new Date();\n const diffTime = Math.round( getDiffTime( tokenDate, currentDate ) / 1000 );\n\n // the remaining validity period has expired, get a new token from the Google server\n\n if ( diffTime > TOKEN_TIMEOUT || !currentToken ) {\n currentToken = await generateAccessToken();\n }\n\n // Return token to caller with remaining validity period in seconds\n\n // console.log('getAccessToken: ', currentToken, TOKEN_TIMEOUT - diffTime );\n const result = { token: currentToken, time: TOKEN_TIMEOUT - diffTime };\n res.json( result );\n}", "title": "" }, { "docid": "6cbc7543722c664d0e5480fa884bdd9b", "score": "0.58775973", "text": "function refreshToken(){\n\tif(getToken())\n\t$.ajax({\n\t\t url: '/user/refresh',\n type: 'post',\n success: function (data) {\n localStorage.setItem('jwtToken',data.accessToken);\n }\n\t});\n}", "title": "" }, { "docid": "6e472aefb159fcea11946571544d4bbe", "score": "0.58635587", "text": "refresh()\n {\n debug(\"[refresh] Attempting to refresh using a refresh_token...\");\n\n const refreshToken = getPath(this, \"state.tokenResponse.refresh_token\");\n if (!refreshToken) {\n throw new Error(\"Unable to refresh. No refresh_token found in state\");\n }\n\n const tokenUri = this.state.tokenUri;\n if (!tokenUri) {\n throw new Error(\"Unable to refresh. No tokenUri found in storage\");\n }\n\n const scopes = getPath(this, \"state.tokenResponse.scope\") || \"\";\n if (scopes.indexOf(\"online_access\") == -1) {\n throw new Error(\"Trying to refresh but no `online_access` scope was granted\");\n }\n\n return request(tokenUri, {\n mode : \"cors\",\n method : \"POST\",\n headers: {\n \"content-type\": \"application/x-www-form-urlencoded\"\n },\n body: `grant_type=refresh_token&refresh_token=${encodeURIComponent(refreshToken)}`\n }).then(responseToJSON).then(data => {\n if (!data.access_token) {\n throw new Error(\"No access token received\");\n }\n return data;\n }).then(data => {\n debug(\"[refresh] Received new access token %O\", data);\n Object.assign(this.state.tokenResponse, data);\n return this.state;\n }).catch(error => {\n debug(\"[refresh] Deleting the expired or invalid refresh token\");\n delete this.state.tokenResponse.refresh_token;\n throw error;\n }).finally(() => {\n this.environment.getStorage().set(this.state.key, this.state);\n });\n }", "title": "" }, { "docid": "087558f968a2283a46c1637f79d7e4c3", "score": "0.58541596", "text": "function refreshToken(callback) {\n var me = self.getMe();\n if (!me || !me.key || !me.expires || !me.refresh) {\n $location.path('/');\n return;\n }\n var lastRefreshed = Number(localStorage.getItem('lastRefreshed')) + (1000 * 60 * 60);\n var time = new Date(me.expires).getTime() - (1000 * 60 * 60 * 24);\n if (Date.now() > time && Date.now() > lastRefreshed) {\n localStorage.setItem('lastRefreshed', Date.now());\n var req = {\n method: 'POST',\n url: config.api + '/users/token/refresh',\n data: {\n client: config.client,\n key: me.key,\n refresh: me.refresh\n }\n };\n $http(req).\n success(function (data) {\n me.key = data.key;\n me.token = data.token;\n me.refresh = data.refresh;\n me.expires = data.expires;\n self.setMe(me);\n return callback && callback();\n }).\n error(function (data) {\n self.logout();\n });\n } else {\n return callback && callback();\n }\n }", "title": "" }, { "docid": "9e9bcde9b6985846efb5af7f996af88f", "score": "0.58304346", "text": "requestTimesheetTotal(context) {\n const proxy = 'https://cors-anywhere.herokuapp.com/'\n const url = 'https://rest.tsheets.com/api/v1/timesheets'\n axios.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('tsheets_access_token')\n axios({\n url: proxy+url,\n method: 'get',\n params: {\n 'user_ids': localStorage.tsheets_user_id,\n 'start_date': new Date().toJSON().slice(0,10)\n }\n }).then(res => {\n context.commit('TOTAL_TIMESHEETS', res.data)\n }).catch(err => {\n console.log(err.response)\n })\n }", "title": "" }, { "docid": "13ab96cd7c849d4b0b93781b828fd5d0", "score": "0.58272815", "text": "async refreshTokenNoCache(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n refreshToken) {\n const gtoken = this.createGToken();\n const token = await gtoken.getToken({\n forceRefresh: this.isTokenExpiring(),\n });\n const tokens = {\n access_token: token.access_token,\n token_type: 'Bearer',\n expiry_date: gtoken.expiresAt,\n id_token: gtoken.idToken,\n };\n this.emit('tokens', tokens);\n return { res: null, tokens };\n }", "title": "" }, { "docid": "0f8d8f3ba108ac4de5ca2cb8f4c4c927", "score": "0.5825898", "text": "requestRefreshToken(e) {\n this.__context = \"refresh\";\n if (e.detail.element) {\n this.__element = e.detail.element;\n }\n this.generateRequest(this.refreshUrl);\n }", "title": "" }, { "docid": "a9c5f4f6c77d34505e5057a1dc08f216", "score": "0.5819673", "text": "async function refreshAccessToken() {\n const refreshToken = await keytar.getPassword('Philter', 'GoogleDriveRefreshToken')\n if (!refreshToken) {\n return null\n }\n const tokenData = await electronOauth2(config, windowParams).refreshToken(refreshToken)\n return {\n refreshToken: refreshToken,\n accessToken: tokenData.access_token\n }\n}", "title": "" }, { "docid": "ce8b9975d512568dece8a1745d8f32cf", "score": "0.58168715", "text": "refresh(request) {\r\n return this.oauth({\r\n grant_type: \"refresh_token\",\r\n refresh_token: querystring.parse(request.url.query).refreshToken\r\n });\r\n }", "title": "" }, { "docid": "1c4cf4ba309ff0183dd5ca93c92e6905", "score": "0.5815949", "text": "getAccessTokenFromRefreshToken(req, res) {\n console.log(\"we got this token thing going on\");\n const refresh_token = req.body.refresh_token;\n console.log(refresh_token);\n const authOptions = {\n url: 'https://accounts.spotify.com/api/token',\n headers: { 'Authorization': 'Basic ' + (new Buffer(client_id + ':' + client_secret).toString('base64')) },\n form: {\n grant_type: 'refresh_token',\n refresh_token: refresh_token\n },\n json: true\n };\n request.post(authOptions, function (error, response, body) {\n if (!error && response.statusCode === 200) {\n var access_token = body.access_token;\n res.send({\n 'access_token': access_token\n });\n }\n });\n }", "title": "" }, { "docid": "4b09cf2c2ae9474ef139cc1c4e9cd43b", "score": "0.5813497", "text": "function GetSmsAuthToken2(){\n var options = {\n method: 'GET',\n url: 'http://localhost:8080/demo/api/apigwtoken/',\n headers: {\n 'cache-control': 'no-cache',\n authorization: 'Basic YmlsbDphYmMxMjM='\n }\n };\n try {\n request(options, function (error, response, body) {\n if (!error) {\n var ApiGwSmsAuth = JSON.parse(body);\n if(ApiGwSmsAuth.status == 'approved'){\n var ApiGwAuth = JSON.parse(body);\n ApiGwAuthToken = ApiGwSmsAuth.accessToken;\n ApiGwAuthTokenExpiry = Date.now() + 23*50*60*1000; // Expire in 24 hours. Renew Token 10 mins before expiry \n\n console.log('Token = ' + ApiGwAuthToken + ' expiry in ' + ApiGwAuthTokenExpiry); \n } \n } else {\n }\n });\n } catch (e) { \n }\n}", "title": "" }, { "docid": "e6038625621a4788a493862ddb5084c8", "score": "0.5807587", "text": "function decodeAndCheckRefresh(value) {\r\n const getTokenFromLocal = ls.get(\"token\").accessToken || \"\";\r\n var decoded = jwt.decode(getTokenFromLocal, { complete: true });\r\n const tokentime =\r\n decoded !== null ? decoded.payload.exp : RefreshTokenAgain(value);\r\n const localStorageToken = new Date(\r\n tokentime * 1000 - 2000 * 60\r\n ).toLocaleString();\r\n const localUserDate = new Date().toLocaleString();\r\n // console.log(localStorageToken + \"--local storage token\");\r\n // console.log(localUserDate);\r\n\r\n if (Date.parse(localStorageToken) < Date.parse(localUserDate)) {\r\n RefreshTokenAgain(value);\r\n }\r\n }", "title": "" }, { "docid": "224a4518d6850c10eaacc3e93e4bacb3", "score": "0.5807289", "text": "refreshToken (context) {\n return new Promise((resolve, reject) => {\n axiosBase.post('/api/token/refresh/', {\n refresh: context.state.refreshToken\n }) // send the stored refresh token to the backend API\n .then(response => { // if API sends back new access and refresh token update the store\n console.log('New access successfully generated')\n context.commit('updateAccess', response.data.access)\n resolve(response.data.access)\n })\n .catch(err => {\n console.log('error in refreshToken Task')\n reject(err) // error generating new access and refresh token because refresh token has expired\n })\n })\n }", "title": "" }, { "docid": "7871bc59ccbc821a3ae9a6144c801589", "score": "0.58047426", "text": "function renewToken () {\n lock.checkSession({ scope: 'openid email profile offline_access' },\n function (err, result) {\n if (err) {\n console.log(err)\n } else {\n console.log('result renew token', result)\n getUserInfo(result)\n }\n }\n )\n}", "title": "" }, { "docid": "79e8d3810c9fbc20c331013e1918df2a", "score": "0.5797672", "text": "refreshAppCheckToken(token) { }", "title": "" }, { "docid": "e731bf63c56c3f5c60bfb08bc9ca697e", "score": "0.5779373", "text": "async refreshAccessTokenAsync() {\n // Retrieve the external credential.\n const subjectToken = await this.retrieveSubjectToken();\n // Construct the STS credentials options.\n const stsCredentialsOptions = {\n grantType: STS_GRANT_TYPE,\n audience: this.audience,\n requestedTokenType: STS_REQUEST_TOKEN_TYPE,\n subjectToken,\n subjectTokenType: this.subjectTokenType,\n // generateAccessToken requires the provided access token to have\n // scopes:\n // https://www.googleapis.com/auth/iam or\n // https://www.googleapis.com/auth/cloud-platform\n // The new service account access token scopes will match the user\n // provided ones.\n scope: this.serviceAccountImpersonationUrl\n ? [DEFAULT_OAUTH_SCOPE]\n : this.getScopesArray(),\n };\n // Exchange the external credentials for a GCP access token.\n const stsResponse = await this.stsCredential.exchangeToken(stsCredentialsOptions);\n if (this.serviceAccountImpersonationUrl) {\n this.cachedAccessToken = await this.getImpersonatedAccessToken(stsResponse.access_token);\n }\n else {\n // Save response in cached access token.\n this.cachedAccessToken = {\n access_token: stsResponse.access_token,\n expiry_date: new Date().getTime() + stsResponse.expires_in * 1000,\n res: stsResponse.res,\n };\n }\n // Save credentials.\n this.credentials = {};\n Object.assign(this.credentials, this.cachedAccessToken);\n delete this.credentials.res;\n // Trigger tokens event to notify external listeners.\n this.emit('tokens', {\n refresh_token: null,\n expiry_date: this.cachedAccessToken.expiry_date,\n access_token: this.cachedAccessToken.access_token,\n token_type: 'Bearer',\n id_token: null,\n });\n // Return the cached access token.\n return this.cachedAccessToken;\n }", "title": "" }, { "docid": "7fde206b7629189b373bc3bd9a6d780d", "score": "0.57764685", "text": "function retrieveSTAccessTok (safetrek_auth_code) {\n console.log(\"RETRIEVING ACCESS TOKEN.\");\n\n let request_body = {\n \"grant_type\": \"authorization_code\",\n \"code\": safetrek_auth_code,\n \"client_id\": process.env.CLIENT_ID,\n \"client_secret\": process.env.CLIENT_SECRET,\n \"redirect_uri\": \"https://safe-bot.herokuapp.com/webhook\"\n };\n\n request({\n \"uri\": \"https://login-sandbox.safetrek.io/oauth/token\",\n \"headers\": \"Content-Type: application/json\",\n \"method\": \"POST\",\n \"json\": request_body\n }, (err, res, body) => {\n if (!err) {\n console.log(body);\n safetrek_access_token = body.access_token;\n safetrek_refresh_token = body.refresh_token;\n } else {\n console.error(\"Unable to attain SafeTrek access token:\" + err);\n }\n });\n}", "title": "" }, { "docid": "0647a78e95aa24669ac6b5649bcf7f85", "score": "0.57760066", "text": "function RefreshToken(refresh_token, access_token){\n this.initData(); \n this.refresh_token = refresh_token;\n this.access_token = access_token;\n this.validateRequiredFields();\n}", "title": "" }, { "docid": "9196c281eea768ec95ec7729b7375894", "score": "0.57720864", "text": "function refreshToken(cozy, client, token) {\n return retrieveToken(cozy, client, token, {\n grant_type: 'refresh_token',\n refresh_token: token.refreshToken\n });\n}", "title": "" }, { "docid": "19b03395f8f0407902fc7e45a6eb2b8d", "score": "0.5752473", "text": "function getToken(callback){\n request.post({\n url: 'https://www.arcgis.com/sharing/rest/oauth2/token/',\n json:true,\n form: {\n 'f': 'json',\n 'client_id': 'u6PzgzifEzvKst92',\n 'client_secret': 'fffa18521c7c4ee5a0ddd5c565b5c8cb',\n 'grant_type': 'client_credentials',\n 'expiration': '1440'\n }\n }, function(error, response, body){\n console.log('BAT',body.access_token);\n callback(body.access_token);\n });\n}", "title": "" }, { "docid": "a82662276322fff08c5b624fad2f9b3c", "score": "0.57503355", "text": "async function getNewToken(refreshToken) {\n const data = await refreshKey(refreshToken);\n store.dispatch(setAccessToken(data.access_token));\n}", "title": "" }, { "docid": "4065fd167dc2e044cb1594093abef1b0", "score": "0.5734378", "text": "refreshToken(uuid, refreshToken) {\n\n //Avoid for more than one request started with old token and do not call twice refresh token \n if (this.currentRefreshToken && this.currentRefreshToken !== refreshToken) {\n return;\n }\n\n //Avoid for do not call refresh token api when before request started it.\n if (this.refreshStatus === refreshStatus.REFRESHING) {\n return;\n }\n\n this.refreshStatus = refreshStatus.REFRESHING;\n\n if (this.tryCount++ > 4) {\n this.redirectToLogin();\n return;\n }\n\n {/*authFactory.refreshToken({ uuid, token: refreshToken })\n .then((res) => {\n storageService.update(STORAGE_KEYS.AUTH_INFO, { token: res.token, refreshToken: res.refreshToken })\n .then(() => {\n this.refreshStatus = refreshStatus.INIT;\n this.currentRefreshToken = res.refreshToken;\n });\n }).catch((err) => {\n //If refresh token api call catch a token error, app should show login page.\n if (this.isTokenError(err)) {\n this.redirectToLogin();\n }\n })\n */}\n }", "title": "" }, { "docid": "aa4714c4d468e634e6b54c5d21143720", "score": "0.5709556", "text": "function refreshToken(token) {\r\n\t//console.log(\"to refresh\",token);\r\n\t$.ajax({\r\n\t\turl: \"http://104.236.3.75/fassster-api/public/api/user/token-refresh\",\r\n\t\ttype: \"post\",\r\n\t\tdataType: \"json\",\r\n\t\theaders: { \r\n\t\t\t\t\"Authorization\": \"Bearer \" + token\r\n\t\t}\r\n\t})\r\n\t.done(function(data) {\r\n\t\t\t//console.log(data);\r\n\t\t\tif(data.success == true) {\r\n\t\t\t\t//store token into session\r\n\t\t\t\t$.session.set('userToken', data.token);\r\n\t\t\t\t//return new token\r\n\t\t\t\treturn data.token\r\n\t\t\t}\r\n\t});\r\n}", "title": "" }, { "docid": "beecdd9540a450c11eca649428c10738", "score": "0.56930816", "text": "refreshAuthTokens() {\n // const { refresh } = this\n // return client.POST('/auth/refresh', { refresh }).then(tokens => {\n // this.setAuthTokens(tokens)\n // })\n\n return Promise.resolve({ access: 'someAccess', refresh: 'someRefresh' }).then(tokens => {\n this.setAuthTokens(tokens);\n });\n }", "title": "" }, { "docid": "c16f1f5b63f9badcff9c16d6e7b196d9", "score": "0.56921244", "text": "function collectAccessToken() {\n $.post(`https://www.strava.com/oauth/token?client_id=32540&client_secret=${client_secret}&code=${accessCode}&grant_type=authorization_code`, function(data, status) {\n if(status === 'success') {\n accessToken = data.access_token;\n refreshToken = data.refresh_token;\n } \n else(\n alert('Request Error'));\n })\n return accessToken, refreshToken;\n}", "title": "" }, { "docid": "c98c66f3563b9782121e6605d966e249", "score": "0.568449", "text": "refreshAuthTokens() {\n // const { refresh } = this\n // return client.POST('/auth/refresh', { refresh }).then(tokens => {\n // this.setAuthTokens(tokens)\n // })\n\n return Promise.resolve({ access: 'someAccess', refresh: 'someRefresh' }).then(tokens => {\n this.setAuthTokens(tokens)\n })\n }", "title": "" }, { "docid": "83e003a63bfe8a71806db576aff11ca3", "score": "0.56793684", "text": "refresh()\n {\n const debug = _debug.extend(\"client:refresh\");\n debug(\"Attempting to refresh with refresh_token...\");\n\n const refreshToken = getPath(this, \"state.tokenResponse.refresh_token\");\n if (!refreshToken) {\n throw new Error(\"Unable to refresh. No refresh_token found.\");\n }\n\n const tokenUri = this.state.tokenUri;\n if (!tokenUri) {\n throw new Error(\"Unable to refresh. No tokenUri found.\");\n }\n\n const scopes = getPath(this, \"state.tokenResponse.scope\") || \"\";\n if (scopes.indexOf(\"offline_access\") == -1 && scopes.indexOf(\"online_access\") == -1) {\n throw new Error(\"Unable to refresh. No offline_access or online_access scope found.\");\n }\n\n // This method is typically called internally from `request` if certain\n // request fails with 401. However, clients will often run multiple\n // requests in parallel which may result in multiple refresh calls.\n // To avoid that, we keep a to the current refresh task (if any).\n if (!this._refreshTask) {\n this._refreshTask = request(tokenUri, {\n mode : \"cors\",\n method : \"POST\",\n headers: {\n \"content-type\": \"application/x-www-form-urlencoded\"\n },\n body: `grant_type=refresh_token&refresh_token=${encodeURIComponent(refreshToken)}`,\n credentials: \"include\"\n }).then(data => {\n if (!data.access_token) {\n throw new Error(\"No access token received\");\n }\n return data;\n }).then(data => {\n debug(\"Received new access token %O\", data);\n Object.assign(this.state.tokenResponse, data);\n return this.state;\n }).catch(error => {\n debug(\"Deleting the expired or invalid refresh token.\");\n delete this.state.tokenResponse.refresh_token;\n throw error;\n }).finally(() => {\n this._refreshTask = null;\n this.environment.getStorage().set(this.state.key, this.state);\n });\n }\n\n return this._refreshTask;\n }", "title": "" }, { "docid": "ee657f13ca9c01d1ffb3a9205fcba289", "score": "0.56763005", "text": "getValidToken(){\n let that = this;\n return new Promise(function(resolve, reject){\n\n // when the token is expired, we have to get a new one\n if(that.tokenExpired()){\n if(that.refreshToken == \"\"){\n reject(\"Kein Refresh-Token vorhanden!\");\n }\n\n var settings = {\n \"crossDomain\": true,\n \"url\": that.uri.token,\n \"method\": \"POST\",\n \"headers\": {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"Accept\": \"*/*\",\n },\n \"data\": {\n \"grant_type\": \"refresh_token\",\n \"refresh_token\": that.refreshToken\n }\n }\n\n $.ajax(settings)\n .done(res => {\n console.log(\"refresh-token successful\");\n that.token = res.access_token;\n that.refreshToken = res.refresh_token;\n that.tokenEOL = Date.now() + (1000 * res.expires_in);\n that.patient = res.patient;\n // check if logged in patient is the same as last logged in\n if(localStorage.getItem(\"patientId\") != res.patient){\n // if we have another patient, there went something wrong and we log out\n console.log(\"Fehler: PatientenId stimmt nicht überein. Logout.\")\n that.logout();\n }\n if(that.keepToken){\n localStorage.setItem(\"oauth-token\", res.access_token);\n localStorage.setItem(\"oauth-refreshtoken\", res.refresh_token);\n localStorage.setItem(\"oauth-tokeneol\", that.tokenEOL);\n }\n resolve(that.token);\n })\n .catch(err => {\n console.log(err)\n reject(\"Fehler beim Beziehen eines neuen Tokens (siehe Konsole)\")\n });\n }\n\n // if the token is still valid, we can just return it\n else {\n resolve(that.token);\n }\n });\n }", "title": "" }, { "docid": "351d047f542f580ab287a118014c209e", "score": "0.5670814", "text": "function refreshToken(req, res, callback){\n try{\n var token = req.body.decoded_token;\n var roles = req.body.roles;\n var credentials = jwt.jwtEncode(token.uid, token.sub, roles, token.orgid, token.cid);\n callback(false, credentials, {uid: token.uid, cid: token.orgid});\n } catch(err) {\n callback(true, err);\n }\n}", "title": "" }, { "docid": "c503b486bb166040fa6702dd0cf92552", "score": "0.56659174", "text": "function accessToken(){\n\n documentProps();\n var app_id = document.getProperty(\"app_id\");\n var app_key = document.getProperty(\"app_key\");\n var nonce = getDate.toISOString();\n var s512Txt = nonce+''+app_key;\n var secret = CryptoJS.SHA512(s512Txt).toString(CryptoJS.enc.Hex);\n\n var data = {\n \"app_id\": app_id,\n \"secret\": secret,\n \"grant_type\": \"client_credentials\",\n \"nonce\": nonce\n }\n var options = {\n \"method\": \"post\",\n \"headers\": {\n \"Content-type\": \"application/json\",\n \"X-GP-Version\": \"2020-12-22\",\n },\n \"payload\" : JSON.stringify(data) \n }\n\n try{\n\n var response = UrlFetchApp.fetch(\"https://apis.sandbox.globalpay.com/ucp/accesstoken\", options);\n\n if(response.getResponseCode()==\"200\"){\n var json = response.getContentText();\n var returnedData = JSON.parse(json);\n \n returnedAccessToken = returnedData.token;\n \n }else{\n Logger.log(response.getResponseCode());\n }\n\n }catch(err){\n Logger.log(err);\n }\n }", "title": "" }, { "docid": "270f298dc57306420d6c05c6c7ac1472", "score": "0.56501627", "text": "async refresh ({ commit, state }) {\n const { refresh_token } = state.refresh_token\n console.log('refresh token store auth', state.refresh_token)\n // make an API call using the refresh token to generate a new access token\n const { data: { payload } } = await this.$axios.post(\n '/api/v1/refresh', \n { refresh_token }\n )\n commit(AUTH_MUTATIONS.SET_PAYLOAD, payload)\n }", "title": "" }, { "docid": "8dff4de463182ddc078393895faba21e", "score": "0.5645072", "text": "refreshAccessToken(refreshToken) {\n const error = ParamsChecker.validateNonEmpty(refreshToken, 'refreshToken');\n if (error) {\n return Promise.reject(error);\n }\n const body = {\n token : refreshToken\n };\n return HttpHelper.auth('/auth/token', body);\n }", "title": "" }, { "docid": "e8d579680b608e3db5138564e44f0c18", "score": "0.56431466", "text": "getTokens() {\n var result = {};\n\n // We've saved off the access & refresh token to tableau.password\n if (tableau.password) {\n console.log(\"Grabbing authentication from tableau.password\");\n result = JSON.parse(tableau.password);\n } else {\n console.log(\"Grabbing authentication from query hash\");\n result = this._getHashParams();\n }\n\n return result;\n }", "title": "" }, { "docid": "2452629d218adc8ebb43f4d2ebda384a", "score": "0.56370944", "text": "function gettokens(code){\n var parameters = {\n client_id : config.client_id ,\n client_secret : config.client_secret ,\n code : code ,\n grant_type : \"authorization_code\" ,\n redirect_uri : config.host\n }\n const base_url = \"https://oauth2.googleapis.com/token\"\n var query_parameters = querystring.stringify(parameters)\n const token_url = `${base_url}?${query_parameters}`\n return axios.post(token_url)\n \n\n \n\n}", "title": "" }, { "docid": "13145110c7d813623599a2336e28cefb", "score": "0.56340224", "text": "validateRefreshToken(endOnInvalid = true, req) {\n if (this.isCLI()) {\n return true;\n }\n // get the refresh token from cookie\n let refreshToken = req.cookies['haxcms_refresh_token'];\n // if there isn't one then we have to bail hard\n if (!refreshToken) {\n res.send(401);\n }\n // if there is a refresh token then decode it\n let refreshTokenDecoded = this.decodeRefreshToken(refreshToken);\n let n = Math.floor(Date.now() / 1000);\n // validate the token\n // make sure token has issued and expiration dates\n if ((refreshTokenDecoded.iat) && (refreshTokenDecoded.exp)) {\n // issued at date is less than or equal to now\n if (refreshTokenDecoded.iat <= n) {\n // expiration date is greater than now\n if (n < refreshTokenDecoded.exp) {\n // it's valid\n return refreshTokenDecoded;\n }\n }\n }\n // kick back the end if its invalid\n if (endOnInvalid) {\n res.cookie('haxcms_refresh_token', '', { \n expires:1, \n });\n res.send(401);\n }\n return false;\n }", "title": "" }, { "docid": "826fb07b5a0ed178e857de12145dd38d", "score": "0.5616349", "text": "refreshTokens() {\n // Check if the tokens are not being refreshed already\n if (!this.refresh_promise) {\n this.refresh_promise = new Promise((resolve, reject) => {\n // Create a request that will fetch new tokens\n request\n .post(config.api.host + '/api/v6-rc1/authenticate/token')\n // Use base64'd client ID and secret for authorization\n .set('Authorization', 'Basic ' + this.oauth.token)\n // Send refresh token in form data\n // TODO: check if it's `x-www-form-urlencoded`\n .type('form')\n .send({\n refresh_token: this.tokens.refresh_token,\n grant_type: 'refresh_token',\n })\n .end((error, response) => {\n // Refresh is finished, another can start\n this.refresh_promise = null;\n\n // If there is no response, we assume that the network is down\n if (!response) {\n reject({ message: 'network_error' });\n\n // If everything is fine, we save the tokens to local storage\n } else if (response.ok) {\n const result = this.tokens.set(response.body).save();\n resolve(result);\n // If the refresh token is invalid, we clear tokens, remove them\n // from local storage and return an error\n } else if (response.clientError) {\n // tokens.destroy() will return a resolved promise, so we need to\n // reject it with the refresh denied error\n const result = this.tokens\n .clear()\n .destroy()\n .then(() => {\n return Promise.reject({ message: 'refresh_denied' });\n });\n\n // if the result promise is rejected,\n // this promise will be rejected too\n resolve(result);\n\n // If something weird happens, return an error\n } else {\n reject({ message: 'unknown_error' });\n }\n });\n });\n }\n\n // Return a new or existing refresh promise\n return this.refresh_promise;\n }", "title": "" }, { "docid": "75a06258675e0c91173f5a72072839ce", "score": "0.55933183", "text": "async requestToken() {\n const iat = Math.floor(new Date().getTime() / 1000);\n const additionalClaims = this.additionalClaims || {};\n const payload = Object.assign({\n iss: this.iss,\n scope: this.scope,\n aud: GOOGLE_TOKEN_URL,\n exp: iat + 3600,\n iat,\n sub: this.sub,\n }, additionalClaims);\n const signedJWT = jws.sign({\n header: { alg: 'RS256' },\n payload,\n secret: this.key,\n });\n try {\n const r = await gaxios_1.request({\n method: 'POST',\n url: GOOGLE_TOKEN_URL,\n data: {\n grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n assertion: signedJWT,\n },\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n responseType: 'json',\n });\n this.rawToken = r.data;\n this.expiresAt =\n r.data.expires_in === null || r.data.expires_in === undefined\n ? undefined\n : (iat + r.data.expires_in) * 1000;\n return this.rawToken;\n }\n catch (e) {\n this.rawToken = undefined;\n this.tokenExpires = undefined;\n const body = e.response && e.response.data ? e.response.data : {};\n if (body.error) {\n const desc = body.error_description\n ? `: ${body.error_description}`\n : '';\n e.message = `${body.error}${desc}`;\n }\n throw e;\n }\n }", "title": "" }, { "docid": "3c35886c9a13920832fc58539676eb74", "score": "0.5592518", "text": "_https_auth_code (auth, code, callback) {\n console.log('_https_auth_code');\n\n //let auth = Homey.ManagerSettings.get('ringCredentials');\n\n if (auth === null || auth === undefined) {\n return callback(new Error('invalid_credentials'));\n }\n\n let postdata = this._https_auth_postdata_auth(auth);\n\n var timeout = setTimeout(() => {\n request.abort();\n }, refreshTimeout);\n\n const url = parse('https://oauth.ring.com/oauth/token');\n url.method = 'POST';\n url.headers = {\n 'hardware_id': this._uniqueid,\n 'content-type': 'application/json',\n '2fa-support': 'true',\n '2fa-code': code || '',\n 'content-length': postdata.length\n };\n\n let request = https.request(url, (response) => {\n let data = '';\n\n response.on('data', (chunk) => {\n data += chunk;\n });\n\n response.on('end', () => {\n let error = null;\n let result = {};\n\n if (response.statusCode >= 400) {\n this._authenticated = false;\n console.log('_https_auth_code : invalid_authentication : ', response.statusCode);\n error = new Error('invalid_authentication ' + response.statusCode + ' ' + data);\n } else {\n try {\n result = JSON.parse(data);\n console.log('_https_auth_code: retrieved the refresh and access token')\n Homey.ManagerSettings.set('ringRefreshToken', result.refresh_token);\n //console.log('_https_auth_code: refresh token ['+result.refresh_token+']')\n this._bearer = result.access_token;\n Homey.ManagerSettings.set('ringBearer', result.access_token);\n //console.log('_https_auth_code: bearer token ['+result.access_token+']')\n this._authenticated = true;\n } catch (e) {\n error = e;\n }\n }\n\n clearTimeout(timeout);\n callback(error, result);\n });\n\n response.on('error', (error) => {\n clearTimeout(timeout);\n callback(error);\n });\n });\n\n request.on('error', (error) => {\n clearTimeout(timeout);\n callback(error);\n });\n\n request.write(postdata);\n\n request.end();\n }", "title": "" }, { "docid": "c0001d16c39c888255d21f99fb2536a1", "score": "0.55845976", "text": "function refreshToken(refreshTokenString) {\n\t\t\t\treturn Resource.$post(Resource.$url() + '?grant_type=refresh_token&refresh_token=' + refreshTokenString);\n\t\t\t}", "title": "" }, { "docid": "436c5f6afeaf3264811c5d2747c41556", "score": "0.55810386", "text": "async function applyForToken() {\n const _result = await $.ajax({\n url: API_URL,\n type: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n success: (resp) => {\n console.log(`Successfully received a new token, id = ${resp.token}`);\n window.location.reload();\n },\n error: (e) => {\n console.log(`Couldn't apply for a new token: ${JSON.stringify(e)}`);\n showError(\n \"Submission Error\",\n `Couldn't apply for a new token: ${e.responseJSON?.error || 'No response from the server.'}`\n );\n }\n });\n}", "title": "" }, { "docid": "2a8a1661c4a66beb6c97397c724361d4", "score": "0.5565758", "text": "async refreshToken() {\n const refreshTokenCount = parseInt(await AsyncStorage.getItem('refreshTokenCount'))\n if (refreshTokenCount <= 45) {\n const refreshToken = JSON.parse(await SecureStore.getItemAsync('refreshToken'))\n const response = await fetch(`https://www.googleapis.com/oauth2/v4/token?refresh_token=${\n refreshToken\n }&client_id=${\n '28190026547-uf0bj4g21abepth6tbfhf8ag7rohb9cf.apps.googleusercontent.com'\n }&grant_type=refresh_token`, {\n method: 'POST',\n }\n )\n let body = await response.json()\n await AsyncStorage.setItem('refreshTokenCount', (refreshTokenCount + 1).toString())\n console.log('refresh token count is ' + refreshTokenCount)\n console.log('token refreshed')\n SecureStore.setItemAsync('accessToken', JSON.stringify(body.access_token))\n .then(\n this.shouldTokenRefresh()\n )\n }\n else {\n AsyncStorage.setItem('signedIn', 'false')\n console.log('send to login screen')\n this.props.navigation.replace('LoginScreenRouter')\n }\n }", "title": "" }, { "docid": "d38b448f5892dd6968370adca283e508", "score": "0.556166", "text": "function get_token(code){\n params = {\n 'code': code,\n 'client_id':'32029',\n 'client_secret':'0565c2ccd75607aad3a021fd6d90b33a31a823f8',\n 'grant_type': \"authorization_code\"\n }\n\n // set cookie of the two tokens and reload page\n set_token_cookie = function(json){\n json = JSON.parse(json)\n set_cookie(\"access_token\", json[\"access_token\"], json[\"expires_at\"])\n set_cookie(\"refresh_token\", json[\"refresh_token\"], json[\"expires_at\"]*2)\n location.reload()\n }\n // Post + Callback\n res = post_api('token', params, set_token_cookie, 'https://www.strava.com/oauth/')\n}", "title": "" } ]
65498e9b350952cc5914c533e89091b1
Update a key value pair
[ { "docid": "6700605b820c7746abbe00c540f49eea", "score": "0.0", "text": "function updateAt(k, a) {\n return r => updateAt_(r, k, a);\n}", "title": "" } ]
[ { "docid": "b59f3035efdbd3c05e739818f50a312b", "score": "0.77363014", "text": "function updateValue(key) {\n\n\t}", "title": "" }, { "docid": "1644bb2c27e345edb3d7fe2575f4e00a", "score": "0.7505172", "text": "function updateObject(object, key, value) {\n \n}", "title": "" }, { "docid": "c61efaeedb3d47921c303cf2c7bae06f", "score": "0.7213688", "text": "@action update(key, value) {\n this[key] = value;\n console.log('after', key, value);\n }", "title": "" }, { "docid": "cfffa39890208bdb9f2d428f912b3efa", "score": "0.7114058", "text": "update(post_id, key, value) {\n const post = this.get(post_id);\n post[key] = value;\n }", "title": "" }, { "docid": "a9f96146819925869613a35894302cce", "score": "0.7061956", "text": "function performValueUpdate(obj, update, key) {\n\t\tobj[key] = update\n\t}", "title": "" }, { "docid": "bfbd50bf018830b37e146c8c4bee2737", "score": "0.69795054", "text": "function updateProfile(key, value){\n\n}", "title": "" }, { "docid": "066a96386a42d6d0703afbebdceac141", "score": "0.6810409", "text": "function updateObject(object, key, value) {\n//console.log(object, key, value);\n//update the property key in object with new value\n//if key does not exist create it\nobject[key] = value;\nreturn object;\n}", "title": "" }, { "docid": "fc4508ebbd952bab7e54300c7e5bc16c", "score": "0.67877877", "text": "function updateVal( id, key, val ) {\n var data = {};\n data[ key ] = val;\n return qwest.put( \"/api/patient/\" + id, data )\n .then( function() {\n console.log( \"updated: \" + key + \" to value: \" + val + \" for patient: \" + id );\n })\n .catch( function(e) {\n console.log( \"oops: \" + e );\n });\n}", "title": "" }, { "docid": "9ca4d4f0bc981f49b15bd1a893ac325a", "score": "0.67185396", "text": "function performKeyUpdate(obj, update, key) {\n\t\tobj[update] = obj[key]\n\t\tdelete obj[key]\n\n\t}", "title": "" }, { "docid": "9a596a500a0638eaa5be01fa7e7c6bd3", "score": "0.66670746", "text": "async function update(index, transaction, key, value) {\n\t\t\t\t\treturn await put(transaction, key, value);\n\t\t\t\t}", "title": "" }, { "docid": "d4339c779d0a08b668bde58e024cfae5", "score": "0.6641393", "text": "function updateObject(object, key, value) {\n \n // I: an object, a Key, and a value\n // O: update key property of object with a value\n \n // re-asign value of parameter key of parameter object to parameter value\n \n object[key] = value;\n \n // return the updated object with the value\n \n return object;\n}", "title": "" }, { "docid": "2604b27a2b03d49bf208975d843f895c", "score": "0.6598803", "text": "function updateState (key, value) {\n state[key] = value;\n console.log(state);\n}", "title": "" }, { "docid": "636c3e80855f83d5dd47a01299aa3a20", "score": "0.6553966", "text": "function updateObject(object, key, value){\n object[key] = value;\n return object;\n \n}", "title": "" }, { "docid": "c833a32d8734f5d733f1814419bb44e8", "score": "0.6553797", "text": "function updateProperty(obj, key, value) {\n obj[key] = value;\n console.log(`value update new value ${obj[key]}`, obj);\n}", "title": "" }, { "docid": "88aa626140ebb8688b00456c6f02da1a", "score": "0.6525145", "text": "function updateObject(object, key, value) {\nobject[key] = value;\nreturn object;\n}", "title": "" }, { "docid": "816eed4d6c8cbb0c1f5a31461a0fb657", "score": "0.6505545", "text": "function updateObject(object, key, value) {\n//function w/ object, key and value params\n object[key] = value;\n //update prperty key on object w/ a new value\n return object;\n //return updated object\n\n}", "title": "" }, { "docid": "e6df120447fabd712d32749cdc70d003", "score": "0.6396627", "text": "update_by_push(key, value) {\n this.assert_valid_data_key(key);\n let array = this.data_dict[key];\n bs.assert_type(array, bs.TYPE_ARRAY);\n array.push(value);\n this.data_dict[key] = array;\n }", "title": "" }, { "docid": "06787ed311d2aab5e9683092ea9cd80b", "score": "0.63655245", "text": "function updateObject(object, key, value) {\n // Update the key property on object with value\n object[key] = value;\n return object;\n}", "title": "" }, { "docid": "b4552ef49be39ddb129b55cb86000623", "score": "0.63206565", "text": "function updateObject(object, key, value) {\n /** Aren't you performing the same action in the if statement as outside the if statement? I don't think you need an if here*/\n object[key] = value;\n return object;\n}", "title": "" }, { "docid": "9adad640cb2fea047360f150265974e5", "score": "0.6317588", "text": "function _update(bytes32 version, bytes32 key, address value, address addressNull) public\n {\n require(AddressBytes32[msg.sender][version][key] != addressNull);\n AddressBytes32[msg.sender][version][key] = value;\n }", "title": "" }, { "docid": "086da0358790c67c60aa7b918b411fe6", "score": "0.63026327", "text": "set(key,value) {\n let index = this._hash(key);\n \n //Check if there is any element at the selected index\n if(!this.keyMap[index]) {\n this.keyMap[index] = [];\n this.keyMap[index].push([key, value]);\n } else {\n for(let i = 0; i < this.keyMap[index].length; i++) {\n if(this.keyMap[index][i][0] !== key) {\n this.keyMap[index].push([key, value]);\n break;\n } else {\n this.keyMap[index][i][1] = value;\n }\n }\n }\n }", "title": "" }, { "docid": "0e1c8125f83c32bd28c51f1e7fc3f087", "score": "0.6283853", "text": "function updateObject(object, key, value) {\n//create if statements\n //check if the porperty of key is object\n //then reassign key on object to value\n //\nif(object.hasOwnProperty(key)) {\n object[key] = value;\n } else {\n object[key] = value;\n }\n return object;\n}", "title": "" }, { "docid": "71678948b972c571912d9eecafa001ea", "score": "0.627412", "text": "function updateFormState(key, value) {\n formState[key] = value;\n}", "title": "" }, { "docid": "a43586fe5dde2b485416dfdbe8fb1268", "score": "0.6270217", "text": "function updateAndSaveKey(self, deferred, key, info) {\n\t\"use strict\";\n\n\t// Check if key exists.\n\tif (self.keys.hasOwnProperty(key)) {\n\t\t// Set the key info.\n\t\tself.keys[key] = info;\n\n\t\t// Save the keys to disk.\n\t\tself.save().then(function (status) {\n\t\t\t\tdeferred.resolve(200);\n\t\t\t},\n\t\t\tfunction (error) {\n\t\t\t\tdeferred.reject(error);\n\t\t\t});\n\t}\n\telse {\n\t\tdeferred.reject(new Error('API key do not exists.'));\n\t}\n}", "title": "" }, { "docid": "d18f40a0b8e91e8dee857b7f3378bbba", "score": "0.6235287", "text": "function changeKey(id, value)\n{\n\t\n\tkey[id] = value;\n}", "title": "" }, { "docid": "b663813bbaeb343703ba45ca2aac3f4f", "score": "0.61924326", "text": "set(key, value) {\n\t\t_lib.merge(_lib.expandKeyValue(key, value), this.model);\n\t}", "title": "" }, { "docid": "933504aa0987df2330612b05b33d5354", "score": "0.6182075", "text": "set(key, val){\n return self._db.then((db)=>{\n const tx = db.transaction(\"keyval\", \"readwrite\");\n tx.objectStore(\"keyval\").put(val, key);\n return tx.complete;\n })\n }", "title": "" }, { "docid": "6b04edc36abfa8bdb16fad063b79c284", "score": "0.61788505", "text": "function _Update(bytes32 version, uint256 key, address value, address addressNull) public\n {\n require(AddressUint256[msg.sender][version][key] != addressNull);\n AddressUint256[msg.sender][version][key] = value;\n }", "title": "" }, { "docid": "ede4e66f91332f7da7b3f4bb8877c643", "score": "0.61679375", "text": "setValue(key1, key2, value) {\n if (!(key1 in this.mapping)) {\n this.mapping[key1] = {};\n }\n this.mapping[key1][key2] = value;\n }", "title": "" }, { "docid": "a16de155275bb78bfc10a14819629499", "score": "0.61577725", "text": "set(key, value){\n let index = this._hash(key)\n if(!this.keyMap[index]){\n this.keyMap[index] = [] \n }\n this.keyMap[index].push([key, value]) \n }", "title": "" }, { "docid": "341c1be2c9bde176742b0ced8de92b3e", "score": "0.61562085", "text": "updateInput(key, value) {\n this.setState({\n [key]: value\n });\n }", "title": "" }, { "docid": "8f2170320af1164944b1b3e1b700ca4b", "score": "0.61512953", "text": "function _update(address addressIndex, bytes32 version, bytes32 key, address value, address addressNull) public\n {\n require(AddressBytes32[msg.sender][addressIndex][version][key] != addressNull);\n AddressBytes32[msg.sender][addressIndex][version][key] = value;\n }", "title": "" }, { "docid": "1ec14c8ce3751b9382a4f43f5efcb944", "score": "0.61325085", "text": "put(k,v)\n { \n let obj;\n let tmp = new KeyValueHash(k,v);\n let idx = this.dict.getIndex(tmp);\n if(this.dict.contains(tmp))\n {\n obj = this.dict[idx].search(tmp);\n obj.value = v;\n }\n else\n {\n this.dict.add(tmp);\n }\n }", "title": "" }, { "docid": "735afc60291b2320cbe2fa526884dd17", "score": "0.6130075", "text": "function setKey(key, value) {\n var db = _getDB();\n db.transaction(function(tx) {\n var rs = tx.executeSql('INSERT OR REPLACE INTO user VALUES (?,?);', [key,\"\"+value]);\n if (rs.rowsAffected == 0) {\n throw \"Error updating key\";\n } else {\n\n }\n });\n}", "title": "" }, { "docid": "a30c3bec0962ccbb0ffb98ec552f41f5", "score": "0.6123507", "text": "onUpdateUserDetails(key, value, e) {\n this.setState({\n editUser: {\n ...this.state.editUser,\n [key]: value\n }\n });\n }", "title": "" }, { "docid": "04e8edb8ae3ff0d7432f2851db75f57b", "score": "0.61181056", "text": "function updateDriverWithKeyAndValue(driver, key, value){\n let updatedDriver = {...driver};\n\n updatedDriver[key] = value;\n\n return updatedDriver;\n}", "title": "" }, { "docid": "9cb091e5fad5e49d1a26e3873895affc", "score": "0.61157614", "text": "function updateObject(object, key, value) {\n \n// Should take an object, a key and a value. Should update the property <key> on <object> with new <value>. If <key> does not exist on <object> create it.\n\nobject[key] = value;\n// if(object.hasOwnProperty(key)){\n// object[key] = value; \n// } else {\n// object[key] = value; \n// }\n// meh.\nreturn object; \n}", "title": "" }, { "docid": "7079e3d68cce112eb42435de0960940d", "score": "0.61114556", "text": "function updateObjectWithKeyAndValue(object, key, value) {\n\t// body...\n var newObject = Object.assign({}, object, { [key]: value });\n return newObject;\n}", "title": "" }, { "docid": "a89fbadfa228c6a5d0db308116ea96c3", "score": "0.6102108", "text": "update(){}", "title": "" }, { "docid": "a89fbadfa228c6a5d0db308116ea96c3", "score": "0.6102108", "text": "update(){}", "title": "" }, { "docid": "a8b1e506ed635901cd22d78cf0c00f9c", "score": "0.60864574", "text": "set(key,value){\n // hash the key & save to variable\n let index = this._hash(key);\n //insert key and value at 'index'\n // if there is not any keys at index spot\n if(!this.keyMap[index]){\n // if not set to empty array\n this.keyMap[index] = [];\n }\n // push [key, value] into said index\n this.keyMap[index].push([key, value]);\n }", "title": "" }, { "docid": "6ef2fc5d999e7951c0d12db2c9b8cbc6", "score": "0.6057699", "text": "updateWith(kv) {\n utils.objectApply(this, kv);\n this.updateDom();\n }", "title": "" }, { "docid": "f776927945b0ee360db52b7c92167c3d", "score": "0.6049974", "text": "function incrementValue(key, id){\n\tif(typeof valueMap.get(key) == 'undefined'){\n\t\tvalueMap.set(key, id);\n\t} else {\n\t\tlet tmp = valueMap.get(key);\n\t\tlet newTmp = tmp + \" + \" + id;\n\t\tvalueMap.set(key, newTmp);\n\t}\n}", "title": "" }, { "docid": "1d440e6b18cea5d46b255c2ec81c8da3", "score": "0.6049271", "text": "function updateObjectWithKeyAndValue(object, key, value) {\n return Object.assign({}, object, { [key]: value })\n}", "title": "" }, { "docid": "b105db54700995c7d3671e9e22f20369", "score": "0.60388166", "text": "function updateParam(key, value) {\n\tvar kvp = location.search.substr(1).split('&');\n\tvar path = location.pathname;\n\tkey = encodeURI(key);\n\tif (value) {\n\t\tvalue = encodeURI(value);\n\t\tif (kvp[0] === \"\") {\n\t\t\tkvp = [];\n\t\t}\n\t\tvar i = kvp.length;\n\t\tvar x;\n\t\twhile(i--) {\n\t\t\tx = kvp[i].split('=');\n\t\t\tif (x[0] === key) {\n\t\t\t\tif (!value) {}\n\t\t\t\tx[1] = value;\n\t\t\t\tkvp[i] = x.join('=');\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (i < 0) {\n\t\t\tkvp[kvp.length] = [key,value].join('=');\n\t\t}\n\t\tpath += '?' + kvp[0];\n\t\tif (kvp.length > 1) {\n\t\t\tpath += kvp.join('&');\n\t\t}\n\t} else {\n\t\tfor (var i = 0; i < kvp.length; i++) {\n\t\t\tif (kvp[i].indexOf(key) === -1) {\n\t\t\t\tpath += kvp[i];\n\t\t\t}\n\t\t}\n\t}\n\tpath += location.hash;\n\t// change url without reload the page\n\thistory.pushState(null, null, path);\n}", "title": "" }, { "docid": "1e605f9e7f6f9bb4fcb3fec1c36a6e02", "score": "0.6034536", "text": "function setValue(object, key, value) {\n object[key] = value;\n}", "title": "" }, { "docid": "1e605f9e7f6f9bb4fcb3fec1c36a6e02", "score": "0.6034536", "text": "function setValue(object, key, value) {\n object[key] = value;\n}", "title": "" }, { "docid": "4f75c1c5793019c5571dbb749b53dc43", "score": "0.59983444", "text": "function _Update(address addressIndex, bytes32 version, uint256 key, address value, address addressNull) public\n {\n require(AddressUint256[msg.sender][addressIndex][version][key] != addressNull);\n AddressUint256[msg.sender][addressIndex][version][key] = value;\n }", "title": "" }, { "docid": "8663e0c734829ec2ce58b916bf4615d6", "score": "0.5994029", "text": "put(key, value) {\n const hashedIndex = this.hash(key);\n const pos = hashedIndex;\n const node = this.values[hashedIndex];\n\n if (!node) {\n this.values[pos] = [key, value];\n return;\n }\n\n let index = 0;\n let foundKey = node && node[index];\n while (undefined !== foundKey && foundKey !== key) {\n index += 2;\n foundKey = node[index];\n }\n\n node[index] = key;\n node[index + 1] = value;\n }", "title": "" }, { "docid": "c4cfa5fd88f3fc4f6f7091a406d8654b", "score": "0.59853137", "text": "function destructivelyUpdateObjectWithKeyAndValue(object,key,value){\n object[key] = value;\n return object;\n}", "title": "" }, { "docid": "5c856d9f07dce0a0891ea9bdb4c8a2b9", "score": "0.59818316", "text": "function destructivelyUpdateObjectWithKeyAndValue(object, key, value) {\n object[key] = value;\n \n return object;\n}", "title": "" }, { "docid": "a5b96f6305cbc0e6ea01fbda51fd7b28", "score": "0.5977347", "text": "function update(obj, key, val) {\n let newObj = [...obj]\n newObj[key] = val\n return newObj\n}", "title": "" }, { "docid": "ecc7f38373702a3fc0168194ca97a1e8", "score": "0.5977044", "text": "function update(obj, key, val) {\n let newObj = {...obj};\n newObj[key] = val;\n return newObj;\n }", "title": "" }, { "docid": "3897e63052f00d1abad5c573391f8e22", "score": "0.59767914", "text": "function destructivelyUpdateObjectWithKeyAndValue(object, key, value){\n \n object[key] = value;\n \n return object;\n\n}", "title": "" }, { "docid": "f9ee052c594163ebd4bcc92486ae3e53", "score": "0.59697723", "text": "set(key, value) {\n this.map.set(key, this.get(key).add(value))\n }", "title": "" }, { "docid": "3c8f27131655ab997e5905fd79e43258", "score": "0.5969343", "text": "set(key,value){\n const keyHash = this.hash(key);\n const bucketArray = this.buckets[keyHash];\n const storedElement = bucketArray.find((element) => {\n return element.key === key;\n });\n// if the key is found then we are overriding the value of stored element \nif (storedElement) {\n storedElement.val = value;\n } else {\n // we are storing the value as an object which has its own key under the hash index value \n bucketArray.push({ key: key, val: value });\n }\n }", "title": "" }, { "docid": "5182b0fd5453ec8afe5da6606cb0ee03", "score": "0.59679484", "text": "set(key, value) {\n const hashCode = HashTable.hash(key);\n this.data[hashCode] = {\n key,\n value\n }\n }", "title": "" }, { "docid": "d0568da4a8bf20afc8ae738043c8c203", "score": "0.5967084", "text": "set(key, value){\n let index = this._hash(key);\n if(!this.keyMap[index]){\n this.keyMap[index] = [];\n }\n this.keyMap[index].push([key, value]);\n }", "title": "" }, { "docid": "b2501875200b931c5dce7a530a08025e", "score": "0.5956857", "text": "function updateItem(itemId, key, value){\n if(itemId){\n const updatedItems = traverseAndReplace(items, itemId, key, value);\n setItems(updatedItems);\n }else{\n setItems(value);\n }\n }", "title": "" }, { "docid": "e99f5b9c337ff54d0c38afd393af1d13", "score": "0.5945402", "text": "function updateStorage(key, value) {\n\n var saveObj = {};\n saveObj[key] = value;\n\n if (settingsSet !== true) {\n settingsSet = true;\n saveObj[\"settingsSet\"] = settingsSet;\n }\n\n chrome.storage.sync.set(saveObj, function() {});\n }", "title": "" }, { "docid": "7b8675b9c683bb566c472f6714262247", "score": "0.5933262", "text": "set(key, value) {\n\n }", "title": "" }, { "docid": "db1ad0b6ea962082fbd0ce2131f0e586", "score": "0.59293354", "text": "setValue(key,value) {\n if ( key in this.fieldValues ) {\n //\n this.rawValues[key] = value\n var vs = '' + value\n var vprint = this.fieldFormat.replace('%s',vs)\n if ( this.printKey ) {\n vprint = vprint.replace('%k',key)\n }\n this.fieldValues[key] = vprint;\n }\n }", "title": "" }, { "docid": "e5bc2337a64bad5730bd0d57aaa677e3", "score": "0.5924656", "text": "function put(key, data) {\n var pos = this.betterHash(key);\n if (this.table[pos] === undefined) {\n this.table[pos] = key;\n this.values[pos] = data;\n }\n else {\n while (this.table[pos] !== undefined) {\n pos ++;\n }\n this.table[pos] = key;\n this.values[pos] = data;\n }\n }", "title": "" }, { "docid": "da13cd22e772c1aaf41c7c297905eb5f", "score": "0.59207404", "text": "_update_value (n, v) {\n\t\tlet state = {};\n\t\tstate[n] = v;\n\t\tthis.setState({\n\t\t\t...this.state,\n\t\t\t...state\n\t\t})\n\t\tthis.props.onChange(n, v);\n\t}", "title": "" }, { "docid": "7fb662f227847d7b46883880d0d6dbd9", "score": "0.5905816", "text": "async update({ params, request, response }) {\n\t}", "title": "" }, { "docid": "b5392f4c8e5914fcd140165d2dc99649", "score": "0.589967", "text": "handleKeyUpdate(e) {\n e.preventDefault();\n\n this.setState({ submittedKey: true });\n const { apiKey} = this.state;\n // if the curren is correct:\n fetch('/settings', {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n\n vt_api_key: apiKey\n\n })\n })\n }", "title": "" }, { "docid": "6faf5ede566afbaf820bf2f63f19a599", "score": "0.5865651", "text": "function destructivelyUpdateObjectWithKeyAndValue(object, key, value) {\n // body...\n object[key] = value;\n return object;\n}", "title": "" }, { "docid": "bd55d75aae072a002574152292f07316", "score": "0.58570933", "text": "function playerUpdate(playerNumber, itemToUpdate, valueToUpdate) {\n var playerID;\n\n if (playerNumber == \"One\") {\n playerID = \"playerOne\";\n }\n if (playerNumber == \"Two\") {\n playerID = \"playerTwo\";\n }\n rpsMultiPlayerRef.child(playerID).once(\"value\", function(snap) {\n var object = snap.val();\n object[itemToUpdate] = valueToUpdate;\n\n rpsMultiPlayerRef.child(playerID).set(object);\n });\n}", "title": "" }, { "docid": "61c388c450472e47660e3e5f9a592ba1", "score": "0.58570004", "text": "static put(key, value) {\n return IndexedDBStore.dbPromise\n .then((db) => {\n const transaction = db.transaction(IndexedDBStore.objectStoreName, 'readwrite');\n const restaurantDataStore = transaction.objectStore(IndexedDBStore.objectStoreName);\n restaurantDataStore.put(value, key);\n return transaction.complete;\n });\n }", "title": "" }, { "docid": "ac958b5ccbf1f37aed3e7b6398d04b37", "score": "0.58330697", "text": "set(key, value) {\n const address = this._hash(key)\n if (!this.data[address]) {\n this.data[address] = []\n }\n this.data[address].push([key, value])\n }", "title": "" }, { "docid": "4f1e6c2ad0dda9cbb778f7044f472d56", "score": "0.58304274", "text": "function destructivelyUpdateObjectWithKeyAndValue(object, key, value) {\n object [key] = value;\n return object;\n}", "title": "" }, { "docid": "abbdf9f9a13286ee10c3dd5683a19331", "score": "0.5830149", "text": "function destructivelyUpdateObjectWithKeyAndValue(object, key, value) {\n object[key] = value\n return object\n}", "title": "" }, { "docid": "abbdf9f9a13286ee10c3dd5683a19331", "score": "0.5830149", "text": "function destructivelyUpdateObjectWithKeyAndValue(object, key, value) {\n object[key] = value\n return object\n}", "title": "" }, { "docid": "a61ff13553d3cd4ba152ad91f1ad4169", "score": "0.58265114", "text": "'data_objects.update' (key, new_data, new_type) {\n\n // Check that the key is as it should be.\n check(key, String);\n check(new_type, String);\n check(new_data, Match.Any);\n\n DataObjects.update({\n key: key\n }, {\n $set: {\n data: new_data,\n type: new_type\n }\n });\n }", "title": "" }, { "docid": "ba43138752ace6fa263ccf342835b843", "score": "0.58220637", "text": "function updateData(key, updatedData){\n var meta = {\n name: 'marksheet'\n };\n var filter = {\n index: 'rollnumber',\n data: [key]\n };\n return dataStore.update(meta, filter, updatedData).then(function(){\n $('#console').append('<h3>Updated rollnumber 2\\'s sub3 mark to 90</h3>');\n });\n}", "title": "" }, { "docid": "803a1a17a375a227e64d77d411175302", "score": "0.58216107", "text": "function update() {\n var json = null;\n\n if (program.org == null || program.ds == null || program.res == null) {\n console.log('You must specify an org id, dataset id and resource id.');\n return;\n }\n\n // check we have something to update\n if (program.json == null && program.xjson == null && program.key == null) {\n console.log('You must specify some json data to update.');\n return;\n }\n\n // if passed a key but not the value\n if (program.key != null && program.val == null) {\n console.log('You must specify both a key and a value to perform the update.');\n return;\n }\n\n if ((program.json != null || program.xjson != null) && program.key != null){\n console.log('You can only specify a json fragment to update or a key to update - you cannot specify both. Go to your room!');\n return;\n }\n\n // update a fragment\n if (program.json != null || program.xjson != null) {\n // get the json and continue\n if (program.json != null) {\n completeUpdate(JSON.parse(program.json), program.upload);\n }\n if (program.xjson != null) {\n fs.readFile(program.xjson, 'utf8', function (err, data) {\n if (err) throw err;\n completeUpdate(JSON.parse(data), program.upload);\n });\n }\n }\n\n // update a specific key\n if (program.key != null && program.val != null) {\n\n // get the existing metadata - pass in true at the end to get raw json rather than entities\n publisher.getPublishedResource(program.org, program.ds, program.res, function(err, result){\n\n // the metadata is a subset of the response\n var metadata = result.MetadataResultSet.FileMetadata;\n\n // change the key to the new value\n myutil.setValues(metadata, program.key, program.val);\n\n // send back to the server\n completeUpdate(metadata, null);\n //publisher.updateResource(program.org, program.ds, program.res, metadata, renderTransaction);\n\n }, true);\n }\n}", "title": "" }, { "docid": "698d137e253a01cc7183668637c81648", "score": "0.5807697", "text": "function updateUrlParam(query, key, val) {\n if (val == null) {\n query.delete(key)\n } else if (Array.isArray(val)) {\n for (let v of val) {\n if (v == null) {\n query.delete(key)\n } else {\n query.append(key, v)\n }\n }\n } else {\n query.set(key, val)\n }\n}", "title": "" }, { "docid": "55ecc05f35e4036afb2ecdf18e7e30ac", "score": "0.5801345", "text": "async addKeyValue(dirtyKey, value) {\n const self = this;\n const key = dirtyKey.toString(); // ensure it's a string\n try {\n await self.database.put(key, JSON.stringify(value));\n } catch (error) {\n console.log('addKeyValue -- error', error);\n }\n }", "title": "" }, { "docid": "f4f1e06b785a751da381477fec5ba32d", "score": "0.5798718", "text": "set(k,v){\n const hashedKey = hash(k, 10);\n this._items[hashedKey] = v;\n }", "title": "" }, { "docid": "ab7979c060248e17f6add51e0dad4759", "score": "0.5798607", "text": "function destructivelyUpdateObjectWithKeyAndValue(object, key, value) {\n object[key] = value;\n return object;\n}", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "590423c7e343cc48bcb4fd7e2638734f", "score": "0.579381", "text": "async update ({ params, request, response }) {\n }", "title": "" }, { "docid": "a1df5f60c42889047cd4fa377b3a1f97", "score": "0.5780873", "text": "set(key, value) {\n\t\tlet config = this.state.config;\n\t\tconfig[key] = value;\n\t\tthis.setState({config: config}, () => {\n\t\t\tthis._save();\n\t\t});\n\t}", "title": "" }, { "docid": "17f0202c04aefc9bf6bd111d8d6d2cfe", "score": "0.5780162", "text": "function updateObjectWithKeyAndValue(object, key, value) {\n return Object.assign({}, object, { [key]: value})\n}", "title": "" }, { "docid": "17f0202c04aefc9bf6bd111d8d6d2cfe", "score": "0.5780162", "text": "function updateObjectWithKeyAndValue(object, key, value) {\n return Object.assign({}, object, { [key]: value})\n}", "title": "" }, { "docid": "695fdca137ae7f4449f0339ae289ae32", "score": "0.57789356", "text": "setValue(key, value) {\n this.searchFields[key].value = value;\n }", "title": "" }, { "docid": "67e91884981c9feac8abb315056a0ed1", "score": "0.57758725", "text": "function updateObjectWithKeyAndValue(object, key, value) {\n return Object.assign({}, object, { [key]: value } )\n}", "title": "" }, { "docid": "7f5b68f350843b3fd8e26189124a8b9c", "score": "0.57695276", "text": "set(key, value) {\n // Normalize stream data.\n let item = this._createItem({ value });\n this._map.set(key, item);\n }", "title": "" }, { "docid": "365e767e887a546844b9e72081479d08", "score": "0.5762601", "text": "function update (e) {\n const [id, name] = e.target.name.split('-')\n const key = { id }\n\n key[name] = e.target.type === 'checkbox' ? e.target.checked : e.target.value\n\n AppManager.keys.update(key, true)\n}", "title": "" }, { "docid": "52b735eeb391ea43d42e6ff6f31e40d2", "score": "0.5756389", "text": "function updateObjectWithKeyAndValue(object, key, value) {\n return Object.assign({}, object, {[key]: value})\n}", "title": "" }, { "docid": "b1e5e0c775f03ec8fb6af41c8344e945", "score": "0.5753648", "text": "updateState(key,value){\n this.setState(key: value)\n }", "title": "" }, { "docid": "730b4258aa4934f4a07f8aacae2bebe2", "score": "0.57508105", "text": "function updatePlaylist (object, key, value) {\n object[key] = value;\n return object;\n}", "title": "" }, { "docid": "ab78aa8ee97ee1d8c2707978a2947865", "score": "0.5743399", "text": "function updatePlaylist(object, key, value) {\n\tobject[key] = value;\n\treturn object;\n}", "title": "" }, { "docid": "1a4bfb3371afcfe9a8d42110b4d5a805", "score": "0.5741489", "text": "function updateQueryStringParameter(key, value, url) {\n if(!url) url = window.location.href;\n var re = new RegExp(\"([?&])\" + key + \"=.*?(&|$)\", \"i\");\n var separator = url.indexOf('?') !== -1 ? \"&\" : \"?\";\n if (url.match(re)) {\n return url.replace(re, '$1' + key + \"=\" + value + '$2');\n } else {\n return url + separator + key + \"=\" + value;\n }\n }", "title": "" } ]
7ad986ee75a6ef4b797688f9a6ac3b1f
Gets unique values of an array
[ { "docid": "364a2f87c007fcaa14cfa46e5739434e", "score": "0.0", "text": "function onlyUnique(value, index, self) {\n return self.indexOf(value) === index;\n}", "title": "" } ]
[ { "docid": "6edaec92291893503857347301eb161c", "score": "0.84740466", "text": "array_unique(array) {\n return Array.from(new Set(array));\n }", "title": "" }, { "docid": "3696426346164cd488800b87628d481d", "score": "0.8262476", "text": "function unique(arr){\n return arr.filter(function(value, index, self){ return self.indexOf(value) === index; });\n }", "title": "" }, { "docid": "38df466173f9f004f86c6749dc161db0", "score": "0.8191832", "text": "function getUnique(array) {\n var uniqueArray = [];\n\n // Loop through array values\n for (var value of array) {\n if (uniqueArray.indexOf(value) === -1) {\n uniqueArray.push(value);\n }\n }\n return uniqueArray;\n }", "title": "" }, { "docid": "29b698f2433c3131a7dba0b6bf5f4512", "score": "0.8114847", "text": "function uniqueValues(array) {\n var o = {}, i, l = array.length, r = [];\n for(i=0; i<l;i++) {\n o[array[i]] = array[i];\n }\n for(i in o) {\n r.push(o[i]);\n }\n return r;\n}", "title": "" }, { "docid": "a66d31f3e91169733543304f21bd6c6a", "score": "0.8094689", "text": "function unique(arr) {\n\treturn Array.from(new Set(arr)); //makes an array out of the the set that was made with the initial arr\n\t// this is a cool trick;\n}", "title": "" }, { "docid": "6c387756466954f773b2f505437e8b9b", "score": "0.809235", "text": "function uniq(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n }", "title": "" }, { "docid": "c07f1db1ba338c37b63a6325001284c8", "score": "0.8028402", "text": "function uniq(arr) {\n\t var theSet = new ExportedSet(arr);\n\t var result = new Array(theSet.size);\n\t var index = -1;\n\t theSet.forEach(function (value) {\n\t result[++index] = value;\n\t });\n\t return result;\n\t}", "title": "" }, { "docid": "48ecd283c8a314ab1b04f99b009dfab0", "score": "0.80133414", "text": "function unique(array) {\n return array.filter(function (value, index, self) {\n return self.indexOf(value) === index;\n })\n}", "title": "" }, { "docid": "6614ff7565efde5171a4ed3bc647d14f", "score": "0.80123067", "text": "function uniqueArray (arr){\n return arr.filter(function(x,i,ar){\n return ar.indexOf(x) == i;\n });\n}", "title": "" }, { "docid": "a6d142846d8732518875ffccdad7db71", "score": "0.8007526", "text": "function unique2(arr) {\r\n return Array.from(new Set(arr));\r\n}", "title": "" }, { "docid": "53ab41863cf3e4149391059aa1afab91", "score": "0.8004803", "text": "function uniq(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "53ab41863cf3e4149391059aa1afab91", "score": "0.8004803", "text": "function uniq(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "53ab41863cf3e4149391059aa1afab91", "score": "0.8004803", "text": "function uniq(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "53ab41863cf3e4149391059aa1afab91", "score": "0.8004803", "text": "function uniq(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "53ab41863cf3e4149391059aa1afab91", "score": "0.8004803", "text": "function uniq(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "53ab41863cf3e4149391059aa1afab91", "score": "0.8004803", "text": "function uniq(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "4d3c9a102042043a869b885390d2a212", "score": "0.7981896", "text": "function uniq(array) {\n return Array.from((new Set(array)).keys());\n}", "title": "" }, { "docid": "97b7867ea8b7859440bfeedf4d5bc81e", "score": "0.7964986", "text": "function unique(array) {\n return array.filter(function (v, i, a) {\n return a.indexOf(v) === i;\n });\n}", "title": "" }, { "docid": "66222a0cf1d2ea9bf508df2f99ae3bc3", "score": "0.7963211", "text": "function unique(array) {\n return array.filter(function(value, index) {\n return array.indexOf(value) === index;\n });\n}", "title": "" }, { "docid": "97e024ec903a53aa55a610ecd5925e46", "score": "0.7943667", "text": "function unique(array) {\r\n var i, item, temp = [], len = array.length;\r\n\r\n for (i = 0; i < len; ++i) {\r\n item = array[i];\r\n if (!inArray.call(null, item, temp)) {\r\n temp.push(item);\r\n }\r\n }\r\n return temp;\r\n }", "title": "" }, { "docid": "f345cdd8a876eaf3eef2e07efe7059bb", "score": "0.7935943", "text": "function uniqNoSet(arr) {\n \tvar ret = [];\n \n \tfor (var i = 0; i < arr.length; i++) {\n \t\tif (ret.indexOf(arr[i]) === -1) {\n \t\t\tret.push(arr[i]);\n \t\t}\n \t}\n \n \treturn ret;\n }", "title": "" }, { "docid": "b886e80a4b6f6d3c5ebd31be776675a4", "score": "0.7903252", "text": "function uniq(arr) {\n var theSet = new __WEBPACK_IMPORTED_MODULE_0_pouchdb_collections__[\"b\" /* Set */](arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "5de8eddd0936acb3cede1b8a6c3dd733", "score": "0.7878318", "text": "function getUnique(array) {\n\t\tvar uniqueArray = [];\n\t\t// Loop through array values\n\t\tfor (i = 0; i < array.length; i++) {\n\t\t\t// check wheter there is no duplicate\n\t\t\tif (uniqueArray.indexOf(array[i]) === -1) {\n\t\t\t\t// append into the array\n\t\t\t\tuniqueArray.push(array[i]);\n\t\t\t}\n\t\t}\n\t\t// return the result\n\t\treturn uniqueArray;\n\n\t}", "title": "" }, { "docid": "040ddba740c86ea7c7ef482307f69c8d", "score": "0.7870027", "text": "function unique (array){\n uniqueArray = array.filter(function(elem, pos) {\n return array.indexOf(elem) == pos;\n });\n return uniqueArray;\n}", "title": "" }, { "docid": "4f58f4d59049a0bd5897e9186cef54aa", "score": "0.78646046", "text": "function unique(arr) {\n\t var u = {}, a = [];\n\t for(var i = 0, l = arr.length; i < l; ++i){\n\t if(!u.hasOwnProperty(arr[i])) {\n\t a.push(arr[i]);\n\t u[arr[i]] = 1;\n\t }\n\t }\n\t return a;\n\t}", "title": "" }, { "docid": "8855211fa23a96f520efd5c485420e46", "score": "0.786194", "text": "function uniq$1(arr) {\n var theSet = new ExportedSet(arr);\n var result = new Array(theSet.size);\n var index = -1;\n theSet.forEach(function (value) {\n result[++index] = value;\n });\n return result;\n}", "title": "" }, { "docid": "18b12159fe2154c46469008c441e950f", "score": "0.78512555", "text": "function uniqNoSet(arr) {\n\t\tvar ret = [];\n\n\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\t\tret.push(arr[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "34396445d07a41fadb32ddc0dfbd2c2b", "score": "0.7849786", "text": "function uniqNoSet(arr) {\n\tvar ret = [];\n\n\tfor (var i = 0; i < arr.length; i++) {\n\t\tif (ret.indexOf(arr[i]) === -1) {\n\t\t\tret.push(arr[i]);\n\t\t}\n\t}\n\n\treturn ret;\n}", "title": "" }, { "docid": "4328eae4849a2844a2a5aab076e27855", "score": "0.78320545", "text": "function unique(array) {\n var result = [];\n for (var i = 0, n = array.length; i < n; i++) {\n var found = false;\n for (var x = i + 1; x < n; x++) {\n if (array[x] == array[i]) {\n found = true;\n break;\n }\n }\n if (found) continue;\n result.push(array[i]);\n }\n return result;\n }", "title": "" }, { "docid": "b2767ca1320058a528abacbf2cdd7e9b", "score": "0.78055155", "text": "function uniq$1(arr) {\n\t var theSet = new ExportedSet$1(arr);\n\t var result = new Array(theSet.size);\n\t var index = -1;\n\t theSet.forEach(function (value) {\n\t result[++index] = value;\n\t });\n\t return result;\n\t}", "title": "" }, { "docid": "2979496f2ac7a468372acd78e41baa07", "score": "0.7779558", "text": "function unique (array) {\n var newArray=$.unique(array);\n console.log(newArray);\n}", "title": "" }, { "docid": "2e1807dfebb748a6a8fc5b7f4989d0d9", "score": "0.7772837", "text": "getUniqueValues(inputArray) {\n let uniques = [];\n inputArray.forEach((input) => {\n input.forEach((inp) => {\n if (!uniques.includes(inp)) {\n uniques.push(inp);\n }\n });\n });\n return uniques;\n }", "title": "" }, { "docid": "47e44f59c1f2130b0b7a10808ed9ef37", "score": "0.7772406", "text": "function filterUnique(array){\n var uniqueVals = [];\n $.each(array, function(i, el){\n if($.inArray(el, uniqueVals) === -1) uniqueVals.push(el);\n });\n return uniqueVals;\n}", "title": "" }, { "docid": "b2fc81492e5baceb226e86ca87d6cb97", "score": "0.77498734", "text": "function getUnique(array) {\n var u = {}, a = [];\n for(var i = 0, l = array.length; i < l; ++i){\n if(u.hasOwnProperty(array[i])) {\n continue;\n }\n a.push(array[i]);\n u[array[i]] = 1;\n }\n return a;\n}", "title": "" }, { "docid": "0f20772ecd6457d42a252b5a193fa68f", "score": "0.7744562", "text": "function unique(array) {\r\n return array.filter(function (el, index, arr) {\r\n return index == arr.indexOf(el);\r\n });\r\n}", "title": "" }, { "docid": "27de0be4539abce6e68ebbeba9a8f1ac", "score": "0.77440715", "text": "function unique ( array ) {\r\n\t\treturn array.filter(function(a){\r\n\t\t\treturn !this[a] ? this[a] = true : false;\r\n\t\t}, {});\r\n\t}", "title": "" }, { "docid": "9e09a6b5ad911ad2dd93027a8cfb369d", "score": "0.7720846", "text": "function uniteUnique(arr) {\n\n\t// use a set as handily keeps insertion order, and unique elems only\n\tlet result = new Set();\n\tfor (let prop in arguments) {\n\t\t\n\t\targuments[prop].forEach( function(element, index) {\n\t\t\tresult.add(element);\n\t\t\t//console.log(result);\n\t\t});\n\t \n\t}\n return Array.from(result);\n}", "title": "" }, { "docid": "d9bee9bdb9c88ecf7c8cb2354f125b48", "score": "0.7704596", "text": "function unique(arr) {\n var u = {}, a = [];\n for(var i = 0, l = arr.length; i < l; ++i){\n if(!u.hasOwnProperty(arr[i])) {\n a.push(arr[i]);\n u[arr[i]] = 1;\n }\n }\n return a;\n}", "title": "" }, { "docid": "271d4a05fd6c4601ec689ef530c1216a", "score": "0.7696809", "text": "function unique(arr) {\n return arr.filter(function (item, index) {\n return arr.indexOf(item) === index;\n });\n}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2671da916880d7610d5619032c16a5cb", "score": "0.76916933", "text": "function unique ( array ) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "dc8f627c0510b0a144d9986f36939485", "score": "0.7683275", "text": "function uniteUnique(arr) {\nlet args = Array.protoype.slice.call(arguments);\nreturn args.reduce(function(a,b) {\n\nreturn a.concat(b.filter(function(subArray) {\n\nreturn a.indexOf(subArray) <0;\n\n}));\n});\n}", "title": "" }, { "docid": "e883f52799293b7f7079e67e0773aacc", "score": "0.767064", "text": "function uniqueArray4(a) {\n return [...new Set(a)];\n}", "title": "" }, { "docid": "850e48260fe76f2a193a5e49bd64a2c3", "score": "0.7666053", "text": "function uniqNoSet(arr) {\n var ret = [];\n\n for (var i = 0; i < arr.length; i++) {\n if (ret.indexOf(arr[i]) === -1) {\n ret.push(arr[i]);\n }\n }\n\n return ret;\n} // 2 - a simple Set type is defined", "title": "" }, { "docid": "715ccf4cfaf644d90e2b39146e1da321", "score": "0.76647174", "text": "function uniqueArray (a) {\n var seen = {};\n return a.filter(function(item) {\n return seen.hasOwnProperty(item) ? false : (seen[item] = true);\n });\n}", "title": "" }, { "docid": "02bb6b010028f5baf66b321f9a924d11", "score": "0.7661446", "text": "function _unique(values) {\n return Array.from(new Set(values));\n}", "title": "" }, { "docid": "d2f75d0566919899f9187cc82da7adda", "score": "0.76500475", "text": "function unique(arr) {\n var u = {}, a = [];\n for(var i = 0, l = arr.length; i < l; ++i){\n if(!u.hasOwnProperty(arr[i])) {\n a.push(arr[i]);\n u[arr[i]] = 1;\n }\n }\n return a;\n}", "title": "" }, { "docid": "bc7027fc533cd796e0c88b8f4d0722e8", "score": "0.7646443", "text": "function unique(array) {\n var uniq = []\n array = array.sort()\n array.forEach(function(val, i) {\n val !== array[i-1] && uniq.push(val)\n })\n return uniq\n}", "title": "" }, { "docid": "459b8a0ccfb67ba05238e82dd53cc77c", "score": "0.763125", "text": "function uniteUnique(arr) {\n var newArray = [].concat.apply([], arguments);\n var result = newArray.reduce((accumulator, current) => {\n \n if (accumulator.indexOf(current) === -1) {\n accumulator.push(current);\n }\n return accumulator;\n }, []);\n\n return result;\n \n}", "title": "" }, { "docid": "5c73b9fe78f6195a5bc11d6b6fa48c2f", "score": "0.76152754", "text": "function unique(array) {\r\n\t\treturn array.filter(function(a){\r\n\t\t\treturn !this[a] ? this[a] = true : false;\r\n\t\t}, {});\r\n\t}", "title": "" }, { "docid": "1ec403cf6c6daa62d35b2cddc02bd36b", "score": "0.76106244", "text": "function unique(array) {\n\treturn array.reduce(function (previous, current) {\n\t\tif (\n\t\t\t!previous.find(function (prevItem) {\n\t\t\t\treturn prevItem === current;\n\t\t\t})\n\t\t) {\n\t\t\tprevious.push(current);\n\t\t}\n\t\treturn previous;\n\t}, []);\n}", "title": "" }, { "docid": "a44d789751621c78972e2692504c7be3", "score": "0.7608033", "text": "function unique ( array ) {\n return array.filter(function(a){\n return !this[a] ? this[a] = true : false;\n }, {});\n }", "title": "" }, { "docid": "34350c740d017a499570d4dd8580f047", "score": "0.7606912", "text": "function unique(array) {\n return $.grep(array, function(el, index) {\n return index == $.inArray(el, array);\n });\n }", "title": "" }, { "docid": "42c73428a1bfea4b43aea4c860ed575e", "score": "0.76007587", "text": "function arrayDistinctUnsafe(array) {\r\n var o = {}, i, l = array.length, r = [];\r\n for (i = 0; i < l; i += 1) {\r\n var v = array[i];\r\n o[v] = v;\r\n }\r\n for (i in o) r.push(o[i]);\r\n return r;\r\n }", "title": "" }, { "docid": "628b30e3c91ea42c8b74c4ce68940c38", "score": "0.75976044", "text": "function unique(array){\n var uniqueArray = [];\n\n for (var i = 0; i < array.length; i++) {\n if (uniqueArray.indexOf(array[i]) === -1) {\n uniqueArray.push(array[i]);\n }\n }\n\n return uniqueArray;\n}", "title": "" }, { "docid": "d32bf467a6d0749afd4ca8428cd21c70", "score": "0.7587842", "text": "function unique(array) {\n return $.grep(array, function(el, index) {\n return index === $.inArray(el, array);\n });\n }", "title": "" }, { "docid": "b85f1c1c077378de5d5478d2fa3abb06", "score": "0.7586583", "text": "function unique(array) {\n\t var seen = {};\n\t return array.filter(function(item) {\n\t return seen.hasOwnProperty(item) ? false : (seen[item] = true);\n\t });\n\t}", "title": "" }, { "docid": "0411b65e52e890658daec107e87b8151", "score": "0.75821537", "text": "function manual_uniquearr(array){\r\n return $.grep(array,function(el,index){\r\n return index == $.inArray(el,array);\r\n });\r\n}", "title": "" }, { "docid": "ea13433bf45f8d88f3b45f932012ff60", "score": "0.7579613", "text": "function unique(array) {\r\n\t\t\treturn array.filter(function(a){\r\n\t\t\t\treturn !this[a] ? this[a] = true : false;\r\n\t\t\t}, {});\r\n\t\t}", "title": "" }, { "docid": "3f2d78f5771d4888764b9f594546f2e9", "score": "0.75758064", "text": "function uniteUnique(...arr) {\n const array = arr.flat();\n return [...new Set(array)];\n}", "title": "" }, { "docid": "e1fa754f6b817418cf1693cfc17cd32f", "score": "0.7563507", "text": "unique() {\n var arr = [];\n for(var i = 0; i < this.length; i++) {\n if(!arr.contains(this[i])) {\n arr.push(this[i]);\n }\n }\n return arr; \n}", "title": "" }, { "docid": "085770527a41bce994a1276eb1ebc0cb", "score": "0.756077", "text": "function uniqueArr(a) {\n var temp = [], i;\n for (i = 0; i < a.length; i += 1) {\n if (!contains(temp, a[i])) {\n temp.length += 1;\n temp[temp.length - 1] = a[i];\n }\n }\n return temp;\n\n }", "title": "" }, { "docid": "50f2c7abc5cd25df7db701b4d6f26a75", "score": "0.75586927", "text": "function arrayUnique(array) {\n var a = array.concat();\n for (var i=0; i<a.length; ++i) {\n for (var j=i+1; j<a.length; ++j) {\n if (a[i] === a[j]) {\n a.splice(j--, 1);\n }\n }\n }\n return a;\n}", "title": "" }, { "docid": "0d846b364bab7afc75b80eb42a82045c", "score": "0.7556689", "text": "function uniqueValues(arr){\n let s = new Set(arr).size;\n return s;\n}", "title": "" }, { "docid": "79834ff2ac7ba4618a2ab2b07c9ab7a9", "score": "0.75495684", "text": "function uniq(arr) {\n\treturn arr.filter(function (el, i) {\n\t\treturn arr.indexOf(el, i + 1) == -1;\n\t});\n}", "title": "" }, { "docid": "2178b79f48ea2997c0240b8f4a36e1b9", "score": "0.7540697", "text": "function unique(array) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2178b79f48ea2997c0240b8f4a36e1b9", "score": "0.7540697", "text": "function unique(array) {\n\t\treturn array.filter(function(a){\n\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t}, {});\n\t}", "title": "" }, { "docid": "2a67877ceac9297857aa7adf4759cca8", "score": "0.75369906", "text": "function arrayUnique(array) {\n var a = array.concat();\n for(var i=0; i<a.length; ++i) {\n for(var j=i+1; j<a.length; ++j) {\n if(a[i] === a[j])\n a.splice(j--, 1);\n }\n }\n\n return a;\n}", "title": "" }, { "docid": "c770e77f063f2f40e10be257d656eea8", "score": "0.7535537", "text": "function unique(array) {\n\t\treturn $.grep(array, function(el, index) {\n\t\t\treturn index === $.inArray(el, array);\n\t\t});\n\t}", "title": "" }, { "docid": "caf6613eeed2a5dfa5727cc8355f533b", "score": "0.7530346", "text": "function uniq (arr) {\n return arr.reduce((acc, current) => {\n\n if (!acc.includes(current)) {\n acc.push(current);\n }\n return acc;\n }, []);\n}", "title": "" }, { "docid": "1e281e53b34068ac3f6052b4136c064c", "score": "0.7528354", "text": "function uniteUnique(a,...arr) {\n const flattenArray = a.concat(arr.reduce((a, b) => a.concat(b)));\n return Array.from(new Set(flattenArray));\n}", "title": "" }, { "docid": "87ac1f3ed03993dd7c77f130f3a53d29", "score": "0.7524185", "text": "function uniteUnique(arr) {\n\tconst args = [...arguments];\n\n\tconst unifiedArr = [].concat(...args);\n\n\t//for loop could work too\n\t//Sets can only contain one of each element\n\treturn [...new Set(unifiedArr)];\n}", "title": "" }, { "docid": "1fe9df7e8e9de9022d01bba1f916cb64", "score": "0.75193566", "text": "function uniteUnique(arr) {\r\n /* the arguments object, despite not being an array, is made to support iteration */\r\n return [...new Set(Array.prototype.concat.call(...arguments))]\r\n}", "title": "" }, { "docid": "f807f8c256854074275073c92e942a05", "score": "0.7505742", "text": "function uniqSetWithForEach(arr) {\n \tvar ret = [];\n \n \t(new Set(arr)).forEach(function (el) {\n \t\tret.push(el);\n \t});\n \n \treturn ret;\n }", "title": "" }, { "docid": "3f1317d7829aabe5f6285339f1a1257a", "score": "0.7503351", "text": "function uniteUnique(arr) {\n var finalArray = [];\n // Making the function work with any number of arguments, not just three\n for(var i = 0; i < arguments.length; i++){\n var arrayArguments = arguments[i];\n // loops through the array at hand \n for(var j = 0; j < arrayArguments.length; j++){\n var indexValue = arrayArguments[j];\n if(finalArray.indexOf(indexValue) < 0){\n finalArray.push(indexValue);\n }\n }\n }\n return finalArray;\n }", "title": "" }, { "docid": "f4506658aed05281ce9cce93cc42daa6", "score": "0.7500081", "text": "function makeArrayUnique(arr) {\n var u = {},\n a = [];\n for (var i = 0, l = arr.length; i < l; ++i) {\n if (!u.hasOwnProperty(arr[i])) {\n a.push(arr[i]);\n u[arr[i]] = 1;\n }\n }\n return a;\n}", "title": "" }, { "docid": "d8b50c7e5e449bf1be1473c8edc41ed9", "score": "0.7489379", "text": "function unique(array) {\n return array.filter(function(a) {\n return !this[a] ? this[a] = true : false;\n }, {});\n }", "title": "" }, { "docid": "85dde40870cfd3ca5605d944c2bb3b51", "score": "0.74828833", "text": "function uniq (arr) {\n return reduce(arr, function (prev, curr) {\n if (prev.indexOf(curr) === -1) prev.push(curr)\n return prev\n }, [])\n}", "title": "" }, { "docid": "b867d8f351de280e3bec94fae6137a41", "score": "0.74822676", "text": "function filterUniquesInArray(array) {\n 'use strict';\n var arrayOfUniques = [], arrayLength = array.length;\n\n for (var i = 0; i < arrayLength; i++) {\n for (var j = i + 1; j < arrayLength; j++) {\n if (array[i] === array[j])\n j = ++i;\n }\n\n arrayOfUniques.push(array[i]);\n }\n\n return arrayOfUniques;\n}", "title": "" }, { "docid": "04d5167915d20e2a87b493164007c0cf", "score": "0.7482182", "text": "function unique(array) {\n return array.filter(function (a) {\n return !this[a] ? (this[a] = true) : false;\n }, {});\n }", "title": "" }, { "docid": "b0201518f2d4d9711f26679ba5b8230a", "score": "0.74757487", "text": "function arrayUnique(arr) {\n var u = {},\n a = [];\n\n for (var i = 0, l = arr.length; i < l; i++) {\n var k = arr[i];\n if (u[k]) {\n continue;\n }\n a.push(k);\n u[k] = true;\n }\n\n return a;\n}", "title": "" }, { "docid": "b0201518f2d4d9711f26679ba5b8230a", "score": "0.74757487", "text": "function arrayUnique(arr) {\n var u = {},\n a = [];\n\n for (var i = 0, l = arr.length; i < l; i++) {\n var k = arr[i];\n if (u[k]) {\n continue;\n }\n a.push(k);\n u[k] = true;\n }\n\n return a;\n}", "title": "" }, { "docid": "db47b125a86439aebe81f8a50942aa28", "score": "0.7469073", "text": "function unique(array) {\n\t\t\treturn array.filter(function(a){\n\t\t\t\treturn !this[a] ? this[a] = true : false;\n\t\t\t}, {});\n\t\t}", "title": "" }, { "docid": "b8085b604da4667629805665c92fcc99", "score": "0.7467874", "text": "function uniqSetWithForEach(arr) {\n\tvar ret = [];\n\n\t(new Set(arr)).forEach(function (el) {\n\t\tret.push(el);\n\t});\n\n\treturn ret;\n}", "title": "" }, { "docid": "b8085b604da4667629805665c92fcc99", "score": "0.7467874", "text": "function uniqSetWithForEach(arr) {\n\tvar ret = [];\n\n\t(new Set(arr)).forEach(function (el) {\n\t\tret.push(el);\n\t});\n\n\treturn ret;\n}", "title": "" } ]
0fb554b9e17d8a093271e2995a750068
var seed = 1;
[ { "docid": "8d3b01dcb12c0c52d5688ebdd8b3ac67", "score": "0.7165886", "text": "function random() {\n return Math.random();\n // var x = Math.sin(seed++) * 10000;\n // return x - Math.floor(x);\n}", "title": "" } ]
[ { "docid": "94d0e5f009bbb9d6b8525466658a57fa", "score": "0.79602647", "text": "function next() {\n seed += 1;\n return seed;\n}", "title": "" }, { "docid": "5894083579d76ecf4bb4559488484089", "score": "0.7644471", "text": "function resetSeed() {\n window.seeder = 1777771 / (window.seed = (round(random() * 10000000))); // 1777771 is prime\n window.seedlast = .007;\n window.getSeed = function() { \n return seedlast = \"0.\" + String(seeder / seedlast).substring(4).replace('.', '');\n }\n}", "title": "" }, { "docid": "595e5748622fab249574e7f79d98d632", "score": "0.7392141", "text": "seed(seed)\n\t{\n\t\tseed = Math.abs(seed | 0);\n\t\tthis._a = (Random.r1 + Random.r2 + seed) % Random.r1;\n\t\tthis._b = (Random.r2 + Random.r3 + seed) % Random.r2;\n\t\tthis._c = (Random.r3 + Random.r1 + seed) % Random.r3;\n\t\tthis._d = 0;\n\t\tthis._e = 0;\n\t\tthis._f = 0;\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "46f3e0d3dd833c93139d9bf471e8dec3", "score": "0.7315719", "text": "function rng_seed_time() {\n\t rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "c7d22365d5efd19e2c33ce5f4cabc617", "score": "0.7315629", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n}", "title": "" }, { "docid": "c7d22365d5efd19e2c33ce5f4cabc617", "score": "0.7315629", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n}", "title": "" }, { "docid": "c7d22365d5efd19e2c33ce5f4cabc617", "score": "0.7315629", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n}", "title": "" }, { "docid": "c7d22365d5efd19e2c33ce5f4cabc617", "score": "0.7315629", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n}", "title": "" }, { "docid": "df9b0fe49db29eba080eb2a112d7dd29", "score": "0.7283867", "text": "setSeed(value) {\n this.seed = value;\n }", "title": "" }, { "docid": "7fe7a1414302ac63ff8f90d5c629f98d", "score": "0.7271932", "text": "function random(seed) {\r\n // Returns random number to caller\r\n return Math.floor((Math.random() * seed));\r\n}", "title": "" }, { "docid": "ec3e365ab1be392f845478fa72bd0fcd", "score": "0.72483975", "text": "next() {\n this.seed = (MULTIPLIER * this.seed) % MODULUS;\n return this.seed;\n }", "title": "" }, { "docid": "5e13497cc77dd3bdde6c2c999eca121e", "score": "0.72426766", "text": "function seed(seed) {\n alphabet.seed(seed);\n return module.exports;\n}", "title": "" }, { "docid": "39105fe3544befab35567e3e29ae76e4", "score": "0.7197817", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "223ba0d519d469bf53392a38ce85aa6e", "score": "0.7180852", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "223ba0d519d469bf53392a38ce85aa6e", "score": "0.7180852", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "223ba0d519d469bf53392a38ce85aa6e", "score": "0.7180852", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "223ba0d519d469bf53392a38ce85aa6e", "score": "0.7180852", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "223ba0d519d469bf53392a38ce85aa6e", "score": "0.7180852", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "223ba0d519d469bf53392a38ce85aa6e", "score": "0.7180852", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "3c4c13b3e5cd0f6ed170eefa79e41751", "score": "0.71800876", "text": "function rng_seed_time() {\n rng_seed_int(new Date().getTime());\n }", "title": "" }, { "docid": "b5188ed4b64e8cc48b2b331dda45f02f", "score": "0.7171653", "text": "function rng_seed_time() {\n\t\t rng_seed_int(new Date().getTime());\n\t\t}", "title": "" }, { "docid": "b5188ed4b64e8cc48b2b331dda45f02f", "score": "0.7171653", "text": "function rng_seed_time() {\n\t\t rng_seed_int(new Date().getTime());\n\t\t}", "title": "" }, { "docid": "b5188ed4b64e8cc48b2b331dda45f02f", "score": "0.7171653", "text": "function rng_seed_time() {\n\t\t rng_seed_int(new Date().getTime());\n\t\t}", "title": "" }, { "docid": "b5188ed4b64e8cc48b2b331dda45f02f", "score": "0.7171653", "text": "function rng_seed_time() {\n\t\t rng_seed_int(new Date().getTime());\n\t\t}", "title": "" }, { "docid": "b5188ed4b64e8cc48b2b331dda45f02f", "score": "0.7171653", "text": "function rng_seed_time() {\n\t\t rng_seed_int(new Date().getTime());\n\t\t}", "title": "" }, { "docid": "c9e0edd0976e695bd6603a8b821aa42d", "score": "0.7171528", "text": "getPerlinSeed(){\n this.perlinSeed = (this.perlinSeed + 1) % 100;\n return this.perlinSeed;\n }", "title": "" }, { "docid": "2b7b5200da0ca7dbcc13d624a2e87670", "score": "0.71673363", "text": "function initialize(seed = DEFAULT_SEED) {\n return seed;\n }", "title": "" }, { "docid": "18c05267bd83612defab11ed31e063f7", "score": "0.71643686", "text": "function rng() {\n return random();\n }", "title": "" }, { "docid": "894e2ee1fd4ff41f1ead26ab0471734a", "score": "0.71586037", "text": "_rand() {}", "title": "" }, { "docid": "2f12fec373626aeba35cd07e42d77e71", "score": "0.71441674", "text": "function seed( seed ) \n{\n var v, i;\n // Scale the seed out\n if ( seed > 0 && seed < 1 ) seed *= 65536;\n\n seed = FLOOR( seed );\n if ( seed < 256 ) seed |= seed << 8;\n for (i = 0; i < 256; i++) \n {\n v = ( i & 1 ) ? (p[i] ^ (seed & 255)) : (p[i] ^ ((seed>>8) & 255));\n perm[i] = perm[i + 256] = v;\n }\n}", "title": "" }, { "docid": "de9a154878f535b991a3ccf31ac02aa7", "score": "0.7124558", "text": "function rng() {\n return random();\n }", "title": "" }, { "docid": "de9a154878f535b991a3ccf31ac02aa7", "score": "0.7124558", "text": "function rng() {\n return random();\n }", "title": "" }, { "docid": "fbc72c17c657cd2baabf8de153f4c589", "score": "0.71227324", "text": "function rng(seed) {\n return seedrandom(seed || 'test');\n}", "title": "" }, { "docid": "f4081a27500c3e292b51bd62ab0c6c5c", "score": "0.71134293", "text": "function rng_seed_time(){!function rng_seed_int(e){U[D++]^=255&e,U[D++]^=e>>8&255,U[D++]^=e>>16&255,U[D++]^=e>>24&255,D>=M&&(D-=M)}((new Date).getTime())}", "title": "" }, { "docid": "f4081a27500c3e292b51bd62ab0c6c5c", "score": "0.71134293", "text": "function rng_seed_time(){!function rng_seed_int(e){U[D++]^=255&e,U[D++]^=e>>8&255,U[D++]^=e>>16&255,U[D++]^=e>>24&255,D>=M&&(D-=M)}((new Date).getTime())}", "title": "" }, { "docid": "f618ed49ef6bb264f1e092c31b7bc15e", "score": "0.7108812", "text": "constructor(seed)\n {\n this.seed = seed;\n this.count = 0;\n this._seedArray = new Array(56);\n for (var i = 0; i < 56; i++)\n this._seedArray[i] = 0;\n var num = ((161803398 - (Math.abs(seed))) | 0);\n this._seedArray[55] = num;\n var num2 = 1;\n\n for (var i = 1; i < 55; i = ((i + 1) | 0))\n {\n var num3 = ((Math.imul(21, i) % 55) | 0);\n this._seedArray[num3] = num2;\n num2 = ((num - num2) | 0);\n if (num2 < 0)\n num2 = ((num2 + 2147483647) | 0);\n num = (this._seedArray[num3] | 0);\n }\n\n for (var j = 1; j < 5; j = ((j + 1) | 0))\n {\n for (var k = 1; k < 56; k = ((k + 1) | 0))\n {\n this._seedArray[k] = (((this._seedArray[k] | 0) - (this._seedArray[((1 + ((((k + 30) | 0) % 55) | 0)) | 0)] | 0)) | 0);\n if ((this._seedArray[k] | 0) < 0)\n this._seedArray[k] = (((this._seedArray[k] | 0) + 2147483647) | 0);\n }\n }\n this._inext = 0;\n this._inextp = 31;\n }", "title": "" }, { "docid": "6d0aa06a7f73a34ef474a6e3ab852864", "score": "0.7077504", "text": "next() {\n this.seed = this.seed * 16807 % 2147483647;\n return this.seed;\n }", "title": "" }, { "docid": "6d0aa06a7f73a34ef474a6e3ab852864", "score": "0.7077504", "text": "next() {\n this.seed = this.seed * 16807 % 2147483647;\n return this.seed;\n }", "title": "" }, { "docid": "9c2a509ac139037db4b8d4b52a9e1a4b", "score": "0.7072961", "text": "function initRandom(seed) {\n let val = seed % 2147483647;\n return () => val = (val * 16807) % 2147483647;\n}", "title": "" }, { "docid": "64d33f50cbb4d164d5b340f17093667a", "score": "0.7029975", "text": "function randomNumberGenerator() {\n seed = (seed * g) % n;\n return seed;\n}", "title": "" }, { "docid": "6248e9e1109cb2f84235f91d3fbbc2fd", "score": "0.7025455", "text": "static Random(seed) {\n return null;\n }", "title": "" }, { "docid": "3ffdca2802c312ab43ed52277cb07e72", "score": "0.7017873", "text": "function rng_seed_time(){!function rng_seed_int(t){T[M++]^=255&t,T[M++]^=t>>8&255,T[M++]^=t>>16&255,T[M++]^=t>>24&255,M>=O&&(M-=O)}((new Date).getTime())}", "title": "" }, { "docid": "3ffdca2802c312ab43ed52277cb07e72", "score": "0.7017873", "text": "function rng_seed_time(){!function rng_seed_int(t){T[M++]^=255&t,T[M++]^=t>>8&255,T[M++]^=t>>16&255,T[M++]^=t>>24&255,M>=O&&(M-=O)}((new Date).getTime())}", "title": "" }, { "docid": "3b3e791f81f5c9bfcc0de178a3525ec9", "score": "0.700423", "text": "function random() {\n var x = Math.sin(seed++) * 10000;\n return x - Math.floor(x);\n}", "title": "" }, { "docid": "ca85a1a3c41602c93e6b529910f911e5", "score": "0.6983961", "text": "function random () {\n return generator.random();\n}", "title": "" }, { "docid": "b8ec9ea08822f5504bd797fdcd6a5753", "score": "0.697401", "text": "function seedIdenty()\n {\n seed = seedDefault;\n var intermidIndex = (++letterIndex);\n while(intermidIndex > 10)\n {\n seed += letter[9];\n intermidIndex -= 10;\n }\n seed += letter[(intermidIndex-1)];\n //seed = letter[letterIndex++];\n return seed;\n }", "title": "" }, { "docid": "aa3cc9daa5a690f914ec1e65a4bc1e22", "score": "0.6964025", "text": "function seed(seed) {\n if(seed > 0 && seed < 1){\n // Scale the seed out\n seed *= 65536;\n }\n\n seed = Math.floor(seed);\n if(seed < 256){\n seed |= seed << 8;\n }\n\n for(var i = 0; i < 256; i++){\n var v;\n if(i & 1){\n v = p[i] ^ (seed & 255);\n }\n else{\n v = p[i] ^ ((seed >> 8) & 255);\n }\n\n perm[i] = perm[i + 256] = v;\n gradP[i] = gradP[i + 256] = grad3[v % 12];\n }\n}", "title": "" }, { "docid": "49779bb36bdcfc9f2b640bde8d6effa7", "score": "0.6940049", "text": "function seedRandomGenerator(seed) {\n\tif (!seed) {\n\t\tseed = Date.now() - 1352700000;\n\t}\n\tseed = seed % RAND_MAX_COMBO;\n\n\traninit(RNGState[RNG_SUBSTANTIVE], seed);\n\traninit(RNGState[RNG_COSMETIC], seed);\n\treturn seed;\n}", "title": "" }, { "docid": "0a9c67cd57d876ac12c6f52cb51d8d38", "score": "0.69375324", "text": "function newseed(seednum) {\n return [seednum]\n}", "title": "" }, { "docid": "fe5ffd3b2c60aa1602b81da824102725", "score": "0.69136596", "text": "function SeededRandom(){}", "title": "" }, { "docid": "78e6386c6878bd92e0ce22518db1218b", "score": "0.69004166", "text": "function pseudoRandom(seed) {\n seed = (seed * 9301 + 49297) % 233280;\n return seed / 233280.0;\n}", "title": "" }, { "docid": "78e6386c6878bd92e0ce22518db1218b", "score": "0.69004166", "text": "function pseudoRandom(seed) {\n seed = (seed * 9301 + 49297) % 233280;\n return seed / 233280.0;\n}", "title": "" }, { "docid": "6346f6df1807814c376762f2aff15efe", "score": "0.6894778", "text": "function seed (num) {\n if (typeof num === 'number' && (num % 1) === 0) {\n // jscs:disable requireCamelCaseOrUpperCaseIdentifiers\n generator.init_seed(num);\n return true;\n }\n else {\n return undefined;\n }\n}", "title": "" }, { "docid": "04a03f68e1bc72e60a50d73e6465b4cf", "score": "0.6883671", "text": "next() {\n return this.seed = this.seed * 16807 % 2147483647;\n }", "title": "" }, { "docid": "7ea5c7b4defdc4efa46bcdd4f46b17eb", "score": "0.68786633", "text": "rng_seed_time() {\n\t\tthis.rng_seed_int(new Date().getTime());\n\t}", "title": "" }, { "docid": "0d75479f63b605823af7bae8ded0bcfd", "score": "0.687263", "text": "function seededRandom( s ) {\n\n\tif ( s !== undefined ) _seed = s % 2147483647;\n\n\t// Park-Miller algorithm\n\n\t_seed = _seed * 16807 % 2147483647;\n\n\treturn ( _seed - 1 ) / 2147483646;\n\n}", "title": "" }, { "docid": "da10824c74832a9b86835a5271c680ae", "score": "0.6867366", "text": "function setSeed(seed) {\n random = seed === null ? singletonRandom : (0, _seedRandom.default)(String(seed));\n } // initialize a seeded pseudo random number generator with config's random seed", "title": "" }, { "docid": "8fde4aaabc6cdd937dea602f71c77b35", "score": "0.6845497", "text": "function _seed() {\n\t // create a plugin-based message digest\n\t var md = ctx.plugin.md.create();\n\n\t // digest pool 0's entropy and restart it\n\t md.update(ctx.pools[0].digest().getBytes());\n\t ctx.pools[0].start();\n\n\t // digest the entropy of other pools whose index k meet the\n\t // condition '2^k mod n == 0' where n is the number of reseeds\n\t var k = 1;\n\t for(var i = 1; i < 32; ++i) {\n\t // prevent signed numbers from being used\n\t k = (k === 31) ? 0x80000000 : (k << 2);\n\t if(k % ctx.reseeds === 0) {\n\t md.update(ctx.pools[i].digest().getBytes());\n\t ctx.pools[i].start();\n\t }\n\t }\n\n\t // get digest for key bytes and iterate again for seed bytes\n\t var keyBytes = md.digest().getBytes();\n\t md.start();\n\t md.update(keyBytes);\n\t var seedBytes = md.digest().getBytes();\n\n\t // update\n\t ctx.key = ctx.plugin.formatKey(keyBytes);\n\t ctx.seed = ctx.plugin.formatSeed(seedBytes);\n\t ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;\n\t ctx.generated = 0;\n\t }", "title": "" }, { "docid": "e9e2e555b45087b55130d55fe115d40b", "score": "0.6824094", "text": "function getRNG(){\n\n}", "title": "" }, { "docid": "b8b4e8b4f40cdfff69b53b0fb6f3476c", "score": "0.68224585", "text": "function get_random() {\n return Math.seededRandom(0, 1);\n}", "title": "" }, { "docid": "b918639be60c1b0219204bebb66bf19e", "score": "0.68059117", "text": "function Random(seed) {\n this._seed = seed % 2147483647;\n if (this._seed <= 0) this._seed += 2147483646;\n}", "title": "" }, { "docid": "67530a43aabcab200373f1df6b7f6524", "score": "0.68004745", "text": "function seedrand(seed) {\n for (let i = 0; i < randseed.length; i++) {\n randseed[i] = 0;\n }\n for (let i = 0; i < seed.length; i++) {\n randseed[i % 4] = (randseed[i % 4] << 5) - randseed[i % 4] + seed.charCodeAt(i);\n }\n}", "title": "" }, { "docid": "24e3372a3cd7a774999f01b986dabb57", "score": "0.67901397", "text": "function seed(seedValue) {\n alphabet_1.seed(seedValue);\n return module.exports;\n}", "title": "" }, { "docid": "24e3372a3cd7a774999f01b986dabb57", "score": "0.67901397", "text": "function seed(seedValue) {\n alphabet_1.seed(seedValue);\n return module.exports;\n}", "title": "" }, { "docid": "12b796c930da1d7e34ea0d5f507732b7", "score": "0.6782595", "text": "function randomizer(seed)\r\n{\r\n // Returns a somewhat random real number between 0 (inclusive) and 1 (not inclusive), like Math.random() but with a seed I control.\r\n // Modulus is in parens to work around a Crunchinator bug.\r\n\r\n function rndReal() {\r\n\tseed = (seed*9301 + 49297) % (233280);\r\n\treturn seed/(233280.0);\r\n };\r\n\r\n // Returns a somewhat random integer in the range {0, 1, 2, ..., number-1}\r\n function rndInt(number) {\r\n\treturn Math.floor(rndReal() * number);\r\n };\r\n\r\n return rndInt;\r\n}", "title": "" }, { "docid": "f08b74a84d9bfb666298f91b674a0038", "score": "0.6775942", "text": "function _seed() {\n // create a plugin-based message digest\n var md = ctx.plugin.md.create();\n\n // digest pool 0's entropy and restart it\n md.update(ctx.pools[0].digest().getBytes());\n ctx.pools[0].start();\n\n // digest the entropy of other pools whose index k meet the\n // condition '2^k mod n == 0' where n is the number of reseeds\n var k = 1;\n for(var i = 1; i < 32; ++i) {\n // prevent signed numbers from being used\n k = (k === 31) ? 0x80000000 : (k << 2);\n if(k % ctx.reseeds === 0) {\n md.update(ctx.pools[i].digest().getBytes());\n ctx.pools[i].start();\n }\n }\n\n // get digest for key bytes and iterate again for seed bytes\n var keyBytes = md.digest().getBytes();\n md.start();\n md.update(keyBytes);\n var seedBytes = md.digest().getBytes();\n\n // update\n ctx.key = ctx.plugin.formatKey(keyBytes);\n ctx.seed = ctx.plugin.formatSeed(seedBytes);\n ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;\n ctx.generated = 0;\n }", "title": "" }, { "docid": "3c9563caf20fb46595f0b78d1a532c8a", "score": "0.67685765", "text": "function seed(seedValue) {\n\t alphabet.seed(seedValue);\n\t return module.exports;\n\t}", "title": "" }, { "docid": "54fc84e7cb681051d92925bd21b7937d", "score": "0.6753384", "text": "function makeRNG(seed)\n{\n let lcg = (a) => (a * 48271 % 2147483647)\n\t\n seed = lcg(seed)\n\t\n return () => ((seed = lcg(seed)) / 2147483648)\n}", "title": "" }, { "docid": "678a8639fe1f03da030202e02ce7b152", "score": "0.67513514", "text": "function seed(seedValue) {\n\t alphabet.seed(seedValue);\n\t return module.exports;\n\t}", "title": "" }, { "docid": "678a8639fe1f03da030202e02ce7b152", "score": "0.67513514", "text": "function seed(seedValue) {\n\t alphabet.seed(seedValue);\n\t return module.exports;\n\t}", "title": "" }, { "docid": "678a8639fe1f03da030202e02ce7b152", "score": "0.67513514", "text": "function seed(seedValue) {\n\t alphabet.seed(seedValue);\n\t return module.exports;\n\t}", "title": "" }, { "docid": "678a8639fe1f03da030202e02ce7b152", "score": "0.67513514", "text": "function seed(seedValue) {\n\t alphabet.seed(seedValue);\n\t return module.exports;\n\t}", "title": "" }, { "docid": "c0d242bfd23256bef95198fc99d9043c", "score": "0.6746666", "text": "function seedSubmit() {\n currentSeed=seed.value\n rng = new Math.seedrandom(seed.value);\n console.log(rng());\n //Generates string for use in html on second line of page\n document.getElementById('currentSeed').innerHTML = \"Current Seed: \"\n + currentSeed + \" - \" + generateErrorMsgType();\n console.log(\"Current Seed: \" + currentSeed);\n}", "title": "" }, { "docid": "481ed325a2d4c1320c9b5721f00eaf5d", "score": "0.6739741", "text": "setSeed(value) {\n this.seed = uint32(value);\n }", "title": "" }, { "docid": "d665a83db01ffd0c964a6699401919c9", "score": "0.67251015", "text": "function seed(value) {\n s = 624;\n m = [value];\n for (var i = 1; i < 624; i++) {\n m[i] = (m[i - 1] ^ m[i - 1] >> 30) + i | 0;\n }\n }", "title": "" }, { "docid": "ba2cf406e6e7bd66a33998b8e263b214", "score": "0.67178875", "text": "static createGenerator(_seed) {\n // TODO: replace with random number generator to generate predictable sequence\n return Math.random;\n }", "title": "" }, { "docid": "55e2ae6f7a3576658c176f8e6d31e098", "score": "0.67120737", "text": "seed(val) {\n this._seed = val;\n return this;\n }", "title": "" }, { "docid": "41194c063c36ca898339623ceb2f6c12", "score": "0.6711334", "text": "function setSeed(seed) {\n random = seed === null ? singletonRandom : __WEBPACK_IMPORTED_MODULE_0_seed_random___default()(String(seed));\n } // initialize a seeded pseudo random number generator with config's random seed", "title": "" }, { "docid": "6cd0888ab7923d61d257757e64cace18", "score": "0.67101854", "text": "function seed(seedValue) {\n alphabet.seed(seedValue);\n return module.exports;\n}", "title": "" }, { "docid": "6cd0888ab7923d61d257757e64cace18", "score": "0.67101854", "text": "function seed(seedValue) {\n alphabet.seed(seedValue);\n return module.exports;\n}", "title": "" }, { "docid": "6cd0888ab7923d61d257757e64cace18", "score": "0.67101854", "text": "function seed(seedValue) {\n alphabet.seed(seedValue);\n return module.exports;\n}", "title": "" }, { "docid": "6cd0888ab7923d61d257757e64cace18", "score": "0.67101854", "text": "function seed(seedValue) {\n alphabet.seed(seedValue);\n return module.exports;\n}", "title": "" }, { "docid": "6cd0888ab7923d61d257757e64cace18", "score": "0.67101854", "text": "function seed(seedValue) {\n alphabet.seed(seedValue);\n return module.exports;\n}", "title": "" }, { "docid": "6cd0888ab7923d61d257757e64cace18", "score": "0.67101854", "text": "function seed(seedValue) {\n alphabet.seed(seedValue);\n return module.exports;\n}", "title": "" } ]
10eba22266f7c11aa008352279e5b899
Taken from source and then modified for style and to strip newline
[ { "docid": "44e97a3d3c8562356123f97267abbb6f", "score": "0.0", "text": "function charsToLines(diffs, lineArray, ignoreTrailingNewLines) {\n\t\t\tfor (var x = 0; x < diffs.length; x++) {\n\t\t\t\tvar chars = diffs[x][1];\n\t\t\t\tvar text = [];\n\t\t\t\tfor (var y = 0; y < chars.length; y++) {\n\t\t\t\t\ttext[y] = lineArray[chars.charCodeAt(y)];\n\t\t\t\t}\n\t\t\t\tdiffs[x][1] = text.join((ignoreTrailingNewLines) ? '\\n' : '');\n\t\t\t}\n\t\t}", "title": "" } ]
[ { "docid": "7ec33c13d5f2e01a391a530d4fc4b114", "score": "0.6560319", "text": "function trimLeadingLineBreaks(node) {\n do {\n if (node.nodeType === 3) {\n node.nodeValue = node.nodeValue.replace(/^[\\r\\n]+/, '');\n }\n\n node = node.firstChild;\n } while (node);\n }", "title": "" }, { "docid": "2b7769ca53f59fa7faa91188da871c8b", "score": "0.6418716", "text": "function stripNewLine(str) {\n str = str.replace(/\\n/g, '<br>');\n return str;\n }", "title": "" }, { "docid": "93b0672684ce610819e935b28c61eeea", "score": "0.63505137", "text": "removeLineBreaking() {\n let word = this.props.data.toLowerCase()\n word = word.replace(/(\\r\\n|\\n|\\r)/gm,\"\")\n word = word.replace(/(\\r\\n|\\n|\\r)/gm,\" \")\n word = word.replace(/\\s+/g,\" \")\n\n return word\n }", "title": "" }, { "docid": "32bef661ec1dc418a48eebcf5eef3e81", "score": "0.620703", "text": "function cleanContent(input) {\n return input.replace(/\\n {6}\\n {8}\\n {8}/g, \"\");\n}", "title": "" }, { "docid": "4ab2f6fea75571b1576215ab68b1080a", "score": "0.6145613", "text": "function heavyCleanup(input) {\n // TODO: Some of the backslash escapes should be handled by Flowmark instead\n // being of unescaped here.\n return input.replace(/ > /gim, ' ')\n .replace(/<!-- -->/gim, '')\n .replace(/\\\\'/gim, \"'\")\n .replace(/\\\\\"/gim, '\"')\n .replace(/\\\\\\$/gim, '$')\n .replace(/\\\\~/gim, '~')\n .replace(/\\\\>/gim, '>')\n .replace(/\\\\\\\\ >/gim, '\\n') // Some newlines get converted erroneously.\n .replace(/\\[([^\\[\\]]*?)\\]\\{.underline\\}/gim, '$1');\n}", "title": "" }, { "docid": "b31f1f6af96f809f254b598f81fb4dbb", "score": "0.6142434", "text": "function removeLeadingNewline(node) {\n if (node.nodeType !== 3 || node.nodeName !== '#text') {\n return;\n }\n\n node.nodeValue = node.nodeValue.replace(/^\\n/, '');\n }", "title": "" }, { "docid": "f401646175de73ddfa665e124e97ccb3", "score": "0.61284786", "text": "function normalize(s) {\n\t\t\t\t\treturn s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n\t\t\t\t}", "title": "" }, { "docid": "cfe28ee8bb970889717931b29aab69d4", "score": "0.61080205", "text": "function normalize(s) {\n\t return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n\t }", "title": "" }, { "docid": "cfe28ee8bb970889717931b29aab69d4", "score": "0.61080205", "text": "function normalize(s) {\n\t return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n\t }", "title": "" }, { "docid": "cfe28ee8bb970889717931b29aab69d4", "score": "0.61080205", "text": "function normalize(s) {\n\t return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n\t }", "title": "" }, { "docid": "cfe28ee8bb970889717931b29aab69d4", "score": "0.61080205", "text": "function normalize(s) {\n\t return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n\t }", "title": "" }, { "docid": "9de61876307a3ac8b5b9c7059c5743c7", "score": "0.6035529", "text": "function nol(contents) {\n return contents.replace(/[\\r\\n]/g, \"\");\n }", "title": "" }, { "docid": "a2112d99d0d0a390497f4974448e157a", "score": "0.6016418", "text": "stripComments (line) {\n return line\n .replace(this.constructor.re1, '')\n .replace(this.constructor.re2, '')\n .replace(this.constructor.re3, '');\n }", "title": "" }, { "docid": "7c25053e1a45ee364fa46f56b0a7e8b1", "score": "0.6010076", "text": "function removeLineBreaks(text, opt_paragraph_delim) {\n var paragraph_delim = opt_paragraph_delim || \"\\n\\n\";\n text = text.replace(/\\\\\\n/gm, \"XX\");\n text = text.replace(/\\n\\n/gm, \"CC\");\n text = text.replace(/\\r\\n|\\n|\\r/gm, \" \");\n text = text.replace(/XX/g, \"\\n\");\n return text.replace(/CC/g, paragraph_delim).trim();\n}", "title": "" }, { "docid": "d5a9a2c4172c45b68ebbfe816bbc41ab", "score": "0.5976327", "text": "function removeTN(value) {\n\t\t\treturn value.replace(/(\\n|\\t)/gm, \"\").trim();\n\t\t}", "title": "" }, { "docid": "75182d5f91a88c0b455cafdf53cd2c1c", "score": "0.59750086", "text": "function stripBlock(text) {\n let spaces = null;\n\n for (const line of text.split('\\n').slice(1)) {\n if (line.length === 0) {\n continue;\n }\n\n const count = line.match(/^\\s*/)[0].length;\n if (spaces === null) {\n spaces = count;\n } else if (count < spaces) {\n spaces = count;\n }\n }\n\n const lines = [];\n for (const line of text.split('\\n')) {\n lines.push(line.substr(spaces));\n }\n\n return lines.join('\\n');\n}", "title": "" }, { "docid": "1137797a57ad4adc225ddef1d0c48409", "score": "0.5967054", "text": "function stripAndCollapse( value ) {\n var tokens = value.match( /[^\\x20\\t\\r\\n\\f]+/g ) || [];\n return tokens.join( \" \" );\n }", "title": "" }, { "docid": "00e01989e0975931d4c24cbd72bdccfc", "score": "0.5966786", "text": "function removeLineEndings(s) {\n\n // First trim '\\n'\n if ((s.length > 0) && (s[s.length - 1] == '\\n')) {\n s = s.substring(0, s.length - 1);\n }\n\n // Next trim '\\r'\n if ((s.length > 0) && (s[s.length - 1] == '\\r')) {\n s = s.substring(0, s.length - 1);\n }\n\n return s;\n}", "title": "" }, { "docid": "8a64416f20ef84bee4fd0362118d7be6", "score": "0.5964764", "text": "function remove(text){\n text = text.replace(/\\n/g,\" \");\n text = text.replace(/\\r/g,\" \");\n text = text.replace(/\\t/g,\" \");\n text = text.replace(/ {1,}/g,\" \");\n text = text.trim();\n return text ;\n}", "title": "" }, { "docid": "7b0175709e8696bd9a85c1c826b6f4d7", "score": "0.59513414", "text": "function removeReturns(text) {\n return text.replace(/\\r?\\n|\\r/g, \"\");\n}", "title": "" }, { "docid": "409ab1b8face7b7cfbdd8647f84b6a9c", "score": "0.5948889", "text": "function sanitize(line) {\r\n // remove comments\r\n var no_comments = line.replace(/^(.*?);.*/, \"$1\");\r\n \r\n // trim line\r\n return no_comments.replace(/^\\s+/, \"\").replace(/\\s+$/, \"\");\r\n }", "title": "" }, { "docid": "0dcd47472622d67109d7e3b71676c214", "score": "0.59266406", "text": "function/* missing to */trim/* a fucking */(text)/* ??? */ { return text.replace(/^\\s*|\\s*$/g, ''); }", "title": "" }, { "docid": "0cfb07b49c34390e3a1e108e62c99b90", "score": "0.58935493", "text": "function removeExtraneousLineBreaksFrom(node) {\n\t\tremoveExtraneousLineBreaksBefore(node);\n\t\tremoveExtraneousLineBreaksAtTheEndOf(node);\n\t}", "title": "" }, { "docid": "4b7446dab3fe9fa3522e996beea9e7d0", "score": "0.58906835", "text": "function customTrim(el) {\n el = el.replace(/(^\\s*)|(\\s*$)/gi, \"\").replace(/[ ]{2,}/gi, \" \").replace(/\\n +/, \"\\n\");\n return el;\n }", "title": "" }, { "docid": "3437d979af56c055bdedb2234ca1ee04", "score": "0.587722", "text": "function normalize(s) {\n return s.trim().replace(/\\r\\n/g, '\\n')\n }", "title": "" }, { "docid": "0483d5deb36f0660bc1f7e8396554160", "score": "0.5872637", "text": "function stripNewlines(str) {\n /**\n * To strip newlines from a string, remove any U+000A LF and U+000D CR code\n * points from the string.\n */\n return str.replace(/[\\n\\r]/g, \"\");\n}", "title": "" }, { "docid": "5770debd54c56589ddb627c957531d02", "score": "0.5847304", "text": "function smarteditNormalStyleIntoLine(wikismartLine){\n\tif(wikismartLine != null && wikismartLine.length > 0){\n\t\tvar containsHd = -2;\n\t\tvar tsindex = 0; // If the line begin with \\n, we have to test string without \\n\n\t\tvar teststartindice = wikismartLine.indexOf(\"\\n\");\n\t\tif(teststartindice == 0){\n\t\t\ttsindex = 1;\n\t\t}\n\t\tcontainsHd = wikismartContainsHeading(wikismartLine.substring(tsindex,wikismartLine.length));\n\t\tif(containsHd != -1){ // Si la ligne contient un heading, alors il faut le remplacer par celui qui est demandé\n\t\t\twikismartLine = wikismartLine.substring(0,tsindex)+wikismartLine.substring((tsindex+containsHd+3),wikismartLine.length);\n\t\t\tvar tsfirstchar = wikismartIndexOfFirstCharacter(wikismartLine.substring(tsindex,wikismartLine.length));\n\t\t\tif(tsfirstchar != -1){\n\t\t\t\twikismartLine = wikismartLine.substring(0,tsindex)+wikismartLine.substring(tsfirstchar,wikismartLine.length);\n\t\t\t}\n\t\t}\n\t}\n\treturn wikismartLine;\n}", "title": "" }, { "docid": "5a8c22754a1ba81c9142a16979e7d26a", "score": "0.584022", "text": "function fix(text) {\n if (!text) return;\n return text.split('\\n').map(function(line) {\n if (line.match(/^- /))\n line = ' ' + line;\n return line;\n }).join('\\n');\n }", "title": "" }, { "docid": "44078f92bd45e31890028c23fdec95ae", "score": "0.5819919", "text": "function baynote_removeHtml(raw) {\n\tif (!raw) return;\n\traw = raw.replace(/\\<[^>]*\\>/g, \"\");\n\traw = raw.replace(/\\<.*/, \"\");\n\traw = raw.replace(/\\&nbsp;/g, \" \");\n\traw = raw.replace(/^\\s+/, \"\");\n\traw = raw.replace(/\\s+$/, \"\");\n\traw = raw.replace(/\\n/g, \" \");\n\treturn raw;\n}", "title": "" }, { "docid": "564f844c73e5cb51efbfb651048a493e", "score": "0.5794663", "text": "function normalizeEndings(text) {\r\n \r\n text = text.replace(/\\r\\n/g, '\\n');\r\n text = text + '\\n';\r\n\r\n text = text.replace(/[\\n]{2,}/g, '\\n');\r\n text = text.replace(/\\n/g, eol);\r\n\r\n return text;\r\n}", "title": "" }, { "docid": "73e9e725f3d9ac69bdd87a9cf1dfb120", "score": "0.57816905", "text": "function fixEOL(text) {\r\n var rat = text.indexOf('\\r');\r\n var nat = text.indexOf('\\n');\r\n if(rat == -1) {\r\n return text;\r\n }\r\n if(nat == -1) {\r\n return text.replace(/\\r/g, '\\n');\r\n }\r\n if(rat < nat) {\r\n return text.replace(/\\r\\n/g, '\\n');\r\n }\r\n return text.replace(/\\n\\r/g, '\\n');\r\n}", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "1492a4e8230b7f59f78f793d88ed8cab", "score": "0.5776109", "text": "function normalize(s) {\n return s ? s.replace(/\\r?\\n/g, '\\r\\n') : ''\n }", "title": "" }, { "docid": "32d0cdcfd6fa5a334c8b6dc4de01e67d", "score": "0.5762066", "text": "function getShrinkedCode (src) {\n\t\t// strip head comment\n\t\tvar blankLine = src.indexOf('\\n\\n');\n\t\tif (blankLine >= 0) {\n\t\t\tsrc = src.substring(blankLine + 2);\n\t\t}\n\n\t\t// strip all single line comments\n\t\tsrc = src.replace(/\\/\\/.*/g, ' ');\n\n\t\t// remove all newlines\n\t\tsrc = src.replace(/\\n[\\n\\s]*/g, ' ');\n\n\t\treturn src;\n\t}", "title": "" }, { "docid": "3b404934fc6d6edf3df5b5995506c02d", "score": "0.5759519", "text": "valueReformattedForMultilines(value) {\n if (typeof(value)==\"string\") return(value.replace(/\\n/ig,\"<br/>\"));\n else return(value);\n }", "title": "" }, { "docid": "57e37065339bd8d5a984faca8aa7006e", "score": "0.5758306", "text": "function strip_ansi(str)\n{\n\treturn str.replace( /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');\n}", "title": "" }, { "docid": "9c5254bf03645b0597eca0e9cf789d9d", "score": "0.57504237", "text": "function skipSpace(string) {\n return string.replace(/(#.*\\n|\\s)/g, \"\");\n}", "title": "" }, { "docid": "9c20acce1a3fc26af8f2abf98cbbda6a", "score": "0.5737496", "text": "codeFormatter(code) {\n return code.replace(/\\\\n/g, `\n `);\n }", "title": "" }, { "docid": "8173b4f2f3326421810dd314f8f6c731", "score": "0.5734568", "text": "function stripAndCollapse(value){var tokens=value.match(rnothtmlwhite)||[];return tokens.join(\" \");}", "title": "" }, { "docid": "8173b4f2f3326421810dd314f8f6c731", "score": "0.5734568", "text": "function stripAndCollapse(value){var tokens=value.match(rnothtmlwhite)||[];return tokens.join(\" \");}", "title": "" }, { "docid": "8173b4f2f3326421810dd314f8f6c731", "score": "0.5734568", "text": "function stripAndCollapse(value){var tokens=value.match(rnothtmlwhite)||[];return tokens.join(\" \");}", "title": "" }, { "docid": "8173b4f2f3326421810dd314f8f6c731", "score": "0.5734568", "text": "function stripAndCollapse(value){var tokens=value.match(rnothtmlwhite)||[];return tokens.join(\" \");}", "title": "" }, { "docid": "8173b4f2f3326421810dd314f8f6c731", "score": "0.5734568", "text": "function stripAndCollapse(value){var tokens=value.match(rnothtmlwhite)||[];return tokens.join(\" \");}", "title": "" }, { "docid": "cbf870cca4a0de2493cbffd412abd2f6", "score": "0.57337165", "text": "function removeExtraneousLineBreaksFrom(node) {\n removeExtraneousLineBreaksBefore(node);\n removeExtraneousLineBreaksAtTheEndOf(node);\n }", "title": "" }, { "docid": "ca8aca8473a4c9c41a82676c920f185d", "score": "0.5725625", "text": "function getFormattedLine (line) {\n \tif(typeof line !== \"string\"){\n \t\treturn '';\n \t}\n \treturn line.split('').filter(function(ch) {\n \t\t \treturn isSpecialChar(ch) === false ;\n \t\t\t}).join('');\n }", "title": "" }, { "docid": "2b20b2e54d5ca91119defba0b0f8d35c", "score": "0.5719752", "text": "removeLeadingNewlines() {\n var i, k, l, leadingNewlineToken, len, len1, ref, ref1, tag;\n ref = this.tokens;\n for (i = k = 0, len = ref.length; k < len; i = ++k) {\n [tag] = ref[i];\n if (tag !== 'TERMINATOR') {\n // Find the index of the first non-`TERMINATOR` token.\n break;\n }\n }\n if (i === 0) {\n return;\n }\n ref1 = this.tokens.slice(0, i);\n // If there are any comments attached to the tokens we’re about to discard,\n // shift them forward to what will become the new first token.\n for (l = 0, len1 = ref1.length; l < len1; l++) {\n leadingNewlineToken = ref1[l];\n moveComments(leadingNewlineToken, this.tokens[i]);\n }\n // Discard all the leading newline tokens.\n return this.tokens.splice(0, i);\n }", "title": "" }, { "docid": "d3b13b2e51d5a7ca584d8a4259a78480", "score": "0.5715047", "text": "function removeNL(s)\r\n{\r\n // NewLine, CarriageReturn and Tab characters from a String\r\n // will be removed and will return the new string\r\n\r\n r = \"\";\r\n for (i = 0; i < s.length; i++)\r\n {\r\n if (s.charAt(i) != '\\n' & s.charAt(i) != '\\r' & s.charAt(i) != '\\t') {\r\n r += s.charAt(i);\r\n }\r\n }\r\n\r\n return r;\r\n}", "title": "" }, { "docid": "4a9d8e01217631f37c09e0171b61fbc8", "score": "0.57083994", "text": "function clrText(noTrim) {\n\tvar a=this.replace(/[\\?£\\$<>\\[\\]\\{\\};\"\\(\\){}\\^\\[\\]\\!\\\\\\*²%]+/g,'');\n\ta = a.replace(/[&]/g, \"et\");\n/*\ta = a.replace(/[àâä]/g, \"a\");\n\ta = a.replace(/[éèêë_]/g, \"e\");\n\ta = a.replace(/[îï]/g, \"i\");\n\ta = a.replace(/[ôö]/g, \"o\");\n\ta = a.replace(/[ûüùµ]/g, \"u\");\n\ta = a.replace(/[ç]/g, \"c\");\n\ta = a.replace(/[ñ]/g, \"n\");\n*/\n\ta = a.replace(/[_]/g, \" \");\n\ta = a.replace(/[ ][ ]+/g,\" \");\n\tif (noTrim) return a;\n\telse return a.replace(/\\s+$/,'').replace(/^\\s+/,'');\n}", "title": "" }, { "docid": "035530f1ef7dbbc2398a7cc7ef574c8f", "score": "0.5696548", "text": "function catchupNewlines(end, state) {\n\t catchup(end, state, stripNonNewline);\n\t}", "title": "" }, { "docid": "eb091eacf45f1a844fafa96417d83983", "score": "0.56917375", "text": "function lineText() {\n\t\tvar beg = source.lastIndexOf(\"\\n\", pos - 1);\n\t\tvar end = source.indexOf(\"\\n\", pos);\n\t\treturn beg < end ? source.substring(beg, end) : \"\";\n\t}", "title": "" }, { "docid": "35c441473f0a6be75bda34be5de964d2", "score": "0.56826955", "text": "function removeEmptyLines() {\n utilitymanager_1.um.utilityManager({\n utilType: utilitymanager_1.um.TIXUtilityType.utLinesUtility,\n sp: utilitymanager_1.um.TIXSelPolicy.All,\n }, function (up) {\n var arr = up.inlines;\n for (var i = arr.length - 1; i >= 0; i--) {\n if (!arr[i].trim()) {\n arr.splice(i, 1);\n }\n }\n return arr;\n });\n }", "title": "" }, { "docid": "9b0e9fc3f9f0f81386c33d2899eed45e", "score": "0.56801796", "text": "function dropEndingNewline(string) {\n\t return string[string.length - 1] === '\\n' ? string.slice(0, -1) : string;\n\t}", "title": "" }, { "docid": "9b0e9fc3f9f0f81386c33d2899eed45e", "score": "0.56801796", "text": "function dropEndingNewline(string) {\n\t return string[string.length - 1] === '\\n' ? string.slice(0, -1) : string;\n\t}", "title": "" }, { "docid": "9b0e9fc3f9f0f81386c33d2899eed45e", "score": "0.56801796", "text": "function dropEndingNewline(string) {\n\t return string[string.length - 1] === '\\n' ? string.slice(0, -1) : string;\n\t}", "title": "" }, { "docid": "9b0e9fc3f9f0f81386c33d2899eed45e", "score": "0.56801796", "text": "function dropEndingNewline(string) {\n\t return string[string.length - 1] === '\\n' ? string.slice(0, -1) : string;\n\t}", "title": "" }, { "docid": "5c5edf972d542a24db8ccd61fa41079c", "score": "0.56710833", "text": "function trim(strText) { \n\t\t// this will get rid of leading spaces\n\t\twhile (strText.substring(0,1) == ' ')\n\t\t\tstrText = strText.substring(1, strText.length);\n\n\t\t// this will get rid of trailing spaces\n\t\twhile (strText.substring(strText.length-1,strText.length) == ' ')\n\t\t\tstrText = strText.substring(0, strText.length-1);\n\t\tvar pos=0\n\t\tvar tevePos=0\n\t\twhile(strText.indexOf(\"\\n\",pos)>-1)\n\t\t{\n\t\t\ttevePos=strText.indexOf(\"\\n\",pos)\n\t\t\tpos=tevePos+1\n\t\t}\n\t\t\n\t return strText;\n}", "title": "" }, { "docid": "08334de81edc0eff846a69f920c48261", "score": "0.5660273", "text": "function dropFinalNL(str) {\n var lfIdx = str.lastIndexOf(\"\\n\");\n return (lfIdx == -1) ? str : str.substring(0,lfIdx);\n}", "title": "" }, { "docid": "33fe5bd27d1d517a9159d4c0e03badc3", "score": "0.5640379", "text": "function trimHelp(str) {\n return str.replace(/^\\n/, '').replace(/\\n$/, '');\n}", "title": "" }, { "docid": "b3eb31015cf643d7384e4b1913f27809", "score": "0.56384194", "text": "toString() {\n let lines = this._result.split('\\n');\n let prefix = this.prefix;\n\n if (lines.length >= LARGE_RESULT_LINES) {\n lines.unshift('');\n prefix = this.undent + ' // ';\n }\n\n lines = lines.map((line, i) =>\n i === 0 ? '// \\u21e8 ' + line : prefix + line\n );\n return this.bare + lines.join('\\n');\n }", "title": "" }, { "docid": "41e46833d02d3410f78b9d0e1686da04", "score": "0.5630018", "text": "function stripCSMultiline(code) {\n // Really simple heuristic for coffeescript:\n // Just scan the multiline quote and comment delimeters, and\n // omit parts of the code within those when scanning.\n var parts = code.split(/(###|\\/\\/\\/|\"\"\"|'''|#|\\n)/);\n var keep = [],\n inside = null,\n hadline = false,\n ignoreline = false;\n for (var j = 0; j < parts.length; ++j) {\n var part = parts[j];\n if (ignoreline) {\n if (part === '\\n') {\n ignoreline = false;\n } else {\n continue;\n }\n }\n if (inside) {\n if (part === '\\n' && !hadline) {\n hadline = true;\n keep.push(part);\n }\n if (part === inside) {\n hadline = false;\n part = null;\n }\n continue;\n }\n if (part === '#') {\n ignoreline = true;\n continue;\n }\n if (/^(?:###|\"\"\"|'''|\\/\\/\\/)$/.test(part)) {\n inside = part;\n continue;\n }\n keep.push(part);\n }\n return keep.join('');\n}", "title": "" }, { "docid": "2b1f4c4fc283e30fc9196a5a53a7ef6a", "score": "0.56292343", "text": "function cleanLineBreaks(code) {\n\t\tvar openSpans = [],\n\t\t\tmatcher = /<\\/?span[^>]*>|\\r\\n|\\r|\\n/ig,\n\t\t\tnewline = /\\r\\n|\\r|\\n/,\n\t\t\tclosingTag = /^<\\//;\n\n\t\treturn code.replace(matcher, function(match) {\n\t\t\tif(newline.test(match)) {\n\t\t\t\tif(openSpans.length) {\n\t\t\t\t\treturn openSpans.map(function() { return '</span>' }).join('') + match + openSpans.join('');\n\t\t\t\t} else {\n\t\t\t\t\treturn match;\n\t\t\t\t}\n\t\t\t} else if(closingTag.test(match)) {\n\t\t\t\topenSpans.pop();\n\t\t\t\treturn match;\n\t\t\t} else {\n\t\t\t\topenSpans.push(match);\n\t\t\t\treturn match;\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "dfc08fdda3f70ec3a5f2d8ff4d969449", "score": "0.5619714", "text": "_trim(str) {\n // cannot just use trim() to preserve the first line indentation (if any).\n return str.replace(/^\\s*\\n+/g, '').trimEnd();\n }", "title": "" }, { "docid": "f2b7050919e805b1a86422ad31f2cc94", "score": "0.56094897", "text": "function outdentOneSpace() {\n utilitymanager_1.um.utilityManager({\n utilType: utilitymanager_1.um.TIXUtilityType.utLineUtility,\n sp: utilitymanager_1.um.TIXSelPolicy.All,\n }, function (up) { return up.intext !== '' && up.intext[0] === ' ' ?\n up.intext.substr(1) : up.intext; });\n }", "title": "" }, { "docid": "b6cedd884c74afe70920abe536dae828", "score": "0.56009454", "text": "function stripAndCollapse( value ) {\n \t\tvar tokens = value.match( rnothtmlwhite ) || [];\n \t\treturn tokens.join( \" \" );\n \t}", "title": "" }, { "docid": "a72b656678b5acddbe9df449c7524d7b", "score": "0.5597841", "text": "function filterWhitespace(string) {\n return string.trim().replace(/(\\r\\n|\\n|\\r|↵)/gm, \" \").replace(/ +/g, \" \");\n }", "title": "" }, { "docid": "03bdba5628ac14a8a020ce37f322de4e", "score": "0.5582182", "text": "function dropEndingNewline(string) {\n return string[string.length - 1] === '\\n' ? string.slice(0, -1) : string;\n }", "title": "" }, { "docid": "c3d1aed57b22f4bff2cf6a1b30a8c77c", "score": "0.5575199", "text": "_process_board_string(proto_board_string) {\n const that = this;\n if (proto_board_string.match(/\\n$/)) {\n return proto_board_string + \"\";\n }\n else {\n return proto_board_string + \"\\n\";\n }\n }", "title": "" }, { "docid": "ae1b991f19ecb4cc502823737341cd2d", "score": "0.55682355", "text": "function stripWhitespace(string) {\n return new CleanCSS({\n keepBreaks: true,\n processImport: false,\n noRebase: true\n }).minify(string.replace(/[\\r\\n]+/mg,' ').replace(/\\s+/gm,''));\n}", "title": "" }, { "docid": "8cf486290320e13f03fabe05c4a51ded", "score": "0.5563013", "text": "function cleanUp(lines)\n {\n if(!lines) return null\n else return lines\n .map(line =>\n line\n .replace(/ ->(?=\\s*$)/, ' ')\n .replace(/-or-/, ' ')\n .replace(/¦/g, ' ')\n .replace(/[«»]/g, '')\n .replace(/\\s+$/, '')\n .replace(/·/g, ' ')\n .replace(/-*→/g, '\\t')\n )\n // Trim empty lines off end\n .reduceRight\n ( (ls, l) => l || ls.length ? [l, ...ls] : []\n , []\n )\n\n }", "title": "" }, { "docid": "eaec9578339b669f7aaae4ef48f7396e", "score": "0.55624336", "text": "function graspText(arr) \n{\n for (var i = 0; i < arr.length; i++) \n {\n var text = getTextNode(arr[i]).replace(/[\\r\\n\\s]+/g,\"\");\n if (text) \n return getTextNode(arr[i]).replace(/[\\r\\n\\s]+/g,\" \");\n }\n\n return \"\";\n}", "title": "" }, { "docid": "d79a15e59ea6d455fadbbdbfdf3b3366", "score": "0.5560413", "text": "function removeEOL(str) {\n return str.replace('\\n', ' ');\n}", "title": "" }, { "docid": "538c522ee2e22ab0990d0cf43edecf2e", "score": "0.55522966", "text": "function detailsLateralRemovePreface() {\n\tvar newLine = true;\n\n}", "title": "" }, { "docid": "9b226d4ecc33edf01c0589c9afc2a8aa", "score": "0.5542333", "text": "function trimAndKeepIndents(text) {\n var lines = text.split('\\n');\n var firstLineWithContent = lines.find(function (l) { return l.trim(); });\n var indent;\n var match;\n if (match = /^\\s+/.exec(firstLineWithContent)) {\n indent = match[0].length;\n }\n else {\n indent = 0;\n }\n return lines.map(function (l) { return l.slice(indent); }).join('\\n');\n}", "title": "" }, { "docid": "9a8f07f168ad6a480f8292a2315eb5af", "score": "0.55414283", "text": "skipWhitespace() {\n const regex = new RegExp(/^/.source + Token.patterns.get(Token.TYPE_WHITESPACE).source);\n this.buffer = this.buffer.replace(regex, \"\");\n }", "title": "" }, { "docid": "f95853b6b1445abbea195999c7c2cd38", "score": "0.55411786", "text": "function strip(html) {\r\n var doc = new DOMParser().parseFromString(html, 'text/html');\r\n var clean = doc.body.textContent;\r\n clean = clean.replace(/(\\r\\n\\t|\\n|\\r\\t)/gm, \"\");\r\n return clean || \"\";\r\n }", "title": "" }, { "docid": "bfb0b7224ee7dd0963411a1d38c8d745", "score": "0.55379295", "text": "function removeTrailingWhitespace(s) {\n while (s.length > 0 && /\\s|\\n|\\r/.test(s[s.length - 1]))\n s = s.substring(0, s.length - 1);\n return s;\n }", "title": "" }, { "docid": "764e90dc0a997477d5782c6895f68de8", "score": "0.55334896", "text": "function editor_tools_strip_whitespace(str, return_stripped)\n{\n var strip_pre = '';\n var strip_post = '';\n\n // Strip whitespace from end of string.\n for (;;) {\n var lastchar = str.substring(str.length-1, str.length);\n if (lastchar == ' ' || lastchar == '\\r' ||\n lastchar == '\\n' || lastchar == '\\t') {\n strip_post = lastchar + strip_post;\n\n str = str.substring(0, str.length-1);\n } else {\n break;\n }\n }\n\n // Strip whitespace from start of string.\n for (;;) {\n var firstchar = str.substring(0,1);\n if (firstchar == ' ' || firstchar == '\\r' ||\n firstchar == '\\n' || firstchar == '\\t') {\n strip_pre += firstchar;\n str = str.substring(1);\n } else {\n break;\n }\n }\n\n if (return_stripped) {\n return new Array(str, strip_pre, strip_post);\n } else {\n return str;\n }\n}", "title": "" }, { "docid": "8ea0180ced0541ce9e94328b23e22f8c", "score": "0.55332994", "text": "function handleEndingNewline(text) {\n return text.slice(-1) == \"\\n\" ? text.substring(0, text.length - 1) : text;\n}", "title": "" }, { "docid": "024cadfa1ca06300db4ca985d54e2fa5", "score": "0.5530787", "text": "function stripWhitespace(string) {\n return string.replace(/[\\r\\n]+/mg, ' ').replace(/\\s+/gm, '');\n }", "title": "" }, { "docid": "84b734f532ee9b5bfc01a4f306fce439", "score": "0.55263567", "text": "function preprocess (src) {\n // Remove headers with no bodies\n let newSrc = src.replace(emptyHeaderRegex, function (match, header, rest) {\n return rest\n })\n\n // Replace single spaces in lists\n newSrc = newSrc.replace(singleListSpaceRegex, function (match, before, after) {\n return before + '\\n\\n\\n' + after\n })\n\n // Add style to timestamps\n newSrc = newSrc.replace(timestampRegex, function (match, timestamp) {\n return '<span class=\"timestamp\">' + timestamp + '</span>'\n })\n\n // Add style to checkboxes\n newSrc = newSrc.replace(doneItemRegex, function (match, bulletWithSpace, bullet, item) {\n return bulletWithSpace + ' [x] ' + item\n })\n\n return newSrc\n}", "title": "" }, { "docid": "60e10454c1b8eb59dba33a14927bf603", "score": "0.55240905", "text": "function reprs( s ) { return s.replace( /\\n/g, \"\\\\n\" ).replace( /\\t/g, \"\\\\t\" ); }", "title": "" }, { "docid": "a2cb0a09faf8b0fc9633b2be65749e5c", "score": "0.5521909", "text": "function stripper(s){\n return s.replace(/\\s\\s+/g, ' ').replace(/^\\s/,'').replace(/\\s$/,'');\n }", "title": "" }, { "docid": "c906e57daec92fc2ff51412821b0c014", "score": "0.5520296", "text": "function myTrim(x) {\r\n return x.replace(/(^[ \\t]*\\n)/gm, \"\");\r\n}", "title": "" }, { "docid": "179232525fa54ba90fa7e3ade908e129", "score": "0.55147105", "text": "function clean(s) {\n return s.replace(/\"\\n\"/g, \"\").replace(/\\n/g, \"\").replace(/\\\\\"/g, '\"');\n }", "title": "" }, { "docid": "00fa3c0f400970ab951450aeb131be27", "score": "0.5506264", "text": "function dropEndingNewline(string) {\r\n return string[string.length - 1] === '\\n' ? string.slice(0, -1) : string;\r\n}", "title": "" }, { "docid": "1d2fbc6d6ce7bc1e9d9465030744a5b7", "score": "0.5502222", "text": "function stripAndCollapse( value ) {\n \t\tvar tokens = value.match( rnothtmlwhite ) || [];\n \t\treturn tokens.join( \" \" );\n \t}", "title": "" }, { "docid": "6c4a530609720a88683db4218fea4da3", "score": "0.550193", "text": "function stripAndCollapse( value ) {\r\n\t\tvar tokens = value.match( rnothtmlwhite ) || [];\r\n\t\treturn tokens.join( \" \" );\r\n\t}", "title": "" }, { "docid": "6c4a530609720a88683db4218fea4da3", "score": "0.550193", "text": "function stripAndCollapse( value ) {\r\n\t\tvar tokens = value.match( rnothtmlwhite ) || [];\r\n\t\treturn tokens.join( \" \" );\r\n\t}", "title": "" }, { "docid": "6c4a530609720a88683db4218fea4da3", "score": "0.550193", "text": "function stripAndCollapse( value ) {\r\n\t\tvar tokens = value.match( rnothtmlwhite ) || [];\r\n\t\treturn tokens.join( \" \" );\r\n\t}", "title": "" }, { "docid": "6c4a530609720a88683db4218fea4da3", "score": "0.550193", "text": "function stripAndCollapse( value ) {\r\n\t\tvar tokens = value.match( rnothtmlwhite ) || [];\r\n\t\treturn tokens.join( \" \" );\r\n\t}", "title": "" }, { "docid": "799e35a67cb73f85b1d11a3fc941b99f", "score": "0.54960847", "text": "function stripAndCollapse( value ) {\n\t\t\tvar tokens = value.match( rnothtmlwhite ) || [];\n\t\t\treturn tokens.join( \" \" );\n\t\t}", "title": "" } ]
e8b03ccf72ab7a2acbd1505b255c5a68
Successful forgotPassword event function
[ { "docid": "b634c0f9aca154a146379f2d1f39a93e", "score": "0.7797525", "text": "function onForgotPassword( result )\r\n{\r\n debug( 'forgot-password: ' + JSON.stringify( result ) );\r\n}", "title": "" } ]
[ { "docid": "9dfe98eb3f3b55ab39cb4ed84f6ed934", "score": "0.75838006", "text": "function ForgotPass(e) {\n firebase\n .auth()\n .sendPasswordResetEmail(this.email)\n .then(\n () => {\n this.success_msg_forgot = \"Check your mail!\";\n },\n (err) => {\n this.err_msg_forgot = err.message;\n }\n );\n e.preventDefault();\n}", "title": "" }, { "docid": "373a373a3b3b9a9b1a3f89faa7925082", "score": "0.75031596", "text": "function onForgotPasswordError( result )\r\n{\r\n debug( 'forgot-password-error: ' + JSON.stringify( result ) );\r\n}", "title": "" }, { "docid": "c74459a5360f75d135fc505f008acd82", "score": "0.73235947", "text": "function forgotPassword(){\n var emailAddress = document.getElementById(\"retype-email\");\n\n auth.sendPasswordResetEmail(emailAddress).then(function() {\n $('#forgotPasswordDiv').hide();\n $('.login-html').show();\n alert(\"email sent\")\n }).catch(function(error) {\n alert(error);\n });\n }", "title": "" }, { "docid": "5ba85474b26d2c78e23d32e68cd8d359", "score": "0.7309088", "text": "function forgotpw() {\r\n\tvar data = {};\r\n\tdata.error = null;\r\n\tif (req.data.email != null) {\r\n\t\tvar user = app.getObjects(\"User\",{email:req.data.email})[0];\r\n\t\tif (user) {\r\n\t\t\tvar random = new Date().valueOf() + user.username;\r\n\t\t\tuser.id = random.md5();\r\n\t\t\tuser.reset_sent = true;\r\n\t\t\tuser.send_reset();\r\n\t\t\tres.redirect(this.getURI(\"login?notice=true\"));\r\n\t\t\treturn;\r\n\t\t} else {\r\n\t\t\tdata.error = \"No user exists with the specified Email Address.\";\r\n\t\t}\r\n\t}\r\n\treturn this.manage_forgotpw_view(data);\r\n}", "title": "" }, { "docid": "fd6664e7526a7344f3bcabcf8bf2d538", "score": "0.7307404", "text": "function forgot_password(){\n\n\n\tvar userEmail = document.getElementById(\"email_field\").value;\n\tvar userPass = document.getElementById(\"password_field\").value;\n\t\n\tvar auth = firebase.auth();\n\tvar emailAddress = document.getElementById(\"email_field\").value;\n\n\tauth.sendPasswordResetEmail(emailAddress).then(function() {\n\t// Email sent.\n\t\twindow.alert('Email Sent');\n\t}).catch(function(error) {\n\t// An error happened.\n\t\tvar errorCode = error.code;\n\t\tvar errorMessage = error.message;\n\t\tif(errorCode ==\"auth/invalid-email\") {\n\t\t\talert(errorMessage);\n\t\t} else if (errorCode == \"auth/user-not-found\") {\n\t\t\talert(errorMessage);\n\t\t\t\n\t\t}\n\t\tconsole.log(error);\n\t});\n\n\t\n}", "title": "" }, { "docid": "9e277945f268979c43a3a7f305d81cdd", "score": "0.72243315", "text": "async forgotPassword() {\n Keyboard.dismiss()\n await Auth.forgotPassword(this.state.email)\n .then(data => {\n console.log('New code sent', data)\n Alert.alert(i18n.t('A verification code has been sent to your email'))\n this.setState({ stage: '2' })\n })\n .catch(err => {\n if (!err.message) {\n console.log('Error while sending verification code: ', err)\n Alert.alert(i18n.t('Error while sending verification code: '), err)\n } else {\n console.log('Error while sending verification code: ', err.message)\n Alert.alert(i18n.t('Error while sending verification code: '), err.message)\n }\n })\n }", "title": "" }, { "docid": "26aeb07233f05fa7f2ce64db93f030e1", "score": "0.69893193", "text": "function resetPass2() {\n\tvar emailAddress = firebase.auth().currentUser.email;\n\n\tfirebase.auth().sendPasswordResetEmail(emailAddress).then(function() {\n\t alert(\"Reset email sent! Please check your inbox and follow the instructions in the email.\")\n\t}).catch(function(error) {\n\t alert(error.message);\n\t console.log(error);\n\t});\n}", "title": "" }, { "docid": "de82b4e4cf324105c193ac0b9687f8e0", "score": "0.68785506", "text": "async forgot_password(ctx) {\n const { body } = ctx.request\n console.log('There are things missing', body)\n const { email } = await forgotSchema.validate(body, {\n abortEarly: false\n })\n\n const user = await User.findByEmail(email)\n var token = generateToken(body)\n\n if (!user) {\n throw new UnauthorizedError('Email is invalid')\n } else {\n user.password_reset_token = token\n user.reset_password = 1\n var data = {\n head: 'Admin',\n name: user.name,\n recovery_token: token,\n link: 'http://18.218.142.32:5000/recover-password?token=' + token\n }\n await user.updateResetPassword(user)\n await user.updateResetPasswordToken(user)\n var mail = await sendEmailToUser(\n 'FORGOT_PASSWORD',\n data,\n user.email,\n '[email protected]',\n 'Forgot Password Request Acknowledgement',\n ''\n )\n console.log('What the hell with the email', mail)\n }\n\n ctx.body = {\n status: 200,\n message: 'An email with the resent link has been sent to the user'\n }\n }", "title": "" }, { "docid": "3f101b3ed9d9ced97de08c270c479888", "score": "0.683898", "text": "async sendpasswordResetConfrim() { await this.send('passwordResetConfirm', 'You password has been reset successully!')}", "title": "" }, { "docid": "dc92f7729b39daa059400a39592daa83", "score": "0.6821536", "text": "changePassword() {\n var user = firebase.auth().currentUser\n var nav = this.props.navigation\n\n auth.sendPasswordResetEmail(user.email).then(function() {\n alert(\"Check your account's email to reset your password!\")\n nav.navigate('Login')\n }).catch(function(error) {\n console.log('Error sending password reset email: ' + error.message)\n alert(\"Error sending password reset email: \" + error.message)\n })\n }", "title": "" }, { "docid": "af1dbc52ee1b7c98f87f466d2d64fa61", "score": "0.6817831", "text": "function forgotPassword()\n{\n var lang = 'en';\n if ('lang' in args)\n lang = args.lang;\n var form = this.form;\n\n // change the action so the values are submitted to the\n // password reset function instead of the sign-on function\n form.password.value = '';\n form.action = 'forgotPassword.php?lang=' + lang;\n form.submit();\n}", "title": "" }, { "docid": "80b4d4fbc2cdc30020c61b334b2cc9ca", "score": "0.68156606", "text": "passwordResetEmail(email) {\n console.log('email', email)\n // firebase.auth().sendPasswordResetEmail(email)\n // .then( () => alert(`Password reset has been sent to this email address: ${email}`),\n // // error\n // () => alert('The email you entered was either invalid or does not exist!'))\n }", "title": "" }, { "docid": "a8f07a61bec683907991933a6dd137f8", "score": "0.6814199", "text": "function forgotPasswordFormCallback(resultData){\n $('#forgotPasswrod').prop('disabled',false);\n myJsMain.commonFunction.hidePleaseWait();\n myJsMain.commonFunction.tidiitAlert('Tidiit System Message',resultData.msg,200);\n }", "title": "" }, { "docid": "3d3ed692b5dc9ff06698e72e78ff449d", "score": "0.6769825", "text": "async confirmPasswordReset({ commit }, { code, newPassword }) {\n try {\n const db = await database();\n const auth = await db.auth();\n await auth.confirmPasswordReset(code, newPassword);\n commit(\"@firebase/confirmPasswordReset\");\n }\n catch (e) {\n commit(\"@firebase/error\", {\n stack: e.stack,\n message: `Failured to confirm password reset: ${e.message} [ ${e.code} ${e.name} ]`\n });\n throw e;\n }\n }", "title": "" }, { "docid": "97bcb938e2181610f482e1e86385812e", "score": "0.6751338", "text": "passwordReset(email){\n return this.auth.sendPasswordResetEmail(email);\n }", "title": "" }, { "docid": "9cc1a4da01ae5103b5cd5637ce3d9556", "score": "0.6741318", "text": "async forgotPasswordSubmit() {\n Keyboard.dismiss()\n this.setState({ isLoading: true })\n const { email, authcode, password } = this.state\n await Auth.forgotPasswordSubmit(email, authcode, password)\n .then(() => {\n this.setState({ isLoading: false })\n console.log('Your password has been reset')\n Alert.alert(i18n.t('Your password has been reset'))\n this.setState({ stage: '1' })\n this.props.navigation.navigate('SignIn')\n })\n .catch(err => {\n this.setState({ isLoading: false })\n if (!err.message) {\n console.log('Error while confirming the new password: ', err)\n Alert.alert(i18n.t('Error while confirming the new password: '), err)\n } else {\n console.log('Error while confirming the new password: ', err.message)\n Alert.alert(i18n.t('Error while confirming the new password: '), err.message)\n }\n })\n }", "title": "" }, { "docid": "b8721f12198f6117b00004479fff4f4c", "score": "0.6709566", "text": "function forgotPasswordHandler() {\n document.getElementById(\"forgot-password-button\").onclick = function () {\n window.api.send(\"toDeleteAllJournals\", { data: \"\" });\n passwordPlaceholderHandler();\n }\n }", "title": "" }, { "docid": "b82ef710bca7d57978d1365cbeae909a", "score": "0.66973513", "text": "function testConfirmPasswordReset_success() {\n var userEmail = '[email protected]';\n var newPassword = 'newPass';\n var code = 'PASSWORD_RESET_OOB_CODE';\n var expectedResponse = {\n 'email': userEmail\n };\n asyncTestCase.waitForSignals(1);\n assertSendXhrAndRunCallback(\n 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/resetPass' +\n 'word?key=apiKey',\n 'POST',\n goog.json.serialize({\n 'oobCode': code,\n 'newPassword': newPassword\n }),\n fireauth.RpcHandler.DEFAULT_FIREBASE_HEADERS_,\n delay,\n expectedResponse\n );\n rpcHandler.confirmPasswordReset(code, newPassword).then(function (email) {\n assertEquals(userEmail, email);\n asyncTestCase.signal();\n });\n}", "title": "" }, { "docid": "4e196b1dc75d9260afe79251075c9f69", "score": "0.668043", "text": "getForgotPassword(event) {\n event.preventDefault(); //don't submit\n this.props.forgotPasswordCallback(this.state.email);\n }", "title": "" }, { "docid": "361b34ac449cfe95ed8f265056c0e7f4", "score": "0.6649134", "text": "function forgotpassword(){\n\n\t if($('#email').val()==\"\")\n\t {\n\t\t inlineMsg('email','<strong> You must enter your Username/Email :</strong>',2);\n\t\t return false;\n\t }\n\t if(($('#email').val().length < 4)){\n\t\t\tinlineMsg('email','<strong>Minimum length for Username/Email is 4</strong>',2);\n\t\t\treturn false; \n\t\t\t}\n\n\t}", "title": "" }, { "docid": "9ce39becc36dcb5e3d5e1e7b64a1d0d3", "score": "0.66161597", "text": "function doForgotPassword() \n{ \n var token = cocoon.request.get(\"token\");\n\n if (token == null) \n {\n // We have no token, this is the initial form. First ask the user for their email address\n // and then send them a token.\n \n var email = cocoon.request.getParameter(\"email\");\n \n var errors = new Array();\n do {\n cocoon.sendPageAndWait(\"forgot/start\",{\"email\" : email, \"errors\" : errors.join(',')});\n \n email = cocoon.request.getParameter(\"email\");\n errors = new Array();\n\n var epersonFound = (EPerson.findByEmail(getDSContext(),email) != null);\n\n if (!epersonFound)\n {\n // No eperson found for the given address, set the field in error and let \n // the user try again.\n errors = new Array(\"email\");\n continue;\n }\n\n // An Eperson was found for the given email, so use the forgot password \n // mechanism. This may throw a AddressException if the email is ill-formed.\n AccountManager.sendForgotPasswordInfo(getDSContext(),email);\n getDSContext().commit();\n } while (errors.length > 0)\n \n cocoon.sendPage(\"forgot/verify\", {\"email\":email});\n } \n else \n {\n // We have a token. Find out who the it's for\n var email = AccountManager.getEmail(getDSContext(), token);\n\n if (email == null) \n {\n cocoon.sendPage(\"forgot/invalid-token\");\n return;\n }\n\n var epersonFound = (AccountManager.getEPerson(getDSContext(), token) != null);\n\n if (!epersonFound)\n {\n cocoon.sendPage(\"forgot/invalid-token\");\n return;\n }\n\n var errors = new Array();\n\n do {\n cocoon.sendPageAndWait(\"forgot/reset\", { \"email\" : email, \"errors\" : errors.join(',') });\n\n // Get the eperson associated with the password change\n var eperson = AccountManager.getEPerson(getDSContext(), token);\n\n // Temporaraly log the user in so that they can update their password.\n getDSContext().setCurrentUser(eperson);\n\n errors = updatePassword(eperson);\n\n getDSContext().setCurrentUser(null);\n\n } while (errors.length > 0)\n\n // Log the user in and remove the token.\n AuthenticationUtil.logIn(getObjectModel(),eperson);\n AccountManager.deleteToken(getDSContext(), token);\n getDSContext().commit();\n\n cocoon.sendPage(\"forgot/finished\");\n }\n}", "title": "" }, { "docid": "0b832077f0eb2620693eb38e1826dd27", "score": "0.661304", "text": "function onPasswordReset(){\n const { email } = this.state\n Alert.alert(\n 'Reset Password',\n 'Are you sure you want to reset your account password? ',\n [\n {text: 'Cancel', onPress: () => {return null}},\n {text: 'Confirm', onPress: () => { \n firebase.auth().sendPasswordResetEmail(email)\n .then((email) => {\n firebase.auth().signOut()\n .then(this.onSuccessfullLogOut.bind(this))\n .catch(this.onFailuredLogOut.bind(this))\n })\n }}\n ]\n )\n}", "title": "" }, { "docid": "74892825acb16105e0b833066ef20e5e", "score": "0.6595147", "text": "checkPassword() {\n Meteor.call('user.checkPassword', this.state.password, (err, resp) => {\n // email did not pass regex or is empty or already registered\n if (err) {\n // display err msg\n this.setState({ passwordHelpText: err.reason, isPasswordValid: false })\n } else if (resp) {\n // email is good, remove err msg & display success\n if (this.state.passwordHelpText) {\n this.setState({ passwordHelpText: null })\n }\n // displays the success badge\n this.setState({ isPasswordValid: true })\n }\n })\n }", "title": "" }, { "docid": "e8d7fb6e975d92901d6f6a858ae9fb88", "score": "0.6590559", "text": "function sendPasswordReset() {\r\n var email = document.getElementById('email').value;\r\n // [START sendpasswordemail]\r\n firebase.auth().sendPasswordResetEmail(email).then(function() {\r\n // Password Reset Email Sent!\r\n // [START_EXCLUDE]\r\n alert('Password Reset Email Sent!');\r\n // [END_EXCLUDE]\r\n }).catch(function(error) {\r\n // Handle Errors here.\r\n var errorCode = error.code;\r\n var errorMessage = error.message;\r\n // [START_EXCLUDE]\r\n if (errorCode == 'auth/invalid-email') {\r\n alert(errorMessage);\r\n } else if (errorCode == 'auth/user-not-found') {\r\n alert(errorMessage);\r\n }\r\n console.log(error);\r\n // [END_EXCLUDE]\r\n });\r\n // [END sendpasswordemail];\r\n }", "title": "" }, { "docid": "b1df4c4a8bc0b4d1e76267420ecf6802", "score": "0.6576356", "text": "function handleResetPasswordButtonClick() {\n var dynamicData = {},\n repeatPassword = \"\";\n\n dynamicData[\"oldPassword\"] = DOM.$oldPasswordInput.val();\n dynamicData[\"newPassword\"] = DOM.$newPasswordInputs.eq(0).val();\n repeatPassword = DOM.$newPasswordInputs.eq(1).val();\n\n //Check that user has enter a old password and a new password\n if (\n dynamicData[\"oldPassword\"].length <= 0 ||\n dynamicData[\"newPassword\"].length <= 0\n ) {\n alert(\"Please enter both your old password and a new password\");\n } else {\n //Check that the new password matches the reapeat\n if (!(dynamicData[\"newPassword\"] == repeatPassword)) {\n alert(\"Entered password's dont match. Please try again.\");\n } else {\n resetPasswordInDB(dynamicData).done(function(data) {\n alert(data);\n });\n }\n }\n }", "title": "" }, { "docid": "d867f0b0cc72fc663cfbb668a56a5ca5", "score": "0.6564349", "text": "function _forgotPassword() {\n var $forgotPasswordForm = $(\"#recoverPasswordForm\");\n $forgotPasswordForm.validator({\n disable: false\n }).on('submit', _onForgotFormSubmit)\n .off('input.bs.validator focusout.bs.validator');\n /*\n comentado porque la modal de recuperar contraseña es la misma que la de login al cambiar de una a otra o al cerrarse aparecen los form reseteados\n $(\"#recover-password\").on(\"hidden.bs.modal\", function(event) {\n var button = $(event.relatedTarget);\n var modal = $(this);\n $(\"#recover-content\").show();\n modal.find(\"#emailRecover\").val(\"\");\n modal.find(\"#confirmation-msg\").addClass(\"hide\");\n modal.find(\".form-group\").removeClass(\"has-error\");\n modal.find(\".help-block\").empty();\n modal.find(\".js-error-message\").empty();\n modal.find('[type=\"submit\"]').prop(\"disabled\", false);\n });*/\n \n }", "title": "" }, { "docid": "0ba00725bcad010c1648ac96eafd1c76", "score": "0.6549705", "text": "function resetPasswordSuccess() {\n var $formState = $('.reset-password-success');\n\n // check if reset password form was successfully submited.\n if (!$formState.length) {\n return;\n }\n\n // show success message\n $('#ResetSuccess').removeClass('hide');\n }", "title": "" }, { "docid": "0ba00725bcad010c1648ac96eafd1c76", "score": "0.6549705", "text": "function resetPasswordSuccess() {\n var $formState = $('.reset-password-success');\n\n // check if reset password form was successfully submited.\n if (!$formState.length) {\n return;\n }\n\n // show success message\n $('#ResetSuccess').removeClass('hide');\n }", "title": "" }, { "docid": "46f4e7028b154275a9ff747ab364daf4", "score": "0.654663", "text": "onChangePassword(e) {\n e.preventDefault();\n let isFormValid = isValidForm(this.resetPassSchema, this.refs);\n if (!isFormValid) {\n if (!this.state.isClicked) {\n this.setState({ isClicked: true });\n }\n this.props.notifyToaster(NOTIFY_ERROR, { message: this.refs.password.state.error });\n return false;\n }\n let obj = getForm(this.resetPassSchema, this.refs);\n let _this = this;\n let {strings} = this.props;\n resetPassword(this.state.userId, obj.password).then(function (res) {\n if (res.success) {\n _this.setState({ isPassUpdated: true });\n }\n else {\n let errorMsg = _this.props.notify.error(res.error, strings);\n _this.refs.password.setState({ error: errorMsg });\n }\n }).catch(function (err) {\n _this.props.notifyToaster(NOTIFY_ERROR);\n });\n }", "title": "" }, { "docid": "96cc3a1ce2574650b538c4f6e2d18366", "score": "0.6536266", "text": "async sendResetLinkEmail({ request, session, response }) {\n const validation = await validate(request.input('email'), {\n email: 'required|email'\n })\n\n if (validation.fails()) {\n session.withErrors(validation.messages()).flashAll()\n\n return response.redirect('back')\n }\n\n try {\n const user = await User.findBy('email', request.input('email'))\n\n await Token.query()\n .where('user_id', user.id)\n .where('type', 'password')\n .delete()\n\n const token = new Token()\n token.token = Encryption.encrypt(randToken.generate(16))\n token.type = 'password'\n\n await user.tokens().save(token)\n\n Event.fire('forgot::password', {\n user: user.toJSON(),\n token: token.token\n })\n\n session.flash({\n notification: {\n type: 'success',\n message: 'A passowrd reset link has been sent to your email address.'\n }\n })\n\n return response.redirect('back')\n } catch (error) {\n Logger.error(error)\n\n // we do not tell if the user does not exist\n session.flash({\n notification: {\n type: 'success',\n message: 'A passowrd reset link has been sent to your email address.'\n }\n })\n\n return response.redirect('back')\n }\n }", "title": "" }, { "docid": "a82b1df81faba7dbde3a874bbc669eef", "score": "0.6509061", "text": "function resetPasswordSuccess() {\n var $formState = $('.reset-password-success');\n\n // check if reset password form was successfully submited.\n if (!$formState.length) {\n return;\n }\n\n // show success message\n $('#ResetSuccess').removeClass('hide');\n }", "title": "" }, { "docid": "208c361f68fdf97551a57c5b47c7f84b", "score": "0.65049374", "text": "function onChangePasswordComplete(response)\n\t{\n\t\tvar notification = $('#notification');\n\t\tnotification.slideUp(\"fast\");\n\t\tconsole.log(response);\n\t\tlogError(response.responseText);\n\n\t\tswitch (response.status)\n\t\t{\n\t\t\tcase 200:\n\t\t\t\tmessage = 'Votre mot de passe a bien été modifié. ';\n\t\t\t\tnotification.slideDown(\"slow\", verifyButton);\n\t\t\t\t$('#notification').removeClass('red').addClass('green');\n\t\t\t\t//setTimeout(function(){ window.location = 'Connect'; }, 2000);\n\t\t\t\tbreak;\n\n\t\t\tcase 409:\t// TODO: Change notification's color and bring shawdow to it\n\t\t\t\tmessage = 'Votre ancien mot de passe est incorrect.';\n\t\t\t\t$('#notification').removeClass('green').addClass('red');\n\t\t\t\tnotification.slideDown(\"slow\", verifyButton);\n\t\t\t\tbreak;\n\n\t\t\tcase 424:\t// TODO: Change notification's color and bring shawdow to it\n\t\t\t\tmessage = 'Une erreur s\\'est produite, veuillez recommencer.';\n\t\t\t\t$('#notification').removeClass('green').addClass('red');\n\t\t\t\tnotification.slideDown(\"slow\", verifyButton);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tmessage = 'Unhandled exception';\n\t\t\t\tbreak;\n\t\t}\n\t\t$('#notification_text').text(message);\n\t}", "title": "" }, { "docid": "95ff645ae77fe1441c61880f582f147b", "score": "0.64906913", "text": "function configureForgotPassword () {\n\tvar throttledpost = Utils.UI.throttle(2500, $.post);\n\n\tvar forgotcoordinator = new Coordinator.Coordinator({\n\t\tset: { sent: false },\n\t\tsuccess: function (conds, data) {\n\t\t\t$('#loginpassworderror').text(\n\t\t\t\tloginForgotPasswordFixtext('success')\n\t\t\t).slideFadeIn();\t\t\n\t\t},\n\t\tfailure: function (conds, data) {\n\t\t\t$('#loginpassworderror').text(\n\t\t\t\tloginForgotPasswordFixtext(data.sent)\n\t\t\t).slideFadeIn();\n\n\t\t\tif (data.sent === 'no-identifier' || data.sent === 'user-not-found') {\n\t\t\t\t$('#username').addClass('error').focus();\n\t\t\t}\n\t\t}\n\t});\n\n\t$('#forgotpassword').on(\"click\", function () {\n\t\tvar username = $.trim($('#username').val());\n\n\t\tif (!username) {\n\t\t\tforgotcoordinator.set('sent', false, 'no-identifier');\n\t\t\treturn;\n\t\t}\n\n\t\tvar data = {\n\t\t\tidentifier: username\n\t\t};\n\n\t\tthrottledpost('/1.0/internal/account/password-reset/issue-token/', data, function (response) {\n\t\t\tif (!response) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresponse = $.parseJSON(response);\n\n\t\t\tif (response.success) {\n\t\t\t\tforgotcoordinator.set('sent', true);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tforgotcoordinator.set('sent', false, response.reason);\n\t\t\t}\n\t\t});\n\t});\n\n\tvar wasreset = $.url(document.location.href).param('password_was_reset');\n\tif (wasreset) {\n\t\t$('#pitch')\n\t\t\t.text(_('Your password was reset.'))\n\t\t\t.show();\n\t}\n}", "title": "" }, { "docid": "6f8a47f03715432ae88309cad1c866de", "score": "0.64888144", "text": "resetPassword() {\n if (this.checkFieldValidation() && this.emailAddress !== '') {\n // request data is TBD\n const requestdata = {\n userId: this.emailAddress,\n };\n // $emit will emit/send requestData to parent component.\n const requestConfig = {};\n requestConfig.params = requestdata;\n this.registrationLoginService.forgotPassword(requestConfig, this.handleResponse, this.handleError);\n this.$refs.spinner.showSpinner();\n }\n }", "title": "" }, { "docid": "f39f27d3ffba60cd596e6b0b3ae58d04", "score": "0.645583", "text": "async forgot_password(req, res) {\n try {\n let { email } = req.body;\n console.log(req.body);\n const user = await users.find_by_email(email);\n console.log(user);\n if (user.length != 0) {\n if (user[0].verified === false) {\n return res.json({\n statusCode: \"403\",\n error: \"please verify your email first\",\n });\n } else {\n const resetToken = await users.generate_reset_token(user);\n let subject = `Password Reset`;\n let html = `<h2>Netflix</h2>\n <h3>Dear ${user[0].name}, Seems like you forgot your password for Netflix account. if this is true, click below to reset your password.</h3>\n <button style=\"background-color: #338DFF; /* blue */\n border: none;\n color: white;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 16px;\n margin: 4px 2px;\n cursor: pointer;\"><a href=https://netflix-by-mohit.netlify.app/user/forgot_password/${resetToken}>Reset My Password</a></button>\n <p>copy paste this link to your browser:- https://netflix-by-mohit.netlify.app/user/forgot_password/${resetToken}</p> \n <p style=\"color:red;\">If you did not forgot your password you can safely ignore this email.</p>\n <p>Thank you</p>`;\n email1(user[0].email, subject, html);\n res.status(200).json({\n statusCode: 200,\n message: `We have send a reset password email to ${user[0].email}. Please click the reset password link to set a new password.`,\n });\n }\n } else\n return res.json({ statusCode: 403, error: \"email ID not found\" });\n } catch (err) {\n console.log(err.message);\n res.status(500).send(\"server error\");\n }\n }", "title": "" }, { "docid": "1ca346b720da58a03ad1f5b2357890c8", "score": "0.64553547", "text": "function seeForgotPassword()\r\n{\r\n var username = $( \"#seeLoginUsername\" ).val();\r\n player.UserRegistration.forgotPassword( username );\r\n}", "title": "" }, { "docid": "e39ac91fc4be3edd74d9fbec4f0ae843", "score": "0.6452685", "text": "handleResponse() {\n this.$refs.spinner.hideSpinner();\n this.resetButtonClicked = true;\n this.$emit('submit');\n this.forgotPasswordLabel = this.i18n.passwordResetPostLabel;\n this.forgotPasswordStatus = this.i18n.passwordResetPostDesc;\n globalEventBus.$emit('announce', this.forgotPasswordStatus);\n }", "title": "" }, { "docid": "89d4b90ef1893dd9e86ecda767d8da37", "score": "0.6448262", "text": "function forgotPass() {\n\twindow.location.href= \"/forgot\"\n}", "title": "" }, { "docid": "d8e122412509c21bfe59d8f5730c979c", "score": "0.6441357", "text": "async forgot_password(req, res) {\n try {\n let { email } = req.body\n const user = await users.find_by_email(email)\n\n if (user.dataValues.verified_email === false) {\n return res.json({ \"message\": \"please verify your email first\" })\n }\n else {\n const resetToken = await users.generate_reset_token(user)\n let subject = `Password Reset`\n let html = `<h2>ShubhKadam.com</h2>\n <h3>Dear ${user.dataValues.name}, Seems like you forgot your password for ShubhKadam.com account. if this is true, click below to reset your password.</h3>\n <button style=\"background-color: #338DFF; /* blue */\n border: none;\n color: white;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 16px;\n margin: 4px 2px;\n cursor: pointer;\"><a href=https://shubh-kadam-psql.herokuapp.com/user/forgot_password/${resetToken}\">Reset My Password</a></button> \n <p>copy paste this link to your browser:- https://shubh-kadam-psql.herokuapp.com/user/forgot_password/${resetToken}\n <p style=\"color:red;\">If you did not forgot your password you can safely ignore this email.</p>\n <p>Thank you for choosing ShubhKadam.com</p>`;\n email1(user.dataValues.email, subject, html)\n user.resetToken=resetToken\n await user.update({resetToken:resetToken})\n await user.save()\n res.status(200).json({ statuscode: 200, message: `We have send a reset password email to ${user.dataValues.email}. Please click the reset password link to set a new password.` })\n }\n\n } catch (err) {\n if (err.message === \"email not found\") return res.send(err.message)\n console.log(err.message)\n res.status(500).send(\"server error\")\n }\n }", "title": "" }, { "docid": "fd8e2ff740417bb3709adc507ada00b1", "score": "0.64407676", "text": "async reset_password(ctx) {\n const { body } = ctx.request\n console.log('There are things missing', body)\n const { email } = await forgotSchema.validate(body, {\n abortEarly: false\n })\n\n const user = await User.findByEmail(email)\n var token = generateToken(body)\n\n if (!user) {\n throw new UnauthorizedError('Email is invalid')\n } else {\n user.token = token\n var data = {\n name: user.name,\n recovery_token: token,\n link: 'http://18.218.142.32:5000/recover-password?token=' + token\n }\n await user.updateToken(user)\n var mail = await sendEmailToUser(\n 'FORGOT_PASSWORD',\n data,\n user.email,\n '[email protected]',\n 'Forgot Password Request Acknowledgement',\n ''\n )\n console.log('What the hell with the email', mail)\n }\n\n ctx.body = {\n status: 200,\n message: 'An email with the resent link has been sent to the user'\n }\n }", "title": "" }, { "docid": "72b5a152664b909253df561d59e21c74", "score": "0.6428915", "text": "async forgetPasswordReset({ request, response }){\n\t\tconst { email , newPasssword } = request.all();\n\t\ttry {\n\t\t\tlet user = await User.findBy('email',email);\n\t\t\tif(user){\n\t\t\t\tif(!user.forgetPasswordOtp){\n\t\t\t\t\tuser.password = newPasssword;\n\t\t\t\t\tuser.save();\n\t\t\t\t\treturn { success: true}\n\t\t\t\t}else { \n\t\t\t\t\treturn response.status(401).json({ success: false, msg: \"Please verify otp\"})\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\treturn response.status(401).json({ success: false, msg: \"User doesn't exist\"});\n\t\t\t}\n\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t\treturn response.status(500).json({ success: false});\n\t\t}\n\t}", "title": "" }, { "docid": "4d14fa685efcf284807135362f09c0b5", "score": "0.6427461", "text": "async passwordResetEmail(payload, loading, { update, onError }) {\n if (loading) loading(true);\n try {\n const res = await noAuthInstance.post(`${this.API_URL}/reset/`, payload);\n if (loading) loading(false);\n update(res);\n }\n catch (err) {\n if (loading) loading(false);\n onError(err);\n }\n }", "title": "" }, { "docid": "4ca2af7217fc147a44aead772b2da9ad", "score": "0.6415809", "text": "async sendPasswordReset () { await this.send('passwordReset', 'Your password reset token (only valid for 10 minutes)') }", "title": "" }, { "docid": "f06a73f1898d9ec2f7d0685e401c0954", "score": "0.64151955", "text": "function resetPasswordCallback(result)\n{\n\tif(result === false)\n\t{\n\t\t$(\"#modal\").modal({backdrop: \"static\", keyboard: false, show: true});\n\t\t$(\".modal-header\").html(\"Password Reset Failed\");\n\t\t$(\".modal-body\").html(\"<p>We had trouble resetting your password.<br/><br/>Want to refresh the page<br/>and try again?</p>\");\n\t\t$(\"#btn-confirm\").css(\"display\", \"none\");\n\t\t$(\"#btn-cancel\").click(function(){\n\t\t\t$(\"#btn-confirm\").css(\"display\", \"block\");\n\t\t\twindow.location = \"https://phood-buddy.com/login.html\";\n\t\t});\n\t}\n\telse\n\t{\n\t\t$(\"#modal\").modal({backdrop: \"static\", keyboard: false, show: true});\n\t\t$(\".modal-header\").html(\"Password Reset Success\");\n\t\t$(\".modal-body\").html(\"<p>Your reset password email has been sent.</p>\");\n\t\t$(\"#btn-confirm\").css(\"display\", \"none\");\n\t\t$(\"#btn-cancel\").click(function(){\n\t\t\t$(\"#btn-confirm\").css(\"display\", \"block\");\n\t\t\twindow.location = \"https://phood-buddy.com/login.html\";\n\t\t});\n\t}\n}", "title": "" }, { "docid": "e6b539a331860cd2dfaf52a5561baf68", "score": "0.6410838", "text": "function recoverPassword(e){\n //e.target points to the DOM where input name is equal to the name of the modal form (ie. '#recoverPassword' form)\n let target = $(e.target),\n securityAnswer1 = target.find('input[name=\"securityAnswer1\"]'),\n securityAnswer2 = target.find('input[name=\"securityAnswer2\"]'),\n email = target.find('input[name=\"email\"]'),\n newPassword = target.find('input[name=\"newPassword\"]'),\n confirmNewPassword = target.find('input[name=\"verifyNewPassword\"]');\n\n let formValid = securityAnswer1.get(0).checkValidity() &&\n securityAnswer2.get(0).checkValidity() &&\n email.get(0).checkValidity() &&\n newPassword.get(0).checkValidity() &&\n confirmNewPassword.get(0).checkValidity();\n if (formValid) {\n e.preventDefault();\n let url = SnippetsUrl + '?cmd=update_user';\n $.post(url, {\n securityAnswer1: securityAnswer1.val(),\n securityAnswer2: securityAnswer2.val(),\n email: email.val(),\n newPassword: newPassword.val(),\n verifyNewPassword: confirmNewPassword.val(),\n })\n .done(function(response) { //done is not being called and the new passwords\n if (response.status === 'OK') {\n userAlert('success', 'User successfully reset.');\n } else {\n userAlert('danger', response.errmsg);\n }\n })\n .fail(function(response) {\n userAlert('danger', 'Password recovery has failed.');\n })\n .always(function(response) {\n securityAnswer1.val(''); // reset form\n securityAnswer2.val('');\n email.val('');\n newPassword.val('');\n confirmNewPassword.val('');\n $('#loginModal').modal('hide');\n });\n } else { return true; } // when form isn't valid\n}", "title": "" }, { "docid": "3cda759de409e37f772b19f614ba8d38", "score": "0.63969666", "text": "function request() { return { type: loginConstants.FORGOT_PASSWORD_REQUEST } }", "title": "" }, { "docid": "ee9bb5cea45662d607790c716bc7a850", "score": "0.6390452", "text": "function forgotPassword() {\n var username = $('#username').val();\n var url = 'http://cryogen.live/recover';\n if (username)\n url += '?username=' + username;\n shell.openExternal(url);\n }", "title": "" }, { "docid": "2c6b0e6212932d075aeb23191502ac2f", "score": "0.6381764", "text": "async sendPasswordResetEmail(email) {\n return this.firebase.auth().sendPasswordResetEmail(email, {})\n }", "title": "" }, { "docid": "df270de0438c38166267af7f8e04f0d1", "score": "0.6365392", "text": "function forgotForm()\n\t {\t\t\n\t\t var data = $(\"#forgot_password\").serialize();\n\t\t\t \n\t\t $.ajax({\n\t\t\t \n\t\t type : 'POST',\n\t\t url : '../includes/admin_pwd_recovery.php',\n\t\t data : data,\n\t\t beforeSend: function()\n\t\t {\t\n\t\t\t $(\"#error\").fadeOut();\n\t\t\t $(\"#submit-btn\").html('<img src=\"../img/processing.gif\" width=\"30\" /> &nbsp; checking');\n\t\t },\n\t\t success : function(response)\n\t\t\t {\t\t\t\t\t\t\n\t\t\t\t if(response==\"sent\"){\n\t\t\t\t\t$(\"#error\").fadeIn(1000, function(){\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#error\").html('<div class=\"alert alert-success\"> <span class=\"glyphicon glyphicon-check\"></span> &nbsp; You have successfully reset your password. Check your inbox for your news password!</div>');\n\t\t\t\t\t $(\"#submit-btn\").html('<span class=\"fa fa-check\"></span> &nbsp; Sent');\n\t\t\t\t\t});\n\t\t\t\t }\n\t\t\t\t else if(response==\"e\"){\n\t\t\t\t\t$(\"#error\").fadeIn(1000, function(){\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#error\").html('<div class=\"alert alert-danger\"> <span class=\"glyphicon glyphicon-info-sign\"></span> &nbsp; There is an error sending mail!</div>');\n\t\t\t\t\t\t$(\"#submit-btn\").html('<i class=\"fa fa-envelope-o\" ></i> RESET MY PASSWORD');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t $(\"#error\").fadeIn(1000, function(){\t\t\t\t\t\t\n\t\t\t $(\"#error\").html('<div class=\"alert alert-danger\" style=\"font-size:12px;\"> <span class=\"glyphicon glyphicon-info-sign\"></span> &nbsp; '+response+' !</div>');\n\t\t\t $(\"#submit-btn\").html('<i class=\"fa fa-envelope-o\" ></i> RESET MY PASSWORD');\n\t\t\t\t\t\t\t\t });\n\t\t\t\t }\n\t\t\t}\n\t\t });\n\t\t\t return false;\n }", "title": "" }, { "docid": "2af8b53a981e55337e15d3472d46f389", "score": "0.6354778", "text": "function forgotPassword(req, res, next) {\n const { email } = req.body;\n const criteria = (email.indexOf('@') === -1) ? { phoneNumber: email } : { email };\n const isEmail = !(email.indexOf('@') === -1);\n\n const query = User.findOne(criteria);\n query.then((user) => { // eslint-disable-line consistent-return\n if (user) {\n // Generate and set OTP to user\n const otp = OTP.generate(6, { upperCase: false, specialChars: false, alphabets: false });\n // Send OTP Email if email given\n user.otp = otp; // eslint-disable-line no-param-reassign\n user.save()\n .then((savedUser) => { // eslint-disable-line consistent-return\n if (isEmail) {\n const emailParams = {\n firstName: savedUser.firstName,\n to: savedUser.email,\n otp: savedUser.otp\n };\n EmailService.forgotPassword(emailParams);\n res.json({ message: 'OTP Email sent!' });\n } else {\n Twilio.smsOTP({ otp: savedUser.otp });\n return res.json({ message: 'OTP SMS sent!' });\n }\n })\n .catch(() => {\n next(new APIError('Internal Server Error', httpStatus.INTERNAL_SERVER_ERROR, true));\n });\n // Send OTP SMS if phone number given\n } else {\n if (isEmail) {\n return next(new APIError('This email is not registered', httpStatus.BAD_REQUEST, true));\n }\n return next(new APIError('Phone number not registered', httpStatus.BAD_REQUEST, true));\n }\n });\n}", "title": "" }, { "docid": "845fc165562a554533b374bdebfae667", "score": "0.635324", "text": "checkPassword() {\n const { password, passwordHelpText } = this.state\n Meteor.call('user.checkPassword', password, (err, resp) => {\n // email did not pass regex or is empty or already registered\n if (err) {\n // display err msg\n console.log(err)\n this.setState({\n passwordHelpText: err.reason,\n isPasswordValid: false\n })\n } else if (resp) {\n // email is good, remove err msg & display success\n if (passwordHelpText) {\n this.setState({\n passwordHelpText: null\n })\n }\n // displays the success badge\n this.setState({\n isPasswordValid: true\n })\n }\n })\n }", "title": "" }, { "docid": "8d3f9750e8927c9d9543f2a1c0ed6dc2", "score": "0.6347438", "text": "sendPasswordReset(state) {\n\t\tthis.setState({\n\t\t\tloading: true\n\t\t}, () => {\n\t\t\t// Send AWS Cognito email to re-set password\n\t\t\tforgotPassword(state.email)\n\t\t\t\t.then((cognitoUserPackage) => {\n\t\t\t\t\tthis.setState({\n\t\t\t\t\t\tcognitoUserPackage,\n\t\t\t\t\t\tloading: false,\n\t\t\t\t\t\tsent: true,\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\tthis.setState({\n\t\t\t\t\t\terrorMessage: err.message,\n\t\t\t\t\t\tloading: false\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t})\n\t}", "title": "" }, { "docid": "9e291e786673ab9a38139f3504292a99", "score": "0.6339774", "text": "onForgotPasswordSubmit() {\n const email = document.querySelector(\"#forgotpassword-email\").children[0]\n .value;\n axios\n .post(`/api/forgotpassword`, {\n email,\n })\n .then((response) => {\n this.setState({\n alertMessage: `Instructions on how to reset your password were sent to ${this.state.email}`,\n alertType: \"success\",\n forgotPassMdl: false,\n });\n })\n .catch((error) => {\n this.setState({\n alertMessage: `No one with email ${this.state.email} founded.`,\n alertType: \"error\",\n forgotPassMdl: false,\n });\n });\n }", "title": "" }, { "docid": "3fc3ce80f6f4f7af527e21f369c3235e", "score": "0.63395506", "text": "getForgotPasswordResponse(response) {\n if (response.isLoading === false && response.error === false && !_.isEmpty(response.forgotResponse)) {\n const actions = [\n {\n text: 'Ok',\n onPress: () => {\n this.props.navigation.navigate('Login')\n }\n }\n ];\n Common.showAlertwithAction(Constant.PROJECTNAME, response.forgotResponse.message, actions);\n }\n else if (response.errorMsg !== \"\") {\n Common.showAlertWithDefaultTitle(response.errorMsg);\n }\n }", "title": "" }, { "docid": "59efd50ba598ee0d500ce24a34100236", "score": "0.6334035", "text": "function forgotPassword(data) {\n return $http.post(HOST + \"forgotPassword\", data).then(function (response) {\n return response.data;\n }, function (error) {\n return error.data;\n }).catch(function (err) {\n console.log(\"err\", err);\n });\n }", "title": "" }, { "docid": "98ff64d33960f8be2ee9c6fc05a06109", "score": "0.6324929", "text": "async createResetPassword(req, res, next) {\n try {\n crypto.randomBytes(32, async (err, buffer) => {\n if (err) {\n req.flash('error', 'Что-то пошло не так, повторите попытку позже');\n return res.redirect('/auth/reset');\n }\n\n const token = buffer.toString('hex');\n const candidate = await User.findOne({ email: req.body.email });\n\n if (candidate) {\n candidate.resetToken = token;\n candidate.resetTokenExp = Date.now() + 60 * 60 * 1000;\n await candidate.save();\n await transporter.sendMail(resetEmail(candidate.email, token));\n res.redirect('/auth/login');\n } else {\n req.flash('error', 'Такого email нет');\n res.redirect('/auth/reset');\n }\n });\n } catch (e) {\n console.log(e);\n }\n }", "title": "" }, { "docid": "3674c1765c4489ba31dc9890cb66d094", "score": "0.63179785", "text": "async function sendResetPasswordLink(req, res, next) {\n try {\n const email = req.body.email;\n\n let foundUser = await User.findOne({email});\n if (!foundUser) {\n return res.status(400).json({\n error: req.getLabel('there.is.no.user.with.this.email', req.lang)\n });\n }\n\n const token = uuid();\n\n foundUser.set({\n tokens: {\n resetPasswordToken: token,\n }\n });\n\n const updatedUser = await foundUser.save();\n if (!updatedUser) {\n return res.status(400).json({\n error: req.getLabel('error.saving.user', req.lang)\n });\n }\n\n try {\n // postEvent({\n // event: 'howfinder_sendRestPasswordEmail',\n // date: Date.now(),\n // payload: updatedUser\n // });\n\n // sendMail({\n // key: 'userResetPasswordTemplate',\n // to: updatedUser.email,\n // from: EMAIL_ADMIN,\n // context: {user: updatedUser}\n // });\n } catch (e) {\n console.log(e);\n }\n\n res.addMessage('success', req.getLabel('we.sent.you.letter.with.reset.link', req.lang));\n res.addMessage('info', token);\n\n let user;\n\n if (CONFIG.NODE_ENV === 'development') {\n user = updatedUser;\n } else {\n user = _.pick(updatedUser, ['_id', 'username', 'email', 'isActive', 'resetPasswordToken']);\n }\n\n // postEvent({\n // event: 'howfinder_resetPasswordLinkSent',\n // date: Date.now(),\n // payload: user\n // });\n\n return res.status(200).json({\n user\n });\n } catch(e) {\n next(e);\n }\n}", "title": "" }, { "docid": "46cc07982ad59745c79e0845739f5b49", "score": "0.6314865", "text": "function renderPostForgotPassword( req, res ){\n\n var crypto = require('crypto');\n\n var confirmationKey = crypto.createHash('sha1').update((new Date()).toString(32)).digest('hex');\n\n konter.db.models.User.findOne( {email: req.body.email}, function( err, user ){\n if( user ){\n user.update({ confirmation: { key: confirmationKey,\n expires: moment().add('d',3).toDate(),\n ipAddr: konter.plugins.auth.getRemoteIP( req ),\n tries: 3 } }, function( err ){\n if( err ){\n req.flash('error', err);\n console.log(err);\n res.render( konter.views.get( 'auth/forgot_password.jade' ), { flash: req.flash() } );\n } else {\n konter.plugins.mailer.deliver({ \n to: req.body.email,\n subject: '['+konter.config.site.title+'] '+res.locals.t('Password reset request'),\n text: req.i18n.t('You (or somebody else) has requested to reset your password. If this was not your intention, you can ignore this email (respectively report an abuse) - your password will remain untouched. If you whish to continue, please click on the link below.') +\n \"http://\" + konter.config.site.domain + \"/users/\"+ user._id + \"/reset_password?key=\" + confirmationKey +\n res.locals.t('bye', {site: konter.config.site.title})\n },\n function( err, response ){\n if( err ){\n console.log( err );\n req.flash('error', err);\n } else\n req.flash('notice', res.locals.t('Password reset request has been sent!'));\n res.render( konter.views.get( 'auth/login.jade' ), { flash: req.flash() } );\n });\n }\n\n });\n } else {\n req.flash('error', res.locals.t('Email unknown') );\n res.render( konter.views.get( 'auth/forgot_password.jade' ), { flash: req.flash() } );\n }\n });\n}", "title": "" }, { "docid": "e32ba9bf144bde05cf1ba231c9882070", "score": "0.6304782", "text": "function forgotEmail(email_input) {\n $('#forgot_error').removeClass('has-text-success').removeClass('has-text-danger').html('');\n email = $(email_input).val();\n if (email == \"\") {\n $(email_input).addClass('is-danger');\n } else {\n $(email_input).removeClass('is-danger');\n $.post(\"/staff/reset_password\",{email:email}, function(data) {\n if (data == \"Success\") {\n $('#forgot_error').html('The password for this email address has been reset. Please check your emails to log back in.').addClass('has-text-success');\n } else {\n $('#forgot_error').html(data).addClass('has-text-danger');\n }\n });\n }\n // Prevent page reload\n return false;\n}", "title": "" }, { "docid": "f5e7ed78772b7247050fab12c04ea791", "score": "0.6294428", "text": "getForgotPassword(req, res) {\n res.status(200);\n }", "title": "" }, { "docid": "f6636eab78369ee9fd59f81293854dd7", "score": "0.6293121", "text": "passwordChanged() {\n this.resetState_();\n this.isPasswordChanged_ = true;\n this.passwordChangeAttempt_++;\n if (this.passwordChangeAttempt_ > 1) {\n this.$.oldPasswordInput.invalid = true;\n }\n }", "title": "" }, { "docid": "f151257417271d8fe00f4daa5ffc66b9", "score": "0.62907904", "text": "_sendPasswordResetMail(user, cb, errCb) {\n\n // Remove the previous generated email so that the previous token is invalid\n this.ResetPasswords.destroy({\n where: {user_id: user.id}\n });\n\n this.ResetPasswords.create({\n user_id: user.id,\n token: uuid()\n }).then(passVerf => {\n log.info(`Reset Password email sent to ${user.email}`);\n email(user.email, 'Reset Password', `\n <p>Please click the link below to reset your password.</p><br/>\n <a href=\"http://localhost:3000/users/reset-password/${passVerf.token}\">Reset Password</a><br/>\n `, null).then((info) => {\n cb(info);\n }).catch(err => {\n log.error('Error in sending reset password email');\n errCb(err);\n });\n }).catch(err => {\n errCb(err);\n })\n }", "title": "" }, { "docid": "1a2afe0fd306e05be0fdb62a37c974a6", "score": "0.62840754", "text": "function askForPasswordReset(isValid) {\n vm.success = vm.error = null;\n\n if (!isValid) {\n $scope.$broadcast('show-errors-check-validity', 'vm.forgotPasswordForm');\n\n return false;\n }\n\n $http.post('/api/auth/forgot', vm.credentials).success(function (response) {\n // Show user success message and clear form\n vm.credentials = null;\n vm.success = response.message;\n $mdToast.show(\n $mdToast.simple()\n .textContent(vm.success)\n .hideDelay(3000)\n );\n\n }).error(function (response) {\n // Show user error message and clear form\n vm.credentials = null;\n vm.error = response.message;\n $mdToast.show(\n $mdToast.simple()\n .textContent(vm.error)\n .hideDelay(3000)\n );\n });\n }", "title": "" }, { "docid": "5b65c1e31f99277e80c74ed2c49f1446", "score": "0.6276357", "text": "function resetPasswordSuccess() {\n // check if reset password form was\n // successfully submitted and show success message.\n\n if (document.querySelector(selectors.formState)) {\n document.querySelector(selectors.resetSuccess).classList.remove('hide');\n }\n}", "title": "" }, { "docid": "a37f69ac823fdeca82c1dd03a747716e", "score": "0.623157", "text": "function forgotP() { \n \n $.post(base_url+\"index.php/auth/forgot_password\",\n {\n email: $(\"#temail\").val()\n },function(response){\n $.each(response, function(key, value) {\n //console.log(value)\n if(key == \"id\")\n id = value;\n else if(key == \"message\")\n messg = value;\n else if(key == \"status\")\n status = value;\n });\n \n if(status == 0){\n $(\"#dpwerr\").html(messg);\n $(\"#dpwerr\").addClass('help-block-error');\n $(\"#dpwerr\").removeClass('help-block-success');\n }else{\n $(\"#dpwerr\").addClass('help-block-success');\n $(\"#dpwerr\").removeClass('help-block-error');\n $(\"#dpwerr\").html(messg);\n }\n },'json'\n );\n //}\n //});\n }", "title": "" }, { "docid": "32a215787fc04035a13be3d0ca0a5006", "score": "0.6226521", "text": "async ['POST /reset-password/start']({ body }) {\n const user = await this.db.User.findOne({ email: body.email });\n if (user instanceof Object) {\n const code = await nanoid(this.config.user.resetPassword.codeLength);\n user.code = {\n value: code,\n ttl: Date.now() + this.config.user.resetPassword.ttl\n }\n await user.save();\n }\n /**\n * It is better to avoid granting a user to pluck\n * existing email addresses in DB\n */\n return { ok: true };\n }", "title": "" }, { "docid": "de98cf770eba3f42549b697113223200", "score": "0.62073535", "text": "async resetPassword(_, {email}) {\n return this.dispatch('graphql', {\n query: {\n op: 'recoverPassword',\n vars: {email}\n }\n }).then(({errors}) => {\n\n // Check for errors and, if present, return the message of the first one\n if (errors && errors.length) {\n throw errors[0].message;\n }\n });\n }", "title": "" }, { "docid": "f826c6ff9910a2dc718e869460fb415f", "score": "0.6204949", "text": "function testConfirmPasswordReset_unknownServerResponse() {\n var newPassword = 'newPass';\n var code = 'PASSWORD_RESET_OOB_CODE';\n var expectedResponse = {};\n asyncTestCase.waitForSignals(1);\n assertSendXhrAndRunCallback(\n 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/resetPass' +\n 'word?key=apiKey',\n 'POST',\n goog.json.serialize({\n 'oobCode': code,\n 'newPassword': newPassword\n }),\n fireauth.RpcHandler.DEFAULT_FIREBASE_HEADERS_,\n delay,\n expectedResponse\n );\n rpcHandler\n .confirmPasswordReset(code, newPassword)\n .thenCatch(function (error) {\n fireauth.common.testHelper.assertErrorEquals(\n new fireauth.AuthError(fireauth.authenum.Error.INTERNAL_ERROR),\n error\n );\n asyncTestCase.signal();\n });\n}", "title": "" }, { "docid": "4d4af30988d74d7e9f0dc03e70362288", "score": "0.61953604", "text": "async verificationPass() {\n this.setState({ showDialog: false });\n this.setState({ forgetPass: false });\n var params = {\n ClientId: aws_data11.ClientId, /* required */\n ConfirmationCode: this.state.verificationCode, /* required */\n Password: this.state.password, /* required */\n Username: (this.state.userName).toLowerCase(), /* required */\n };\n var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();\n cognitoidentityserviceprovider.confirmForgotPassword(params, function (err, data) {\n if (err) {\n var errormsg = JSON.stringify(err);\n if (errormsg.contains(\"Invalid verification\")) {\n ToastAndroid.show(Strings.login_toast_pwdverification, 500);\n }\n else if (errormsg.contains(\"lambda\")) {\n ToastAndroid.show(Strings.login_toast_pwdsuccess, 500);\n }\n else {\n alert(err, err.stackerr);\n }\n } // an error occurred\n else {\n alert(\"Success==> \" + JSON.stringify(data)); // successful response\n }\n });\n }", "title": "" }, { "docid": "f25a46588c106b745482528d334b7ca2", "score": "0.6145963", "text": "handleChangeNewPasswordVerify(event) {\n this.setState({\n newPasswordVerify: event.target.value,\n });\n }", "title": "" }, { "docid": "1394807e4b532d85b655dd3a6ebd37a9", "score": "0.6144079", "text": "sendPasswordResetEmail(passwordResetEmail) {\n return tslib_1.__awaiter(this, void 0, void 0, function* () {\n yield this.afAuth.auth.sendPasswordResetEmail(passwordResetEmail).then(() => {\n /* Navagate them back to home with params */\n }).catch((error) => {\n console.log(error); /* Make a better way */\n });\n });\n }", "title": "" }, { "docid": "a62687223e6837e3da9bfa9aee1172b2", "score": "0.6135963", "text": "async sendPasswordResetEmail({ commit }, { email, actionCodeSettings }) {\n try {\n const db = await database();\n const auth = await db.auth();\n await auth.sendPasswordResetEmail(email, actionCodeSettings);\n commit(\"@firebase/sendPasswordResetEmail\");\n }\n catch (e) {\n commit(\"@firebase/error\", {\n stack: e.stack,\n message: `Failure to send password-reset email: ${e.message} [ ${e.code} ${e.name} ]`\n });\n throw e;\n }\n }", "title": "" }, { "docid": "716692a30240718e3ffd00947f573025", "score": "0.611665", "text": "function sendUserVerificationCode(email,newPass){\n var mailOptions = {\n from:'Baduga <[email protected]>',\n to: email,\n subject: 'Reset Password- Baduga Admin',\n text: 'This is your email verification code '+ newPass\n };\n transporter.sendMail(mailOptions, function(error, info){\n if (error) {\n console.log(error);\n // res.end('There is a problem in sending email, please try again later!')\n } else {\n // res.end('Check your inbox for a password reset message.')\n console.log('Email sent: ' + info.response);\n }\n});\n}", "title": "" }, { "docid": "8af62a6f9ca21fd81bed0644982659d6", "score": "0.6115881", "text": "async ResetPassword() {\r\n const resetPasswordModel = new ResetPasswordModel()\r\n const mailer = new Mailer()\r\n const passwordReset = new PasswordReset()\r\n const ResetToken = await passwordReset.GenerateToken({name: 'aliabkarSultani'})\r\n await resetPasswordModel.AddResetToken(this.request.body.email, ResetToken)\r\n await mailer.Send({\r\n text: 'http://127.0.0.1:3000/login/reset-password?resetToken=' + ResetToken,\r\n to: this.request.body.email\r\n })\r\n Responser.send(this.response, 200, \"Success\", 'Your reset link has been sent to your email. Check your inbox!')\r\n }", "title": "" }, { "docid": "7e703d4380b2decc30006fc484c1cd32", "score": "0.61039937", "text": "function forgotValidate(){\n var user=userName();\n var email=emailValidate();\n var pass=passwordMatch();\n if(userName()&&emailValidate()&&passwordMatch()) {\n \n }\n else{\n return false;\n\t}\n}", "title": "" }, { "docid": "845db4dd1e016d05df0a036020a67537", "score": "0.610051", "text": "function confirmResetPassword(data) {\n $log.debug('[SECURITY] Confirm reset password');\n return credentialChecker\n .confirmResetPassword(data, {ignoreHttpFirewall : true });\n }", "title": "" }, { "docid": "df12c87815e7a6f646047a9970e30a61", "score": "0.60958016", "text": "async handle ({ redirectUrl, user, email }) {\n console.log(`${ForgotPasswordMail.key}: start`)\n await Mail.send(\n ['emails.forgot_password'],\n { name: user.name, email, token: user.token, link: `${redirectUrl}?token=${user.token}` },\n message => {\n message.to(user.email).from(tglEmail, tglName).subject('Recuperação de senha')\n }\n )\n }", "title": "" }, { "docid": "d7af7e1b16021966d8ca986a42c9cfaa", "score": "0.6087892", "text": "async SetNewPassword () {\r\n const ResetToken = this.request.body.reset_token\r\n const NewPassword = this.request.body.new_password\r\n const resetPasswordModel = new ResetPasswordModel()\r\n const UserResetToken = await resetPasswordModel.FindBy('reset_token', ResetToken)\r\n console.log(UserResetToken)\r\n // Note: check for expiration date\r\n try {\r\n if(UserResetToken && await jwt.verify(ResetToken, 'secret')) {\r\n await UserModel.SetNewPassword({\r\n password: NewPassword, \r\n id: UserResetToken.user_id\r\n })\r\n \r\n Responser.send(this.response, 200, \"Success\", 'Youre password reseted successfully')\r\n }\r\n }catch(err) {\r\n console.log(err)\r\n throw { type: \"BadRequest\", message: err.message }\r\n }\r\n \r\n }", "title": "" }, { "docid": "d51c3d98ef946219ebc9836436c03aa7", "score": "0.60752755", "text": "function submitForgotData(){\n\ttry{ \n\t\tvar uname = $.txtfieldUserName.value; \n\t\t uname = uname.toLowerCase();\n\t \temiratesid = $.textfieldEmirateId.value.replace(/[-]/gi, \"\");\n\t \tlicense = $.textfieldLicense.value;\n\t \tlicense = license.replace(/&(?!amp;)/g, '&amp;'​);\n\t \tmobile = $.textfieldMobile.value.replace(/[-]/gi, \"\");\n\t \tpassport = $.textfieldPassport.value;\n\t \tpassport = passport.replace(/&(?!amp;)/g, '&amp;'​);\n\t var lblEmiratePassport;\n\t \n\t if($.imgPwdIndividual.image === Alloy.Globals.path.radioActive){\n\t\t\tif(passport === \"\" && emiratesid === \"\"){\n\t\t\t\tutilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.validateHintText,function(){});\n\t\t\t}else if(uname === \"\"){\n\t\t \t utilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.enterUserName,function(){});\n\t\t\t}else if(mobile === \"\"){\n\t\t\t utilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.mobileNumber,function(){});\n\t\t\t}else if (emiratesid.length < 15 && emiratesid !== \"\") {\n\t\t\t\t$.textfieldEmirateId.value = \"\";\n\t\t\t \tutilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.invalidEmiratesId,function(){});\n\t\t\t}\n\t\t\telse if (mobile.length !== 10 && mobile.value !== \"\") {\n\t\t\t utilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.mobileLength,function(){});\n\t\t\t}else{\n\t\t\t\ttry{\n\t\t\t\t\tlblEmiratePassport = (emiratesid !== \"\")?emiratesid:passport;\n\t\t\t\t\thttpManager.forgetPassword(function(result){\t\t\t\t\t\n\t\t\t\t\t\tvar rootNode = result.getElementsByTagName(\"output\");\n\t\t\t\t\t\tvar ns =\"http://ForgetPassword\";\n\t\t\t\t\t\t//var subNode = result.getElementsByTagName(\"uaq:Status\");\n\t\t\t\t \tif(rootNode.length > 0){\n\t\t\t\t \t\tvar status = result.getElementsByTagNameNS(ns, \"Status\").item(0).textContent;\n\t\t\t\t \t\t\n\t\t\t\t \t\tif(status === \"Success\"){\n\t\t\t\t \t\t\tAlloy.Globals.hideLoading();\n\t\t\t\t \t\t\tvar alert = Ti.UI.createAlertDialog({\n\t\t\t\t\t\t\t\t\ttitle : Alloy.Globals.selectedLanguage.appTitle,\n\t\t\t\t\t\t\t\t\tmessage : (Alloy.Globals.isEnglish)?result.getElementsByTagNameNS(ns, \"Message_EN\").item(0).textContent:result.getElementsByTagNameNS(ns, \"Message_AR\").item(0).textContent,\n\t\t\t\t\t\t\t\t\tbuttonNames : [Alloy.Globals.selectedLanguage.ok]\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\talert.addEventListener('click', function(e) {\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (e.index == 0) {\n\t\t\t\t\t\t\t\t\t\tvar winMenu = Alloy.createController('UserManagement/winLogin',{\n\t\t\t\t\t\t\t\t\t\t\tisFromLeftPanel : false\n\t\t\t\t\t\t\t\t\t\t}).getView();\n\t\t\t\t\t\t\t\t\t\tAlloy.Globals.openWindow(winMenu);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\talert.show();\t\t\t \t\t\t\n\t\t\t\t \t\t}else if(status === \"Failure\"){\n\t\t\t\t \t\t\tAlloy.Globals.hideLoading();\n\t\t\t\t \t\t\tvar alert = Ti.UI.createAlertDialog({\n\t\t\t\t\t\t\t\t\ttitle : Alloy.Globals.selectedLanguage.appTitle,\n\t\t\t\t\t\t\t\t\tmessage : (Alloy.Globals.isEnglish)?result.getElementsByTagNameNS(ns, \"Message_EN\").item(0).textContent:result.getElementsByTagNameNS(ns, \"Message_AR\").item(0).textContent,\n\t\t\t\t\t\t\t\t\tbuttonNames : [Alloy.Globals.selectedLanguage.ok]\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\talert.show();\n\t\t\t\t \t\t}\n\t\t\t\t \t}else{\n\t\t\t\t \t\tvar alert = Ti.UI.createAlertDialog({\n\t\t\t\t\t\t\t\ttitle : Alloy.Globals.selectedLanguage.appTitle,\n\t\t\t\t\t\t\t\tmessage : Alloy.Globals.selectedLanguage.serviceError,\n\t\t\t\t\t\t\t\tbuttonNames : [Alloy.Globals.selectedLanguage.ok]\n\t\t\t\t\t\t });\n\t\t\t\t\t\t alert.show();\n\t\t\t\t \t Alloy.Globals.hideLoading();\n\t\t\t\t \t}\n\t\t\t\t\t},1,uname,mobile,lblEmiratePassport);\n\t\t\t\t}catch(e){\n\t\t\t\t\tTi.API.info('Error '+e.message);\n\t\t\t\t}\n\t\t\t}\n\t\t}else if($.imgPwdEstablishment.image === Alloy.Globals.path.radioActive){\n\t\t\tif(license === \"\"){\n\t\t \t utilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.licenseNumber,function(){});\n\t\t\t}else if(uname === \"\"){\n\t\t\t\tutilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.enterUserName,function(){});\n\t\t }else if(mobile === \"\"){\n\t\t\t utilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.mobileNumber,function(){});\n\t\t\t}else if (emiratesid !== \"\" && emiratesid.length < 15) {\n\t\t \t utilities.showAlert(Alloy.Globals.selectedLanguage.forgotUsername,Alloy.Globals.selectedLanguage.invalidEmiratesId,function(){});\n\t\t\t}\n\t\t\telse if (mobile.length !== 10 && mobile.value !== \"\") {\n\t\t\t utilities.showAlert(Alloy.Globals.selectedLanguage.forgetPassword,Alloy.Globals.selectedLanguage.mobileLength,function(){});\n\t\t\t}else{\t\t\t\t\n\t\t\t\ttry{\n\t\t\t\t\thttpManager.forgetPassword(function(result){\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar rootNode = result.getElementsByTagName(\"output\");\n\t\t\t\t\t\tvar ns =\"http://ForgetPassword\";\n\t\t\t\t\t\t\n\t\t\t\t \tif(rootNode.length > 0 ){\n\t\t\t\t \t\n\t\t\t\t \t\tvar status = result.getElementsByTagNameNS(ns, \"Status\").item(0).textContent;\n\t\t\t\t \t\t\n\t\t\t\t \t\tif(status === \"Success\"){\n\t\t\t\t \t\t\t\n\t\t\t\t \t\t\tvar alert = Ti.UI.createAlertDialog({\n\t\t\t\t\t\t\t\t\ttitle : Alloy.Globals.selectedLanguage.appTitle,\n\t\t\t\t\t\t\t\t\tmessage : (Alloy.Globals.isEnglish)?result.getElementsByTagNameNS(ns, \"Message_EN\").item(0).textContent:result.getElementsByTagNameNS(ns, \"Message_AR\").item(0).textContent,\n\t\t\t\t\t\t\t\t\tbuttonNames : [Alloy.Globals.selectedLanguage.ok]\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\talert.addEventListener('click', function(e) {\n\t\t\t\t\t\t\t\t\tif (e.index == 0) {\n\t\t\t\t\t\t\t\t\t\tvar winMenu = Alloy.createController('UserManagement/winLogin',{\n\t\t\t\t\t\t\t\t\t\t\tisFromLeftPanel : false\n\t\t\t\t\t\t\t\t\t\t}).getView();\n\t\t\t\t\t\t\t\t\t\tAlloy.Globals.openWindow(winMenu);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\talert.show();\n\t\t\t\t \t\t}else if(status === \"Failure\"){\n\t\t\t\t \t\t\tAlloy.Globals.hideLoading();\n\t\t\t\t \t\t\tvar alert = Ti.UI.createAlertDialog({\n\t\t\t\t\t\t\t\t\ttitle : Alloy.Globals.selectedLanguage.appTitle,\n\t\t\t\t\t\t\t\t\tmessage : (Alloy.Globals.isEnglish)?result.getElementsByTagNameNS(ns, \"Message_EN\").item(0).textContent:result.getElementsByTagNameNS(ns, \"Message_AR\").item(0).textContent,\n\t\t\t\t\t\t\t\t\tbuttonNames : [Alloy.Globals.selectedLanguage.ok]\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\talert.show();\n\t\t\t\t \t\t}\n\t\t\t\t \t}else{\n\t\t\t\t \t\tvar alert = Ti.UI.createAlertDialog({\n\t\t\t\t\t\t\t\ttitle : Alloy.Globals.selectedLanguage.appTitle,\n\t\t\t\t\t\t\t\tmessage : Alloy.Globals.selectedLanguage.serviceError,\n\t\t\t\t\t\t\t\tbuttonNames : [Alloy.Globals.selectedLanguage.ok]\n\t\t\t\t\t\t });\n\t\t\t\t\t\t alert.show();\n\t\t\t\t \t Alloy.Globals.hideLoading();\n\t\t\t\t \t}\n\t\t\t\t \tAlloy.Globals.hideLoading();\n\t\t\t\t},2,uname,mobile,license);\n\t\t\t\t}catch(e){\n\t\t\t\t\tTi.API.info('Error '+e.message);\n\t\t\t\t}\t\t\t\n\t\t\t}\n\t\t}\n\t}catch(e){\n\t\tTi.API.info('Error in submit forget data function '+JSON.stringify(e));\n\t}\n}", "title": "" }, { "docid": "a2b64704a1d2e461d7fc24281145af31", "score": "0.6070613", "text": "function forgotPassword()\n{\n // Define the Dialog and its properties\n $(\"div#userEmail\").dialog({\n resizable: false,\n draggable: false,\n dialogClass: \"forgot\",\n modal: false,\n width: 500,\n open: function () {;\n },\n buttons: {\n \"Send\": function () {\n\n $(this).dialog(\"close\");\n startLoading();\n var form = $(\"#forgotEmailForm\");\n\n // ajax call here for sending email notification\n $.ajax({\n url: \"accounts/password/reset/\",\n type: form.attr('method'),\n data: form.serialize(),\n dataType: 'text',\n success: function(response){\n // code to update DOM here\n console.log(response);\n stopLoading();\n if (response === \"resetFormSuccess\") {\n swal({ title: \"Sent!\",\n text: \"We've e-mailed you instructions for setting your password to the e-mail address you submitted. You should be receiving it shortly.\",\n type: \"success\"});\n }\n },\n error: function(response){\n // log ajax errors? something went wrong\n console.log(response);\n somethingWrong();\n }\n });\n\n\n },\n \"Cancel\": function () {\n $(this).dialog(\"close\");\n }\n }\n });\n}", "title": "" }, { "docid": "658acc5e47d93602054a9c89350ccd0e", "score": "0.6070551", "text": "function updatePasswordEventHandler() {\n\t$('#login_dive').delegate('#pw_chg', 'click', function() { \n\t\tvar fflag=0;\n\t\tcloseOpenDialogs();\n\t\tchangePassword(fflag);\n\t});\n}", "title": "" }, { "docid": "217f95d6eac0a9aed0669640da7bf3d7", "score": "0.6052228", "text": "async function forgot(req, res, next) {\n const { email } = req.body;\n try {\n let user = await User.findOne({ where: { email }});\n\n if (!user) {\n return res.render('login/forgot', {\n user: req.body,\n error: 'E-mail não cadastrado.'\n });\n }\n\n req.user = user;\n\n next();\n } catch (error) {\n console.error(error);\n }\n}", "title": "" }, { "docid": "281e62082685976573f18b9dae7b5909", "score": "0.6048591", "text": "function forgotPasswordValidate(id){\n\t\t$('#forgot_password_form').submit(function( e ) {\n\t\t\te.preventDefault();\n\t\t\tvar code = $(\".forgot_password_code\").val().trim();\n\t\t\t\n\t\t\t$.post( \"../login/login_forgot_password_verify.php\", {\n\t\t\t\tid: \tid,\n\t\t\t\tcode: \tcode\n\t\t\t}, function( data ) {\n\t\t\t\tif(data.alert == \"success\"){\n\t\t\t\t\tloadChangePassword(id);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tswal(data.title, data.message, data.alert);\n\t\t\t}, \"json\");\n\t });\n\t}", "title": "" }, { "docid": "1ad183c116311e9b1787c2ba1a40bcdb", "score": "0.6047934", "text": "async verifyPasswordResetCode({ commit }, code) {\n try {\n const db = await database();\n const auth = await db.auth();\n const email = await auth.verifyPasswordResetCode(code);\n commit(\"@firemodel/verifyPasswordResetCode\", email);\n return email;\n }\n catch (e) {\n commit(\"@firebase/error\", {\n stack: e.stack,\n message: `Failure to verify password reset code: ${e.message} [ ${e.code} ${e.name} ]`\n });\n throw e;\n }\n }", "title": "" }, { "docid": "8dcadd687374e68b260f401cf75b56bc", "score": "0.60477936", "text": "confirmpassword(){\n\n if (this.props.config.debug==true) { console.log(\"in EmailSignup/confirmpassword\"); }\n\n try {\n if (this.refs.pw.getValue() != this.refs.pw2.getValue()) {\n this.setState({ wrongSignupPassword: true });\n this.setState({ askPasswordConfirmation: true });\n }\n }\n catch(TypeError) {\n // pw2 not yet completed\n console.log(\"typeerror catch\")\n this.setState({ wrongSignupPassword: true });\n this.setState({ askPasswordConfirmation: true });\n }\n if (this.refs.pw.getValue() == this.refs.pw2.getValue()) {\n this.setState({ askPasswordConfirmation: false });\n this.setState({ wrongSignupPassword: false });\n this.setState({ signupPasswordMatch: true });\n }\n\n }", "title": "" }, { "docid": "bc7b8c8cf0be978031d4ad751e830146", "score": "0.60455865", "text": "async resetPassword(email) {\n await this.auth.sendPasswordResetEmail(email);\n }", "title": "" }, { "docid": "2dffdbc7e277ed85b8dba07c81c02376", "score": "0.60438293", "text": "function checkResetPass() {\n var resetPass = document.getElementById('pwdResetConfirm');\n var resetPassConfirm = document.getElementById('pwdResetConfirmRepeat');\n if (resetPass && resetPassConfirm) {\n if (resetPass.value != resetPassConfirm.value) {\n resetPassConfirm.setCustomValidity('Lozinke moraju biti jednake.');\n } else {\n resetPassConfirm.setCustomValidity('');\n }\n }\n }", "title": "" }, { "docid": "784e40e74fc462348ecd766d7598d1e0", "score": "0.6039862", "text": "async function handleEmailForm(values) {\n setState({ ...state, sendingCode: true });\n try {\n await Auth.forgotPassword(values.email);\n setState({ ...state, email: values.email, sendingCode: false });\n } catch (e) {\n message.error(e.message);\n setState({ ...state, sendingCode: false });\n }\n }", "title": "" }, { "docid": "9239bba41aef368bedc7cb6d218b9268", "score": "0.60356617", "text": "function resetMyPassword()\n{\n\t$(\"#modal\").modal({backdrop: \"static\", keyboard: false, show: true});\n\t$(\".modal-header\").html(\"Reset Password\");\n\t$(\".modal-body\").html(\"<form><label>Registered Email:&nbsp;&nbsp;</label><input id='resetEmail' type='email' /></form>\");\n\t$(\"#btn-confirm\").click(function(){\n\t\tvar email = $(\"#resetEmail\").val();\n\t\tresetPassword(email, resetPasswordCallback);\n\t});\n}", "title": "" }, { "docid": "b6f5481b424381ec3e5e0c7ae595b00f", "score": "0.602576", "text": "async function sendPasswordResetToken(ctx) {\n ctx.status = 501;\n}", "title": "" }, { "docid": "ecaf6aedbb095f3331899a4e2772ff83", "score": "0.5989386", "text": "onSubmit(e) {\n e.preventDefault();\n const { email, family_name } = this.state;\n Axios.post(process.env.REACT_APP_SERVER_API + '/auth/recover-password', {\n email,\n family_name\n })\n .then((res) => {\n this.setState({\n feedback: {\n type: 'success',\n message: res.data\n }\n });\n })\n .catch((err) => {\n this.setState({\n feedback: { type: 'danger', message: err.response.data }\n });\n });\n }", "title": "" }, { "docid": "fbcc58ff1c2dbd71e5d5e7b57d677843", "score": "0.5983665", "text": "function resetPassword(email) {\n return auth.sendPasswordResetEmail(email)\n .catch(APIerror => {\n setAPIerror(\"Something went wrong sending reset password email\", APIerror)\n })\n }", "title": "" }, { "docid": "d4e027b2d281c497c74ec7b970b0ac42", "score": "0.59826815", "text": "async ['PUT /reset-password/complete | reset-password.max-attempts']({\n body,\n key,\n attempts, t\n }) {\n const user = await this.db.User.findOne({ email: body.email });\n if (!(user instanceof Object)) {\n throw this.Boom.badRequest({ email: 'Wrong email' });\n }\n const { code } = user;\n try {\n equal(code.value, body.code);\n equal(new Date() < new Date(code.ttl), true);\n } catch {\n const { ttl } = this.config.user.resetPassword.attempts;\n await this.redis.set(key, attempts + 1, 'EX', ttl);\n\n throw this.Boom.badRequest({\n code: t('auth.incorrect-reset-password-code')\n });\n }\n /**\n * All checks has been evaluated successfully\n */\n user.password = body.password;\n user.code = {};\n await user.cryptPassword();\n await user.save();\n return { ok: true };\n }", "title": "" }, { "docid": "4c45147fe9ca6b8ced62d2dc641cc408", "score": "0.5982391", "text": "function updatePassword(e){\n e.preventDefault();\n let pwd = $('#pwd').val();\n let confirmpwd = $('#confirmpwd').val();\n\n\n if (confirmpwd == '' || pwd == '') {\n $('#responsePasssword').html('<spna class=\"text-danger\">Enter New Password </span>');\n } else if (pwd !== confirmpwd) {\n $('#responsePasssword').html('<spna class=\"text-danger\">Password Not Matched</span>');\n } else {\n $.ajax({\n url: './includes/updatepassword.process.php',\n method: \"POST\",\n data: $('#updatePasswordForm').serialize(),\n \n })\n .done(function (data) {\n $('form').trigger(\"reset\");\n $('#responsePasssword').html('<spna class=\"text-success\">' + data + '</span>');\n setTimeout(function () {\n $('#responsePasssword').fadeOut('slow');\n }, 3000);\n \n })\n .fail(function () {\n console.log('Error!');\n })\n }\n return false;\n}", "title": "" }, { "docid": "08222346d41d3305771549b8b7f654e8", "score": "0.5975909", "text": "function changeEmail(e) {\n e.preventDefault();\n auth.currentUser.updateEmail(emailInput).then(function () {\n // Update successful.\n //Sending Verification\n auth.currentUser.sendEmailVerification().then(function () {\n // Email sent.\n alert(\"We send you a verification email so check your email.\");\n }).catch(function (error) {\n // An error happened.\n alert(error.message);\n console.log(error);\n });\n //Sending Verification\n }).catch(function (error) {\n // An error happened.\n console.log(error);\n alert(error.message);\n });\n }", "title": "" }, { "docid": "cc45f0880cbbdfb4c538a21e57b7dbd0", "score": "0.5968211", "text": "function sendPasswordReset(userData){\n return mg.messages().send(userData,function (error,body){\n if (error) {console.log(error.message)}\n return console.log(body)\n })\n}", "title": "" }, { "docid": "54187d720bd99b620a2743a07a0da9c9", "score": "0.59625715", "text": "async makeResetPassword(req, res, next) {\n if (!req.params.token) {\n return res.redirect('/auth/login');\n }\n\n try {\n const user = await User.findOne({\n resetToken: req.params.token,\n resetTokenExp: { $gt: Date.now() },\n });\n\n if (!user) {\n return res.redirect('/auth/login');\n } else {\n res.render('auth/password', {\n title: 'Восстановить доступ',\n error: req.flash('error'),\n userId: user._id.toString(),\n token: req.params.token,\n });\n }\n } catch (e) {\n console.log(e);\n }\n }", "title": "" }, { "docid": "9e8657d7743317e05060a80b83d9657f", "score": "0.595588", "text": "function hashPassword (resetPassword) {\n if (resetPassword.changed('tempPassword')) {\n return bcrypt.hash(resetPassword.tempPassword, 10).then(function (password) {\n resetPassword.tempPassword = password\n })\n }\n}", "title": "" }, { "docid": "d0d49ce7aeb151895cfc9334de9853f8", "score": "0.5950668", "text": "function changePasswordCallback(result)\n{\n\tif(result === false)\n\t{\n\t\t$(\"#modal\").modal({backdrop: \"static\", keyboard: false, show: true});\n\t\t$(\".modal-header\").html(\"Password Change Failed\");\n\t\t$(\".modal-body\").html(\"<p>We had trouble changing your password.<br/><br/>Make sure both fields are filled out with the password you used to login and the password you want use from now on.</p>\");\n\t\t$(\"#btn-confirm\").css(\"display\", \"none\");\n\t\t$(\"#btn-cancel\").click(function(){\n\t\t\t$(\"#btn-confirm\").css(\"display\", \"block\");\n\t\t});\n\t}\n\telse\n\t{\n\t\t$(\"#modal\").modal({backdrop: \"static\", keyboard: false, show: true});\n\t\t$(\".modal-header\").html(\"Password Change Success\");\n\t\t$(\".modal-body\").html(\"<p>Your password has been changed.</p>\");\n\t\t$(\"#btn-confirm\").css(\"display\", \"none\");\n\t\t$(\"#btn-cancel\").click(function(){\n\t\t\t$(\"#btn-confirm\").css(\"display\", \"block\");\n\t\t});\n\t}\n}", "title": "" }, { "docid": "1a3eb444b7c55696abe2bf219dc30730", "score": "0.59492123", "text": "function savePasswordSuccessful(data) {\n if (data === '') {\n $scope.savePasswordSuccessful = true;\n $scope.savePasswordShowMessage = true;\n $scope.savePasswordMessage = 'Your password has been updated successful!';\n //reset form\n $scope.userpasswordform.$setPristine();\n //reset model\n $scope.passwordModel = angular.copy({ oldPassword: '', newPassword: '', confirmNewPassword: '' });\n }\n\n //hide indicator\n $scope.onSubmitting = false;\n }", "title": "" } ]
20782f1a5d769d9f52ff07a1e8790950
Rather than flood the browser history, use location.replace.
[ { "docid": "56edb3735a620c7ae25a39cceab94949", "score": "0.0", "text": "function click(d) {\n location.replace(\"#\" + encodeURIComponent(d === activeTopic ? \"!\" : d.name));\n // PFS: 12/05/2015\n parent.resizeIframeByHeight(parent.document.getElementsByName('iframe_a')[0],document.getElementById('interactiveABC').scrollHeight);\n d3.event.preventDefault();\n}", "title": "" } ]
[ { "docid": "e91a99c34f67d732b492480a955be614", "score": "0.81403303", "text": "function locationReplace(url) {\n window.history.replaceState(null, \"\", \"#\")\n window.location.replace(url)\n }", "title": "" }, { "docid": "7a12db0ee8c620f068e81dc9b6781b5b", "score": "0.8069487", "text": "function replaceLocation(url) {\n\twindow.location.replace(url);\n}", "title": "" }, { "docid": "c3af733fd02cdd8d94b08d24b5ddb0f6", "score": "0.8058306", "text": "replace(location) {\n window.location.replace(location || \"/\");\n }", "title": "" }, { "docid": "f4e682e7f03294382edbb7964ef27877", "score": "0.7807424", "text": "function locationReplace(url) {\n window.history.replaceState(null, \"\", pjax.state.url)\n window.location.replace(url)\n}", "title": "" }, { "docid": "71e9d6abd12f1acddb5ef9ad3dfe5cdf", "score": "0.77031213", "text": "function replace() {\n $location.replace();\n }", "title": "" }, { "docid": "764fd89270c771ddde1fb735b4cba467", "score": "0.7502359", "text": "function changePage(url){\n location.replace(url);\n}", "title": "" }, { "docid": "5bc88d97b007a60cb8dee335f807e536", "score": "0.74265057", "text": "function changePage(url) {\n location.replace(url);\n}", "title": "" }, { "docid": "7722150681c317197b752d52c269d697", "score": "0.7293057", "text": "function redirect(url) {\n window.location.replace(url); \n}", "title": "" }, { "docid": "ca271a08450e5987f63cd390e2c3c4db", "score": "0.72378427", "text": "function redirect(url) {\r\n\tlocation.replace(url);\r\n}", "title": "" }, { "docid": "3e6da66c64b0724c093de57b04837ff1", "score": "0.69636613", "text": "function reload() {\r\n window.location.href = window.location.href;\r\n}", "title": "" }, { "docid": "8205b6c5a6def05feff13620628d8654", "score": "0.6944879", "text": "function redirect() {\n window.location.replace(\"index.html\");\n}", "title": "" }, { "docid": "7ded1a3dff845288ecc139b91be816f4", "score": "0.69392043", "text": "replacePage(view, query) {\n window.history.replaceState(view, \"\", view.uri);\n this._navigate(view, query);\n }", "title": "" }, { "docid": "51a9c47f1d21541e6ae1d8ffbfb3be8b", "score": "0.6936107", "text": "function rhref(url){\n\twindow.location.href = url;\n}", "title": "" }, { "docid": "02bbbda459fab8e24dd3549e6613574b", "score": "0.69339114", "text": "function reload() {\r\n window.location.href = window.location.href;\r\n}", "title": "" }, { "docid": "712768184863900b2107ff4aa8850da6", "score": "0.69166267", "text": "function mandarAinicio(){\r\n window.location.replace(\"index.html\");\r\n}", "title": "" }, { "docid": "712768184863900b2107ff4aa8850da6", "score": "0.69166267", "text": "function mandarAinicio(){\r\n window.location.replace(\"index.html\");\r\n}", "title": "" }, { "docid": "f163a9d66325f4a23f2e58e9dce2ec08", "score": "0.68443745", "text": "function again() {\n\twindow.location = window.location.pathname + document.getElementById(\"switch-renderer\").getAttribute(\"href\");\n\twindow.location.reload(true);\n}", "title": "" }, { "docid": "4318d24b03afff745f034e89ebd62d04", "score": "0.6841853", "text": "function gotourl(url) {\n\twindow.location = url;\n}", "title": "" }, { "docid": "fe20c57540ae0e9a4218b1f2ef9c1d3b", "score": "0.68372303", "text": "function go_home(){\r\n\twindow.location.replace('#mainpage');\r\n\twindow.location.reload(true);\r\n}", "title": "" }, { "docid": "0c2aeb86682fd5fb24a526e1ab9efe43", "score": "0.6821032", "text": "function backToIndex (){\n location.replace(\"./index.html\");\n}", "title": "" }, { "docid": "f0b71010312912fb80cd6c97a6d611c4", "score": "0.6799816", "text": "function cleanUp(){\n if(history.location.pathname !== '/'){\n history.replace('/');\n }\n}", "title": "" }, { "docid": "d19888f5fb7fc589b79b5db6034cf3f7", "score": "0.67668104", "text": "function resetBrowserUrl() {\n window.history.pushState({}, document.title, window.location.pathname+\"?console=\"+getParameterByName(\"console\").replace('/',''));\n}", "title": "" }, { "docid": "e9fb4ff1ccdcf53917188a272d5854c3", "score": "0.6755319", "text": "function nochace() {\n\twindow.location.reload(true);\n}", "title": "" }, { "docid": "d8af98775af94e80595a888806e9f3cf", "score": "0.6753083", "text": "function nextPage (url, replace) {\n if (replace)\n window.history.replaceState(document.location.href, \"\", url);\n else\n window.history.pushState(document.location.href, \"\", url);\n\n render();\n }", "title": "" }, { "docid": "6a65c79a9aed03e6eb7aeb95397c39c1", "score": "0.6748491", "text": "function tohistory(e) {\n\te.preventDefault();\n\twindow.location.assign(\"/history.html\");\n}", "title": "" }, { "docid": "98fb77fb82b69a9a22882c4663b9d88e", "score": "0.67431873", "text": "function apocalypse() {\n location.reload();\n}", "title": "" }, { "docid": "d55527c6411ed39becd28704ca074268", "score": "0.6742557", "text": "redirectBack() {\n window.location.href = url(this.getPreviousRoute());\n }", "title": "" }, { "docid": "bcff056374609f9e13347c0d252f394a", "score": "0.67351145", "text": "function redirigirA(url) {\n win.location.href = urlBase + url;\n }", "title": "" }, { "docid": "b47d3f56720b14767c6e5cbd2d3a9647", "score": "0.6707897", "text": "function setLocation(curLoc)\n{\n try \n\t{\n history.pushState(null, null, curLoc);\n return false;\n } \n\tcatch(e) \n\t{\n\t\t\n\t}\n location.hash = '#' + curLoc;\n}", "title": "" }, { "docid": "87a6ab31ce256d7a7e7f8131491e8638", "score": "0.66952723", "text": "function relocate(s) {\n history.replaceState(null, null, s);\n}", "title": "" }, { "docid": "89f10814a1590369e76d4ebe14c2707e", "score": "0.66920644", "text": "function navigateTo(url) {\n window.location = url;\n }", "title": "" }, { "docid": "466092c5f207c57a03e467148adbb802", "score": "0.6665109", "text": "function goBack() {\n window.location.replace(\"redirect_mainpage.html\");\n }", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "d721b87ef2af93a2682cac550598c397", "score": "0.66650796", "text": "function clear() {\n location.replace(\"#!\");\n}", "title": "" }, { "docid": "9fa8aae7f003df318dee411b7cd8c9d0", "score": "0.66638494", "text": "function back_reload() {\r\n if (document.referrer) \r\n window.location.href = document.referrer + '?tmp=' + Math.random(); \r\n else \r\n history.back(); // no chance to raload\r\n}", "title": "" }, { "docid": "2405315f47c91fc3003226b6b348ba0f", "score": "0.6651683", "text": "function book4() {\n window.location.replace(\"/book/4\")\n}", "title": "" }, { "docid": "ae135434f4cab2141bedbbcd0338283f", "score": "0.66487956", "text": "function redirect(url) {\n\twindow.location = url;\n}", "title": "" }, { "docid": "ae135434f4cab2141bedbbcd0338283f", "score": "0.66487956", "text": "function redirect(url) {\n\twindow.location = url;\n}", "title": "" }, { "docid": "0e678763cd35cf32417fda3c31644aa3", "score": "0.6618709", "text": "function backToSearch() {\n location.assign(\"index.html\");\n}", "title": "" }, { "docid": "b986ce7ab3d42303838bab1f58679af1", "score": "0.659377", "text": "function goHere(url) {\r\n\twindow.location=url;\r\n}", "title": "" }, { "docid": "771651eff57da40915eda3b31dc1e057", "score": "0.65750253", "text": "function book3() {\n window.location.replace(\"/book/3\")\n}", "title": "" }, { "docid": "dc5708351c1363f3f5aab55043b786c5", "score": "0.6561413", "text": "function redirect(url) {\n window.location.href = url;\n}", "title": "" }, { "docid": "9cd0a5a78627e35b4b0e66ca49c1c36f", "score": "0.6545018", "text": "function redirect(url){\n window.location.href = url;\n}", "title": "" }, { "docid": "c7ec5a904a365c9b2bbd5f3fff4be12a", "score": "0.6544848", "text": "function redirect_form(){\n window.location.replace(\"http://localhost:9094/newRequest\");\n}", "title": "" }, { "docid": "ac4ec3354ce25680dd26a20348507210", "score": "0.6542791", "text": "function goBack() {\n location.reload();\n}", "title": "" }, { "docid": "b80a9b43dccac2c30c8c0a6c8d19d330", "score": "0.6535151", "text": "deshabilitaRetroceso() {\n window.location.hash = \"no-back-button\";\n window.location.hash = \"Again-No-back-button\"; //chrome\n window.onhashchange = function () { window.location.hash = \"no-back-button\"; };\n }", "title": "" }, { "docid": "36e77cfe995be5eb8d7915f0a2bf54cf", "score": "0.6529804", "text": "function book2() {\n window.location.replace(\"/book/2\")\n}", "title": "" }, { "docid": "5d70457ba9e6312690457e4e51c3e832", "score": "0.65176994", "text": "function redirect(url){\n window.location.href=url;\n}", "title": "" }, { "docid": "1a5eae3199e8cb0d5a0869f89a6062a8", "score": "0.6512302", "text": "function cancelUpdate(){\n window.location.replace(\"http://localhost:8080/static/favorites.html\");\n}", "title": "" }, { "docid": "5c237c00e387e43c015d79db739742a7", "score": "0.6511523", "text": "forward() {\n\t\twindow.history.forward();\n\t}", "title": "" }, { "docid": "b0260d691ee6477591b6cc6cad6fc381", "score": "0.65113103", "text": "navigate(a){window.history.pushState(null,a,a),s.routeChange()}", "title": "" }, { "docid": "229c98ea3f13a97ecd25427f7d5d1edd", "score": "0.65044254", "text": "function VisitPage(url) {\n window.location = url;\n}", "title": "" }, { "docid": "17e44392be0a18a2dfe8e56537e0f947", "score": "0.64980423", "text": "function redirect(url){\n\twindow.location.href = url;\n}", "title": "" }, { "docid": "abd22ed663ad46275c8be8e0c6fc0776", "score": "0.64964086", "text": "function tooYoung() {\n window.location.replace('https://disneyland.disney.go.com/');\n}", "title": "" }, { "docid": "603e79c641fa7ea87767d1f74e94c589", "score": "0.6491846", "text": "redirectToPage(redirectURL) {\r\n this.urlPath = getCurrentURL();\r\n if (this.urlPath != redirectURL && !contains(this.urlPath, redirectURL + '/')) {\r\n browserHistory.push(redirectURL);\r\n }\r\n }", "title": "" }, { "docid": "0e16f40cd0b8f90c643198f12b458acf", "score": "0.6484984", "text": "function bye(){\n\talert(\"Good bye ^^\");\n\tlocation.replace(\"../home.html\");\n}", "title": "" }, { "docid": "47a6d01768376cf7ee145af9dd9790f0", "score": "0.64820987", "text": "function redirect(url){\n location.href = url;\n}", "title": "" }, { "docid": "3bb947fb4201a8f37c87b45c3c37b4b5", "score": "0.64800745", "text": "function refresh() {\n // location.reload()\n // location.replace('https://www.youtube.com/watch?v=87C5iuGaCq0&ab_channel=HiteshChoudhary')\n // location.assign('https://www.youtube.com/watch?v=87C5iuGaCq0&ab_channel=HiteshChoudhary')\n // location.href = ('https://www.youtube.com/watch?v=87C5iuGaCq0&ab_channel=HiteshChoudhary')\n}", "title": "" }, { "docid": "60c34067dbf9b6a18f2e0a750835eac8", "score": "0.64768106", "text": "function goToUrl(newPage) {\n window.location = newPage;\n}", "title": "" }, { "docid": "decf0414a150033abef5ce6a4df98bb0", "score": "0.6472442", "text": "function deshabilitaRetroceso(){\n window.location.hash=\"no-back-button\";\n window.location.hash=\"Again-No-back-button\" //chrome\n window.onhashchange=function(){window.location.hash=\"no-back-button\";}\n}", "title": "" }, { "docid": "25fa5482bd9b20e3999f71d32fecf17c", "score": "0.6471512", "text": "function Reset() {\n window.location.href = baseUrl;\n}", "title": "" }, { "docid": "b87d48961988abab25ec1c90018dc23a", "score": "0.646297", "text": "function back(){\r\n window.location.href = \"index.html\"\r\n}", "title": "" }, { "docid": "9bf22360caba1e7f400089dde78d112b", "score": "0.6461089", "text": "function reloadHome(){\n\twindow.location = \"maps.html\";\n}", "title": "" }, { "docid": "135029b73b29a1be1384b2ab1e210c0a", "score": "0.645761", "text": "function handleRedirect(url) {\n\t\t\twindow.location = url;\n\t\t}", "title": "" }, { "docid": "e0081d44a5033ef55bf5444bbb750027", "score": "0.6451466", "text": "function changeHistoryState(url) {\n window.history.pushState(null, null, url);\n }", "title": "" }, { "docid": "13238b82d98d84a0fe54354753f2a0fb", "score": "0.6445625", "text": "function book1() {\n window.location.replace(\"/book/1\")\n}", "title": "" }, { "docid": "303536c39bad1e5349694d23e14cc123", "score": "0.6441959", "text": "function cambiaURL(url){\nwindow.location.reload() = url\n}", "title": "" }, { "docid": "02d1533c66f7a567d6a8f8cf8da9eb11", "score": "0.6439538", "text": "backToLogin(){\n\t\t window.location.href = '#/login';\n\t }", "title": "" }, { "docid": "1bd68392718a6ba15b649137c1f4c2a6", "score": "0.643604", "text": "function redirectTo(path){\r\n window.location.href = \"\" + path;\r\n}", "title": "" }, { "docid": "caa763bf073976a560ee544ebff88c62", "score": "0.643432", "text": "function goToHighScore(){\n window.location.replace(\"./highscores.html\") \n}", "title": "" }, { "docid": "29866e49d37a8390ab9f5c4de532a662", "score": "0.6421243", "text": "function redirHome()\n{\n\tlocation.href = \"index.html\";\n}", "title": "" } ]
24a17c9f7b97185c89e154ae4d71b8db
/ constructor() NAME constructor SYNOPSIS constructor(newId) newId > string of player id DESCRIPTION constructor RETURNS AUTHOR Lauren Mihalik DATE 2/1/2018
[ { "docid": "b97ef2a6521d1742cee592035efda0ce", "score": "0.6865479", "text": "constructor(newId){\n this.chipCount=1000;\n this.playerId=newId;\n this.playerName=\"\";\n this.ready=false;\n this.cards=[];\n this.roundBet=0;\n this.folded=true;\n this.allIn=false;\n this.isComputer=false;\n this.didBet=false;\n }", "title": "" } ]
[ { "docid": "c4ba116becb06a157cc3c36c1cc9ac09", "score": "0.7518883", "text": "constructor(playerID) {\n this.playerID = playerID;\n }", "title": "" }, { "docid": "49a95f56613774988136dc50e01546af", "score": "0.7072218", "text": "constructor(name,id){//constructor is like a function \n this.name = name;\n this.id = id}", "title": "" }, { "docid": "7eeed2e0b0ffb7e41aabfebc9597e1dd", "score": "0.68790555", "text": "constructor(id, players, pool) {\n this.id = id;\n this.players = players;\n this.pool = pool;\n }", "title": "" }, { "docid": "1bea59fc2c4345e8e9a31f10824ad653", "score": "0.6835804", "text": "constructor(name, id) {\n this.name = name;\n this.id = id;\n }", "title": "" }, { "docid": "fcf72bd9adbab684109d557966fe5d10", "score": "0.6603693", "text": "constructor(id, name) {\n //instance variables, \n this.id = id;\n this.name = name;\n \n }", "title": "" }, { "docid": "079f9049b03ac5dc98b019abe7df83cd", "score": "0.65893275", "text": "constructor (id) {\n this.id = id;\n }", "title": "" }, { "docid": "ea7139e7cf761a34d75bb504b07183ff", "score": "0.6573504", "text": "constructor(id = 34, name = 'john') {\n this.id = id;//34;\n this.name = name; 'john';\n }", "title": "" }, { "docid": "ee591006131b43384f69d73e07d04471", "score": "0.6491284", "text": "constructor(_id, _name) {\n this.id = _id;\n this.name = _name;\n }", "title": "" }, { "docid": "d8cf4fa1ff1d8d7c4f3febba62155065", "score": "0.647675", "text": "constructor(id, name) {\n this.id = id;\n this.name = name;\n // this.id = id;\n // this.name = name;\n }", "title": "" }, { "docid": "d8cf4fa1ff1d8d7c4f3febba62155065", "score": "0.647675", "text": "constructor(id, name) {\n this.id = id;\n this.name = name;\n // this.id = id;\n // this.name = name;\n }", "title": "" }, { "docid": "3f529d849c3d69126aee4ede5ade9408", "score": "0.6469273", "text": "constructor(id, name) {\n this.id = id;\n this.name = name;\n }", "title": "" }, { "docid": "c774abf5279f2e21901c1aa74259b620", "score": "0.646115", "text": "constructor(id) {\n this.id=id;\n \n\n }", "title": "" }, { "docid": "9161afc3c4ee7e160834078448b4c3b3", "score": "0.6457151", "text": "function NewPlayer(name) {\n this.name = name;\n this.hand = [];\n this.score = 0;\n this.bet = 0;\n this.bank = 1000;\n}", "title": "" }, { "docid": "ef99431f1b5b70b766d48d03ae2fb166", "score": "0.6411956", "text": "constructor(id = 1, name = 'default') {\n this.id = id;//1;\n this.name = name;// 'subramanian';\n }", "title": "" }, { "docid": "8d129c1aae7e5a05a8971874150ce29d", "score": "0.6388791", "text": "function Clicli(id, username) {\n //this.id = id;\n this.username = username;\n}", "title": "" }, { "docid": "106e7959c33282d177696f3c595c2ba4", "score": "0.6345824", "text": "function createPlayer(id, name, avatar_filepath, condition) { \n this.id = id; \n this.name = name; \n this.avatar_filepath = avatar_filepath;\n this.condition = condition;\n\n this.money = startAmount;\n this.numCorrect = 0;\n this.numWasCopied = 0;\n this.numCopyingOther = 0; \n}", "title": "" }, { "docid": "0936a2f7de15a02a5aff16b34811bf62", "score": "0.6324143", "text": "createPlayer(playerID) {\n // pos, size, health, strength, texture, hitSpeed, movementSpeed, direction\n this.players[playerID] = new Player({x: 40, y: 30}, {width:10, height:10}, 1000, 100, \"\", 10, 1, 0);\n }", "title": "" }, { "docid": "d2bd88d01ff75bb5775b38b94d4a9081", "score": "0.6226163", "text": "constructor(id, name) {\n\t\t//private id property\n\t\tthis._id = id;\n\t\t//public name property\n\t\tthis.name = name;\n\t}", "title": "" }, { "docid": "702d733c9e8210bb0fc5a00e4ca384ec", "score": "0.6210463", "text": "constructor(id, name, year, writer, nop) {\n this.id = id\n this.name = name\n this.year = year\n this.writer = writer\n this.nop = nop\n }", "title": "" }, { "docid": "d33ef13854fbf5cc9f9be0de424f348c", "score": "0.620399", "text": "function Player (playerID) {\n this.playerID = playerID;\n // this.playerID = [1,2];\n this.roundScore = 0;\n this.totalScore = 0;\n}", "title": "" }, { "docid": "141d437428eee178d9ba7a5a06d5ec44", "score": "0.6201028", "text": "function Player(pName, pID) {\n\n\t// Object variables\n\tvar _genericName = pName;\n\tvar _name = pName;\n\tvar _pID = pID;\n\tvar _isLeader = false;\n\tvar _type = PlayerType.RESISTANCE;\n\tvar _ready = false;\n\tvar _connected = true;\n\n\tthis.getName = function() { return _name; };\n\tthis.getGenericName = function() { return _genericName; };\n\tthis.getId = function() { return _pID; };\n\tthis.isConnected = function() {return _connected; };\n\tthis.changeName = function(name) { _name = name; };\n\tthis.setLeader = function(isLeader) { _isLeader = isLeader; };\n\tthis.getIsLeader = function() {return _isLeader; };\n\tthis.setType = function(type) { _type = type; };\n\tthis.getType = function() { return _type; };\n\tthis.isReady = function() { return _ready; };\n\tthis.setReady = function(ready) { _ready = ready; };\n\tthis.setConnected = function(con) { _connected = con };\n\tthis.setId = function(id) { _pID = id; };\n\tthis.toggleReady = function() { _ready =! _ready };\n}", "title": "" }, { "docid": "8ba34a3e5251c28c59868f4cc460a5cf", "score": "0.6198729", "text": "constructor(player)\n {\n this.player = player;\n }", "title": "" }, { "docid": "7d74c5461484aed0d081c09bd7f1700e", "score": "0.61798835", "text": "constructor (player) {\n this.player = player;\n }", "title": "" }, { "docid": "8caac3a689811765299eface4ad8a12f", "score": "0.61620665", "text": "function createPlayer() {\n\n\t// Add the name of the player\n\tthis.Name = \"\";\n\n\t// Add the gender of the player\n\tthis.gender = \"\";\n\n\t// Add the amount of money for the player\n\tthis.money = \"\";\n\n\t// Add the starter TopoPet name\n\tthis.starterTopoPet = \"\";\n\n\t// Add the active TopoPets names\n\tthis.activeTopoPet1 = \"\";\n\tthis.activeTopoPet2 = \"\";\n\tthis.activeTopoPet3 = \"\";\n\tthis.activeTopoPet4 = \"\";\n\tthis.activeTopoPet5 = \"\";\n\n\t// Add the computerTopoPets\n\tfor (i = 0; i < 100; i++) {\n\t\tvar computerTopoPetNumber = i + 1;\n\t\tvar computerTopoPetCall = \"computer\" + computerTopoPetNumber;\n\t\tthis[computerTopoPetCall] = 0;\n\t};\n\n\t// Add the TopoPets caught\n\tthis.topoPetsCaught = topoPetsCaught;\n}", "title": "" }, { "docid": "3a0da5df0703c121ff9db55d7d6bc1ca", "score": "0.61299074", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x42ff96ed;\n this.SUBCLASS_OF_ID = 0xd48afe4f;\n\n this.video = args.video || null;\n this.userId = args.userId;\n this.randomId = args.randomId !== undefined ? args.randomId : readBigIntFromBuffer(generateRandomBytes(4),false,true);\n this.gAHash = args.gAHash;\n this.protocol = args.protocol;\n }", "title": "" }, { "docid": "ce9db308a75a03f88d2bbd77fa101c3c", "score": "0.6126488", "text": "function Player(id, slot)\n{\n this.id = null;\n this.slot = slot;\n this.name = \"\";\n this.gender = eGender.FEMALE;\n this.size = eSize.MEDIUM;\n //this.state = new PlayerState();\n //this.wardrobe = new Wardrobe();\n //this.hand = new PokerHand();\n this.out = false;\n //this.forfeit = new Forfeit();\n //this.ticket = new Ticket();\n this.xml = null;\n this.listing = null;\n}", "title": "" }, { "docid": "a7fcaf4fef2f5100a6fdbc051aa9f19e", "score": "0.6041837", "text": "constructor({ x = 10, y = 10, w = 30, h = 30, main, score = 0, id }) {\n this.x = x;\n this.y = y;\n this.w = y;\n this.h = h;\n this.speed = 5;\n this.score = score;\n this.id = id;\n this.movementDirection = {};\n this.isMain = main;\n console.log('A player has been created');\n }", "title": "" }, { "docid": "60b7e6d4c8959cd4433ccc753d010ff2", "score": "0.6025672", "text": "function initNewPlayer(newUser,socketId) {\r\n\r\n //Determine slot nr to use (the lowest free slot nr), and use it's slot metadata as properties for the new user\r\n //Max 4 players, maybe larger in the future\r\n for (slot = 0; slot <= 3; slot++) {\r\n var slotfound =0\r\n for (var player in players) {\r\n if (players[player].slot == slot) { slotfound = 1}\r\n }\r\n if (slotfound == 0) {\r\n console.log(\"slot nr \" + slot + \" is the lowest free slot, assigning to user \" + newUser );\r\n var newPlayer = slots[slot]\r\n newPlayer[\"name\"] = newUser\r\n newPlayer[\"socketid\"] = socketId\r\n return newPlayer\r\n }\r\n }\r\n\r\n //let newplayer = { name: newUser, direction: \"R\", x1: 100, y1 : 900, x2: 100, y2 : 900,speed : 1}\r\n console.log(\"All slots are taken allready, user cant play B:(\" );\r\n return {}\r\n }", "title": "" }, { "docid": "f007f58500b9ba32f69e9d3fc19f956d", "score": "0.6008393", "text": "SinglePlayer() {}", "title": "" }, { "docid": "53b903a479258024ba0aef2863f231c4", "score": "0.5984289", "text": "function Player(name, id) {\n console.log('Player');\n this.id = id;\n this.name = name;\n this.hand = null;\n this.score = 0;\n this.onesBank = 20;\n this.fivesBank = 30;\n this.tensBank = 50;\n this.totalBank = 100;\n this.onesBet = 0;\n this.fivesBet = 0;\n this.tensBet = 0;\n this.bgParams = this.playerParams(id, \"bg\");\n this.btnParams = this.playerParams(id, \"btn\");\n this.textParams = this.playerParams(id, \"text\");\n this.inputParams = this.playerParams(id, \"input\");\n this.imageParams = this.playerParams(id, \"image\");\n }", "title": "" }, { "docid": "29ab60719457bb7b2dd774e68137a4a2", "score": "0.59650856", "text": "constructor(_id, name, creator, status, startDate, endDate, winner, players) {\n this._id = _id;\n this.name = name;\n this.creator = creator;\n this.status = status;\n this.startDate = startDate;\n this.endDate = endDate;\n this.winner = winner;\n this.players = players;\n this.boards = {};\n }", "title": "" }, { "docid": "1e07fb8ce8355e395fdbc66fec1e57c8", "score": "0.59500307", "text": "function Person(id){\r\n let id=id;\r\n this.name='hat';\r\n this.setId=function(id){\r\n _id=id;\r\n }\r\n this.getId=function(){\r\n return _id;\r\n }\r\n}", "title": "" }, { "docid": "1e0896c39716e4e0260ee9aed2ee4498", "score": "0.5944828", "text": "function Person(id) {\n\tthis.id = id;\n}", "title": "" }, { "docid": "50ce3282baddfe3353f6039b0293db8e", "score": "0.5921625", "text": "initPlayer(username, socketId) {\n const newPlayer = new Player(username, socketId, Object.keys(this.playerList).length === 0);\n this.playerList[socketId] = newPlayer;\n return newPlayer;\n }", "title": "" }, { "docid": "d4c107b5780dbf62d0868d6ab908aa47", "score": "0.5903802", "text": "function Player(team) {\n //this.name = ...\n //this.position = ...\n}", "title": "" }, { "docid": "6f077f512ad16cdcec5a3a9165b6bf69", "score": "0.59026474", "text": "function newPlayerID(gameID, name, phoneNumber) {\n return (gameID.toString().replace(/ +/g, \"\") + name.replace(/ +/g, \"\") + phoneNumber.replace(/ +/g, \"\")).toLowerCase(); // remove whitespace from id\n}", "title": "" }, { "docid": "fd48b44d50dc57283100a8f31683ad1f", "score": "0.5881293", "text": "constructor (playerId, score) {\n this.playerId = playerId\n this.scores = []\n // At the time of initialization, totalScore is\n // the score with which the player is created.\n this.totalScore = score\n this.scores.push(score)\n }", "title": "" }, { "docid": "63ae27a830782317ab41fbf08c40ed57", "score": "0.5876605", "text": "constructor(id,title,release_date,producer,director,description)\n{\n this.id=id;\n this.title=title;\n this.release_date=release_date;\n this.producer=producer;\n this.director=director;\n this.description=description;\n}", "title": "" }, { "docid": "c903564703d965392e839a294b5486f9", "score": "0.5868384", "text": "constructor(name, numPlayers)\n {\n this.name = name;\n this.numPlayers = numPlayers;\n this.record = [0,0];\n }", "title": "" }, { "docid": "562a16ea7fe8c6588d5c54eb38939b75", "score": "0.5853155", "text": "function makeCard(id) {\n\tvar card = {id:id};\n\tcard.rank = makeCard.rank;\n\tcard.suit = makeCard.suit;\n\tcard.cardID = makeCard.cardId;\n\tcard.color = makeCard.color;\n\tcard.cardName = makeCard.cardName;\n\tcard.precedes = makeCard.precedes;\n\tcard.sameColor = makeCard.sameColor;\n\tcard.nextInSuit = makeCard.nextInSuit;\n\tcard.prevInSuit = makeCard.prevInSuit;\n\treturn card;\n}", "title": "" }, { "docid": "7921b095115796add4e8f4c3ca9bb855", "score": "0.58508825", "text": "function createNewPlayer(socketId) {\n return {\n x: Math.floor(Math.random()*700)+50,\n y:Math.floor(Math.random()*500)+50,\n vx: 0.05, //velocity to achieve smooth motion of character, range 0-1\n vy: 0.05,\n playerId: socketId};\n}", "title": "" }, { "docid": "7dcefc9a593b3ee55fbcab003c817580", "score": "0.58406824", "text": "function newPlayer(gameID, name, phoneNumber, creditZar) {\n var playerID = newPlayerID(gameID, name, phoneNumber)\n\n var p = parseFloat(creditZar);\n var c = game[gameID].settings.playerDefaultCredit + p;\n\n game[gameID].player[playerID] = {\n name : name,\n phoneNumber : phoneNumber,\n creditZar : c,\n creditNok : convertZarNok(gameID, c),\n totalZar : 0,\n totalNok : 0,\n };\n\n return playerID;\n}", "title": "" }, { "docid": "c7cd23570d08e2ccf3fb5849abedbf5c", "score": "0.58155197", "text": "function Player(id, mark) {\n this.id = id;\n this.mark = mark;\n}", "title": "" }, { "docid": "6e4807f833c5afa051e47b3a222edc22", "score": "0.58062655", "text": "function initialNewPlayers() {\n player1 = new PlayerOne();\n player2 = new PlayerTwo();\n \n}", "title": "" }, { "docid": "4c53a930dd1df8dbf6a08b1df73ca264", "score": "0.5797605", "text": "function Player() { }", "title": "" }, { "docid": "8804083cce0d2f1efbfeb09f262cf966", "score": "0.57937986", "text": "function Player() {} //A function that returns nothing and creates nothing", "title": "" }, { "docid": "d78bb2056a06651a5aff03d04b4b202a", "score": "0.5786441", "text": "function CreatePlayer(name) {\n this.name = name;\n this.totalGame = 0;\n this.win = 0;\n this.losing = 0;\n this.draw = 0;\n this.choice = undefined;\n}", "title": "" }, { "docid": "ce2fe2f4df88974e219e11267f86073c", "score": "0.5781429", "text": "create (id, data) { return { id: id, data: data } }", "title": "" }, { "docid": "f02e79f7221bb0f62f9517e09b363c67", "score": "0.5755333", "text": "getOrCreatePlayer(playerID){\n return this.playerInfos.getOrCreate(playerID);\n }", "title": "" }, { "docid": "e55e77bb8fab5ec820e794841766e123", "score": "0.57513416", "text": "function createPlayerObject(playerid, activity, data, mode) {\n\n var alliance = _.find(data.alliances, {'ID': data.players[playerid].allianceID})\n\n if(alliance) {\n var alliancename = alliance.name\n } else {\n var alliancename = 'n/a'\n }\n\n switch(mode) {\n case 'new':\n var newPlayer = { // Create new Player object to update old one\n playerid: data.players[playerid].ID,\n name: data.players[playerid].name,\n allianceid: data.players[playerid].allianceID,\n alliancename: alliancename,\n points: [data.players[playerid].points],\n rank: [data.players[playerid].rank],\n towns: [data.players[playerid].towns],\n killsall: [data.playerkillsall[playerid].points],\n killsall_rank: data.playerkillsall[playerid].rank,\n killsoff: [data.playerkillsoff[playerid].points],\n killsoff_rank: data.playerkillsoff[playerid].rank,\n killsdef: [data.playerkillsdef[playerid].points],\n killsdef_rank: data.playerkillsdef[playerid].rank,\n activity: activity.points,\n killsoff_activity: activity.killsoff\n }\n break\n case 'update':\n var newPlayer = { // Create new Player object to update old one\n playerid: data.players[playerid].ID,\n name: data.players[playerid].name,\n allianceid: data.players[playerid].allianceID,\n alliancename: alliancename,\n $push: {\n points: {\n $each: [data.players[playerid].points],\n $slice: -c.arrayLimit\n },\n rank: {\n $each: [data.players[playerid].rank],\n $slice: -c.arrayLimit\n },\n towns: {\n $each: [data.players[playerid].towns],\n $slice: -c.arrayLimit\n },\n killsall: {\n $each: [data.playerkillsall[playerid].points],\n $slice: -c.arrayLimit\n },\n killsoff: {\n $each: [data.playerkillsoff[playerid].points],\n $slice: -c.arrayLimit\n },\n killsdef: {\n $each: [data.playerkillsdef[playerid].points],\n $slice: -c.arrayLimit\n }\n },\n killsall_rank: data.playerkillsall[playerid].rank,\n killsoff_rank: data.playerkillsoff[playerid].rank,\n killsdef_rank: data.playerkillsdef[playerid].rank,\n activity: activity.points,\n killsoff_activity: activity.killsoff\n }\n break\n }\n return newPlayer\n}", "title": "" }, { "docid": "2ea976eb4b0ed98973d4aba240f25959", "score": "0.5750246", "text": "constructor(id, title, date, description, username, tags){\n\t\tthis.id = \"hi\",\n\t\tthis.title = title,\n\t\tthis.date = date,\n\t\tthis.description = description,\n\t\tthis.username = username,\n\t\tthis.tags = tags\n\t}", "title": "" }, { "docid": "adb6901386f5367c745363b1aa1aead5", "score": "0.5722255", "text": "constructor(id, name, price) {\n this.id = id;\n this.name = name;\n this.price = price;\n }", "title": "" }, { "docid": "a767178f5b7b66d5e474686f2599e101", "score": "0.57122284", "text": "function callConstructor(id, parametros, l, c) {\n this.id = id;\n this.parametros = parametros;\n this.l = l;\n this.c = c;\n }", "title": "" }, { "docid": "6f95bdde05871772e6904b8583204d0f", "score": "0.56993556", "text": "function createNewPlayer (folder, first, last, label, gender, clothing, out, forfeit, timer, current, stage, state, xml) {\n var newPlayerObject = {folder:folder,\n first:first,\n last:last,\n label:label,\n gender:gender,\n clothing:clothing,\n out:out,\n forfeit:forfeit,\n timer:timer,\n current:current,\n\t\t\t\t\t\t stage:stage,\n state:state,\n xml:xml};\n \n return newPlayerObject;\n}", "title": "" }, { "docid": "48101d98d82c27d4aad653deda382126", "score": "0.569668", "text": "function generateNewPiece(id) {\n let p = new Pieces.Piece(id);\n [p.row, p.col] = Pieces.SpawnPositions[id];\n return p;\n }", "title": "" }, { "docid": "6a4bd14113df4245ca1acb6be201f190", "score": "0.5684405", "text": "constructor(id, gold, ammoAmount, selectedSkinID, minutesPlayed) {\n this.id = id;\n this.gold = gold;\n this.ammoAmount = ammoAmount\n this.selectedSkinID = selectedSkinID;\n this.minutesPlayed = minutesPlayed;\n }", "title": "" }, { "docid": "d5cd02361646881404d9d79810e5c272", "score": "0.56807274", "text": "function Player(){}", "title": "" }, { "docid": "22d8797c2f573889ea2eb8696634a60b", "score": "0.56574154", "text": "Initialize(IObjectId, int) {\n\n }", "title": "" }, { "docid": "713eb4b30867a721088159637e88a66d", "score": "0.56545496", "text": "constructor(player, xOld, yOld, zOld, xNew, yNew, zNew) {\n\t\t\tthis.player = player;\n\t\t\tthis.xOld = xOld;\n\t\t\tthis.yOld = yOld;\n\t\t\tthis.zOld = zOld;\n\t\t\tthis.xNew = xNew;\n\t\t\tthis.yNew = yNew;\n\t\t\tthis.zNew = zNew;\n\t\t\t\n\t\t}", "title": "" }, { "docid": "ce89c6ac0c7b0daa9f9d9de56d9173e7", "score": "0.56487054", "text": "addPlayer(firstName, lastName, age){\n let newPlayer = {firstName: firstName,\n lastName: lastName,\n age: age};\n this._players.push(newPlayer);\n }", "title": "" }, { "docid": "20e612459b0fa1c865c21987a8d6c57c", "score": "0.56417084", "text": "function Player() {\n this.id = null;\n this.isHero = 0; // Possibility of being morgana, same below\n this.isVillain = 0;\n this.isInnocent = 0;\n this.isMorgana = 0;\n this.isAssasin = 0;\n this.isMordred = 0;\n this.isMerlin = 0;\n this.isPercival = 0;\n this.isDummy = 0;\n\n this.identity = null;\n }", "title": "" }, { "docid": "5ca1aff70c16e3e5341b668a0cc35f71", "score": "0.5635257", "text": "constructor(id) {\n if(!(Number.isInteger(id) && id >= 0))\n {\n throw Error(`${id} is not a valid card ID`);\n }\n\n this._id = id;\n Object.freeze(this); \n }", "title": "" }, { "docid": "d1d7b7a321a51038e956a612c0465093", "score": "0.56221735", "text": "function newPlayer() {\n\t\t\tvm.Player = $PlayersSvc.initializePlayer(); // Inizializzo il giocatore\n\t\t}", "title": "" }, { "docid": "d8d705cf9c81380627edb30c1432f0f3", "score": "0.56198394", "text": "_createPlayers(){\n let p1 = new Player('Sam', true);\n let p2 = new Player('Jeff', false);\n let players = [p1,p2]\n return players;\n }", "title": "" }, { "docid": "6e79f6318a5e73e1708228b0705e5584", "score": "0.56020457", "text": "addPlayer(firstName, lastName, age){\n \n /*We want to add a new player to your team. Add a method addPlayer to\n\tyour team object. This method should take in three parameters:\n\tfirstName, lastName, and age. It should create a player object,\n\tand add them to the team's players array.*/\n let newPlayer = {\n firstName: firstName,\n lastName: lastName,\n age: age,\n };\n this._players.push(newPlayer);\n }", "title": "" }, { "docid": "44cc9a0af03b0e9fd3b68df2375392a8", "score": "0.56004167", "text": "static initialize(obj, id) { \n obj['id'] = id;\n }", "title": "" }, { "docid": "44cc9a0af03b0e9fd3b68df2375392a8", "score": "0.56004167", "text": "static initialize(obj, id) { \n obj['id'] = id;\n }", "title": "" }, { "docid": "44cc9a0af03b0e9fd3b68df2375392a8", "score": "0.56004167", "text": "static initialize(obj, id) { \n obj['id'] = id;\n }", "title": "" }, { "docid": "73be31d77e9cf3bccb2b815e7506fdbe", "score": "0.5595813", "text": "function createPlayer (nameP, surname, dateOfBirth, nameC, odds, continent, betAmount, country) {\n var person = new Person(nameP, surname, dateOfBirth); //dve promeniljive pod name... posle toga nameP i nameC\n //var betAmount = this.betAmount;\n\t\tvar country = new Country(nameC, odds, continent);\n return new Player (person, betAmount, dateOfBirth);\n }", "title": "" }, { "docid": "07bfa60ecd40206717ff469b32749d4c", "score": "0.5595625", "text": "function Car(id) { // notice capital letter\n this.carId = id;\n // if we created 100,000 car instances, \n // there would be 100,000 of these. \n // Use protoytpe to only create one instance\n this.start = function () {\n console.log('start: ' + this.carId);\n };\n}", "title": "" }, { "docid": "ad01d85aaa2ba04625771f9ee1ff90f6", "score": "0.55753326", "text": "constructor(id) {\n this._id = id;\n this._data = {};\n }", "title": "" }, { "docid": "04560db6840a6d289051ac8c17db87ce", "score": "0.55695885", "text": "function genPlayer(id) {\n return new YT.Player('player', {\n width: '100%',\n height: '100%',\n host: 'http://www.youtube-nocookie.com',\n videoId: id,\n playerVars: {\n origin: window.location.host,\n 'playsinline': 1,\n 'modestbranding': 1,\n 'disablekb': 1,\n 'iv_load_policy': 3,\n 'fs' : 0,\n },\n events: {\n 'onReady': onPlayerReady,\n 'onStateChange': checkPlayer, \n }\n });\n}", "title": "" }, { "docid": "742219df40b80687e69f86b2b1aa9538", "score": "0.55694807", "text": "function Player(uuid, turnOrder, colour, score) {\n this.uuid = uuid;\n this.turnOrder = turnOrder;\n this.colour = colour;\n this.score = score;\n}", "title": "" }, { "docid": "58fddc01d15b1cf036a847e83ba53631", "score": "0.55657905", "text": "function RandomPlayer () {\n this.name = 'random';\n return Player.call(this);\n}", "title": "" }, { "docid": "4aa668730ec1ef473aae8aaec0af7173", "score": "0.55615705", "text": "function get_player_id(index){\n return player_id = \"player\" + (index + 1);\n}", "title": "" }, { "docid": "c6206a08716bb985a9ac95c0aaf74135", "score": "0.5561023", "text": "function Person(name, department, id) {\n this.id = id;\n this.name = name;\n this.dept = department;\n\n}", "title": "" }, { "docid": "4423dfa93a0af0260c200fcd72441baf", "score": "0.55582654", "text": "function new_player(state, player_id, mapping){\n /* CREATE NEW INSTANCE */\n const spriteWidth = 16;\n const spriteHeight = 16;\n\n var knightImg = new Image(spriteWidth * 6, spriteHeight); // width, height of resized knight image\n knightImg.src = \"assets/images/knight_run_spritesheet.png\";\n\n // knight run spritesheet data\n var knightSheet = {\n images: [knightImg],\n frames: {width: spriteWidth, height: spriteHeight},\n framerate: 15\n };\n\n // create sprites\t\n var knightSprite = new createjs.SpriteSheet(knightSheet);\n var animation = new createjs.Sprite(knightSprite);\n\n state[player_id] = {\n animation: animation,\n isMoving: false,\n facingRight: true,\n facingRightPrev: true,\n width: spriteWidth,\n height: spriteHeight,\n x: 0,\n y: 0\n }\n \n\n /* ADD TO RENDER */\n state[render_stage_id].addChild(state[player_id].animation);\n\n /* Register to Input Feedback */\n // state :: state object, player_id :: key in table, i + 1 :: player_input_mapping\n // player_input_mapping --> See input.js\n register_movable(state, player_id, movable_type_player, mapping, true);\n\n register_player_action(state, player_id, mapping);\n}", "title": "" }, { "docid": "ff7943c66728e51cc38cdbe6c9e937a9", "score": "0.55580175", "text": "MultiPlayer() {}", "title": "" }, { "docid": "7b67ab38c84768853c26e7ed8892a35e", "score": "0.5544119", "text": "constructor(){\n this.id;\n this.init;\n this.end;\n }", "title": "" }, { "docid": "7bac671f899598b38fc5d2db7ae442b8", "score": "0.5539415", "text": "function Player(id, name, x, y, score) {\n this.tag = document.createElement('div');\n this.tag.id = id;\n this.name = name;\n this.x = x;\n this.y = y;\n this.tag.setAttribute('style', 'left:' + x + 'px' + ';top:' + y + 'px' + ';width:' + 72.5 + 'px' + ';height:' +\n 100 + 'px'); //places player on board by appending css style\n this.score = score;\n }", "title": "" }, { "docid": "5bc6150d66e653d867c4eea79b613664", "score": "0.55299425", "text": "static initialize(obj, id, name) { \n obj['id'] = id;\n obj['name'] = name;\n }", "title": "" }, { "docid": "5bc6150d66e653d867c4eea79b613664", "score": "0.55299425", "text": "static initialize(obj, id, name) { \n obj['id'] = id;\n obj['name'] = name;\n }", "title": "" }, { "docid": "0bba9b80a5648427b3f829fb5bc90ccc", "score": "0.55285907", "text": "function Player()\n{\n}", "title": "" }, { "docid": "0bba9b80a5648427b3f829fb5bc90ccc", "score": "0.55285907", "text": "function Player()\n{\n}", "title": "" }, { "docid": "b98f81a61b7d1b5f847624350a05dfdf", "score": "0.5527355", "text": "constructor(id, name, breed, sex){\n this.id = id;\n this.name = name;\n this.breed = breed;\n this.sex = sex;\n }", "title": "" }, { "docid": "a901142af455e921cc171d3d33830ce4", "score": "0.55224115", "text": "function UUID(){\n this.id = this.createUUID();\n}", "title": "" }, { "docid": "41d535d414024c0a4f03cbe28d52637f", "score": "0.55205417", "text": "constructor(num, id) {\n this.id = id;\n this.num = num;\n this.numDone = 0;\n this.captions = [];\n this.drawings = [];\n this.completers = [];\n\n this.inProgress = false;\n this.completingPlayer = null;\n }", "title": "" }, { "docid": "1bbd6b65a82cda02bfb0ffeb0f46cd1f", "score": "0.5520259", "text": "addNewPlayer(id, user, name) {\r\n let room = this.getAvailableRoom();\r\n let player = room.addPlayer(id, user, name);\r\n\r\n this.playerRoomId[id] = room.id;\r\n\r\n this.sendInitialGameStatus(player, room);\r\n }", "title": "" }, { "docid": "ad654fe6571ba085730209fd0f35e2da", "score": "0.55189574", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x59ead627;\n this.SUBCLASS_OF_ID = 0x8af52aac;\n\n this.userInitiative = args.userInitiative || null;\n this.peer = args.peer;\n this.rating = args.rating;\n this.comment = args.comment;\n }", "title": "" }, { "docid": "73b09c799efda1405d9520cf20ca117d", "score": "0.55089647", "text": "function idGenerator() {\n\n}", "title": "" }, { "docid": "f057e954bb9a280925e996766391037f", "score": "0.550838", "text": "function Player(name,marker)\n{\n this.name=name;\n this.marker=marker;\n \n}", "title": "" }, { "docid": "d8ff6ab03115a0c3e06f379a60a7b708", "score": "0.5506524", "text": "constructor(t, d, r, u, rid, pid) {\n this.title = \"'\" + t + \"'\";\n this.description = \"'\" + d + \"'\";\n this.role = \"'\" + r + \"'\";\n // this.usedThisRound = u;\n //this.roomID = rid;\n // this.playerID = pid;\n }", "title": "" }, { "docid": "b8e2f6fffc3c9ad04117b1276d04932f", "score": "0.5501139", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xb2cbc1c0;\n this.SUBCLASS_OF_ID = 0x8af52aac;\n\n this.video = args.video || null;\n this.peer = args.peer;\n this.duration = args.duration;\n this.reason = args.reason;\n this.connectionId = args.connectionId;\n }", "title": "" }, { "docid": "9fe36d195edaac826e966423b389dca0", "score": "0.54988265", "text": "constructor(name, id, email) {\n // this . = value of parameter/prototypes\n this.name = name;\n this.id = id;\n this.email = email;\n }", "title": "" }, { "docid": "50b1cf5804c433527a06189a12918217", "score": "0.5496397", "text": "function makeCard(id) {\n var newCard = { number: id, };\n \n function inRange (number, min, max) {\n if (typeof (number) !== \"number\") {\n console.error('validation error! \"' + number + '\" is not a number');\n return NaN;\n } else if ((number <= max) && (number >= min)) {\n return true;\n } else {\n console.error('validation error! \"' + number + '\" is outside the given range');\n return undefined;\n }\n }\n \n if(!inRange(id, 0, 51)) { return false; }\n\n newCard.rank = makeCard.rank;\n newCard.suit = makeCard.suit;\n newCard.color = makeCard.color;\n newCard.cardID = makeCard.cardID;\n newCard.cardName = makeCard.cardName;\n newCard.precedes = makeCard.precedes;\n newCard.sameColor = makeCard.sameColor;\n newCard.nextInSuit = makeCard.nextInSuit;\n newCard.prevInSuit = makeCard.prevInSuit;\n newCard.inRange = inRange;\n\n return newCard;\n}", "title": "" }, { "docid": "9d1567418fb98e09847f50ca90720948", "score": "0.5496085", "text": "function newWeapon(gameID, name, cost, seller, text) {\n \n var weaponID = game[gameID].weaponIDcounter;\n game[gameID].weapon[weaponID] = {\n name : name,\n cost : cost,\n seller : seller,\n text : text,\n };\n\n game[gameID].weaponIDcounter++;\n return weaponID;\n}", "title": "" }, { "docid": "5d42bda15505c6a7b55bcc69172a93f5", "score": "0.5491444", "text": "addPlayer(firstName, lastName, age) {\n let player = {\n firstName: firstName,\n lastName: lastName,\n age: age\n };\n this.players.push(player);\n }", "title": "" }, { "docid": "68ae8a28a4b1477b5c3895051a426f65", "score": "0.54880553", "text": "createNewTask(name, id){\n class Task{\n constructor(name, id){\n this.id = id; \n this.name = name;\n this.completed = false; \n }\n }\n this.id++;\n return new Task(name, this.id); \n }", "title": "" }, { "docid": "5d0837f81f488c84f3aef48fef4b5612", "score": "0.54877377", "text": "function convertIdToPlayer(id) { \n pos = idLookup[id]; \n return dummyPlayers[pos]; \n}", "title": "" }, { "docid": "d08b45142e7b0abf685cef952249b8e4", "score": "0.5473886", "text": "function player(playerName, playerStatus, playerProfession, playerMoney)\n{\n this.playerName = playerName;\n this.playerStatus = playerStatus;\n this.playerProfession = playerProfession; //affects starting money\n this.playerMoney = playerMoney;\n}", "title": "" } ]
09e83e301cbaeacc545f4f1cc13f0e75
istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
[ { "docid": "237fed864f76ce8335e4a816e9a10279", "score": "0.0", "text": "validate(_value, _utils) {\n return false;\n }", "title": "" } ]
[ { "docid": "6438dc5dc8a642069883e4a871b2d3a0", "score": "0.73129296", "text": "function func1() { } // console.log(func1.length); expected output: 0", "title": "" }, { "docid": "cdc25548252d849f46182b1ea3ce29b3", "score": "0.6891401", "text": "function countArguments(func) {\n console.log(func.length);\n}", "title": "" }, { "docid": "40b5cce83914944d3980679b45970c2f", "score": "0.6839654", "text": "function functionLength(f) {\n return f._length || f.length;\n }", "title": "" }, { "docid": "5902ddcc13f50b4de74e779e15ead3ee", "score": "0.6518992", "text": "function Len() {\r\n}", "title": "" }, { "docid": "3de5ec7fbef84ec40b9fdfbdc26e74a6", "score": "0.6383556", "text": "function getLength(something) {\n return something.length;\n}", "title": "" }, { "docid": "089c7eeccdf5c7faa3ca8f8e93ff5235", "score": "0.63290644", "text": "function foo(x) {\n return x.length;\n}", "title": "" }, { "docid": "baaba89d0309089ec79bfc3e54825adf", "score": "0.63131994", "text": "size() {}", "title": "" }, { "docid": "7cd76ac5df58570906d0e18534738f6b", "score": "0.623021", "text": "get length() {\r\n return function(a) {\r\n return this.max(a) - this.min(a)\r\n }\r\n }", "title": "" }, { "docid": "0244c71a0d94d39d52d5565bc645c63d", "score": "0.6056927", "text": "get length() {}", "title": "" }, { "docid": "0244c71a0d94d39d52d5565bc645c63d", "score": "0.6056927", "text": "get length() {}", "title": "" }, { "docid": "359bfb4f84ab11bd4616f179f6f40a32", "score": "0.59846455", "text": "function elsoFunction(param1, param2) {\n console.log(param1 + \" \" + param2);\n return param1.length;\n}", "title": "" }, { "docid": "9d3d388593a1443f25e3605ccf33224e", "score": "0.5981456", "text": "function myfunctionarg(a,b){\r\n return arguments.length;\r\n}", "title": "" }, { "docid": "15ce4943bc1f7b268684fbc3cf6a74c4", "score": "0.5953725", "text": "function arg_len() { return arguments.length; }", "title": "" }, { "docid": "9c2e015b3712dccdc6f26e3fc46136a0", "score": "0.59233624", "text": "function getHookArgumentsLength(fn){if(isUndef(fn)){return false;}var invokerFns=fn.fns;if(isDef(invokerFns)){// invoker\nreturn getHookArgumentsLength(Array.isArray(invokerFns)?invokerFns[0]:invokerFns);}else{return(fn._length||fn.length)>1;}}", "title": "" }, { "docid": "9c2e015b3712dccdc6f26e3fc46136a0", "score": "0.59233624", "text": "function getHookArgumentsLength(fn){if(isUndef(fn)){return false;}var invokerFns=fn.fns;if(isDef(invokerFns)){// invoker\nreturn getHookArgumentsLength(Array.isArray(invokerFns)?invokerFns[0]:invokerFns);}else{return(fn._length||fn.length)>1;}}", "title": "" }, { "docid": "6d90d48918f556b16bc4894846f42b34", "score": "0.59007627", "text": "function length(arr) {\n // code\n var lengthCount = arr.length;\n return lengthCount;\n}", "title": "" }, { "docid": "0841f450484a5a213d8f112992f37230", "score": "0.58297145", "text": "function forLength(func, value, iterations) {\n return forValue(\n function() {\n return func()\n .then(function(result) {\n return result.length\n })\n },\n value, iterations);\n }", "title": "" }, { "docid": "5f09d8531f25a24d7598f468e0f16eaf", "score": "0.58142525", "text": "get length(){return undefined;}", "title": "" }, { "docid": "5f09d8531f25a24d7598f468e0f16eaf", "score": "0.58142525", "text": "get length(){return undefined;}", "title": "" }, { "docid": "e0aa2b722f137e6909d750c1336eab6d", "score": "0.57994807", "text": "count() {}", "title": "" }, { "docid": "b8fb16f02a75f718964ead374d69ae74", "score": "0.57832664", "text": "function length() {\n array = ['1', '2', '3'];\n return array.length\n}", "title": "" }, { "docid": "14e29bf346c56d97c0a14e82eec7192c", "score": "0.57802844", "text": "function someArr(arr) {\n return arr.length;\n}", "title": "" }, { "docid": "b16dce48e7fa2ab110699a17f0de7f7c", "score": "0.5765141", "text": "function rltlength () {\n}", "title": "" }, { "docid": "e6841d5ccfe522aaf2b2f9a906bf5245", "score": "0.56930834", "text": "get size() {\n if (!IsCountQueuingStrategy(this)) {\n throw countBrandCheckException('size');\n }\n return countSizeFunction;\n }", "title": "" }, { "docid": "40718dfcd510df5838c698fe13b50dbb", "score": "0.5687093", "text": "function length(p0) {\n return filterFunction('length', 'int', p0);\n}", "title": "" }, { "docid": "8a755b8f05c76f67e38aebe63c05c986", "score": "0.5636544", "text": "function testcase() {\n \n var desc = Object.getOwnPropertyDescriptor(arguments,\"length\");\n assert.notSameValue(desc, undefined);\n }", "title": "" }, { "docid": "bccccf83efe2a5497d689f0a98532902", "score": "0.56362766", "text": "get _length () {\n return 1\n }", "title": "" }, { "docid": "bccccf83efe2a5497d689f0a98532902", "score": "0.56362766", "text": "get _length () {\n return 1\n }", "title": "" }, { "docid": "65a8933363f4402c36b93e5ac18353a7", "score": "0.5633245", "text": "function abstractFunction() { throw new Error('abstract'); }", "title": "" }, { "docid": "65a8933363f4402c36b93e5ac18353a7", "score": "0.5633245", "text": "function abstractFunction() { throw new Error('abstract'); }", "title": "" }, { "docid": "d1582a561bfff69a6185700d81e02bda", "score": "0.562685", "text": "length(arr) {\n return arr.length;\n }", "title": "" }, { "docid": "946448f69862271c64a0a1ed224f274c", "score": "0.5612871", "text": "function getHookArgumentsLength (fn) {\n if (isUndef(fn)) {\n return false\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(\n Array.isArray(invokerFns)\n ? invokerFns[0]\n : invokerFns\n )\n } else {\n return (fn._length || fn.length) > 1\n }\n }", "title": "" }, { "docid": "57de995aced8077fdfbf333a9c289808", "score": "0.5579467", "text": "function length(xs){\r\n return xs.length;\r\n}", "title": "" }, { "docid": "10b9aae5aedda99758b48c25e829e717", "score": "0.55630094", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n }", "title": "" }, { "docid": "ef3a9189aa12dc70e20093b504c1c692", "score": "0.5561249", "text": "function getHookArgumentsLength (fn) {\n if (isUndef(fn)) {\n return false\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(\n Array.isArray(invokerFns)\n ? invokerFns[0]\n : invokerFns\n )\n } else {\n return (fn._length || fn.length) > 1\n }\n }", "title": "" }, { "docid": "ef3a9189aa12dc70e20093b504c1c692", "score": "0.5561249", "text": "function getHookArgumentsLength (fn) {\n if (isUndef(fn)) {\n return false\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(\n Array.isArray(invokerFns)\n ? invokerFns[0]\n : invokerFns\n )\n } else {\n return (fn._length || fn.length) > 1\n }\n }", "title": "" }, { "docid": "ef3a9189aa12dc70e20093b504c1c692", "score": "0.5561249", "text": "function getHookArgumentsLength (fn) {\n if (isUndef(fn)) {\n return false\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(\n Array.isArray(invokerFns)\n ? invokerFns[0]\n : invokerFns\n )\n } else {\n return (fn._length || fn.length) > 1\n }\n }", "title": "" }, { "docid": "ef3a9189aa12dc70e20093b504c1c692", "score": "0.5561249", "text": "function getHookArgumentsLength (fn) {\n if (isUndef(fn)) {\n return false\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(\n Array.isArray(invokerFns)\n ? invokerFns[0]\n : invokerFns\n )\n } else {\n return (fn._length || fn.length) > 1\n }\n }", "title": "" }, { "docid": "e72ab8f8fedebb6e9e59d6bd6f08bc13", "score": "0.5557211", "text": "function getHookArgumentsLength(fn) {\n\t if (isUndef(fn)) {\n\t return false;\n\t }\n\t var invokerFns = fn.fns;\n\t if (isDef(invokerFns)) {\n\t // invoker\n\t return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n\t } else {\n\t return (fn._length || fn.length) > 1;\n\t }\n\t}", "title": "" }, { "docid": "e72ab8f8fedebb6e9e59d6bd6f08bc13", "score": "0.5557211", "text": "function getHookArgumentsLength(fn) {\n\t if (isUndef(fn)) {\n\t return false;\n\t }\n\t var invokerFns = fn.fns;\n\t if (isDef(invokerFns)) {\n\t // invoker\n\t return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n\t } else {\n\t return (fn._length || fn.length) > 1;\n\t }\n\t}", "title": "" }, { "docid": "b4440b518bfbd87f898cf7d151a0c254", "score": "0.5552424", "text": "async size() {\n await this.getMyRoutines();\n return this.routines.length;\n }", "title": "" }, { "docid": "c6e58d94294f264bf3fbbdc53dc02985", "score": "0.5552291", "text": "function length(string) {\n // YOUR CODE BELOW HERE //\n \n // The .length property accesses the number of characters in a given string.\n // This is how we decipher the length of a string.\n return string.length; // When the length function is called the given argument's length will be returned.\n\n // YOUR CODE ABOVE HERE //\n}", "title": "" }, { "docid": "ce1604bca9b1bb0bb38bd7c14c7ce7a7", "score": "0.55460733", "text": "function getHookArgumentsLength (fn) {\n\t if (!fn) { return false }\n\t var invokerFns = fn.fns;\n\t if (invokerFns) {\n\t // invoker\n\t return getHookArgumentsLength(\n\t Array.isArray(invokerFns)\n\t ? invokerFns[0]\n\t : invokerFns\n\t )\n\t } else {\n\t return (fn._length || fn.length) > 1\n\t }\n\t}", "title": "" }, { "docid": "ce1604bca9b1bb0bb38bd7c14c7ce7a7", "score": "0.55460733", "text": "function getHookArgumentsLength (fn) {\n\t if (!fn) { return false }\n\t var invokerFns = fn.fns;\n\t if (invokerFns) {\n\t // invoker\n\t return getHookArgumentsLength(\n\t Array.isArray(invokerFns)\n\t ? invokerFns[0]\n\t : invokerFns\n\t )\n\t } else {\n\t return (fn._length || fn.length) > 1\n\t }\n\t}", "title": "" }, { "docid": "e7e3631343f135d60be1274b9fdc3a2e", "score": "0.55456257", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(\n Array.isArray(invokerFns) ?\n invokerFns[0] :\n invokerFns\n )\n } else {\n return (fn._length || fn.length) > 1\n }\n }", "title": "" }, { "docid": "dcf152ae4bbfd8c6e7cef1843abe439b", "score": "0.55361307", "text": "function getLength(arr){\n var a = arr.length\n return a\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "581f71294c7316770641ecb08540d2fd", "score": "0.55252105", "text": "function getHookArgumentsLength(fn) {\n if (isUndef(fn)) {\n return false;\n }\n var invokerFns = fn.fns;\n if (isDef(invokerFns)) {\n // invoker\n return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);\n } else {\n return (fn._length || fn.length) > 1;\n }\n}", "title": "" }, { "docid": "35353c77851c70379fff841298074e60", "score": "0.55231065", "text": "function getHookArgumentsLength (fn) {\n\t if (isUndef(fn)) {\n\t return false\n\t }\n\t var invokerFns = fn.fns;\n\t if (isDef(invokerFns)) {\n\t // invoker\n\t return getHookArgumentsLength(\n\t Array.isArray(invokerFns)\n\t ? invokerFns[0]\n\t : invokerFns\n\t )\n\t } else {\n\t return (fn._length || fn.length) > 1\n\t }\n\t}", "title": "" }, { "docid": "35353c77851c70379fff841298074e60", "score": "0.55231065", "text": "function getHookArgumentsLength (fn) {\n\t if (isUndef(fn)) {\n\t return false\n\t }\n\t var invokerFns = fn.fns;\n\t if (isDef(invokerFns)) {\n\t // invoker\n\t return getHookArgumentsLength(\n\t Array.isArray(invokerFns)\n\t ? invokerFns[0]\n\t : invokerFns\n\t )\n\t } else {\n\t return (fn._length || fn.length) > 1\n\t }\n\t}", "title": "" }, { "docid": "94d7f6dde6e151937adb89b824a5c605", "score": "0.55191207", "text": "function nombreFuncion(){\n \n}", "title": "" }, { "docid": "2cde875cb72256885890522939f2150d", "score": "0.5515613", "text": "get functionCounts() {\n const totalCount = this.functions.length;\n let stateChangingFunctions = 0;\n let constantFunctions = 0;\n this.functions.forEach((func) => {\n if (['view', 'pure', 'constant'].indexOf(func.stateMutability) > -1) {\n constantFunctions += 1;\n } else {\n stateChangingFunctions += 1;\n }\n });\n return { totalCount, stateChangingFunctions, constantFunctions };\n }", "title": "" }, { "docid": "ee95267afa103496994a202fe040e08f", "score": "0.5511294", "text": "function getHookArgumentsLength (fn) {\n if (!fn) { return false }\n var invokerFns = fn.fns;\n if (invokerFns) {\n // invoker\n return getHookArgumentsLength(\n Array.isArray(invokerFns)\n ? invokerFns[0]\n : invokerFns\n )\n } else {\n return (fn._length || fn.length) > 1\n }\n}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" }, { "docid": "777b8ed53e4b63fbd1e0430e26d98cab", "score": "0.5509417", "text": "function emptyFunction() {}", "title": "" } ]
15c43e4a73ce13fc41b781ce588122f0
Full screen toggle helper function
[ { "docid": "9d6818c4b0900aeb8c2c1a0c40484472", "score": "0.7807995", "text": "function toggleFullScreen(value) {\n if (!getfullscreenelement()) {\n GoInFullscreen(document.documentElement);\n } else {\n GoOutFullscreen();\n }\n}", "title": "" } ]
[ { "docid": "d870b96697526e2ae7e9e8927d8f4d90", "score": "0.88477474", "text": "function toggleFullscreenMode() {\n}", "title": "" }, { "docid": "fcd9810897d68015fdd8f95e2b766d89", "score": "0.8667288", "text": "function toggleScreenFull() {\n\tscreenfull.toggle();\n}", "title": "" }, { "docid": "63f8adf5c45fb25fdb7e2c3b7def8679", "score": "0.81767064", "text": "function fullScreen() {\n GAME.state.states[GAME.state.current].toggleFullScreen()\n}", "title": "" }, { "docid": "c9ba968a78967814a9ef77dabf0c5cf4", "score": "0.8164836", "text": "function onFullscreenChange(){\n s.$fsToggleBtn.toggleClass('active');\n }", "title": "" }, { "docid": "39dd4608317ab579e2291ce3e04167ba", "score": "0.8078649", "text": "toggleFullScreen() {\n const d = document.fullscreenElement;\n\n if (!this.container.is(':visible'))\n if (d) document.exitFullscreen();\n else this.v[0].requestFullscreen();\n\n this.buttons.screen[d ? 'addClass' : 'removeClass']('fa-expand');\n if (d) document.exitFullscreen();\n else this.container[0].requestFullscreen();\n\n }", "title": "" }, { "docid": "1080bd2d5b6ac975dcf3078d8b8da01e", "score": "0.8007302", "text": "function ViewerFullscreenToggle(){\n if( ngscreenfull.enabled ) {\n // ngscreenfull.toggle($gE.conVwCon[0]); // --> issue on scrollbar visibility\n ngscreenfull.toggle();\n if( g_viewerIsFullscreen ) {\n g_viewerIsFullscreen=false;\n $gE.conVwTb.find('.fullscreenButton').removeClass('removeFullscreenButton').addClass('setFullscreenButton');\n }\n else {\n g_viewerIsFullscreen=true;\n $gE.conVwTb.find('.fullscreenButton').removeClass('setFullscreenButton').addClass('removeFullscreenButton');\n }\n }\n }", "title": "" }, { "docid": "7816f034fc8f8780123b10709719d6e0", "score": "0.78873307", "text": "function fullScreenToggle()\n{\n\tCB_console(\"Toggling full screen mode...\");\n\t//If it is using full screen mode already, disables it:\n\tif (CB_Screen.isFullScreen())\n\t{\n\t\tCB_console(\"Full screen mode detected. Trying to restore normal mode...\");\n\t\tCB_Screen.setFullScreen(false); //Uses the Fullscreen API and fallbacks to other methods internally, including NW.js, Electron ones, when not available.\n\t}\n\t//...otherwise, requests full screen mode:\n\telse\n\t{\n\t\tCB_console(\"Normal mode detected. Trying to enable full screen mode...\");\n\t\tCB_Screen.setFullScreen(true, undefined, true); //Allows reloading into another (bigger) window (for legacy clients).\n\t}\n}", "title": "" }, { "docid": "56b02ab46e67744104e26902f73d901f", "score": "0.7823467", "text": "function openFullscreen(xtar='#fullscreen') {\nconst target = $(xtar)[0];\nif (screenfull.enabled) {\nscreenfull.request(target);\ngal_init_fullscreen = true;\njQuery('.gal-fullscreen').addClass('gal-restore');\n} else {\njQuery('.gal-fullscreen').hide();\n}\n}", "title": "" }, { "docid": "9f5023d69e44846524222ba492843133", "score": "0.7811742", "text": "function toggleFullScreen(){\n\tif(inFullScreen()){\n\t\tconsole.log(\"exit fullscreen\");\n\t\texitFullscreen();\n\t} else {\n\t\tconsole.log(\"enter fullscreen\");\n\t\tlaunchIntoFullscreen($(\"body\")[0]);\n\t}\n}", "title": "" }, { "docid": "55f6330b7a03bde2932cbc8c5676696b", "score": "0.7711587", "text": "function ViewerFullscreenToggle() {\n\t\tif(g_viewerIsFullscreen) {\n\t\t\tif(document.exitFullscreen) {\n\t\t\t\tdocument.exitFullscreen();\n\t\t\t} else if(document.webkitExitFullscreen) {\n\t\t\t\tdocument.webkitExitFullscreen();\n\t\t\t} else if(document.msExitFullscreen) {\n\t\t\t\tdocument.msExitFullscreen();\n\t\t\t} else if(document.mozCancelFullScreen) {\n\t\t\t\tdocument.mozCancelFullScreen();\n\t\t\t}\n\n\t\t\tg_viewerIsFullscreen = false;\n\t\t\t$gE.conVwTb.find('.fullscreenButton').removeClass('removeFullscreenButton').addClass('setFullscreenButton');\n\t\t} else {\n\t\t\tif($gE.conVwCon[0].requestFullscreen) {\n\t\t\t\t$gE.conVwCon[0].requestFullscreen();\n\t\t\t} else if($gE.conVwCon[0].webkitRequestFullscreen) {\n\t\t\t\t$gE.conVwCon[0].webkitRequestFullscreen();\n\t\t\t} else if($gE.conVwCon[0].msRequestFullscreen) {\n\t\t\t\t$gE.conVwCon[0].msRequestFullscreen();\n\t\t\t} else if($gE.conVwCon[0].mozRequestFullScreen) {\n\t\t\t\t$gE.conVwCon[0].mozRequestFullScreen();\n\t\t\t}\n\t\t\tg_viewerIsFullscreen = true;\n\t\t\t$gE.conVwTb.find('.fullscreenButton').removeClass('setFullscreenButton').addClass('removeFullscreenButton');\n\t\t}\n\t}", "title": "" }, { "docid": "263d62e1407070cbd1908c73b1160c5b", "score": "0.76861995", "text": "function toggleFullscreen() {\n if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {\n enableFullScreen();\n } else {\n disableFullScreen();\n }\n hideGameButtons();\n}", "title": "" }, { "docid": "843253f5ccf3462d758bde872b4ea118", "score": "0.7636932", "text": "function toggleFullscreen(e){e=e||document.documentElement,document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}", "title": "" }, { "docid": "2d8eeda712ac72f31165c5bcfabfc26f", "score": "0.754869", "text": "function toggle_fullscreen()\n{\n if (!fullscreen_mode)\n {\n var screen_width=screen.availWidth;\n var screen_height=screen.availHeight;\n var features='width='+screen_width;\n features += ',height='+screen_height;\n var url = add_arg_to_url(location.href, 'fullscreen', '1');\n url += '#image';\n window.open(url,'',features);\n }\n else\n {\n window.close();\n }\n}", "title": "" }, { "docid": "30c49801722cf4f4d0f461eac42d497a", "score": "0.7541407", "text": "function toggleFullScreen()\n\t{\n\t\tvar elem = document.documentElement;\n\t\t\n\t\tif(fullScreen)\n\t\t{\n\t\t\tif (document.exitFullscreen) \n\t\t\t{\n\t\t\t\tdocument.exitFullscreen();\n\t\t\t} \n\t\t\telse if (document.mozCancelFullScreen) \n\t\t\t{\n\t\t\t\tdocument.mozCancelFullScreen();\n\t\t\t} \n\t\t\telse if (document.webkitExitFullscreen)\n\t\t\t{\n\t\t\t\tdocument.webkitExitFullscreen();\n\t\t\t} \n\t\t\telse if (document.msExitFullscreen) \n\t\t\t{\n\t\t\t\tdocument.msExitFullscreen();\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (elem.requestFullscreen) \n\t\t\t{\n\t\t\t\telem.requestFullscreen();\n\t\t\t} \n\t\t\telse if (elem.mozRequestFullScreen) \n\t\t\t{\n\t\t\t\telem.mozRequestFullScreen();\n\t\t\t} \n\t\t\telse if (elem.webkitRequestFullscreen) \n\t\t\t{\n\t\t\t\telem.webkitRequestFullscreen();\n\t\t\t} \n\t\t\telse if (elem.msRequestFullscreen) \n\t\t\t{\n\t\t\t\telem.msRequestFullscreen();\n\t\t\t}\n\t\t}\n\t\t\n\t\tfullScreen = !fullScreen;\n\t}", "title": "" }, { "docid": "530594cb02f2226573f1adfd1dc6e43f", "score": "0.7520763", "text": "function toggleFullScreen() {\n\t\t\t\t\telement = $this[0];\n\t\t\t\t\tvar requestMethod;\n\t\t\t\t\tif (!camera.isFullScreen) {\n\t\t\t\t\t\t// Supports most browsers and their versions.\n\t\t\t\t\t\trequestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;\n\t\t\t\t\t\tif (requestMethod) { // Native full screen.\n\t\t\t\t\t\t\trequestMethod.call(element);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trequestMethod = document.cancelFullScreen || document.webkitCancelFullScreen || document.mozCancelFullScreen || document.msCancelFullScreen;\n\t\t\t\t\t\tif (requestMethod) { // Native full screen.\n\t\t\t\t\t\t\tdocument.webkitIsFullScreen ? document.webkitCancelFullScreen() : document.mozFullScreen ? document.mozCancelFullScreen() : document.fullScreen && (document.cancelFullScreen ? document.cancelFullScreen() : document.exitFullscreen && document.exitFullscreen());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Older IE.\n\t\t\t\t\tif (!requestMethod) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (typeof window.ActiveXObject !== \"undefined\") { \n\t\t\t\t\t\t\t\tvar wscript = new ActiveXObject(\"WScript.Shell\");\n\t\t\t\t\t\t\t\tif (wscript !== null) {\n\t\t\t\t\t\t\t\t\tif ((!camera.isFullScreen && window.screenTop) || (camera.isFullScreen && !window.screenTop)) {\n\t\t\t\t\t\t\t\t\t\t$(document).off('keydown.fullScreen');\n\t\t\t\t\t\t\t\t\t\twscript.SendKeys(\"{F11}\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\t$(document).off('keydown.fullScreen');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfullScreenSize();\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}", "title": "" }, { "docid": "1c2b03d8e497d9ab594b6291b99b3cc7", "score": "0.75162476", "text": "static set allowFullscreenSwitch(value) {}", "title": "" }, { "docid": "b96e3cd5e221ac220df7d34394daf15c", "score": "0.74545723", "text": "function toggleFullScreen() {\n if (!document.fullscreenElement && // alternative standard method\n !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods\n if (document.documentElement.requestFullscreen) {\n document.documentElement.requestFullscreen();\n } else if (document.documentElement.mozRequestFullScreen) {\n document.documentElement.mozRequestFullScreen();\n } else if (document.documentElement.webkitRequestFullscreen) {\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n $.cookie('fullscreen','1',{ expires: 365 });\n } else {\n if (document.cancelFullScreen) {\n document.cancelFullScreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitCancelFullScreen) {\n document.webkitCancelFullScreen();\n }\n $.cookie('fullscreen','0',{ expires: 365 });\n }\n }", "title": "" }, { "docid": "ace62cc171e72a1c0b5d38aef5020aa5", "score": "0.74523765", "text": "updateFullScreenButtonVisibility() {\n // If already in full screen, do nothing\n if (this.fullscreen) {\n return;\n }\n\n let forceFullscreen = false;\n if (this.options.layout.fullScreen.fullScreenMode === 'always') {\n forceFullscreen = true;\n }\n else if (this.options.layout.fullScreen.fullScreenMode === 'dynamic') {\n forceFullscreen = (this.$container.width() < this.options.layout.fullScreen.forceFullScreenWidthThreshold);\n }\n\n this.$container.toggleClass('h5p-mini-course-force-fullscreen', forceFullscreen);\n }", "title": "" }, { "docid": "f963074680171ef69c6af0e0f99ac7ac", "score": "0.7419782", "text": "function toggleFullscreen() {\n if (!document.fullscreenElement &&\n !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods\n if (document.documentElement.requestFullscreen) {\n document.documentElement.requestFullscreen();\n } else if (document.documentElement.msRequestFullscreen) {\n document.documentElement.msRequestFullscreen();\n } else if (document.documentElement.mozRequestFullScreen) {\n document.documentElement.mozRequestFullScreen();\n } else if (document.documentElement.webkitRequestFullscreen) {\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n else {\n noty({ text: \"Cannot enter fullscreen mode automatically. Try manually pressing F11!\", type: \"error\" });\n }\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen();\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitExitFullscreen) {\n document.webkitExitFullscreen();\n }\n else {\n noty({ text: \"Cannot exit fullscreen mode automatically. Try manually pressing F11!\", type: \"error\" });\n }\n }\n}", "title": "" }, { "docid": "d3f289e999ad73ff22d2c7325326b157", "score": "0.7419478", "text": "function toggleFullScreen() {\n var fsElement = document.documentElement;\n\n if (!document.mozFullScreen && !document.webkitIsFullScreen) {\n //Enter Full Screen\n if (fsElement.mozRequestFullScreen) {\n fsElement.mozRequestFullScreen();\n }\n else {\n fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n } else {\n //Exit Full Screen\n if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else {\n document.webkitCancelFullScreen();\n }\n }\n}", "title": "" }, { "docid": "405d2afc712f3c151f3efa4378c76d96", "score": "0.74007666", "text": "function toggleFullScreen() {\n if (!document.fullscreenElement && // alternative standard method\n !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods\n if (document.documentElement.requestFullscreen) {\n document.documentElement.requestFullscreen();\n } else if (document.documentElement.mozRequestFullScreen) {\n document.documentElement.mozRequestFullScreen();\n } else if (document.documentElement.webkitRequestFullscreen) {\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n } else {\n if (document.cancelFullScreen) {\n document.cancelFullScreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitCancelFullScreen) {\n document.webkitCancelFullScreen();\n }\n }\n }", "title": "" }, { "docid": "405d2afc712f3c151f3efa4378c76d96", "score": "0.74007666", "text": "function toggleFullScreen() {\n if (!document.fullscreenElement && // alternative standard method\n !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods\n if (document.documentElement.requestFullscreen) {\n document.documentElement.requestFullscreen();\n } else if (document.documentElement.mozRequestFullScreen) {\n document.documentElement.mozRequestFullScreen();\n } else if (document.documentElement.webkitRequestFullscreen) {\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n } else {\n if (document.cancelFullScreen) {\n document.cancelFullScreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitCancelFullScreen) {\n document.webkitCancelFullScreen();\n }\n }\n }", "title": "" }, { "docid": "a70c9828b824904848a0b57c9845c3c5", "score": "0.73972225", "text": "function toggleFullScreen() {\r\n if (!document.fullscreenElement && // alternative standard method\r\n !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods\r\n if (document.documentElement.requestFullscreen) {\r\n document.documentElement.requestFullscreen();\r\n } else if (document.documentElement.mozRequestFullScreen) {\r\n document.documentElement.mozRequestFullScreen();\r\n } else if (document.documentElement.webkitRequestFullscreen) {\r\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\r\n }\r\n } else {\r\n if (document.cancelFullScreen) {\r\n document.cancelFullScreen();\r\n } else if (document.mozCancelFullScreen) {\r\n document.mozCancelFullScreen();\r\n } else if (document.webkitCancelFullScreen) {\r\n document.webkitCancelFullScreen();\r\n }\r\n }\r\n }", "title": "" }, { "docid": "a70c9828b824904848a0b57c9845c3c5", "score": "0.73972225", "text": "function toggleFullScreen() {\r\n if (!document.fullscreenElement && // alternative standard method\r\n !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods\r\n if (document.documentElement.requestFullscreen) {\r\n document.documentElement.requestFullscreen();\r\n } else if (document.documentElement.mozRequestFullScreen) {\r\n document.documentElement.mozRequestFullScreen();\r\n } else if (document.documentElement.webkitRequestFullscreen) {\r\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\r\n }\r\n } else {\r\n if (document.cancelFullScreen) {\r\n document.cancelFullScreen();\r\n } else if (document.mozCancelFullScreen) {\r\n document.mozCancelFullScreen();\r\n } else if (document.webkitCancelFullScreen) {\r\n document.webkitCancelFullScreen();\r\n }\r\n }\r\n }", "title": "" }, { "docid": "e8af9dfa75bc30fa8064b666e7589444", "score": "0.73300266", "text": "function toggleFullscreen(elem) {\n elem = elem || document.documentElement;\n if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {\n if (elem.requestFullscreen) {\n elem.requestFullscreen();\n } else if (elem.msRequestFullscreen) {\n elem.msRequestFullscreen();\n } else if (elem.mozRequestFullScreen) {\n elem.mozRequestFullScreen();\n } else if (elem.webkitRequestFullscreen) {\n elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen();\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitExitFullscreen) {\n document.webkitExitFullscreen();\n }\n }\n }", "title": "" }, { "docid": "474997dec87b56b421ec116cf7304608", "score": "0.7302129", "text": "function fullScreenTrigger(){\n fullscreen_open.play();\n\t//$('.detail-side-text p' ).fadeIn();\n}", "title": "" }, { "docid": "da8d6f6c18299c380c710a8f4261c456", "score": "0.72912276", "text": "function toggleFullScreen() {\n if (!document.fullscreenElement && // alternative standard method\n !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods\n if (document.documentElement.requestFullscreen) {\n document.documentElement.requestFullscreen();\n } else if (document.documentElement.mozRequestFullScreen) {\n document.documentElement.mozRequestFullScreen();\n } else if (document.documentElement.webkitRequestFullscreen) {\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n } else {\n if (document.cancelFullScreen) {\n document.cancelFullScreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitCancelFullScreen) {\n document.webkitCancelFullScreen();\n }\n }\n}", "title": "" }, { "docid": "da8d6f6c18299c380c710a8f4261c456", "score": "0.72912276", "text": "function toggleFullScreen() {\n if (!document.fullscreenElement && // alternative standard method\n !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods\n if (document.documentElement.requestFullscreen) {\n document.documentElement.requestFullscreen();\n } else if (document.documentElement.mozRequestFullScreen) {\n document.documentElement.mozRequestFullScreen();\n } else if (document.documentElement.webkitRequestFullscreen) {\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n } else {\n if (document.cancelFullScreen) {\n document.cancelFullScreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitCancelFullScreen) {\n document.webkitCancelFullScreen();\n }\n }\n}", "title": "" }, { "docid": "16801736e2d542fbf3c826ebab3787a7", "score": "0.7288677", "text": "function boardToggleFullScreen(button) {\n CONTAINER_MAIN_BODY.toggleClass('mindalay--border-full-screen');\n boardToggleButton(button, CONTAINER_MAIN_BODY.hasClass('mindalay--border-full-screen'), minimize_bord_icon, full_screen_icon, TR_MINIMIZE_BOARD, TR_FULL_SCREEN)\n}", "title": "" }, { "docid": "f285588bdb6cf0758b54a32e0a18d67b", "score": "0.7284907", "text": "onFullScreen() {\n ViewPresActions.fullscreen(true);\n }", "title": "" }, { "docid": "86ee9d17472fb2ba71c3deaf22516ded", "score": "0.72773826", "text": "function toggleFullscreen() {\n if (video.requestFullscreen) {\n video.requestFullscreen();\n } else if (video.msRequestFullscreen) {\n video.msRequestFullscreen();\n } else if (video.mozRequestFullScreen) {\n video.mozRequestFullScreen();\n } else if (video.webkitRequestFullscreen) {\n video.webkitRequestFullscreen();\n }\n}", "title": "" }, { "docid": "b66cf939e7aa0f17b8034789c1f57dde", "score": "0.7241092", "text": "static toggleFullScreen(editor) {\n // Set fullscreen\n let self = MDEActions;\n let cm = editor.codemirror;\n cm.setOption(\"fullScreen\", !cm.getOption(\"fullScreen\"));\n\n // Prevent scrolling on body during fullscreen active\n if (cm.getOption(\"fullScreen\")) {\n window.mdeSavedOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n } else {\n document.body.style.overflow = window.mdeSavedOverflow;\n }\n\n // Update toolbar class\n let wrap = cm.getWrapperElement();\n\n if (!/fullscreen/.test(wrap.previousSibling.className)) {\n wrap.previousSibling.className += \" fullscreen\";\n } else {\n wrap.previousSibling.className = wrap.previousSibling.className.replace(/\\s*fullscreen\\b/, \"\");\n }\n\n // Update toolbar button\n let toolbarButton = editor.toolbarElements.fullscreen;\n\n if (!/active/.test(toolbarButton.className)) {\n toolbarButton.className += \" active\";\n } else {\n toolbarButton.className = toolbarButton.className.replace(/\\s*active\\s*/g, \"\");\n }\n\n // Hide side by side if needed\n let sidebyside = cm.getWrapperElement().nextSibling;\n if (/editor-preview-active-side/.test(sidebyside.className)) {\n self.toggleSideBySide(editor);\n }\n }", "title": "" }, { "docid": "783226862d8e6dd8da63b1db4a119aca", "score": "0.7225125", "text": "function toggleFullScreen() {\n\t if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods\n\t if (document.documentElement.requestFullscreen) {\n\t document.documentElement.requestFullscreen();\n\t } else if (document.documentElement.msRequestFullscreen) {\n\t document.documentElement.msRequestFullscreen();\n\t } else if (document.documentElement.mozRequestFullScreen) {\n\t document.documentElement.mozRequestFullScreen();\n\t } else if (document.documentElement.webkitRequestFullscreen) {\n\t document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n\t }\n\t } else {\n\t if (document.exitFullscreen) {\n\t document.exitFullscreen();\n\t } else if (document.msExitFullscreen) {\n\t document.msExitFullscreen();\n\t } else if (document.mozCancelFullScreen) {\n\t document.mozCancelFullScreen();\n\t } else if (document.webkitExitFullscreen) {\n\t document.webkitExitFullscreen();\n\t }\n\t }\n\t}", "title": "" }, { "docid": "c46a0d9d8f5352d6a89cbb908b88c7e1", "score": "0.7194368", "text": "function toggleFullscreen(e) {\n\t'use strict';\n\t// Get fullscreen element\n\tdocument.fullscreenElement = document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;\n\t\n\tif ((typeof(document.fullscreenElement) === 'undefined' || document.fullscreenElement === null) && typeof(e) !== 'undefined') {\n\t\t// Request fullscreen \n\t\te.requestFullscreen = e.requestFullscreen || e.mozRequestFullScreen || e.webkitRequestFullscreen || e.msRequestFullscreen; \n\t\te.requestFullscreen();\n\t} else {\n\t\t// Switch back to windowed mode and set fullscreen element to null. Otherwise it will break toggling back and forth.\n\t\tdocument.fullscreenElement = null;\n\t\tdocument.exitFullscreen = document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen || document.msExitFullscreen;\n\t\tdocument.exitFullscreen();\n\t}\n\t\n\treturn false;\n}", "title": "" }, { "docid": "ba7158389af85330bf2643419cc25025", "score": "0.7186347", "text": "function openFullscreen() {\n if (elem.requestFullscreen) {\n elem.requestFullscreen();\n } else if (elem.webkitRequestFullscreen) { /* Safari */\n elem.webkitRequestFullscreen();\n } else if (elem.msRequestFullscreen) { /* IE11 */\n elem.msRequestFullscreen();\n }\n }", "title": "" }, { "docid": "a1455023352140d5c8431c131852771b", "score": "0.7180391", "text": "function toggleFullscreen() {\n if (!isFullscreen) {\n try {\n webapis.avplay.setDisplayRect(0, 0, resolutionWidth, resolutionHeight);\n webapis.avplay.setDisplayMethod('PLAYER_DISPLAY_MODE_FULL_SCREEN');\n } catch (error) {\n logger.log(error.message);\n }\n\n logger.log('Fullscreen on');\n\n playerEl.classList.add(FULLSCREEN_CLASS);\n controlsEl.classList.add(FULLSCREEN_CLASS);\n\n if (timerEl) {\n timerEl.classList.add(FULLSCREEN_CLASS);\n }\n\n if (subtitlesEl) {\n subtitlesEl.classList.add(FULLSCREEN_CLASS);\n }\n\n isFullscreen = true;\n } else {\n try {\n webapis.avplay.setDisplayRect(\n playerCoords.x,\n playerCoords.y,\n playerCoords.width,\n playerCoords.height\n );\n webapis.avplay.setDisplayMethod('PLAYER_DISPLAY_MODE_AUTO_ASPECT_RATIO');\n } catch (error) {\n logger.log(error.message);\n }\n\n logger.log('Fullscreen off');\n playerEl.classList.remove(FULLSCREEN_CLASS);\n controlsEl.classList.remove(FULLSCREEN_CLASS);\n\n if (subtitlesEl) {\n subtitlesEl.classList.remove(FULLSCREEN_CLASS);\n }\n\n if (timerEl) {\n timerEl.classList.remove(FULLSCREEN_CLASS);\n }\n\n isFullscreen = false;\n }\n }", "title": "" }, { "docid": "1afe5b0138b5003da2a54fbad7f8b72d", "score": "0.71803147", "text": "function toggleFullScreen() {\n var doc = window.document;\n var docEl = doc.documentElement;\n\n var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;\n var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;\n if (!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {\n requestFullScreen.call(docEl);\n } else {\n cancelFullScreen.call(doc);\n }\n}", "title": "" }, { "docid": "a987b4496f1d5e01154a1cdc288ca9ef", "score": "0.7178393", "text": "function _toggleFullScreen() \r\n {\r\n\t if (!document.fullscreenElement && // alternative standard method\r\n\t !document.mozFullScreenElement && !document.webkitFullscreenElement) \r\n\t { // current working methods\r\n\t if (document.documentElement.requestFullscreen) \r\n\t {\r\n\t document.documentElement.requestFullscreen();\r\n\t } \r\n\t else if (document.documentElement.mozRequestFullScreen) \r\n\t {\r\n\t document.documentElement.mozRequestFullScreen();\r\n\t } \r\n\t else if (document.documentElement.webkitRequestFullscreen) \r\n\t {\r\n\t document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\r\n\t }\r\n\t else if ($.browser.msie) \r\n\t { // Older IE.\r\n\t _IE_fullScreenMode()\r\n\t }\r\n\t else\r\n\t\t {\r\n\t\t \t_showErrorMsg(\"Not Supported Feature\");\r\n\t\t }\r\n\t \r\n\t } \r\n\t else \r\n\t {\r\n\t if (document.cancelFullScreen) \r\n\t {\r\n\t document.cancelFullScreen();\r\n\t } \r\n\t else if (document.mozCancelFullScreen) \r\n\t {\r\n\t document.mozCancelFullScreen();\r\n\t } \r\n\t else if (document.webkitCancelFullScreen) \r\n\t {\r\n\t document.webkitCancelFullScreen();\r\n\t }\r\n\t else if ($.browser.msie)\r\n\t {\r\n\t \t_IE_fullScreenMode()\r\n\t }\r\n\t else\r\n\t {\r\n\t \t_showErrorMsg(\"Not Supported Feature\");\r\n\t\t}\r\n \t}\r\n}", "title": "" }, { "docid": "6d38e20de09c004db5b1732687c85a0e", "score": "0.7136047", "text": "static get allowFullscreenSwitch() {}", "title": "" }, { "docid": "ab7d5fbb9cdc51585ff35c09e230d92f", "score": "0.7131309", "text": "function closeFullScreen(){\n if(!screenfull.isFullscreen){\n $('html').removeClass('blackout');\n $(\".enlargement\").remove();\n DOM.$targetImages.removeClass('screenfull-target-link').find('img').show();\n restoreLinks();\n }\n }", "title": "" }, { "docid": "2dc7f282e576ffd0a08b6f01b6ee64a6", "score": "0.7130973", "text": "function toggleFullScreen() { // > CustomCode.fullscreen:4\n if (!document.fullscreenElement && // alternative standard method // > CustomCode.fullscreen:5\n !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods // > CustomCode.fullscreen:6\n if (document.documentElement.requestFullscreen) { // > CustomCode.fullscreen:7\n document.documentElement.requestFullscreen(); // > CustomCode.fullscreen:8\n } else if (document.documentElement.msRequestFullscreen) { // > CustomCode.fullscreen:9\n document.documentElement.msRequestFullscreen(); // > CustomCode.fullscreen:10\n } else if (document.documentElement.mozRequestFullScreen) { // > CustomCode.fullscreen:11\n document.documentElement.mozRequestFullScreen(); // > CustomCode.fullscreen:12\n } else if (document.documentElement.webkitRequestFullscreen) { // > CustomCode.fullscreen:13\n document.documentElement.webkitRequestFullscreen(); // > CustomCode.fullscreen:14\n } // > CustomCode.fullscreen:15\n } else { // > CustomCode.fullscreen:16\n if (document.exitFullscreen) { // > CustomCode.fullscreen:17\n document.exitFullscreen(); // > CustomCode.fullscreen:18\n } else if (document.msExitFullscreen) { // > CustomCode.fullscreen:19\n document.msExitFullscreen(); // > CustomCode.fullscreen:20\n } else if (document.mozCancelFullScreen) { // > CustomCode.fullscreen:21\n document.mozCancelFullScreen(); // > CustomCode.fullscreen:22\n } else if (document.webkitExitFullscreen) { // > CustomCode.fullscreen:23\n document.webkitExitFullscreen(); // > CustomCode.fullscreen:24\n } // > CustomCode.fullscreen:25\n } // > CustomCode.fullscreen:26\n } // > CustomCode.fullscreen:27", "title": "" }, { "docid": "517f0d5d7ed813046a8cd23afc9e8526", "score": "0.71179265", "text": "function pn_fullscreen() {\n document.querySelector(\"#pn_noteContainer\").classList.add(\"fullscreen\");\n document.querySelector(\"#pn_fullscreen\").classList.add(\"off\");\n document.querySelector(\"#pn_exitFullscreen\").classList.remove(\"off\");\n}", "title": "" }, { "docid": "875c7a5384b39ed551954fecda674221", "score": "0.7117141", "text": "static set macFullscreenMode(value) {}", "title": "" }, { "docid": "ca04aaf7bde56c32274c80849b21b882", "score": "0.7116903", "text": "function toggleFull() {\n\tvar frame = document.getElementById(\"gameContainer\");\n\tif (!document.isFullScreen && !document.fullscreenElement && !document.webkitFullscreenElement && !document.mozFullScreenElement && !document.msFullscreenElement) {\n\t\tconsole.log (\"Attempting to enter fullscreen\");\n\t\tif(frame.requestFullScreen) {\n\t\t\tconsole.log(\"standardFull\");\n\t\t\tframe.requestFullScreen();\n\t\t\t//addExit();\n\t\t} else if (frame.mozRequestFullscreen) {\n\t\t\tconsole.log(\"mozFull\");\n\t\t\tframe.mozRequestFullscreen();\n\t\t\t//addExit();\n\t\t} else if (frame.webkitRequestFullscreen) {\n\t\t\tconsole.log(\"webkitFull\");\n\t\t\tframe.webkitRequestFullscreen();\n\t\t\t//addExit();\n\t\t} else if (frame.msRequestFullscreen) {\n\t\t\tconsole.log(\"msFull\");\n\t\t\tframe.msRequestFullscreen();\n\t\t\t//addExit();\n\t\t} \n\t} else {\n\t\tconsole.log(\"Attempting to exit fullscreen\");\n\t\tif(document.exitFullScreen) {\n\t\t\tconsole.log(\"standardExit\");\n\t\t\tdocument.exitFullScreen();\n\t\t} else if (document.mozCancelFullscreen) {\n\t\t\tconsole.log(\"moxExit\");\n\t\t\tdocument.mozCancelFullscreen();\n\t\t} else if (document.webkitExitFullscreen) {\n\t\t\tconsole.log(\"webkitExit\");\n\t\t\tdocument.webkitExitFullscreen();\n\t\t} else if (document.msExitFullscreen) {\n\t\t\tconsole.log(\"msExit\");\n\t\t\tdocument.msExitFullscreen();\n\t\t}\n\tdocument.getElementById(\"exitFullButton\").style.visibility = 'hidden';\n\tdocument.getElementById(\"fullButton\").style.visibility = 'initial';\n\t}\n}", "title": "" }, { "docid": "054ff9dcfa7be8f594586af5036ba226", "score": "0.7081021", "text": "static set d3d9FullscreenMode(value) {}", "title": "" }, { "docid": "28282d659437aa12f3809045095955b2", "score": "0.7077921", "text": "function openFullScreen(elem) {\n if (elem.requestFullscreen) {\n elem.requestFullscreen();\n } else if (elem.mozRequestFullScreen) { // Firefox\n elem.mozRequestFullScreen();\n } else if (elem.webkitRequestFullscreen) { // Chrome, Safari & Opera\n elem.webkitRequestFullscreen();\n } else if (elem.msRequestFullscreen) { // IE/Edge\n elem.msRequestFullscreen();\n }\n\n body.classList.add('full-screen');\n}", "title": "" }, { "docid": "42f6f78f8a9cd2c33b004b2e79cb03af", "score": "0.7055307", "text": "static set d3d11FullscreenMode(value) {}", "title": "" }, { "docid": "ebac6dfe02435a19fca90d7ac02b9a0d", "score": "0.7000671", "text": "function closeFullscreen(){\nif (screenfull.enabled) {\nscreenfull.exit();\ngal_init_fullscreen = false;\njQuery('.gal-fullscreen').removeClass('gal-restore');\n} else {\njQuery('.gal-fullscreen').hide();\n}\n}", "title": "" }, { "docid": "7570d49a6286e48c21973340971600d2", "score": "0.6994057", "text": "function toggleFullScreen(editor) {\n\t// Set fullscreen\n\tvar cm = editor.codemirror;\n\tcm.setOption(\"fullScreen\", !cm.getOption(\"fullScreen\"));\n\n\n\t// Prevent scrolling on body during fullscreen active\n\tif(cm.getOption(\"fullScreen\")) {\n\t\tsaved_overflow = document.body.style.overflow;\n\t\tdocument.body.style.overflow = \"hidden\";\n\t} else {\n\t\tdocument.body.style.overflow = saved_overflow;\n\t}\n\n\n\t// Update toolbar class\n\tvar wrap = cm.getWrapperElement();\n\n\tif(!/fullscreen/.test(wrap.previousSibling.className)) {\n\t\twrap.previousSibling.className += \" fullscreen\";\n\t} else {\n\t\twrap.previousSibling.className = wrap.previousSibling.className.replace(/\\s*fullscreen\\b/, \"\");\n\t}\n\n\n\t// Update toolbar button\n\tvar toolbarButton = editor.toolbarElements.fullscreen;\n\n\tif(!/active/.test(toolbarButton.className)) {\n\t\ttoolbarButton.className += \" active\";\n\t} else {\n\t\ttoolbarButton.className = toolbarButton.className.replace(/\\s*active\\s*/g, \"\");\n\t}\n\n\n\t// Hide side by side if needed\n\tvar sidebyside = cm.getWrapperElement().nextSibling;\n\tif(/editor-preview-active-side/.test(sidebyside.className))\n\t\ttoggleSideBySide(editor);\n}", "title": "" }, { "docid": "7570d49a6286e48c21973340971600d2", "score": "0.6994057", "text": "function toggleFullScreen(editor) {\n\t// Set fullscreen\n\tvar cm = editor.codemirror;\n\tcm.setOption(\"fullScreen\", !cm.getOption(\"fullScreen\"));\n\n\n\t// Prevent scrolling on body during fullscreen active\n\tif(cm.getOption(\"fullScreen\")) {\n\t\tsaved_overflow = document.body.style.overflow;\n\t\tdocument.body.style.overflow = \"hidden\";\n\t} else {\n\t\tdocument.body.style.overflow = saved_overflow;\n\t}\n\n\n\t// Update toolbar class\n\tvar wrap = cm.getWrapperElement();\n\n\tif(!/fullscreen/.test(wrap.previousSibling.className)) {\n\t\twrap.previousSibling.className += \" fullscreen\";\n\t} else {\n\t\twrap.previousSibling.className = wrap.previousSibling.className.replace(/\\s*fullscreen\\b/, \"\");\n\t}\n\n\n\t// Update toolbar button\n\tvar toolbarButton = editor.toolbarElements.fullscreen;\n\n\tif(!/active/.test(toolbarButton.className)) {\n\t\ttoolbarButton.className += \" active\";\n\t} else {\n\t\ttoolbarButton.className = toolbarButton.className.replace(/\\s*active\\s*/g, \"\");\n\t}\n\n\n\t// Hide side by side if needed\n\tvar sidebyside = cm.getWrapperElement().nextSibling;\n\tif(/editor-preview-active-side/.test(sidebyside.className))\n\t\ttoggleSideBySide(editor);\n}", "title": "" }, { "docid": "7570d49a6286e48c21973340971600d2", "score": "0.6994057", "text": "function toggleFullScreen(editor) {\n\t// Set fullscreen\n\tvar cm = editor.codemirror;\n\tcm.setOption(\"fullScreen\", !cm.getOption(\"fullScreen\"));\n\n\n\t// Prevent scrolling on body during fullscreen active\n\tif(cm.getOption(\"fullScreen\")) {\n\t\tsaved_overflow = document.body.style.overflow;\n\t\tdocument.body.style.overflow = \"hidden\";\n\t} else {\n\t\tdocument.body.style.overflow = saved_overflow;\n\t}\n\n\n\t// Update toolbar class\n\tvar wrap = cm.getWrapperElement();\n\n\tif(!/fullscreen/.test(wrap.previousSibling.className)) {\n\t\twrap.previousSibling.className += \" fullscreen\";\n\t} else {\n\t\twrap.previousSibling.className = wrap.previousSibling.className.replace(/\\s*fullscreen\\b/, \"\");\n\t}\n\n\n\t// Update toolbar button\n\tvar toolbarButton = editor.toolbarElements.fullscreen;\n\n\tif(!/active/.test(toolbarButton.className)) {\n\t\ttoolbarButton.className += \" active\";\n\t} else {\n\t\ttoolbarButton.className = toolbarButton.className.replace(/\\s*active\\s*/g, \"\");\n\t}\n\n\n\t// Hide side by side if needed\n\tvar sidebyside = cm.getWrapperElement().nextSibling;\n\tif(/editor-preview-active-side/.test(sidebyside.className))\n\t\ttoggleSideBySide(editor);\n}", "title": "" }, { "docid": "589c900896f0b7d276e3b3c6a93b5a12", "score": "0.6979233", "text": "function switchToFullscreen() {\n if (container.requestFullscreen) {\n container.requestFullscreen();\n }\n else if (container.msRequestFullscreen) {\n container.msRequestFullscreen();\n }\n else if (container.mozRequestFullScreen) {\n container.mozRequestFullScreen();\n }\n else if (container.webkitRequestFullscreen) {\n container.webkitRequestFullscreen();\n }\n }", "title": "" }, { "docid": "34587b465762769f681fae57a53d120b", "score": "0.6955735", "text": "fullScreen() {\n this.props.allowFullScreen && this._iframeNode.requestFullScreen && this._iframeNode.requestFullScreen();\n }", "title": "" }, { "docid": "98d68aa220f2a61b2307b6d574c343cc", "score": "0.69314307", "text": "toggleFullscreen() {\n let vid = document.querySelector('iframe')\n if (!document.vid) {\n vid.requestFullscreen();\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen();\n }\n }\n }", "title": "" }, { "docid": "cf05f06b9b21a736277ba41c912d2fd6", "score": "0.6918698", "text": "static set defaultIsFullScreen(value) {}", "title": "" }, { "docid": "dcbfc8a37a8560368d2cd7b39f1b4b86", "score": "0.6902165", "text": "function toggleContainerFullscreen(){\n\t\t\t\t\t\n\t\t\t\t\tif(document.fullscreenElement || // alternative standard method\n \t\t\t\t\tdocument.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement /*utils.hasClass(container, fullscreenModeClazz)*/){\n\t\t\t\t\t\t// exit fullscreen\n\t\t\t\t\t\tif (document.exitFullscreen) {\n\t\t\t\t\t\t\tdocument.exitFullscreen();\n\t\t\t\t\t\t} else if (document.msExitFullscreen) {\n\t\t\t\t\t\t\tdocument.msExitFullscreen();\n\t\t\t\t\t\t} else if (document.mozCancelFullScreen) {\n\t\t\t\t\t\t\tdocument.mozCancelFullScreen();\n\t\t\t\t\t\t} else if (document.webkitExitFullscreen) {\n\t\t\t\t\t\t\tdocument.webkitExitFullscreen();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\"The bowser doesn't support fullscreen mode\"); //// Don't support fullscreen\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\t// enter fullscreen\n\t\t\t\t\t\tif (document.documentElement.requestFullscreen) {\n\t\t\t\t\t\t\tcontainer.requestFullscreen();\n\t\t\t\t\t\t} else if (document.documentElement.msRequestFullscreen) {\n\t\t\t\t\t\t\tcontainer.msRequestFullscreen();\n\t\t\t\t\t\t} else if (document.documentElement.mozRequestFullScreen) {\n\t\t\t\t\t\t\tcontainer.mozRequestFullScreen();\n\t\t\t\t\t\t} else if (document.documentElement.webkitRequestFullscreen) {\n\t\t\t\t\t\t\tcontainer.webkitRequestFullscreen();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\"The bowser doesn't support fullscreen mode\"); //// Don't support fullscreen\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}", "title": "" }, { "docid": "7e6909a30093c405317f7efbd9ed7b33", "score": "0.6890637", "text": "function toggleFullscreen() {\n let elem = document.querySelector(\"video\");\n if (!document.fullscreenElement) {\n elem.requestFullscreen().catch(err => {\n alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);\n });\n } else {\n document.exitFullscreen();\n }\n}", "title": "" }, { "docid": "66badfbb9ad1f7c5bcd673c6938c7784", "score": "0.6887247", "text": "_onFullscreenChanged() {\n this._updateDockVisibility();\n }", "title": "" }, { "docid": "bbaf4cbc3936b0362377a1dd543fb72d", "score": "0.6875391", "text": "GoFullscreen() {\n\t\t\t//let container = document.getElementById(\"container\");\n\t\t\tlet container = document.getElementsByTagName(\"BODY\")[0];\n\t\t\tif (container.requestFullScreen) {\n\t\t\t\tcontainer.requestFullScreen();\n\t\t\t} else if (container.webkitRequestFullScreen) {\n\t\t\t\tcontainer.webkitRequestFullScreen();\n\t\t\t} else if (container.mozRequestFullScreen) {\n\t\t\t\tcontainer.mozRequestFullScreen();\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "f229114d4f69d8c08ddc3db34d681470", "score": "0.6857273", "text": "fullscreen() {\n // TODO: find out\n const rfs =\n this.refs.iframe.requestFullScreen ||\n this.refs.iframe.webkitRequestFullScreen ||\n this.refs.iframe.mozRequestFullScreen ||\n this.refs.iframe.msRequestFullScreen\n\n rfs && rfs.call(this.refs.iframe)\n }", "title": "" }, { "docid": "21652799bb0460705c703eb09797f238", "score": "0.68571234", "text": "function showFullscreen (className) {\n var element = $('.' + className);\n\n element.classList.add('fullscreen-open');\n}", "title": "" }, { "docid": "c30d944631e24e3040b517a435814b7d", "score": "0.6826686", "text": "function openFullscreen() {\n /* If fullscreen mode is available, show the element in fullscreen */\n if (\n document.fullscreenEnabled || /* Standard syntax */\n document.webkitFullscreenEnabled || /* Chrome, Safari & Opera */\n document.mozFullScreenEnabled || /* Firefox */\n document.msFullscreenEnabled /* IE/Edge */\n ) {\n \n /* Show the element in fullscreen */\n elem.webkitRequestFullscreen();\n if (elem.requestFullscreen) {\n elem.requestFullscreen(); /* Standard syntax */\n } else if (elem.mozRequestFullScreen) { /* Firefox */\n elem.mozRequestFullScreen();\n } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */\n elem.webkitRequestFullscreen();\n } else if (elem.msRequestFullscreen) { /* IE/Edge */\n elem.msRequestFullscreen();\n }\n \n }\n }", "title": "" }, { "docid": "df177fbfc7c92bc4f97e283fa0b3854b", "score": "0.680687", "text": "goFullscreen () {\n\t\tlet fullscreens = [\n\t\t\t'requestFullScreen',\n\t\t\t'webkitRequestFullScreen',\n\t\t\t'mozRequestFullScreen',\n\t\t\t'msRequestFullScreen'\n\t\t];\n\n\t\tfullscreens.forEach((fullscreen) => {\n\t\t\tif(typeof this.video[fullscreen] === 'function') {\n\t\t\t\tthis.video[fullscreen]();\n\t\t\t}\n\t\t});\n\n\t}", "title": "" }, { "docid": "aac59c586e34324cfd18acc45250a7e4", "score": "0.6796253", "text": "function fullScreenHandler() {\n if (isFullScreen())\n toggleMediaPlayerSize();\n else\n toggleMediaPlayerSize(PLAYER_SIZE_FULL);\n}", "title": "" }, { "docid": "0875567e63521a911c2f42c288932015", "score": "0.67916065", "text": "function toggleFullScreen(editor) {\n // Set fullscreen\n var cm = editor.codemirror;\n cm.setOption('fullScreen', !cm.getOption('fullScreen'));\n\n\n // Prevent scrolling on body during fullscreen active\n if (cm.getOption('fullScreen')) {\n saved_overflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n } else {\n document.body.style.overflow = saved_overflow;\n }\n\n\n // Hide side by side if needed\n var sidebyside = cm.getWrapperElement().nextSibling;\n if (/editor-preview-active-side/.test(sidebyside.className))\n toggleSideBySide(editor);\n\n if (editor.options.onToggleFullScreen) {\n editor.options.onToggleFullScreen(cm.getOption('fullScreen') || false);\n }\n\n // Remove or set maxHeight\n if (typeof editor.options.maxHeight !== 'undefined') {\n if (cm.getOption('fullScreen')) {\n cm.getScrollerElement().style.removeProperty('height');\n sidebyside.style.removeProperty('height');\n } else {\n cm.getScrollerElement().style.height = editor.options.maxHeight;\n editor.setPreviewMaxHeight();\n }\n }\n\n\n // Update toolbar class\n if (!/fullscreen/.test(editor.toolbar_div.className)) {\n editor.toolbar_div.className += ' fullscreen';\n } else {\n editor.toolbar_div.className = editor.toolbar_div.className.replace(/\\s*fullscreen\\b/, '');\n }\n\n\n // Update toolbar button\n if (editor.toolbarElements && editor.toolbarElements.fullscreen) {\n var toolbarButton = editor.toolbarElements.fullscreen;\n\n if (!/active/.test(toolbarButton.className)) {\n toolbarButton.className += ' active';\n } else {\n toolbarButton.className = toolbarButton.className.replace(/\\s*active\\s*/g, '');\n }\n }\n}", "title": "" }, { "docid": "17515014865753dc707cdae55ace9767", "score": "0.6786249", "text": "function fullscreen(){\n jQuery('#hero').css({\n height: jQuery(window).height()\n });\n }", "title": "" }, { "docid": "32955a0fde7bfbfec01fd86a4919997b", "score": "0.6754244", "text": "function toggleFullScreen() {\n\t$(document).keyup(function(e) {\n\t\tisFullScreenEnabled = false;\n\t\tbuttonBar.style.bottom = \"15px\";\n\t\tif (e.keyCode === 27) { // escape key maps to keycode `27`\n\t\tif(document.cancelFullScreen) { document.cancelFullScreen(); }\n\t\telse if(document.mozCancelFullScreen) { document.mozCancelFullScreen(); }\n\t\telse if(document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); }\n\t\t}\n\t});\n\t\n\tif(isFullScreenEnabled === false){\n\t\tisFullScreenEnabled = true;\n\t\tbuttonBar.style.right = \"5px\";\n\t\tif(video.requestFullScreen) { video.requestFullScreen(); }\n\t\telse if(video.msRequestFullscreen) { video.msRequestFullscreen(); }\n\t\telse if(video.mozRequestFullScreen) { video.mozRequestFullScreen(); }\n\t\telse if(video.webkitRequestFullScreen) { video.webkitRequestFullScreen(); }\n\t}\n\t\n\telse{\n\t\tisFullScreenEnabled = false;\n\t\tbuttonBar.style.bottom = \"15px\";\n\t\tif(document.cancelFullScreen) { document.cancelFullScreen(); }\n\t\telse if(document.msExitFullscreen) { document.msExitFullscreen(); }\n\t\telse if(document.mozCancelFullScreen) { document.mozCancelFullScreen(); }\n\t\telse if(document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); }\n\t\t}\n}", "title": "" }, { "docid": "8e991f745b7d10faf4f23a1160ffde6b", "score": "0.67397445", "text": "function fullscreen() {\n jQuery('#hero').css({\n width: jQuery(window).width(),\n height: jQuery(window).height()\n });\n }", "title": "" }, { "docid": "659c0ecf218fc93225e2eba090a79844", "score": "0.67305845", "text": "function closeFullScreen() {\n document.exitFullscreen();\n body.classList.remove('full-screen');\n}", "title": "" }, { "docid": "ebe79639c8c0c224c9f57fd90307efa7", "score": "0.67294484", "text": "function FullDisplay() {\n\tif (!FlagFullDisplay){\n\t\tif(document.documentElement.requestFullScreen) {\n\t\t\t\tdocument.documentElement.requestFullScreen();\n\t\t\t\t\t} \n\t\telse if(document.documentElement.mozRequestFullScreen) {\n\t\t\t\tdocument.documentElement.mozRequestFullScreen();\n\t\t\t\t\t}\n\t\telse if(document.documentElement.webkitRequestFullScreen) {\n\t\t\tdocument.documentElement.webkitRequestFullScreen();\n\t\t\t\t}\n\t\t}\n\telse{\n\t\tif (document.cancelFullScreen) {\n\t\t\tdocument.cancelFullScreen();\n\t\t\t} \n\t\telse if (document.mozCancelFullScreen) {\n\t\t\tdocument.mozCancelFullScreen();\n\t\t\t} \n\t\telse if (document.webkitCancelFullScreen) {\n\t\t\tdocument.webkitCancelFullScreen();\n\t\t\t}\n\t\t}\n\t\tFlagFullDisplay = !FlagFullDisplay;\n}", "title": "" }, { "docid": "69079bfd9a48935c814a50aa475e63ff", "score": "0.67191404", "text": "lauchFullscreen() {\n\t\tconst container = document.querySelector('.story-container');\n\t\tthis.fullscreenMethod.bind(container)();\n\t}", "title": "" }, { "docid": "7d7cc52316fc64edc335d3398569fb2e", "score": "0.6710199", "text": "function exitFullScreen(event){\n if (tFullScreen)\n toggleFullScreen(event);\n}", "title": "" }, { "docid": "7a777393d43712528f4dcddd0bd904aa", "score": "0.67012715", "text": "_onScreenfullLoaded() {\n let root = this;\n root.screenfullLoaded = true;\n\n // handles fullscreen\n if (screenfull) {\n screenfull.on(\"change\", () => {\n if (screenfull.enabled) root.fullscreen = screenfull.isFullscreen;\n });\n }\n }", "title": "" }, { "docid": "13546dfc487d462d7518b8041fcccc42", "score": "0.66963136", "text": "function fullscreen_fx() {\n if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {\n if (document.documentElement.requestFullscreen) {\n document.documentElement.requestFullscreen();\n } else if (document.documentElement.msRequestFullscreen) {\n document.documentElement.msRequestFullscreen();\n } else if (document.documentElement.mozRequestFullScreen) {\n document.documentElement.mozRequestFullScreen();\n } else if (document.documentElement.webkitRequestFullscreen) {\n document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n }\n // Taille de l'écran\n taiEX = window.screen.width;\n taiEY = window.screen.height;\n } else {\n if (document.cancelFullScreen) {\n document.cancelFullScreen();\n } else if (document.msCancelFullScreen) {\n document.msCancelFullScreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitCancelFullScreen) {\n document.webkitCancelFullScreen();\n }\n taiEX = window.screen.width;\n taiEY = window.screen.height;\n }\n}", "title": "" }, { "docid": "da9246f33e947ff5aca75ebba494b762", "score": "0.668585", "text": "enterFullMode() {\n this._setMode('full');\n }", "title": "" }, { "docid": "da9246f33e947ff5aca75ebba494b762", "score": "0.668585", "text": "enterFullMode() {\n this._setMode('full');\n }", "title": "" }, { "docid": "53b7e43fa34ddd0e45f636d2e1cc0605", "score": "0.66857195", "text": "function fullScreen(ele) {\r\n\t ele.style.top = 0;\r\n\t ele.style.left = 0;\r\n\t ele.style.width = '100%';\r\n\t ele.style.height = '100%';\r\n\t }", "title": "" }, { "docid": "b341ac449a8a14f922586a96f5d7d421", "score": "0.66759944", "text": "static get macFullscreenMode() {}", "title": "" }, { "docid": "49fcc89bbe8759853610d7e6b8d8c656", "score": "0.6663401", "text": "toggleMapFullscreen() {\n window.L.easyButton({\n states: [{\n stateName: 'expand',\n icon: '<span class=\"icon icon-sm icon-expand\"><svg><use xlink:href=\"#expand-icon\"/></svg></span>',\n title: 'Expand',\n onClick: control => {\n this.$map\n .animate({ height: $(window).height() - $('#menu').height() }, () => {\n this.map.invalidateSize();\n this.fitBounds();\n });\n\n smoothScroll(this.$map);\n control.state('compress');\n }\n }, {\n stateName: 'compress',\n icon: '<span class=\"icon icon-sm icon-compress\"><svg><use xlink:href=\"#compress-icon\"/></svg></span>',\n title: 'Compress',\n onClick: control => {\n this.$map\n .animate({ height: $(window).width() > 767 ? '400px' : '300px' }, () => {\n this.map.invalidateSize();\n this.fitBounds();\n });\n\n smoothScroll(this.$map);\n control.state('expand');\n }\n }]\n }).addTo(this.map);\n }", "title": "" }, { "docid": "0f4fa21059c0bb8aa5e1b80292ef763e", "score": "0.66617584", "text": "function speedToggle(ismob){\n if(ismob != true || isFullScreen()){\n if(ismob != false){\n _(\"optionsMenu\").style.justifyContent = \"unset\";\n _(\"optionsMenu\").style.top = \"-240px\";\n _(\"optionsMenu\").style.width = \"auto\";\n _(\"optionsMenu\").style.left = \"unset\";\n }\n if(_(\"optionsMenu\").style.display == \"block\"){\n _(\"optionsMenu\").style.display = \"none\";\n }else{\n _(\"optionsMenu\").style.display = \"block\";\n }\n }else if(ismob != false && !isFullScreen()){\n _(\"optionsMenu\").style.justifyContent = \"center\";\n _(\"optionsMenu\").style.top = \"-80px\";\n _(\"optionsMenu\").style.width = \"calc(100% - 40px)\";\n _(\"optionsMenu\").style.left = \"20px\";\n _(\"optionsMenu\").style.right = \"20px\";\n _(\"optionsMenu\").style.flexWrap = \"wrap\";\n if(_(\"optionsMenu\").style.display == \"flex\"){\n _(\"optionsMenu\").style.display = \"none\";\n }else{\n _(\"optionsMenu\").style.display = \"flex\";\n }\n }\n}", "title": "" }, { "docid": "31b7181da4c01b18bfc40f7a404b4a34", "score": "0.66430587", "text": "function openFullscreen() {\r\n\r\n var elem = document.getElementById(\"table\");\r\n if (elem.requestFullscreen) {\r\n elem.requestFullscreen();\r\n } else if (elem.mozRequestFullScreen) {\r\n /* Firefox */\r\n elem.mozRequestFullScreen();\r\n } else if (elem.webkitRequestFullscreen) {\r\n /* Chrome, Safari and Opera */\r\n elem.webkitRequestFullscreen();\r\n } else if (elem.msRequestFullscreen) {\r\n /* IE/Edge */\r\n elem.msRequestFullscreen();\r\n }\r\n}", "title": "" }, { "docid": "df510f880d4c6b36c166071a18e93bf1", "score": "0.6639917", "text": "toggle() {\n if (!this.__main) {\n this.init();\n } else if (this.__main.style.display == \"none\") {\n this.show();\n } else {\n this.__main.style.display = \"none\";\n }\n }", "title": "" }, { "docid": "36fc554092cf15d49bdc4c64eaa0f418", "score": "0.6622008", "text": "emitFullscreen() {\n this.emit(STORES_PRES_VIEW.FULL_SCREEN);\n }", "title": "" }, { "docid": "4da2e9d4415ec11fe78d9decac039012", "score": "0.661272", "text": "bindFullScreen() {\n this.fullScreenButton.addEventListener('click', () => {\n this.map.toggleFullscreen();\n document.querySelector('#mapid').click();\n keyboard.close();\n });\n }", "title": "" }, { "docid": "57a7d9d6083069cebf2618396d2a65b2", "score": "0.6596163", "text": "toggleFullScreen() {\n\t\t\tif (paella.player.isFullScreen()) {\n\t\t\t\tpaella.player.exitFullScreen();\n\t\t\t}\n\t\t\telse if ((!paella.player.checkFullScreenCapability() || paella.utils.userAgent.browser.Explorer) && window.location !== window.parent.location) {\n\t\t\t\t// Iframe and no fullscreen support\n\t\t\t\tvar url = window.location.href;\n\t\n\t\t\t\tpaella.player.pause();\n\t\t\t\tpaella.player.videoContainer.currentTime()\n\t\t\t\t\t.then((currentTime) => {\n\t\t\t\t\t\tvar obj = this.secondsToHours(currentTime);\n\t\t\t\t\t\twindow.open(url+\"&time=\"+obj.h+\"h\"+obj.m+\"m\"+obj.s+\"s&autoplay=true\");\n\t\t\t\t\t});\n\t\t\t\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tpaella.player.goFullScreen();\n\t\t\t}\n\t\n\t\t\tif (paella.player.config.player.reloadOnFullscreen && paella.player.videoContainer.supportAutoplay()) {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tif(this._reload) {\n\t\t\t\t\t\tpaella.player.videoContainer.setQuality(null)\n\t\t\t\t\t\t\t.then(() => {\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t//paella.player.reloadVideos();\n\t\t\t\t\t}\n\t\t\t\t}, 1000);\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "a113670b90aa9a332db328b2592e46ee", "score": "0.6591605", "text": "static get defaultIsFullScreen() {}", "title": "" }, { "docid": "e4981699bf7539f42200a857f2769b26", "score": "0.6586789", "text": "function enterFullscreen() {\n console.log(\"enterFullscreen()\");\n $('body').addClass('full-screen');\n elem.onwebkitfullscreenchange = onFullScreenEnter;\n elem.onmozfullscreenchange = onFullScreenEnter;\n elem.onfullscreenchange = onFullScreenEnter;\n if (elem.webkitRequestFullscreen) {\n elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);\n } else {\n if (elem.mozRequestFullScreen) {\n elem.mozRequestFullScreen();\n } else {\n elem.requestFullscreen();\n }\n }\n// document.getElementById('enter-exit-fs').onclick = exitFullscreen;\n}", "title": "" }, { "docid": "6c5b854e1bf3da01fbcd6222f35f7c15", "score": "0.6581355", "text": "function toggle() {\n show = 0;\n}", "title": "" }, { "docid": "58bc82559ea18be5dad91e37be15404c", "score": "0.657845", "text": "function OCM_fullscreenOpen() {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif ($('body.material').length > 0) {\r\n\t\t\t\t\t\t$('header#top .slide-out-widget-area-toggle a').addClass('menu-push-out');\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t// Scroll away from fixed reveal footer if shown (firefox bug with bluring over it)\r\n\t\t\t\t\tvar $scrollDelay = 0;\r\n\t\t\t\t\tvar $scrollDelay2 = 0;\r\n\t\t\t\t\t\r\n\t\t\t\t\tif (nectarDOMInfo.scrollTop + $window.height() > $('.blurred-wrap').height() && $('#nectar_fullscreen_rows').length == 0) {\r\n\t\t\t\t\t\t$('body,html').stop().animate({\r\n\t\t\t\t\t\t\tscrollTop: $('.blurred-wrap').height() - $window.height()\r\n\t\t\t\t\t\t}, 600, 'easeInOutCubic');\r\n\t\t\t\t\t\t$scrollDelay = 550;\r\n\t\t\t\t\t\t$scrollDelay2 = 200;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t$('header#top .slide-out-widget-area-toggle:not(.std-menu) .lines-button').addClass('close');\r\n\t\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\t\t$('.blurred-wrap').addClass('blurred');\r\n\t\t\t\t\t}, $scrollDelay);\r\n\t\t\t\t\t$('#slide-out-widget-area.fullscreen').show().addClass('open');\r\n\t\t\t\t\t\r\n\t\t\t\t\tif ($('.nectar-social.fixed').length == 0) {\r\n\t\t\t\t\t\thideToTop();\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t// Remove box shadow incase at the top of the page with nectar box roll above\r\n\t\t\t\t\t$('.container-wrap').addClass('no-shadow');\r\n\t\t\t\t\t$headerOuterEl.stop(true).css('transform', 'translateY(0)');\r\n\t\t\t\t\t\r\n\t\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t$('.off-canvas-menu-container .menu > li').each(function (i) {\r\n\t\t\t\t\t\t\t$(this).delay(i * 50).transition({\r\n\t\t\t\t\t\t\t\ty: 0,\r\n\t\t\t\t\t\t\t\t'opacity': 1\r\n\t\t\t\t\t\t\t}, 800, 'easeOutExpo');\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t$('#slide-out-widget-area.fullscreen .widget').each(function (i) {\r\n\t\t\t\t\t\t\t$(this).delay(i * 100).transition({\r\n\t\t\t\t\t\t\t\ty: 0,\r\n\t\t\t\t\t\t\t\t'opacity': 1\r\n\t\t\t\t\t\t\t}, 800, 'easeOutExpo');\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}, 370 + $scrollDelay2);\r\n\t\t\t\t\t\r\n\t\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\t\t$('#slide-out-widget-area .off-canvas-social-links').addClass('line-shown');\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t$('#slide-out-widget-area .off-canvas-social-links li').each(function (i) {\r\n\t\t\t\t\t\t\t$(this).delay(i * 50).transition({\r\n\t\t\t\t\t\t\t\t'scale': 1\r\n\t\t\t\t\t\t\t}, 400, 'easeOutCubic');\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t$('#slide-out-widget-area .bottom-text').transition({\r\n\t\t\t\t\t\t\t'opacity': 0.7\r\n\t\t\t\t\t\t}, 400, 'easeOutCubic');\r\n\t\t\t\t\t}, 750 + $scrollDelay2);\r\n\t\t\t\t\t\r\n\t\t\t\t\t// Fade In BG Overlay\r\n\t\t\t\t\tsetTimeout(function () {\r\n\t\t\t\t\t\tvar $easing = ($('body.mobile').length > 0) ? 'easeOutCubic' : 'easeInOutQuint';\r\n\t\t\t\t\t\t$offCanvasBG.css({\r\n\t\t\t\t\t\t\t'height': '100%',\r\n\t\t\t\t\t\t\t'width': '100%'\r\n\t\t\t\t\t\t}).show().stop(true).transition({\r\n\t\t\t\t\t\t\t'y': '0%'\r\n\t\t\t\t\t\t}, 920, $easing, function () {\r\n\t\t\t\t\t\t\t$('.slide-out-widget-area-toggle > div > a').removeClass('animating');\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}, 50 + $scrollDelay2);\r\n\t\t\t\t\t\r\n\t\t\t\t\t// Overflow state \r\n\t\t\t\t\tOCM_overflowState();\r\n\t\t\t\t\t\r\n\t\t\t\t\tif ($('.mobile #header-outer[data-permanent-transparent=\"false\"]').length > 0 && $('.container-wrap').hasClass('no-scroll')) {\r\n\t\t\t\t\t\t$('#ajax-content-wrap').addClass('at-content');\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tif ($('.mobile #header-outer[data-permanent-transparent=\"false\"]').length > 0 || $('.mobile').length == 0 && $('#header-outer.transparent').length == 0) {\r\n\t\t\t\t\t\t$('#slide-out-widget-area.fullscreen .inner-wrap').css('padding-top', $headerOuterEl.height());\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t}", "title": "" }, { "docid": "38e4cf36c328866bb7c3ce912242b1ac", "score": "0.65736145", "text": "function open() {\n const el = ref.current || document.documentElement\n\n if (el.requestFullscreen) return el.requestFullscreen()\n if (el.mozRequestFullScreen) return el.mozRequestFullScreen()\n if (el.webkitRequestFullscreen) return el.webkitRequestFullscreen()\n if (el.msRequestFullscreen) return el.msRequestFullscreen()\n }", "title": "" }, { "docid": "3fb124a8ca3fc83ec98dadcb08702556", "score": "0.65683097", "text": "function callFullScreenMode(e){\n \n if (screenfull.enabled) {\n\n e.preventDefault();\n\n // make sure this stuff only happens if we're not full-screen yet\n if(!screenfull.isFullscreen){\n\n // get initial variables\n let target = $(this);\n let originalImg = $(target).find('img');\n let fullImgSrc = $(target).attr('href');\n let fullImg = document.createElement('img');\n $(fullImg).attr('src',fullImgSrc).addClass('enlargement').hide();\n\n // suppress the link\n $(this).attr('href','#');\n\n // FIRE!\n createImage( originalImg, target, fullImg, goFullScreen );\n }\n }\n }", "title": "" }, { "docid": "58ce5510a00794520376cd77a5006c7e", "score": "0.6566494", "text": "function onFullscreenChange() {\n if(!document.webkitFullscreenElement && !document.mozFullScreenElement) {\n vrMode = false;\n }\n resize();\n}", "title": "" }, { "docid": "48d13163d5641de3f96da9db9e46618f", "score": "0.65621763", "text": "function OpenHiddenFullSidebar() {\n var hamburgerBtn = document.querySelectorAll(\"#guide-button\");\n RemoveFullSidebarTransitions();\n HideFullSidebar();\n RemoveSidebarDim();\n hamburgerBtn[1].click();\n}", "title": "" }, { "docid": "fa75ad8a36a1c76e85aa87a09c54f3b1", "score": "0.65590256", "text": "function fullscreen(){\n if (document.fullscreenElement) {\n // fullscreen is activated\n document.exitFullscreen();\n } else {\n // fullscreen is cancelled\n document.documentElement.requestFullscreen();\n }\n}", "title": "" }, { "docid": "994d7ad17ccc278aa890104a38ac75f9", "score": "0.6537531", "text": "enterFullScreen() {\n this.dmPlayer.setFullscreen(true);\n }", "title": "" }, { "docid": "5c886f835bd49b6f95764d012e75ffe5", "score": "0.6536898", "text": "function enterFullscreen(id) {\n onFullScreenEnter(id);\n $( \".fullscreen\" ).toggleClass( \"fullscreen-on\" );\n var el = document.getElementById(id);\n var onfullscreenchange = function(e){\n var fullscreenElement = document.fullscreenElement || document.mozFullscreenElement || document.webkitFullscreenElement;\n var fullscreenEnabled = document.fullscreenEnabled || document.mozFullscreenEnabled || document.webkitFullscreenEnabled;\n console.log( 'fullscreenEnabled = ' + fullscreenEnabled, ', fullscreenElement = ', fullscreenElement, ', e = ', e);\n }\n\n el.addEventListener(\"webkitfullscreenchange\", onfullscreenchange);\n el.addEventListener(\"mozfullscreenchange\", onfullscreenchange);\n el.addEventListener(\"fullscreenchange\", onfullscreenchange);\n\n if (el.webkitRequestFullScreen) {\n el.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);\n } else {\n el.mozRequestFullScreen();\n }\n document.querySelector('#'+id + ' img').onclick = function(){\n exitFullscreen(id);\n console.log('#'+id + ' button');\n }\n}", "title": "" }, { "docid": "4bde976b29333e4b681f443e9b80d4da", "score": "0.6533547", "text": "function goFullscreen(id) {\n var element = document.getElementById(id); \n if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen();\n } else if (element.webkitRequestFullScreen) {\n element.webkitRequestFullScreen();\n } \n}", "title": "" }, { "docid": "4bde976b29333e4b681f443e9b80d4da", "score": "0.6533547", "text": "function goFullscreen(id) {\n var element = document.getElementById(id); \n if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen();\n } else if (element.webkitRequestFullScreen) {\n element.webkitRequestFullScreen();\n } \n}", "title": "" }, { "docid": "8ad7a7cabeef3160893afbef2b8bbc36", "score": "0.6509393", "text": "function toFakeFullScreen(){\n\t\t\n\t\tjQuery(\"body\").addClass(\"ug-body-fullscreen\");\n\t\tg_objWrapper.addClass(\"ug-fake-fullscreen\");\n\t\t\n\t\tg_temp.isFakeFullscreen = true;\n\t\t\n\t\tg_objGallery.trigger(t.events.ENTER_FULLSCREEN);\n\t\tg_objGallery.trigger(t.events.SIZE_CHANGE);\n\t}", "title": "" }, { "docid": "6bae6866bea612615fb68823789f25b1", "score": "0.6502475", "text": "function toggleView(e) {\n //find the body element \n let backgroundBody = document.body\n console.log(\"click happened\")\n //when the event is registered on the target, use toggle() to switch between show(\"dark-mode\") and hide(\"dark-mode\")\n e.target\n backgroundBody.classList.toggle(\"dark-mode\");\n}", "title": "" } ]
d91e097814ae1f957265cd99c14b2af5
[MSXLS] 2.5.198.59 ; [MSXLSB] 2.5.97.41
[ { "docid": "02b17f614cebe0c2c87422d34d5f24f8", "score": "0.0", "text": "function parse_PtgExtraArray(blob, length, opts) {\n\tvar rows = 0, cols = 0;\n\tif(opts.biff == 12) {\n\t\trows = blob.read_shift(4); // DRw\n\t\tcols = blob.read_shift(4); // DCol\n\t} else {\n\t\tcols = 1 + blob.read_shift(1); //DColByteU\n\t\trows = 1 + blob.read_shift(2); //DRw\n\t}\n\tif(opts.biff >= 2 && opts.biff < 8) { --rows; if(--cols == 0) cols = 0x100; }\n\t// $FlowIgnore\n\tfor(var i = 0, o = []; i != rows && (o[i] = []); ++i)\n\t\tfor(var j = 0; j != cols; ++j) o[i][j] = parse_SerAr(blob, opts.biff);\n\treturn o;\n}", "title": "" } ]
[ { "docid": "18c9f3a8a45febf5393a356e3bc14173", "score": "0.56946784", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "26c30dbc09874a2d3cec1cfad80d0a3c", "score": "0.56707555", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\t//blob.chk(HEADER_CLSID, 'CLSID: ');\n\tblob.l += 16;\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "26c30dbc09874a2d3cec1cfad80d0a3c", "score": "0.56707555", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\t//blob.chk(HEADER_CLSID, 'CLSID: ');\n\tblob.l += 16;\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "26c30dbc09874a2d3cec1cfad80d0a3c", "score": "0.56707555", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\t//blob.chk(HEADER_CLSID, 'CLSID: ');\n\tblob.l += 16;\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "26c30dbc09874a2d3cec1cfad80d0a3c", "score": "0.56707555", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\t//blob.chk(HEADER_CLSID, 'CLSID: ');\n\tblob.l += 16;\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "26c30dbc09874a2d3cec1cfad80d0a3c", "score": "0.56707555", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\t//blob.chk(HEADER_CLSID, 'CLSID: ');\n\tblob.l += 16;\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "26c30dbc09874a2d3cec1cfad80d0a3c", "score": "0.56707555", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\t//blob.chk(HEADER_CLSID, 'CLSID: ');\n\tblob.l += 16;\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "26c30dbc09874a2d3cec1cfad80d0a3c", "score": "0.56707555", "text": "function check_get_mver(blob) {\n\tif(blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0];\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\t//blob.chk(HEADER_CLSID, 'CLSID: ');\n\tblob.l += 16;\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "36452bdc6dd4b095309c9d0ad63af607", "score": "0.5625205", "text": "static get VERSION() {\n return 0x2001;\n }", "title": "" }, { "docid": "da227530e80494cbfedbfe018effbcc2", "score": "0.56000674", "text": "function parse_XLSBCellParsedFormula(data, length) {\n\tvar cce = data.read_shift(4);\n\treturn parsenoop(data, length-4);\n}", "title": "" }, { "docid": "da227530e80494cbfedbfe018effbcc2", "score": "0.56000674", "text": "function parse_XLSBCellParsedFormula(data, length) {\n\tvar cce = data.read_shift(4);\n\treturn parsenoop(data, length-4);\n}", "title": "" }, { "docid": "da227530e80494cbfedbfe018effbcc2", "score": "0.56000674", "text": "function parse_XLSBCellParsedFormula(data, length) {\n\tvar cce = data.read_shift(4);\n\treturn parsenoop(data, length-4);\n}", "title": "" }, { "docid": "cc0330c4dd1d9409b67379fc6400c8a9", "score": "0.5579204", "text": "function check_get_mver(blob) {\n if (blob[blob.l] == 0x50 && blob[blob.l + 1] == 0x4b) return [0, 0]; // header signature 8\n\n blob.chk(HEADER_SIGNATURE, 'Header Signature: '); // clsid 16\n //blob.chk(HEADER_CLSID, 'CLSID: ');\n\n blob.l += 16; // minor version 2\n\n var mver = blob.read_shift(2, 'u');\n return [blob.read_shift(2, 'u'), mver];\n }", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "590fa96209262be37bb63c9dfe3f710b", "score": "0.5541776", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "f4a22ea80772ef1a08675bf2380165f8", "score": "0.55336213", "text": "function parse_SupBook(blob, length, opts) {\n var end = blob.l + length;\n var ctab = blob.read_shift(2);\n var cch = blob.read_shift(2);\n var virtPath;\n if (cch >= 1 && cch <= 255)\n virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n var rgst = blob.read_shift(end - blob.l);\n opts.sbcch = cch;\n return [\n cch,\n ctab,\n virtPath,\n rgst\n ];\n }", "title": "" }, { "docid": "f4a22ea80772ef1a08675bf2380165f8", "score": "0.55336213", "text": "function parse_SupBook(blob, length, opts) {\n var end = blob.l + length;\n var ctab = blob.read_shift(2);\n var cch = blob.read_shift(2);\n var virtPath;\n if (cch >= 1 && cch <= 255)\n virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n var rgst = blob.read_shift(end - blob.l);\n opts.sbcch = cch;\n return [\n cch,\n ctab,\n virtPath,\n rgst\n ];\n }", "title": "" }, { "docid": "371377af0ae9bd6e847dd01209989028", "score": "0.55118126", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\tvar virtPath;\n\tif(cch >=0x01 && cch <=0xff) virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\tvar rgst = blob.read_shift(end - blob.l);\n\topts.sbcch = cch;\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "371377af0ae9bd6e847dd01209989028", "score": "0.55118126", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\tvar virtPath;\n\tif(cch >=0x01 && cch <=0xff) virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\tvar rgst = blob.read_shift(end - blob.l);\n\topts.sbcch = cch;\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "371377af0ae9bd6e847dd01209989028", "score": "0.55118126", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\tvar virtPath;\n\tif(cch >=0x01 && cch <=0xff) virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\tvar rgst = blob.read_shift(end - blob.l);\n\topts.sbcch = cch;\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "371377af0ae9bd6e847dd01209989028", "score": "0.55118126", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\tvar virtPath;\n\tif(cch >=0x01 && cch <=0xff) virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\tvar rgst = blob.read_shift(end - blob.l);\n\topts.sbcch = cch;\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "371377af0ae9bd6e847dd01209989028", "score": "0.55118126", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\tvar virtPath;\n\tif(cch >=0x01 && cch <=0xff) virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\tvar rgst = blob.read_shift(end - blob.l);\n\topts.sbcch = cch;\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "3ac5fc3bf779321954752fa6485e9a0e", "score": "0.5509724", "text": "function parse_XLSBCellParsedFormula(data, length) {\n\t\tvar cce = data.read_shift(4);\n\t\treturn parsenoop(data, length-4);\n\t}", "title": "" }, { "docid": "40dd6794a403df75ffb3229aa058f502", "score": "0.5486867", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar end = data.l + length;\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "40dd6794a403df75ffb3229aa058f502", "score": "0.5486867", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar end = data.l + length;\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "40dd6794a403df75ffb3229aa058f502", "score": "0.5486867", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n\tvar end = data.l + length;\n\tvar cce = data.read_shift(4);\n\tvar rgce = parse_Rgce(data, cce, opts);\n\tvar cb = data.read_shift(4);\n\tvar rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n\treturn [rgce, rgcb];\n}", "title": "" }, { "docid": "6967002a4f894d0b71dacb65ed46fe6d", "score": "0.5466701", "text": "function parse_XLSBCellParsedFormula(data, length) {\n var cce = data.read_shift(4);\n return parsenoop(data, length - 4);\n }", "title": "" }, { "docid": "c9fcdee514f823e41427d2309e9ded6b", "score": "0.542943", "text": "function parse_SupBook(blob, length, opts) {\n\t\tvar end = blob.l + length;\n\t\tvar ctab = blob.read_shift(2);\n\t\tvar cch = blob.read_shift(2);\n\t\tvar virtPath;\n\t\tif(cch >=0x01 && cch <=0xff) virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t\tvar rgst = blob.read_shift(end - blob.l);\n\t\topts.sbcch = cch;\n\t\treturn [cch, ctab, virtPath, rgst];\n\t}", "title": "" }, { "docid": "cdcdb949e8a092652ca113d4e5bfe82a", "score": "0.5424357", "text": "function check_get_mver(blob) {\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "cdcdb949e8a092652ca113d4e5bfe82a", "score": "0.5424357", "text": "function check_get_mver(blob) {\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "cdcdb949e8a092652ca113d4e5bfe82a", "score": "0.5424357", "text": "function check_get_mver(blob) {\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "cdcdb949e8a092652ca113d4e5bfe82a", "score": "0.5424357", "text": "function check_get_mver(blob) {\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "cdcdb949e8a092652ca113d4e5bfe82a", "score": "0.5424357", "text": "function check_get_mver(blob) {\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "cdcdb949e8a092652ca113d4e5bfe82a", "score": "0.5424357", "text": "function check_get_mver(blob) {\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "cdcdb949e8a092652ca113d4e5bfe82a", "score": "0.5424357", "text": "function check_get_mver(blob) {\n\t// header signature 8\n\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t// clsid 16\n\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t// minor version 2\n\tvar mver = blob.read_shift(2, 'u');\n\n\treturn [blob.read_shift(2,'u'), mver];\n}", "title": "" }, { "docid": "dd0ad8fd7a8314f3277466c0bb8a2e5e", "score": "0.54102093", "text": "function lwiw126720() { return 'L2.X'; }", "title": "" }, { "docid": "30d232e7e614b1b1268c23ca35a63137", "score": "0.53858876", "text": "get excelserial1904()\t{return {day:this.data.j-Δ.time.calendar.J1904}}", "title": "" }, { "docid": "524b1922620289b717d722b2b99f2cf5", "score": "0.538339", "text": "function parse_XLSBParsedFormula(data, length, opts) {\n var cce = data.read_shift(4);\n var rgce = parse_Rgce(data, cce, opts);\n var cb = data.read_shift(4);\n var rgcb = cb > 0 ? parse_RgbExtra(data, cb, rgce, opts) : null;\n return [rgce, rgcb];\n }", "title": "" }, { "docid": "7c0597f644480b038e34332668219ff1", "score": "0.5355607", "text": "function check_get_mver(blob) {\n\t\t// header signature 8\n\t\tblob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n\n\t\t// clsid 16\n\t\tblob.chk(HEADER_CLSID, 'CLSID: ');\n\n\t\t// minor version 2\n\t\tvar mver = blob.read_shift(2, 'u');\n\n\t\treturn [blob.read_shift(2,'u'), mver];\n\t}", "title": "" }, { "docid": "872656141331f171d4ba1b1a99d22a31", "score": "0.5325447", "text": "function check_get_mver(blob) {\n // header signature 8\n blob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n // clsid 16\n blob.chk(HEADER_CLSID, 'CLSID: ');\n // minor version 2\n var mver = blob.read_shift(2, 'u');\n return [\n blob.read_shift(2, 'u'),\n mver\n ];\n }", "title": "" }, { "docid": "872656141331f171d4ba1b1a99d22a31", "score": "0.5325447", "text": "function check_get_mver(blob) {\n // header signature 8\n blob.chk(HEADER_SIGNATURE, 'Header Signature: ');\n // clsid 16\n blob.chk(HEADER_CLSID, 'CLSID: ');\n // minor version 2\n var mver = blob.read_shift(2, 'u');\n return [\n blob.read_shift(2, 'u'),\n mver\n ];\n }", "title": "" }, { "docid": "a5f9f8b41c1111af757fc979f7eefb39", "score": "0.5304098", "text": "function _014DOB_bO7jaSPMhX_aXFxFw(){}", "title": "" }, { "docid": "7af0d2ea2a507e917cb24614a4d07015", "score": "0.52270037", "text": "get COMpayload() { return [-this.COMx, 0, 0]; }", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "f68f6d7066fdc4b1aec2de445e058fde", "score": "0.5202727", "text": "function parse_PtgSxName(blob) {\n\tblob.l += 2;\n\treturn [blob.read_shift(4)];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "0d37bfe7be157d7d1b85fb78130da8cc", "score": "0.5142653", "text": "function parse_SupBook(blob, length, opts) {\n\tvar end = blob.l + length;\n\tvar ctab = blob.read_shift(2);\n\tvar cch = blob.read_shift(2);\n\topts.sbcch = cch;\n\tif(cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n\tif(cch < 0x01 || cch >0xff) throw new Error(\"Unexpected SupBook type: \"+cch);\n\tvar virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n\t/* TODO: 2.5.277 Virtual Path */\n\tvar rgst = [];\n\twhile(end > blob.l) rgst.push(parse_XLUnicodeString(blob));\n\treturn [cch, ctab, virtPath, rgst];\n}", "title": "" }, { "docid": "2d697e9ae47f29fb80508f3679790cc4", "score": "0.51297086", "text": "function parse_ExternSheet(blob, length, opts) {\n\tif(opts.biff < 8) return parse_ShortXLUnicodeString(blob, length, opts);\n\tvar o = parslurp2(blob,length,parse_XTI);\n\tvar oo = [];\n\tif(opts.sbcch === 0x0401) {\n\t\tfor(var i = 0; i != o.length; ++i) oo.push(opts.snames[o[i][1]]);\n\t\treturn oo;\n\t}\n\telse return o;\n}", "title": "" }, { "docid": "2d697e9ae47f29fb80508f3679790cc4", "score": "0.51297086", "text": "function parse_ExternSheet(blob, length, opts) {\n\tif(opts.biff < 8) return parse_ShortXLUnicodeString(blob, length, opts);\n\tvar o = parslurp2(blob,length,parse_XTI);\n\tvar oo = [];\n\tif(opts.sbcch === 0x0401) {\n\t\tfor(var i = 0; i != o.length; ++i) oo.push(opts.snames[o[i][1]]);\n\t\treturn oo;\n\t}\n\telse return o;\n}", "title": "" }, { "docid": "2d697e9ae47f29fb80508f3679790cc4", "score": "0.51297086", "text": "function parse_ExternSheet(blob, length, opts) {\n\tif(opts.biff < 8) return parse_ShortXLUnicodeString(blob, length, opts);\n\tvar o = parslurp2(blob,length,parse_XTI);\n\tvar oo = [];\n\tif(opts.sbcch === 0x0401) {\n\t\tfor(var i = 0; i != o.length; ++i) oo.push(opts.snames[o[i][1]]);\n\t\treturn oo;\n\t}\n\telse return o;\n}", "title": "" }, { "docid": "2d697e9ae47f29fb80508f3679790cc4", "score": "0.51297086", "text": "function parse_ExternSheet(blob, length, opts) {\n\tif(opts.biff < 8) return parse_ShortXLUnicodeString(blob, length, opts);\n\tvar o = parslurp2(blob,length,parse_XTI);\n\tvar oo = [];\n\tif(opts.sbcch === 0x0401) {\n\t\tfor(var i = 0; i != o.length; ++i) oo.push(opts.snames[o[i][1]]);\n\t\treturn oo;\n\t}\n\telse return o;\n}", "title": "" }, { "docid": "2d697e9ae47f29fb80508f3679790cc4", "score": "0.51297086", "text": "function parse_ExternSheet(blob, length, opts) {\n\tif(opts.biff < 8) return parse_ShortXLUnicodeString(blob, length, opts);\n\tvar o = parslurp2(blob,length,parse_XTI);\n\tvar oo = [];\n\tif(opts.sbcch === 0x0401) {\n\t\tfor(var i = 0; i != o.length; ++i) oo.push(opts.snames[o[i][1]]);\n\t\treturn oo;\n\t}\n\telse return o;\n}", "title": "" }, { "docid": "e88c76214e0ff85aa74f6bd60db5fab0", "score": "0.5081947", "text": "function parse_ExternSheet(blob, length, opts) {\n\t\tif(opts.biff < 8) return parse_ShortXLUnicodeString(blob, length, opts);\n\t\tvar o = parslurp2(blob,length,parse_XTI);\n\t\tvar oo = [];\n\t\tif(opts.sbcch === 0x0401) {\n\t\t\tfor(var i = 0; i != o.length; ++i) oo.push(opts.snames[o[i][1]]);\n\t\t\treturn oo;\n\t\t}\n\t\telse return o;\n\t}", "title": "" }, { "docid": "ac4798dc7296a9d488a2245354d516a8", "score": "0.50469065", "text": "function parse_SupBook(blob, length, opts) {\n var end = blob.l + length;\n var ctab = blob.read_shift(2);\n var cch = blob.read_shift(2);\n opts.sbcch = cch;\n if (cch == 0x0401 || cch == 0x3A01) return [cch, ctab];\n if (cch < 0x01 || cch > 0xff) throw new Error(\"Unexpected SupBook type: \" + cch);\n var virtPath = parse_XLUnicodeStringNoCch(blob, cch);\n /* TODO: 2.5.277 Virtual Path */\n\n var rgst = [];\n\n while (end > blob.l) {\n rgst.push(parse_XLUnicodeString(blob));\n }\n\n return [cch, ctab, virtPath, rgst];\n }", "title": "" }, { "docid": "ba9286eaa97b58b4d477822e43b7828e", "score": "0.5001088", "text": "function parse_PtgSxName(blob) {\n blob.l += 2;\n return [blob.read_shift(4)];\n }", "title": "" }, { "docid": "3a8a8ded65e8379e784c6ce084ed340a", "score": "0.49755964", "text": "function parse_Xnum(data) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "3a8a8ded65e8379e784c6ce084ed340a", "score": "0.49755964", "text": "function parse_Xnum(data) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "3a8a8ded65e8379e784c6ce084ed340a", "score": "0.49755964", "text": "function parse_Xnum(data) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "3a8a8ded65e8379e784c6ce084ed340a", "score": "0.49755964", "text": "function parse_Xnum(data) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "f3c610ab0acd2af961ecc162528f0c56", "score": "0.49737835", "text": "function parse_ExternSheet(blob, length, opts) {\n\tif(opts.biff < 8) return parse_BIFF5ExternSheet(blob, length, opts);\n\tvar o = [], target = blob.l + length, len = blob.read_shift(opts.biff > 8 ? 4 : 2);\n\twhile(len-- !== 0) o.push(parse_XTI(blob, opts.biff > 8 ? 12 : 6, opts));\n\t\t// [iSupBook, itabFirst, itabLast];\n\treturn o;\n}", "title": "" }, { "docid": "66e1c047e006a198d0ba35abb8d5164c", "score": "0.49608746", "text": "function parse_ExternSheet(blob, length, opts) {\n\tif(opts.biff < 8) return parse_BIFF5ExternSheet(blob, length, opts);\n\tvar o = [], target = blob.l + length, len = blob.read_shift(opts.biff > 8 ? 4 : 2);\n\twhile(len-- !== 0) o.push(parse_XTI(blob, opts.biff > 8 ? 12 : 6, opts));\n\t\t// [iSupBook, itabFirst, itabLast];\n\tvar oo = [];\n\treturn o;\n}", "title": "" }, { "docid": "8f1dc73869c4c691c07bc90fd2f16da8", "score": "0.49378726", "text": "function xe(t) {\n return t.isFoundDocument() ? t.version : U.min();\n}", "title": "" }, { "docid": "8f1dc73869c4c691c07bc90fd2f16da8", "score": "0.49378726", "text": "function xe(t) {\n return t.isFoundDocument() ? t.version : U.min();\n}", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "6d19d0433ca006326334f0ae3381744d", "score": "0.4935623", "text": "function parse_PtgNum(blob) { blob.l++; return parse_Xnum(blob, 8); }", "title": "" }, { "docid": "e77a6cfc2735860ea0d4f53099e52a14", "score": "0.49102366", "text": "function lwiw195360() { return '; xa.'; }", "title": "" }, { "docid": "6133aeb619f7d021a5d29301582950b0", "score": "0.4909009", "text": "function $version(byte) {\n version = (version << 8) | byte;\n if (++offset < 4) return $version;\n if (version >= 2 && version <= 3) {\n offset = 0;\n return $num;\n }\n throw new Error(\"Invalid version number \" + num);\n }", "title": "" }, { "docid": "2722b2aaf663a7f0f3296acaec31a712", "score": "0.48976713", "text": "function lwiw194040() { return ' = 1'; }", "title": "" }, { "docid": "5c9128d8fded5ee06ce1c29688f78eae", "score": "0.4897455", "text": "function parse_ExternSheet(blob, length, opts) {\n if (opts.biff < 8)\n return parse_ShortXLUnicodeString(blob, length, opts);\n var o = parslurp2(blob, length, parse_XTI);\n var oo = [];\n if (opts.sbcch === 1025) {\n for (var i = 0; i != o.length; ++i)\n oo.push(opts.snames[o[i][1]]);\n return oo;\n } else\n return o;\n }", "title": "" }, { "docid": "5c9128d8fded5ee06ce1c29688f78eae", "score": "0.4897455", "text": "function parse_ExternSheet(blob, length, opts) {\n if (opts.biff < 8)\n return parse_ShortXLUnicodeString(blob, length, opts);\n var o = parslurp2(blob, length, parse_XTI);\n var oo = [];\n if (opts.sbcch === 1025) {\n for (var i = 0; i != o.length; ++i)\n oo.push(opts.snames[o[i][1]]);\n return oo;\n } else\n return o;\n }", "title": "" }, { "docid": "3490d043570816809f1cee7f9ee2c720", "score": "0.48802844", "text": "function parse_Xnum(data, length) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "3490d043570816809f1cee7f9ee2c720", "score": "0.48802844", "text": "function parse_Xnum(data, length) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "3490d043570816809f1cee7f9ee2c720", "score": "0.48802844", "text": "function parse_Xnum(data, length) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "3490d043570816809f1cee7f9ee2c720", "score": "0.48802844", "text": "function parse_Xnum(data, length) { return data.read_shift(8, 'f'); }", "title": "" }, { "docid": "3490d043570816809f1cee7f9ee2c720", "score": "0.48802844", "text": "function parse_Xnum(data, length) { return data.read_shift(8, 'f'); }", "title": "" } ]
1263e66ebaf14b0e46f1a32afd29178a
sets the counter and then calls to the function to count down
[ { "docid": "9a573e51ddff7e0571d5cc6b47cafd4e", "score": "0.0", "text": "function run() {\n intervalId = setInterval(decrement, 1000);\n }", "title": "" } ]
[ { "docid": "77290714c6caee7f5795a77f06977bed", "score": "0.7995951", "text": "function countDown(){\n\t\t\n\t}", "title": "" }, { "docid": "31c058f54b50e203fd94e8b045094791", "score": "0.74012095", "text": "function countReset() {\n counter = setInterval(count, 500);\n}", "title": "" }, { "docid": "0db04b9d5fd2a2e35d37ab6d404187c8", "score": "0.7388584", "text": "function changeCounter(){\n\treturn countDown-turnCount;\n}", "title": "" }, { "docid": "8598366ec74ef892a75bf0f9cbbffcc6", "score": "0.73844177", "text": "function timer(){\n\t\t\tcounter = setInterval(decrement, 1000);\n\t\t}", "title": "" }, { "docid": "c3da17ae708e5399683a80d0d1579ca1", "score": "0.7370064", "text": "function resetCounter(){\n counter = 0;\n}", "title": "" }, { "docid": "6a051b4949a3fc95bbfb0a71f46ae133", "score": "0.73685515", "text": "function decreaseCount() {\n\t\tsetCount((preCount) => preCount - 1);\n\t}", "title": "" }, { "docid": "2edf5bfae3728e9c6071ead69e25b733", "score": "0.7324305", "text": "function updateCounter() {}", "title": "" }, { "docid": "cf3389c5e1b8dd5768718e53c60b3566", "score": "0.7277267", "text": "function countdown() {\n\t\tintervalID = setInterval(decrement, 1000);\n\n\t}", "title": "" }, { "docid": "cd43880b29e51c9aade34837f9f12605", "score": "0.72174007", "text": "function countDown(){\n count=count-1;\n if (count < -1)\n {\n clearInterval(counter);\n //counter ended, do something here\n return;\n }\n \n console.log (`Count: ${count+1}`)\n // //Do code for showing the number of seconds here\n }", "title": "" }, { "docid": "e4b797e5b894077241676a273316657a", "score": "0.71546096", "text": "function run(){\n counter = setInterval(decrement, 1000);\n }", "title": "" }, { "docid": "ba89262bf7175c81d0251c914e73af69", "score": "0.71083194", "text": "function startCountDown() {\n $(\"#reset\").hide();\n countDown = 16;\n clearInterval(intervalId);\n intervalId = setInterval(decrement, 1000);\n }", "title": "" }, { "docid": "8d97a3b4d4c42277748ed4189369407f", "score": "0.70821834", "text": "function counter() {\n countDown--;\n $(\"#display-timer\").text(\"Time Left = \" + countDown + \" sec\");\n if (countDown <= 0) {\n clearInterval(timer);\n $(\"#questions\").empty();\n $(\"#questions\").append(\"Times up, no more questions.\"); \n resetCountDown();\n }\n\n }", "title": "" }, { "docid": "ffd39a2a6febcad813b9d6b563b600a0", "score": "0.70274913", "text": "function countDown () {\n timer--;\n $(\"#buttonRow\").html(\"<h2>Time Remaining: \" + timer + \" Seconds </h2>\");\n //console.log(timer);\n if (timer === 0) {\n stopCountDown();\n //console.log(\"DONE\");\n }\n }", "title": "" }, { "docid": "bd5d2eec5bf169031773a3c4b6fe8bea", "score": "0.6971501", "text": "function run() {\n counter = setInterval(decrement, 1000);\n }", "title": "" }, { "docid": "ce797af447d2964c56623b88518d4997", "score": "0.6967335", "text": "function decrement() {\n number--;\n $(\"#timer\").html(number);\n if (number === 0) {\n \t//see functions at the end\n checkAnswers();\n renderStats();\n }\n}", "title": "" }, { "docid": "88151ddb8b4271f40e8a88d339743f65", "score": "0.69518644", "text": "function timer() {\n\t\t\t\t\t\t \tcount -= 1;\n\t\t\t\t\t\t \tif (count < 0)\n\t\t\t\t\t\t \t{\n\t\t\t\t\t\t \tclearInterval(counter);\n\t\t\t\t\t\t \t//counter ended, do something here\n\n\t\t\t\t\t\t \treturn;\n\t\t\t\t\t\t \t}\n\t\t\t\t\t\t \tchrome.browserAction.setBadgeText({text: count.toString()});\n\t\t\t\t\t\t \tchrome.storage.local.set({timer: count});\n\t\t\t\t\t\t}", "title": "" }, { "docid": "a04c8657345f90c4b62fe002ffc257ca", "score": "0.6933818", "text": "function decrement() {\n count -= 10;\n}", "title": "" }, { "docid": "0178e948ace76a5711a85e6294ee7072", "score": "0.69236255", "text": "function countDown (num) {\n\tif (num <= 0) {\n\t\tconsole.log(\"All done!\");\n\t\treturn;\n\t}\n\tconsole.log(num);\n\tnum--;\n\tcountDown(num);\n}", "title": "" }, { "docid": "1618eeb799cc75cf4f8bcf96cd724f46", "score": "0.69117415", "text": "function countDown() {\n counter--;\n\n $(\"#time\").html(\"<h2> Time Left: \" + counter + \"</h2>\");\n\n if (counter === 0) {\n timeUp();\n }\n}", "title": "" }, { "docid": "23a43b19e9af81f3ee5773345e45ef7e", "score": "0.69035107", "text": "function countDown() {\n counter--;\n $('#time').html('Seconds Left: ' + counter);\n if (counter === 0) {\n timeOver()\n }\n}", "title": "" }, { "docid": "ce7ebc09406d3acaa79683f4592d8a18", "score": "0.69003963", "text": "function countDownCall (times, fn) {\n if (times < 1) times = 1\n\n return function countDownCalled () {\n if (fn == null) return\n if (times <= 0) return\n\n times--\n if (times !== 0) return\n\n const result = fn.apply(this, arguments)\n fn = null\n return result\n }\n}", "title": "" }, { "docid": "9b9c0853b79a8e365ba9a94dd0e8cedc", "score": "0.6886703", "text": "static resetCount() {\n count = 0;\n }", "title": "" }, { "docid": "feac255a6d02f28efeeddec1e70679a9", "score": "0.68806165", "text": "function decrement() {\n counter--;\n $(\"#show-number\").html(\"Time Remaining: \" + counter + \" Seconds\");\n if (counter <= 0) {\n score();\n }\n }", "title": "" }, { "docid": "3916bf3595a1c6ce9ba87070da5bb001", "score": "0.68687737", "text": "function counter() {\n //*************************/\n //**** YOUR CODE HERE *****/\n //*************************/\n}", "title": "" }, { "docid": "924f2c29add841cd2add43393fe7d4a4", "score": "0.68652976", "text": "function countown(){\n count--;\n $('#countdowntimer').html(count + \"seconds\");\n }", "title": "" }, { "docid": "613c351031b9973fa8540a05536f33ef", "score": "0.6851482", "text": "function countDown(i) {\n clearInterval(int)\n int = setInterval(function () {\n $(\"#timeRemaining\").html(\"Time Remaining: \" + i);\n i-- || clearInterval(int)\n\n\n }, 1000);\n }", "title": "" }, { "docid": "e072f94da56a3dab74a6f0034ca29ceb", "score": "0.68417835", "text": "function doCountDown() {\n console.log(countDown);\n if (countDown > 0) {\n countDownDiv.innerHTML = countDown.toString();\n setTimeout(doCountDown, 1000);\n }\n else {\n countDownDiv.innerHTML = \"\";\n resetVideo();\n }\n countDown--;\n }", "title": "" }, { "docid": "7ef7d3e004cf95c5b96d442bdc24ac67", "score": "0.6831472", "text": "function counter() {\n time--;\n $(\"#time\").text(time);\n if (time < 0) {\n incorrect();\n }\n }", "title": "" }, { "docid": "b908540db90e5bfd2006f16475a7f4ba", "score": "0.68297255", "text": "function countDown() {\n // decrease time by 1\n time--;\n // update the time displayed\n update($timer,time);\n // the game is over if the timer has reached 0\n if(time <= 0) {\n gameOver();\n }\n }", "title": "" }, { "docid": "7f8c163532d1aa50dfc38cfad814e6fd", "score": "0.6820518", "text": "function count() {\n\tif (mode == \"countdown\") {\n\t\tcountDown();\n\t} else if (mode == \"countup\") {\n\t\tcountUp();\n\t}\n}", "title": "" }, { "docid": "4cf79e50109882c69858437f1adb8a43", "score": "0.6808593", "text": "function countUp() {\n time = time + 1;\n timer.innerHTML = time;\n }", "title": "" }, { "docid": "fa7a387d65807366aaaa90f5207fb792", "score": "0.678585", "text": "function countDown() {\n // local variables\n \n // only count down time if game active\n if (activateGame == 1) {\n if (secDown >0) {\n secDown--;\n pTimer.html('secs: ' + secDown);\n } \n else {\n clearInterval(timer);\n pTimer.style('color', 'yellow');\n result(0);\n }\n }\n}", "title": "" }, { "docid": "88adaf891d35403253a2f50e9be7f6e7", "score": "0.67844194", "text": "function count_down(){\n var times = 20;\n function __(){\n times -= 1;\n if (times == 0){\n console.log(\"=====\\nthat's enough\\n===============\\n\");\n }\n }\n return __;\n}", "title": "" }, { "docid": "bf49168f688d629df2dd2c0e9ca56b6e", "score": "0.67732936", "text": "function countdown() {\n questionInterval = setInterval(decrement, 1000);\n }", "title": "" }, { "docid": "d8ce74632df66cf5a1f4e65ec5ca0f87", "score": "0.676208", "text": "function resetCounting() {\n count = 0;\n numberCount = 1;\n }", "title": "" }, { "docid": "d42576192a93f56eccac3686ebe79dc7", "score": "0.6761473", "text": "function startTimer(){\n\t\tcounter = setInterval(decrement, 1000);}", "title": "" }, { "docid": "a393cc6edbbdc553f938921f06d2f23b", "score": "0.6756112", "text": "function timer(){\n counter--;\n $('#counter').html(\"<h5>Time Remaining:\"+ counter);\n if(counter <= 0){\n console.log('times up');\n done();\n }\n }", "title": "" }, { "docid": "344f50491157feeae36f1cc6d190c4ab", "score": "0.6741786", "text": "function countdown(){\n\n\t\t// starting point down\n\t\tcount--;\n\n\t\t// showing the time left\n \t$('#timer_number').html(count + \" Seconds\");\n\n \n\t\t\t// when user finishes\n\t\t\t$(\"#done_button\").on(\"click\", function(){\n\n\t\t\t\n\t\t\tcount = 0; \n\t\t\treturn;\n\n\t\t\t});\n\n\t\t\t// When the game is up on its own\n\t\t\tif(count == -1){\n\n\t\t\t\t// calculating the user answers\n\t\t\t\ttimeUp();\n\n\t\t\t\t// Game over and user needs to refresh the page to restart\n\t\t\t\t$(\"#mid_game_container\").hide();\n\n\t\t\t}\n\n\n\t}", "title": "" }, { "docid": "449c24930f8a42c14dfeb52d3099b225", "score": "0.67410845", "text": "function decrementCounter() {\n\tseconds--;\n\tcreateHoleInterval--;\n}", "title": "" }, { "docid": "00c84a5053174a026099b0bf14322a7a", "score": "0.673966", "text": "function decrement(){\n count--;\n timer.html(\"<h2> Time Remaining:\"+\"\"+count+\"\"+\"seconds\"+\"</h2>\"); // update the content of timer with new count\n \n // when count equels to zero , the timer should stop and the trivia game's result show up on the page.\n if(count == 0){\n $(\"#main-section\").empty(); \n result();\n }\n }", "title": "" }, { "docid": "ace7cb3a2da46c4f44eb69b510e8c08b", "score": "0.6725544", "text": "function beginCountDown() {\r\n//set arguments for beginCountDown function (function, interval in milliseconds)\r\n//declare variable to reference function that will decrement time\r\n var timerInterval = setInterval(function() {\r\n//decrement countDown\r\n countDown--;\r\n//change text content to display count down decrement\r\n timeElement.textContent = \"Time remaining: \" + countDown;\r\n//check is count down has expired\r\n//if countDown has expired, clear and run score page\r\n if(countDown === 0) {\r\n \r\n clearInterval(timerInterval);\r\n }\r\n \r\n }, 1000);\r\n\r\n}", "title": "" }, { "docid": "88a4c64cda50bdd3a25e9daf71810daa", "score": "0.67095", "text": "function countdown(counter) {\n var count = counter;\n counter = setInterval(timer, 1000);\n\n function timer(){\n $(\".counter\").text(count);\n count=count-1;\n if (count < 0) {\n clearInterval(counter);\n location.reload();\n }\n\n };\n }", "title": "" }, { "docid": "548612ba721cb4a9119eefea19eb60ba", "score": "0.67091537", "text": "function startCount() {\n\t$(\"#counter\").html(game.counter);\n\tcounter = setInterval(countDown, 1000);\n}", "title": "" }, { "docid": "429de7e1cfa4686c2f129d76bd48cbc6", "score": "0.67042977", "text": "function decrement() {\n counter--;\n $(\"#timer-number\").html(\"Time Remaining: \" + counter);\n \n if (counter == 0) {\n checkAnswers();\n stop()\n endResults();\n }\n}", "title": "" }, { "docid": "ce02d7718fa69d32613c3793305a5708", "score": "0.66927314", "text": "function startCountDown(){\r\n interval=setInterval(countDown,1000);\r\n }", "title": "" }, { "docid": "4c7f48357727418224dcb6b1a692a7c7", "score": "0.6691545", "text": "function timer() {\n\t\t$(\"#countDown\").html(startCount);\n\t\tstartCount = startCount - 1;\n\t\tconsole.log(startCount);\n\t\tmyTimer = setTimeout(function(){ timer() }, 1000);\n\t\tif (startCount === -1) {\n\t\t\tconsole.log(\"we have reached \" + startCount);\n\t\t\tstopTimer();\n\t\t}\n\t}", "title": "" }, { "docid": "46a17363a559f306a03df28f4f178f4b", "score": "0.6686856", "text": "function count() {\n time--;\n $(\".seconds\").text(time);\n if (time === 0) {\n endExam();\n }\n }", "title": "" }, { "docid": "ebb4d62847be8787488ddb57b05e6490", "score": "0.66754997", "text": "function resetCounter(){\r\n\t\tstop();\r\n\t\tcounter = 0\r\n\t\tdocument.getElementById(\"message\").innerHTML = counter;\r\n\t\r\n\t}", "title": "" }, { "docid": "b023c212d6db92834980c7be333b824a", "score": "0.66541517", "text": "function answerCountdown() {\n // Decrease number by one.\n changeScore ()\n \n }", "title": "" }, { "docid": "626b4917f2054aa731d0020fdc6cba85", "score": "0.6648841", "text": "function CountDownStep(){\n\t\tsetTimeout(function(){\n\t\t\t\n\t\t\t//If we still have time on the clock keep counting down\n\t\t\tif(countDown > 0){\n\t\t\t\tsetTimeout(CountDownStep, 1000);\n\t\t\t\tcountDown -=1;\n\t\t\t}\n\t\t});\n\t\t\n\t\tif(countDown == 0){\n\t\t\tisControlEnabled = false;\n\t\t\t$('#countdown').text(\"0\");\n\t\t\t$('#countdown').addClass('hide');\n\t\t\t$('#countdown').removeClass('hide');\n\t\t\t\n\t\t\tif(chefScore == fatassScore)\n\t\t\t\t$('#result').text('Tie!');\n\t\t\telse if(chefScore > fatassScore)\n\t\t\t\t$('#result').text('Left Side Wins');\n\t\t\telse if(chefScore < fatassScore)\n\t\t\t\t$('#result').text('Right Side Wins');\n\t\t\t$('#result').removeClass('hide');\n\t\t\t//CountDownStep();\n\t\t}\n\t\telse\n\t\t\t$('#countdown').text(countDown);\n\t}", "title": "" }, { "docid": "0721a71db121187ac6601ad8a420310e", "score": "0.66418755", "text": "function timer() {\n intervalId = setInterval(decrement, 1000);\n\n }", "title": "" }, { "docid": "6c9a159b68912953af74b991423a9c30", "score": "0.6635704", "text": "function resetTaskCount() {\n $('#Tcounter').html(0);\n nC = 0;\n}", "title": "" }, { "docid": "2b000f7a3f0ba7141abcfa049f353af7", "score": "0.6630515", "text": "function count() {\n\tcounter += 1;\n}", "title": "" }, { "docid": "01b8e16e566befddcfcff12fbf774f12", "score": "0.66184413", "text": "decrement() {\n this.updateCounter('decrement');\n }", "title": "" }, { "docid": "487608df05aa3ce800ccb75336167df9", "score": "0.6618068", "text": "function countDown() {\n timer--;\n $('#time').text(timer);\n\n if (timer <= 0) {\n clearInterval(timerId);\n // work with timer to make sure quiz stops at 0\n if (timer === 0) {\n // just display score\n localStorage.setItem('recentScore', score);\n location.replace('highScore.html');\n }\n\n // check for high score\n }\n }", "title": "" }, { "docid": "73842c9cef44a4fb239fccb8b64e813a", "score": "0.6613323", "text": "function decrement() {\n timerCount--;\n $('#timer').html(\" \" + timerCount + \" \" + \"seconds\");\n if (timerCount === 1) {\n $('#timer').html(\" \" + timerCount + \" \" + \"second\");\n }\n else if (timerCount === 0) {\n stop();\n hide();\n displayResult();\n }\n }", "title": "" }, { "docid": "45d26d5b05dc64ade7432172df0ad572", "score": "0.6612888", "text": "function counterup(){\n\t\tif( $('.counter').length ){\n\t\t\t$('.counter').counterUp({\n\t\t\t\tdelay: 10,\n\t\t\t\ttime: 1000\n\t\t\t});\n\t\t}\n\t}", "title": "" }, { "docid": "113b94bfc3ad15496c12e114faaf8752", "score": "0.6604288", "text": "function decrement(){ \n \n if(number<0){\n //call timeout function\n timeoutProcess(); \n }else{ \n var temp = timeConverter(number); \n $(\".timer\").text(timeConverter(number));\n }\n number--;\n }", "title": "" }, { "docid": "6d0b854800f021dbf972134b31126261", "score": "0.6603788", "text": "function countDown() {\n if (num <= 0) {\n //base case\n console.log(\"All Done!\");\n return; //ends the function\n }\n console.log(num); //this section functions if the base case hasn't been hit.\n num--;\n countDown(num);\n}", "title": "" }, { "docid": "255dff73dab5c5172a6a8ec20dc0cb8e", "score": "0.65981776", "text": "reset() {\n console.debug('Reset count');\n this._value = 0;\n this.tick();\n }", "title": "" }, { "docid": "a8fc93d3dbb550f7255f58405e0f25b6", "score": "0.6586254", "text": "function decrement() {\n\n\t\tconvertedTime = convertTime(countDownTimer);\n\n\t\t$(\"#displayCountDown\").html(\"Time Remaining: \" + convertedTime);\n\n\t\tcountDownTimer--;\n\n\t\tif (countDownTimer === 0) {\n\t\t\tshowGameResults();\n\t\t}\n\t}", "title": "" }, { "docid": "89668567562a66b80ef6253cac2cb653", "score": "0.658363", "text": "function decrement() {\n clockRunning = true;\n // Decrease number by one.\n number --;\n if (number >= 0){\n $(\"#countdownTimer\").text(number);\n }\n // Once number hits zero...\n if (number === 0) {\n \n // ...run the stop function.\n stop();\n audio.pause();\n // Alert the user that time is up.\n $(\"#gameStatus\").text(\"Time's Up!\");\n displayResults();\n console.log(\"Time's Up!\")\n } \n }", "title": "" }, { "docid": "89e50cd5c6ae0edb7e3551396464953c", "score": "0.6573103", "text": "function countDown(num) {\n while (num >= 0) {\n console.log(num--);\n }\n }", "title": "" }, { "docid": "54381a1cb049670766b83e9663e3d1d2", "score": "0.6568915", "text": "function count() {\n $(\"#clock\").text(\"Time Left \" +time);\n time--;\n if (time === 0) {\n reset();\n };\n }", "title": "" }, { "docid": "4d9a25804e510a87e3312bffb6e2740f", "score": "0.656326", "text": "function handleCount(){\n setcount(count +1);\n \n }", "title": "" }, { "docid": "35f0a00b5cefb9d002279e95fd0ddfa3", "score": "0.65594715", "text": "function countDown() {\n $(\"#time-remaining\").html(\"<h2>Time Remaining: \" + timer + \" Seconds<h2>\");\n timer--;\n\n //timer stops at zero\n //-1 was chosen to display 0. If = to 0 timer displays one and ends game\n if (timer === -1) {\n stop();\n unanswered++;\n $(\"#answerBox\").html(\"<h2> Time's Up! The correct answer is: \" + selection.choices[selection.answer] + \"</h2>\");\n showPic();\n }\n }", "title": "" }, { "docid": "938972dae89796cd1c4ea56adeddb5a9", "score": "0.65466475", "text": "function subOne() {\n\n if(count > 0)\n {\n count --;\n document.getElementById(\"theCounter\").innerText = count;\n }\n\n else if(count <= 0)\n {\n \n alert(\"you've clicked less than 0 times!\");\n \n }\n\n}", "title": "" }, { "docid": "dcebfa7514c0671df00e5198fa96fc0e", "score": "0.6543675", "text": "function countDown() {\n if (time < 1) {\n clearInterval(clock);\n userTimeout();\n $('#timer').html('');\n $('#question-count').html('');\n };\n // if there is still time left, decrease time by one second\n if (time > 0) {\n time--;\n $('#timer').html('<p>' + time + ' seconds left</p>');\n }\n\n if (time === 1) {\n $('#timer').html('<p>' + time + ' second left</p>');\n }\n\n }", "title": "" }, { "docid": "9fb3eb2fd873a4efacb4e8e5db11c686", "score": "0.6536023", "text": "function reset(){\r\nrunning = 0;\r\ncount = 0;\r\n}", "title": "" }, { "docid": "73ca4836f3323b8db58bb4d9ea4d8805", "score": "0.65286887", "text": "function stopCounting() {\n clearInterval(counterId);\n}", "title": "" }, { "docid": "41dd6724b9c41589747939da7fa3ec47", "score": "0.6519511", "text": "function decrement() {\n if (data > 1) data -= 1;\n document.getElementById(\"counter-label\").innerText = data;\n}", "title": "" }, { "docid": "67f113a04ca7b08e8255c5cd0cd85d03", "score": "0.6519058", "text": "function run() {\n timerId = setInterval(decrement, 1000);\n }", "title": "" }, { "docid": "f73b4489dbe8ea628d4cfc4edbf9e9bf", "score": "0.65108114", "text": "function countDown(num){\n if(num <= 0){\n console.log(\"All done!\");\n return;\n }\n console.log(num);\n num--;\n countDown(num)\n}", "title": "" }, { "docid": "c2aa81f227715f9320d4a9b9464c33de", "score": "0.65079343", "text": "function countdown() {\n timer--;\n $(\"#timer\").html(\"Time Left: \" + timer);\n if (timer == 0) {\n unanswered++;\n imageNoAnswer();\n }\n }", "title": "" }, { "docid": "9c09883f8193f6e2a4a42f9e3e62df13", "score": "0.6499026", "text": "function timer() {\n if (count <= 0) {\n // clearInterval(counter);\n // return;\n }\n count--;\n document.getElementById(\"timer\").innerHTML = count / 100;\n}", "title": "" }, { "docid": "bb0973a15e36eaa8641a5d3700cbe7ec", "score": "0.6489433", "text": "function countDownTimer() {\n $(\"#timer\").text(timerCount);\n timerCount--;\n if (timerCount === 0) {\n clearInterval(timer);\n totalWrong++;\n incorrectSlide();\n\n }\n}", "title": "" }, { "docid": "c27a6a746555e42e8871c550b6cd18d9", "score": "0.6487678", "text": "function reset() {\n setCounter(initialValue);\n }", "title": "" }, { "docid": "630f22f5d02c5c673644d01919e0831f", "score": "0.64854765", "text": "function countDown() {\n if(dogName.energy > 1) {\n dogName.energy -= 1;\n setTimeout(function(){\n countDown();\n }, 5000);\n otputDogEnergy();\n }\n else {\n alert('Please feed the dog, it is starving');\n counterCanStart = true;\n }\n checkDogEnergy(dogName);\n }", "title": "" }, { "docid": "d0440cab2ca83b38126b132fbe27feae", "score": "0.6482666", "text": "decreaseCount() {\n if (this.state.count > 1) {\n this.setState(\n {\n count: this.state.count - 1\n },\n () => {\n this.onChange();\n }\n );\n }\n }", "title": "" }, { "docid": "7a245f200488dd2e1045b61bd46859b5", "score": "0.6480578", "text": "function countDown(num){\n if(num <= 0){\n console.log(\"all done!\");\n return; \n }\n console.log(num); \n num--;\n countDown(num); \n}", "title": "" }, { "docid": "c511039f62d9311a9578cb720659908d", "score": "0.647497", "text": "function countDown(){ //Counts down every second of the variable timeLeft\n timeLeft--;\n if(timeLeft > 0){\n setTimeout(countDown,1000);\n }\n console.log(timeLeft);\n $(\"#timeLeft\").text(timeLeft);\n }", "title": "" }, { "docid": "737f6541ec361bcb63a51825635b8fcb", "score": "0.6473877", "text": "function countDown() {\n $('#timer').each(function () {\n var count = parseInt($('#timer').html());\n if (count !== 0) {\n $('#timer').html(count - 1);\n }\n if (count == 0) {\n clearInterval(minusTime);\n endgame();\n }\n });\n if (!timerRunning) {\n minusTime = setInterval(countDown, 1000);\n timerRunning = true;\n }\n}", "title": "" }, { "docid": "fa47ebeefda8afe1346e03207f9316d4", "score": "0.64600945", "text": "function counter(count){return ++count;}", "title": "" }, { "docid": "6cd2ab7b9bea15206ba82e3ed297c905", "score": "0.6457841", "text": "function decrement () {\n\tnumber--; \n\t$(\"#timer\").html(\"<h3> Time Remaining: \" + number + \"</h3>\"); \n\tif (number === 0 ) {\n\t\ttimeOut ();\n\t}\n}", "title": "" }, { "docid": "d001b7e4bf818d5aa720d9d7cd11b92b", "score": "0.6445615", "text": "function makeCounter(init) {\n // YOUR CODE HERE\n var counter = init;\n return {\n up: function() {\n return counter = counter + 1;\n },\n down: function() {\n return counter = counter - 1;\n },\n reset:function() {\n return counter = init;\n }\n }\n\n}", "title": "" }, { "docid": "dfdb072ca250dcdfb9f2976b5518208a", "score": "0.6444087", "text": "function countDown(main,opt) {\n\t\t\t\topt.count=0;\n\t\t\t\t\n\t\t\t\tsetInterval(function() {\n\t\t\t\t\t\t\tif ((opt.animateon==false && opt.mouseover==false) || (opt.animateon==false && opt.thumbclicked==true)) {\n\t\t\t\t\t\t\t\topt.thumbclicked=false;\n\t\t\t\t\t\t\t\topt.count++;\n\t\t\t\t\t\t\t\tif (opt.count >= opt.delay/100 + opt.doffset/100) {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\topt.speed = opt.speedGood;\n\t\t\t\t\t\t\t\t\trotateSlides(main,opt);\n\t\t\t\t\t\t\t\t\topt.count=0;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t},100);\n\t\t\t}", "title": "" }, { "docid": "c184c40ec7895f40acba24d132bc0e06", "score": "0.64433736", "text": "function run () {\n \t\ttimer = setInterval(decrement, 1000);\n\t\t}", "title": "" }, { "docid": "91b8b1bd7b2a93c7b2296c7125035f5b", "score": "0.6435963", "text": "function CountDown(){\r\n\t\t \r\n\t\t //Broadcast the updated Game State\r\n\t\t pacManiaCountDown = Math.floor(pacManiaCountDown - 1);\r\n\t\t\t \r\n\t\t //Stop the Count Down\r\n\t\t if(pacManiaCountDown <= 0){\r\n\t\t\t clearInterval(countDownInterval);\r\n\t\t\t countDownInterval = null;\r\n\t\t\t pacManiaCountDown = 1;\r\n\t\t\t console.log(\"Started the Game State @ \"+(new Date().toLocaleTimeString()));\r\n\t\t\t //gameRender = setInterval( UpdateGameState, 35);\r\n\t\t\t gameRender = setInterval( UpdateGameState, 20);\r\n\t\t\t stepCounter=0;\r\n\t\t\t \r\n\t\t\t //If there's only one player change the Game type to endless\r\n\t\t\t if(pacArray.length==1)\r\n\t\t\t\t pacManiaGameSetting[0].typeofGame = \"Endless\";\r\n\t\t\t \r\n\t\t\t //Add Pellets to the gameboard-----------------------------\r\n\t\t\t fillWithPacItems();\r\n\t\t\t //-------------------- Print out the Game Settings\r\n\t\t\t console.log(\"---------------------------------------------------------\");\r\n\t\t\t console.log(pacManiaGameSetting[0].typeofGame);\r\n\t\t\t console.log(pacManiaGameSetting[0].fruitsOccurance);\r\n\t\t\t console.log(pacManiaGameSetting[0].typeofFruits);\t\t\t \r\n\t\t\t PacMania.emit('Setup Board', data={ Maze : 1});\t\r\n\t\t }\r\n\t\t \r\n\t }", "title": "" }, { "docid": "4583698c021c34612953ff251d0dd633", "score": "0.64349604", "text": "function startCountdown() {\n clearInterval(intervalId);\n // Set the interval to decrease the timer by one second\n intervalId = setInterval(decrement, 1000);\n}", "title": "" }, { "docid": "f51a3d420c0d4aca4588bd5a50a9778b", "score": "0.64329445", "text": "function countDown(num){\n if(num<0) return;\n console.log(num);\n num--;\n countDown(num);\n}", "title": "" }, { "docid": "496c36221df1cc5cb2149a06bd3b866b", "score": "0.64298797", "text": "function countdown() {\n //decrement the counter by one\n counter--;\n //update the time remaining text with jquery\n $(\"#counter-text\").text(\"time remaing; \" + counter);\n //if counter gets to zero display times up\n if(counter = 0) {\n //alert to user that time is up\n alert(\"Time UP!\");\n \n //stop the timer\n clearInterval(timer);\n //invoke the checkAnswer function\n checkAnswers();\n } \n \n }", "title": "" }, { "docid": "60f37393932917ce017a7d46f388bcea", "score": "0.64274025", "text": "function count() {\n if (_halt) {\n _onHalt(_current);\n } else if (_step > 0 ? (_current < _terminal) : (_current > _terminal)) {\n _onProgress(_current);\n\n _current += _step;\n\n if (_delay) {\n setTimeout(count, 1000);\n }\n } else {\n _onDone(_current);\n }\n }", "title": "" }, { "docid": "7545688f26685a1a00ed594dfd807850", "score": "0.642474", "text": "function timer() {\n clearInterval(interval);\n interval = setInterval(decrement, 1000);\n}", "title": "" }, { "docid": "dd293b8b37aaf34080b697e7f94c2f21", "score": "0.6419653", "text": "resetIncrement() {\n this.uptimeSettings.mouseDown = false;\n this.uptimeSettings.iteration = 1;\n }", "title": "" }, { "docid": "3244d66f446963013bdaf5ef520bf2ac", "score": "0.64195365", "text": "clearCount() {\n this.count = 0;\n this.mode = PAUSE;\n }", "title": "" }, { "docid": "dc3bfbb15cf94432f89b918b3630a5b2", "score": "0.64187413", "text": "function doCountdown() {\n if (counter >= 0) {\n if (counter == 0) {\n jQuery(\"span.markdown-save\").html(saved);\n }\n counter--;\n setTimeout(doCountdown, 1000);\n }\n }", "title": "" }, { "docid": "d2d9ff08ca3933a676a8d29522646ff4", "score": "0.6412465", "text": "function countsCalls() {\n countsCalls.counter++;\n}", "title": "" }, { "docid": "7379048c60868d238d80151314ab84e2", "score": "0.64092475", "text": "function decrement() {\n $(\"#timer\").text(timer);\n timer--;\n if (timer < 0) {\n stopTimer();\n counterIncorrect++;\n //next questions;\n }\n\n }", "title": "" }, { "docid": "73e072e0e9fcba80cbeb260de94ce684", "score": "0.64044714", "text": "function increase() {\n setCount(count + 1); //setCount value will be changed and then displayed to count\n } //setCount avoids repeatation", "title": "" }, { "docid": "bfa539c12a06446a5e3bb74c0b0bd2a2", "score": "0.63908637", "text": "function countDown2() {//set our var. starting position\r\n var count = 10;\r\n for (var i = 1; i <= 10; i++) { // iteration... I understand now\r\n setTimeout(function () {\r\n document.getElementById(\"countDownTimer\").innerHTML = count;\r\n count--;\r\n }, 1000 * i);\r\n\r\n }//setting the seconds for our timer cut in and cut out\r\n setTimeout(function () {\r\n document.getElementById(\"countDownTimer\").innerHTML = \"Blast Off!!\";\r\n count--;\r\n }, 11000);\r\n\r\n}", "title": "" }, { "docid": "21381defe590e2062762bf17b21c6891", "score": "0.63854283", "text": "function decrement() {\n timer--;\n $('#timerDis').html(\"Time Remaining: \" + timer + \" seconds\");\n // Start of trivia; condition for out of time\n if (timer === 0) {\n stop();\n unansCount++;\n $('#answerDis').html(\"<p>Took too long... Should of picked \" + stor.cho[stor.cor] + \"</p>\");\n showGif();\n }\n }", "title": "" } ]
2be6cd8e09b8da91ae24cfa54da4e425
for hint = "string"
[ { "docid": "f9887b6ab7ddda945f2765fe02c678ad", "score": "0.0", "text": "toString() {\n return `{name: \"${this.name}\"}`;\n }", "title": "" } ]
[ { "docid": "fa05ccba9d93289f88bf73430caae151", "score": "0.584257", "text": "function JediHint() {}", "title": "" }, { "docid": "0cd190952eb0c77cd6bf04df5baed204", "score": "0.56846744", "text": "function hint() {\n\t// function for adding hints\n\tif (hintsNum <= 0) {\n\t\t// if all hints were used, return\n\t\treturn;\n\t}\n\tvar grl = getRandomLetter(); // get the hint letter from entry string by randomizing the specified letter to be used\n\tvar letter = grl[0];\n\tvar position = grl[1];\n\tvar index = findLetter(letter); // finding hint letter from the roster of letters\n\thintsNum--; // decrement by one\n\taddhint(letter, index, position); // show hint\n\t$(\"#hintsNum\")[0].innerHTML = hintsNum + \" hint(s) remaining\"; // change the innerHTML with the number of hints remaining\n}", "title": "" }, { "docid": "ba90a11271addcbd571ee460ecce749f", "score": "0.5651975", "text": "function one(str){\n // code here\n}", "title": "" }, { "docid": "653046984e225c2890083891dd130db2", "score": "0.562942", "text": "function hint(string,container,id){\n\tif(!string || !container) return;\n\tvar z = document.createElement('div');\n\tz.className = 'hint';\n\tif(id) z.id = id;\n\tvar y = document.createElement('span');\n\ty.className = 'up';\n\ty.innerHTML = '&uarr;';\n\tz.appendChild(y);\n\tvar x = document.createElement('p');\n\tx.innerHTML = string;\n\tz.appendChild(x);\n\tcontainer.appendChild(z);\n\t\n\tvar a = setTimeout(function(){\n\t\tvar b = setTimeout(function(){ //Hide the pop-up after 3 seconds. (Using opacity first so that modern browsers can fade-out)\n\t\t\tz.style.opacity = \"0\";\n\t\t\tvar c = setTimeout(function(){\n\t\t\t\tz.parentNode.removeChild(z);\n\t\t\t},500);\n\t\t},3000);\n\t},500);\n}", "title": "" }, { "docid": "9dd2075813719ea87dd69481f19a5b84", "score": "0.55259436", "text": "function giveHint() {\n let count = limitHintNumber();\n if (count <= Math.floor(0.6 * (word.length))) {\n let letters = $('letters').children;\n let hintOn = true;\n while(hintOn) {\n let rand = Math.floor(Math.random() * letters.length);\n if (!letters[rand].disabled) {\n letters[rand].value = word[rand];\n freezeLetter(letters[rand]);\n hintOn = false;\n }\n }\n } else {\n alert('Sorry, we can only give you hints up to 60% of the word. :(');\n }\n }", "title": "" }, { "docid": "5582638aeff184d6033bff49592f7c67", "score": "0.5521924", "text": "function type(str) {\n if(endFunc == true){\n instantSetup();\n return;\n }\n if(i < str.length){\n typing = typing+str.charAt(i);\n $('#textHere').text(typing+'_');\n }else{\n $('#textHere').text(typing);\n return false;\n }\n var ran = 0;\n setTimeout(function(){\n type(str);\n }, ran)\n i++;\n}", "title": "" }, { "docid": "2a3958d483766929032462143368ab71", "score": "0.5473269", "text": "for(var i = 0; i < argsForCommand.length; i++) {\n var test = entered.string.replace(/\\s*/, '');\n\n if (argsForCommand[i].startsWith(test)) {\n completions.push(argsForCommand[i] + ': ');\n }\n }", "title": "" }, { "docid": "2563d6c64de7083a84ce71f45954b13a", "score": "0.5422991", "text": "stringMatch(input) {\n throw 'abstract';\n }", "title": "" }, { "docid": "2b0ab8fec3de17f0c5a3b5f46f4af4c4", "score": "0.54196274", "text": "function spinWords(string){\n // Have fun :)\n }", "title": "" }, { "docid": "b9e28800f7b0c38736d708ca93d49aac", "score": "0.5394899", "text": "function myHint() {\n\t\tdocument.getElementById(\"hint\").innerHTML = \"Try typing 346, which is the distance in miles from SF to LA.\";\n\t}", "title": "" }, { "docid": "40c13801bfd6396d669921f0a3edc514", "score": "0.53863317", "text": "function abc (string) {\n\tfor (i=0; i < string.length; i++ ) {\n\t\tif (str.charAt(i) === \"?\") {\n\t\t\tconsole.log(\"h3\")\n\t\t}\n\t\tif ((typeof parseInt(string.charAt(i))) != \"string\") {\n\t\t\tconsole.log(\"h4 \" + i + \" \" + string.charAt(i));\n\t\t}\n\t\t// if (parseInt()){\n\t\t// \t\t}\n\t}\n}", "title": "" }, { "docid": "76607ce2af459376c473e60ad54a8629", "score": "0.5379229", "text": "allMatches(string, start) {\n throw 'abstract';\n }", "title": "" }, { "docid": "73613f5eb1e7353e6001b87195ecbd7a", "score": "0.5360438", "text": "function showHint(str) {\n if (str.length == 0) { \n document.getElementById(\"txtHint\").innerHTML = \"\";\n return;\n }\n const xhttp = new XMLHttpRequest();\n xhttp.onload = function() {\n document.getElementById(\"txtHint\").innerHTML =\n this.responseText;\n }\n xhttp.open(\"GET\", \"gethint.php?q=\"+str);\n xhttp.send(); \n }", "title": "" }, { "docid": "38e47d667813d3a02a1cd01fe7561797", "score": "0.53603756", "text": "function st(t){return\"string\"==typeof t}", "title": "" }, { "docid": "75f2a2f063ee929c26439e6d7ac80bef", "score": "0.535241", "text": "for(word_to_guess.length) {\n\t\n }", "title": "" }, { "docid": "e889b8ed4814472be1965e17f88bd509", "score": "0.5346384", "text": "function oneString() {\n return dummy`hello`;\n}", "title": "" }, { "docid": "c7d7b07edd0a34ef153d1234038718a4", "score": "0.53399044", "text": "function searchWord2(str) {\n \n}", "title": "" }, { "docid": "9e88eee3d02756177457ffaa753465e8", "score": "0.53086495", "text": "function solutionWithFor() {\n // Browse characters array...\n // ...\n}", "title": "" }, { "docid": "c9b5be6e0e91718a154cd968ff93c9f3", "score": "0.5307042", "text": "hintStrings(linkCount) {\n let hints = [\"\"];\n let offset = 0;\n while (((hints.length - offset) < linkCount) || (hints.length === 1)) {\n const hint = hints[offset++];\n for (const ch of this.linkHintCharacters) {\n hints.push(ch + hint);\n }\n }\n hints = hints.slice(offset, offset + linkCount);\n\n // Shuffle the hints so that they're scattered; hints starting with the same character and short\n // hints are spread evenly throughout the array.\n return hints.sort().map((str) => str.reverse());\n }", "title": "" }, { "docid": "a39053ca3b6bc5cfd2a1de643355124f", "score": "0.5295817", "text": "get hintLabel() { return this._hintLabel; }", "title": "" }, { "docid": "a39053ca3b6bc5cfd2a1de643355124f", "score": "0.5295817", "text": "get hintLabel() { return this._hintLabel; }", "title": "" }, { "docid": "a39053ca3b6bc5cfd2a1de643355124f", "score": "0.5295817", "text": "get hintLabel() { return this._hintLabel; }", "title": "" }, { "docid": "4dc06fc7cbb250e12b59ac1d9f0e340a", "score": "0.52141595", "text": "hint() {\n const cursor = cm.getCursor()\n const token = cm.getTokenAt(cursor, true)\n const keyword = token.string.substring(1 + keywordSubstring, token.string.length - 1)\n\n // filter our list\n const list = autocompleteOptions.filter(a => {\n return !keyword || a.text.toLowerCase().startsWith(keyword.toLowerCase())\n })\n const from = Object.assign({}, cursor)\n from.ch = token.start + 1 + keywordSubstring // keep quote\n\n const to = Object.assign({}, from)\n to.ch = token.end - 1 // keep quote\n\n list.sort((a, b) => {\n return a.text < b.text ? -1 : 1\n })\n const hints = {\n list,\n from,\n to,\n // completeSingle seems that is not working ?\n completeSingle: false,\n }\n\n CodeMirror.on(hints, 'select', (completion, element) => {\n // remove old tooltip\n removeTooltip()\n if (completion.desc) {\n tooltip = createTooltip()\n tooltip.innerHTML = completion.desc\n // li < ul < body - by default\n element.parentNode.parentNode.appendChild(tooltip)\n const box = element.getBoundingClientRect()\n const ulbox = element.parentNode.getBoundingClientRect()\n\n tooltip.style.left = ulbox.left + ulbox.width + 'px'\n tooltip.style.top = box.top + 'px'\n }\n })\n CodeMirror.on(hints, 'close', () => {\n removeTooltip()\n CodeMirror.off(hints, 'close')\n CodeMirror.off(hints, 'select')\n CodeMirror.on(hints, 'shown')\n })\n return hints\n }", "title": "" }, { "docid": "39149e72283a033ebfcdf7dc165213d2", "score": "0.5210004", "text": "function _stringPart() {\n expect(detectType('')).toBe('string')\n expect(detectType('123')).toBe('string')\n expect(detectType('hello')).toBe('string')\n}", "title": "" }, { "docid": "32e51b1cc88712237b62947911c7f9a0", "score": "0.5207674", "text": "function p(stringvar){\n\tif (!aString(stringvar))\n\t\treturn \"<i>not set</i>\";\n\t\n\treturn stringvar;\n}", "title": "" }, { "docid": "b2b06dee006ee266a368233da5d481b8", "score": "0.5191023", "text": "function two(str){\n // code here\n}", "title": "" }, { "docid": "a47344f026ab5ad70a2c50c08dfd8f13", "score": "0.5187112", "text": "[\"computed\" + \"String\"]() {}", "title": "" }, { "docid": "d570d4085cdd77d9754f2301d0c75005", "score": "0.5180595", "text": "function init() {\n //generate a random number and grab the word that corresponds to it in the word array\nwordHint.textContent = currentWord.split(\"\").map(letter => letter = \"__\").join(\" \");\n\n}", "title": "" }, { "docid": "6f1ada322116e889b1734411388c61a9", "score": "0.5168398", "text": "function three(str){\n // code here\n}", "title": "" }, { "docid": "6317789cfae189d24ebb4905ae7a7600", "score": "0.5150122", "text": "function displayHints(str) {\n\t\tif (window.event.which == 38 || window.event.which == 40 ||\n\t\t\twindow.event.which == 13) return false;\n\t\t// Access search hints box, then make it empty\n\t\t// So previous searches will be cleared\n\t\tvar hints = document.getElementById(\"search-hints\");\n\t\thints.innerHTML = null;\n\t\t// If search box value is empty, stop further execution of code\n\t\tif (str === \"\") return false;\n\t\t// \"str\" argument is the search box value\n\t\tvar pattern = new RegExp(str, \"i\");\n\t\t// Loop throught the \"locations\" array\n\t\tfor (var i = 0, len = locations.length; i < len; i++) {\n\t\t\tvar currentItem = locations[i].stringLocation;\n\t\t\t// Search for pattern\n\t\t\tvar match = currentItem.search(pattern);\n\t\t\t// If a match is found\n\t\t\tif (match !== -1) {\n\t\t\t\t// Create a \"p\" element\n\t\t\t\tvar p = document.createElement(\"p\");\n\t\t\t\t// Set \"p\" content equal to current item inside location array\n\t\t\t\tp.innerHTML = currentItem.substr(0, match);\n\t\t\t\t// Highlight the matched string\n\t\t\t\tp.innerHTML += \"<strong>\" +\n\t\t\t\t\tcurrentItem.substr(match, searchBox.value.length) +\n\t\t\t\t\t\"</strong>\";\n\t\t\t\t// Add the remaining string\n\t\t\t\tp.innerHTML += currentItem.substr(match + searchBox.value.length, currentItem.length);\n\t\t\t\t// Display the p element\n\t\t\t\thints.appendChild(p);\n\t\t\t}\n\t\t}\n\n\t\t// Get all displayed hints\n\t\tvar pHints = hints.querySelectorAll(\"p\");\n\t\t// If there's a hint displayed, set bgcolor of the first one to light green\n\t\tif (pHints.length !== 0) pHints[0].style.background = \"#efd\";\n\t\t// Listen for click event to all hints displayed\n\t\tfor (i = 0, len = pHints.length; i < len; i++) {\n\t\t\tpHints[i].addEventListener(\"click\", setInput);\n\t\t}\n\t}", "title": "" }, { "docid": "216827d2293ea0e9c4b56d4dc345176f", "score": "0.51382774", "text": "function checkIt(string) {\r\n place = detect.indexOf(string) + 1;\r\n thestring = string;\r\n return place;\r\n}", "title": "" }, { "docid": "a53cce9f342702f3401d7921569bf738", "score": "0.5133323", "text": "function pointless(...chars) {\n return \"Rick Astley\";\n}", "title": "" }, { "docid": "9229317192845811295f8f4ffe9f6e04", "score": "0.5130997", "text": "suggest(...params) {\n return this._suggest(...params)\n }", "title": "" }, { "docid": "a6cda5a233865b52913ebb0ce44e7922", "score": "0.5128524", "text": "function stringClass (){}", "title": "" }, { "docid": "6ef7d26fdab2ea8834039a4c7076ff7f", "score": "0.5117964", "text": "function lettersWithStrings(array, char){\n // Your code here\n}", "title": "" }, { "docid": "8420fdb25dbd4686ad960788991b7cfe", "score": "0.51172477", "text": "function fixTypo(stringArray) {\n\t\"use strict\";\n\n\t// List of typos\n\tvar typo = [\n\t\t// Sharp\n\t\t[\"sharp\",\"sharps\",\"harp\",\"sarp\",\"shrp\",\"shap\",\"shar\",\"ssharp\",\"shharp\",\"shaarp\",\"sharrp\",\"sharpp\",\"hsarp\",\"sahrp\",\"shrap\",\"shapr\",\"aharp\",\"wharp\",\"eharp\",\"dharp\",\"xharp\",\"zharp\",\"sgarp\",\"syarp\",\"suarp\",\"sjarp\",\"snarp\",\"sbarp\",\"shqrp\",\"shwrp\",\"shsrp\",\"shxrp\",\"shzrp\",\"shaep\",\"sha4p\",\"sha5p\",\"shatp\",\"shagp\",\"shafp\",\"shadp\",\"sharo\",\"shar0\",\"sharl\",\"asharp\",\"saharp\",\"wsharp\",\"swharp\",\"esharp\",\"seharp\",\"dsharp\",\"sdharp\",\"xsharp\",\"sxharp\",\"zsharp\",\"szharp\",\"sgharp\",\"shgarp\",\"syharp\",\"shyarp\",\"suharp\",\"shuarp\",\"sjharp\",\"shjarp\",\"snharp\",\"shnarp\",\"sbharp\",\"shbarp\",\"shqarp\",\"shaqrp\",\"shwarp\",\"shawrp\",\"shsarp\",\"shasrp\",\"shxarp\",\"shaxrp\",\"shzarp\",\"shazrp\",\"shaerp\",\"sharep\",\"sha4rp\",\"shar4p\",\"sha5rp\",\"shar5p\",\"shatrp\",\"shartp\",\"shagrp\",\"shargp\",\"shafrp\",\"sharfp\",\"shadrp\",\"shardp\",\"sharop\",\"sharpo\",\"shar0p\",\"sharp0\",\"sharlp\",\"sharpl\",\"sharb\",\"sharos\"],\n\t\t// Flat\n\t\t[\"flat\",\"flats\",\"lat\",\"fat\",\"flt\",\"fla\",\"fflat\",\"fllat\",\"flaat\",\"flatt\",\"lfat\",\"falt\",\"flta\",\"dlat\",\"rlat\",\"tlat\",\"glat\",\"vlat\",\"clat\",\"fkat\",\"foat\",\"fpat\",\"flqt\",\"flwt\",\"flst\",\"flxt\",\"flzt\",\"flar\",\"fla5\",\"fla6\",\"flay\",\"flah\",\"flag\",\"flaf\",\"dflat\",\"fdlat\",\"rflat\",\"frlat\",\"tflat\",\"ftlat\",\"gflat\",\"fglat\",\"vflat\",\"fvlat\",\"cflat\",\"fclat\",\"fklat\",\"flkat\",\"folat\",\"float\",\"fplat\",\"flpat\",\"flqat\",\"flaqt\",\"flwat\",\"flawt\",\"flsat\",\"flast\",\"flxat\",\"flaxt\",\"flzat\",\"flazt\",\"flart\",\"flatr\",\"fla5t\",\"flat5\",\"fla6t\",\"flat6\",\"flayt\",\"flaty\",\"flaht\",\"flath\",\"flagt\",\"flatg\",\"flaft\",\"flatf\",\"flab\"],\n\n\t\t// Scale\n\t\t[\"scale\",\"scales\",\"cale\",\"sale\",\"scle\",\"scae\",\"scal\",\"sscale\",\"sccale\",\"scaale\",\"scalle\",\"scalee\",\"csale\",\"sacle\",\"sclae\",\"scael\",\"acale\",\"wcale\",\"ecale\",\"dcale\",\"xcale\",\"zcale\",\"sxale\",\"sdale\",\"sfale\",\"svale\",\"scqle\",\"scwle\",\"scsle\",\"scxle\",\"sczle\",\"scake\",\"scaoe\",\"scape\",\"scalw\",\"scal3\",\"scal4\",\"scalr\",\"scalf\",\"scald\",\"scals\",\"ascale\",\"sacale\",\"wscale\",\"swcale\",\"escale\",\"secale\",\"dscale\",\"sdcale\",\"xscale\",\"sxcale\",\"zscale\",\"szcale\",\"sxcale\",\"scxale\",\"sdcale\",\"scdale\",\"sfcale\",\"scfale\",\"svcale\",\"scvale\",\"scqale\",\"scaqle\",\"scwale\",\"scawle\",\"scsale\",\"scasle\",\"scxale\",\"scaxle\",\"sczale\",\"scazle\",\"scakle\",\"scalke\",\"scaole\",\"scaloe\",\"scaple\",\"scalpe\",\"scalwe\",\"scalew\",\"scal3e\",\"scale3\",\"scal4e\",\"scale4\",\"scalre\",\"scaler\",\"scalfe\",\"scalef\",\"scalde\",\"scaled\",\"scalse\",\"scales\"],\n\t\t// Major\n\t\t[\"major\",\"maj\",\"majer\",\"majors\",\"ajor\",\"mjor\",\"maor\",\"majr\",\"majo\",\"mmajor\",\"maajor\",\"majjor\",\"majoor\",\"majorr\",\"amjor\",\"mjaor\",\"maojr\",\"majro\",\"najor\",\"jajor\",\"kajor\",\"mqjor\",\"mwjor\",\"msjor\",\"mxjor\",\"mzjor\",\"mahor\",\"mauor\",\"maior\",\"makor\",\"mamor\",\"manor\",\"majir\",\"maj9r\",\"maj0r\",\"majpr\",\"majlr\",\"majkr\",\"majoe\",\"majo4\",\"majo5\",\"majot\",\"majog\",\"majof\",\"majod\",\"nmajor\",\"mnajor\",\"jmajor\",\"mjajor\",\"kmajor\",\"mkajor\",\"mqajor\",\"maqjor\",\"mwajor\",\"mawjor\",\"msajor\",\"masjor\",\"mxajor\",\"maxjor\",\"mzajor\",\"mazjor\",\"mahjor\",\"majhor\",\"maujor\",\"majuor\",\"maijor\",\"majior\",\"makjor\",\"majkor\",\"mamjor\",\"majmor\",\"manjor\",\"majnor\",\"majior\",\"majoir\",\"maj9or\",\"majo9r\",\"maj0or\",\"majo0r\",\"majpor\",\"majopr\",\"majlor\",\"majolr\",\"majkor\",\"majokr\",\"majoer\",\"majore\",\"majo4r\",\"major4\",\"majo5r\",\"major5\",\"majotr\",\"majort\",\"majogr\",\"majorg\",\"majofr\",\"majorf\",\"majodr\",\"majord\"],\n\t\t// Minor\n\t\t[\"minor\",\"min\",\"miner\",\"minors\",\"inor\",\"mnor\",\"mior\",\"minr\",\"mino\",\"mminor\",\"miinor\",\"minnor\",\"minoor\",\"minorr\",\"imnor\",\"mnior\",\"mionr\",\"minro\",\"ninor\",\"jinor\",\"kinor\",\"munor\",\"m8nor\",\"m9nor\",\"monor\",\"mlnor\",\"mknor\",\"mjnor\",\"mibor\",\"mihor\",\"mijor\",\"mimor\",\"minir\",\"min9r\",\"min0r\",\"minpr\",\"minlr\",\"minkr\",\"minoe\",\"mino4\",\"mino5\",\"minot\",\"minog\",\"minof\",\"minod\",\"nminor\",\"mninor\",\"jminor\",\"mjinor\",\"kminor\",\"mkinor\",\"muinor\",\"miunor\",\"m8inor\",\"mi8nor\",\"m9inor\",\"mi9nor\",\"moinor\",\"mionor\",\"mlinor\",\"milnor\",\"mkinor\",\"miknor\",\"mjinor\",\"mijnor\",\"mibnor\",\"minbor\",\"mihnor\",\"minhor\",\"mijnor\",\"minjor\",\"mimnor\",\"minmor\",\"minior\",\"minoir\",\"min9or\",\"mino9r\",\"min0or\",\"mino0r\",\"minpor\",\"minopr\",\"minlor\",\"minolr\",\"minkor\",\"minokr\",\"minoer\",\"minore\",\"mino4r\",\"minor4\",\"mino5r\",\"minor5\",\"minotr\",\"minort\",\"minogr\",\"minorg\",\"minofr\",\"minorf\",\"minodr\",\"minord\"],\n\t\t// Mode\n\t\t[\"mode\",\"modes\",\"ode\",\"mde\",\"moe\",\"mod\",\"mmode\",\"moode\",\"modde\",\"modee\",\"omde\",\"mdoe\",\"moed\",\"node\",\"jode\",\"kode\",\"mide\",\"m9de\",\"m0de\",\"mpde\",\"mlde\",\"mkde\",\"mose\",\"moee\",\"more\",\"mofe\",\"moce\",\"moxe\",\"modw\",\"mod3\",\"mod4\",\"modr\",\"modf\",\"modd\",\"mods\",\"nmode\",\"mnode\",\"jmode\",\"mjode\",\"kmode\",\"mkode\",\"miode\",\"moide\",\"m9ode\",\"mo9de\",\"m0ode\",\"mo0de\",\"mpode\",\"mopde\",\"mlode\",\"molde\",\"mkode\",\"mokde\",\"mosde\",\"modse\",\"moede\",\"modee\",\"morde\",\"modre\",\"mofde\",\"modfe\",\"mocde\",\"modce\",\"moxde\",\"modxe\",\"modwe\",\"modew\",\"mod3e\",\"mode3\",\"mod4e\",\"mode4\",\"modre\",\"moder\",\"modfe\",\"modef\",\"modde\",\"moded\",\"modse\",\"modes\"],\n\t\t// Ionian\n\t\t[\"ionian\",\"ion\",\"onian\",\"inian\",\"ioian\",\"ionan\",\"ionin\",\"ionia\",\"iionian\",\"ioonian\",\"ionnian\",\"ioniian\",\"ioniaan\",\"ioniann\",\"oinian\",\"inoian\",\"ioinan\",\"ionain\",\"ionina\",\"uonian\",\"8onian\",\"9onian\",\"oonian\",\"lonian\",\"konian\",\"jonian\",\"iinian\",\"i9nian\",\"i0nian\",\"ipnian\",\"ilnian\",\"iknian\",\"iobian\",\"iohian\",\"iojian\",\"iomian\",\"ionuan\",\"ion8an\",\"ion9an\",\"ionoan\",\"ionlan\",\"ionkan\",\"ionjan\",\"ioniqn\",\"ioniwn\",\"ionisn\",\"ionixn\",\"ionizn\",\"ioniab\",\"ioniah\",\"ioniaj\",\"ioniam\",\"uionian\",\"iuonian\",\"8ionian\",\"i8onian\",\"9ionian\",\"i9onian\",\"oionian\",\"ioonian\",\"lionian\",\"ilonian\",\"kionian\",\"ikonian\",\"jionian\",\"ijonian\",\"iionian\",\"ioinian\",\"i9onian\",\"io9nian\",\"i0onian\",\"io0nian\",\"iponian\",\"iopnian\",\"ilonian\",\"iolnian\",\"ikonian\",\"ioknian\",\"iobnian\",\"ionbian\",\"iohnian\",\"ionhian\",\"iojnian\",\"ionjian\",\"iomnian\",\"ionmian\",\"ionuian\",\"ioniuan\",\"ion8ian\",\"ioni8an\",\"ion9ian\",\"ioni9an\",\"ionoian\",\"ionioan\",\"ionlian\",\"ionilan\",\"ionkian\",\"ionikan\",\"ionjian\",\"ionijan\",\"ioniqan\",\"ioniaqn\",\"ioniwan\",\"ioniawn\",\"ionisan\",\"ioniasn\",\"ionixan\",\"ioniaxn\",\"ionizan\",\"ioniazn\",\"ioniabn\",\"ionianb\",\"ioniahn\",\"ionianh\",\"ioniajn\",\"ionianj\",\"ioniamn\",\"ionianm\"],\n\t\t// Dorian\n\t\t[\"dorian\",\"dor\",\"orian\",\"drian\",\"doian\",\"doran\",\"dorin\",\"doria\",\"ddorian\",\"doorian\",\"dorrian\",\"doriian\",\"doriaan\",\"doriann\",\"odrian\",\"droian\",\"doiran\",\"dorain\",\"dorina\",\"sorian\",\"eorian\",\"rorian\",\"forian\",\"corian\",\"xorian\",\"dirian\",\"d9rian\",\"d0rian\",\"dprian\",\"dlrian\",\"dkrian\",\"doeian\",\"do4ian\",\"do5ian\",\"dotian\",\"dogian\",\"dofian\",\"dodian\",\"doruan\",\"dor8an\",\"dor9an\",\"doroan\",\"dorlan\",\"dorkan\",\"dorjan\",\"doriqn\",\"doriwn\",\"dorisn\",\"dorixn\",\"dorizn\",\"doriab\",\"doriah\",\"doriaj\",\"doriam\",\"sdorian\",\"dsorian\",\"edorian\",\"deorian\",\"rdorian\",\"drorian\",\"fdorian\",\"dforian\",\"cdorian\",\"dcorian\",\"xdorian\",\"dxorian\",\"diorian\",\"doirian\",\"d9orian\",\"do9rian\",\"d0orian\",\"do0rian\",\"dporian\",\"doprian\",\"dlorian\",\"dolrian\",\"dkorian\",\"dokrian\",\"doerian\",\"doreian\",\"do4rian\",\"dor4ian\",\"do5rian\",\"dor5ian\",\"dotrian\",\"dortian\",\"dogrian\",\"dorgian\",\"dofrian\",\"dorfian\",\"dodrian\",\"dordian\",\"doruian\",\"doriuan\",\"dor8ian\",\"dori8an\",\"dor9ian\",\"dori9an\",\"doroian\",\"dorioan\",\"dorlian\",\"dorilan\",\"dorkian\",\"dorikan\",\"dorjian\",\"dorijan\",\"doriqan\",\"doriaqn\",\"doriwan\",\"doriawn\",\"dorisan\",\"doriasn\",\"dorixan\",\"doriaxn\",\"dorizan\",\"doriazn\",\"doriabn\",\"dorianb\",\"doriahn\",\"dorianh\",\"doriajn\",\"dorianj\",\"doriamn\",\"dorianm\"],\n\t\t// Phrygian\n\t\t[\"phrygian\",\t\"phryg\",\"hrygian\",\"prygian\",\"phygian\",\"phrgian\",\"phryian\",\"phrygan\",\"phrygin\",\"phrygia\",\"pphrygian\",\"phhrygian\",\"phrrygian\",\"phryygian\",\"phryggian\",\"phrygiian\",\"phrygiaan\",\"phrygiann\",\"hprygian\",\"prhygian\",\"phyrgian\",\"phrgyian\",\"phryigan\",\"phrygain\",\"phrygina\",\"ohrygian\",\"0hrygian\",\"lhrygian\",\"pgrygian\",\"pyrygian\",\"purygian\",\"pjrygian\",\"pnrygian\",\"pbrygian\",\"pheygian\",\"ph4ygian\",\"ph5ygian\",\"phtygian\",\"phgygian\",\"phfygian\",\"phdygian\",\"phrtgian\",\"phr6gian\",\"phr7gian\",\"phrugian\",\"phrjgian\",\"phrhgian\",\"phrggian\",\"phryfian\",\"phrytian\",\"phryyian\",\"phryhian\",\"phrybian\",\"phryvian\",\"phryguan\",\"phryg8an\",\"phryg9an\",\"phrygoan\",\"phryglan\",\"phrygkan\",\"phrygjan\",\"phrygiqn\",\"phrygiwn\",\"phrygisn\",\"phrygixn\",\"phrygizn\",\"phrygiab\",\"phrygiah\",\"phrygiaj\",\"phrygiam\",\"ophrygian\",\"pohrygian\",\"0phrygian\",\"p0hrygian\",\"lphrygian\",\"plhrygian\",\"pghrygian\",\"phgrygian\",\"pyhrygian\",\"phyrygian\",\"puhrygian\",\"phurygian\",\"pjhrygian\",\"phjrygian\",\"pnhrygian\",\"phnrygian\",\"pbhrygian\",\"phbrygian\",\"pherygian\",\"phreygian\",\"ph4rygian\",\"phr4ygian\",\"ph5rygian\",\"phr5ygian\",\"phtrygian\",\"phrtygian\",\"phgrygian\",\"phrgygian\",\"phfrygian\",\"phrfygian\",\"phdrygian\",\"phrdygian\",\"phrtygian\",\"phrytgian\",\"phr6ygian\",\"phry6gian\",\"phr7ygian\",\"phry7gian\",\"phruygian\",\"phryugian\",\"phrjygian\",\"phryjgian\",\"phrhygian\",\"phryhgian\",\"phrgygian\",\"phryggian\",\"phryfgian\",\"phrygfian\",\"phrytgian\",\"phrygtian\",\"phryygian\",\"phrygyian\",\"phryhgian\",\"phryghian\",\"phrybgian\",\"phrygbian\",\"phryvgian\",\"phrygvian\",\"phryguian\",\"phrygiuan\",\"phryg8ian\",\"phrygi8an\",\"phryg9ian\",\"phrygi9an\",\"phrygoian\",\"phrygioan\",\"phryglian\",\"phrygilan\",\"phrygkian\",\"phrygikan\",\"phrygjian\",\"phrygijan\",\"phrygiqan\",\"phrygiaqn\",\"phrygiwan\",\"phrygiawn\",\"phrygisan\",\"phrygiasn\",\"phrygixan\",\"phrygiaxn\",\"phrygizan\",\"phrygiazn\",\"phrygiabn\",\"phrygianb\",\"phrygiahn\",\"phrygianh\",\"phrygiajn\",\"phrygianj\",\"phrygiamn\",\"phrygianm\"],\n\t\t// Lydian\n\t\t[\"lydian\",\"lyd\",\"ydian\",\"ldian\",\"lyian\",\"lydan\",\"lydin\",\"lydia\",\"llydian\",\"lyydian\",\"lyddian\",\"lydiian\",\"lydiaan\",\"lydiann\",\"yldian\",\"ldyian\",\"lyidan\",\"lydain\",\"lydina\",\"kydian\",\"oydian\",\"pydian\",\"ltdian\",\"l6dian\",\"l7dian\",\"ludian\",\"ljdian\",\"lhdian\",\"lgdian\",\"lysian\",\"lyeian\",\"lyrian\",\"lyfian\",\"lycian\",\"lyxian\",\"lyduan\",\"lyd8an\",\"lyd9an\",\"lydoan\",\"lydlan\",\"lydkan\",\"lydjan\",\"lydiqn\",\"lydiwn\",\"lydisn\",\"lydixn\",\"lydizn\",\"lydiab\",\"lydiah\",\"lydiaj\",\"lydiam\",\"klydian\",\"lkydian\",\"olydian\",\"loydian\",\"plydian\",\"lpydian\",\"ltydian\",\"lytdian\",\"l6ydian\",\"ly6dian\",\"l7ydian\",\"ly7dian\",\"luydian\",\"lyudian\",\"ljydian\",\"lyjdian\",\"lhydian\",\"lyhdian\",\"lgydian\",\"lygdian\",\"lysdian\",\"lydsian\",\"lyedian\",\"lydeian\",\"lyrdian\",\"lydrian\",\"lyfdian\",\"lydfian\",\"lycdian\",\"lydcian\",\"lyxdian\",\"lydxian\",\"lyduian\",\"lydiuan\",\"lyd8ian\",\"lydi8an\",\"lyd9ian\",\"lydi9an\",\"lydoian\",\"lydioan\",\"lydlian\",\"lydilan\",\"lydkian\",\"lydikan\",\"lydjian\",\"lydijan\",\"lydiqan\",\"lydiaqn\",\"lydiwan\",\"lydiawn\",\"lydisan\",\"lydiasn\",\"lydixan\",\"lydiaxn\",\"lydizan\",\"lydiazn\",\"lydiabn\",\"lydianb\",\"lydiahn\",\"lydianh\",\"lydiajn\",\"lydianj\",\"lydiamn\",\"lydianm\"],\n\t\t// Mixolydian\n\t\t[\"mixolydian\",\"mixo\",\"mixolyd\",\"ixolydian\",\"mxolydian\",\"miolydian\",\"mixlydian\",\"mixoydian\",\"mixoldian\",\"mixolyian\",\"mixolydan\",\"mixolydin\",\"mixolydia\",\"mmixolydian\",\"miixolydian\",\"mixxolydian\",\"mixoolydian\",\"mixollydian\",\"mixolyydian\",\"mixolyddian\",\"mixolydiian\",\"mixolydiaan\",\"mixolydiann\",\"imxolydian\",\"mxiolydian\",\"mioxlydian\",\"mixloydian\",\"mixoyldian\",\"mixoldyian\",\"mixolyidan\",\"mixolydain\",\"mixolydina\",\"nixolydian\",\"jixolydian\",\"kixolydian\",\"muxolydian\",\"m8xolydian\",\"m9xolydian\",\"moxolydian\",\"mlxolydian\",\"mkxolydian\",\"mjxolydian\",\"mizolydian\",\"misolydian\",\"midolydian\",\"micolydian\",\"mixilydian\",\"mix9lydian\",\"mix0lydian\",\"mixplydian\",\"mixllydian\",\"mixklydian\",\"mixokydian\",\"mixooydian\",\"mixopydian\",\"mixoltdian\",\"mixol6dian\",\"mixol7dian\",\"mixoludian\",\"mixoljdian\",\"mixolhdian\",\"mixolgdian\",\"mixolysian\",\"mixolyeian\",\"mixolyrian\",\"mixolyfian\",\"mixolycian\",\"mixolyxian\",\"mixolyduan\",\"mixolyd8an\",\"mixolyd9an\",\"mixolydoan\",\"mixolydlan\",\"mixolydkan\",\"mixolydjan\",\"mixolydiqn\",\"mixolydiwn\",\"mixolydisn\",\"mixolydixn\",\"mixolydizn\",\"mixolydiab\",\"mixolydiah\",\"mixolydiaj\",\"mixolydiam\",\"nmixolydian\",\"mnixolydian\",\"jmixolydian\",\"mjixolydian\",\"kmixolydian\",\"mkixolydian\",\"muixolydian\",\"miuxolydian\",\"m8ixolydian\",\"mi8xolydian\",\"m9ixolydian\",\"mi9xolydian\",\"moixolydian\",\"mioxolydian\",\"mlixolydian\",\"milxolydian\",\"mkixolydian\",\"mikxolydian\",\"mjixolydian\",\"mijxolydian\",\"mizxolydian\",\"mixzolydian\",\"misxolydian\",\"mixsolydian\",\"midxolydian\",\"mixdolydian\",\"micxolydian\",\"mixcolydian\",\"mixiolydian\",\"mixoilydian\",\"mix9olydian\",\"mixo9lydian\",\"mix0olydian\",\"mixo0lydian\",\"mixpolydian\",\"mixoplydian\",\"mixlolydian\",\"mixollydian\",\"mixkolydian\",\"mixoklydian\",\"mixoklydian\",\"mixolkydian\",\"mixoolydian\",\"mixoloydian\",\"mixoplydian\",\"mixolpydian\",\"mixoltydian\",\"mixolytdian\",\"mixol6ydian\",\"mixoly6dian\",\"mixol7ydian\",\"mixoly7dian\",\"mixoluydian\",\"mixolyudian\",\"mixoljydian\",\"mixolyjdian\",\"mixolhydian\",\"mixolyhdian\",\"mixolgydian\",\"mixolygdian\",\"mixolysdian\",\"mixolydsian\",\"mixolyedian\",\"mixolydeian\",\"mixolyrdian\",\"mixolydrian\",\"mixolyfdian\",\"mixolydfian\",\"mixolycdian\",\"mixolydcian\",\"mixolyxdian\",\"mixolydxian\",\"mixolyduian\",\"mixolydiuan\",\"mixolyd8ian\",\"mixolydi8an\",\"mixolyd9ian\",\"mixolydi9an\",\"mixolydoian\",\"mixolydioan\",\"mixolydlian\",\"mixolydilan\",\"mixolydkian\",\"mixolydikan\",\"mixolydjian\",\"mixolydijan\",\"mixolydiqan\",\"mixolydiaqn\",\"mixolydiwan\",\"mixolydiawn\",\"mixolydisan\",\"mixolydiasn\",\"mixolydixan\",\"mixolydiaxn\",\"mixolydizan\",\"mixolydiazn\",\"mixolydiabn\",\"mixolydianb\",\"mixolydiahn\",\"mixolydianh\",\"mixolydiajn\",\"mixolydianj\",\"mixolydiamn\",\"mixolydianm\"],\n\t\t// Aeolian\n\t\t[\"aeolian\",\"aeol\",\"eolian\",\"aolian\",\"aelian\",\"aeoian\",\"aeolan\",\"aeolin\",\"aeolia\",\"aaeolian\",\"aeeolian\",\"aeoolian\",\"aeollian\",\"aeoliian\",\"aeoliaan\",\"aeoliann\",\"eaolian\",\"aoelian\",\"aeloian\",\"aeoilan\",\"aeolain\",\"aeolina\",\"qeolian\",\"weolian\",\"seolian\",\"xeolian\",\"zeolian\",\"awolian\",\"a3olian\",\"a4olian\",\"arolian\",\"afolian\",\"adolian\",\"asolian\",\"aeilian\",\"ae9lian\",\"ae0lian\",\"aeplian\",\"aellian\",\"aeklian\",\"aeokian\",\"aeooian\",\"aeopian\",\"aeoluan\",\"aeol8an\",\"aeol9an\",\"aeoloan\",\"aeollan\",\"aeolkan\",\"aeoljan\",\"aeoliqn\",\"aeoliwn\",\"aeolisn\",\"aeolixn\",\"aeolizn\",\"aeoliab\",\"aeoliah\",\"aeoliaj\",\"aeoliam\",\"qaeolian\",\"aqeolian\",\"waeolian\",\"aweolian\",\"saeolian\",\"aseolian\",\"xaeolian\",\"axeolian\",\"zaeolian\",\"azeolian\",\"aweolian\",\"aewolian\",\"a3eolian\",\"ae3olian\",\"a4eolian\",\"ae4olian\",\"areolian\",\"aerolian\",\"afeolian\",\"aefolian\",\"adeolian\",\"aedolian\",\"aseolian\",\"aesolian\",\"aeiolian\",\"aeoilian\",\"ae9olian\",\"aeo9lian\",\"ae0olian\",\"aeo0lian\",\"aepolian\",\"aeoplian\",\"aelolian\",\"aeollian\",\"aekolian\",\"aeoklian\",\"aeoklian\",\"aeolkian\",\"aeoolian\",\"aeoloian\",\"aeoplian\",\"aeolpian\",\"aeoluian\",\"aeoliuan\",\"aeol8ian\",\"aeoli8an\",\"aeol9ian\",\"aeoli9an\",\"aeoloian\",\"aeolioan\",\"aeollian\",\"aeolilan\",\"aeolkian\",\"aeolikan\",\"aeoljian\",\"aeolijan\",\"aeoliqan\",\"aeoliaqn\",\"aeoliwan\",\"aeoliawn\",\"aeolisan\",\"aeoliasn\",\"aeolixan\",\"aeoliaxn\",\"aeolizan\",\"aeoliazn\",\"aeoliabn\",\"aeolianb\",\"aeoliahn\",\"aeolianh\",\"aeoliajn\",\"aeolianj\",\"aeoliamn\",\"aeolianm\"],\n\t\t// Locrian\n\t\t[\"locrian\",\"loc\",\"ocrian\",\"lcrian\",\"lorian\",\"locian\",\"locran\",\"locrin\",\"locria\",\"llocrian\",\"loocrian\",\"loccrian\",\"locrrian\",\"locriian\",\"locriaan\",\"locriann\",\"olcrian\",\"lcorian\",\"lorcian\",\"lociran\",\"locrain\",\"locrina\",\"kocrian\",\"oocrian\",\"pocrian\",\"licrian\",\"l9crian\",\"l0crian\",\"lpcrian\",\"llcrian\",\"lkcrian\",\"loxrian\",\"lodrian\",\"lofrian\",\"lovrian\",\"loceian\",\"loc4ian\",\"loc5ian\",\"loctian\",\"locgian\",\"locfian\",\"locdian\",\"locruan\",\"locr8an\",\"locr9an\",\"locroan\",\"locrlan\",\"locrkan\",\"locrjan\",\"locriqn\",\"locriwn\",\"locrisn\",\"locrixn\",\"locrizn\",\"locriab\",\"locriah\",\"locriaj\",\"locriam\",\"klocrian\",\"lkocrian\",\"olocrian\",\"loocrian\",\"plocrian\",\"lpocrian\",\"liocrian\",\"loicrian\",\"l9ocrian\",\"lo9crian\",\"l0ocrian\",\"lo0crian\",\"lpocrian\",\"lopcrian\",\"llocrian\",\"lolcrian\",\"lkocrian\",\"lokcrian\",\"loxcrian\",\"locxrian\",\"lodcrian\",\"locdrian\",\"lofcrian\",\"locfrian\",\"lovcrian\",\"locvrian\",\"locerian\",\"locreian\",\"loc4rian\",\"locr4ian\",\"loc5rian\",\"locr5ian\",\"loctrian\",\"locrtian\",\"locgrian\",\"locrgian\",\"locfrian\",\"locrfian\",\"locdrian\",\"locrdian\",\"locruian\",\"locriuan\",\"locr8ian\",\"locri8an\",\"locr9ian\",\"locri9an\",\"locroian\",\"locrioan\",\"locrlian\",\"locrilan\",\"locrkian\",\"locrikan\",\"locrjian\",\"locrijan\",\"locriqan\",\"locriaqn\",\"locriwan\",\"locriawn\",\"locrisan\",\"locriasn\",\"locrixan\",\"locriaxn\",\"locrizan\",\"locriazn\",\"locriabn\",\"locrianb\",\"locriahn\",\"locrianh\",\"locriajn\",\"locrianj\",\"locriamn\",\"locrianm\"],\n\t\t// Blues\n\t\t[\"blues\",\"lues\",\"bues\",\"bles\",\"blus\",\"blue\",\"bblues\",\"bllues\",\"bluues\",\"bluees\",\"bluess\",\"lbues\",\"bules\",\"bleus\",\"bluse\",\"vlues\",\"glues\",\"hlues\",\"nlues\",\"bkues\",\"boues\",\"bpues\",\"blyes\",\"bl7es\",\"bl8es\",\"blies\",\"blkes\",\"bljes\",\"blhes\",\"bluws\",\"blu3s\",\"blu4s\",\"blurs\",\"blufs\",\"bluds\",\"bluss\",\"bluea\",\"bluew\",\"bluee\",\"blued\",\"bluex\",\"bluez\",\"vblues\",\"bvlues\",\"gblues\",\"bglues\",\"hblues\",\"bhlues\",\"nblues\",\"bnlues\",\"bklues\",\"blkues\",\"bolues\",\"bloues\",\"bplues\",\"blpues\",\"blyues\",\"bluyes\",\"bl7ues\",\"blu7es\",\"bl8ues\",\"blu8es\",\"bliues\",\"bluies\",\"blkues\",\"blukes\",\"bljues\",\"blujes\",\"blhues\",\"bluhes\",\"bluwes\",\"bluews\",\"blu3es\",\"blue3s\",\"blu4es\",\"blue4s\",\"blures\",\"bluers\",\"blufes\",\"bluefs\",\"bludes\",\"blueds\",\"bluses\",\"bluess\",\"blueas\",\"bluesa\",\"bluews\",\"bluesw\",\"bluees\",\"bluese\",\"blueds\",\"bluesd\",\"bluexs\",\"bluesx\",\"bluezs\",\"bluesz\"],\n\t\t// Chromatic\n\t\t[\"chromatic\",\"hromatic\",\"cromatic\",\"chomatic\",\"chrmatic\",\"chroatic\",\"chromtic\",\"chromaic\",\"chromatc\",\"chromati\",\"cchromatic\",\"chhromatic\",\"chrromatic\",\"chroomatic\",\"chrommatic\",\"chromaatic\",\"chromattic\",\"chromatiic\",\"chromaticc\",\"hcromatic\",\"crhomatic\",\"chormatic\",\"chrmoatic\",\"chroamtic\",\"chromtaic\",\"chromaitc\",\"chromatci\",\"xhromatic\",\"dhromatic\",\"fhromatic\",\"vhromatic\",\"cgromatic\",\"cyromatic\",\"curomatic\",\"cjromatic\",\"cnromatic\",\"cbromatic\",\"cheomatic\",\"ch4omatic\",\"ch5omatic\",\"chtomatic\",\"chgomatic\",\"chfomatic\",\"chdomatic\",\"chrimatic\",\"chr9matic\",\"chr0matic\",\"chrpmatic\",\"chrlmatic\",\"chrkmatic\",\"chronatic\",\"chrojatic\",\"chrokatic\",\"chromqtic\",\"chromwtic\",\"chromstic\",\"chromxtic\",\"chromztic\",\"chromaric\",\"chroma5ic\",\"chroma6ic\",\"chromayic\",\"chromahic\",\"chromagic\",\"chromafic\",\"chromatuc\",\"chromat8c\",\"chromat9c\",\"chromatoc\",\"chromatlc\",\"chromatkc\",\"chromatjc\",\"chromatix\",\"chromatid\",\"chromatif\",\"chromativ\",\"xchromatic\",\"cxhromatic\",\"dchromatic\",\"cdhromatic\",\"fchromatic\",\"cfhromatic\",\"vchromatic\",\"cvhromatic\",\"cghromatic\",\"chgromatic\",\"cyhromatic\",\"chyromatic\",\"cuhromatic\",\"churomatic\",\"cjhromatic\",\"chjromatic\",\"cnhromatic\",\"chnromatic\",\"cbhromatic\",\"chbromatic\",\"cheromatic\",\"chreomatic\",\"ch4romatic\",\"chr4omatic\",\"ch5romatic\",\"chr5omatic\",\"chtromatic\",\"chrtomatic\",\"chgromatic\",\"chrgomatic\",\"chfromatic\",\"chrfomatic\",\"chdromatic\",\"chrdomatic\",\"chriomatic\",\"chroimatic\",\"chr9omatic\",\"chro9matic\",\"chr0omatic\",\"chro0matic\",\"chrpomatic\",\"chropmatic\",\"chrlomatic\",\"chrolmatic\",\"chrkomatic\",\"chrokmatic\",\"chronmatic\",\"chromnatic\",\"chrojmatic\",\"chromjatic\",\"chrokmatic\",\"chromkatic\",\"chromqatic\",\"chromaqtic\",\"chromwatic\",\"chromawtic\",\"chromsatic\",\"chromastic\",\"chromxatic\",\"chromaxtic\",\"chromzatic\",\"chromaztic\",\"chromartic\",\"chromatric\",\"chroma5tic\",\"chromat5ic\",\"chroma6tic\",\"chromat6ic\",\"chromaytic\",\"chromatyic\",\"chromahtic\",\"chromathic\",\"chromagtic\",\"chromatgic\",\"chromaftic\",\"chromatfic\",\"chromatuic\",\"chromatiuc\",\"chromat8ic\",\"chromati8c\",\"chromat9ic\",\"chromati9c\",\"chromatoic\",\"chromatioc\",\"chromatlic\",\"chromatilc\",\"chromatkic\",\"chromatikc\",\"chromatjic\",\"chromatijc\",\"chromatixc\",\"chromaticx\",\"chromatidc\",\"chromaticd\",\"chromatifc\",\"chromaticf\",\"chromativc\",\"chromaticv\"],\n\t\t// Pentatonic\n\t\t[\"pentatonic\",\"penta\",\"entatonic\",\"pntatonic\",\"petatonic\",\"penatonic\",\"penttonic\",\"pentaonic\",\"pentatnic\",\"pentatoic\",\"pentatonc\",\"pentatoni\",\"ppentatonic\",\"peentatonic\",\"penntatonic\",\"penttatonic\",\"pentaatonic\",\"pentattonic\",\"pentatoonic\",\"pentatonnic\",\"pentatoniic\",\"pentatonicc\",\"epntatonic\",\"pnetatonic\",\"petnatonic\",\"penattonic\",\"penttaonic\",\"pentaotnic\",\"pentatnoic\",\"pentatoinc\",\"pentatonci\",\"oentatonic\",\"0entatonic\",\"lentatonic\",\"pwntatonic\",\"p3ntatonic\",\"p4ntatonic\",\"prntatonic\",\"pfntatonic\",\"pdntatonic\",\"psntatonic\",\"pebtatonic\",\"pehtatonic\",\"pejtatonic\",\"pemtatonic\",\"penratonic\",\"pen5atonic\",\"pen6atonic\",\"penyatonic\",\"penhatonic\",\"pengatonic\",\"penfatonic\",\"pentqtonic\",\"pentwtonic\",\"pentstonic\",\"pentxtonic\",\"pentztonic\",\"pentaronic\",\"penta5onic\",\"penta6onic\",\"pentayonic\",\"pentahonic\",\"pentagonic\",\"pentafonic\",\"pentatinic\",\"pentat9nic\",\"pentat0nic\",\"pentatpnic\",\"pentatlnic\",\"pentatknic\",\"pentatobic\",\"pentatohic\",\"pentatojic\",\"pentatomic\",\"pentatonuc\",\"pentaton8c\",\"pentaton9c\",\"pentatonoc\",\"pentatonlc\",\"pentatonkc\",\"pentatonjc\",\"pentatonix\",\"pentatonid\",\"pentatonif\",\"pentatoniv\",\"opentatonic\",\"poentatonic\",\"0pentatonic\",\"p0entatonic\",\"lpentatonic\",\"plentatonic\",\"pwentatonic\",\"pewntatonic\",\"p3entatonic\",\"pe3ntatonic\",\"p4entatonic\",\"pe4ntatonic\",\"prentatonic\",\"perntatonic\",\"pfentatonic\",\"pefntatonic\",\"pdentatonic\",\"pedntatonic\",\"psentatonic\",\"pesntatonic\",\"pebntatonic\",\"penbtatonic\",\"pehntatonic\",\"penhtatonic\",\"pejntatonic\",\"penjtatonic\",\"pemntatonic\",\"penmtatonic\",\"penrtatonic\",\"pentratonic\",\"pen5tatonic\",\"pent5atonic\",\"pen6tatonic\",\"pent6atonic\",\"penytatonic\",\"pentyatonic\",\"penhtatonic\",\"penthatonic\",\"pengtatonic\",\"pentgatonic\",\"penftatonic\",\"pentfatonic\",\"pentqatonic\",\"pentaqtonic\",\"pentwatonic\",\"pentawtonic\",\"pentsatonic\",\"pentastonic\",\"pentxatonic\",\"pentaxtonic\",\"pentzatonic\",\"pentaztonic\",\"pentartonic\",\"pentatronic\",\"penta5tonic\",\"pentat5onic\",\"penta6tonic\",\"pentat6onic\",\"pentaytonic\",\"pentatyonic\",\"pentahtonic\",\"pentathonic\",\"pentagtonic\",\"pentatgonic\",\"pentaftonic\",\"pentatfonic\",\"pentationic\",\"pentatoinic\",\"pentat9onic\",\"pentato9nic\",\"pentat0onic\",\"pentato0nic\",\"pentatponic\",\"pentatopnic\",\"pentatlonic\",\"pentatolnic\",\"pentatkonic\",\"pentatoknic\",\"pentatobnic\",\"pentatonbic\",\"pentatohnic\",\"pentatonhic\",\"pentatojnic\",\"pentatonjic\",\"pentatomnic\",\"pentatonmic\",\"pentatonuic\",\"pentatoniuc\",\"pentaton8ic\",\"pentatoni8c\",\"pentaton9ic\",\"pentatoni9c\",\"pentatonoic\",\"pentatonioc\",\"pentatonlic\",\"pentatonilc\",\"pentatonkic\",\"pentatonikc\",\"pentatonjic\",\"pentatonijc\",\"pentatonixc\",\"pentatonicx\",\"pentatonidc\",\"pentatonicd\",\"pentatonifc\",\"pentatonicf\",\"pentatonivc\",\"pentatonicv\"],\n\t\t// Whole\n\t\t[\"whole\",\"hole\",\"wole\",\"whle\",\"whoe\",\"whol\",\"wwhole\",\"whhole\",\"whoole\",\"wholle\",\"wholee\",\"hwole\",\"wohle\",\"whloe\",\"whoel\",\"qhole\",\"2hole\",\"3hole\",\"ehole\",\"dhole\",\"shole\",\"ahole\",\"wgole\",\"wyole\",\"wuole\",\"wjole\",\"wnole\",\"wbole\",\"while\",\"wh9le\",\"wh0le\",\"whple\",\"whlle\",\"whkle\",\"whoke\",\"whooe\",\"whope\",\"wholw\",\"whol3\",\"whol4\",\"wholr\",\"wholf\",\"whold\",\"whols\",\"qwhole\",\"wqhole\",\"2whole\",\"w2hole\",\"3whole\",\"w3hole\",\"ewhole\",\"wehole\",\"dwhole\",\"wdhole\",\"swhole\",\"wshole\",\"awhole\",\"wahole\",\"wghole\",\"whgole\",\"wyhole\",\"whyole\",\"wuhole\",\"whuole\",\"wjhole\",\"whjole\",\"wnhole\",\"whnole\",\"wbhole\",\"whbole\",\"whiole\",\"whoile\",\"wh9ole\",\"who9le\",\"wh0ole\",\"who0le\",\"whpole\",\"whople\",\"whlole\",\"wholle\",\"whkole\",\"whokle\",\"whokle\",\"wholke\",\"whoole\",\"wholoe\",\"whople\",\"wholpe\",\"wholwe\",\"wholew\",\"whol3e\",\"whole3\",\"whol4e\",\"whole4\",\"wholre\",\"wholer\",\"wholfe\",\"wholef\",\"wholde\",\"wholed\",\"wholse\",\"wholes\"],\n\t\t// Signature\n\t\t[\"signature\",\"sig\",\"ignature\",\"sgnature\",\"sinature\",\"sigature\",\"signture\",\"signaure\",\"signatre\",\"signatue\",\"signatur\",\"ssignature\",\"siignature\",\"siggnature\",\"signnature\",\"signaature\",\"signatture\",\"signatuure\",\"signaturre\",\"signaturee\",\"isgnature\",\"sginature\",\"singature\",\"siganture\",\"signtaure\",\"signautre\",\"signatrue\",\"signatuer\",\"aignature\",\"wignature\",\"eignature\",\"dignature\",\"xignature\",\"zignature\",\"sugnature\",\"s8gnature\",\"s9gnature\",\"sognature\",\"slgnature\",\"skgnature\",\"sjgnature\",\"sifnature\",\"sitnature\",\"siynature\",\"sihnature\",\"sibnature\",\"sivnature\",\"sigbature\",\"sighature\",\"sigjature\",\"sigmature\",\"signqture\",\"signwture\",\"signsture\",\"signxture\",\"signzture\",\"signarure\",\"signa5ure\",\"signa6ure\",\"signayure\",\"signahure\",\"signagure\",\"signafure\",\"signatyre\",\"signat7re\",\"signat8re\",\"signatire\",\"signatkre\",\"signatjre\",\"signathre\",\"signatuee\",\"signatu4e\",\"signatu5e\",\"signatute\",\"signatuge\",\"signatufe\",\"signatude\",\"signaturw\",\"signatur3\",\"signatur4\",\"signaturr\",\"signaturf\",\"signaturd\",\"signaturs\",\"asignature\",\"saignature\",\"wsignature\",\"swignature\",\"esignature\",\"seignature\",\"dsignature\",\"sdignature\",\"xsignature\",\"sxignature\",\"zsignature\",\"szignature\",\"suignature\",\"siugnature\",\"s8ignature\",\"si8gnature\",\"s9ignature\",\"si9gnature\",\"soignature\",\"siognature\",\"slignature\",\"silgnature\",\"skignature\",\"sikgnature\",\"sjignature\",\"sijgnature\",\"sifgnature\",\"sigfnature\",\"sitgnature\",\"sigtnature\",\"siygnature\",\"sigynature\",\"sihgnature\",\"sighnature\",\"sibgnature\",\"sigbnature\",\"sivgnature\",\"sigvnature\",\"sigbnature\",\"signbature\",\"sighnature\",\"signhature\",\"sigjnature\",\"signjature\",\"sigmnature\",\"signmature\",\"signqature\",\"signaqture\",\"signwature\",\"signawture\",\"signsature\",\"signasture\",\"signxature\",\"signaxture\",\"signzature\",\"signazture\",\"signarture\",\"signatrure\",\"signa5ture\",\"signat5ure\",\"signa6ture\",\"signat6ure\",\"signayture\",\"signatyure\",\"signahture\",\"signathure\",\"signagture\",\"signatgure\",\"signafture\",\"signatfure\",\"signatyure\",\"signatuyre\",\"signat7ure\",\"signatu7re\",\"signat8ure\",\"signatu8re\",\"signatiure\",\"signatuire\",\"signatkure\",\"signatukre\",\"signatjure\",\"signatujre\",\"signathure\",\"signatuhre\",\"signatuere\",\"signaturee\",\"signatu4re\",\"signatur4e\",\"signatu5re\",\"signatur5e\",\"signatutre\",\"signaturte\",\"signatugre\",\"signaturge\",\"signatufre\",\"signaturfe\",\"signatudre\",\"signaturde\",\"signaturwe\",\"signaturew\",\"signatur3e\",\"signature3\",\"signatur4e\",\"signature4\",\"signaturre\",\"signaturer\",\"signaturfe\",\"signaturef\",\"signaturde\",\"signatured\",\"signaturse\",\"signatures\"],\n\t\t// Relative\n\t\t[\"relative\",\"rel\",\"elative\",\"rlative\",\"reative\",\"reltive\",\"relaive\",\"relatve\",\"relatie\",\"relativ\",\"rrelative\",\"reelative\",\"rellative\",\"relaative\",\"relattive\",\"relatiive\",\"relativve\",\"relativee\",\"erlative\",\"rleative\",\"realtive\",\"reltaive\",\"relaitve\",\"relatvie\",\"relatiev\",\"eelative\",\"4elative\",\"5elative\",\"telative\",\"gelative\",\"felative\",\"delative\",\"rwlative\",\"r3lative\",\"r4lative\",\"rrlative\",\"rflative\",\"rdlative\",\"rslative\",\"rekative\",\"reoative\",\"repative\",\"relqtive\",\"relwtive\",\"relstive\",\"relxtive\",\"relztive\",\"relarive\",\"rela5ive\",\"rela6ive\",\"relayive\",\"relahive\",\"relagive\",\"relafive\",\"relatuve\",\"relat8ve\",\"relat9ve\",\"relatove\",\"relatlve\",\"relatkve\",\"relatjve\",\"relatice\",\"relatife\",\"relatige\",\"relatibe\",\"relativw\",\"relativ3\",\"relativ4\",\"relativr\",\"relativf\",\"relativd\",\"relativs\",\"erelative\",\"reelative\",\"4relative\",\"r4elative\",\"5relative\",\"r5elative\",\"trelative\",\"rtelative\",\"grelative\",\"rgelative\",\"frelative\",\"rfelative\",\"drelative\",\"rdelative\",\"rwelative\",\"rewlative\",\"r3elative\",\"re3lative\",\"r4elative\",\"re4lative\",\"rrelative\",\"rerlative\",\"rfelative\",\"reflative\",\"rdelative\",\"redlative\",\"rselative\",\"reslative\",\"reklative\",\"relkative\",\"reolative\",\"reloative\",\"replative\",\"relpative\",\"relqative\",\"relaqtive\",\"relwative\",\"relawtive\",\"relsative\",\"relastive\",\"relxative\",\"relaxtive\",\"relzative\",\"relaztive\",\"relartive\",\"relatrive\",\"rela5tive\",\"relat5ive\",\"rela6tive\",\"relat6ive\",\"relaytive\",\"relatyive\",\"relahtive\",\"relathive\",\"relagtive\",\"relatgive\",\"relaftive\",\"relatfive\",\"relatuive\",\"relatiuve\",\"relat8ive\",\"relati8ve\",\"relat9ive\",\"relati9ve\",\"relatoive\",\"relatiove\",\"relatlive\",\"relatilve\",\"relatkive\",\"relatikve\",\"relatjive\",\"relatijve\",\"relaticve\",\"relativce\",\"relatifve\",\"relativfe\",\"relatigve\",\"relativge\",\"relatibve\",\"relativbe\",\"relativwe\",\"relativew\",\"relativ3e\",\"relative3\",\"relativ4e\",\"relative4\",\"relativre\",\"relativer\",\"relativfe\",\"relativef\",\"relativde\",\"relatived\",\"relativse\",\"relatives\"],\n\t\t// Random\n\t\t[\"random\",\"randome\",\t\"andom\",\"rndom\",\"radom\",\"ranom\",\"randm\",\"rando\",\"rrandom\",\"raandom\",\"ranndom\",\"randdom\",\"randoom\",\"randomm\",\"arndom\",\"rnadom\",\"radnom\",\"ranodm\",\"randmo\",\"eandom\",\"4andom\",\"5andom\",\"tandom\",\"gandom\",\"fandom\",\"dandom\",\"rqndom\",\"rwndom\",\"rsndom\",\"rxndom\",\"rzndom\",\"rabdom\",\"rahdom\",\"rajdom\",\"ramdom\",\"ransom\",\"raneom\",\"ranrom\",\"ranfom\",\"rancom\",\"ranxom\",\"randim\",\"rand9m\",\"rand0m\",\"randpm\",\"randlm\",\"randkm\",\"randon\",\"randoj\",\"randok\",\"erandom\",\"reandom\",\"4random\",\"r4andom\",\"5random\",\"r5andom\",\"trandom\",\"rtandom\",\"grandom\",\"rgandom\",\"frandom\",\"rfandom\",\"drandom\",\"rdandom\",\"rqandom\",\"raqndom\",\"rwandom\",\"rawndom\",\"rsandom\",\"rasndom\",\"rxandom\",\"raxndom\",\"rzandom\",\"razndom\",\"rabndom\",\"ranbdom\",\"rahndom\",\"ranhdom\",\"rajndom\",\"ranjdom\",\"ramndom\",\"ranmdom\",\"ransdom\",\"randsom\",\"ranedom\",\"randeom\",\"ranrdom\",\"randrom\",\"ranfdom\",\"randfom\",\"rancdom\",\"randcom\",\"ranxdom\",\"randxom\",\"randiom\",\"randoim\",\"rand9om\",\"rando9m\",\"rand0om\",\"rando0m\",\"randpom\",\"randopm\",\"randlom\",\"randolm\",\"randkom\",\"randokm\",\"randonm\",\"randomn\",\"randojm\",\"randomj\",\"randokm\",\"randomk\"],\n\t\t// ScaleBook\n\t\t[\"ScaleBook\",\"scalebook\"],\n\t\t// Leland\n\t\t[\"Leland\",\"leland\"],\n\t\t// Jansen\n\t\t[\"Jansen\",\"jansen\"]\n\t];\n\n\t// Loop through each element of stringArray\n\tfor (i = 0; i < stringArray.length; i++) {\n\t\t// Loop through each group of typos\n\t\tfor (j = 0; j < typo.length; j++) {\n\t\t\t// Loop throuh each typo in the group starting with second element\n\t\t\tfor (k = 1; k < typo[j].length; k++) {\n\t\t\t\t// If the stringArray element matches the typo\n\t\t\t\tif (stringArray[i] === typo[j][k]) {\n\t\t\t\t\t// Replace the typo with the first element (the correction)\n\t\t\t\t\tstringArray[i] = typo[j][0];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn stringArray;\n\n} // End of fixTypo", "title": "" }, { "docid": "bd36bc583aa6b6809912f66e71130ad6", "score": "0.50983286", "text": "_setLatencyHint(hint) {\n let lookAheadValue = 0;\n this._latencyHint = hint;\n if (Object(_util_TypeCheck__WEBPACK_IMPORTED_MODULE_5__[\"isString\"])(hint)) {\n switch (hint) {\n case \"interactive\":\n lookAheadValue = 0.1;\n break;\n case \"playback\":\n lookAheadValue = 0.5;\n break;\n case \"balanced\":\n lookAheadValue = 0.25;\n break;\n }\n }\n this.lookAhead = lookAheadValue;\n this.updateInterval = lookAheadValue / 2;\n }", "title": "" }, { "docid": "ead195a371742b89fc768dfc37c0ccde", "score": "0.50946903", "text": "function misspelled(correct, incorrect) {\n \n}", "title": "" }, { "docid": "93820f489ce79c7cc7f9379b54cd0d36", "score": "0.50891554", "text": "function checkHints() {\r\n\tfor (var HINT = 4; HINT <= HNTMAX; HINT++) {\r\n\t\tif (!HINTED[HINT]) {\r\n\t\t\tif (!BITSET(LOC, HINT)) HINTLC[HINT] = -1;\r\n\t\t\tHINTLC[HINT]++;\r\n\t\t\tif (HINTLC[HINT] >= HINTS[HINT][1]) offerHint();\r\n\t\t}\r\n\t}\r\n}", "title": "" }, { "docid": "88e637049edcab69610264f6f32f994a", "score": "0.5086764", "text": "function checkIt(string)\r\n{\r\n place = detect.indexOf(string) + 1;\r\n thestring = string;\r\n return place;\r\n}", "title": "" }, { "docid": "4739a7bb8eaaf600ff442ce3e828eb5f", "score": "0.50830626", "text": "function xStr(s) {\r\n\tfor (var i = 0; i < arguments.length; ++i) {\r\n\t\tif (typeof (arguments[i]) != \"string\") {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}", "title": "" }, { "docid": "a405244aeb4cc0210a554e6f89ee7c20", "score": "0.50770146", "text": "function startAutoComplete() {\n begin(this.value.toLowerCase());\n}", "title": "" }, { "docid": "394ad218d6114f7742bfe7981e0a0eb0", "score": "0.50756514", "text": "function crosswordPuzzle(crossword, hints) {\n \n}", "title": "" }, { "docid": "abd5f71547aa867ed61375bc064b1cf2", "score": "0.5066971", "text": "function hint(wordSelection) {\n for (x in wordList) {\n\n var findWord = wordList[x].movie\n if (wordSelection == findWord) {\n document.getElementById(\"hints\").innerHTML = \"Character: \" + wordList[x].character + \"&emsp; Costar: \" + wordList[x].coStar\n }\n var findWord = wordList[x].character\n if (wordSelection == findWord) {\n document.getElementById(\"hints\").innerHTML = \"Movie: \" + wordList[x].movie + \"&emsp; Costar: \" + wordList[x].coStar\n }\n var findWord = wordList[x].coStar\n if (wordSelection == findWord) {\n document.getElementById(\"hints\").innerHTML = \"Movie: \" + wordList[x].movie + \"&emsp; Character: \" + wordList[x].character\n }\n\n }\n}", "title": "" }, { "docid": "7fc288a257c33511cff341e1c82534e5", "score": "0.5066569", "text": "function questionMark(str) {\n var q = 0;\n str = str.split(\"\");\n for (let i = 0; i < str.length; i++) {\n if (str[i] === \"?\") {\n q++;\n }\n }\n if (q === 0) {\n return \"tidak ada tanda tanya\";\n } else {\n return q;\n }\n // console.log(\"ini dibawah return\");\n}", "title": "" }, { "docid": "faacc4400d5c39055c21f266b214aff4", "score": "0.50647086", "text": "function catchFakeWord(string)\n{\n\tif(! document.getElementById(\"result\").value)\n\t{\n\t\tdocument.getElementById(\"result\").value += (\"Our dictionary has identified a nonsense word! Here are its nonsense anagrams: \" + \"\\n\")\n\t\tpermute(string.split(\"\"))\n\t\tfor(j=0;j<permArr.length;j++)\n\t\t{\n\t\t\tdocument.getElementById(\"result\").value += (permArr[j].join(\"\") + \"\\n\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "84edea624c432e45397922c8b49f3374", "score": "0.5060467", "text": "constructor(string){\n this.fullString = string;\n this.output = \"\";\n this.stringPointer = 0;\n this.counter = 0;\n }", "title": "" }, { "docid": "5084bae15243ecb9430bf0d7671bbdfc", "score": "0.5058783", "text": "suggest(msg, params) {\n\t\tif (params.length < 4) {\n\t\t\tmsg.reply('Whoops, I didn\\'t understand that. Please use !hsk suggest [character] [translation]');\n\t\t\treturn;\n\t\t}\n\n\t\tlet character = params[2] || null;\n\n\t\tif (character !== null) {\n\t\t\tvar fullstring = params.join(' ');\n\t\t\tvar split = fullstring.indexOf(character + ' '); \n\t\t\tvar translation = fullstring.slice(split + (character.length + 1));\n\n\t\t\tvar me = this.client.users.get(\"201650154867130368\");\n\t\t\tme.send(`New suggestion from ${msg.author}: ${character} -> ${translation}`);\n\t\t\tmsg.reply('Thanks! Your suggestion has been noted :)')\n\t\t}\n\t}", "title": "" }, { "docid": "9eb99ec262ebf5545f288f2927e1c88e", "score": "0.50528026", "text": "function provideHint(){\n\t$('#prompt').text('The number is either '+generateHintArray());\n\t// $('#prompt').text(\"You have guessed \"+pastGuesses);\n\t// $('#prompt').append(\"the answer is \" +winningNumber);\n\n}", "title": "" }, { "docid": "a3231aac48b7b6e242dc9d5f3cc45161", "score": "0.5045175", "text": "function simpleAutocompleteOption(lastWord) {\n var lastWordModded = lastWord.trim();\n var lastWordModdedLength = lastWordModded.length;\n for (var index in functionAppendix) {\n var wordStart = index.toLowerCase().substr(0, lastWordModdedLength);\n console.log(\"wordStart $\" + wordStart);\n if (wordStart == lastWordModded) {\n return functionAppendix[index].substr(lastWordModdedLength);\n }\n }\n return \"\";\n}", "title": "" }, { "docid": "9dde9f4558f5bb5d5616e3b7a63836a4", "score": "0.5042174", "text": "function bogus(value/*:String*/)/*:void*/ {}", "title": "" }, { "docid": "3a6062b82d1661fc6588680bb5622b7d", "score": "0.5040863", "text": "function checkKeyWord(keyWords, string){\n\tfor (var i = keyWords.length - 1; i >= 0; i--) {\n\t\tif (keyWords[i].label == string){\n\t\t\treturn (keyWords[i].value);\n\t\t}\n\t};\n\treturn (\"\");\n}", "title": "" }, { "docid": "4f805aaded7960916e5c8f99f3761f3c", "score": "0.5038236", "text": "function phrase (myString){\n return myString;\n}", "title": "" }, { "docid": "a9d99bad9dc2053950324770548ea30b", "score": "0.50377554", "text": "function findNeedle(haystack) {\n return \"found the needle at postition \" + haystack.indexOf('needle')\n \n }", "title": "" }, { "docid": "97a9eed2c41a66e70dca9683f300f891", "score": "0.5034705", "text": "function string_check () {\r\n var strPy = document.getElementById('string_Py').value;\r\n //console.log(strPy);\r\n if (strPy === null || strPy === undefined || strPy.substring(0,2) === 'Py') {\r\n document.getElementById('result_check').innerHTML = \"The word \" + strPy + \" has Py in front.\";\r\n } else {\r\n document.getElementById('result_check').innerHTML = \"Py was added to the string\" + (\" Py\" + strPy) + \".\";\r\n }\r\n}", "title": "" }, { "docid": "6ba4c452aab3172fa63c003b2c1e1c27", "score": "0.5033131", "text": "function receiveHint()\n{\n if ( hint == 1 )\n {\n document.getElementById(\"hint\").innerHTML = \"0s and 1s are only needed \" + \"<br />\" + \" unless you see Xs. Xs aren't \" + \"<br />\" + \"case sensitive.\";\n }\n \n else if ( hint == 2 )\n {\n document.getElementById(\"hint\").innerHTML = \"Group 1s for SOP and 0s \" + \"<br />\" + \"for POS. Make your groups as big as possible and \" + \"<br />\" + \"if there's a don't care state, pick the values that can \" + \"<br />\" + \"make a bigger group.\";\n }\n \n else if ( hint == 3 )\n {\n document.getElementById(\"hint\").innerHTML = \"When writing equations, don't include 'Y=' \" + \"<br />\" + \"and variables aren't case sensitive.\";\n }\n \n else\n {\n document.getElementById(\"hint\").innerHTML = \"Group 1s for SOP and 0s \" + \"<br />\" + \"for POS. Make your groups as big as possible and \" + \"<br />\" + \"if there's a don't care state, pick the values that can \" + \"<br />\" + \"make a bigger group.\";\n }\n \n return 0;\n}", "title": "" }, { "docid": "bd17d61bf5734bff5d0d998f9647fd3b", "score": "0.50298214", "text": "static validate ( str ) { virtualⵢ ( str ); }", "title": "" }, { "docid": "b83e682e1261fb40e7b9d8b680ae178c", "score": "0.5013189", "text": "hint(hint) {\n (0, abstract_cursor_1.assertUninitialized)(this);\n this[kBuiltOptions].hint = hint;\n return this;\n }", "title": "" }, { "docid": "cd3103ec7ca548c69205f04727e3be46", "score": "0.5013096", "text": "function python(hljs) {\n var KEYWORDS = {\n keyword:\n 'and elif is global as in if from raise for except finally print import pass return ' +\n 'exec else break not with class assert yield try while continue del or def lambda ' +\n 'async await nonlocal|10',\n built_in:\n 'Ellipsis NotImplemented',\n literal: 'False None True'\n };\n var PROMPT = {\n className: 'meta', begin: /^(>>>|\\.\\.\\.) /\n };\n var SUBST = {\n className: 'subst',\n begin: /\\{/, end: /\\}/,\n keywords: KEYWORDS,\n illegal: /#/\n };\n var LITERAL_BRACKET = {\n begin: /\\{\\{/,\n relevance: 0\n };\n var STRING = {\n className: 'string',\n contains: [hljs.BACKSLASH_ESCAPE],\n variants: [\n {\n begin: /(u|b)?r?'''/, end: /'''/,\n contains: [hljs.BACKSLASH_ESCAPE, PROMPT],\n relevance: 10\n },\n {\n begin: /(u|b)?r?\"\"\"/, end: /\"\"\"/,\n contains: [hljs.BACKSLASH_ESCAPE, PROMPT],\n relevance: 10\n },\n {\n begin: /(fr|rf|f)'''/, end: /'''/,\n contains: [hljs.BACKSLASH_ESCAPE, PROMPT, LITERAL_BRACKET, SUBST]\n },\n {\n begin: /(fr|rf|f)\"\"\"/, end: /\"\"\"/,\n contains: [hljs.BACKSLASH_ESCAPE, PROMPT, LITERAL_BRACKET, SUBST]\n },\n {\n begin: /(u|r|ur)'/, end: /'/,\n relevance: 10\n },\n {\n begin: /(u|r|ur)\"/, end: /\"/,\n relevance: 10\n },\n {\n begin: /(b|br)'/, end: /'/\n },\n {\n begin: /(b|br)\"/, end: /\"/\n },\n {\n begin: /(fr|rf|f)'/, end: /'/,\n contains: [hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET, SUBST]\n },\n {\n begin: /(fr|rf|f)\"/, end: /\"/,\n contains: [hljs.BACKSLASH_ESCAPE, LITERAL_BRACKET, SUBST]\n },\n hljs.APOS_STRING_MODE,\n hljs.QUOTE_STRING_MODE\n ]\n };\n var NUMBER = {\n className: 'number', relevance: 0,\n variants: [\n {begin: hljs.BINARY_NUMBER_RE + '[lLjJ]?'},\n {begin: '\\\\b(0o[0-7]+)[lLjJ]?'},\n {begin: hljs.C_NUMBER_RE + '[lLjJ]?'}\n ]\n };\n var PARAMS = {\n className: 'params',\n variants: [\n // Exclude params at functions without params\n {begin: /\\(\\s*\\)/, skip: true, className: null },\n {\n begin: /\\(/, end: /\\)/, excludeBegin: true, excludeEnd: true,\n contains: ['self', PROMPT, NUMBER, STRING, hljs.HASH_COMMENT_MODE],\n },\n ],\n };\n SUBST.contains = [STRING, NUMBER, PROMPT];\n return {\n name: 'Python',\n aliases: ['py', 'gyp', 'ipython'],\n keywords: KEYWORDS,\n illegal: /(<\\/|->|\\?)|=>/,\n contains: [\n PROMPT,\n NUMBER,\n // eat \"if\" prior to string so that it won't accidentally be\n // labeled as an f-string as in:\n { beginKeywords: \"if\", relevance: 0 },\n STRING,\n hljs.HASH_COMMENT_MODE,\n {\n variants: [\n {className: 'function', beginKeywords: 'def'},\n {className: 'class', beginKeywords: 'class'}\n ],\n end: /:/,\n illegal: /[${=;\\n,]/,\n contains: [\n hljs.UNDERSCORE_TITLE_MODE,\n PARAMS,\n {\n begin: /->/, endsWithParent: true,\n keywords: 'None'\n }\n ]\n },\n {\n className: 'meta',\n begin: /^[\\t ]*@/, end: /$/\n },\n {\n begin: /\\b(print|exec)\\(/ // don’t highlight keywords-turned-functions in Python 3\n }\n ]\n };\n}", "title": "" }, { "docid": "fcd56ff39da48780a919d24049db75c6", "score": "0.50120586", "text": "function tt(s){\n// dataTypeExpression is optional and defaults to \"*\"\nreturn function(t,e){\"string\"!=typeof t&&(e=t,t=\"*\");var i,n=0,r=t.toLowerCase().match(Nt)||[];if(vt(e))\n// For each dataType in the dataTypeExpression\nfor(;i=r[n++];)\n// Prepend if requested\n\"+\"===i[0]?(i=i.slice(1)||\"*\",(s[i]=s[i]||[]).unshift(e)):(s[i]=s[i]||[]).push(e)}}", "title": "" }, { "docid": "6ff78cd2391b48fc4af53b5ef38c5f75", "score": "0.50084126", "text": "function provideHint(){\n\t// add code here\n\tif ($('#hint-msg').text().length === 0 )\n\t{\n\t\tvar randomArray = [];\n\t\tfor (var i =0; i<3; i++)\n\t\t{\n\t\t\trandomArray.push(Math.floor(Math.random()*100));\n\t\t}\n\n\t\trandomArray[Math.floor(Math.random()*3)]=winningNumber;\n\n\t\t$('#hint-msg').text(\"One of these values is the winning number [\" + randomArray.toString() +\"], submit a guess!\");\n\t}\n}", "title": "" }, { "docid": "4febcb42215e64a6abfbc46a5345dda6", "score": "0.50044256", "text": "function chooseWord() {\n answer = answers[Math.floor(Math.random() * answers.length)];\n remainingLetters = answer.length;\n for (let i = 0; 9 < answer.length; i++) {\n answer[i] = \"_\";\n }\n thisHint = answers.indexOf(answer);\n hintString = hints[thisHint];\n document.getElementById(\"wordHint\").innerHTML = hintString;\n document.getElementById(\"goal\").textContent = \"Guess the word!\";\n console.log(`my hint ${hintString} for word ${answer}`);\n}", "title": "" }, { "docid": "b0fba7b529881074b91de299de31ce93", "score": "0.5001222", "text": "function offerHint() {\r\n\t// NOW FOR THE QUICK TESTS. SEE DATABASE DESCRIPTION FOR ONE-LINE NOTES.\r\n\tvar conditions = false;\r\n\tswitch (HINT) {\r\n\t\tcase 4: //CAVE\r\n\t\t\tconditions = (PROP[GRATE] == 0 && !HERE(KEYS));\r\n\t\t\tbreak;\r\n\t\tcase 5: //BIRD\r\n\t\t\tconditions = (HERE(BIRD) && TOTING(ROD) && OBJ == BIRD);\r\n\t\t\tbreak;\r\n\t\tcase 6: //SNAKE\r\n\t\t\tconditions = (HERE(SNAKE) && !HERE(BIRD));\r\n\t\t\tbreak;\r\n\t\tcase 7: //MAZE\r\n\t\t\tconditions = (ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0 && HOLDNG > 1);\r\n\t\t\tbreak;\r\n\t\tcase 8: //DARK\r\n\t\t\tconditions = (PROP[EMRALD] != -1 && PROP[PYRAM] == -1);\r\n\t\t\tbreak;\r\n\t\tcase 9: //WITT\r\n\t\t\tconditions = true;\r\n\t\t\tbreak;\r\n\t\tdefault: throw 'Hint number exceeds list';\r\n\t}\r\n\tif (conditions) {\r\n\t\tif (YES(HINTS[HINT][3],0,54)) {\r\n\t\t\tout('I am prepared to give you a hint, but it will cost you ' + HINTS[HINT][2] + ' points.');\r\n\t\t\tHINTED[HINT] = YES(175,HINTS[HINT][4],54);\r\n\t\t\tif (HINTED[HINT] && LIMIT > 30) LIMIT = LIMIT + 30*HINTS[HINT][2];\r\n\t\t}\r\n\t}\r\n\tHINTLC[HINT] = 0;\r\n}", "title": "" }, { "docid": "332e8abc6747768a8abb2231f0782e6e", "score": "0.500038", "text": "function foo() {\r\n var bar = \"bar\";\r\n for (let i=0; i<bar.length; i++){\r\n console.log(bar.charAt(i));\r\n }\r\n\r\n console.log(i); //ReferenceError\r\n}", "title": "" }, { "docid": "c8152744c3304fbf4ef094e6dc9120e8", "score": "0.49989983", "text": "function check_string(ans){\r\n\tif(22 == ans)\r\n\t\treturn \"Correct\";\r\n\telse \r\n\t\treturn \"Incorrect\";\r\n}", "title": "" }, { "docid": "2ae2776e4a98466361d9ea15e4eb8e50", "score": "0.49964404", "text": "function registerStandardHints(successFunc) {\n CodeMirror.registerHelper('hint', 'codeworld', cm => {\n let cur = cm.getCursor();\n let token = cm.getTokenAt(cur);\n\n // If the current token is whitespace, it can be split.\n let term, from;\n if (/^\\s+$/.test(token.string)) {\n term = \"\";\n from = cur;\n } else {\n term = token.string.substr(0, cur.ch - token.start);\n from = CodeMirror.Pos(cur.line, token.start);\n }\n\n let found = [];\n let hints = Object.keys(codeWorldSymbols)\n for (let i = 0; i < hints.length; i++) {\n let hint = hints[i];\n if (hint.startsWith(term)) {\n found.push({\n text: hint,\n render: elem => {\n renderDeclaration(elem, hint,\n codeWorldSymbols[hint], 50);\n }\n });\n }\n }\n\n found.sort((a, b) => {\n function startsWithLetter(c) {\n return /^[a-zA-Z].*/.test(c);\n }\n\n if (startsWithLetter(a.text) && !startsWithLetter(b\n .text)) return -1;\n else if (startsWithLetter(b.text) && !\n startsWithLetter(a.text)) return 1;\n else return a.text.toLowerCase() < b.text.toLowerCase() ?\n -1 : 1\n });\n\n if (found.length > 0) {\n let data = {\n list: found,\n from: from,\n to: cur\n };\n\n function deleteOldHintDocs() {\n $(\".hint-description\").remove()\n }\n\n CodeMirror.on(data, 'close', deleteOldHintDocs);\n CodeMirror.on(data, 'pick', deleteOldHintDocs);\n\n // Tracking of hint selection\n CodeMirror.on(\n data, 'select',\n (selection, elem) => {\n let codeWordInfo = codeWorldSymbols[selection.text],\n hintsWidgetRect = elem.parentElement.getBoundingClientRect(),\n doc = document.createElement('div');\n deleteOldHintDocs();\n let hover = renderHover(selection.text);\n if (hover) {\n doc.className += \"hint-description\";\n doc.style.top = hintsWidgetRect.top + \"px\";\n doc.style.left = hintsWidgetRect.right +\n \"px\";\n doc.appendChild(hover)\n document.body.appendChild(doc)\n }\n }\n );\n return data;\n }\n });\n\n sendHttp('GET', 'codeworld-base.txt', null, request => {\n let lines = [];\n if (request.status != 200) {\n console.log('Failed to load autocomplete word list.');\n } else {\n lines = request.responseText.split('\\n');\n }\n\n let startLine = lines.indexOf('module Prelude') + 1;\n let endLine = startLine;\n while (endLine < lines.length) {\n if (lines[endLine].startsWith(\"module \")) {\n break;\n }\n endLine++;\n }\n lines = lines.slice(startLine, endLine);\n\n // Special case for \"main\" and \"program\", since they are morally\n // built-in names.\n codeworldKeywords['main'] = 'deprecated';\n codeworldKeywords['program'] = 'builtin';\n\n codeWorldBuiltinSymbols['program'] = {\n declaration: \"program :: Program\",\n doc: \"Your program.\",\n symbolStart: 0,\n symbolEnd: 7\n };\n\n let doc = \"\";\n lines.forEach(line => {\n if (line.startsWith(\"type Program\")) {\n // We must intervene to hide the IO type.\n line = \"data Program\";\n } else if (line.startsWith(\"type Truth\")) {\n line = \"data Truth\";\n } else if (line.startsWith(\"True ::\")) {\n line = \"True :: Truth\";\n } else if (line.startsWith(\"False ::\")) {\n line = \"False :: Truth\";\n } else if (line.startsWith(\"newtype \")) {\n // Hide the distinction between newtype and data.\n line = \"data \" + line.substr(8);\n } else if (line.startsWith(\"pattern \")) {\n // Hide the distinction between patterns and constructors.\n line = line.substr(8);\n } else if (line.startsWith(\"class \")) {\n doc = \"\";\n return;\n } else if (line.startsWith(\"instance \")) {\n doc = \"\";\n return;\n } else if (line.startsWith(\"infix \")) {\n doc = \"\";\n return;\n } else if (line.startsWith(\"infixl \")) {\n doc = \"\";\n return;\n } else if (line.startsWith(\"infixr \")) {\n doc = \"\";\n return;\n }\n\n // Filter out strictness annotations.\n line = line.replace(/(\\s)!([A-Za-z\\(\\[])/g, '$1$2');\n\n // Filter out CallStack constraints.\n line = line.replace(/:: HasCallStack =>/g, '::');\n\n if (line.startsWith(\"-- |\")) {\n doc = line.replace(/\\-\\- \\| /g, \"\") + \"\\n\";\n } else if (line.startsWith(\"-- \")) {\n doc += line.replace(/\\-\\- /g, \"\") + \"\\n\";\n } else {\n let wordStart = 0;\n if (line.startsWith(\"type \") || line.startsWith(\n \"data \")) {\n wordStart += 5;\n\n // Hide kind annotations.\n let kindIndex = line.indexOf(\" ::\");\n if (kindIndex != -1) {\n line = line.substr(0, kindIndex);\n }\n }\n\n let wordEnd = line.indexOf(\" \", wordStart);\n if (wordEnd == -1) {\n wordEnd = line.length;\n }\n if (wordStart == wordEnd) {\n doc = \"\";\n return;\n }\n\n if (line[wordStart] == \"(\" && line[wordEnd - 1] ==\n \")\") {\n wordStart++;\n wordEnd--;\n }\n\n let word = line.substr(wordStart, wordEnd -\n wordStart);\n if (hintBlacklist.indexOf(word) < 0) {\n codeWorldBuiltinSymbols[word] = {\n declaration: line,\n symbolStart: wordStart,\n symbolEnd: wordEnd\n }\n if (doc) {\n codeWorldBuiltinSymbols[word].doc = doc;\n }\n }\n\n if (hintBlacklist.indexOf(word) >= 0) {\n codeworldKeywords[word] = 'deprecated';\n } else if (/^[A-Z:]/.test(word)) {\n codeworldKeywords[word] = 'builtin-2';\n } else {\n codeworldKeywords[word] = 'builtin';\n }\n doc = \"\";\n }\n });\n\n successFunc();\n });\n}", "title": "" }, { "docid": "6df96ff762dc755bf4f211db7c52e72a", "score": "0.49951228", "text": "function addPy(){\n let mes = prompt(\"enter String:\");\n let result = document.getElementById(\"Pystring\");\n if (mes.substring(0, 2)!==\"Py\") {\n result.innerHTML = \"Py\" + mes;\n }else{\n result.innerHTML = mes;\n }\n}", "title": "" }, { "docid": "dcdd9596428edb6aa5319b6cd07497d4", "score": "0.49883512", "text": "function greet (strang){\n return 'Hello, ' + strang + '!'\n}", "title": "" }, { "docid": "cae98faceef30cd3e8dd4bac74ab99ee", "score": "0.49824545", "text": "function checkIt(value){\n let checkType = Object.prototype.toString.call(value).slice(8, -1)\n\n return paramResult = checkType.toLowerCase()\n }", "title": "" }, { "docid": "b7aa2f0ae1fb9c2e233b82cf71c031a1", "score": "0.49822548", "text": "function string_check(str1) {\n if (str1 === null || str1 === undefined || str1.substring(0, 2) === 'Py') \n {\n return str1;\n }\n return `Py${str1}`;\n}", "title": "" }, { "docid": "cb818bfbe115f84a790fe244404c153c", "score": "0.49822405", "text": "function hint() {\n switch (answer) {\n case 'antman':\n document.getElementById('hint').innerHTML = 'Guess the character from avengers who has the power of ant';\n break;\n case 'spiderman':\n document.getElementById('hint').innerHTML = 'Guess the character from avengers who has the power of spiderman';\n break;\n case 'iornman':\n document.getElementById('hint').innerHTML = 'Guess the character from avengers who has the power of electronics';\n break;\n case 'blackpanther':\n document.getElementById('hint').innerHTML = 'Guess the character from avengers who has the power of panther';\n break;\n case 'deadpool':\n document.getElementById('hint').innerHTML = 'Guess the character from avengers who has the power of dead';\n break;\n case 'hulk':\n document.getElementById('hint').innerHTML = 'Guess the character from avengers who has the power of green';\n break;\n case 'captianamerica':\n document.getElementById('hint').innerHTML = 'Guess the character from avengers who has the power of america';\n break;\n case 'ramnathkovind':\n document.getElementById('hint').innerHTML = '14th president';\n break;\n case 'pranabmukherjee':\n document.getElementById('hint').innerHTML = '13th president';\n break;\n case 'pratibhapatil':\n document.getElementById('hint').innerHTML = '12th president';\n break;\n case 'abdulkalam':\n document.getElementById('hint').innerHTML = '11th president';\n break;\n case 'kocherilramannarayanan':\n document.getElementById('hint').innerHTML = '10th president';\n break;\n case 'shankardayalsharma':\n document.getElementById('hint').innerHTML = '11th president';\n break;\n case 'ramaswamyvenkataraman':\n document.getElementById('hint').innerHTML = '10th president';\n break;\n }\n}", "title": "" }, { "docid": "ab36bc31740c6b8cef8b6af03cd00b5d", "score": "0.4980521", "text": "function firstThing(test) {\nconsole.log(test + \":is this working\");\n}", "title": "" }, { "docid": "5ac103bbec5d25428de8791b511eb9cf", "score": "0.4979033", "text": "function enableSearch(string,callback) {\n callback(null,string + \" found \");\n}", "title": "" }, { "docid": "3246f5924ef1bd804151320a9b09f376", "score": "0.49788082", "text": "function makeSuggestExplanation(foodName, nutrientName, foodNutrientValue, NutrientThreshold, operator){\r\n return (\"\")\r\n}", "title": "" }, { "docid": "76b73453d29fec8e4e89511a4ba049d1", "score": "0.49753824", "text": "function UpdateHints()\r\n\t{\r\n\t\tvar hint = KQBStrings.Hints.Start;\r\n\t\t\t\t\r\n\t\tKQB.ShowHint(hint);\r\n\t}", "title": "" }, { "docid": "cebe9c7db1547f20761e8daf2baae9c9", "score": "0.49736884", "text": "function cursorCheck(str) {\n return str.toLowerCase().includes('ironman') || str.toLowerCase().includes('cursor') || str.toLowerCase().includes('ostap');\n }", "title": "" }, { "docid": "a783d031ec1b6258a6d6951f5fb02b3b", "score": "0.49676576", "text": "function provideHint(){\n\tvar hintsStr = \"\";\n\tvar hints = [];\n\tif($('#hints').text() === \"\" && gameStatus){\n\t\tfor(var i=0; i<10-(guesses.length*2); i++){\n\t\t\tputIn = Math.ceil(100*Math.random());\n\t\t\tif(putIn != winningNumber && hints.indexOf(putIn) === -1){\n\t\t\t\thints.push(putIn);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti--;\n\t\t\t}\t\t\n\t\t}\n\t\thints[Math.floor(((10-guesses.length*2))*Math.random())] = winningNumber;\n\t\t$('#hintView').text(\"The winning number is one of these.\");\n\t\t$('#hints').text(hints.join(\" , \"));\n\t}\n}", "title": "" }, { "docid": "efc695300b882ff5bd37bc7ecca76506", "score": "0.4961727", "text": "function initHint(prop) {\n var container = $(\"#\" + prop);\n var hint = appendHint(container);\n hint.html(i18n(\"setting_\" + prop + \"Hint\")).appendTo(container);\n return hint;\n }", "title": "" }, { "docid": "3e5301fba41ae118629f868da0c4a2e1", "score": "0.49609765", "text": "function sayString(strInput) {\n return strInput;\n }", "title": "" }, { "docid": "eabb38650431c6e8112a7ef69d9ae90c", "score": "0.4960023", "text": "get hint() {\n\t\treturn this.nativeElement ? this.nativeElement.hint : undefined;\n\t}", "title": "" }, { "docid": "07e47aa3ed0921a23e43581bfdfb9fda", "score": "0.49580953", "text": "function renderHintsAvailable() {\r\n var elHint = document.querySelector(`.hints-available`);\r\n strHTML = '';\r\n\r\n for (var i = 0; i < gHintsAvailable; i++) {\r\n strHTML += `<span class=\"hint-emoji\" onClick=\"runHint(this)\">${HINT}</span>`;\r\n }\r\n\r\n elHint.innerHTML = strHTML;\r\n\r\n}", "title": "" }, { "docid": "ca4be92bd17c030e94b4e6ee237c46e2", "score": "0.49544823", "text": "function giveHint() {\n\t\t\tvar typingNode = document.getElementById(\"myTypingText\");\n\t\t\tif (gamestate) {\n\t\t\t\ttypingNode.innerHTML = \"Oh what's the point? the number times 2 is \" + (2 * numr) +\".\";\n\t\t\t} else {\n\t\t\t\ttypingNode.innerHTML = \"just reset since your chances are up. You wanted \" + numr + \".\";\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "ca9c5a9a33dbfb525d000b62c72d70a0", "score": "0.49493986", "text": "function uu217282() { return 's(\"%T'; }", "title": "" }, { "docid": "885bb6fcc12f6f2f9b64537da7c802e7", "score": "0.4947996", "text": "function typeWithBreaks(str, time){\n for(var i = 0; i < str.length; i++){\n var charCode = str.charCodeAt(i);\n var character = str.charAt(i);\n var e = jQuery.Event(\"keypress\", {keyCode: charCode, key: character});\n\n jasmine.clock().tick(time);\n TypingTest.readLetter(e);\n }\n}", "title": "" }, { "docid": "5abb1f74b68c97c22bb040a502f34980", "score": "0.49409267", "text": "function leetspeak(string) {\n var dict = {'A': 4, 'E': 3, 'G': 6, 'I': 1, 'O': 0, 'S': 5, 'T': 7};\n var char = \"\";\n var leet_string = \"\";\n string = string.toUpperCase();\n for (var i = 0; i < string.length; i++) {\n char = string[i];\n if (char in dict) {\n leet_string += dict[char];\n } else {\n leet_string += char;\n }\n }\n console.log(leet_string);\n}", "title": "" }, { "docid": "a7ad4b485669d97adaa97b64cfd27298", "score": "0.49358946", "text": "function makeSafe(ngram) {\n var ans = ngram;\n if (reserved_words.indexOf(ngram) !== -1) {\n ans = '#' + ngram + '#';\n }\n\treturn ans\n}", "title": "" }, { "docid": "e21e198a12727d5517b1cec198b48ab6", "score": "0.4933183", "text": "function createNewString(value){\n if (value.substring(0,2) === 'py'){\n console.log(value);\n } else {\n console.log('py' + value);\n }\n}", "title": "" }, { "docid": "b833dc5b7bb9e54d1c3bf8ba0ffeadae", "score": "0.49302", "text": "function sayWhat() {\r\n\tout(word1 + \" what?\");\r\n\tOBJ = 0;\r\n\treturn true;\r\n\t// return to 'check hints' (2600)\r\n}", "title": "" }, { "docid": "d7442b883f9ddf588de9352673058dc1", "score": "0.49250484", "text": "function daimioHint(editor) {\n // Find the token at the cursor\n var cur = editor.getCursor()\n , token = editor.getTokenAt(cur)\n , found = []\n , state = token.state.now\n , stack = token.state.stack\n , oldstate = stack[stack.length-1] || {data: []}\n , start = token.string\n , from = {line: cur.line, ch: token.start}\n , to = {line: cur.line, ch: token.end}\n \n if(state.where == 'pval' && state.verb == 'open' && token.type != 'error') // don't show pnames for pvals\n return false\n \n if(!/^[{\\w\\s]*$/.test(start)) // don't show models except after '{' or ' '\n return false\n \n if(!/^\\w+$/.test(start)) { // fix the token if it's borken\n // TODO: if inside a pval, do some crazy autocompleting stuff\n // not pval? then just skip the boundaries\n start = ''\n from.ch = cur.ch\n to.ch = cur.ch\n }\n \n var possibilities = ( oldstate.data.handler\n ? try_state(oldstate, start)\n : try_state(state, start)\n ) || [] \n // maybe = try_state(state.data, start)\n // || try_state(oldstate.data, start)\n // || []\n \n for(var i=0, l=possibilities.length; i < l; i++) {\n var possible = possibilities[i]\n if(/\\w/.test(start)) {\n if (possible.indexOf(start) == 0) \n found.push(possible)\n } else {\n found.push(start + possible)\n }\n }\n \n return {list: found, from: from, to: to}\n }", "title": "" }, { "docid": "b4926e0c73c4c862acc56db87e315dfb", "score": "0.49228865", "text": "function someGenerics7(strs, a, b, c) {}", "title": "" }, { "docid": "edaf37aceadac0cdfb6aa51b144918a6", "score": "0.49218282", "text": "function wordHolder(word) {\n for (i = 0; i < word.length; i++) {\n placeholder.push(\" \");\n }\n\n console.log(\"placeholder arr: \" + placeholder);\n console.log(\"placeholder typeof: \" + typeof placeholder);\n\n\n }", "title": "" }, { "docid": "0b9a8694293e346c3d5a7c5ef83e4366", "score": "0.49168748", "text": "function autocomplete(input, array) {\n\n}", "title": "" }, { "docid": "08d304e99fdd521315cf78868b5a09ca", "score": "0.49076292", "text": "function startsWithWhich(toks, str) {\n for (let which=0; which<toks.length; which++) {\n if (str.indexOf(toks[which])==0) {\n return which;\n }\n }\n debugMsg('Not found any \"'+toks+'\" in \"'+str+'\"');\n return undefined;\n}", "title": "" }, { "docid": "c0a75875ba372a5d0f500b50585c4063", "score": "0.49075893", "text": "function dl(a){return a&&a.implementsGoogStringTypedString?a.getTypedStringValue():a}", "title": "" }, { "docid": "922e7807ca285faacd17902dfcff14d2", "score": "0.49061382", "text": "function index(str){\nfor(i=0;i<str.length;i++){\n if (str[i]==='u')\n console.log(i)\n}\n\n}", "title": "" }, { "docid": "527b020ef7d9744a8a35ef9941974cd1", "score": "0.49053088", "text": "function verbing (str) {\r\nfor (var i= 0; i<str.length; i++) {\r\n if(str.length>=3)\r\n}\r\n}", "title": "" }, { "docid": "8fc5f3dc38f550d29b04598f8e5299c8", "score": "0.48996538", "text": "function addPy(str) {\n if (str === null || str === undefined || str.substring(0, 2) == \"Py\")\n return str;\n else\n return str = \"Py\" + str;\n}", "title": "" }, { "docid": "13a5f5c1cd19d3ead6e51c8d2cc40c88", "score": "0.4899322", "text": "[\"computedString\"]() {}", "title": "" }, { "docid": "8124228aad39c878b32f0c1d38ae7ebb", "score": "0.48970667", "text": "function findNeedle(haystack) {\n return (`found the needle at position ${\nhaystack.indexOf('needle')}`)\n}", "title": "" }, { "docid": "68e8bb68381157504e7e1100739cba42", "score": "0.4895718", "text": "function greetAll(...str){\n alert(\"hello ,\" + str );\n}", "title": "" }, { "docid": "898eae6d29cb089b7b1dbf6cfdcc807f", "score": "0.48946455", "text": "function docifyHint(inputHint, hintID, user){\n let doc = new hints({ _id: inputHint.toString(), hint_id: hintID,\n submittedBy: user});\n return doc;\n}", "title": "" } ]
4dd5d8fcd0fa212a6de7666755b29156
TO DO: perform sql queries and returns data select query returns array of object insert or update query return an object
[ { "docid": "35ebeee1ff05aa7b6aae1530a106e1bb", "score": "0.56235", "text": "async function executeQuery (sqlQuery) {\n let data;\n let query = await session.executeSql(sqlQuery)\n .then(output => {\n data = output;\n })\n .catch(function (error) {\n console.log(error);\n });\n console.log('returning data '+data);\n return data;\n }", "title": "" } ]
[ { "docid": "fee5bd3d122be2ca5c42b3309d32b1a4", "score": "0.67116624", "text": "_query(connection, obj) {\n const { method } = obj;\n let callMethod;\n switch (method) {\n case 'insert':\n case 'update':\n case 'counter':\n case 'del':\n callMethod = 'run';\n break;\n default:\n callMethod = 'all';\n }\n return new Promise(function (resolver, rejecter) {\n if (!connection || !connection[callMethod]) {\n return rejecter(\n new Error(`Error calling ${callMethod} on connection.`)\n );\n }\n connection[callMethod](obj.sql, obj.bindings, function (err, response) {\n if (err) return rejecter(err);\n obj.response = response;\n\n // We need the context here, as it contains\n // the \"this.lastID\" or \"this.changes\"\n obj.context = this;\n return resolver(obj);\n });\n });\n }", "title": "" }, { "docid": "1eb18f89e6d44569ab860128fa703fa1", "score": "0.6645613", "text": "_query(connection, obj) {\n const client = this;\n if (!obj || typeof obj === 'string') obj = { sql: obj };\n return new Promise((resolver, rejecter) => {\n const { sql } = obj;\n if (!sql) return resolver();\n const req = (connection.tx_ || connection).request();\n // req.verbose = true;\n req.multiple = true;\n if (obj.bindings) {\n for (let i = 0; i < obj.bindings.length; i++) {\n client._setReqInput(req, i, obj.bindings[i]);\n }\n }\n req.query(sql, (err, recordset) => {\n if (err) {\n return rejecter(err);\n }\n obj.response = recordset.recordsets[0];\n resolver(obj);\n });\n });\n }", "title": "" }, { "docid": "0983625b532e22afcb3eff46a8e45024", "score": "0.6636482", "text": "_query(connection, obj) {\n if (!obj.sql) throw new Error('The query is empty');\n\n return connection\n .executeAsync(obj.sql, obj.bindings)\n .then(function(response) {\n if (!obj.returning) return response;\n const rowIds = obj.outParams.map(\n (v, i) => response[`returnParam${i ? i : ''}`]\n );\n return connection.executeAsync(obj.returningSql, rowIds);\n })\n .then(function(response) {\n obj.response = response;\n obj.rowsAffected = response.updateCount;\n return obj;\n })\n .catch((err) => {\n if (isConnectionError(err)) {\n connection.__knex__disposed = err;\n }\n throw err;\n });\n }", "title": "" }, { "docid": "b1c4d9be76adc5567be6637264dd2677", "score": "0.6538323", "text": "query(sql) {\n return new Promise((resolve, reject) => {\n this.db.query(sql, (err, rows) => {\n if (err) {\n this.log.error(\"SQL ERROR:\" + \"\\n\\t\" +\n \"ERR CODE: \" + err.code + \"\\n\\t\" +\n \"ERR ERRNO: \" + err.errno + \"\\n\\t\" +\n \"ERR FATAL: \" + err.fatal + \"\\n\\t\" +\n \"ERR SQL: \" + err.sql + \"\\n\\t\" +\n \"ERR SQL State: \" + err.sqlState + \"\\n\\t\" +\n \"ERR SQL Mess: \" + err.sqlMessage + \"\\n\\t\" +\n \"\");\n reject(err.sqlMessage)\n } else {\n let data = [];\n if (rows.length > 0)\n rows.forEach(element => {\n data.push(JSON.parse(JSON.stringify(element)));\n });\n if (rows.insertId)\n data = rows;\n resolve(data);\n }\n })\n })\n }", "title": "" }, { "docid": "71f0077fc5ee434005e25101c7be7002", "score": "0.64086837", "text": "_query(connection, obj) {\n if (!obj || typeof obj === 'string') obj = { sql: obj };\n return new Promise(function (resolver, rejecter) {\n if (!obj.sql) {\n resolver();\n return;\n }\n const queryOptions = Object.assign({ sql: obj.sql }, obj.options);\n connection.query(queryOptions, obj.bindings, function (\n err,\n rows,\n fields\n ) {\n if (err) return rejecter(err);\n obj.response = [rows, fields];\n resolver(obj);\n });\n });\n }", "title": "" }, { "docid": "a32762cb999715b3db199e841c6ce7c2", "score": "0.63704157", "text": "_query(connection, obj) {\n if (!obj || typeof obj === 'string')\n obj = {sql: obj};\n return new Promise(function (resolver, rejecter) {\n const sql = obj.sql;\n if (!sql)\n return resolver();\n if (connection.transaction && connection.db) {\n connection = connection.transaction;\n }\n\n connection.query(sql, obj.bindings, function (err, rows, fields) {\n if (err)\n return rejecter(err);\n obj.response = [rows, fields, obj.bindings];\n resolver(obj);\n });\n });\n }", "title": "" }, { "docid": "ce422a84a90590a3dc5b39cfba848670", "score": "0.6204892", "text": "_query(connection, obj) {\n let queryConfig = {\n text: obj.sql,\n values: obj.bindings || [],\n };\n\n if (obj.options) {\n queryConfig = extend(queryConfig, obj.options);\n }\n\n return new Promise(function (resolver, rejecter) {\n connection.query(queryConfig, function (err, response) {\n if (err) return rejecter(err);\n obj.response = response;\n resolver(obj);\n });\n });\n }", "title": "" }, { "docid": "b78683a30053bc488b794b6ed70c0660", "score": "0.6154077", "text": "select(sql, values = {}) {\n return this.query(sql, values).then(results => results.rows)\n }", "title": "" }, { "docid": "23ed64054e200142321dc086355a2e3f", "score": "0.60937357", "text": "insert() {\n const sql = QueryCompiler.prototype.insert.call(this);\n if (sql === '') return sql;\n const { returning } = this.single;\n return {\n sql: sql + this._returning(returning),\n returning,\n };\n }", "title": "" }, { "docid": "b849b4f11dbf1a9c5b621162c5528fe5", "score": "0.6076526", "text": "async select() {\n let conn = DBConnFactory();\n let result = await conn.selectOne(await this.toJsonObject(), this.tablename);\n if (result == null) {\n throw new Error(\"The requested SimObj cannot be found in the database\");\n }\n await this.fromJsonObject(result);\n }", "title": "" }, { "docid": "86a8eba40de20b79c8eff35add365a67", "score": "0.60383874", "text": "query(soql) {\n return this.connect().query(soql);\n }", "title": "" }, { "docid": "9874381045348967773d833794dd798d", "score": "0.6000049", "text": "query(originalSql, values = {}) {\n return new Promise((res, rej) => {\n\n // Apply Middleware\n let finalSql = this.applyMiddlewareOnBeforeQuery(originalSql, values)\n\n // Bind dynamic values to SQL\n finalSql = this.queryBindValues(finalSql, values).trim()\n\n this.connection.query({\n sql: finalSql,\n typeCast: (field, next) => field.type === 'JSON' ? JSON.parse(field.string()) : next()\n }, (err, results, fields) => {\n if (err) {\n // assign `sql` and preserve `message` prop\n err.sql = finalSql\n\n rej(err)\n } else {\n\n // When calling `connection.query`, the results returned are either \"rows\"\n // in the case of an SQL statement, or meta results in the case of non-SQL\n\n // Apply Middleware\n results = this.applyMiddlewareOnResults(originalSql, results)\n\n // If sql is SELECT\n if (this.isSelect(finalSql)) {\n\n // Results is the rows\n res({ rows: results, fields, sql: finalSql})\n\n } else {\n res({ ...results, sql: finalSql })\n }\n\n }\n })\n })\n }", "title": "" }, { "docid": "493073667578cca0343bccd994c121e5", "score": "0.5993723", "text": "processResponse(obj, runner) {\n const resp = obj.response;\n if (obj.output) return obj.output.call(runner, resp);\n if (obj.method === 'raw') return resp;\n if (resp.command === 'SELECT') {\n if (obj.method === 'first') return resp.rows[0];\n if (obj.method === 'pluck') return map(resp.rows, obj.pluck);\n return resp.rows;\n }\n if (\n resp.command === 'INSERT' ||\n resp.command === 'UPDATE' ||\n resp.command === 'DELETE'\n ) {\n return resp.rowCount;\n }\n return resp;\n }", "title": "" }, { "docid": "6dbc0b65180a2a2d50b6a33629a77b0e", "score": "0.5971287", "text": "function giodb_execute( query ) { \n wdb.db.transaction(function(tx) { \n rs = tx.executeSql( query, [] ) ; \n }) ; \n \n return rs ; \n}", "title": "" }, { "docid": "b5d50692a329a8ab1d6813b64d5b7d48", "score": "0.5889993", "text": "function SQL(config) {\n var dataName = config.name;\n var version = config.version || '1.0.0';\n var description = config.description || 'SQL DB';\n var size = config.size || (64 * 1024);\n var tableName = null;\n var fields = '';\n var res = {\n dataName: dataName,\n version: version,\n description: description,\n size: size,\n tableName: tableName,\n fields: fields,\n db: openDatabase(dataName, version, description, size),\n /*\n * Recive un objeto \"params\" donde este tiene\n * name: el nombre de la tabla y\n * fields: un array de los campos que la tabla tendrá\n * Opcionalmente recibe un callback de un resultado positivo\n * y una función de un posible error\n */\n createTable: function (params, success, error) {\n var _this = this;\n if (success === void 0) { success = function (res) { return console.log(res, 'ok createTable'); }; }\n if (error === void 0) { error = function (tx, e) { return console.log(e, 'error createTable'); }; }\n this.tableName = params.tableName;\n var tableName = params.tableName;\n var flds = params.fields;\n for (var i = 0; i < flds.length; i++)\n this.fields += (i == 0 ? flds[i] : \", \" + flds[i]);\n this.db.transaction(function (tx) {\n tx.executeSql(\"CREATE TABLE IF NOT EXISTS \" + tableName + \" (\" + _this.fields + \")\", [], function (tx, res) { return success(__assign({ tx: tx, res: res }, _this)); }, error);\n });\n },\n /*\n * Recive un objeto \"records\" en el cual se especifica\n * la key es el campo a ingresar y el valor de la key el valor del campo\n * Ej: { id: 1, data1: 2, data2: 3 }\n */\n insert: function (records, success, error) {\n var _this = this;\n if (success === void 0) { success = function (tx, result) { return console.log(result, 'ok insert'); }; }\n if (error === void 0) { error = function (tx, e) { return console.log(\"error insert\", e); }; }\n var keysRecords = Object.keys(records || {});\n var lengthKeysRecords = keysRecords.length;\n if (lengthKeysRecords > this.fields.split(',').length && lengthKeysRecords < this.fields.split(',').length)\n error('Error:', \"La cantidad de valores a ingresar no es la misma que los campos de la tabla.\\nCampos: \" + this.fields + \" \");\n else if (!records || lengthKeysRecords <= 0)\n error('Error:', 'Ingrese un objeto con las keys correspondientes, ej; {id:1, data1:2}');\n else {\n this.db.transaction(function (tx) {\n var values = \"\";\n var keys = [];\n for (var i = 0; i < lengthKeysRecords; i++) {\n values += (i == 0 ? \"?\" : \", ?\");\n keys.push(records[keysRecords[i]]);\n }\n tx.executeSql(\"INSERT INTO \" + _this.tableName + \" (\" + _this.fields + \") VALUES (\" + values + \")\", keys, success, error);\n });\n }\n },\n /*\n * Recive un array con los objetos del insert\n */\n insertValues: function (records, success, error) {\n var _this = this;\n if (success === void 0) { success = function (tx, result) { return console.log(result, 'ok insert values'); }; }\n if (error === void 0) { error = function (tx, e) { return console.log(\"error insert values\", e); }; }\n if (records.length <= 0)\n error('Erro', 'Inserte objetos ');\n else {\n var count = 0;\n var errors_1 = [];\n var ress = void 0, txx = void 0;\n var fn_1 = function (cant) {\n _this.insert(records[cant], function (tx, res) {\n if (cant >= (records.length - 1))\n success(tx, res);\n else\n fn_1(cant + 1);\n }, function (tx, err) {\n if (cant >= records.length) {\n errors_1.push(err);\n error(tx, errors_1);\n }\n else {\n errors_1.push(err);\n fn_1(cant + 1);\n }\n });\n };\n fn_1(count);\n }\n },\n generateStrings: function (a, value, key) {\n var vals = [];\n var fds = '';\n if (typeof value == 'object' && value.OR && value.OR.length > 0) {\n for (var e = 0; e < value.OR.length; ++e) {\n fds += (e == 0 ? \"( \" + key + \" = ? \" : e == (value.OR.length - 1) ? \" OR \" + key + \" = ? )\" : \" OR \" + key + \" = ? \");\n vals.push(value.OR[e]);\n }\n }\n if (typeof value == 'object' && value.AND && value.AND.length > 0) {\n for (var e = 0; e < value.AND.length; ++e) {\n fds += (e == 0 ? \"( \" + key + \" = ? \" : e == (value.AND.length - 1) ? \" AND \" + key + \" = ? )\" : \" AND \" + key + \" = ? \");\n vals.push(value.AND[e]);\n }\n }\n if (typeof value != 'object') {\n fds += (a == 0 ? key + \" = ? \" : \" AND \" + key + \" = ? \");\n vals.push(value);\n }\n return { vals: vals, fds: fds };\n },\n /*\n * Recive un objeto \"records\" en el cual se especifica\n * la key es el campo por el cual se eliminará la data y el valor es\n * al que tendrá que hacer referencia del campo guardado\n * Ej: { id: 1, data1: 2} = 'WHERE id = 1 AND data1 = 2' o { id: { AND:[1, 2] } } = 'WHERE id = 1 AND id = 2'\n * { id: { OR: [1, 2] }, data2: 2 } = 'WHERE id = 1 OR id = 2 AND data2 = 2'\n */\n deleted: function (values, success, error) {\n var _this = this;\n if (success === void 0) { success = function (tx, result) { return console.log(result, 'ok deleted'); }; }\n if (error === void 0) { error = function (tx, e) { return console.log(\"error deleted\", e); }; }\n var keysValues = Object.keys(values || {});\n var lengthKeysValues = keysValues.length;\n if ((values != null && typeof values != 'object') || lengthKeysValues <= 0) {\n error('Error:', 'Ningún campo para eliminar');\n }\n else {\n var vals_1 = [];\n var fds_1 = '';\n for (var i = 0; i < lengthKeysValues; i++) {\n var obj = this.generateStrings(i, values[keysValues[i]], keysValues[i]);\n fds_1 += obj.fds;\n vals_1.push.apply(vals_1, obj.vals);\n }\n this.db.transaction(function (tx) { return tx.executeSql(\"DELETE FROM \" + _this.tableName + \" WHERE \" + fds_1, vals_1, success, error); });\n }\n },\n /*\n * Recive un objeto \"records\" en el cual se especifica\n * la key es el campo por el cual se obtendrá la data y el valor es\n * al que tendrá que hacer referencia del campo guardado, si no se especifica nada se optienen todos los valores\n * Ej: { id: 1, data1: 2} = 'WHERE id = 1 AND data1 = 2' o { id: { AND:[1, 2] } } = 'WHERE id = 1 AND id = 2'\n * { id: { OR: [1, 2] }, data2: 2 } = 'WHERE id = 1 OR id = 2 AND data2 = 2'\n * * return a Array for the function success calback\n */\n getVal: function (values, success, error) {\n var _this = this;\n if (success === void 0) { success = function (tx, result) { return console.log(result, 'ok getVal'); }; }\n if (error === void 0) { error = function (tx, e) { return console.log(\"error getVal\", e); }; }\n this.db.transaction(function (tx) {\n var sqlString = \"SELECT * FROM \" + _this.tableName;\n var fields = Object.keys(values || {});\n if (values && typeof values == 'object' && fields.length >= 0) {\n var vals = [];\n var fds = '';\n for (var i = 0; i < fields.length; i++) {\n var obj = _this.generateStrings(i, values[fields[i]], fields[i]);\n fds += obj.fds;\n vals.push.apply(vals, obj.vals);\n }\n sqlString += \" WHERE \" + fds;\n tx.executeSql(sqlString, vals, function (tx, results) {\n if (results.rows.length <= 0)\n success(tx, []);\n else {\n var resultsArray = [];\n for (var e = 0; e < results.rows.length; ++e)\n resultsArray.push(results.rows[e]);\n success(tx, resultsArray);\n }\n }, error);\n }\n else {\n tx.executeSql(sqlString, [], function (tx, results) {\n if (results.rows.length == 0)\n success(tx, []);\n else {\n var resultsArray = [];\n for (var e = 0; e < results.rows.length; ++e)\n resultsArray.push(results.rows[e]);\n success(tx, resultsArray);\n }\n }, error);\n }\n });\n },\n update: function (values, updates, success, error) {\n if (success === void 0) { success = function (tx, result) { return console.log(result, 'ok getVal'); }; }\n if (error === void 0) { error = function (tx, e) { return console.log(\"error getVal\", e); }; }\n //`UPDATE FILES SET name = ?, fullPath = ?, version = ?, date = ? WHERE id = ?` \n var keysValues = values == null ? 'all' : Object.keys(values);\n var keysUpdates = Object.keys(updates || {});\n var lengthKeysValues = keysValues.length;\n if ((typeof values == 'string' && values != 'all') || lengthKeysValues <= 0) {\n error('Error:', 'Ningún campo para eliminar');\n }\n else {\n var vals_2 = [];\n var fds = '';\n var upFds = '';\n var sqlString_1 = \"UPDATE \" + this.tableName;\n for (var e = 0; e < keysUpdates.length; ++e) {\n upFds += (e == 0 ? \" \" + keysUpdates[e] + \" = ? \" : \" , \" + keysUpdates[e] + \" = ? \");\n vals_2.push(updates[keysUpdates[e]]);\n }\n sqlString_1 += \" SET \" + upFds;\n if (typeof values != 'string') {\n for (var i = 0; i < lengthKeysValues; i++) {\n var obj = this.generateStrings(i, values[keysValues[i]], keysValues[i]);\n fds += obj.fds;\n vals_2.push.apply(vals_2, obj.vals);\n }\n sqlString_1 += \" WHERE \" + fds;\n }\n this.db.transaction(function (tx) { return tx.executeSql(sqlString_1, vals_2, success, error); });\n }\n }\n };\n var espy = function (fn) { return function () {\n var arg = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n arg[_i] = arguments[_i];\n }\n return fn.apply(res, arg);\n }; };\n res.createTable = espy(res.createTable);\n res.insert = espy(res.insert);\n res.update = espy(res.update);\n res.getVal = espy(res.getVal);\n res.deleted = espy(res.deleted);\n return res;\n}", "title": "" }, { "docid": "ddee08e1b51dfb8b67698a8052199fea", "score": "0.5877275", "text": "function runQuery(sql) {\n //Single row operation\n var sqlQuery = sql;\n db.each(sql, function(err, rows) {\n return rows;\n });\n}", "title": "" }, { "docid": "0ce5e3ea8ec10c571ac5b082635734dc", "score": "0.58702165", "text": "async save() {\r\n const { rows: [res] } = await dbConnection.dbConnect(\r\n `INSERT INTO ${userTableName} (\r\n email, password, first_name, last_name, phone, address, street, state, country\r\n ) VALUES (\r\n $1, $2, $3, $4, $5, $6, $7, $8, $9\r\n ) returning id, email, first_name, last_name, phone, address, street, state, country, role`,\r\n [\r\n this.email, this.password, this.firstName, this.lastName,\r\n this.phone, this.address, this.street, this.state, this.country,\r\n ],\r\n );\r\n\r\n return res;\r\n }", "title": "" }, { "docid": "9d187aee17589e4693a3599dc8f75218", "score": "0.5865379", "text": "async Getdata() {\n try {\n var sql = `SELECT * FROM ${this.db}.project_tbl inner join ${this.db}.employee_tbl on ${this.db}.project_tbl.empid = ${this.db}.employee_tbl.empunkid`;\n let projData = await this.dao.executeQuery(sql);\n return projData\n }\n catch (e) {\n console.log(e)\n return false\n }\n }", "title": "" }, { "docid": "b433b7da0c88d979173584b4420de3df", "score": "0.5848798", "text": "update() {\n const sql = QueryCompiler.prototype.update.apply(this, arguments);\n this._slightReturn();\n return {\n sql,\n };\n }", "title": "" }, { "docid": "d2364c04c336bbdbe97ab254564274cd", "score": "0.58371896", "text": "function afterExecute(err, results) {\n debug(`executed(${query.database.uuid || 'default'}) : ${query.sql}`);\n\n if (benchmark) {\n query.sequelize.log('Executed (' + (query.database.uuid || 'default') + '): ' + query.sql, Date.now() - queryBegin, query.options);\n }\n\n if (err) {\n err.sql = query.sql;\n reject(query.formatError(err));\n } else {\n const metaData = this;\n let result = query.instance;\n\n // add the inserted row id to the instance\n if (query.isInsertQuery(results, metaData)) {\n query.handleInsertQuery(results, metaData);\n if (!query.instance) {\n // handle bulkCreate AI primary key\n if (\n metaData.constructor.name === 'Statement'\n && query.model\n && query.model.autoIncrementAttribute\n && query.model.autoIncrementAttribute === query.model.primaryKeyAttribute\n && query.model.rawAttributes[query.model.primaryKeyAttribute]\n ) {\n const startId = metaData[query.getInsertIdField()] - metaData.changes + 1;\n result = [];\n for (let i = startId; i < startId + metaData.changes; i++) {\n result.push({ [query.model.rawAttributes[query.model.primaryKeyAttribute].field]: i });\n }\n } else {\n result = metaData[query.getInsertIdField()];\n }\n }\n }\n\n if (query.sql.indexOf('sqlite_master') !== -1) {\n if (query.sql.indexOf('SELECT sql FROM sqlite_master WHERE tbl_name') !== -1) {\n result = results;\n if (result && result[0] && result[0].sql.indexOf('CONSTRAINT') !== -1) {\n result = query.parseConstraintsFromSql(results[0].sql);\n }\n } else {\n result = results.map(resultSet => resultSet.name);\n }\n } else if (query.isSelectQuery()) {\n if (!query.options.raw) {\n // This is a map of prefix strings to models, e.g. user.projects -> Project model\n const prefixes = query._collectModels(query.options.include);\n\n results = results.map(result => {\n return _.mapValues(result, (value, name) => {\n let model;\n if (name.indexOf('.') !== -1) {\n const lastind = name.lastIndexOf('.');\n\n model = prefixes[name.substr(0, lastind)];\n\n name = name.substr(lastind + 1);\n } else {\n model = query.options.model;\n }\n\n const tableName = model.getTableName().toString().replace(/`/g, '');\n const tableTypes = columnTypes[tableName] || {};\n\n if (tableTypes && !(name in tableTypes)) {\n // The column is aliased\n _.forOwn(model.rawAttributes, (attribute, key) => {\n if (name === key && attribute.field) {\n name = attribute.field;\n return false;\n }\n });\n }\n\n return tableTypes.hasOwnProperty(name)\n ? query.applyParsers(tableTypes[name], value)\n : value;\n });\n });\n }\n\n result = query.handleSelectQuery(results);\n } else if (query.isShowOrDescribeQuery()) {\n result = results;\n } else if (query.sql.indexOf('PRAGMA INDEX_LIST') !== -1) {\n result = query.handleShowIndexesQuery(results);\n } else if (query.sql.indexOf('PRAGMA INDEX_INFO') !== -1) {\n result = results;\n } else if (query.sql.indexOf('PRAGMA TABLE_INFO') !== -1) {\n // this is the sqlite way of getting the metadata of a table\n result = {};\n\n let defaultValue;\n for (const _result of results) {\n if (_result.dflt_value === null) {\n // Column schema omits any \"DEFAULT ...\"\n defaultValue = undefined;\n } else if (_result.dflt_value === 'NULL') {\n // Column schema is a \"DEFAULT NULL\"\n defaultValue = null;\n } else {\n defaultValue = _result.dflt_value;\n }\n\n result[_result.name] = {\n type: _result.type,\n allowNull: _result.notnull === 0,\n defaultValue,\n primaryKey: _result.pk !== 0\n };\n\n if (result[_result.name].type === 'TINYINT(1)') {\n result[_result.name].defaultValue = { '0': false, '1': true }[result[_result.name].defaultValue];\n }\n\n if (typeof result[_result.name].defaultValue === 'string') {\n result[_result.name].defaultValue = result[_result.name].defaultValue.replace(/'/g, '');\n }\n }\n } else if (query.sql.indexOf('PRAGMA foreign_keys;') !== -1) {\n result = results[0];\n } else if (query.sql.indexOf('PRAGMA foreign_keys') !== -1) {\n result = results;\n } else if (query.sql.indexOf('PRAGMA foreign_key_list') !== -1) {\n result = results;\n } else if ([QueryTypes.BULKUPDATE, QueryTypes.BULKDELETE].indexOf(query.options.type) !== -1) {\n result = metaData.changes;\n } else if (query.options.type === QueryTypes.UPSERT) {\n result = undefined;\n } else if (query.options.type === QueryTypes.VERSION) {\n result = results[0].version;\n } else if (query.options.type === QueryTypes.RAW) {\n result = [results, metaData];\n } else if (query.isUpdateQuery() || query.isInsertQuery()) {\n result = [result, metaData.changes];\n }\n\n resolve(result);\n }\n }", "title": "" }, { "docid": "5ac9cbd98e6d1df53e1a1ff634532dcf", "score": "0.58340746", "text": "insert() {\n const insertValues = this.single.insert || [];\n let sql = this.with() + `insert into ${this.tableName} `;\n const { returning } = this.single;\n const returningSql = returning\n ? this._returning('insert', returning) + ' '\n : '';\n\n if (Array.isArray(insertValues)) {\n if (insertValues.length === 0) {\n return '';\n }\n } else if (typeof insertValues === 'object' && isEmpty(insertValues)) {\n return {\n sql: sql + returningSql + this._emptyInsertValue,\n returning,\n };\n }\n\n const insertData = this._prepInsert(insertValues);\n if (typeof insertData === 'string') {\n sql += insertData;\n } else {\n if (insertData.columns.length) {\n sql += `(${this.formatter.columnize(insertData.columns)}`;\n sql += `) ${returningSql}values (`;\n let i = -1;\n while (++i < insertData.values.length) {\n if (i !== 0) sql += '), (';\n sql += this.formatter.parameterize(\n insertData.values[i],\n this.client.valueForUndefined\n );\n }\n sql += ')';\n } else if (insertValues.length === 1 && insertValues[0]) {\n sql += returningSql + this._emptyInsertValue;\n } else {\n sql = '';\n }\n }\n return {\n sql,\n returning,\n };\n }", "title": "" }, { "docid": "0093c6eaaf169b192234afb98712e124", "score": "0.5811893", "text": "executed() {\n return this.sync().then((res) => {\n return new Promise((resolve, reject) => {\n res.db.query({\n sql: `SELECT * FROM ${this.tableName} ORDER BY run_at ASC;`,\n }, (err, rows) => {\n if (res.mustClose) res.db.end();\n if (err) return reject(err);\n return resolve((rows || []).map((row) => row[this.columnName]));\n });\n });\n });\n }", "title": "" }, { "docid": "d2bd38a9457c17fc3c9e51ae4e1c2c59", "score": "0.5805348", "text": "addEmployee(data){\n return connection.query(\"INSERT INTO employees SET ?\", data);\n }", "title": "" }, { "docid": "781c7235313c599d62a7b114013652c5", "score": "0.57868886", "text": "getOne(sql = '', values = []) {\n values = Array.isArray(values) === false ? [values] : values;\n return new Promise((resolve, reject) => {\n let resultado = null;\n this.conexion.query({\n sql,\n values\n }, (err, result, fields) => {\n if (err) {\n reject(err);\n } else {\n resultado = result[0];\n if (Array.isArray(resultado)) {\n if (resultado.length > 0) {\n resultado = resultado[0];\n } else {\n resultado = null;\n }\n }\n resolve(resultado);\n }\n });\n });\n }", "title": "" }, { "docid": "c67377edf3bbe8d4dbf81f824f8b2245", "score": "0.5780113", "text": "update() {\n const withSQL = this.with();\n const updateData = this._prepUpdate(this.single.update);\n const wheres = this.where();\n const { returning } = this.single;\n return {\n sql:\n withSQL +\n `update ${this.single.only ? 'only ' : ''}${this.tableName} ` +\n `set ${updateData.join(', ')}` +\n (wheres ? ` ${wheres}` : '') +\n this._returning(returning),\n returning,\n };\n }", "title": "" }, { "docid": "352f00f58aa0862ea1ec74ec2f75a728", "score": "0.5777981", "text": "_updateSql(obj) {\n\t\tlet table = this.constructor.table;\n\t\tlet fm = this.constructor.fieldMap;\n\t\tlet ifm = this.constructor._inverseFieldMap;\n\n\t\tassert(this[this.constructor.idField], `The model must have ${this.constructor.idField} defined in order to update`);\n\n\t\tlet q = squel.update()\n\t\t\t.table(table.tableName);\n\n\t\tObject.keys(obj).forEach(k => {\n\t\t\tq.set(fm[k], obj[k]);\n\t\t});\n\n\t\tObject.keys(fm).forEach(k => {\n\t\t\tq.returning(`${table.tableName}.${fm[k]}`);\n\t\t});\n\n\t\tq.where(`${fm[this.constructor.idField]} = ?`, this[this.constructor.idField]);\n\n\t\treturn q;\n\t}", "title": "" }, { "docid": "15f62b4c4cbab0e42fcb301d791c6dae", "score": "0.57720935", "text": "function queryPedidos(tx){\n tx.executeSql('SELECT * FROM Pedidos',[],pullPedidos);\n}", "title": "" }, { "docid": "83582a800daaaebad0a34942f5268d27", "score": "0.57643765", "text": "insert() {\n const sql = QueryCompiler.prototype.insert.apply(this, arguments);\n if (sql === '') return sql;\n this._slightReturn();\n return {\n sql,\n };\n }", "title": "" }, { "docid": "e1703c530f70f355705b5993377ef03e", "score": "0.5757535", "text": "function doSQL(sql) {\n\t\ttry {\n\t\t\tvar array = [];\n\t\t\tvar initialContext = aa.proxyInvoker.newInstance(\"javax.naming.InitialContext\", null).getOutput();\n\t\t\tvar ds = initialContext.lookup(\"java:/AA\");\n\t\t\tvar conn = ds.getConnection();\n\t\t\tvar sStmt = conn.prepareStatement(sql);\n\n\t\t\tif (sql.toUpperCase().indexOf(\"SELECT\") == 0) {\n\t\t\t\taa.print(\"executing \" + sql);\n\t\t\t\tvar rSet = sStmt.executeQuery();\n\t\t\t\twhile (rSet.next()) {\n\t\t\t\t\tvar obj = {};\n\t\t\t\t\tvar md = rSet.getMetaData();\n\t\t\t\t\tvar columns = md.getColumnCount();\n\t\t\t\t\tfor (i = 1; i <= columns; i++) {\n\t\t\t\t\t\tobj[md.getColumnName(i)] = String(rSet.getString(md.getColumnName(i)));\n\t\t\t\t\t}\n\t\t\t\t\tobj.count = rSet.getRow();\n\t\t\t\t\tarray.push(obj)\n\t\t\t\t}\n\t\t\t\trSet.close();\n\t\t\t\taa.print(\"...returned \" + array.length + \" rows\");\n\t\t\t\t//aa.print(JSON.stringify(array));\n\t\t\t\treturn array\n\t\t\t} else if (sql.toUpperCase().indexOf(\"UPDATE\") == 0) {\n\t\t\t\taa.print(\"executing update: \" + sql);\n\t\t\t\tvar rOut = sStmt.executeUpdate();\n\t\t\t\taa.print(rOut + \" rows updated\");\n\t\t\t} else {\n\t\t\t\taa.print(\"executing : \" + sql);\n\t\t\t\tvar rOut = sStmt.execute();\n\t\t\t\taa.print(rOut);\n\t\t\t}\n\t\t\tsStmt.close();\n\t\t\tconn.close();\n\t\t} catch (err) {\n\t\t\taa.print(err.message);\n\t\t}\n\t}", "title": "" }, { "docid": "9e4722add5544abc188774ec036d535a", "score": "0.57443494", "text": "insert() {\n let insertValues = this.single.insert || [];\n let { returning } = this.single;\n\n if (!Array.isArray(insertValues) && isPlainObject(this.single.insert)) {\n insertValues = [this.single.insert];\n }\n\n // always wrap returning argument in array\n if (returning && !Array.isArray(returning)) {\n returning = [returning];\n }\n\n if (\n Array.isArray(insertValues) &&\n insertValues.length === 1 &&\n isEmpty(insertValues[0])\n ) {\n return this._addReturningToSqlAndConvert(\n `insert into ${this.tableName} (${this.formatter.wrap(\n this.single.returning\n )}) values (default)`,\n returning,\n this.tableName\n );\n }\n\n if (\n isEmpty(this.single.insert) &&\n typeof this.single.insert !== 'function'\n ) {\n return '';\n }\n\n const insertData = this._prepInsert(insertValues);\n\n const sql = {};\n\n if (isString(insertData)) {\n return this._addReturningToSqlAndConvert(\n `insert into ${this.tableName} ${insertData}`,\n returning\n );\n }\n\n if (insertData.values.length === 1) {\n return this._addReturningToSqlAndConvert(\n `insert into ${this.tableName} (${this.formatter.columnize(\n insertData.columns\n )}) values (${this.formatter.parameterize(insertData.values[0])})`,\n returning,\n this.tableName\n );\n }\n\n const insertDefaultsOnly = insertData.columns.length === 0;\n\n sql.sql =\n 'begin ' +\n insertData.values\n .map((value) => {\n let returningHelper;\n const parameterizedValues = !insertDefaultsOnly\n ? this.formatter.parameterize(value, this.client.valueForUndefined)\n : '';\n const returningValues = Array.isArray(returning)\n ? returning\n : [returning];\n let subSql = `insert into ${this.tableName} `;\n\n if (returning) {\n returningHelper = new ReturningHelper(returningValues.join(':'));\n sql.outParams = (sql.outParams || []).concat(returningHelper);\n }\n\n if (insertDefaultsOnly) {\n // no columns given so only the default value\n subSql += `(${this.formatter.wrap(\n this.single.returning\n )}) values (default)`;\n } else {\n subSql += `(${this.formatter.columnize(\n insertData.columns\n )}) values (${parameterizedValues})`;\n }\n subSql += returning\n ? ` returning ROWID into ${this.formatter.parameter(\n returningHelper\n )}`\n : '';\n\n // pre bind position because subSql is an execute immediate parameter\n // later position binding will only convert the ? params\n\n subSql = this.formatter.client.positionBindings(subSql);\n\n const parameterizedValuesWithoutDefault = parameterizedValues\n .replace('DEFAULT, ', '')\n .replace(', DEFAULT', '');\n return (\n `execute immediate '${subSql.replace(/'/g, \"''\")}` +\n (parameterizedValuesWithoutDefault || returning ? \"' using \" : '') +\n parameterizedValuesWithoutDefault +\n (parameterizedValuesWithoutDefault && returning ? ', ' : '') +\n (returning ? 'out ?' : '') +\n ';'\n );\n })\n .join(' ') +\n 'end;';\n\n if (returning) {\n sql.returning = returning;\n // generate select statement with special order by to keep the order because 'in (..)' may change the order\n sql.returningSql =\n `select ${this.formatter.columnize(returning)}` +\n ' from ' +\n this.tableName +\n ' where ROWID in (' +\n sql.outParams.map((v, i) => `:${i + 1}`).join(', ') +\n ')' +\n ' order by case ROWID ' +\n sql.outParams\n .map((v, i) => `when CHARTOROWID(:${i + 1}) then ${i}`)\n .join(' ') +\n ' end';\n }\n\n return sql;\n }", "title": "" }, { "docid": "0453382b0879b7874d0bcaaccc213b35", "score": "0.5739502", "text": "function saveDataToDB(sqlInfo) {\n // create the parameter placeholder\n let params = [];\n\n for (let i = 1; i <= sqlInfo.values.length; i++) {\n params.push(`$${i}`);\n }\n\n let sqlParams = params.join();\n\n let sql = '';\n\n if (sqlInfo.searchQuery) {\n // for location only\n sql = `INSERT INTO ${sqlInfo.endpoint}s (${sqlInfo.columns}) VALUES (${sqlParams}) RETURNING ID;`;\n } else {\n // for all other endpoints\n sql = `INSERT INTO ${sqlInfo.endpoint}s (${sqlInfo.columns}) VALUES (${sqlParams});`;\n }\n\n // save the data\n try { return client.query(sql, sqlInfo.values); }\n catch (err) { handleError(err); }\n\n}", "title": "" }, { "docid": "db8c55b86be44b8de0548fd9814a8daa", "score": "0.57322884", "text": "function sqlForPartialUpdate(dataToUpdate, jsToSql) {\n //take the keys out of the data you need to update\n const keys = Object.keys(dataToUpdate);\n //if no keys then return an error\n if (keys.length === 0) throw new BadRequestError(\"No data\");\n\n // {firstName: 'Aliya', age: 32} => ['\"first_name\"=$1', '\"age\"=$2']\n //map each key with the column name and index\n const cols = keys.map((colName, idx) =>\n //make the column name = to the secure version of passing in data ($1)\n `\"${jsToSql[colName] || colName}\"=$${idx + 1}`,\n );\n\n return {\n //make a list of the column names to update\n setCols: cols.join(\", \"),\n //create the list of values that coorelate to the columns that are being updated\n values: Object.values(dataToUpdate),\n };\n}", "title": "" }, { "docid": "68db4056dd91f2697890fe851466bcfe", "score": "0.57230103", "text": "function sqlQuery (query1) {\n\treturn new Promise ((reso, rej) => {\n\t\tpool.query(query1,(err, result, fields) => {\n\t\t\tif (err) {\n\t\t\t\trej(err);\n\t\t\t}\n\t\t\telse {\n\t\t\t\treso(result);\n\t\t\t}\n\t\t});\n\t});\n}", "title": "" }, { "docid": "94dd06083ae55d478469c3087ccda7a6", "score": "0.57069117", "text": "function massageSQLResult(sql, insertId, rowsAffected, rows) {\n if (/^\\s*UPDATE\\b/i.test(sql)) {\n // insertId is always undefined for \"UPDATE\" statements\n insertId = void 0;\n } else if (/^\\s*CREATE\\s+TABLE\\b/i.test(sql)) {\n // WebSQL always returns an insertId of 0 for \"CREATE TABLE\" statements\n insertId = 0;\n rowsAffected = 0;\n } else if (/^\\s*DROP\\s+TABLE\\b/i.test(sql)) {\n // WebSQL always returns insertId=undefined and rowsAffected=0\n // for \"DROP TABLE\" statements. Go figure.\n insertId = void 0;\n rowsAffected = 0;\n } else if (!/^\\s*INSERT\\b/i.test(sql)) {\n // for all non-inserts (deletes, etc.) insertId is always undefined\n // ¯\\_(ツ)_/¯\n insertId = void 0;\n }\n return new WebSQLResultSet(insertId, rowsAffected, rows);\n}", "title": "" }, { "docid": "9de0955ba6feccb274856a7becbbbef2", "score": "0.56987315", "text": "insere(serie){\n\n //baseQuery(sql, params), aqui estamos passando a query e a serie que sera cadastrada\n //no banco de dados, via API.\n return baseQuery(\"INSERT INTO series SET ?\", serie)\n \n }", "title": "" }, { "docid": "10474e93c506d4a5663bd805afe46036", "score": "0.5697652", "text": "update() {\n const updates = this._prepUpdate(this.single.update);\n const where = this.where();\n let { returning } = this.single;\n const sql =\n `update ${this.tableName}` +\n ' set ' +\n updates.join(', ') +\n (where ? ` ${where}` : '');\n\n if (!returning) {\n return sql;\n }\n\n // always wrap returning argument in array\n if (!Array.isArray(returning)) {\n returning = [returning];\n }\n\n return this._addReturningToSqlAndConvert(sql, returning, this.tableName);\n }", "title": "" }, { "docid": "bc797377ca39b56a5263ce4c41f310f0", "score": "0.5691828", "text": "async update(obj) {\n\t\treturn performQuery(this._updateSql(obj), this.constructor._pool)\n\t\t\t.then(r => this.constructor.fromSQLRow(r.rows[0]));\n\t}", "title": "" }, { "docid": "aa42927889a190c757ff3a6ee0dae9fd", "score": "0.5683919", "text": "insertNewEmployee(employeeData) {\n return connection.query(\"INSERT INTO employee SET ?\", employeeData);\n }", "title": "" }, { "docid": "7a70bd013363d26027c3049aa1b47b88", "score": "0.5676722", "text": "function DBRequest (sql_request, values) {\n\treturn new Promise (function (resolve, reject) {\n\t\tconsole.log ('DB request: ' + sql_request);\n\t\tif (values) {\n\t\t\tconsole.log ('with values: ' + values);\n\t\t}\n\t\tpool.getConnection(function(err, connection) {\n \n\t\t\tconnection.query(sql_request, values, function(err, rows, fields) {\n\t\t\t\tconnection.release();\n \t\t\t\tif (err) {\n \t\t\t\t\treject (err);\n \t\t\t\t}\n \t\t\t\tconsole.log (rows, rows.insertId);\n \t\t\t\tif (sql_request.slice(0, 6) == 'INSERT') {\n \t\t\t\t\tresolve (rows.insertId);\n \t\t\t\t}\n \t\t\t\tresolve (rows);\n\t\t\t})\n\t\t})\n\t})\n}", "title": "" }, { "docid": "e5621f7148153d796fb0e3e3e7a545db", "score": "0.56744194", "text": "function SQL() {}", "title": "" }, { "docid": "e855bf79778863e2785168b693e6297c", "score": "0.5671585", "text": "lista(){\n\n //baseQuery(sql, params), aqui estamos passando a query e como nao ha necessidade\n //de passarmos algum parametro,ele sera vazio.\n return baseQuery(\"SELECT * FROM series\")\n\n }", "title": "" }, { "docid": "596cb9bb72c948e8b075226b002da5a0", "score": "0.56642723", "text": "static async select_record(relation, sql){\n //\n //Assuming the user is already logged in, add the database name to open \n //on the server\n const name = relation.entity.dbase.name;\n //\n //Fetch and wait for the response, using the (shared) index file\n const result = await mutall.fetch('database', 'get_sql_data', {name, sql});\n //\n //Use the result -- which ian array of records whose member structiire is\n //{primarykey, id} where the properties are the two key pieces \n //of a record identifier -- the primary key value and its user friendly\n //representtaion.\n const selection = await column_foreign.get_selection(relation, result);\n //\n //Return the selection, which has the formaat: {ok, primarykey, id}\n return selection;\n }", "title": "" }, { "docid": "eb935fce21a92c4c66850ac9fde697a3", "score": "0.56639993", "text": "async save() {\n\t\treturn performQuery(this._saveSql(), this.constructor._pool)\n\t\t\t.then(r => {\n\t\t\t\treturn this.constructor.fromSQLRow(r.rows[0]);\n\t\t\t});\n\t}", "title": "" }, { "docid": "9e4b149f5fb3968278d7be0c91096c2e", "score": "0.5657837", "text": "update(obj) {\n return new Promise((resolve, reject) => {\n // Cast object to separate id from other properties\n const {id, ...props} = obj;\n\n // Initialize SQL Variables\n let setProps = [];\n let setParams = [];\n\n // Iterate over props and add to SQL Variables\n for ( const prop in props ) {\n setProps.push(`${prop} = ?`);\n setParams.push(obj[prop]);\n }\n\n // Push ID last to conform to SQL query structure\n setParams.push(id);\n\n // SQL Statement\n const sql = `UPDATE ${this.getTable()} SET ${setProps.join(', ')} WHERE id = ?`;\n\n // SQL Params\n const params = setParams;\n\n // Log Objects\n const logObj = {\n obj: obj,\n props: setProps,\n params: setParams,\n }\n\n // Execute Query\n this.query(sql, params, logObj).then(() => {\n resolve(this.read(id));\n })\n });\n }", "title": "" }, { "docid": "b547a05a42a99d4d9ebd11e9567f2e39", "score": "0.56519777", "text": "function sqlForPartialUpdate(dataToUpdate, jsToSql) {\n // create an array with all keys from dataToUpdate\n const keys = Object.keys(dataToUpdate);\n //throw err if no keys are found\n if (keys.length === 0) throw new BadRequestError(\"No data\");\n\n // {firstName: 'Aliya', age: 32} => ['\"first_name\"=$1', '\"age\"=$2']\n //create an array of strings that are going to be eaqual to the keys folowed by $ and\n //index + 1 to be sql query ready\n const cols = keys.map((colName, idx) =>\n //avoid dublication betwean dataToUpdate and jsToSql\n `\"${jsToSql[colName] || colName}\"=$${idx + 1}`,\n );\n\n // return a string for the SQL query and array of parameterizing values\n return {\n setCols: cols.join(\", \"),\n values: Object.values(dataToUpdate),\n };\n}", "title": "" }, { "docid": "81c68bf1809e3b1870d70eac89b9a318", "score": "0.5651501", "text": "function insertData(dsn, no_param) {\n try {\n var date = new Date();\n console.log(\"Action insertData() was invoked at: \" + date.toLocaleString());\n\n var conn=ibmdb.openSync(dsn);\n // The timestamp value is derived from date and time values passed in\n var data=conn.querySync(\"insert into SALES(AMOUNT,PERIOD,REGION,SALES_PERSON) values(1100000,'2019Q2','USCentral','Lee'),(1400000,'2019Q2','USEast','Laura');\");\n conn.closeSync();\n \n return {result : data};\n } catch (e) {\n return { dberror : e }\n }\n}", "title": "" }, { "docid": "45d3f4fb832b6454f0dad50e1c724629", "score": "0.56433976", "text": "query(sql,variables = []) {\n\t\treturn new Promise( (resolve, reject) => {\n\t\t\tvar query = this.con.query(sql,variables,function(err,rows){\n\t\t\t\tif(err) return reject(err);\n\t\t\t\tresolve(rows);\n\t\t\t});\n\t\t\t//console.log(query.sql);\n\t\t});\n\t}", "title": "" }, { "docid": "eb148705db975177cc285116c54b8d6a", "score": "0.5637359", "text": "function DbApi() {\n return {\n getTableData,\n recheckData,\n saveRelease,\n getRowsData,\n getReleaseToGenres,\n getStatsCacheData,\n getStatsNumberData,\n getIndexData\n };\n\n function getTableData() {\n /*const oldSqlRequest = `SELECT *\n , IF(YEAR(STR_TO_DATE('date' '%M %d,%Y')) > YEAR(CURDATE()), YEAR(STR_TO_DATE('date', '%M %d,%Y')), DATE_FORMAT(STR_TO_DATE('date', '%M %d,%Y'), '%d/%m')) AS date_simple\n , IF(DATEDIFF(CURDATE(), 'added') < 2, 1, 0) AS recent\n FROM tid WHERE (genre = 'Drum & Bass' OR genre = 'Dubstep')\n AND YEAR(STR_TO_DATE('date', '%M %d,%Y')) > 2014\n AND DATEDIFF(CURDATE(), STR_TO_DATE('date', '%M %d,%Y')) <= 1\n ORDER BY genre, STR_TO_DATE('date', '%M %d,%Y')\n `;\n\n return someDb.get(oldSqlRequest);*/\n }\n\n function recheckData(ids) {\n return [\n {id: 123},\n {id: ids || 456}\n ];\n\n /*const idsList = ids.join();\n const oldSqlRequest = `SELECT id FROM tid WHERE id IN (${idsList})`;\n\n return someDb.get(oldSqlRequest);*/\n }\n\n function saveRelease({id, title, artist, genre, label, date, catalogId}) {\n return !id || {id, title, artist, genre, label, date, catalogId};\n\n /*const oldSqlRequest = `\n INSERT INTO tid(id, title, artist, genre, label, `date`, catalog_id, added)\n VALUES (${id}, ${title}, ${artist}, ${genre}, ${label}, ${date}, ${catalog_id}, NOW())\n `;\n\n return someDb.get(oldSqlRequest);*/\n }\n\n function getRowsData() {\n return {\n min: 13,\n max: 12402165,\n rows: 30\n };\n\n /*const oldSqlRequest = `SELECT COUNT(*) AS rows, MIN(id) AS min, MAX(id) AS max FROM tid`;\n return someDb.get(oldSqlRequest);*/\n }\n\n function getReleaseToGenres(limitDays, ourGenresTid) {\n const maxDate = limitDays + 1;\n const genres = ourGenresTid.join('\\' OR genre=\\'');\n\n const oldSqlRequest = `\n SELECT * FROM tid WHERE \"\n DATEDIFF(CURDATE(), 'added') < ${maxDate}\n AND (genre = '${genres}')\n AND YEAR(STR_TO_DATE('date', '%M %d,%Y')) > 2014\n ORDER BY genre, STR_TO_DATE('date', '%M %d,%Y') DESC\n `;\n\n return oldSqlRequest;\n }\n\n function getStatsCacheData() {\n const oldSqlRequest = 'SELECT id, genre FROM tid ORDER BY id';\n return oldSqlRequest;\n }\n\n function getStatsNumberData() {\n const oldSqlRequest = 'SELECT COUNT(*) AS rows, MAX(id) AS max FROM tid';\n return oldSqlRequest;\n }\n\n function getIndexData() {\n const oldSqlRequest = `\n SELECT *,\n IF (DATEDIFF(CURDATE(),'added') < 2,1,0)\n AS recent FROM tid\n WHERE (genre = 'Drum & Bass' OR genre = 'Dubstep' OR genre = 'Breaks')\n AND YEAR(STR_TO_DATE('date','%M %d,%Y')) > 2014\n AND DATEDIFF(CURDATE(), STR_TO_DATE('date', '%M %d,%Y')) <= 1\n ORDER BY genre, STR_TO_DATE('date', '%M %d,%Y') DESC\n `;\n return oldSqlRequest;\n }\n}", "title": "" }, { "docid": "d2fa16e1a3b5271a759247934aa030f5", "score": "0.5625397", "text": "processResponse(obj, runner) {\n if (obj == null) return;\n const { response } = obj;\n const { method } = obj;\n const rows = response[0];\n const fields = response[1];\n if (obj.output) return obj.output.call(runner, rows, fields);\n switch (method) {\n case 'select':\n case 'pluck':\n case 'first': {\n if (method === 'pluck') {\n return map(rows, obj.pluck);\n }\n return method === 'first' ? rows[0] : rows;\n }\n case 'insert':\n return [rows.insertId];\n case 'del':\n case 'update':\n case 'counter':\n return rows.affectedRows;\n default:\n return response;\n }\n }", "title": "" }, { "docid": "829e19e75e0921b073ccc2be3f997558", "score": "0.5623558", "text": "processResponse(obj, runner) {\n const resp = obj.response;\n if (obj.output) return obj.output.call(runner, resp);\n if (obj.method === 'raw') return resp;\n const { returning } = obj;\n if (resp.command === 'SELECT') {\n if (obj.method === 'first') return resp.rows[0];\n if (obj.method === 'pluck') return map(resp.rows, obj.pluck);\n return resp.rows;\n }\n if (returning) {\n const returns = [];\n for (let i = 0, l = resp.rows.length; i < l; i++) {\n const row = resp.rows[i];\n if (returning === '*' || Array.isArray(returning)) {\n returns[i] = row;\n } else {\n // Pluck the only column in the row.\n returns[i] = row[Object.keys(row)[0]];\n }\n }\n return returns;\n }\n if (resp.command === 'UPDATE' || resp.command === 'DELETE') {\n return resp.rowCount;\n }\n return resp;\n }", "title": "" }, { "docid": "c70924e136ab3cab7be35778b292d56e", "score": "0.56186205", "text": "addEmp(data) {\n const values = [data.first, data.last, data.role_id, data.manager_id]\n return this.db\n .promise()\n .query(`INSERT INTO employee (first_name, last_name, role_id, manager_id) VALUES(?,?,?,?)`, values )\n }", "title": "" }, { "docid": "6cd00f6a60f9478832d2d8f516b612aa", "score": "0.5613166", "text": "function getDataUpdateDB() {\n\ttry {\n\t\tvar update_list = [];\n\t\t//\n\t\t$('#table-internal-order tbody tr').each(function() {\n\t\t\tvar isCheck = $(this).find('.check-all').is(':checked');\n\t\t\tif (isCheck) {\n\t\t\t\tvar _data = {\n\t\t\t\t\tin_order_no\t\t\t\t\t: \t$(this).find('.DSP_in_order_no').text().trim(),\n\t\t\t\t\tin_order_detail_no\t\t\t: \t$(this).find('.DSP_in_order_detail_no').text().trim(),\n\t\t\t\t\tproduct_cd\t\t\t\t\t: \t$(this).find('.DSP_product_cd').text().trim(),\n\t\t\t\t\tmanufacture_qty\t\t\t\t: \t$(this).find('.TXT_manufacture_qty').val().replace(/,/g,''),\n\t\t\t\t\tremaining_qty\t\t\t\t: \t$(this).find('.DSP_hdn_remaining_qty').val().trim().replace(/,/g,''),\n\t\t\t\t\tremarks\t\t\t\t\t\t: \t$(this).find('.TXT_remarks').val()\n\t\t\t\t};\n\t\t\t\tupdate_list.push(_data);\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tvar data = {\n\t\t\tupdate_list\t\t\t: \tupdate_list\n\t\t};\n\t\treturn data;\n } catch (e) {\n console.log('getDataUpdateDB: ' + e.message);\n }\n}", "title": "" }, { "docid": "102a604b49c619cae4b6775355f8bf5f", "score": "0.5604475", "text": "static getAll(){\n // db.any returns an array of results\n // db.one will give us just the object\n return db.any(`select * from todo tod`)\n .then( (arrayOfTodo) => {\n return arrayOfTodo.map((todData) => {\n return new Todo(\n todData.id, todData.task, todData.complete, todData.user_id);\n });\n })\n .catch(() => {\n return null; // signal an invalid value\n });\n }", "title": "" }, { "docid": "5d6b20e2dd6b3e6b4fcf7440aedd0b76", "score": "0.5595147", "text": "query(options) {\n return this.connection(this.primaryConnectionName, options).query();\n }", "title": "" }, { "docid": "f7012711dfd717508bc6cec911a86860", "score": "0.5591903", "text": "function getData(query, callback) {\n connection = new Connection(config);\n connection.on('connect', function (err) {\n if (err) {\n callback(err, 'db err');\n } else {\n var request = new Request(query, function (err, rowCount, rows) {\n if (err) {\n callback(err, '');\n } else if (rowCount === 0) {\n callback(null, 'no data');\n } else {\n callback(null, rows);\n }\n });\n connection.execSql(request);\n }\n });\n}", "title": "" }, { "docid": "19526c7d6534eb7243285e19a37b93e6", "score": "0.55915457", "text": "buscaPorId(id){\n //baseQuery(sql, params), aqui estamos passando a query e o id da seria que sera\n //consultada no banco de dados, via API.\n return baseQuery(\"SELECT * FROM series WHERE id = ?\", id)\n\n }", "title": "" }, { "docid": "b4fd3344e35d695f37943919046e72b5", "score": "0.5585816", "text": "function addRow(data) {\n let insertQuery = 'INSERT INTO ?? (??,??,??,?? ) VALUES (?,?,?,?)';\n let query = mysql.format(insertQuery,[\"articulo\",\"cod\",\"nombre\",\"pvp\", \"marca\",data.cod,data.nombre,data.pvp,data.marca]);\n pool.query(query,(err, response) => {\n if(err) {\n console.error(err);\n return;\n }\n // rows added\n console.log(response.insertId);\n });\n}", "title": "" }, { "docid": "7a06848e87edce86b1c36ae81ef19bfe", "score": "0.5576372", "text": "static sqlToJs(results) {\n if (results.length < 1) return false;\n const data = results[0];\n const card = {\n id: data.id,\n title: data.title,\n rowId: data.row_id,\n colId: data.col_id,\n position: data.position,\n description: data.description,\n isArchived: Boolean(data.is_archived)\n }\n return card;\n }", "title": "" }, { "docid": "680df4390b3de3ae0662a545a090f5a0", "score": "0.5575311", "text": "processResponse(obj, runner) {\n if (obj == null)\n return;\n const response = obj.response;\n const method = obj.method;\n let rows = response[0];\n const fields = response[1];\n const bindings = response[2];\n if (obj.output)\n return obj.output.call(runner, rows, fields);\n switch (method) {\n case 'select':\n case 'pluck':\n case 'first':\n {\n const resp = helpers.skim(rows);\n if (method === 'pluck')\n return pluck(resp, obj.pluck);\n return method === 'first' ? resp[0] : resp;\n }\n case 'insert':\n {\n return bindings;\n }\n case 'del':\n case 'update':\n case 'counter':\n {\n if (rows && rows.affectedRows) {\n rows.affectedRows;\n } else {\n rows = {};\n rows.affectedRows = [0];\n }\n return rows.affectedRows;\n }\n default:\n {\n return bindings;\n }\n }\n }", "title": "" }, { "docid": "3f4be3782e7f08cb0f36f98130c8c023", "score": "0.5575274", "text": "function queryDB(tx) {\n tx.executeSql(\"SELECT * FROM DEMO\", [], querySuccess, errorCB);\n}", "title": "" }, { "docid": "a2a2ac511591b8bf5e3ee592b90266f6", "score": "0.55744994", "text": "async get(input_arr,category) {\n const t = await database.sequelize.transaction();\n try {\n let data = [];\n switch(category) {\n case 'product':\n let products = await database.product.findAll({where:{deleted:false}});\n data = products.map((product) => {\n return {\n code: product.get('code'),\n quantity: product.get('quantity'),\n price: product.get('price'),\n brand: product.get('brand')\n }\n });\n break;\n case 'customer':\n let customers = await database.customer.findAll({where:{deleted:false}});\n data = customers.map((customer) => {\n return customer.get('name');\n });\n break;\n }\n await t.commit();\n return data;\n }catch(e) {\n console.log(e);\n await t.rollback();\n throw new Error(e);\n }\n }", "title": "" }, { "docid": "0e5c60370713803f26a887aec0186c2a", "score": "0.5574473", "text": "function selectQuery() {\n return \"SELECT * FROM USERS\" \n}", "title": "" }, { "docid": "653c38144ba507a6edd019c6a69269fa", "score": "0.5568638", "text": "static async insertStudent(studData){\n const student={\n fname:studData.firstName,\n lname:studData.lastName,\n gender:studData.gender,\n address:studData.address,\n email:studData.email,\n age:studData.age,\n dob:studData.dateOfBirth,\n phone:studData.phone,\n nationality:studData.nationality,\n pwd:studData.password\n };\n await pool.query(\"INSERT INTO studdata VALUES(?,?,?,?,?,?,?,?,?,?)\",[student.email,student.fname,student.lname,student.address,student.gender,student.age,student.dob,student.phone,student.nationality,student.pwd]); \n const result=await pool.query(\"INSERT INTO student(email) VALUES (?)\",student.email);\n return {result,email:student.email,dob:student.dob};\n }", "title": "" }, { "docid": "4acf391cd2a12256ad83504b31e68b9e", "score": "0.5558455", "text": "_saveSql() {\n\t\tlet table = this.constructor.table;\n\t\tlet ifm = this.constructor._inverseFieldMap;\n\n\t\tlet thisRow = this.toSqlRow();\n\n\t\tlet q = squel.insert()\n\t\t\t.into(table.tableName);\n\n\t\tlet conflictObject = {};\n\n\t\tObject.keys(table.schema).forEach(k => {\n\t\t\tlet ik = ifm[k];\n\t\t\tq.returning(`${table.tableName}.${k}`);\n\n\t\t\tif (table.schema[k].readOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this[ik] === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this[ik] === null && table.schema[k].isPrimaryKey) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (k !== table.pkey) {\n\t\t\t\tconflictObject[k] = thisRow[k];\n\t\t\t}\n\n\t\t\tq.set(k, thisRow[k]);\n\t\t});\n\n\t\tq.onConflict(table.pkey, conflictObject);\n\n\t\treturn q;\n\t}", "title": "" }, { "docid": "d05882751700f6bd9993330c424c02ca", "score": "0.5556725", "text": "insertQuery(options) {\n return this.connection(this.primaryConnectionName, options).insertQuery();\n }", "title": "" }, { "docid": "f81d0162e8c4090c511cc090a7cff9be", "score": "0.55555475", "text": "function departmentOptions() {\n return db.promise().query('SELECT id, name FROM department') \n}", "title": "" }, { "docid": "2f5fab932566c12a286429290382ed59", "score": "0.5546105", "text": "migrateData(){\n return new Promise(async(resolve, reject) => {\n db.query('select * from records')\n .then(result => {\n if(result.length === 0)\n return reject(\"No Records Found\");\n\n let migrateQuery = \"Insert into legacyRecords (cosID,empyID,location,date) values \";\n for(let i = 0;i<result.length;i++){\n\n migrateQuery+=\"(\"+result[i].cosID+\",\"+result[i].empyID+\",\"+result[i].location+\",'\"+Util.dateToMysqlDateTime(new Date(result[i].date))+\"')\";\n if(i!==result.length-1){\n migrateQuery+=\",\"\n }\n }\n return db.query(migrateQuery);\n })\n .then(res => {\n return db.query('Delete from records where cosID > -1');\n })\n .then(_ => resolve(true))\n .catch(_ => reject(\"error during data migration\"))\n .catch(_ => reject(\"error flushing data\"))\n .catch(err =>{\n return reject(err);\n });\n });\n }", "title": "" }, { "docid": "08a6f0ddfdd55b71d73cb6bd098a12de", "score": "0.55457896", "text": "PerformQuery(queryString, inputs, callback, debug = false) {\n var options = {\n sql: queryString,\n values: inputs\n };\n var sql = this.pool.query(options, inputs, (err, results, fields) => {\n if (callback == null) {\n return;\n }\n if (err) {\n callback(null, err);\n return;\n }\n callback(results, null);\n });\n if (debug) {\n console.log(sql.sql)\n }\n }", "title": "" }, { "docid": "080cc153242e9a121580c54d14fb3109", "score": "0.55374336", "text": "function selectData(con){\n\n // command for selecting all data // you can find it on phmyadmin > SQL > select*\n let SQL_COMMAND = \"SELECT * FROM `user_list`\"\n // command for specific data // you can find it on phmyadmin > SQL > seelct\n // let SQL_COMMAND = \"SELECT `name` FROM `user_list` WHERE `user_list`.`id` = '5'\"\n\n con.query(SQL_COMMAND, function(err, result){\n\n if(err){\n console.log(\"Facing error to selecting data\")\n }else{\n console.log(\"Data selected\")\n // it's return a JSON file\n console.log(result)\n\n // converting JSON to string\n var resultString = JSON.stringify(result);\n console.log(\"Result as a string: \"+ resultString)\n }\n\n })\n\n}", "title": "" }, { "docid": "9ff6bdd355b86f9e99516132a61e9c86", "score": "0.5535447", "text": "async Getdata() {\n try {\n var sql = `SELECT * FROM ${this.db}.employee_tbl`;\n let empData = await this.dao.executeQuery(sql);\n return empData\n }\n catch (e) {\n console.log(e)\n return false\n }\n }", "title": "" }, { "docid": "e29b9d2e6f46df3d86b1b6036213fa7f", "score": "0.5533166", "text": "insert(sql = '', values = []) {\n values = Array.isArray(values) === false ? [values] : values;\n return new Promise((resolve, reject) => {\n this.conexion.query(sql, values, (err, result, fields) => {\n if (err) {\n reject(err);\n } else {\n resolve(result);\n }\n });\n });\n }", "title": "" }, { "docid": "c2a068af2452ba1ee84de3e801e7e320", "score": "0.5528186", "text": "update() {\n const top = this.top();\n const withSQL = this.with();\n const updates = this._prepUpdate(this.single.update);\n const join = this.join();\n const where = this.where();\n const order = this.order();\n const { returning } = this.single;\n return {\n sql:\n withSQL +\n `update ${top ? top + ' ' : ''}${this.tableName}` +\n ' set ' +\n updates.join(', ') +\n (returning ? ` ${this._returning('update', returning)}` : '') +\n (join ? ` from ${this.tableName} ${join}` : '') +\n (where ? ` ${where}` : '') +\n (order ? ` ${order}` : '') +\n (!returning ? this._returning('rowcount', '@@rowcount') : ''),\n returning: returning || '@@rowcount',\n };\n }", "title": "" }, { "docid": "3fd02bbd588e0ca78c03f3cb95d9b85d", "score": "0.55088896", "text": "function sqlForPartialUpdate(dataToUpdate, jsToSql) {\n \n // Makes an array of keys from the keys in the data to update\n const keys = Object.keys(dataToUpdate);\n\n // Throws an error if no data has been passed in\n if (keys.length === 0) throw new BadRequestError(\"No data\");\n\n // cols is an array of strings (the keys in keys array and the SQL value number) created from the keys array.\n // The keys array is mapped with either the jsToSQL or the column name in the data\n // This is then paired with the index number translated to the SQL query\n // See an example below\n const cols = keys.map((colName, idx) =>\n `\"${jsToSql[colName] || colName}\"=$${idx + 1}`,\n );\n // {firstName: 'Aliya', age: 32} => ['\"first_name\"=$1', '\"age\"=$2']\n\n // Returns and object with two key:values\n // setCols is a string of the column names/SQL numbers in the SQL databases where data is to be changed\n // values is an array of the values to be updated\n return {\n setCols: cols.join(\", \"),\n values: Object.values(dataToUpdate),\n };\n}", "title": "" }, { "docid": "bf8ee3ac64ef8434ce87dce74b7f17ba", "score": "0.55048245", "text": "function postService(url,sqlQuery,data) {\n\n app.post(url, function (req, res, next) {\n try {\n var reqObj = req.body;\n req.getConnection(function (err, conn) {\n if (err) {\n console.error('SQL Connection error: ', err);\n return next(err);\n }\n else {\n var insertSql = sqlQuery;\n var insertValues = {};\n for (var i=0;i<data.length;i++) {\n insertValues [data[i]]= reqObj[data[i]];\n }\n\n var query = conn.query(insertSql, insertValues, function (err, result) {\n if (err) {\n console.error('SQL error: ', err);\n return next(err);\n }\n console.log(result);\n var name_Id = result.insertId;\n res.json({\"name\": name_Id});\n\n });\n }\n });\n }\n catch (ex) {\n console.error(\"Internal error:\" + ex);\n return next(ex);\n }\n });\n}", "title": "" }, { "docid": "3e48e2bc92b1a2d604af7136af3ded69", "score": "0.55038697", "text": "function executeQuery(res, query)\r\n{ \r\n\tvar conn = new sql.Connection(config);\r\n conn.connect().then(function () {\r\n var request = new sql.Request(conn);\r\n\t\trequest.query(query)\r\n\t\t.then(function (result) {\r\n // console.log(result);\r\n\t\t\tconn.close();\r\n\t\t\tres.send(result);\r\n }).catch(function (err) {\r\n\t\t\tconn.close();\r\n\t\t\tres.send(err);\r\n });\r\n }).catch(function (err) {\r\n\t\tres.send(err);\r\n }); \r\n}", "title": "" }, { "docid": "e1220c36f12123bcd9130472e876e432", "score": "0.55035865", "text": "function insSQL(){\n var sql = 'INSERT INTO pim_transfers(';\n sql += 'user_id, manufacturer_id, from_id, to_id, products, status_id, delivery_date, type_id, notes)VALUES(';\n sql += '$1::integer, $2::integer, $3::integer, $4::integer, $5::json, $6::integer,';\n sql += ' $7::timestamp without time zone, $8::integer, $9::json) RETURNING id;';\n return sql;\n}", "title": "" }, { "docid": "5f9322cf20c9f78313ad5ce618e4a301", "score": "0.5499115", "text": "async function run() {\n\n let connection;\n\n try {\n connection = await oracledb.getConnection(dbConfig);\n\n const result = await connection.execute(\n `SELECT last_name, hire_date, salary, commission_pct\n FROM employees\n WHERE employee_id = :id`,\n [178],\n {\n fetchInfo :\n {\n \"HIRE_DATE\": { type : oracledb.STRING }, // return the date as a string\n \"COMMISSION_PCT\": { type : oracledb.DEFAULT } // override oracledb.fetchAsString\n }\n });\n\n console.log(result.rows);\n\n } catch (err) {\n console.error(err);\n } finally {\n if (connection) {\n try {\n await connection.close();\n } catch (err) {\n console.error(err);\n }\n }\n }\n}", "title": "" }, { "docid": "49b105715b716fd815c9eb9916ffca5e", "score": "0.5497347", "text": "async get() {\n let record = await this.db.query(`\n SELECT ?\n `, ['1'])\n return record\n }", "title": "" }, { "docid": "fef30963111aa3df2870a81201722e52", "score": "0.54954344", "text": "function SqlResult() {\n this.columns = [];\n this.rows = [];\n }", "title": "" }, { "docid": "ffef12a108458337f8b97fdf73487f95", "score": "0.5492484", "text": "function retrieveOrInsert(dataObject, next, success, fail) {\n const context = Context.fromFunc(success);\n function s(found) {success(found)}\n const onFail = fail || sqlErrorFunc(next, 'insert', dataObject);\n context.callbackTree(crud.selectOne, 'retrieveOrInsertDataObject', dataObject)\n .success(s)\n .fail(crud.insert, 'insert', dataObject)\n .success('insert', crud.selectOne, 'select', dataObject)\n .success('select', s)\n .fail('insert', onFail)\n .execute();\n}", "title": "" }, { "docid": "2cdf69d189181eac990f80c0b9a9de76", "score": "0.549203", "text": "function mk_update_query(o,o2) {\n //console.log('o:',o)\n //console.log('o2:',o2)\n const props = (({\n parent_id, name, locale, live_revision, latest_revision, publish_status, content_type\n }) => ({\n parent_id, name, locale, live_revision, latest_revision, publish_status, content_type\n }))(o);\n\n _assert(Object.keys(props).length ===7, props, \"CORRUPTED\")\n\n const data = [];\n const _query = [];\n\n Object.keys(props).forEach(key =>{\n if ((props[key] != undefined)&&(props[key] != o2[key])) {\n // could be null...\n data.push(props[key]);\n _query.push(`${key} = \\$${data.length}`)\n }\n })\n\n //console.log(`[content_item__update] _query: ${_query.join(', ')}`);\n //console.log(`[content_item__update] data: `,data);\n\n if (data.length >0) {\n data.push(o.item_id);\n\n const query = `\n update cr_items set ${_query} where item_id = \\$${data.length}\n returning item_id\n `;\n\n return {query, data};\n } else {\n return {query:null, data:null}\n }\n}", "title": "" }, { "docid": "27ec9a4137a96be32fcfbbfb37f4af52", "score": "0.5491508", "text": "get(sql = '', values = []) {\n values = Array.isArray(values) === false ? [values] : values;\n return new Promise((resolve, reject) => {\n let resultado = null;\n this.conexion.query({\n sql,\n values\n },\n (err, result, fields) => {\n if (err) {\n reject(resultado);\n } else {\n resultado = result;\n resolve(resultado);\n }\n }\n );\n });\n }", "title": "" }, { "docid": "cee517f54463b281d76e12b9b0067a2c", "score": "0.5485595", "text": "update(sql = '', values = []) {\n values = Array.isArray(values) === false ? [values] : values;\n return new Promise((resolve, reject) => {\n this.conexion.query(sql, values, (err, result, fields) => {\n if (err) {\n reject(err);\n } else {\n resolve(result);\n }\n });\n });\n }", "title": "" }, { "docid": "989bf3400c3dc76a959209994459b861", "score": "0.54843444", "text": "create(object) {\n return new Promise((resolve, reject) => {\n // Validate Object before creation\n const objErrors = this.getErrors(object);\n if (objErrors) {\n reject(console.log(\"objErrors\", objErrors));\n }\n \n // SQL Statement: Insert into table row\n const sql = `INSERT INTO ${this.getTable()} (${this.getParams()}) VALUES (${this.getReplaced(object)})`;\n\n // SQL Params\n const params = this.getValues(object);\n\n // Log Objects\n const logObj = {\n klass: this,\n object: object\n }\n\n this.query(sql, params, logObj).then(result => {\n resolve(this.read(result.insertId));\n });\n });\n }", "title": "" }, { "docid": "c76a3028f035b8f69ff30b611ef63c38", "score": "0.54831886", "text": "static async update(pk, data) {\n let { query, values } = sqlForPartialUpdate(tableName, data, pk, pkvalue)\n let result = await db.query(query, values);\n if (result.rows.length === 0) {\n const err = new Error(`No ${tableName} found`);\n err.status = 404;\n throw err;\n }\n return result.rows[0]\n }", "title": "" }, { "docid": "2376999b4440cb364dac251a62d690c1", "score": "0.5479558", "text": "getBikesT2(success) {\r\n connection.query('select * from Bike where FK_BikeTypeID = 2', (error, results) => {\r\n if (error) return console.error(error);\r\n\r\n success(results);\r\n });\r\n }", "title": "" }, { "docid": "e5617a659927b3959a693fdf86154433", "score": "0.54666835", "text": "function sqlForPartialUpdate(dataToUpdate, jsToSql) {\n // example of dataToUpdate = {name, description, numEmployees, logoUrl}\n // makes an array of the keys from the data we want to update which should be a column name\n const keys = Object.keys(dataToUpdate);\n // if the value here is 0 that means there is no columns that are trying to be updated and we throw an error\n if (keys.length === 0) throw new BadRequestError(\"No data\");\n\n // {firstName: 'Aliya', age: 32} => ['\"first_name\"=$1', '\"age\"=$2']\n // make an array of the specific columns that we want to update\n const cols = keys.map((colName, idx) =>\n // checks to see which format the column name is in, accepts the first one to be true which should be in sql underscore format\n `\"${jsToSql[colName] || colName}\"=$${idx + 1}`,\n );\n // we return the columns after joining them as a string so we can insert them into our sql query in the SET portion\n // we should end up with SET $1,$2,$3 depending on how many fields are being updated\n\n return {\n setCols: cols.join(\", \"),\n\n values: Object.values(dataToUpdate),\n };\n}", "title": "" }, { "docid": "e7cb5d63f870fa9e8f04975b61e0674c", "score": "0.546066", "text": "async exec(sql, params){\n try{\n return await this._exec(sql, params);\n }catch(e){\n this.error = e.message;\n return null;\n }\n }", "title": "" }, { "docid": "209d3e3fcd6046cd178791b5339f0955", "score": "0.5459963", "text": "create(connectionName, table, data, cb) {\n let connectionObject = this.connections.get(connectionName)\n let collection = connectionObject.collections[table];\n\n let schemaName = collection.meta && collection.meta.schemaName ? utils.escapeName(collection.meta.schemaName) + '.' : '';\n let tableName = schemaName + utils.escapeName(table);\n\n // Build up a SQL Query\n let schema = connectionObject.schema;\n //var processor = new Processor(schema);\n\n // Prepare values\n Object.keys(data).forEach(function(value) {\n data[value] = utils.prepareValue(data[value]);\n });\n\n const definition = collection.definition\n _.each(definition, (column, name) => {\n\n if (fieldIsBoolean(column)) {\n // no boolean type in oracle, so save it as a number\n data[name] = (data[name]) ? 1 : 0\n }\n\n })\n\n let sequel = new Sequel(schema, this.sqlOptions)\n\n let incrementSequences = [];\n let query;\n\n try {\n query = sequel.create(table, data);\n } catch (e) {\n return cb(e);\n }\n\n let returningData = utils.getReturningData(collection.definition)\n\n let queryObj = {}\n\n if (returningData.params.length > 0) {\n query.query += ' RETURNING ' + returningData.fields.join(', ') + ' INTO ' + returningData.outfields.join(', ')\n query.values = query.values.concat(returningData.params)\n queryObj.outFormat = oracledb.OBJECT\n }\n\n queryObj.sql = query.query\n queryObj.params = query.values\n\n this.executeQuery(connectionName, queryObj, (err, results) => {\n if (err) return cb(err)\n cb(null, utils.transformBulkOutbinds(results.outBinds, returningData.fields)[0])\n })\n }", "title": "" }, { "docid": "b8497e3afd65e6cff0f88f1e2334040e", "score": "0.54472333", "text": "exec(sql) {\n return new this.Promise((resolve, reject) => {\n this.driver.exec(sql, err => {\n if (err) {\n reject(err);\n } else {\n resolve(this);\n }\n });\n });\n }", "title": "" }, { "docid": "1617f93ff42d7d3b23ec57eef578d831", "score": "0.54472166", "text": "function fetchFromDB(id,table, columns){\n\tvar queryObj = {'QUERY':[{'columns':columns,'table':table,'where':table+'Id IN ('+id+')'}]};\n\tvar queryStr = JSON.stringify(queryObj);\n\tvar URL= getURL('ADMIN3','JSON')+ \"action=guiDbQuery&query=\"+queryStr+\"&version=3.0\";\n\tvar arr_col = columns.split(\",\");\n\tvar ret_arr = new Array();\n $.ajax({\n url: URL,\n dataType: 'html',\n\t\tasync: false,\n success: function(data) {\n\t\t\tvar mydata = data.replace(/'/g,'\"');\n\t\t\tvar jsonData = jQuery.parseJSON(mydata);\n\t\t\tvar row = jsonData.data[0].row;\n\t\t\tfor(var a=0; a<row.length; a++){\n\t\t\t\tfor(var b=0; b<arr_col.length; b++){\n\t\t\t\t\tvar arr_ind = arr_col[b];\n\t\t\t\t\tvar str = arr_col[b]+\":\"+row[a][arr_ind];\n\t\t\t\t\tret_arr.push(str);\n\t\t\t\t}\n\t\t\t}\n }\n });\n\treturn ret_arr;\n}", "title": "" }, { "docid": "e612d588fac657c2e4d4cce93fdd8698", "score": "0.5446245", "text": "static fetchOne(id){\r\n return db.execute(\"SELECT * FROM Asistencia where Empleado_idEmpleado =?\",[id]);\r\n}", "title": "" }, { "docid": "81eeda10781956471a443812ee7a44d5", "score": "0.5442272", "text": "productById(id) {\r\n console.log(id);\r\n return new Promise((resolve) => {\r\n this.initDB().then((db) => {\r\n db.transaction((tx) => {\r\n \r\n tx.executeSql('SELECT * FROM Product WHERE prodId = ?', [id]).then(([tx,results]) => {\r\n console.log(results);\r\n if(results.rows.length > 0) {\r\n let row = results.rows.item(0);\r\n resolve(row);\r\n }\r\n });\r\n }).then((result) => {\r\n this.closeDatabase(db);\r\n }).catch((err) => {\r\n console.log(err);\r\n });\r\n }).catch((err) => {\r\n console.log(err);\r\n });\r\n }); \r\n }", "title": "" }, { "docid": "761395913faf9e5fb595148780e472a8", "score": "0.5440096", "text": "async function saveData(data) { \n\ttry { \n\t\tif(data){ \n\t\t\tvar sql='INSERT INTO '+table+' set ? ';\n\t\t\treturn new Promise((resolve,reject)=>{\n\t\t\t\tconnectPool.query(sql,data, (err, result) => {\n\t\t\t\t\tif (err) { \n\t\t\t\t\t\tconsole.log(data);\n\t\t\t\t\t\treject(err)\n\t\t\t\t\t} else { \n\t\t\t\t\t\tresolve(result)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}) \n\t\t}else{ \n\t\t\treturn null;\n\t\t}\n\t} finally {\n\t\t//if (connectPool && connectPool.end) connectPool.end();\n\t} \n}", "title": "" }, { "docid": "761395913faf9e5fb595148780e472a8", "score": "0.5440096", "text": "async function saveData(data) { \n\ttry { \n\t\tif(data){ \n\t\t\tvar sql='INSERT INTO '+table+' set ? ';\n\t\t\treturn new Promise((resolve,reject)=>{\n\t\t\t\tconnectPool.query(sql,data, (err, result) => {\n\t\t\t\t\tif (err) { \n\t\t\t\t\t\tconsole.log(data);\n\t\t\t\t\t\treject(err)\n\t\t\t\t\t} else { \n\t\t\t\t\t\tresolve(result)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}) \n\t\t}else{ \n\t\t\treturn null;\n\t\t}\n\t} finally {\n\t\t//if (connectPool && connectPool.end) connectPool.end();\n\t} \n}", "title": "" }, { "docid": "0e52aa9ff0899d21502e9cefa7fab77c", "score": "0.54370445", "text": "function sqlForPartialUpdate(dataToUpdate, jsToSql) {\n const keys = Object.keys(dataToUpdate);\n if (keys.length === 0) throw new BadRequestError('No data');\n\n // {firstName: 'Aliya', age: 32} => ['\"first_name\"=$1', '\"age\"=$2']\n // Each Object Key will represent a SQL Column to Update and will be converted appropriately to $1, $2, etc\n const cols = keys.map(\n (colName, idx) => `\"${jsToSql[colName] || colName}\"=$${idx + 1}`\n );\n\n return {\n setCols: cols.join(', '),\n values: Object.values(dataToUpdate),\n };\n}", "title": "" }, { "docid": "28c871d66fe62e985fb18caa2f987923", "score": "0.54337007", "text": "selectModelById(sqldb, input) {\n return __awaiter(this, void 0, void 0, function* () {\n let model = new this.type();\n try {\n const row = yield sqldb.get(this.getSelectByIdStatement(), this.bindPrimaryKeyInputParams(input));\n model = this.updateModelFromRow(model, row);\n }\n catch (e /* istanbul ignore next */) {\n return Promise.reject(new Error(`select '${this.table.name}' failed: ${e.message}`));\n }\n return model;\n });\n }", "title": "" }, { "docid": "40dd6cb580a44a365723b73a862af1c0", "score": "0.5425825", "text": "getBikesT4(success) {\r\n connection.query('select * from Bike where FK_BikeTypeID = 4', (error, results) => {\r\n if (error) return console.error(error);\r\n\r\n success(results);\r\n });\r\n }", "title": "" }, { "docid": "05162cf776014d9db2bddf9fe5856629", "score": "0.5416059", "text": "getBikesT3(success) {\r\n connection.query('select * from Bike where FK_BikeTypeID = 3', (error, results) => {\r\n if (error) return console.error(error);\r\n\r\n success(results);\r\n });\r\n }", "title": "" }, { "docid": "122bec220d0a9fd5b1ffc7953c40de73", "score": "0.5414221", "text": "query(query) {\n return null;\n }", "title": "" } ]
4060c071fd4187e6dfebe7cdf524e3e1
node_modules/sveltegooglemaps/Marker.html generated by Svelte v1.64.1
[ { "docid": "78ffeb908250ac72406e2e315df8239e", "score": "0.0", "text": "function data$2() {\n\treturn { marker: deferred$1() };\n}", "title": "" } ]
[ { "docid": "dfeb6ec2d71e8f66de760018485d08f3", "score": "0.6414842", "text": "function render_map( $el ) {\n\t/*\n\tvar head = document.getElementsByTagName('head')[0];\n\n\t// Save the original method\n\tvar insertBefore = head.insertBefore;\n\n\t// Replace it!\n\thead.insertBefore = function (newElement, referenceElement) {\n\n\t if (newElement.href && newElement.href.indexOf('//fonts.googleapis.com/css?family=Roboto') > -1) {\n\n\t console.info('Prevented Roboto from loading!');\n\t return;\n\t }\n\n\t insertBefore.call(head, newElement, referenceElement);\n\t};\n\t*/\n\n\t// var\n\tvar $markers = $el.find('.marker');\n\n\t//Styling of the maps\n\tvar stylesArray = [\n {\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#212121\"\n }\n ]\n },\n {\n \"elementType\": \"geometry.fill\",\n \"stylers\": [\n {\n \"color\": \"#131314\"\n }\n ]\n },\n {\n \"elementType\": \"labels.icon\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n }\n ]\n },\n {\n \"elementType\": \"labels.text.stroke\",\n \"stylers\": [\n {\n \"color\": \"#212121\"\n }\n ]\n },\n {\n \"featureType\": \"administrative\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n },\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.country\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#4c4c50\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.country\",\n \"elementType\": \"labels.text.stroke\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.land_parcel\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.locality\",\n \"stylers\": [\n {\n \"visibility\": \"simplified\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.locality\",\n \"elementType\": \"geometry.fill\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.locality\",\n \"elementType\": \"geometry.stroke\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.locality\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#4c4c50\"\n }\n ]\n },\n {\n \"featureType\": \"poi\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"poi\",\n \"elementType\": \"labels.text\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"poi\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n }\n ]\n },\n {\n \"featureType\": \"poi.park\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"road\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"road\",\n \"elementType\": \"geometry.fill\",\n \"stylers\": [\n {\n \"color\": \"#2c2c2c\"\n }\n ]\n },\n {\n \"featureType\": \"road\",\n \"elementType\": \"labels.icon\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"road\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#8a8a8a\"\n }\n ]\n },\n {\n \"featureType\": \"road.arterial\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#373737\"\n }\n ]\n },\n {\n \"featureType\": \"road.highway\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#3c3c3c\"\n }\n ]\n },\n {\n \"featureType\": \"road.highway.controlled_access\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#4e4e4e\"\n }\n ]\n },\n {\n \"featureType\": \"road.local\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"road.local\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#616161\"\n }\n ]\n },\n {\n \"featureType\": \"transit\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"transit\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n }\n ]\n },\n {\n \"featureType\": \"water\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#232323\"\n }\n ]\n },\n {\n \"featureType\": \"water\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#4d4d4d\"\n }\n ]\n }\n];\n\n\t// vars\n\tvar args = {\n\t\tzoom\t\t: 2,\n\t\tcenter\t\t: new google.maps.LatLng(0, 0),\n\t\tmapTypeId\t: google.maps.MapTypeId.ROADMAP,\n\t\tstyles: stylesArray,\n\t\tdisableDefaultUI: false,\n\t\tscrollwheel: false,\n\t\tdraggable: true,\n\t\tzoomControl: true,\n\t\tzoomControlOptions: {\n position: google.maps.ControlPosition.BOTTOM_LEFT\n },\n\t\tminZoom: 2,\n\t mapTypeControl: false,\n\t scaleControl: false,\n\t streetViewControl: false,\n\t rotateControl: false,\n\t fullscreenControl: false\n\t};\n\n\t// create map\n\tvar map = new google.maps.Map( $el[0], args);\n\n\t// add a markers reference\n\tmap.markers = [];\n\n\t// add markers\n\t$markers.each(function(){\n\n \tadd_marker( $(this), map );\n\n\t});\n\t//var markerCluster = new MarkerClusterer(map, markers, {imagePath: 'images/m'});\n\t// center map\n\tcenter_map( map );\n\t//var markerCluster = new MarkerClusterer(map, markers);\n\n\n\t//Prevent dragging into a grey area\n\tgoogle.maps.event.addListener(map, 'bounds_changed', function(){\n\n\n\t var proj =map.getProjection();\n\t var bounds = map.getBounds();\n\t var sLat = map.getBounds().getSouthWest().lat();\n\t var nLat = map.getBounds().getNorthEast().lat();\n\t if (sLat < -85 || nLat > 85) {\n // console.log('Gray area visible');\n map.setOptions({\n center: lastValidCenter\n });\n } else {\n lastValidCenter = bounds.getCenter();\n }\n\t});\n\n\n}", "title": "" }, { "docid": "a10545d6431c0b31275202f5f330638c", "score": "0.6056098", "text": "function renderMarkers(map, maps, myLatLng) {\n let marker = new maps.Marker({\n position: myLatLng,\n map,\n title: 'Hello World!'\n });\n }", "title": "" }, { "docid": "59eab66bf4e7519d5d7bcfa3d6a99b37", "score": "0.5948094", "text": "createMarkerInfoWindow(e, map, title) {\n const infoWindow = new window.google.maps.InfoWindow({\n content: '<div id=\"infoWindow\" />',\n position: { lat: e.latLng.lat(), lng: e.latLng.lng() }\n })\n infoWindow.addListener('domready', e => {\n render(<InfoWindow title={title} />, document.getElementById('infoWindow'))\n })\n infoWindow.open(map)\n\n }", "title": "" }, { "docid": "d24b24ae821c538b373126ba2f71c040", "score": "0.589849", "text": "renderMap(){\n GoogleMaps.load((google) => {\n let map = ReactDOM.findDOMNode(this.refs.map);\n let coords = this.position ? this.position.coords : null;\n let center = (coords) ? new google.maps.LatLng(parseFloat(coords.latitude).toFixed(2), parseFloat(coords.longitude).toFixed(2)) : null;\n let mapElement = new google.maps.Map(map, {\n center: center,\n zoom: 18,\n mapTypeId: google.maps.MapTypeId.ROADMAP\n });\n\n // marker\n new google.maps.Marker({\n position : center,\n map : mapElement\n });\n });\n }", "title": "" }, { "docid": "4a9774c68d3e13b3ead82b9ffbd0f157", "score": "0.5822119", "text": "function initDeviceMap() {\n // Variables assigned in script in html template\n var location = {lat: lat, lng: lng};\n var map = new google.maps.Map(document.getElementById('map-device'), {\n zoom: 10,\n center: location,\n });\n var marker = new google.maps.Marker({\n position: location,\n map: map\n });\n}", "title": "" }, { "docid": "4ebc443be390931072bc56317bf11cee", "score": "0.57244146", "text": "async function startMap() {\n\nmymap = L.map('issMap').setView([10.92166,-74.80560], 13);\n\nconst attribution= '&copy; <a href=\"https://www.openstreetmap.org/\">OpenStreetMap</a> contributors';\n\nconst tileUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';\n\t\t\t\t\nconst tiles = L.tileLayer(tileUrl,{attribution}).addTo(mymap);\n\nvar marker ={};\n\nmarker= L.marker([10.92166,-74.80560]);\n\nlivemarker[0]=marker;\n\nlivemarker[0].addTo(mymap);\n\n\n\n//CALL FUNCTIONS\nawait updateMarker();\n}", "title": "" }, { "docid": "0c91c83bdd87a70833cfa97aaf08fdd8", "score": "0.57179725", "text": "createMapS() {\n let mapScript = document.createElement('script');\n const API_KEY = 'AIzaSyCbGGWY4jFTTTaQJC5hJvHoOFfRwiHxsOM';\n mapScript.src = `https://maps.googleapis.com/maps/api/js?key=${API_KEY}&callback=initMap`;\n mapScript.async = true;\n mapScript.defer = true;\n return mapScript;\n }", "title": "" }, { "docid": "0ac2bf2829fcac18fbbbdf55d8ceb7ce", "score": "0.5706847", "text": "function addMapToPage() {\n\n\n const script = document.createElement('script');\n script.src = `https://maps.googleapis.com/maps/api/js?key=AIzaSyD6h8yj2Jd7-8q6lcxifInxtR8Ptv3aztg&callback=initMap`;\n script.defer = true;\n script.async = true;\n window.initMap = initMap;\n document.head.appendChild(script);\n // });\n}", "title": "" }, { "docid": "859f4524c94732b6449cf302ab2b1825", "score": "0.5666323", "text": "render(){\n /**\n * `render` must return a lit-html `TemplateResult`.\n *\n * To create a `TemplateResult`, tag a JavaScript template literal\n * with the `html` helper function:\n */\n return html`\n <style>\n svg {\n display: block;\n margin-left: auto;\n margin-right: auto;\n height: 3.75rem;\n width: auto;\n }\n </style>\n <!-- template content -->\n ${iconMap[this.icon]}\n `;\n }", "title": "" }, { "docid": "54a7f57c3ea373a5d295585709408ef1", "score": "0.5650974", "text": "function addMapToPage() {\n\n const script = document.createElement('script');\n script.src = `https://maps.googleapis.com/maps/api/js?key=AIzaSyD6h8yj2Jd7-8q6lcxifInxtR8Ptv3aztg&callback=initMap`;\n script.defer = true;\n script.async = true;\n window.initMap = initMap;\n document.head.appendChild(script);\n // });\n}", "title": "" }, { "docid": "973ae948600e3d9a07daba788d8f2f3a", "score": "0.5622293", "text": "function renderMarker(latLng, map) {\n var marker = new google.maps.Marker({position: latLng, map:\n map});\n markers.push(marker);\n}", "title": "" }, { "docid": "37067f4082449d0e55f84496c5405f0b", "score": "0.5621884", "text": "render() {\n // TODO add http://schema.org/docs/gs.html\n let scale = this.props.$hover ? K_SCALE_HOVER : this.props.scale;\n scale = this.props.hoveredAtList ? K_SCALE_TABLE_HOVER : 0.65;\n\n const markerHolderStyle = getMarkerHolderStyle(this.props.size, this.props.origin);\n const markerStyle = getMarkerStyle(this.props.size, this.props.origin);\n\n const zIndexStyle = {\n zIndex: Math.round(scale * 10000) - (this.props.showBallon ? 20 : 0) + (this.props.$hover ? K_HINT_HTML_DEFAULT_Z_INDEX : 0) // balloon\n };\n\n const textStyleDef = getMarkerTextStyle();\n const textStyle = calcMarkerTextStyle(scale, textStyleDef);\n\n\n const imageClass = this.props.image ? '' : this.props.imageClass;\n const imageStyle = this.props.image ? {\n backgroundImage: `url(${this.props.image})`\n } : null;\n\n const styleMarkerMarker = calcMarkerMarkerStyle(scale, zIndexStyle, markerStyle, imageStyle);\n\n // css hints library https://github.com/istarkov/html-hint\n return (\n <div style={markerHolderStyle} className='map-marker'>\n <div\n style={styleMarkerMarker}\n className={cx('map-marker__marker', imageClass)}>\n {this.props.withText ?\n <div style={textStyle}>\n {this.props.marker['number']}\n </div>\n :\n <div/>}\n </div>\n </div>\n );\n }", "title": "" }, { "docid": "ca828396057b5b9a6254aadc467d87d3", "score": "0.5609505", "text": "function createMap() {\n const map = new google.maps.Map(\n document.getElementById('map'),\n {center: {lat: 31.779, lng: 35.224}, zoom: 13, mapTypeId: 'hybrid'});\n \n addMapMarker(map, 31.784, 35.212, \"Machane Yehuda Market\", \"The most famous market of jerusalem - 'The Shuk'.\");\n addMapMarker(map, 31.774, 35.177, \"Mt. Herzl\", \"A beautiful place where official ceremonies often take place.\");\n addMapMarker(map, 31.776, 35.234, \"The Old City\", \"Everything about this place is special. The Western Wall, the old houses, the people and everything else.\");\n addMapMarker(map, 31.78008, 35.205, \"Sacher Park\", \"A nice park good for a run, a BBQ or just for hanging out with friends.\");\n addMapMarker(map, 31.751, 35.187, \"Malcha Mall\", \"The biggest mall in Jerusalem.\");\n}", "title": "" }, { "docid": "ba8d2b1a33aeb73295e5be48857bd8a2", "score": "0.56049025", "text": "function main() {\n const ironhackBCN = {\n lat: 41.3977381,\n lng: 2.190471916\n };\n const map = new google.maps.Map(document.getElementById(\"map\"), {\n zoom: 15,\n center: ironhackBCN\n });\n // This event listener calls addMarker() when the map is clicked.\n // google.maps.event.addListener(map, \"click\", function(event) {\n // addMarker(event.latLng, map);\n // });\n // // Add a marker at the center of the map.\n // addMarker(ironhackBCN, map);\n\n // // Adds a marker to the map.\n // function addMarker(location, map) {\n // // Add the marker at the clicked location, and add the next-available label\n // // from the array of alphabetical characters.\n // var marker = new google.maps.Marker({\n // position: location,\n // label: labels[labelIndex++ % labels.length],\n // map: map\n // });\n // }\n}", "title": "" }, { "docid": "3d85659957c84c0b20b9a6513820a57a", "score": "0.5594202", "text": "function renderMarker(marker) {\n\t\tpoly.$.map.appendChild(marker);\n\t}", "title": "" }, { "docid": "8e9c92b1af083a1dc6f23916e753a63c", "score": "0.5562969", "text": "function add_marker( $marker, map ) {\n\n // var\n var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );\n\n var template = [\n '<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:a=\"http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/\" x=\"0px\" y=\"0px\" width=\"15.2px\" height=\"35.1px\" viewBox=\"0 0 15.2 35.1\" style=\"enable-background:new 0 0 15.2 35.1;\" xml:space=\"preserve\">',\n '<style type=\"text/css\">',\n '.st0{clip-path:url(#SVGID_2_);fill:#fbf0e8;}',\n '.st1{clip-path:url(#SVGID_2_);fill:none;stroke:#64aaa7;}',\n '.st2{clip-path:url(#SVGID_2_);fill:none;stroke:#fbf0e8;stroke-width:1.563;}',\n '.st3{clip-path:url(#SVGID_4_);fill:#fbf0e8;}',\n '.st4{clip-path:url(#SVGID_4_);fill:none;stroke:#F5C7BA;}',\n '.st5{clip-path:url(#SVGID_4_);fill:none;stroke:#fbf0e8;stroke-width:1.563;}',\n '</style>',\n '<g>',\n '<defs>',\n '<rect id=\"SVGID_1_\" width=\"15.2\" height=\"35.1\"/>',\n '</defs>',\n '<clipPath id=\"SVGID_2_\">',\n '<use xlink:href=\"#SVGID_1_\" style=\"overflow:visible;\"/>',\n '</clipPath>',\n '<path class=\"st0\" d=\"M7.6,14.7c3.9,0,7.1-3.2,7.1-7.1s-3.2-7.1-7.1-7.1S0.5,3.7,0.5,7.6S3.7,14.7,7.6,14.7\"/>',\n '<circle class=\"st1\" cx=\"7.6\" cy=\"7.6\" r=\"7.1\"/>',\n '<line class=\"st2\" x1=\"7.6\" y1=\"35.1\" x2=\"7.6\" y2=\"1.6\"/>',\n '</g>',\n '</svg>'\n ].join('\\n');\n\n var svgWidth = 0,\n svgHeight = 0;\n\n if ($(window).width() >= 1500) {\n svgWidth = 30;\n svgHeight = 72;\n } else if($(window).width() >= 1200) {\n svgWidth = 27.5;\n svgHeight = 66;\n } else if($(window).width() >= 992) {\n svgWidth = 25;\n svgHeight = 60;\n } else if($(window).width() >= 768) {\n svgWidth = 22.5;\n svgHeight = 54;\n } else if($(window).width() >= 576) {\n svgWidth = 20;\n svgHeight = 48;\n } else {\n svgWidth = 17.5;\n svgHeight = 42;\n }\n\n // create marker\n var marker = new google.maps.Marker({\n position : latlng,\n map : map,\n icon: { url: 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(template), scaledSize: new google.maps.Size(svgWidth, svgHeight) }\n });\n\n // add to array\n map.markers.push( marker );\n\n // if marker contains HTML, add it to an infoWindow\n if( $marker.html() )\n {\n // create info window\n var infowindow = new google.maps.InfoWindow({\n content : $marker.html()\n });\n\n // show info window when marker is clicked\n google.maps.event.addListener(marker, 'click', function() {\n\n infowindow.open( map, marker );\n\n });\n }\n\n }", "title": "" }, { "docid": "a6f6705ca8f1e96b663c5a8db1544ceb", "score": "0.5560306", "text": "componentDidMount() {\n\t\tnew google.maps.Map(this.refs.map, { //this is how we create an embedded google map inside our document => will take a reference to html node - element - and embed the map to that element (*this is how we use 3rd party libraries with react, esp., don't know what JSX or render method or react ecosystem*)\n\t\t\tzoom: 12,\n\t\t\tcenter: {\n\t\t\t\tlat: this.props.lat,\n\t\t\t\tlng: this.props.lon\n\t\t\t}\n\t\t})\n\t}", "title": "" }, { "docid": "875f358a397322c9f7a6288110049218", "score": "0.55311984", "text": "static getDocument() {\n const parser = new DOMParser();\n return parser.parseFromString(mapInfoTemplate, 'text/html');\n }", "title": "" }, { "docid": "7f412126427a3cd6b07ab2fc98aeda8b", "score": "0.5526683", "text": "gm_authFailure() {\n const mapContainer = document.querySelector(\".map-container\");\n mapContainer.innerHTML = \"<p>Google Maps error. Please try later</p>\";\n }", "title": "" }, { "docid": "dcc3f7037c277fea9783bc583c4b3d57", "score": "0.5522745", "text": "function createMap() {\n //Create the Google Map.\n const map = new google.maps.Map(document.getElementById(\"map\"), {\n center: {\n lat: 37.422, \n lng: -122.084\n },\n zoom: 16\n });\n //Create a marker for \"Hogwarts\" aka the Googleplex.\n createMapMarker(map, 37.422, -122.084, \n 'Hogwarts', 'This is Hogwarts, School of Wizardry');\n}", "title": "" }, { "docid": "70e73e66d727c9e9b003eb7f82c9343b", "score": "0.547974", "text": "function googleStaticMap(latitude, longitude) {\n var baseUrl = \"https://maps.googleapis.com/maps/api/staticmap?\" \n baseUrl += \"center=\" + latitude + \",\" + longitude\n baseUrl += \"&zoom=15\"\n baseUrl += \"&size=400x400\"\n\n return baseUrl\n }", "title": "" }, { "docid": "c6e634f657c2adde561cbf25fd5c9dc5", "score": "0.5457773", "text": "function googleError() {\n \"use strict\";\n document.getElementById('map').innerHTML = \"<h2>Google Maps is not loading. Please try refreshing the page later.</h2>\";\n}", "title": "" }, { "docid": "9c8391c62ab307644d2f2217a225a6bc", "score": "0.54533", "text": "function addMarker(pos, t, map) {\n var contentString = '<div id=\"content\">' +\n '<div id=\"siteNotice\">' +\n '</div>' +\n '<h1 id=\"firstHeading\" class=\"firstHeading\">Uluru</h1>' +\n '<div id=\"bodyContent\">' +\n '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +\n 'sandstone rock formation in the southern part of the ' +\n 'Northern Territory, central Australia. It lies 335&#160;km (208&#160;mi) ' +\n 'south west of the nearest large town, Alice Springs; 450&#160;km ' +\n '(280&#160;mi) by road. Kata Tjuta and Uluru are the two major ' +\n 'features of the Uluru - Kata Tjuta National Park. Uluru is ' +\n 'sacred to the Pitjantjatjara and Yankunytjatjara, the ' +\n 'Aboriginal people of the area. It has many springs, waterholes, ' +\n 'rock caves and ancient paintings. Uluru is listed as a World ' +\n 'Heritage Site.</p>' +\n '<p>Attribution: Uluru, <a href=\"https://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194\">' +\n 'https://en.wikipedia.org/w/index.php?title=Uluru</a> ' +\n '(last visited June 22, 2009).</p>' +\n '</div>' +\n '</div>';\n\n\n var infowindow = new google.maps.InfoWindow({\n content: contentString,\n maxWidth: 200\n });\n\n var marker = new google.maps.Marker({\n position: pos,\n map: map,\n title: 'Note'\n });\n marker.addListener('click', function() {\n infowindow.open(map, marker);\n });\n\n return marker;\n}", "title": "" }, { "docid": "7e70b7c0e74633408e27931541b40d6d", "score": "0.54433507", "text": "initMap(location) {\n const map = new window.google.maps.Map(window.document.getElementById('map'), {\n center: location,\n zoom: 12\n });\n\n const marker = new window.google.maps.Marker({\n position: location,\n map: map\n });\n }", "title": "" }, { "docid": "8046280310a624a6eb8027f2af41ef32", "score": "0.5436854", "text": "getMarkerEl () {\n return this._$marker\n }", "title": "" }, { "docid": "1e51247d2f249371fefb34df20b17502", "score": "0.5426126", "text": "render() {\n return html`${mapTemplate({ id: this.id })}`;\n }", "title": "" }, { "docid": "c9aad27ebcda13c8197118c017636a2b", "score": "0.54255056", "text": "function initMap() {\n const location = {lat: 40.6901721, lng: -73.9892954};\n const infoWindowMarkup = `\n <h1 style=\"color: #111\">e.Oliver</h1>\n <div style=\"color: #111\">756 Livingston Street, Brooklyn, NY 11201</div>\n `;\n\n const image = './dist/../images/marker.svg';\n\n\n\n const map = new google.maps.Map(document.getElementById('map'), {zoom: 15, center: location, disableDefaultUI: true,\n styles: [\n {\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#111111\"\n }\n ]\n },\n {\n \"elementType\": \"labels.icon\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n }\n ]\n },\n {\n \"elementType\": \"labels.text.stroke\",\n \"stylers\": [\n {\n \"color\": \"#111111\"\n }\n ]\n },\n {\n \"featureType\": \"administrative\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.country\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#9e9e9e\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.land_parcel\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"administrative.locality\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#bdbdbd\"\n }\n ]\n },\n {\n \"featureType\": \"poi\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n }\n ]\n },\n {\n \"featureType\": \"poi.park\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#181818\"\n }\n ]\n },\n {\n \"featureType\": \"poi.park\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#616161\"\n }\n ]\n },\n {\n \"featureType\": \"poi.park\",\n \"elementType\": \"labels.text.stroke\",\n \"stylers\": [\n {\n \"color\": \"#1b1b1b\"\n }\n ]\n },\n {\n \"featureType\": \"road\",\n \"elementType\": \"geometry.fill\",\n \"stylers\": [\n {\n \"color\": \"#2c2c2c\"\n }\n ]\n },\n {\n \"featureType\": \"road\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#8a8a8a\"\n }\n ]\n },\n {\n \"featureType\": \"road.arterial\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#373737\"\n }\n ]\n },\n {\n \"featureType\": \"road.highway\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#3c3c3c\"\n }\n ]\n },\n {\n \"featureType\": \"road.highway.controlled_access\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#4e4e4e\"\n }\n ]\n },\n {\n \"featureType\": \"road.local\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#616161\"\n }\n ]\n },\n {\n \"featureType\": \"transit\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#757575\"\n }\n ]\n },\n {\n \"featureType\": \"water\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#000000\"\n }\n ]\n },\n {\n \"featureType\": \"water\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"color\": \"#3d3d3d\"\n }\n ]\n }\n ]\n } );\n\n\n const infoWindow = new google.maps.InfoWindow({\n content: infoWindowMarkup\n })\n\n const marker = new google.maps.Marker({\n position: location, \n map: map, \n title: 'e.Oliver',\n icon: image\n });\n\n marker.addListener('click', () => {\n infoWindow.open(map, marker);\n });\n}", "title": "" }, { "docid": "f5688bb4d91d272202962d774e1f2970", "score": "0.54250175", "text": "function initMap(petLat,petLng,shelterName,mapID){\n let map = new google.maps.Map(document.getElementById(mapID),{\n zoom: 10,\n center: new google.maps.LatLng(petLat, petLng)\n })\n let marker = new google.maps.Marker({\n position: {lat: petLat, lng: petLng},\n map: map,\n animation: google.maps.Animation.DROP,\n title: 'Pet Shelter'\n });\n let infowindow = new google.maps.InfoWindow({ \n content: shelterName,\n });\n infowindow.open(map, marker); \n }", "title": "" }, { "docid": "9e9e7abbd5943428bf84c161978bb5e3", "score": "0.54235786", "text": "render() {\n return (\n \n <Map google={window.google}\n style={{ width: '100%', height: '235px'}}\n zoom={15}\n center={new google.maps.LatLng({lat : this.props.details.lat, lng : this.props.details.lng})}\n onClick={this.onMapClicked}>\n <Marker onClick={this.onMarkerClick}\n name={this.props.details.address}\n position={{ lat: this.props.details.lat, lng: this.props.details.lng }} />\n <InfoWindow\n marker={this.state.activeMarker}\n visible={this.state.showingInfoWindow}>\n <div>\n <h1>{this.props.details.address}</h1>\n </div>\n </InfoWindow>\n </Map>\n \n )\n }", "title": "" }, { "docid": "4776dcea9d5055892d188aed24540e44", "score": "0.5421645", "text": "function initMap(gameLocation) {\n // The location of the games*/\n // The map, centered at the location\n var map = new google.maps.Map(\n document.getElementById('map'), {zoom: 18, center: gameLocation, mapTypeId: google.maps.MapTypeId.SATELLITE});\n // The marker, positioned at the game location\n var marker = new google.maps.Marker({position: gameLocation, map: map});\n \n }", "title": "" }, { "docid": "99a974488876b678ba1c7e4d3ca40aec", "score": "0.54216325", "text": "render() {\n return html`${mapTemplate({id: this.id})}`\n }", "title": "" }, { "docid": "f1b4b4d29d596660eb9fa8c8e1908af7", "score": "0.5409686", "text": "function previewLocation(position) {\n let src = `https://maps.googleapis.com/maps/api/staticmap?center=${position.lat},${position.lng}&zoom=13&size=300x300&key=${GOOGLE_API_KEY}`;\n document.querySelector('img').src = src;\n}", "title": "" }, { "docid": "7524c7cb51694f5f635fba26323d56ae", "score": "0.54084647", "text": "function createMarker2(point,place,desc){\n \t\tvar marker = new GMarker(point); \t\t\n\t\tvar html = '<p><h1>'+place+'</h1></p><p>'+desc+'</p>'; //put here the contents of the HtmlInfoWindow\t\t\n\t\tGEvent.addListener(marker, 'click', function() {\t\t\n\t\t\tmarker.openInfoWindowHtml(html,{maxWidth:500});\n\t\t\tmap.setCenter(marker.getPoint());\n\t\t});\t\t\n\t\treturn marker;\n\t}", "title": "" }, { "docid": "46372ba8d6cc19087500d08e159a6970", "score": "0.54055685", "text": "getStaticImage(lat, lng, zoom) {\n return `https://maps.googleapis.com/maps/api/staticmap?center=${lat},${lng}&zoom=${zoom}&size=600x300&maptype=roadmap&markers=color:red%7Clabel:Place%7C${lat},${lng}\n &key=${this.token}`;\n }", "title": "" }, { "docid": "da3d46849602a6361a2da7fce5ebe626", "score": "0.5405479", "text": "function createSearchPointMarker(latlng, name, html) {\n var contentString = html;\n var marker = new google.maps.Marker({\n position: latlng,\n map: map,\n animation: google.maps.Animation.DROP,\n zIndex: Math.round(latlng.lat()*-100000)<<5,\n });\n\n google.maps.event.addListener(marker, 'click', function() {\n infowindow.setContent(contentString); \n infowindow.open(map,marker);\n });\n \n //google.maps.event.trigger(marker, 'click'); \n return marker;\n}", "title": "" }, { "docid": "0c9f01142dd50ec2dcecdb228bacb220", "score": "0.5394089", "text": "function create_main_fragment(component, state) {\n\tvar a, text, p, text_3, p_1, text_9, p_2, text_13, center;\n\n\treturn {\n\t\tc: function create() {\n\t\t\ta = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"e\" /* createElement */])(\"a\");\n\t\t\ttext = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"f\" /* createText */])(\"\\n\");\n\t\t\tp = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"e\" /* createElement */])(\"p\");\n\t\t\tp.innerHTML = \"Distances are determined by modeling the Earth as an oblate spheroid according to the specifications of the <a href=\\\"http://en.wikipedia.org/wiki/World_Geodetic_System\\\">WGS 84 standard.</a>\";\n\t\t\ttext_3 = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"f\" /* createText */])(\"\\n\");\n\t\t\tp_1 = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"e\" /* createElement */])(\"p\");\n\t\t\tp_1.innerHTML = \"This app makes use of the <a href=\\\"http://geographiclib.sourceforge.net/\\\">GeographicLib library</a> by Charles Karney, and the <a href=\\\"http://hpneo.github.io/gmaps/\\\">gmaps.js library</a> by Gustavo Leon.\";\n\t\t\ttext_9 = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"f\" /* createText */])(\"\\n\");\n\t\t\tp_2 = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"e\" /* createElement */])(\"p\");\n\t\t\tp_2.innerHTML = \"Code for this app is available <a href=\\\"https://github.com/twitchard/borderdistance\\\">on GitHub</a>.\";\n\t\t\ttext_13 = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"f\" /* createText */])(\"\\n\");\n\t\t\tcenter = Object(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"e\" /* createElement */])(\"center\");\n\t\t\tcenter.innerHTML = \"<p>App by Richard Marmorstein, June 2014. This is free and unencumbered software released into the public domain.</p>\";\n\t\t\tthis.h();\n\t\t},\n\n\t\th: function hydrate() {\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"m\" /* setAttribute */])(a, \"name\", \"about\");\n\t\t},\n\n\t\tm: function mount(target, anchor) {\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(a, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(text, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(p, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(text_3, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(p_1, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(text_9, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(p_2, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(text_13, target, anchor);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"i\" /* insertNode */])(center, target, anchor);\n\t\t},\n\n\t\tp: __WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"j\" /* noop */],\n\n\t\tu: function unmount() {\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(a);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(text);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(p);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(text_3);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(p_1);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(text_9);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(p_2);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(text_13);\n\t\t\tObject(__WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"g\" /* detachNode */])(center);\n\t\t},\n\n\t\td: __WEBPACK_IMPORTED_MODULE_0__home_twitchard_borderdistance_node_modules_svelte_shared_js__[\"j\" /* noop */]\n\t};\n}", "title": "" }, { "docid": "ee7777c1ef010e0f9ac0a81bef167f7a", "score": "0.53607476", "text": "render() {\r\n const {loading, userLocation} = this.state;\r\n const style = {\r\n width: '90vw',\r\n height: '90vh',\r\n 'marginLeft': 'auto',\r\n 'marginRight': 'auto'\r\n }\r\n\r\n if(loading) {\r\n return null;\r\n }\r\n \r\n return (\r\n <Map\r\n item\r\n xs = { 12 }\r\n style = { style }\r\n google = { this.props.google }\r\n onClick = { this.onMapClick }\r\n zoom = { 10 }\r\n initialCenter = {userLocation}\r\n \r\n >\r\n {this.state.sightings.map(item => (\r\n <Marker\r\n key={item.id}\r\n onClick = { this.onMarkerClick }\r\n title={item.bird.name}\r\n name={item.location}\r\n summary={item.summary}\r\n bird={item.bird.name}\r\n birdImage={item.bird.image}\r\n position={{ lat: item.lat, lng: item.lng }}\r\n />\r\n ))}\r\n <InfoWindow\r\n marker = { this.state.activeMarker }\r\n visible = { this.state.showingInfoWindow }\r\n >\r\n <div>\r\n <h4 className=\"marker-info\">{this.state.selectedPlace.name}</h4>\r\n <h6 className=\"marker-info\">{this.state.selectedPlace.bird}</h6>\r\n <p className=\"marker-info\">{this.state.selectedPlace.summary}</p>\r\n </div> \r\n \r\n </InfoWindow>\r\n </Map>\r\n );\r\n }", "title": "" }, { "docid": "75b3a00a855eae06da172f9110855b95", "score": "0.53528774", "text": "function myclick(i) {\n gmarkers[i].openInfoWindowHtml(htmls[i]);\n window.scrollTo(document.getElementById(\"map_canvas\").offsetLeft, document.getElementById(\"map_canvas\").offsetTop);\n}", "title": "" }, { "docid": "142e97bf70d27d795e23a272cdd1c4b4", "score": "0.53446555", "text": "render() {\n return <div ref=\"map\" />;\n }", "title": "" }, { "docid": "0836faefb3e3d0b725ae6287f14ac6f4", "score": "0.5343845", "text": "function initMap () {\n const center = { lat: parseFloat(lat), lng: parseFloat(lng) }\n\n const map = new google.maps.Map(document.getElementById('map'), {\n zoom: 8,\n center: center,\n scrollwheel: false\n })\n\n const contentString = `<strong>${name}</strong>`\n\n const infoWindow = new google.maps.InfoWindow({\n content: contentString\n })\n\n const marker = new google.maps.Marker({\n position: center,\n map: map\n })\n\n marker.addListener('click', function () {\n infoWindow.open(map, marker)\n })\n}", "title": "" }, { "docid": "0e90d69acb0b65d3677959345cb45c6e", "score": "0.53409696", "text": "render() {\n this.setUpGoogleMap()\n if(this.refs.Gmap){\n //console.log(\"google path: \", this.googleMap.props.children[0])\n //console.log(\"google marker: \", this.googleMap.props.children[1])\n if(this.googleMap.props.children[0].props.path.length > 0){\n //console.log(this.getKmlString())\n }\n }\n let kml = this.getKmlString()\n // Return the stuff we actually want rendered on the page\n return (\n <div className='table'>\n {this.googleMap}\n <SaveKML KMLFile = {kml}/>\n </div>\n )\n }", "title": "" }, { "docid": "abc248b36b4074f87c9327f80bbedf18", "score": "0.53325796", "text": "function initMap() {\n var astorPlace = {\n lat: 40.729884,\n lng: -73.990988\n }; // Set up the map\n\n var map = new google.maps.Map(document.getElementById(\"map\"), {\n center: astorPlace,\n zoom: 18,\n streetViewControl: false\n }); // Set up the markers on the map\n\n var cafeMarker = new google.maps.Marker({\n position: {\n lat: 40.730031,\n lng: -73.991428\n },\n map: map,\n icon:\n \"https://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=cafe|FFFF00\",\n title: \"Cafe\"\n });\n var bankMarker = new google.maps.Marker({\n position: {\n lat: 40.729681,\n lng: -73.991138\n },\n map: map,\n icon:\n \"https://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=dollar|FFFF00\",\n title: \"Bank\"\n });\n var busMarker = new google.maps.Marker({\n position: {\n lat: 40.729559,\n lng: -73.990741\n },\n map: map,\n icon:\n \"https://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=bus|FFFF00\",\n title: \"Bus Stop\"\n }); // We get the map's default panorama and set up some defaults.\n // Note that we don't yet set it visible.\n\n exports.panorama = map.getStreetView();\n exports.panorama.setPosition(astorPlace);\n exports.panorama.setPov(\n /** @type {google.maps.StreetViewPov} */\n {\n heading: 265,\n pitch: 0\n }\n );\n }", "title": "" }, { "docid": "1bee2f0428f7921cefa94f0fea6248bc", "score": "0.5330462", "text": "renderPage() {\n return (\n <Container>\n <Header as=\"h2\" textAlign=\"center\">Map</Header>\n initMap();\n </Container>\n );\n }", "title": "" }, { "docid": "e4f1fee5e6f887a52053ad82f6a256ae", "score": "0.5317405", "text": "function createMarker(latlng, name, html) {\n var contentString = html;\n var marker = new google.maps.Marker({\n position: latlng,\n map: map,\n zIndex: Math.round(latlng.lat()*-100000)<<5\n });\n\n google.maps.event.addListener(marker, 'click', function() {\n infowindow.setContent(contentString); \n infowindow.open(map,marker);\n });\n google.maps.event.trigger(marker, 'click'); \n return marker;\n }", "title": "" }, { "docid": "6b09a5629a5abd26f99aca82468ad8f7", "score": "0.5310337", "text": "renderMarker(marker) {\n let linkText = marker.linkText;\n if (linkText.length > 35) {\n linkText = linkText.slice(0, 33) + \"...\";\n }\n const caption = marker.hintString + (marker.localHint.showLinkText ? \": \" + linkText : \"\");\n marker.element.innerHTML = spanWrap(caption);\n }", "title": "" }, { "docid": "435bcf1fb2398f6c4cac8f5d74f205dd", "score": "0.5309503", "text": "function initMap() {\n // eslint-disable-line\n let latitude = Number((Math.random() * 90).toFixed(3));\n let longitude = Number((Math.random() * -130).toFixed(3));\n\n var startingPosition = new google.maps.LatLng(latitude, longitude);\n var mapSpecs = {\n zoom: 10,\n center: startingPosition,\n mapTypeId: 'satellite',\n };\n\n map = new google.maps.Map(document.getElementById('map'), mapSpecs);\n\n let contentString = `<h4>Welcome</h4><p>Where are we?</p><p>Who cares, there's nothing interesting here. Enter a location in the search bar above and click generate to view that location and see if there are any pictures there.</p>`;\n\n let marker = new google.maps.Marker({\n position: startingPosition,\n map: map,\n title: 'Starting Location',\n });\n\n var infowindow = new google.maps.InfoWindow();\n\n marker.addListener('click', function() {\n infowindow.setContent(contentString);\n infowindow.setOptions({\n maxWidth: 400,\n });\n infowindow.open(map, marker);\n });\n}", "title": "" }, { "docid": "d19dc417db7afdf3a0d6b6e7c248407b", "score": "0.52930003", "text": "function initMap(){\n\n // The location of Ibokun\n const loc = {lat: 7.7861, lng: 4.7226};\n\n //The map, centered at Ibokun\n const map = new google.maps.Map(document.querySelector(\".map\"), {\n zoom: 14,\n center: loc\n });\n\n //The marker, positioned at Ibokun\n const marker = new google.maps.Marker({position: loc, map: map});\n}", "title": "" }, { "docid": "4f2510e85a029300850e6f9d7bec9b46", "score": "0.5292339", "text": "function mapsError() {\n 'use strict';\n document.getElementById('map').innerHTML = '<h3 style=\"text-align:center;\">Sorry, Google Maps is not available at the moment. Please try again later.</h3>';\n}", "title": "" }, { "docid": "bf99d2ce82dd5ab85cbfdf9ec57f435d", "score": "0.52814287", "text": "function initMap() {\n\n const SnazzyInfoWindow = require('snazzy-info-window')\n \n // The location of Uluru\n var center = {\n lat: 40.712784,\n lng: -74.005941\n }\n \n // The map, centered at Uluru\n var map = new google.maps.Map(\n document.getElementById('map'), \n {\n zoom: 17,\n styles: [\n {\n \"featureType\": \"all\",\n \"elementType\": \"all\",\n \"stylers\": [\n {\n \"saturation\": \"32\"\n },\n {\n \"lightness\": \"-3\"\n },\n {\n \"visibility\": \"on\"\n },\n {\n \"weight\": \"1.18\"\n }\n ]\n },\n {\n \"featureType\": \"all\",\n \"elementType\": \"geometry.fill\",\n \"stylers\": [\n {\n \"saturation\": \"-62\"\n },\n {\n \"weight\": \"3.98\"\n },\n {\n \"hue\": \"#0041ff\"\n }\n ]\n },\n {\n \"featureType\": \"administrative\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"landscape\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"landscape.man_made\",\n \"elementType\": \"all\",\n \"stylers\": [\n {\n \"saturation\": \"-70\"\n },\n {\n \"lightness\": \"14\"\n }\n ]\n },\n {\n \"featureType\": \"poi\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"road\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"transit\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"water\",\n \"elementType\": \"all\",\n \"stylers\": [\n {\n \"saturation\": \"100\"\n },\n {\n \"lightness\": \"-14\"\n }\n ]\n },\n {\n \"featureType\": \"water\",\n \"elementType\": \"labels\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n },\n {\n \"lightness\": \"12\"\n }\n ]\n }\n ],\n maxZoom: 20,\n minZoom: 0,\n mapTypeId: 'roadmap',\n disableDefaultUI: true,\n clickableIcons: false,\n disableDoubleClickZoom: false,\n draggable: true,\n keyboardShortcuts: true,\n scrollwheel: false,\n center: center\n }\n )\n\n const markers = [{\n lat: 40.712425,\n lng: -74.008091,\n }, {\n lat: 40.711246,\n lng: -74.007672,\n }, {\n lat: 40.711612,\n lng: -74.006395,\n }, {\n lat: 40.713108,\n lng: -74.008155,\n }, {\n lat: 40.712507,\n lng: -74.004175,\n }, {\n lat: 40.713312,\n lng: -74.005612,\n }, {\n lat: 40.712059,\n lng: -74.008906,\n }, {\n lat: 40.711189,\n lng: -74.005762,\n }, {\n lat: 40.713564,\n lng: -74.00734,\n }, {\n lat: 40.712759,\n lng: -74.006095,\n }, ]\n \n markers.forEach(position => {\n var markerOptions = {\n map: map,\n position\n }\n \n markerOptions.icon = {\n path: 'M11 2c-3.9 0-7 3.1-7 7 0 5.3 7 13 7 13 0 0 7-7.7 7-13 0-3.9-3.1-7-7-7Zm0 9.5c-1.4 0-2.5-1.1-2.5-2.5 0-1.4 1.1-2.5 2.5-2.5 1.4 0 2.5 1.1 2.5 2.5 0 1.4-1.1 2.5-2.5 2.5Z',\n scale: 1.6363636363636363636363636364,\n anchor: new google.maps.Point(11, 22),\n fillOpacity: 1,\n fillColor: '#299aff',\n strokeOpacity: 0\n }\n \n const marker = new google.maps.Marker(markerOptions)\n\n var infoWindow = new SnazzyInfoWindow({\n marker: marker,\n wrapperClass: 'ql-snow',\n placement: 'top',\n backgroundColor: '#fff',\n fontColor: '#000',\n content: '<div class=\"ql-editor\" style=\"font-family: Arial, Helvetica, sans-serif; font-size: 14px;\">\\u003cp\\u003eYour content goes here...\\u003c/p\\u003e</div>',\n maxWidth: undefined,\n maxHeight: undefined,\n padding: \"30px\",\n borderRadius: \"3px 3px\",\n offset: {\n top: \"-37px\",\n left: \"0px\",\n },\n border: false,\n pointer: \"15px\",\n shadow: {\"h\":\"0px\",\"v\":\"1px\",\"blur\":\"3px\",\"spread\":\"0px\",\"opacity\":0.3,\"color\":\"#000000\"},\n closeOnMapClick: true,\n closeWhenOthersOpen: true\n })\n\n })\n }", "title": "" }, { "docid": "c9cbb97fb73180c59ce329be3113a3be", "score": "0.52800024", "text": "function initMap() {\n // The location of Uluru\n const uluru = { lat: -17.8477, lng: 25.8684 };\n // The map, centered at Uluru\n const options = {\n zoom: 14,\n center: uluru,\n }\n\n const map = new google.maps.Map(document.getElementById(\"map\"), options);\n // The marker, positioned at Uluru\n const marker = new google.maps.Marker({\n position: uluru,\n map: map,\n });\n\n}", "title": "" }, { "docid": "15bbf4b5f0a0407a25cac4396b6f1da8", "score": "0.5276367", "text": "function createMarker(latlng, name, html) {\n var contentString = html;\n var marker = new google.maps.Marker({\n position: latlng,\n map: map,\n zIndex: Math.round(latlng.lat()*-100000)<<5\n });\n\n google.maps.event.addListener(marker, 'click', function() {\n //map.setCenter(marker.getPosition());\n //map.panTo(marker.getPosition());\n infowindow.setContent(contentString);\n infowindow.open(map,marker);\n });\n // save the info we need to use later for the side_bar\n gmarkers.push(marker);\n // add a line to the side_bar html\n side_bar_html += '<li><a href=\"javascript:seas(' + (gmarkers.length-1) + ')\">' + name + '<\\/a><\\/li>';\n }", "title": "" }, { "docid": "9ae12aa64142286b66e5fb04471004dd", "score": "0.52759093", "text": "print() {\n const self = this;\n this.markers = [];\n this.collection.forEach(function(o, i) {\n let lat = o.lat || o.location.latitude;\n let lng = o.lng || o.location.longitude;\n let m = new MarkerWithLabel({\n position: new google.maps.LatLng(lat, lng),\n map: self.map,\n hoverContent: o.hoverData || '',\n clickContent: o.clickData || '',\n labelContent: '',\n icon: {\n path: google.maps.SymbolPath.CIRCLE,\n scale: 0\n },\n draggable: false,\n labelAnchor: new google.maps.Point(10, 10),\n labelClass: 'marker-point',\n labelData: o.dataset,\n labelStyle: o.labelStyle || {}\n });\n\n self.markers.push(m);\n\n self.oms.addMarker(m)\n\n setTimeout(function () {\n if (document.querySelector('#popper-container') === null) {\n let temp = document.createElement('template');\n temp.innerHTML = self.returnHoverTemplate();\n $(self.map.getDiv()).append(self.returnHoverTemplate())\n }\n\n if (document.querySelector('#popper-container-clicked') === null) {\n let temp = document.createElement('template');\n temp.innerHTML = self.returnClickTemplate();\n $(self.map.getDiv()).append(self.returnClickTemplate())\n }\n }, 1000)\n\n });\n\n this.setEvents(false);\n this.setOmsEvents();\n }", "title": "" }, { "docid": "167f4abddc7ddffde0873632d71e664d", "score": "0.52758634", "text": "function render_map( $el ) {\n\n\t// var\n\tvar $markers = $el.find('.marker');\n\n\t// vars\n\tvar args = {\n\t\tzoom\t\t: 16,\n\t\tcenter\t\t: new google.maps.LatLng(0, 0),\n\t\tmapTypeId\t: google.maps.MapTypeId.ROADMAP\n\t};\n\n\t// create map\t \t\n\tvar map = new google.maps.Map( $el[0], args);\n\n\t// add a markers reference\n\tmap.markers = [];\n\n\t// add markers\n\t$markers.each(function(){\n\n \tadd_marker( $(this), map );\n\n\t});\n\n\t// center map\n\tcenter_map( map );\n\n}", "title": "" }, { "docid": "11543d3d15016487dcec7f9c84efdb5e", "score": "0.5274328", "text": "function openInfowindow(html, marker) {\n \n // Close previous infowindow if exists\n closeInfowindow();\n \n // Set the content and open\n Gmaps.map.visibleInfoWindow = new google.maps.InfoWindow({content: html});\n Gmaps.map.visibleInfoWindow.open(Gmaps.map.serviceObject, marker);\n}", "title": "" }, { "docid": "b059ff36ee95ad3ff3d316c9d3bb61c2", "score": "0.52682173", "text": "function addMarker(location) {\n const marker = new google.maps.Marker({\n position: location,\n map: map,\n });\n markers.push(marker);\n marker.addListener(\"click\", () => {\n infowindow.open(map, marker);\n });\n const contentString =\n '<div id=\"content\">' +\n '<div id=\"siteNotice\">' +\n \"</div>\" +\n '<h1 id=\"firstHeading\" class=\"firstHeading\">경상대학교</h1>' +\n '<div id=\"bodyContent\">' +\n \"<p><b>경상대학교</b>웹프로그래밍</b>, 이것은 테스트 중임 <br>\" +\n \"우리는 할 수 있다. -황태호-<br> \" +\n \"나를 죽이지 못하는 고통은 나를 강하게 만든다 -황태호-<br> \" +\n\n \"경상대학교 사이트 Site.</p>\" +\n '<p><a href=\"https://www.gnu.ac.kr/main/\" target = \"_blank\">' +\n \"경상대학교 홈페이지</a> \" +\n \"</p>\" +\n \"</div>\" +\n \"</div>\";\n const infowindow = new google.maps.InfoWindow({\n content: contentString,\n });\n \n}", "title": "" }, { "docid": "54b88019ee9383fa202f10da4a553e04", "score": "0.5265124", "text": "function initMap() {\r\n // The location of Uluru 26.901359,75.751577\r\n const uluru = { lat: 26.901359, lng: 75.751577 };\r\n // The map, centered at Uluru\r\n const map = new google.maps.Map(document.getElementById(\"map\"), {\r\n zoom: 16,\r\n center: uluru,\r\n });\r\n // The marker, positioned at Uluru\r\n const marker = new google.maps.Marker({\r\n position: uluru,\r\n map: map,\r\n });\r\n}", "title": "" }, { "docid": "0766e325a35e9ff9cf7c42442133371c", "score": "0.52644104", "text": "function init_map() {\n const myOptions = {\n zoom: 11,\n center: new google.maps.LatLng(51.459779, -0.180647),\n mapTypeId: google.maps.MapTypeId.ROADMAP,\n scrollwheel: false\n };\n map = new google.maps.Map(\n document.getElementById(\"google-maps-container\"),\n myOptions\n );\n marker = new google.maps.Marker({\n map: map,\n position: new google.maps.LatLng(51.459779, -0.180647)\n });\n}", "title": "" }, { "docid": "eb97d64748418b1197162321106e95af", "score": "0.52632916", "text": "function setTemplateError (marker, imgUrl) {\n return `\n <h3 class=\"title\">${marker.title}</h3>\n <img class=\"iw-image\" src=\"${imgUrl}\" />\n <p class=\"iw-error\">There is been an error. Most likely this place has not been found by Foursquare.</p>\n `;\n}", "title": "" }, { "docid": "668f956851c771dda137f7987142575a", "score": "0.5259641", "text": "constructor() {\n let appendTo = document.getElementById(\"overlays\") ||\n document.body;\n let elem = document.createElement(\"div\");\n elem.innerHTML = TASK_MAP_TEMPLATE;\n appendTo.appendChild(elem);\n this.svg = Snap('#task-map-svg');\n }", "title": "" }, { "docid": "8f53242768fc51fd03d70ef1958f44cc", "score": "0.5245348", "text": "function createMarker(point, label, html, map) {\n var icon = new GIcon(G_DEFAULT_ICON);\n icon.image = \"darkgray-circle-icon-10.png\";\n // if (map.getCurrentMapType().getName() === \"Chalk\") {\n // icon.image = \"gray-circle-icon-12.png\";\n // }\n icon.iconSize = new GSize(9, 9);\n icon.shadowSize = new GSize(0, 0);\n icon.iconAnchor = new GPoint(3, 3);\n\n var marker = new GMarker(point, {\n icon: icon\n });\n\n GEvent.addListener(marker, \"click\",\n function() {\n // marker.openInfoWindowHtml(html);\n showTooltip(marker, map);\n });\n\n marker.tooltip = label;\n // The new marker \"mouseover\" and \"mouseout\" listeners\n GEvent.addListener(marker, \"mouseover\",\n\t\t function() {\n\t\t\t showTooltip(marker, map);\n\t\t });\n\n GEvent.addListener(marker, \"mouseout\",\n function() {\n document.getElementById(\"tooltip\").style.visibility = \"hidden\";\n });\n return marker;\n}", "title": "" }, { "docid": "b84b17f6e78d2f01e9e1e0b52ab77480", "score": "0.5244265", "text": "makeInfoWindow(marker) {\n let infowindow = this.state.infoWindow;\n let map = this.state.map;\n\n /* Zoom into the place when the user click on it */\n map.setZoom(15);\n map.setCenter(marker.getPosition());\n\n if (infowindow.marker !== marker) {\n infowindow.setContent('');\n infowindow.marker = marker;\n infowindow.addListener('closeclick', function() {\n infowindow.marker = null;\n });\n\n let streetViewService = new window.google.maps.StreetViewService();\n let radius = 50;\n\n function getStreetView(data, status) {\n if (status === window.google.maps.StreetViewStatus.OK) {\n let nearStreetViewLocation = data.location.latLng;\n infowindow.setContent('<div id=\"pano\" style=\"width:200px; height:200px; position:static\"></div><h2>' + marker.title + '</h2>');\n let panoramaOptions = {\n position: nearStreetViewLocation,\n disableDefaultUI: true,\n pov: {\n heading: 34,\n pitch: 10\n }\n };\n let panorama = new window.google.maps.StreetViewPanorama(\n document.getElementById('pano'), panoramaOptions);\n } else {\n infowindow.setContent('<div>' + marker.title + '</div>' +\n '<div>No Street View Found</div>');\n }\n }\n\n streetViewService.getPanoramaByLocation(marker.position, radius, getStreetView);\n infowindow.open(map, marker);\n }\n\n if ((marker.id === \"Attractions\") || (marker.id === \"Parks\")) {\n this.wiki(marker);\n } else if ((marker.id === \"Coffee\") || (marker.id === \"Restaurants\")) {\n this.yelp(marker);\n }\n }", "title": "" }, { "docid": "b4cbd25420d8c5920cd5b31fd630ba48", "score": "0.5237704", "text": "function initMap() {\r\n // The location of London\r\n const london = { lat: 51.508, lng: -0.127 };\r\n // The map, centered at Uluru\r\n const map = new google.maps.Map(document.getElementById(\"map\"), {\r\n zoom: 15,\r\n center: london,\r\n });\r\n // The marker, positioned at Uluru\r\n const marker = new google.maps.Marker({\r\n position: london,\r\n map: map,\r\n });\r\n}", "title": "" }, { "docid": "3113158432c7334b8fb04ea6e14f0c40", "score": "0.52320856", "text": "function initMap() {\n // get location\n var point = {\n lat: 52.4512502,\n lng: -2.0061653\n };\n // get element my-map from contact page\n var map = new google.maps.Map(document.getElementById('my-map'), {\n // this controls the zoom, the higher the number the more zoomed in the map will be \n zoom: 12,\n center: point\n });\n // this adds a marker to the map \n var marker = new google.maps.Marker({\n position: point,\n map: map\n });\n}", "title": "" }, { "docid": "d1242836912f63e470ad7c00370efc05", "score": "0.5221084", "text": "function new_map( $el ) {\n\n // var\n var $markers = $el.find('.marker');\n\n\n // vars\n var args = {\n zoom : 16,\n center : new google.maps.LatLng(0, 0),\n mapTypeId : google.maps.MapTypeId.ROADMAP,\n mapTypeControl: false,\n scaleControl: false,\n scrollwheel: false,\n navigationControl: false,\n streetViewControl: false,\n styles: [\n {\n \"featureType\": \"all\",\n \"elementType\": \"labels.text.fill\",\n \"stylers\": [\n {\n \"saturation\": \"0\"\n },\n {\n \"color\": \"#fbf0e8\"\n },\n {\n \"lightness\": \"0\"\n }\n ]\n },\n {\n \"featureType\": \"all\",\n \"elementType\": \"labels.text.stroke\",\n \"stylers\": [\n {\n \"visibility\": \"on\"\n },\n {\n \"color\": \"#64aaa7\"\n },\n {\n \"lightness\": \"0\"\n },\n {\n \"weight\": \"4.59\"\n }\n ]\n },\n {\n \"featureType\": \"all\",\n \"elementType\": \"labels.icon\",\n \"stylers\": [\n {\n \"visibility\": \"off\"\n }\n ]\n },\n {\n \"featureType\": \"administrative\",\n \"elementType\": \"geometry.fill\",\n \"stylers\": [\n {\n \"color\": \"#fbf0e8\"\n },\n {\n \"lightness\": \"0\"\n }\n ]\n },\n {\n \"featureType\": \"administrative\",\n \"elementType\": \"geometry.stroke\",\n \"stylers\": [\n {\n \"color\": \"#fefefe\"\n },\n {\n \"lightness\": 17\n },\n {\n \"weight\": 1.2\n }\n ]\n },\n {\n \"featureType\": \"landscape\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"lightness\": \"0\"\n },\n {\n \"gamma\": \"1.00\"\n },\n {\n \"weight\": \"0.01\"\n },\n {\n \"color\": \"#64aaa7\"\n }\n ]\n },\n {\n \"featureType\": \"poi\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#64aaa7\"\n },\n {\n \"lightness\": \"0\"\n },\n {\n \"visibility\": \"on\"\n }\n ]\n },\n {\n \"featureType\": \"poi.park\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#64aaa7\"\n },\n {\n \"lightness\": \"0\"\n }\n ]\n },\n {\n \"featureType\": \"road.highway\",\n \"elementType\": \"geometry.fill\",\n \"stylers\": [\n {\n \"color\": \"#fbf0e8\"\n },\n {\n \"lightness\": \"0\"\n },\n {\n \"weight\": \"1.70\"\n },\n {\n \"visibility\": \"on\"\n }\n ]\n },\n {\n \"featureType\": \"road.highway\",\n \"elementType\": \"geometry.stroke\",\n \"stylers\": [\n {\n \"color\": \"#fbf0e8\"\n },\n {\n \"lightness\": \"0\"\n },\n {\n \"weight\": \"0.01\"\n },\n {\n \"visibility\": \"on\"\n }\n ]\n },\n {\n \"featureType\": \"road.arterial\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#fbf0e8\"\n },\n {\n \"lightness\": \"0\"\n },\n {\n \"weight\": \"1\"\n },\n {\n \"visibility\": \"on\"\n }\n ]\n },\n {\n \"featureType\": \"road.local\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#fbf0e8\"\n },\n {\n \"lightness\": \"0\"\n },\n {\n \"weight\": \"1.61\"\n }\n ]\n },\n {\n \"featureType\": \"transit\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#fbf0e8\"\n },\n {\n \"lightness\": \"0\"\n },\n {\n \"weight\": \"1.50\"\n }\n ]\n },\n {\n \"featureType\": \"water\",\n \"elementType\": \"geometry\",\n \"stylers\": [\n {\n \"color\": \"#538f8c\"\n },\n {\n \"lightness\": \"0\"\n }\n ]\n }\n ]\n };\n\n\n // create map\n var map = new google.maps.Map( $el[0], args);\n\n\n // add a markers reference\n map.markers = [];\n\n\n // add markers\n $markers.each(function(){\n\n add_marker( $(this), map );\n\n });\n\n\n // center map\n center_map( map );\n\n\n // return\n return map;\n\n }", "title": "" }, { "docid": "8dc9cc5768b249890db11eb8346888fa", "score": "0.5217573", "text": "setViewOnMap(latitude, longitude) {\n var latitudeTxt = JSON.stringify(latitude);\n var longtitudeTxt = JSON.stringify(longitude);\n this.Map_Ref.injectJavaScript(`\n mymap.setView([${latitudeTxt}, ${longtitudeTxt}]);\n `);\n }", "title": "" }, { "docid": "4fc9bdf5b0782ff7c935bdeef25aa2b6", "score": "0.5214668", "text": "createElement(){\n let dataArray = [];\n\n for( let c of this.data.cars ){\n dataArray.push(c);\n }\n\n for( let d of this.data.drones ){\n dataArray.push(d);\n }\n \n super.createElement(); //call original function and then continue with google code\n\n setTimeout( () => {\n\n let map = new window.google.maps.Map(document.getElementById('map'), {\n center: this.centerOfMap,\n zoom: 13\n });\n\n for( let vehicle of dataArray ){\n\n let [lat, long] = vehicle.latLong.split(' ');\n console.log(lat);\n console.log(vehicle);\n let myLatLng = new window.google.maps.LatLng(lat, long);\n\n let marker = new google.maps.Marker({\n position: myLatLng,\n map: map\n });\n\n marker.setMap(map);\n\n }\n\n },100);\n }", "title": "" }, { "docid": "90d97033c36d61c68b5edfc20da5492b", "score": "0.521447", "text": "function mapFail(){\n document.getElementById(\"my_map\").innerHTML = \"<p class='text-center'>Google maps API could not be loaded!</p>\";\n}", "title": "" }, { "docid": "f79c4b0948df5d9825a4ad1901d661b4", "score": "0.5201762", "text": "function viewThing() {\n\n // setup the Map\n var mapCanvas = document.getElementById('map');\n var mapOptions = {\n mapTypeId: google.maps.MapTypeId.ROADMAP\n };\n map = new google.maps.Map(mapCanvas, mapOptions);\n var bounds = new google.maps.LatLngBounds();\n menu = menuSetup();\n for (i = 0; i < markers.length; i++) {\n LinkMarkerToContent(markers[i].markerItem, markers[i].contentWindow,\n markers[i].wikiUrl);\n markers[i].markerItem.setMap(map);\n google.maps.event.addListener(markers[i].markerItem, 'click',\n toggleBounce);\n bounds.extend(markers[i].markerItem.position);\n }\n map.fitBounds(bounds);\n}", "title": "" }, { "docid": "81445e3a80755e9f83a8678fe7123ae8", "score": "0.5193336", "text": "function initMap() {\n // The location of Uluru\n const uluru = { lat: -22.9115543, lng: -43.3191242 };\n // The map, centered at Uluru\n const map = new google.maps.Map(document.getElementById(\"map\"), {\n zoom: 4,\n center: uluru,\n });\n // The marker, positioned at Uluru\n const marker = new google.maps.Marker({\n position: uluru,\n map: map,\n });\n}", "title": "" }, { "docid": "41416fc0b269ae7b68ffb4b990b7c533", "score": "0.51870185", "text": "function initialize() {\r\n var mapProp = \r\n {\r\n center: new google.maps.LatLng(40.493533, -74.423022),\r\n zoom: 13,\r\n mapTypeId: google.maps.MapTypeId.ROADMAP\r\n };\r\n \r\n var map = new google.maps.Map(document.getElementById(\"googleMap\"),mapProp);\r\n \r\n var marker = new google.maps.Marker\r\n ({\r\n position: new google.maps.LatLng(40.493533, -74.423022), \r\n map: map,\r\n title: \"Sandy's Pet shop\"\r\n });\r\n}", "title": "" }, { "docid": "79e12965b8c33bf3f4fc0cf1ab629de4", "score": "0.51861876", "text": "function initMap() {\n \n const locPoint = {lat: latLon.locLat, lng: latLon.locLon};\n var map = new google.maps.Map(document.getElementById('map'), {zoom: 18, center: locPoint, zoomControl: false, mapTypeControl: false, streetViewControl: false, fullscreenControl: false});\n \n}", "title": "" }, { "docid": "9aa2d38983712aba55a9f0667ec377c4", "score": "0.5185155", "text": "function zoom(){\nvar map = new google.maps.Map(document.getElementById(\"map\"), {\n zoom: 17,\n center: uluru,\n}); \n\n\nfor(i=0;i<locations.length; i++) {\n marker = new google.maps.Marker({\n position: new google.maps.LatLng(locations[i][1], locations[i][2]),\n map: map,\n title: locations[i][0],\n icon: './assets/images/icon_01.png',\n });\n}\n\n}", "title": "" }, { "docid": "451782446269d6a3cec51ed4d7409d80", "score": "0.5184357", "text": "get markerTemplate() {\n return this.i.n1;\n }", "title": "" }, { "docid": "5894a2a1eeda44047aad8ce28bd0b144", "score": "0.5184282", "text": "function createMarkerForDisplay(lat, lng, content) {\n const marker =\n new google.maps.Marker({position: {lat: lat, lng: lng}, map: map});\n\n const contentString = \n `<div id=\"content\">\n <div id=\"locationInfo\">\n </div>\n <p> Location Title: </p>\n ${content}\n <div id=\"bodyContent\">\n <p>Number of Votes: 1</br>\n Voters: You</br></p>\n <input type='checkbox' id='vote' name='vote' value='vote' checked>\n <label for='vote'> VOTE</label><br></br>\n </div>\n </div>`;\n\n const infoWindow = new google.maps.InfoWindow({content: contentString});\n marker.addListener('click', () => {\n infoWindow.open(map, marker);\n });\n}", "title": "" }, { "docid": "076910853d444db311d5f594b3ca18a2", "score": "0.5183305", "text": "generateMarkers() {\n return this.state.markers.map(markerInstance => (\n <MapView.Marker\n coordinate={{\n latitude: markerInstance.lat,\n longitude: markerInstance.lng\n }}\n //Can later pull coord, title, descrip from API when implemented\n // title={markerInstance.name}\n // description={markerInstance.description}\n key={markerInstance.keyName}\n onPress={e => {\n e.stopPropagation();\n this.props.showGarageInfo(markerInstance.keyName);\n }}\n anchor={{\n x: 1,\n y: 1\n }}\n calloutAnchor={{\n x: 0,\n y: 0\n }}\n callout\n >\n <CustomMarker\n percent={\n (markerInstance.current / markerInstance.max) * 100\n }\n />\n </MapView.Marker>\n ));\n }", "title": "" }, { "docid": "0d87dc83b3efceb01dee6be35a2eb6e9", "score": "0.5182318", "text": "render() {\n return (\n <div className=\"map-container\">\n <Map\n google={this.props.google}\n zoom={4}\n style={mapStyles}\n initialCenter={\n {\n lat: 37.09024,\n lng: -95.712891\n }\n }\n >\n {this.renderMarkers()}\n {this.renderWindows()}\n </Map>\n </div>\n );\n }", "title": "" }, { "docid": "24993d6f0654aa09962275dbceffc6ab", "score": "0.518077", "text": "Map () {\n \n return (\n \n <div><GoogleMap \n\n zoom={zoomMap} \n center={centerMap}\n > \n\n </GoogleMap>\n\n <Marker\n key={markOne[0][\"id\"]}\n position ={{\n lat: markOne[0][\"coordinates\"][\"latitude\"],\n lng: markOne[0][\"coordinates\"][\"longitude\"]\n }}\n title = {markOne[0][\"name\"]} \n onClick = {() => {window.open(markOne[0]['url'])}} \n icon = \"http://maps.google.com/mapfiles/ms/icons/pink-dot.png\" \n ></Marker>\n\n <Marker\n key={markTwo[0][\"id\"]}\n position ={{\n lat: markTwo[0][\"coordinates\"][\"latitude\"],\n lng: markTwo[0][\"coordinates\"][\"longitude\"]\n }}\n title = {markTwo[0][\"name\"]} \n onClick = {() => {window.open(markTwo[0]['url'])}} \n icon = \"http://maps.google.com/mapfiles/ms/icons/pink-dot.png\" \n ></Marker>\n\n <Marker\n key={markThree[0][\"id\"]}\n position ={{\n lat: markThree[0][\"coordinates\"][\"latitude\"],\n lng: markThree[0][\"coordinates\"][\"longitude\"]\n }}\n title = {markThree[0][\"name\"]} \n onClick = {() => {window.open(markThree[0]['url'])}} \n icon = \"http://maps.google.com/mapfiles/ms/icons/pink-dot.png\" \n ></Marker>\n\n <Marker\n key={markFour[0][\"id\"]}\n position ={{\n lat: markFour[0][\"coordinates\"][\"latitude\"],\n lng: markFour[0][\"coordinates\"][\"longitude\"]\n }}\n title = {markFour[0][\"name\"]} \n onClick = {() => {window.open(markFour[0]['url'])}} \n icon = \"http://maps.google.com/mapfiles/ms/icons/pink-dot.png\" \n ></Marker>\n\n <Marker\n key={markFive[0][\"id\"]}\n position ={{\n lat: markFive[0][\"coordinates\"][\"latitude\"],\n lng: markFive[0][\"coordinates\"][\"longitude\"]\n }}\n title = {markFive[0][\"name\"]} \n onClick = {() => {window.open(markFive[0]['url'])}} \n icon = \"http://maps.google.com/mapfiles/ms/icons/pink-dot.png\" \n ></Marker>\n\n <Marker\n key={\"userLocation\"}\n position ={{\n lat: parseFloat(document.getElementById(\"userLat\").getAttribute(\"text\")),\n lng: parseFloat(document.getElementById(\"userLong\").getAttribute(\"text\"))\n }}\n title = \"You are here!\" \n icon = \"http://maps.google.com/mapfiles/ms/icons/blue-dot.png\"\n ></Marker>\n </div>)\n}", "title": "" }, { "docid": "fac364de048741ed40594d055ff77874", "score": "0.51795274", "text": "function createMarker(options, html) {\n var marker = new google.maps.Marker(options);\n if (html) {\n google.maps.event.addListener(marker, \"click\", function () {\n infoWindow.setContent(html);\n infoWindow.open(options.map, this);\n });\n }\n return marker;\n }", "title": "" }, { "docid": "fac364de048741ed40594d055ff77874", "score": "0.51795274", "text": "function createMarker(options, html) {\n var marker = new google.maps.Marker(options);\n if (html) {\n google.maps.event.addListener(marker, \"click\", function () {\n infoWindow.setContent(html);\n infoWindow.open(options.map, this);\n });\n }\n return marker;\n }", "title": "" }, { "docid": "fac364de048741ed40594d055ff77874", "score": "0.51795274", "text": "function createMarker(options, html) {\n var marker = new google.maps.Marker(options);\n if (html) {\n google.maps.event.addListener(marker, \"click\", function () {\n infoWindow.setContent(html);\n infoWindow.open(options.map, this);\n });\n }\n return marker;\n }", "title": "" }, { "docid": "137f05c5a08f9c7bb34048a658b3a2d4", "score": "0.5178698", "text": "static get template() {\n return `\n <style>\n \n @keyframes move {\n 0% { opacity: 0; }\n 90% { \n opacity: 1; \n transform: scale(0.1) rotate(45deg);}\n 100% { \n opacity: 0; \n transform: scale(0.04) rotate(90deg);\n }\n }\n\n .text {\n color: white; \n font-size: 18px; \n font-family: trebuchet ms;\n text-align: center;\n }\n\n .container {\n border-radius: 16px; \n position:relative;\n }\n\n img {\n position:absolute; \n top:0; \n left:0; \n width: 200px;\n }\n\n img.animate {\n animation-name: move;\n animation-duration: 2s;\n animation-fill-mode: forwards;\n }\n\n </style>\n <div class=\"text\">Hello [[name]]</div>\n <div class=\"container\">\n <img src=\"img/web-components.svg\">\n <img src=\"img/polymer.svg\" class=\"animate\">\n </div>`\n }", "title": "" }, { "docid": "a830c1636ac36c29e7cb3efb5f590c68", "score": "0.5173661", "text": "render() {\n return html`${devToolsTemplate({\n currentZoom: this.store.currentZoom,\n closeTools: this.closeTools,\n })}`;\n }", "title": "" }, { "docid": "49642ea714b9f8f781539a1890c74b80", "score": "0.51729506", "text": "function showMap(lat, long) {\n let mapContainer = document.getElementById(\"searchable-map\"); \n map = new google.maps.Map(mapContainer, {\n zoom: 6,\n center: { lat: lat, lng: long },\n zoomControl: true,\n });\n}", "title": "" }, { "docid": "1420489ed97e03e8464f55e3199e783d", "score": "0.51669645", "text": "getMapImage(address, height, locality, mapStyle, markerColor, postalCode, region, width, zoom) {\n let center = this.getMapImageCenter(address, locality, postalCode, region);\n let marker = this.getMapImageMarker(center, markerColor);\n let style = this.getMapImageStyle(mapStyle);\n let mapImage = (\n \"https://maps.googleapis.com/maps/api/staticmap?\" + \n \"center=\" + center + \n \"&zoom=\" + zoom + \n \"&size=640x640\" +\n \"&scale=2\" +\n //\"&markers=\" + marker + \n style + \n \"&key=AIzaSyCy0TJ-oTgR8qIe5SxF4UIwB1m2KHvpViU\"\n );\n return mapImage;\n }", "title": "" }, { "docid": "4f3773f1ad876232b6bb61205fa3c330", "score": "0.5166571", "text": "loadMap() {\n if (this.props && this.props.google) {\n //make sure GAPI is available\n //check if google is available\n const { google } = this.props;\n const maps = google.maps;\n const mapRef = this.refs.map;\n\n //reference to the actual DOM element on the page not the Virtual DOM.\n //we can set the google map to work directly\n const node = ReactDOM.findDOMNode(mapRef); //grab ref to the dom where we want the map to be placed\n\n //instantiate google map, not hard coded values\n let { zoom } = this.props;\n const { lat, lng, name } = this.state.currentLocation; //pulling info from the state rther than props\n const center = new maps.LatLng(lat, lng, name);\n const mapConfig = Object.assign(\n {},\n {\n //we need atleast 2 config options,\n center: center, //combination of lat and ong\n zoom: zoom\n }\n );\n this.map = new maps.Map(node, mapConfig); //constructor is accepting a DOM node and configuration object to create a map\n }\n }", "title": "" }, { "docid": "e3d0d7668f65726b2f482c05df7c4802", "score": "0.5163676", "text": "function initMap() {\r\n // The location of mcdVO\r\n const uluru = { lat: 59.943438375591796, lng: 30.27871813055042 };\r\n // The map, centered at mcdVO\r\n const map = new google.maps.Map(document.getElementById(\"map\"), {\r\n zoom: 17,\r\n center: uluru,\r\n });\r\n // The marker, positioned at mcdVO\r\n const marker = new google.maps.Marker({\r\n position: uluru,\r\n map: map,\r\n });\r\n}", "title": "" }, { "docid": "bea27c7dfdecc01e2fb73d9080bffcf3", "score": "0.51632106", "text": "function add_css$3() {\n var style = element(\"style\");\n style.id = \"svelte-1ps4wd3-style\";\n style.textContent = \".province-tooltip.svelte-1ps4wd3.svelte-1ps4wd3{position:absolute;z-index:100;width:42%;min-width:120px;background-color:#FFFFFF;box-shadow:0 1px 2px rgba(0,0,0,0.07), \\n 0 2px 4px rgba(0,0,0,0.07), \\n 0 4px 8px rgba(0,0,0,0.07)}.tooltip-content.svelte-1ps4wd3.svelte-1ps4wd3{width:100%;height:100%;padding:0.4em;color:#333333}.tooltip-title.svelte-1ps4wd3.svelte-1ps4wd3{display:flex;align-items:baseline;justify-content:space-between;border-bottom:0.15em solid #333333}.tooltip-h3.svelte-1ps4wd3.svelte-1ps4wd3{margin:0;font-size:1.3em;font-weight:normal}.tooltip-h3.margin-r.svelte-1ps4wd3.svelte-1ps4wd3{margin-right:0.3em}.tooltip-h3.margin-l.svelte-1ps4wd3.svelte-1ps4wd3{margin-left:0.3em}.tooltip-h4.svelte-1ps4wd3.svelte-1ps4wd3{font-size:1em;font-weight:bold}.excess-deaths.svelte-1ps4wd3.svelte-1ps4wd3{padding:0 0.2em;border:none;border-radius:2px}.deaths.svelte-1ps4wd3.svelte-1ps4wd3{width:100%;margin:0.3em 0;font-size:1em}table.svelte-1ps4wd3.svelte-1ps4wd3{width:100%;border-collapse:collapse}tr.svelte-1ps4wd3 td.svelte-1ps4wd3{padding:0.1em 0.2em 0.1em 0}tr.svelte-1ps4wd3 td.svelte-1ps4wd3:nth-child(2){font-weight:bold;text-align:right;vertical-align:top}.hidden.svelte-1ps4wd3.svelte-1ps4wd3{visibility:hidden}\";\n append(document.head, style);\n} // (70:54) {#if ($dir === 'ltr' && /\\./.test(f(tooltip.data.estimatedDeaths)))}", "title": "" }, { "docid": "952a8bd946a39145a0a814266696ecfa", "score": "0.515792", "text": "addMarker() {\n return (\n <Marker\n ref=\"marker\"\n position={ this.state.DPCCoords }\n animation={ google.maps.Animation.DROP }\n icon={{\n path: 'M61.5,0 C91,0 125,24.5 125,62.5 C125,94.5181999 78,185.5 61.5,185.5 C45,185.5 0,102.807291 0,62.5 C0,25 32,0 61.5,0 Z M63,96 C81.7776815,96 97,80.7776815 97,62 C97,43.2223185 81.7776815,28 63,28 C44.2223185,28 29,43.2223185 29,62 C29,80.7776815 44.2223185,96 63,96 Z',\n scale: 1 / 4,\n size: new google.maps.Size(1550, 10),\n anchor: new google.maps.Point(0, 130),\n fillColor: '#000',\n fillOpacity: 1\n }}\n onClick={ () => this.handleInfoWindowDisplayState() }>\n { this.state.infoWindowActive ? this.renderInfoWindow() : null }\n </Marker>\n );\n }", "title": "" }, { "docid": "593d6a08694dd703a9405a13f5cd8eb0", "score": "0.5154098", "text": "function getMarkerData(results){\n var myLatLng = [];\n var locationNames = [];\n var shelterPhone;\n var shelterEmail;\n var dataPath = results.petfinder.shelters.shelter;\n for(var i=0; i<dataPath.length; i++){\n\n myLatLng.push([dataPath[i].latitude.$t, dataPath[i].longitude.$t]);\n\n if(dataPath[i].phone.$t == undefined){\n shelterPhone = \"Sorry! No number listed\";\n }\n else if(dataPath[i].phone.$t == '000-000-0000'){\n shelterPhone = 'Sorry! No number listed';\n }\n else{\n shelterPhone = dataPath[i].phone.$t;\n }\n\n if(dataPath[i].email.$t == undefined){\n shelterEmail = 'Sorry! No Email Listed'\n }\n else{\n shelterEmail = '<a href=\"mailto:\"' + dataPath[i].email.$t + '>' + dataPath[i].email.$t + '</a>';\n }\n\n locationNames.push('<div class=\"location-obj\"> <h3 class=\"name\">' + dataPath[i].name.$t + '</h3>' +\n '<h4>' + dataPath[i].city.$t + ', ' + dataPath[i].state.$t + '</h4>' +\n '<h4>' + shelterPhone + '</h4>' +\n '<h4>Email us: ' + shelterEmail + '</h4> </div>' );\n\n }\n\n renderMarkers(myLatLng, locationNames);\n}", "title": "" }, { "docid": "c771597a86724e37ce77ee155d534580", "score": "0.5151619", "text": "function showMarker(marker, content)\n// Show a marker and open it's info window\n{\n\tEffect.ScrollTo('map');\n google_map.closeInfoWindow(); // else get problems\n eval(marker + \".openInfoWindowHtml(\\'\"+content+\"\\');\");\n //eval(\"GEvent.trigger(\" + marker[0] + \", click)\");\n}", "title": "" }, { "docid": "3a46f00f1d027c2e8864bd6e692363ba", "score": "0.5145281", "text": "function moveableMarker() {\n let blankBin = createBinElement(3); //creates DOM element for moveable marker\n\n var center = map.getCenter();\n var popup = new tt.Popup({\n offset: 35,\n });\n moveablePin = new tt.Marker({\n draggable: true,\n element: blankBin,\n })\n .setLngLat(center)\n .addTo(map);\n\n function onDragEnd() {\n var lngLat = moveablePin.getLngLat();\n markerLng.push(lngLat.lng);\n markerLat.push(lngLat.lat);\n popup.setHTML(lngLat.toString());\n popup.setLngLat(lngLat);\n moveablePin.setPopup(popup);\n moveablePin.togglePopup();\n }\n moveablePin.on(\"dragend\", onDragEnd);\n hide();\n markerSet = true;\n document.querySelector(\"#placePin\").onclick = \"\";\n}", "title": "" }, { "docid": "6ea6034743870ac0cd43c10af31d5cb8", "score": "0.51430404", "text": "function addMarker(body) {\n var marker = new google.maps.Marker({\n map: map,\n position: {lat:body.lat, lng:body.lng}\n });\n // adds event listener\n marker.addListener(\"click\", () => {\n infowindow.setContent(generateHtmlPracInfo(body));\n infowindow.open(map, marker);\n });\n markers.push(marker);\n }", "title": "" }, { "docid": "da9bf059234f380d95727b3a0798a15d", "score": "0.5141146", "text": "function initMap() {\n // The location of Uluru\n const center = { lat: pointInside.latitude, lng: pointInside.longitude };\n // The map, centered at Uluru\n const map = new google.maps.Map(\n document.getElementById(\"map\"),\n {\n zoom: 15,\n center: center,\n mapTypeId: 'satellite',\n }\n );\n\n const parkGorkogo = coordinates.map(point=>({lat: point.latitude, lng: point.longitude}))\n\n \n\n const park = new google.maps.Polyline({\n path: parkGorkogo,\n geodesic: true,\n strokeColor: \"#43b02a\",\n strokeOpacity: 0.8,\n strokeWeight: 2,\n });\n park.setMap(map);\n \n const svgMarker = (isIn) => ({\n path: google.maps.SymbolPath.CIRCLE,\n fillColor: isIn ? \"#43b02a\" : 'red',\n fillOpacity: 1,\n strokeWeight: 0,\n rotation: 0,\n scale: 3,\n //anchor: new google.maps.Point(15, 30),\n });\n \n\n createDotPool(coordinates).forEach(point=>{\n const dot = new google.maps.Marker({\n position: {lat: point.latitude, lng: point.longitude},\n icon: svgMarker(inside([point.latitude, point.longitude], coordinates.map(point=>[point.latitude, point.longitude]))),\n }); \n dot.setMap(map)\n })\n \n let infoWindow = new google.maps.InfoWindow({\n content: \"Это парк Горького!\",\n position: center,\n });\n infoWindow.open(map);\n \n // Configure the click listener.\n map.addListener(\"click\", (mapsMouseEvent) => {\n // Close the current InfoWindow.\n infoWindow.close();\n \n // Create a new InfoWindow.\n infoWindow = new google.maps.InfoWindow({\n position: mapsMouseEvent.latLng,\n });\n infoWindow.setContent(\n checkPoint(mapsMouseEvent.latLng.toJSON())\n );\n infoWindow.open(map);\n });\n\n }", "title": "" }, { "docid": "6d0050b64c4263197b25d0d9eebb4913", "score": "0.5139463", "text": "function initMap() {\n $(siteLoader).html(\"<div id='mapBox'></div>\");//create map container\n var mapBox = document.getElementById(\"mapBox\");\n //mapBox.setAttribute(\"id\", \"googleMap\");\n\n var mapOptions = {\n zoom: 17,\n center: {lat: lastPos.lat, lng: lastPos.lng}\n };\n\n //now insert the map\n var map = new google.maps.Map(mapBox, mapOptions);\n\n //create a marker for user's position\n var marker = new google.maps.Marker({\n position: lastPos,\n map: map\n });\n\n var mark;\n\n //Show markers for each waypoint using custom markers\n for (i = 0; i < waypointsArr.length; i++) {\n var pos = new google.maps.LatLng(waypointsArr[i].coords.lat, waypointsArr[i].coords.lng);\n mark = new google.maps.Marker({\n position: pos,\n map: map,\n title: waypointsArr[i].name,\n icon: \"./icon.png\"\n });\n }\n}", "title": "" }, { "docid": "4dfd99cbae18880f36b467a022db06a6", "score": "0.5136387", "text": "componentDidMount() {\r\n // new embedded Google Map inside our App\r\n // Map(HTML Element --> div , Options Object)\r\n new google.maps.Map(this.refs.map, {\r\n zoom: 12,\r\n center: {\r\n lat: this.props.lat,\r\n lng: this.props.lon\r\n }\r\n });\r\n }", "title": "" }, { "docid": "f1838fe641f3e92b0bf75b62a1f10ac9", "score": "0.5135603", "text": "function markerElements() {\n return markerLocations.map((location) => {\n const [lat, lng] = location.split(',');\n return (\n <Marker\n position={{\n lat: Number(lat),\n lng: Number(lng),\n }}\n key={`${lat}-${lng}`}\n />\n );\n });\n }", "title": "" }, { "docid": "32d2b942cea7ba56d78fb6fc00a4c89d", "score": "0.5132977", "text": "function initMap() {\n let map = new google.maps.Map(\n document.getElementById('map'), {zoom: 11, center: coordinates});\n\n let marker = new google.maps.Marker({position: coordinates, map: map});\n}", "title": "" }, { "docid": "0144840f5d092ea4820c25b23100ec85", "score": "0.51318467", "text": "function getInfoContent(marker) {\n let markerContent = \"<div class='map-marker-infowindow'>\";\n markerContent += `<h2>${marker.title}</h2>`;\n const categoryName = categoryToName(marker.category);\n markerContent += `<h4>${categoryName}</h4>`;\n // Add description\n if (marker.description) { markerContent += `<p>${marker.description}</p>`; }\n // If contact details have been provided, add them\n if (marker.phone || marker.website || marker.email) {\n markerContent += '<h3>Contact:</h3>';\n // Values put in to each span to prevent new lines from being created\n if (marker.phone) { markerContent += `<p><span class=\"english-text\"><u>Phone number:</u> ${marker.phone}</span><span class=\"french-text\"><u>Téléphone:</u> ${marker.phone}</span></p>`; }\n if (marker.email) { markerContent += `<p><span class=\"english-text\"><u>Email address:</u> ${marker.email}</span><span class=\"french-text\"><u>Email:</u> ${marker.email}</span></p>`; }\n if (marker.website) { markerContent += `<p><span class=\"english-text\"><u>Website:</u> <a href=${marker.website} target=\"_blank\">${marker.website}</a></span><span class=\"french-text\"><u>Site Internet:</u> <a href=${marker.website} target=\"_blank\">${marker.website}</a></span></p>`; }\n }\n // If address details have been provided, add them\n if (marker.address_line_1 || marker.address_line_2 || marker.postcode) {\n markerContent += '<h3><span class=\"english-text\">Address:</span><span class=\"french-text\">Adresse:</span></h3>';\n if (marker.address_line_1) { markerContent += `<p>${marker.address_line_1}</p>`; }\n if (marker.address_line_2) { markerContent += `<p>${marker.address_line_2}</p>`; }\n if (marker.postcode) { markerContent += `<p>${marker.postcode}</p>`; }\n }\n if (marker.notes) { markerContent += `<h3><span class=\"english-text\">Additional Information:</span><span class=\"french-text\">Information additionnelle:</span></h3><p>${marker.notes}</p>`; }\n markerContent = markerContent + '</div>';\n\n return markerContent;\n}", "title": "" }, { "docid": "6fc633b18b094a61f38cc8c6ec283965", "score": "0.51296395", "text": "function initMap() {\n var myLocation ={lat:39.310842, lng:-76.749990};\n var myProp ={\n center:myLocation,\n zoom:5\n }\n \n var map = new google.maps.Map(document.getElementById('map'),myProp);\n // var marker = new google.maps.Marker({position: myLocation,\n // animation:google.maps.Animation.BOUNCE});\n var marker = new google.maps.Marker({\n position:myLocation,\n // icon: document.querySelector('.fa-thumbtack')\n });\n\n marker.setMap(map);\n \n}", "title": "" }, { "docid": "ced8f210c1f3612181b344fcd9392996", "score": "0.5125327", "text": "function loadMapUrl(){\n const scriptTag = window.document.createElement('script');\n const apiKey = 'AIzaSyASFSGSrxEXyjwZSqMyzRJBbfq_eFutui8';\n scriptTag.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=initMap`;\n scriptTag.async = true;\n scriptTag.defer = true;\n document.body.appendChild(scriptTag);\n}", "title": "" }, { "docid": "2e52c8073aa327a9f0f4987333af6f87", "score": "0.51243865", "text": "function myMap() {\n var myLatLng = { lat: 45.479550, lng: -73.622227 };\n var mapOptions = {\n center: myLatLng,\n zoom: 15,\n }\n var map = new google.maps.Map(document.getElementById(\"map\"), mapOptions);\n var marker = new google.maps.Marker({\n position: myLatLng,\n map: map,\n title: 'Dessert Cafe MOMO'\n });\n\n}", "title": "" } ]
89737613b5118b36d411ef9839fe80a5
supports only 2.0style subtract(1, 's') or subtract(duration)
[ { "docid": "c9d767fd554341003432c94672471e3c", "score": "0.0", "text": "function subtract$1 (input, value) {\n\t return addSubtract$1(this, input, value, -1);\n\t}", "title": "" } ]
[ { "docid": "7d0729f166432bb4dfac383cc4da53a2", "score": "0.76113844", "text": "function duration_add_subtract__subtract (input, value) { // 3331\n return duration_add_subtract__addSubtract(this, input, value, -1); // 3332\n } // 3333", "title": "" }, { "docid": "ef0db4610b5a08717c65f97531a3c18c", "score": "0.7408137", "text": "function duration_add_subtract__subtract (input, value) {\r\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\r\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "23331baa4c2fc9d7a19b331404e74210", "score": "0.7400228", "text": "function duration_add_subtract__subtract (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "91fbdb5a5d2815460af0e8f4f3f76c48", "score": "0.73801476", "text": "function duration_add_subtract__subtract(input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, -1);\n\t }", "title": "" }, { "docid": "2add934f55aabe69c6e24611bc7df78f", "score": "0.7283907", "text": "function duration_add_subtract__subtract(input, value) {\n\t\t\t\treturn duration_add_subtract__addSubtract(this, input, value, -1);\n\t\t\t}", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "ed49f291ca13451c0e81ab41768a2009", "score": "0.72737086", "text": "function duration_add_subtract__subtract (input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "25dfb9df5974d8df721ac725feff995c", "score": "0.72733074", "text": "function duration_add_subtract__subtract(input, value) {\n\t\t\treturn duration_add_subtract__addSubtract(this, input, value, -1);\n\t\t}", "title": "" }, { "docid": "d1df8357eb98b1b97f63ddbf6fe99cf0", "score": "0.7232978", "text": "function duration_add_subtract__subtract(input, value) {\n return duration_add_subtract__addSubtract(this, input, value, -1);\n }", "title": "" }, { "docid": "8c638772eb917ec5b1efbc88bfaa995b", "score": "0.6879361", "text": "function duration_add_subtract__add (input, value) { // 3326\n return duration_add_subtract__addSubtract(this, input, value, 1); // 3327\n } // 3328", "title": "" }, { "docid": "2f996fe92313a6fb4be7255cbefe791c", "score": "0.6774517", "text": "function duration_add_subtract__add (input, value) {\r\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\r\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" }, { "docid": "0cc5d0000bfc9d5735aeeb18d172896c", "score": "0.6675781", "text": "function duration_add_subtract__add (input, value) {\n\t return duration_add_subtract__addSubtract(this, input, value, 1);\n\t }", "title": "" } ]
76766bc64b3408d76fd07a88f06ac824
Bind a transform to be only applied in list
[ { "docid": "87f5c5dec8194895933b3d69f1e66bf6", "score": "0.7031561", "text": "function bindTransform(fn) {\n return function (transform) {\n var state = transform.state;\n\n\n if (!isSelectionInBlockquote(state)) {\n return transform;\n }\n\n for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n return fn.apply(undefined, _toConsumableArray([opts, transform].concat(args)));\n };\n }", "title": "" } ]
[ { "docid": "ebf2a2299699f272c5201844426b0898", "score": "0.74767005", "text": "function bindTransform(fn) {\n return function (transform) {\n var state = transform.state;\n\n\n if (!isSelectionInList(opts, state)) {\n return transform;\n }\n\n for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n return fn.apply(undefined, _toConsumableArray([opts, transform].concat(args)));\n };\n }", "title": "" }, { "docid": "7aeef3e354f15b375ef73e9227f195a5", "score": "0.72920203", "text": "function bindTransform(fn) {\n return function(transform, ...args) {\n const { state } = transform;\n\n if (!isSelectionInList(state)) {\n return transform;\n }\n\n return fn(...[opts, transform].concat(args));\n };\n }", "title": "" }, { "docid": "f62bc7a5c195776debff158d8167844c", "score": "0.66447526", "text": "set transform(value) {}", "title": "" }, { "docid": "f62bc7a5c195776debff158d8167844c", "score": "0.66447526", "text": "set transform(value) {}", "title": "" }, { "docid": "f62bc7a5c195776debff158d8167844c", "score": "0.66447526", "text": "set transform(value) {}", "title": "" }, { "docid": "ce09a4e5af7c7fc2e4064deae0542165", "score": "0.6312334", "text": "transform(value) {\n check(value, Match.OneOf(Function, null));\n this._transform = value;\n return this;\n }", "title": "" }, { "docid": "1af74d3aef3fbda685424d8f6c4d1716", "score": "0.61793226", "text": "get transform() {}", "title": "" }, { "docid": "1af74d3aef3fbda685424d8f6c4d1716", "score": "0.61793226", "text": "get transform() {}", "title": "" }, { "docid": "1af74d3aef3fbda685424d8f6c4d1716", "score": "0.61793226", "text": "get transform() {}", "title": "" }, { "docid": "6bfca90227c22289bd19e153e3407f2d", "score": "0.59729946", "text": "[transform]() {\n this[status] = STATE.NULL;\n this[parser].result.forEach((node, index, list) => {\n // for ignore block\n if (this[status]===STATE.IGNORE){\n list[index] = null;\n return;\n }\n // for common block\n let func = this[node.nodeType];\n if (typeof func==='function'){\n func.apply(this, arguments);\n }else{\n this[defau1t].apply(this, arguments);\n }\n });\n }", "title": "" }, { "docid": "4c6722437d77a3c56f22059541b31138", "score": "0.57542855", "text": "function wrapHook (value, transforms) {\n transforms.forEach(function (transform) {\n value = transform(value)\n })\n return value\n}", "title": "" }, { "docid": "ab970fe08180a32af8b8561d183c9350", "score": "0.57514673", "text": "function transform(t) {\n return function(d) {\n //console.log(d)\n return \"translate(\" + t.apply(d) + \")\";\n\n // Equivalent code, splitting X and Y amount\n //return \"translate(\" + t.applyX(d[0]) + \", \" + t.applyY(d[1]) + \")\";\n };\n}", "title": "" }, { "docid": "db8f029ff16429c2a0051871551d2c51", "score": "0.573563", "text": "function wrapHook(value, transforms) {\n transforms.forEach(function (transform) {\n value = transform(value);\n });\n return value;\n}", "title": "" }, { "docid": "8209f73e8987b7614e78521bf4bf622d", "score": "0.5662546", "text": "applyToPoint(point) {\n var {\n transforms\n } = this;\n var len = transforms.length;\n\n for (var i = 0; i < len; i++) {\n transforms[i].applyToPoint(point);\n }\n }", "title": "" }, { "docid": "bcbb495843c40f474e634ae082f5c9ae", "score": "0.56237364", "text": "map(fn) {\n return new Compose(this.$value.map((x) => x.map(fn)));\n }", "title": "" }, { "docid": "95f63081b7e0b67823d37809099506cc", "score": "0.5621333", "text": "AddMixingTransform() {}", "title": "" }, { "docid": "be9dfb8fee42b7ecb52fa90a20232aa4", "score": "0.56176895", "text": "transform(type){\n\n\t}", "title": "" }, { "docid": "47544b45a9bd0ee2fbd6b72be230523e", "score": "0.5515584", "text": "SetContextTransform(ctx) {\n let v = this.values; //convenience\n ctx.setTransform(v[0][0], v[1][0], v[0][1], v[1][1], v[0][2], v[1][2]);\n }", "title": "" }, { "docid": "97f3c6c8339f7cd15c4a8e4b46e9a240", "score": "0.54097563", "text": "function runTransforms(content, flist) {\n let args = [this, content];\n const funcArgs = Array.from(arguments);\n funcArgs.shift();\n funcArgs.shift();\n args = args.concat(funcArgs);\n\n if (flist) {\n const methods = flist.split(/\\s+/);\n\n for (let j = 0; j < methods.length; j++) {\n const meth = methods[j];\n\n if (window[meth]) {\n // the initial call passed |this| directly, so we keep it that way\n try {\n content = window[meth].apply(this, args);\n } catch (e) {\n (0, _pubsubhub.pub)(\"warn\", \"call to `\".concat(meth, \"()` failed with: \").concat(e, \". See error console for stack trace.\"));\n console.error(e);\n }\n }\n }\n }\n\n return content;\n }", "title": "" }, { "docid": "6ee115189117deefbc91cca26b90d213", "score": "0.54076934", "text": "_setTransforms() {\n if (this._funcs.length > 0) {\n this._target.style.transform = `matrix(\n ${this._funcs[0].transforms[0] || 1}, \n ${this._funcs[0].transforms[1] || 0}, \n ${this._funcs[0].transforms[2] || 0}, \n ${this._funcs[0].transforms[3] || 1}, \n ${this._funcs[0].transforms[4] || 0}, \n ${this._funcs[0].transforms[5] || 0})`;\n }\n }", "title": "" }, { "docid": "65064fe129e2441f091b6086ec1470be", "score": "0.5372247", "text": "function transformFunction(model) {\n\tvar transform = model.toJSON();\n\ttransform.item = '[' + transform.item + ']';\n\t//transform.done = '[' + transform.done + ']';\n\treturn transform;\n}", "title": "" }, { "docid": "86c537d77941c0fb8c073e035d4af2fc", "score": "0.5359129", "text": "transform(value, mappingFunction, thisArg) {\n return mappingFunction.apply(thisArg || this, Array.isArray(value) ? value : [value]);\n }", "title": "" }, { "docid": "0189b6a9ca2d328f922670f1a5fb951d", "score": "0.5335492", "text": "function ulTransform(e, transform) {\n if (transform === 0) {\n //account for invalid input of '-0px'\n e.style[\"-webkit-transform\"] = \"translate(0px, 0px)\";\n e.style[\"-moz-transform\"] = \"translate(0px, 0px)\";\n e.style[\"-ms-transform\"] = \"translate(0px, 0px)\";\n e.style[\"-o-transform\"] = \"translate(0px, 0px)\";\n e.style.transform = \"translate(0px, 0px)\";\n } else {\n //move the slider horizontally\n e.style[\"-webkit-transform\"] = \"translate(-\" + transform + \"px, 0px)\";\n e.style[\"-moz-transform\"] = \"translate(-\" + transform + \"px, 0px)\";\n e.style[\"-ms-transform\"] = \"translate(-\" + transform + \"px, 0px)\";\n e.style[\"-o-transform\"] = \"translate(-\" + transform + \"px, 0px)\";\n e.style.transform = \"translate(-\" + transform + \"px, 0px)\";\n }\n }", "title": "" }, { "docid": "e975596ffa7173e24a4b62c1fc15595d", "score": "0.52998894", "text": "function transform(el, value) {\n el.style['transform'] = value;\n el.style['webkitTransform'] = value;\n}", "title": "" }, { "docid": "d426ea1ee583fa153a78aea32a818b93", "score": "0.5296074", "text": "function makeListTransformer(func) {\n return function(collection) {\n return collection.map(func);\n };\n}", "title": "" }, { "docid": "d2e92eb5514bbc74318bfaea60fe4d38", "score": "0.5288052", "text": "function appendTransform(defaultTransform, transform) {\n\t\tdefaultTransform = angular.isArray(defaultTransform) ? defaultTransform : [ defaultTransform ];\n\t\treturn defaultTransform.concat(transform);\n\t}", "title": "" }, { "docid": "8b5414d4e63b5226017aa01a618843ad", "score": "0.5273523", "text": "function transformModel(){\n\n}", "title": "" }, { "docid": "ac8abfdb591dba31d856d52775cd50f4", "score": "0.52653277", "text": "function mapTransform(args, math, scope) {\n var x, callback;\n\n if (args[0]) {\n x = args[0].compile().evaluate(scope);\n }\n\n if (args[1]) {\n if (Object(_utils_is__WEBPACK_IMPORTED_MODULE_0__[\"isSymbolNode\"])(args[1]) || Object(_utils_is__WEBPACK_IMPORTED_MODULE_0__[\"isFunctionAssignmentNode\"])(args[1])) {\n // a function pointer, like filter([3, -2, 5], myTestFunction)\n callback = args[1].compile().evaluate(scope);\n } else {\n // an expression like filter([3, -2, 5], x > 0)\n callback = Object(_utils_compileInlineExpression__WEBPACK_IMPORTED_MODULE_4__[\"compileInlineExpression\"])(args[1], math, scope);\n }\n }\n\n return map(x, callback);\n }", "title": "" }, { "docid": "38378dd283b2ef37f9aad771a7d27e5c", "score": "0.52554595", "text": "function mapTransform(args, math, scope) {\n var x, callback;\n\n if (args[0]) {\n x = args[0].compile().evaluate(scope);\n }\n\n if (args[1]) {\n if ((0,_utils_is_js__WEBPACK_IMPORTED_MODULE_1__.isSymbolNode)(args[1]) || (0,_utils_is_js__WEBPACK_IMPORTED_MODULE_1__.isFunctionAssignmentNode)(args[1])) {\n // a function pointer, like filter([3, -2, 5], myTestFunction)\n callback = args[1].compile().evaluate(scope);\n } else {\n // an expression like filter([3, -2, 5], x > 0)\n callback = (0,_utils_compileInlineExpression_js__WEBPACK_IMPORTED_MODULE_2__.compileInlineExpression)(args[1], math, scope);\n }\n }\n\n return map(x, callback);\n }", "title": "" }, { "docid": "3c5f4d99602b1a21ce34ba966102dc25", "score": "0.5181532", "text": "function transformFunction(model) {\n\tvar transform = model.toJSON();\n\ttransform.item = transform.item;\n\treturn transform;\n}", "title": "" }, { "docid": "d26ec7762a4bb7b438d60f82f1b2492b", "score": "0.51637924", "text": "transform(){\n\t\tthis.fragment.transform && this.fragment.transform();\n\t\tthis.vertex.transform && this.vertex.transform();\n\t}", "title": "" }, { "docid": "c4862c3ec8466715923d977303058876", "score": "0.51473033", "text": "function mapTransform(args, math, scope) {\n var x, callback;\n\n if (args[0]) {\n x = args[0].compile().evaluate(scope);\n }\n\n if (args[1]) {\n if (Object(is[\"J\" /* isSymbolNode */])(args[1]) || Object(is[\"q\" /* isFunctionAssignmentNode */])(args[1])) {\n // a function pointer, like filter([3, -2, 5], myTestFunction)\n callback = args[1].compile().evaluate(scope);\n } else {\n // an expression like filter([3, -2, 5], x > 0)\n callback = compileInlineExpression(args[1], math, scope);\n }\n }\n\n return map(x, callback);\n }", "title": "" }, { "docid": "b457d2a43a7bf92599e2349fff9f52ff", "score": "0.51462877", "text": "function transform ( arr, trans) {\n\t\tarr.forEach( function(element, index) {\n\t\t\tarr[index] = trans (element) ;\n\t\t});\n\t\treturn arr;\n\t}", "title": "" }, { "docid": "5c5d588dcaee602597a1c8771dcfeb15", "score": "0.51266915", "text": "function addTimelineTransforms(el, transform) {\r\n el.style.webkitTransform = transform;\r\n el.style.msTransform = transform;\r\n el.style.transform = transform;\r\n }", "title": "" }, { "docid": "60df447f30208d60f4acad703f927acb", "score": "0.51153976", "text": "applyTweenTransforms() {\n var tween = this.getActiveTween();\n\n if (tween) {\n this.clips.forEach(clip => {\n tween.applyTransformsToClip(clip);\n });\n }\n }", "title": "" }, { "docid": "e743ab5087136d31f97e035858d3723b", "score": "0.5113908", "text": "function wrapTransform(transform) {\n if (! transform)\n return null;\n\n // No need to doubly-wrap transforms.\n if (transform.__wrappedTransform__)\n return transform;\n\n var wrapped = function (doc) {\n if (doc._id) {\n // XXX do we ever have a transform on the oplog's collection? because that\n // collection has no _id.\n throw new Error(\"can only transform documents with _id\");\n }\n\n var id = doc._id;\n // XXX consider making tracker a weak dependency and checking Package.tracker here\n var transformed = Tracker.nonreactive(function () {\n return transform(doc);\n });\n\n if (!isPlainObject(transformed)) {\n throw new Error(\"transform must return object\");\n }\n\n if (transformed._id) {\n if (!EJSON.equals(transformed._id, id)) {\n throw new Error(\"transformed document can't have different _id\");\n }\n } else {\n transformed._id = id;\n }\n return transformed;\n };\n wrapped.__wrappedTransform__ = true;\n return wrapped;\n}", "title": "" }, { "docid": "8d7fab95e93e2f22431e6b00baefc21e", "score": "0.51089686", "text": "function setTransform({ target: { classList, dataset, name, value } }) {\n // NOTE: 'rotate' and 'scale' have more than one param\n if (classList.contains('transform-config')) {\n const { transform, id } = dataset;\n session.transformTarget[transform][+id] = value;\n } else {\n session.transformTarget[name] = value;\n }\n\n applyTransforms(drawing, session);\n}", "title": "" }, { "docid": "4a7402e78d3d680bdcfc2f49a38f1f9c", "score": "0.5098784", "text": "cloneTransformed(transform) {\n const c = this.clone();\n c.tryTransformInPlace(transform);\n return c;\n }", "title": "" }, { "docid": "b1486f05eb2ca33482e879ba81676c72", "score": "0.50764805", "text": "function transform_install_install(registers) {\n registers.registerTransform(filterTransform);\n registers.registerTransform(sortTransform);\n}", "title": "" }, { "docid": "680cf68b6b03680160ea99b8350aa692", "score": "0.5059458", "text": "function simpleBind(context,fn){return function(value){fn.call(context,value)}}", "title": "" }, { "docid": "3ae748eefba988a9628d72f3e3ff3a2c", "score": "0.5052307", "text": "function wrapTransform(transform) {\n if (!transform) return null;\n\n // No need to doubly-wrap transforms.\n if (transform.__wrappedTransform__) return transform;\n\n var wrapped = function (doc) {\n if (!hasOwn(doc, '_id')) {\n // XXX do we ever have a transform on the oplog's collection? because that\n // collection has no _id.\n throw new Error('can only transform documents with _id');\n }\n\n var id = doc._id;\n // XXX consider making tracker a weak dependency and checking Package.tracker here\n var transformed = Tracker.nonreactive(function () {\n return transform(doc);\n });\n\n if (!isPlainObject(transformed)) {\n throw new Error('transform must return object');\n }\n\n if (hasOwn(transformed, '_id')) {\n if (!EJSON.equals(transformed._id, id)) {\n throw new Error(\"transformed document can't have different _id\");\n }\n } else {\n transformed._id = id;\n }\n return transformed;\n };\n wrapped.__wrappedTransform__ = true;\n return wrapped;\n}", "title": "" }, { "docid": "0014a7db8826be7d6511ff930ffed97f", "score": "0.50507057", "text": "map(fn) {\n return Identity.of(fn(this.$value))\n }", "title": "" }, { "docid": "2fe7b550d0be16967905be172a1dc402", "score": "0.5045037", "text": "function transform(baseArray) {\n return baseArray.map(function(elem, i, arr) {\n elem = function() {\n var idx = i;\n var refArr = arr;\n console.log(refArr[idx]);\n };\n return elem;\n })\n}", "title": "" }, { "docid": "fd2072086b4824f0bf76bba8c88f9057", "score": "0.5039552", "text": "function applyTransform(element, transform) {\n\t//console.log(transform)\n\telement.css({\n\t\t'-webkit-transform': transform,\n\t\t'-moz-transform': transform,\n\t\t'-ms-transform': transform,\n\t\t'-o-transform': transform,\n\t\t'transform': transform\n\t});\n}", "title": "" }, { "docid": "1209d393bbfd2b46c168ad836ff35837", "score": "0.502659", "text": "transformInPlace(transform) {\n const data = this._data;\n const nDouble = this.float64Length;\n const coffs = transform.matrix.coffs;\n const origin = transform.origin;\n const x0 = origin.x;\n const y0 = origin.y;\n const z0 = origin.z;\n let x = 0;\n let y = 0;\n let z = 0;\n for (let i = 0; i + 3 <= nDouble; i += 3) {\n x = data[i];\n y = data[i + 1];\n z = data[i + 2];\n data[i] = coffs[0] * x + coffs[1] * y + coffs[2] * z + x0;\n data[i + 1] = coffs[3] * x + coffs[4] * y + coffs[5] * z + y0;\n data[i + 2] = coffs[6] * x + coffs[7] * y + coffs[8] * z + z0;\n }\n }", "title": "" }, { "docid": "9ad9928abd03e0845b99e00c079d401f", "score": "0.50141096", "text": "function forEachTransform(args, math, scope) {\n var x, callback;\n\n if (args[0]) {\n x = args[0].compile().evaluate(scope);\n }\n\n if (args[1]) {\n if (Object(_utils_is__WEBPACK_IMPORTED_MODULE_0__[\"isSymbolNode\"])(args[1]) || Object(_utils_is__WEBPACK_IMPORTED_MODULE_0__[\"isFunctionAssignmentNode\"])(args[1])) {\n // a function pointer, like forEach([3, -2, 5], myTestFunction)\n callback = args[1].compile().evaluate(scope);\n } else {\n // an expression like forEach([3, -2, 5], x > 0 ? callback1(x) : callback2(x) )\n callback = Object(_utils_compileInlineExpression__WEBPACK_IMPORTED_MODULE_4__[\"compileInlineExpression\"])(args[1], math, scope);\n }\n }\n\n return _forEach(x, callback);\n }", "title": "" }, { "docid": "5b898faa4f2be14b5d2cec3cb889ec43", "score": "0.49862447", "text": "function forEachTransform(args, math, scope) {\n var x, callback;\n\n if (args[0]) {\n x = args[0].compile().evaluate(scope);\n }\n\n if (args[1]) {\n if ((0,_utils_is_js__WEBPACK_IMPORTED_MODULE_1__.isSymbolNode)(args[1]) || (0,_utils_is_js__WEBPACK_IMPORTED_MODULE_1__.isFunctionAssignmentNode)(args[1])) {\n // a function pointer, like forEach([3, -2, 5], myTestFunction)\n callback = args[1].compile().evaluate(scope);\n } else {\n // an expression like forEach([3, -2, 5], x > 0 ? callback1(x) : callback2(x) )\n callback = (0,_utils_compileInlineExpression_js__WEBPACK_IMPORTED_MODULE_2__.compileInlineExpression)(args[1], math, scope);\n }\n }\n\n return _forEach(x, callback);\n }", "title": "" }, { "docid": "da1366484021cc244f96e76cbf9375a5", "score": "0.49833825", "text": "updateTransform(transform) {\n this.drawingMatrix.copyFrom(transform).append(this.localTransform);\n }", "title": "" }, { "docid": "3c1fbce3ae9bb9e6a74da51fdda4b18c", "score": "0.49821123", "text": "function bindToBW(fn){return _.bind(_.partial(fn,collectionList[0]),initTarget._hyperstore)}", "title": "" }, { "docid": "10eda37a5fec201ffe030093ed887c5e", "score": "0.49627972", "text": "map(transform) {\n return new MapIterator(this, transform);\n }", "title": "" }, { "docid": "4f50a26fdb724e1728316a21a5cd3b2a", "score": "0.49616823", "text": "function appendTransform(defaults, transform) {\n // no guarantee that the default transformation is an array\n defaults = angular.isArray(defaults) ? defaults : [defaults];\n // append the new transformation to the defaults\n return defaults.concat(transform);\n }", "title": "" }, { "docid": "fdbe4554f9e22f725ece26869d42a288", "score": "0.49487782", "text": "RemoveMixingTransform() {}", "title": "" }, { "docid": "82f9d192511fa2bbb39d4d257c1f6964", "score": "0.49478263", "text": "function appendTransform(defaults, transform) {\n // We can't guarantee that the default transformation is an array\n defaults = angular.isArray(defaults) ? defaults : [defaults];\n\n // Append the new transformation to the defaults\n return defaults.concat(transform);\n }", "title": "" }, { "docid": "82f9d192511fa2bbb39d4d257c1f6964", "score": "0.49478263", "text": "function appendTransform(defaults, transform) {\n // We can't guarantee that the default transformation is an array\n defaults = angular.isArray(defaults) ? defaults : [defaults];\n\n // Append the new transformation to the defaults\n return defaults.concat(transform);\n }", "title": "" }, { "docid": "b7fef270e7036e5f909c8153d047e353", "score": "0.4935134", "text": "function forEachTransform(args, math, scope) {\n var x, callback;\n\n if (args[0]) {\n x = args[0].compile().evaluate(scope);\n }\n\n if (args[1]) {\n if (Object(is[\"J\" /* isSymbolNode */])(args[1]) || Object(is[\"q\" /* isFunctionAssignmentNode */])(args[1])) {\n // a function pointer, like forEach([3, -2, 5], myTestFunction)\n callback = args[1].compile().evaluate(scope);\n } else {\n // an expression like forEach([3, -2, 5], x > 0 ? callback1(x) : callback2(x) )\n callback = compileInlineExpression(args[1], math, scope);\n }\n }\n\n return _forEach(x, callback);\n }", "title": "" }, { "docid": "91f9b58070681466c6468b6f8b8c3fed", "score": "0.49325505", "text": "transform(matrix)\n {\n this.transformPosition(matrix);\n this.transformTarget(matrix);\n }", "title": "" }, { "docid": "cf0966cc4d4d770ce766624902f07657", "score": "0.49154502", "text": "setTransform(amount) {\n var ctx = this.getContext();\n ctx.transform(amount, 0, 0, amount, 0, 0);\n this.currentTransform *= amount;\n\n logger.print(\"Setting transform: \" + amount + \". New transform: \" + this.currentTransform);\n }", "title": "" }, { "docid": "0c1c055fbef19ddb5d985aff689cb2bb", "score": "0.49138442", "text": "function transform( p, fn ) {\n return function () {\n var result = p();\n\n return result === null ? null : fn( result );\n };\n }", "title": "" }, { "docid": "e06c9bc3b55980930f9353dddfc900ea", "score": "0.4911509", "text": "_batchTransformChanges(func) {\r\n this._batchingTransformChange = true;\r\n func();\r\n this._batchingTransformChange = false;\r\n if (this._needClearTransformCache) {\r\n this._clearCache(TRANSFORM);\r\n this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);\r\n }\r\n this._needClearTransformCache = false;\r\n }", "title": "" }, { "docid": "553331fd6c95beddb090766028ccc989", "score": "0.49091583", "text": "function elm_bind(fn) {\n return function(k, selection, i) {\n return k(selection.data(function(d) { return JS.fromList(fn(d)); }));\n };\n }", "title": "" }, { "docid": "f59755386556052e66aba860fa3f2280", "score": "0.4905988", "text": "function setTransform(i, value) {\n var el = elements[i];\n el.style.webkitTransform = value;\n el.style.mozTransform = value;\n el.style.msTransform = value;\n el.style.oTransform = value;\n el.style.transform = value;\n }", "title": "" }, { "docid": "1774f0e2e1c5d4ee7fdb4a8c596c5884", "score": "0.48958963", "text": "function OurDataManipulation () {\n\n\t//\n\t// invoke Transform constructor\n\t//\n Transform.call(this);\n}", "title": "" }, { "docid": "6261b17a168cd683fc7b285364ce2878", "score": "0.48955467", "text": "function map(array, transform) {\n var mapped = [];\n for (var i = 0; i < array.length; i++) {\n mapped.push(transform(array[i]));\n }\n return mapped;\n}", "title": "" }, { "docid": "efa1ae3af5bdc1e557192c6409043c9c", "score": "0.48848742", "text": "updateTransform()\n {\n this.validate();\n this.containerUpdateTransform();\n }", "title": "" }, { "docid": "76bb0b0f1340611bcf1d8e1e1f281743", "score": "0.48848432", "text": "function map(arr, transformer) {\n let result = [];\n arr.forEach(function (item, index) {\n console.log(item, index);\n result.push(transformer(item));\n });\n return result;\n}", "title": "" }, { "docid": "ad9742796c902267ba3ca3946e57a6d6", "score": "0.4866304", "text": "_importAddonTransforms() {\n this.project.addons.forEach((addon) => {\n if (this.shouldIncludeAddon(addon)) {\n if (addon.importTransforms) {\n let transforms = addon.importTransforms();\n\n if (!transforms) {\n throw new Error(`Addon \"${addon.name}\" did not return a transform map from importTransforms function`);\n }\n\n Object.keys(transforms).forEach((transformName) => {\n let transformConfig = {\n files: [],\n options: {},\n };\n\n // store the transform info\n if (typeof transforms[transformName] === 'object') {\n transformConfig['callback'] = transforms[transformName].transform;\n transformConfig['processOptions'] = transforms[transformName].processOptions;\n } else if (typeof transforms[transformName] === 'function') {\n transformConfig['callback'] = transforms[transformName];\n transformConfig['processOptions'] = (assetPath, entry, options) => options;\n } else {\n throw new Error(\n `Addon \"${addon.name}\" did not return a callback function correctly for transform \"${transformName}\".`\n );\n }\n\n if (this._customTransformsMap.has(transformName)) {\n // there is already a transform with a same name, therefore we warn the user\n this.project.ui.writeWarnLine(\n `Addon \"${addon.name}\" is defining a transform name: ${transformName} that is already being defined. Using transform from addon: \"${addon.name}\".`\n );\n }\n\n this._customTransformsMap.set(transformName, transformConfig);\n });\n }\n }\n });\n }", "title": "" }, { "docid": "8503a7617a288df482ad4f3ba4943092", "score": "0.4865991", "text": "function on(t, e) {\n return t instanceof fn ? function (t, e) {\n for (var n = null, r = 0, i = t.fieldTransforms; r < i.length; r++) {\n var o = i[r],\n u = e instanceof bn ? e.field(o.field) : void 0,\n s = je(o.transform, u || null);\n null != s && (n = null == n ? new gn().set(o.field, s) : n.set(o.field, s));\n }\n\n return n ? n.Ye() : null;\n }(t, e) : null;\n }", "title": "" }, { "docid": "3ef09d3dd99304a51dbd2905af2544c3", "score": "0.48650214", "text": "transform(matrix)\n {\n }", "title": "" }, { "docid": "3034d9e974768aec42496ffa3ef8b5c3", "score": "0.48644298", "text": "transform(m0, m1, m2, m3, m4, m5) {\n return this.mapPoints((x, y) => {\n x = m0 * x + m2 * y + m4;\n y = m1 * x + m3 * y + m5;\n return [x, y];\n });\n }", "title": "" }, { "docid": "224ea6171724de9ae2b1693e1ab38cae", "score": "0.48627713", "text": "bn(t, e) {\n t.forEach(((t, n) => {\n for (const t of e) t.applyToLocalView(n);\n }));\n }", "title": "" }, { "docid": "936ad8636e24f5d0c72b4f7751a85d84", "score": "0.4860381", "text": "map(callbackfn, thisArg) {\n // tslint:disable:no-use-before-declare\n // Disabled the rule, because the classes below reference each other in a way that it is impossible to find a successful order.\n return new TransformIterator(this, callbackfn, thisArg);\n }", "title": "" }, { "docid": "34619aaa4dd23467aba6ebc294f9b938", "score": "0.4851579", "text": "yn(t, e) {\n t.forEach(((t, n) => {\n for (const t of e) t.applyToLocalView(n);\n }));\n }", "title": "" }, { "docid": "25210e760daad65aee453a8318f09c36", "score": "0.48484915", "text": "bind(g_config) {\n\t\tlet ds_transform = this.transform;\n\t\tif(g_config.base) ds_transform.on('base', g_config.base);\n\t\tif(g_config.prefix) ds_transform.on('prefix', g_config.prefix);\n\t\tif(g_config.enter) ds_transform.on('enter', g_config.enter);\n\t\tif(g_config.exit) ds_transform.on('exit', g_config.exit);\n\t\tif(g_config.comment) ds_transform.on('comment', g_config.comment);\n\t\tif(g_config.error) ds_transform.on('error', g_config.error);\n\t\tif(g_config.read) ds_transform.once('read', g_config.read);\n\t\tif(g_config.progress) ds_transform.on('progress', g_config.progress);\n\t\tif(g_config.eof) ds_transform.once('eof', g_config.eof);\n\t\tif(g_config.end) ds_transform.once('end', g_config.end);\n\t\tif(g_config.finish) ds_transform.once('finish', g_config.finish);\n\t\tif(g_config.data) ds_transform.on('data', g_config.data);\n\t}", "title": "" }, { "docid": "7c8f9722ae343c7f7e784646d0ce58d4", "score": "0.4848186", "text": "function applyAllTransforms() {\n var text = '';\n for(var i = 0; i < 8; i++) {\n text += transform(origtext, i) + '\\n';\n }\n parseText(text, 'transformed circuit', undefined, 1);\n}", "title": "" }, { "docid": "a41ee12adb0c75d5523cdf1dabb7dafa", "score": "0.48400703", "text": "function transformElement( element, transform ) {\n\n\t\telement.style.WebkitTransform = transform;\n\t\telement.style.MozTransform = transform;\n\t\telement.style.msTransform = transform;\n\t\telement.style.OTransform = transform;\n\t\telement.style.transform = transform;\n\n\t}", "title": "" }, { "docid": "005d61b681fc2011d79c77af67faff62", "score": "0.4836625", "text": "'transform'(value, options) {\n // returning an observable seems best...?\n // or an easy to use stream?\n\n // need specific transform implementation for that resource.\n // maybe filling in values within an HTML template.\n\n throw 'Need specific implementation';\n\n }", "title": "" }, { "docid": "b4e9ab7ab17783eca40c94af99ea3d6b", "score": "0.48360986", "text": "function applyTransformation() {\n wasm.exports.applyTransformation();\n}", "title": "" }, { "docid": "671bcfe5ca977bb8a8b02a1977499f84", "score": "0.48351744", "text": "transform(ref, op) {\n var {\n current,\n affinity\n } = ref;\n\n if (current == null) {\n return;\n }\n\n var point = Point.transform(current, op, {\n affinity\n });\n ref.current = point;\n\n if (point == null) {\n ref.unref();\n }\n }", "title": "" }, { "docid": "87555df5e90aec6a7f3e2602f00edc49", "score": "0.48340774", "text": "function aggregate(transform) {\n switch (arguments.length) {\n case 1:\n return aggregate_seed_transform_selector.apply(this, [undefined, arguments[0]]);\n default:\n return aggregate_seed_transform_selector.apply(this, arguments);\n }\n}", "title": "" }, { "docid": "a0c9c1927dfaf1b2f95574933d09a2b9", "score": "0.4834057", "text": "translateItems(items, inputKey, outputKey) {\n if (Array.isArray(items)) {\n for (const item of items) {\n if (item[inputKey]) {\n item[outputKey] = this.translate && this.translate && this.translate.instant && this.translate.instant(item[inputKey]);\n }\n }\n }\n }", "title": "" }, { "docid": "120375d0176c03eb4e4ca59ecdf4389a", "score": "0.4832602", "text": "function appendTransform(defaults, transform) {\n\n // We can't guarantee that the default transformation is an array\n defaults = angular.isArray(defaults) ? defaults : [defaults];\n\n // Append the new transformation to the defaults\n return defaults.concat(transform);\n}", "title": "" }, { "docid": "7c31507250f1ca254832129de11c8cef", "score": "0.48185015", "text": "function transform( p, fn ) {\n\t\t\t\treturn function () {\n\t\t\t\t\tvar result = p();\n\n\t\t\t\t\treturn result === null ? null : fn( result );\n\t\t\t\t};\n\t\t\t}", "title": "" }, { "docid": "7c31507250f1ca254832129de11c8cef", "score": "0.48185015", "text": "function transform( p, fn ) {\n\t\t\t\treturn function () {\n\t\t\t\t\tvar result = p();\n\n\t\t\t\t\treturn result === null ? null : fn( result );\n\t\t\t\t};\n\t\t\t}", "title": "" }, { "docid": "7c31507250f1ca254832129de11c8cef", "score": "0.48185015", "text": "function transform( p, fn ) {\n\t\t\t\treturn function () {\n\t\t\t\t\tvar result = p();\n\n\t\t\t\t\treturn result === null ? null : fn( result );\n\t\t\t\t};\n\t\t\t}", "title": "" }, { "docid": "579221377755d161bd23b37283a50017", "score": "0.48180118", "text": "async transform(value) {\n const prependValue = _.get(this, 'options.sourcePrepend', '');\n // Set this.value to the keys of the object passed.\n // this.value = value.map(item => prependValue.concat(item));\n // Call super.transform and pass along the new value to honor composition.\n return super.transform(`${prependValue}${value}`);\n }", "title": "" }, { "docid": "bf1bcf1850bff709a85a3a8f2f65c0c0", "score": "0.48043332", "text": "function applyTransforms(el, nobodyscale) {\n\t\t// zoomer area and scale value\n\t\tvar zoomerArea = el.querySelector('.zoomer__area'), \n\t\t\tzoomerAreaSize = {width: zoomerArea.offsetWidth, height: zoomerArea.offsetHeight},\n\t\t\tzoomerOffset = zoomerArea.getBoundingClientRect(),\n\t\t\tscaleVal = zoomerAreaSize.width/zoomerAreaSize.height < win.width/win.height ? win.width/zoomerAreaSize.width : win.height/zoomerAreaSize.height;\n\n\t\tif( bodyScale && !nobodyscale ) {\n\t\t\tscaleVal /= bodyScale; \n\t\t}\n\n\t\t// apply transform\n\t\tel.style.WebkitTransform = 'translate3d(' + Number(win.width/2 - (zoomerOffset.left+zoomerAreaSize.width/2)) + 'px,' + Number(win.height/2 - (zoomerOffset.top+zoomerAreaSize.height/2)) + 'px,0) scale3d(' + scaleVal + ',' + scaleVal + ',1)';\n\t\tel.style.transform = 'translate3d(' + Number(win.width/2 - (zoomerOffset.left+zoomerAreaSize.width/2)) + 'px,' + Number(win.height/2 - (zoomerOffset.top+zoomerAreaSize.height/2)) + 'px,0) scale3d(' + scaleVal + ',' + scaleVal + ',1)';\n\t}", "title": "" }, { "docid": "dd1f9051c2b52cbcc8b1dc1ffaef9107", "score": "0.47902286", "text": "function transformArray(array, transformer) {\n var transformedArray = [];\n\n array.forEach(function(item, index){\n var transformedItem = transformer(item, index);\n if(utilities.isDefined(transformedItem)) {\n transformedArray.push(transformedItem);\n }\n });\n\n return transformedArray;\n}", "title": "" }, { "docid": "868c45e608270a20ec8218158ec293dc", "score": "0.47895807", "text": "function transform (observable, down, up) {\n assertObservable(observable)\n return function (val) {\n return (\n isGet(val) ? down(observable())\n : isSet(val) ? observable((up || down)(val))\n : observable(function (_val) { val(down(_val)) })\n )}}", "title": "" }, { "docid": "a143b68481e415441d6f32c1e797e027", "score": "0.47865224", "text": "function pipe() {\n\t var funcs = [];\n\t for (var _i = 0; _i < arguments.length; _i++) {\n\t funcs[_i - 0] = arguments[_i];\n\t }\n\t return compose.apply(null, [].slice.call(arguments).reverse());\n\t}", "title": "" }, { "docid": "2f14e36f582181fc5d34dd54f5b215c1", "score": "0.47792992", "text": "function Transform(transformFn, options) {\n return function (target, key) {\n var metadata = new TransformMetadata_1.TransformMetadata(target.constructor, key, transformFn, options);\n storage_1.defaultMetadataStorage.addTransformMetadata(metadata);\n };\n}", "title": "" }, { "docid": "2f14e36f582181fc5d34dd54f5b215c1", "score": "0.47792992", "text": "function Transform(transformFn, options) {\n return function (target, key) {\n var metadata = new TransformMetadata_1.TransformMetadata(target.constructor, key, transformFn, options);\n storage_1.defaultMetadataStorage.addTransformMetadata(metadata);\n };\n}", "title": "" }, { "docid": "ff76b450f601ed3ab438b39ce8102d7a", "score": "0.47783077", "text": "function trackTransforms(ctx) {\r\n }", "title": "" }, { "docid": "b317a4dd51df9cc7373aa182e648f01f", "score": "0.47748983", "text": "function transformEachElement(array, transformFunction) {\n var result = [];\n for (var i=0; i < array.length; i++) {\n result[i] = transformFunction(array[i]);\n }\n return result;\n}", "title": "" }, { "docid": "1bb98ee96a275e5aa1bd8b39bbf6ec7d", "score": "0.4758963", "text": "function pipe() {\r\n\t var funcs = [];\r\n\t for (var _i = 0; _i < arguments.length; _i++) {\r\n\t funcs[_i - 0] = arguments[_i];\r\n\t }\r\n\t return compose.apply(null, [].slice.call(arguments).reverse());\r\n\t}", "title": "" }, { "docid": "c720477fc7117bb8cab3ad98771d18eb", "score": "0.47568357", "text": "applyTransformations() {\n this.scene.multMatrix(this.transformationMatrix);\n }", "title": "" }, { "docid": "68bfb293e3a2723ccf999e3c819a58e7", "score": "0.4754942", "text": "calcTransforms() {\n /*\n Each position corresponds to the position of a given slide:\n 0: left top corner outside the viewport\n 1: left top corner (prev slide position)\n 2: center (current slide position)\n 3: right bottom corner (next slide position)\n 4: right bottom corner outside the viewport\n 5: left side, for when the content is shown\n */\n this.transforms = [\n {x: -1*(winsize.width/2+this.width), y: -1*(winsize.height/2+this.height), rotation: -30},\n {x: -1*(winsize.width/2-this.width/3), y: -1*(winsize.height/2-this.height/3), rotation: 0},\n {x: 0, y: 0, rotation: 0},\n {x: winsize.width/2-this.width/3, y: winsize.height/2-this.height/3, rotation: 0},\n {x: winsize.width/2+this.width, y: winsize.height/2+this.height, rotation: 30},\n {x: -1*(winsize.width/2 - this.width/2 - winsize.width*0.075), y: 0, rotation: 0}\n ];\n }", "title": "" }, { "docid": "9ec58c2f6d7e620a8e6d4d3bd243dca6", "score": "0.4753198", "text": "function transformPoints(points, transform) {\n\t var newPoints = [];\n\t for (var i = 0; i < points.length; i += 1) {\n\t var pt = points[i];\n\t var newPt = {\n\t x: transform.xScale * pt.x + transform.scale01 * pt.y + transform.dx,\n\t y: transform.scale10 * pt.x + transform.yScale * pt.y + transform.dy,\n\t onCurve: pt.onCurve,\n\t lastPointOfContour: pt.lastPointOfContour\n\t };\n\t newPoints.push(newPt);\n\t }\n\n\t return newPoints;\n\t}", "title": "" }, { "docid": "4e7f89f738c020132d6e61fa431d60b6", "score": "0.47423828", "text": "_optionalTransform(item, done) {\n const pushedCount = this._pushedCount;\n this._transform(item, () => {\n if (pushedCount === this._pushedCount)\n this._push(item);\n done();\n }, this._boundPush);\n }", "title": "" }, { "docid": "2610214ab9aa017fc24d0d45d7e8a9c1", "score": "0.47347566", "text": "function translateX(selection, fn) {\n selection.attr(\"transform\", function(d) {\n return \"translate(\" + fn(d) + \",0)\";\n });\n}", "title": "" }, { "docid": "57a1d6775db09446cafda87355c9f66b", "score": "0.47283033", "text": "_getGroupTransform(start, end) {\n var obj = this._getTransformObject(start, end);\n return `translate(${obj.x}, ${obj.y})`;\n }", "title": "" } ]
e3c0dfa398ae364d1c0c5664c2f39280
Svuota il form di ricerca del Provvedimento.
[ { "docid": "1e1b848eda305894712bab11b4848cfb", "score": "0.68226725", "text": "function svuotaFormRicerca() {\n this.pulisciENascondiTabellaProvvedimento();\n //pulisco i campi utilizzati dalla ricerca\n $('#HIDDEN_StrutturaAmministrativoContabile' + this.suffix + 'Uid').val('');\n $('#HIDDEN_StrutturaAmministrativoContabile' + this.suffix + 'Codice').val('');\n $('#HIDDEN_StrutturaAmministrativoContabile' + this.suffix + 'Descrizione').val('');\n $('#SPAN_StrutturaAmministrativoContabile' + this.suffix).text('Nessuna Struttura Amministrativa Responsabile selezionata');\n $('#formRicercaProvvedimento' + this.suffix).find(':input').val('');\n if($('#collapseProvvedimento' + this.suffix).hasClass('in')){\n $('[data-toggle=\"collapse\"][href=\"#collapseProvvedimento' + this.suffix + '\"]').trigger('click');\n }\n }", "title": "" } ]
[ { "docid": "10252bc90bd8ba5361386922b8474b42", "score": "0.71192527", "text": "function limpiarFormularioProveedor() {\n vista.limpiarFormulario('formularioProveedor');\n}", "title": "" }, { "docid": "474d66ab5fb24f77dd3273d7b16550b5", "score": "0.6448443", "text": "function obtemProdutoDoFurmulario(form){\n \n var produto = {\n nome: form.nome.value,\n cor: form.cor.value,\n valorProduto: form.valorProduto.value,\n valorVenda: form.valorVenda.value,\n liquido: calculaLiquido(form.valorProduto.value, form.valorVenda.value)\n\n }\n\n return produto;\n\n}", "title": "" }, { "docid": "9cb0f51aab79b967a197c9d1037177f7", "score": "0.6110833", "text": "function getObject(){\n\t\tvar formObject = domForm.toObject( 'formInfoGral' + aleatorio );\n\t\tif (idDepto.item != null){\n\t\t\tformObject.idDepto = idDepto.item.idDepto;\n\t\t}\n\t\tif (idAbogado.item != null){\n\t\t\tformObject.idAbogado = idAbogado.item.idAbogado;\n\t\t}\n\t\tif (unidadResp.item != null){\n\t\t\tformObject.unidadResp = unidadResp.item.unidadResp;\n\t\t}\n\t\tif ( !formObject.atendidoVencimien ){\n\t\t\tformObject.atendidoVencimien = '0';\n\t\t}\n\t\tif ( !formObject.atendidoRecordato ){\n\t\t\tformObject.atendidoRecordato = '0';\n\t\t}\n\t\treturn formObject;\n\t}", "title": "" }, { "docid": "5fe4cd8a3e1c2ce7b1524c9b49cde8e4", "score": "0.6085325", "text": "static loadFormCumplimientoProductos() {\n Utilitario.agregarMascara();\n fetch(\"formRegistroCumplimientoProductos.html\", {\n method: \"GET\",\n })\n .then(function (response) {\n return response.text();\n })\n .then(function (vista) {\n $(\"#mostrarcontenido\").html(vista);\n })\n .finally(function () {\n Utilitario.quitarMascara();\n });\n }", "title": "" }, { "docid": "43e13650dcd715f2030d5e87c36c8470", "score": "0.59521073", "text": "function obtemPacienteDoFormulario(form){\n //criando um objeto pacientes\n var paciente = {\n nome: form.nome.value,\n peso: form.peso.value,\n altura: form.altura.value,\n gordura: form.gordura.value,\n imc: calculaImc(form.peso.value, form.altura.value)\n }\n return paciente;\n }//funcao obtemPacienteFormulario", "title": "" }, { "docid": "dfd4c52241890871f7dad51dc71ac836", "score": "0.59482694", "text": "function obtemPacienteDoFormulario(form) {\n\n //cria-se um objeto e se passa as propriedades para formar o objeto.\n var paciente = {\n nome: form.nome.value,\n peso: form.peso.value,\n altura: form.altura.value,\n gordura: form.gordura.value,\n imc: calculaImc(form.peso.value, form.altura.value)\n }\n\n return paciente;\n\n}", "title": "" }, { "docid": "f9dbd4c39e34cc7794744f5250b24b5e", "score": "0.5924915", "text": "function adaptaFormulario () {\n\tvar medioPagoEl = getFormElementById(\"mediopago\");\n\tif (! medioPagoEl) {\n\t\tconsole.error(\"No se ha definido el campo Medio de pago.\");\n\t} else {\n\t\tvar medioPago = medioPagoEl.options[medioPagoEl.selectedIndex];\n\t\tswitch (medioPago.value) {\n\t\t\tcase \"domiciliacion\": visibilidadCCC(true);\n\t\t\t\t\t\t\t\t visibilidadTarjeta(false);\n\t\t\t\t\t\t\t\t break;\n\t\t\t/** \n\t\t\t * NO SE USA PORQUE NO SE REALIZA LA GESTIÓN DE PAGOS RECURRENTES CON TARJETA,\n\t\t\t * CUANDO SEA NECESARIO, DESCOMENTAR ESTAS LINEAS\n\t\t\tcase \"tarjeta\": \t visibilidadCCC(false);\n\t\t\t\t\t\t\t\t visibilidadTarjeta(true);\n\t\t\t\t\t\t\t\t break;\n\t\t\t*/\n\t\t\tdefault:\t\t\t visibilidadCCC(false);\n\t\t\t\t\t\t\t\t visibilidadTarjeta(false);\n\t\t\t\t\t\t\t\t break;\n\t\t}\n\t}\n}", "title": "" }, { "docid": "66ca5162ff4c2698082d9755be8edbc5", "score": "0.5902631", "text": "function DadosForm(form) {\n \n //criando objeto paciente\n var paciente = {\n nome: form.nome.value,\n peso: form.peso.value,\n altura: form.altura.value,\n gordura: form.gordura.value,\n imc: CalculaImc(form.peso.value, form.altura.value)\n }\n return paciente;\n}", "title": "" }, { "docid": "7698886ea75f9539136bc1df0eaaf9e1", "score": "0.5889246", "text": "function obtemPacienteDoFormulario(form) {\n let paciente = {\n nome \t\t: \tform.nome.value,\n peso \t\t: \tform.peso.value,\n altura \t: \tform.altura.value,\n gordura : \tform.gordura.value,\n imc \t\t: \tcalculaImc(form.peso.value, form.altura.value)\n }\n\n return paciente;\n}", "title": "" }, { "docid": "a1625dd1cf11ffe8913b2ae0309d34d7", "score": "0.58445525", "text": "function _parcela(){\n \n function __carregar(){\n _load(function(){ \n campos.tipo = p.find('.nl-tipo');\n campos.valor = p.find('.nl-valor-prev').priceFormat();\n });\n }\n \n function __salvar(){\n var\n /*Lancamento destino*/\n l = new MD.Lancamento({\n codigo : id,\n virtual : virtual,\n grupo : lancamento.option('grupo'),\n tipo : campos.tipo.filter(':checked').val()\n });\n /*Validando e setando valor*/\n if(!_setValor(l,'previsto',campos.valor)) return;\n \n Ajax('EDITAR_PARCELA',l.encode(),_done);\n }\n \n return {\n title : 'Editar parcela',\n showButtons : false,\n ajax : __carregar,\n buttons : _buttons(__salvar)\n }\n }", "title": "" }, { "docid": "afcc924fd8f455cbb1a39bc0e3f15cc8", "score": "0.5841281", "text": "function buscaPoliza(){\n formularioCrear.polizaInfoSelect();\n}", "title": "" }, { "docid": "e233df6860bb280ca99bbb01ef3feaae", "score": "0.5771642", "text": "function populateJs2Form(){\n\t//Primero determinamos el modo en el que estamos;\n\tvar mode = getMMGMode(get('msgMedioEnvioPaisFrm.accion'), \n\t\tget('msgMedioEnvioPaisFrm.origen'));\n\n\n\tset('msgMedioEnvioPaisFrm.id', jsMsgMedioEnvioPaisId);\n\tset('msgMedioEnvioPaisFrm.paisOidPais', [jsMsgMedioEnvioPaisPaisOidPais]);\n\tset('msgMedioEnvioPaisFrm.meenOidMediEnvi', [jsMsgMedioEnvioPaisMeenOidMediEnvi]);\n\tset('msgMedioEnvioPaisFrm.codEsta', jsMsgMedioEnvioPaisCodEsta);\n\t\n}", "title": "" }, { "docid": "d8e892521ae86db50fe65b016ecd5b07", "score": "0.5731582", "text": "function generarPreciosSeleccionados() {\n preciosSeleccionados = [];\n var arrayElementos = $('form').serializeArray();\n $.each(arrayElementos, function(indice, valor){ \n if (valor.name == \"precios\") {\n preciosSeleccionados.push(valor.value);\n }\n });\n }", "title": "" }, { "docid": "1637d39f4d983ab72823459a4d67cedb", "score": "0.5714158", "text": "function renderPrescriptionForm(parameters){\n\n //For prescription handling, the controller can only be acompanhamento.php\n var controller = \"acompanhamento.php\";\n //console.log(typeof(parameters.last_p))\n\n var info = 'Inserir prescrição';\n var uniqid = parameters.uniqid;\n var choice = parameters.operation;\n var pat_id = parameters.patientID;\n var form = '';\n\n //The form content\n for(var i = 1; i <= 10; i++){\n\n var current;\n\n try{\n current = \"value = '\" + parameters.last_p['med'+i] + \"'\" ;\n if (parameters.last_p['med'+i] == null) throw \"error\";\n\n }\n catch(err){\n current = \"\"\n }\n\n form += \"<span class='glyphicon glyphicon-minus' aria-hidden='true'></span>\"\n form+= \"<input name= 'med\"+ i + \"' type = 'text' class='form_input'\" + current + \"placeholder = 'Medicamento'></input>\";\n form+= \"<input name= 'dos\"+ i + \"' type = 'text' class='form_input' placeholder = 'Dose'></input>\";\n form+= \"<input name= 'via\"+ i + \"' type = 'text' class='form_input' placeholder = 'Via'></input>\";\n form+= \"<select class = 'custom-select' name= 'pos\"+ i +\"'>\";\n form+= \"<option value = 'null'> Posologia </option>\";\n form+= \"<option value = '1x/d' selected> 1x/dia </option>\";\n form+= \"<option value = '2x/d'> 2x/dia (12/12h) </option>\";\n form+= \"<option value = '3x/d'> 3x/dia (8/8h) </option>\";\n form+= \"<option value = '4x/d'> 4x/dia (6/6h) </option>\";\n form+= \"<option value = '6x/d'> 6x/dia (4/4h) </option>\";\n form+= \"<option value = 'SOS'> Caso necessário </option>\";\n form+= \"</select><br>\";\n }\n\n var content = \"<div class='row'>\"+\n \"<form style='margin:auto' class = 'form-group col-sm-12 col-md-12 col-lg-12' action = \\\"\" + controller + \"\\\" method='POST'>\" +\n form +\n \"<input name= 'operation' type = 'hidden' value = \"+ choice +\"></input>\"+\n \"<input name= 'patientID' type = 'hidden' value = \"+ pat_id +\"></input>\"+\n \"<input name= 'uniqid' type = 'hidden' value = '\"+ uniqid +\"'></input>\"\n \"<br><input class= 'btn btn-success' style= 'width:45%;margin:1em 0 0 1em' type = 'submit' value= '\" + info +\"'>\"\n\n if (choice == \"PRESCRIPTION_EDIT\"){ //Allows for a delete button only in EDITION MODE\n\n content +=\"<br><input class= 'btn btn-success' style= 'width:45%;margin:1em 0 0 1em' type = 'submit' value= '\" + info +\"'>\" +\n \"<button class= 'btn btn-warning' style= 'width:45%;margin:1em 0 0 1em' data-uniqid ='\"+ uniqid +\"' data-operation='DELETE_PRESCRIPTION'\" +\n \"onclick = 'deleteEntry(this)'>Remover Prescrição</button> \"\n \n }\n else\n content +=\"<br><input class= 'btn btn-success' style= 'width:90%;margin:1em 0 0 1em' type = 'submit' value= '\" + info +\"'>\" +\n \"</form>\"+\n \"</div>\";\n\n\n document.getElementById(\"prescription_list\").innerHTML = content;\n}", "title": "" }, { "docid": "7ffe046b90112555723213cb15ed51bc", "score": "0.5710431", "text": "function retornaPacienteFormulario(form){\n var paciente = {\n nome: form.nome.value,\n peso: form.peso.value,\n altura: form.altura.value,\n gordura: form.gordura.value,\n imc: calculaImc(form.peso.value, form.altura.value)\n }\n\n return paciente;\n}", "title": "" }, { "docid": "785c54358bf25ae948f899bf5afa1749", "score": "0.56998396", "text": "function populateJs2Form(){\n\t//Primero determinamos el modo en el que estamos;\n\tvar mode = getMMGMode(get('maeCriteBusquFrm.accion'), \n\t\tget('maeCriteBusquFrm.origen'));\n\n\n\tset('maeCriteBusquFrm.id', jsMaeCriteBusquId);\n\tset('maeCriteBusquFrm.paisOidPais', [jsMaeCriteBusquPaisOidPais]);\n\tset('maeCriteBusquFrm.atreOidAtriEsp1', [jsMaeCriteBusquAtreOidAtriEsp1]);\n\tset('maeCriteBusquFrm.atreOidAtriEsp2', [jsMaeCriteBusquAtreOidAtriEsp2]);\n\t\n}", "title": "" }, { "docid": "183d3ed7292657c0a2a6d4f671e668bf", "score": "0.5698989", "text": "_limpaForm() {\n\n // Reseta os campos para os seguintes valores\n this._inputData.value = '';\n this._inputQuantidade.value = 1;\n this._inputValor.value = 0.0;\n \n // setar o focus do mouse já pra o primeiro item do form.\n this._inputData.focus();\n }", "title": "" }, { "docid": "c0c5a12fc214034a3c4beb8e0e88e809", "score": "0.5642629", "text": "function populateJs2Form(){\n\t//Primero determinamos el modo en el que estamos;\n\tvar mode = getMMGMode(get('segPaisFrm.accion'), \n\t\tget('segPaisFrm.origen'));\n\n\n\tset('segPaisFrm.id', jsSegPaisId);\n\tset('segPaisFrm.codPais', jsSegPaisCodPais);\n\tset('segPaisFrm.moneOidMone', [jsSegPaisMoneOidMone]);\n\tset('segPaisFrm.moneOidMoneAlt', [jsSegPaisMoneOidMoneAlt]);\n\tif(mode == MMG_MODE_CREATE || mode == MMG_MODE_UPDATE_FORM){\n\t\tunbuildLocalizedString('segPaisFrm', 1, jsSegPaisDescripcion)\n\t\tloadLocalizationWidget('segPaisFrm', 'Descripcion', 1);\n\t}else{\n\t\tset('segPaisFrm.Descripcion', jsSegPaisDescripcion);\t\t\n\t}\n\tset('segPaisFrm.indInteGis', [jsSegPaisIndInteGis]);\n\tset('segPaisFrm.valIden', [jsSegPaisValIden]);\n\tset('segPaisFrm.indSaldUnic', jsSegPaisIndSaldUnic);\n\tset('segPaisFrm.valProgEjec', jsSegPaisValProgEjec);\n\tset('segPaisFrm.valPorcAlar', jsSegPaisValPorcAlar);\n\tset('segPaisFrm.indCompAuto', jsSegPaisIndCompAuto);\n\tset('segPaisFrm.numDiasMora', jsSegPaisNumDiasMora);\n\tset('segPaisFrm.indTratAcumDesc', jsSegPaisIndTratAcumDesc);\n\tset('segPaisFrm.valTiemRezo', jsSegPaisValTiemRezo);\n\tset('segPaisFrm.valConfSecuCcc', [jsSegPaisValConfSecuCcc]);\n\tset('segPaisFrm.numDiasFact', jsSegPaisNumDiasFact);\n\tset('segPaisFrm.numLimiDifePago', jsSegPaisNumLimiDifePago);\n\tset('segPaisFrm.indEmisVenc', jsSegPaisIndEmisVenc);\n\tset('segPaisFrm.valMaxiDifeAnlsComb', jsSegPaisValMaxiDifeAnlsComb);\n\tset('segPaisFrm.numPosiNumeClie', jsSegPaisNumPosiNumeClie);\n\tset('segPaisFrm.valFormFech', [jsSegPaisValFormFech]);\n\tset('segPaisFrm.valSepaMile', [jsSegPaisValSepaMile]);\n\tset('segPaisFrm.valSepaDeci', [jsSegPaisValSepaDeci]);\n\tset('segPaisFrm.numPeriEgre', jsSegPaisNumPeriEgre);\n\tset('segPaisFrm.numPeriReti', jsSegPaisNumPeriReti);\n\tset('segPaisFrm.fopaOidFormPago', [jsSegPaisFopaOidFormPago]);\n\tset('segPaisFrm.valCompTele', jsSegPaisValCompTele);\n\tset('segPaisFrm.indFletZonaUbig', [jsSegPaisIndFletZonaUbig]);\n\tset('segPaisFrm.valIndiSecuMoni', jsSegPaisValIndiSecuMoni);\n\tset('segPaisFrm.indSecu', [jsSegPaisIndSecu]);\n\tset('segPaisFrm.indBalaAreaCheq', [jsSegPaisIndBalaAreaCheq]);\n\tset('segPaisFrm.valUrl', jsSegPaisValUrl);\n\tset('segPaisFrm.indImpuIncl', jsSegPaisIndImpuIncl);\n\t\n}", "title": "" }, { "docid": "899c58024822f6f398d58ccbf99a4cfe", "score": "0.5615717", "text": "function PersonaForm () {\n function getData() {\n var fields = ['id','nombre','telefonos','correo','institucionEducativa','nodos','fechaNacimiento','estudiadoMusicaAntes','sabeTocarInstrumento','generosMusicales','instrumentoDePreferencia','sexo','documento'];\n var data = {};\n fields.forEach(function(f) {\n var value = '';\n if(f == 'nodos') value = $('.selectpicker[name=\"nodos\"]').find('option:selected').data('id');\n else if(f == 'sexo') value = $('.selectpicker[name=\"sexo\"]').val();\n else if(f == 'estudiadoMusicaAntes') value = $(\"form[name='persona'] input[name=\"+f+\"]\").is(\":checked\");\n else if(f == 'sabeTocarInstrumento') value = $(\"form[name='persona'] input[name=\"+f+\"]\").is(\":checked\");\n else if(f == 'generosMusicales') value = $(\"form[name='persona'] input[name=\"+f+\"]\").tagsinput('items');\n else if(f == 'instrumentoDePreferencia') value = $(\"form[name='persona'] input[name=\"+f+\"]\").tagsinput('items');\n else value= $(\"form[name='persona'] input[name=\"+f+\"]\").val();\n data[f] = value;\n });\n return data;\n }\n\n // procesa formulario registro.jade\n $(\"form[name='persona'] input[name='crearPersona']\").click(function(e){\n console.log(getData());\n $.post(\"/persona/create\", getData(), function(data) {\n if(data.error) {\n switch(data.error) {\n case \"E_VALIDATION\":\n alert(\"El formato de correo ingresado es inválido\");\n break;\n case \"E_UNKNOWN\":\n alert(\"La dirección de correo ya se encuentra en la base de datos\");\n break;\n }\n } else\n {\n window.location = '/';\n }\n //console.log(data);\n // Object.keys(data).forEach(function(v){\n // if(data[v][0].rule == \"email\") console.log(\"el correo está mal\");\n // });\n });\n });\n\n // procesa formularios conocerte.jade y edit.jade\n $(\"form[name='persona'] input[name='editarPersona']\").click(function(e){\n console.log(getData());\n $.post(\"/persona/update\", getData(), function(data) {\n if(data.error) {\n switch(data.error) {\n case \"E_VALIDATION\":\n alert(\"El formato de correo ingresado es inválido\");\n break;\n case \"E_UNKNOWN\":\n alert(\"La dirección de correo ya se encuentra en la base de datos\");\n break;\n }\n } else\n {\n window.location = '/';\n }\n });\n });\n }", "title": "" }, { "docid": "4293a5eb1eb6b3438c4cf8257a9bb559", "score": "0.55977964", "text": "function get_Proyectos() {\n /* var pagina = 'ProductsForSubletting/listProyects';\n var par = `[{\"store\":\"\"}]`;\n var tipo = 'json';\n var selector = put_Proyectos;\n fillField(pagina, par, tipo, selector); */\n}", "title": "" }, { "docid": "62ee199e5e589deb4df60d86da214720", "score": "0.5577106", "text": "function prefillForm(detailedProduct){\r\n document.getElementById(\"upd_form_imgURL\").value = detailedProduct.img;\r\n document.getElementById(\"upd_form_name\").value = detailedProduct.name;\r\n document.getElementById(\"upd_form_details\").innerHTML = detailedProduct.details;\r\n document.getElementById(\"upd_form_price\").value = detailedProduct.price;\r\n document.getElementById(\"upd_form_qty\").value = detailedProduct.qty;\r\n}", "title": "" }, { "docid": "ff8eaf588c4f3aea0ee28e726353c129", "score": "0.557319", "text": "function effettuaNuovaRicerca() {\n var divRicerca = $(\"#divRicercaCapitolo\");\n var numeroCapitolo = $(\"#numeroCapitolo\");\n var numeroArticolo = $(\"#numeroArticolo\");\n var tipoCapitolo = $(\"input[name='specificaUEB.tipoCapitolo']\");\n \n $(\"#tabellaUEBTrovate\").dataTable();\n $(\"#oggettiDaInserireNellaVariazione\").dataTable();\n\n // Nascondo il div\n divRicerca.slideUp();\n\n // Svuoto i campi per la ricerca\n numeroCapitolo.val(\"\");\n numeroArticolo.val(\"\");\n tipoCapitolo.removeProp(\"checked\");\n\n // Imposto il focus sul tipoCapitolo\n tipoCapitolo.focus();\n }", "title": "" }, { "docid": "3aae25f3a2c494c4a4aadab826f1d350", "score": "0.55727696", "text": "function altaProveedor(){\n var proveedor = {};\n proveedor = {\n rfc: $('#' + id_rfcProveedores).val(),\n razon_social: $('#' + id_razonSocialProveedores).val(),\n direccion: $('#' + id_direccionProveedores).val()\n };\n return proveedor;\n}", "title": "" }, { "docid": "cf161cd72b657fb9498e82e6e76f0b6e", "score": "0.5570132", "text": "function dadosDoFormulario(formAdicionarIngrediente) {\r\n var nomeIngredientes = document.getElementById(\"nomeIngredientes\");\r\n\r\n // BOTAO EXCLUIR GERADO\r\n var htmlBotao = '<button type=\"button\" class=\"excluirIngrediente\">Excluir</button>';\r\n\r\n var ingrediente = {\r\n id: nomeIngredientes.options[nomeIngredientes.selectedIndex].value,\r\n nome: nomeIngredientes.options[nomeIngredientes.selectedIndex].text,\r\n quantidade: document.getElementById(\"quantidade\").value,\r\n // unidade: document.querySelector(\"#unidade\").textContent,\r\n excluir: htmlBotao\r\n }\r\n return ingrediente;\r\n}", "title": "" }, { "docid": "0ef07c5fd8758f7ba43994177fb2977e", "score": "0.55501294", "text": "limpiarLista() {\n this.form.inputCodigoPedido = '';\n this.form.inputCodigoProducto = '';\n this.form.inputCantidad = '';\n this.form.inputValor = '';\n this.form.inputFecha = '';\n this.refrescarFormulario();\n \n }", "title": "" }, { "docid": "0b3cb4f0b9a23c1e3955ef122ad849e9", "score": "0.55432546", "text": "function PopularDados(contrato) {\r\n // popula todos os campos da ficha\r\n $('.contrato-info').each(function () {\r\n var prop = $(this).attr('name');\r\n $(this).text(contrato[prop]);\r\n });\r\n // popula os hidden com o idcontrato\r\n $('input[name=idcontrato]').val(contrato.idcontrato);\r\n}", "title": "" }, { "docid": "b3d442b207ebd49ae30aafa6830556ec", "score": "0.55402714", "text": "function populateJs2Form(){\n\t//Primero determinamos el modo en el que estamos;\n\tvar mode = getMMGMode(get('carParamCarteFrm.accion'), \n\t\tget('carParamCarteFrm.origen'));\n\n\n\tset('carParamCarteFrm.id', jsCarParamCarteId);\n\tset('carParamCarteFrm.paisOidPais', [jsCarParamCartePaisOidPais]);\n\tset('carParamCarteFrm.grsoOidGrupSoli', [jsCarParamCarteGrsoOidGrupSoli]);\n\tset('carParamCarteFrm.niriOidNiveRies', [jsCarParamCarteNiriOidNiveRies]);\n\tset('carParamCarteFrm.codConf', jsCarParamCarteCodConf);\n\tset('carParamCarteFrm.indDeudVenc', jsCarParamCarteIndDeudVenc);\n\tset('carParamCarteFrm.numDiasDeudVenc', jsCarParamCarteNumDiasDeudVenc);\n\tset('carParamCarteFrm.indLineCred', jsCarParamCarteIndLineCred);\n\tset('carParamCarteFrm.fecVigeDesd', jsCarParamCarteFecVigeDesd);\n\tset('carParamCarteFrm.fecVigeHast', jsCarParamCarteFecVigeHast);\n\tset('carParamCarteFrm.valPorcVali', jsCarParamCarteValPorcVali);\n\tset('carParamCarteFrm.indMontMaxi', jsCarParamCarteIndMontMaxi);\n\tset('carParamCarteFrm.valMontMaxiPerm', jsCarParamCarteValMontMaxiPerm);\n\tset('carParamCarteFrm.indPorcMaxi', jsCarParamCarteIndPorcMaxi);\n\tset('carParamCarteFrm.valPorc', jsCarParamCarteValPorc);\n\tset('carParamCarteFrm.numDiasAdic', jsCarParamCarteNumDiasAdic);\n\tset('carParamCarteFrm.invaOidIndiVali', [jsCarParamCarteInvaOidIndiVali]);\n\n}", "title": "" }, { "docid": "81396681dfff8940b0c2611310b8548b", "score": "0.5527473", "text": "function seleccionarProvincia() {\n /* Cambiar estilo de provincia seleccionada */\n argentina.forEach((provincia) => provincia.seleccionar(mConstraint.body.id));\n}", "title": "" }, { "docid": "ab64f08c37d9f5a0c0a01d2668d5615e", "score": "0.55229455", "text": "function fValoresPersona(iCvePersona,cRFC,cRPA,iTipoPersona,cNomRazonSocial,cApPaterno,cApMaterno,cCorreoE,cPseudonimoEmp,\n iCveDomicilio,iCveTipoDomicilio,cCalle,cNumExterior,cNumInterior,cColonia,cCodPostal,cTelefono,\n iCvePais,cDscPais,iCveEntidadFed,cDscEntidadFed,iCveMunicipio,cDscMunicipio,iCveLocalidad,\n cDscLocalidad,lPredeterminado,cDscTipoDomicilio,cDscDomicilio){\n frm.iCvePersona.value = iCvePersona\n frm.cNomRazonSocial.value = cNomRazonSocial;\n frm.cDscDomicilio.value = cDscDomicilio;\n frm.iCveDomicilio.value = iCveDomicilio;\n\n\n\n// cDscDomicilio;\n}", "title": "" }, { "docid": "0f73760d57477aa4bedbb45bf70b85eb", "score": "0.55178535", "text": "function filtrarProductora(){\n let inputProductora = document.getElementById(\"productora\");\n let nombre = inputProductora.value.trim().toUpperCase();\n let peliculasProductora = peliculasP(nombre);\n mostrarPeliculasHTML(peliculasProductora);\n}", "title": "" }, { "docid": "6b1a5802e8231f7331f3bc66090eb4bb", "score": "0.55128044", "text": "function RecolectarDatosGUI() {\n NuevoEvento = {\n id: $('#idreserv').val(),\n title: $(\"#reserva\").val(),\n cliente: $(\"#cliente\").val(),\n pasajeros: $('#pasajero spam.eli').text(),\n start: $('#fecha').html(),\n docgrupo: '',\n grupo: '',\n adicionales: '',\n guia: '',\n ruta: $(\"#ruta\").val(),\n partida: $('#origen').val(),\n destino: $('#destino').val(),\n observaciones: $('#descripcion').val(),\n usuario: $('#user').val(),\n creador: $('.user').html(),\n valor: $('#precio').val().replace(/(?!\\w|\\s).| /g, \"\"),\n vuelo: $('#vuelo').val(),\n idavuelta: $('#yvuelta').val(),\n pax: $('#npasajeros').val(),\n }\n }", "title": "" }, { "docid": "589b547e327d5d8bec23d0836f6771b7", "score": "0.55074394", "text": "function CaricaPagina() { //funzione che si avvia al caricamento della pagina, fa vedere un solo form\n document.getElementById(\"form\").style.display = \"block\";\n document.getElementById(\"newform\").style.display = \"none\";\n richiestaelementi();\n}", "title": "" }, { "docid": "ba31f00a9b22ea20ab5ffccbc76ea074", "score": "0.54945284", "text": "function CambiarValorObjeto(p1){\n p1.nombre = 'Carlos';\n p1.apellido = 'Lara';\n p1.edad = 23\n\n}", "title": "" }, { "docid": "3b03c621384f3d717e13a7a6136eb8f8", "score": "0.5487676", "text": "function traerComunas(Provincia,form){\n $.ajax({\n data:'action=traerComunas&Provincia='+Provincia,\n url: urlDes,\n type:'POST',\n dataType:'JSON',\n async: false\n }).done(function(resp){\n var Contenido = \"\";\n \n if(resp != null){\n \n Contenido += \"<option value=''> Seleccione una comuna </option>\";\n $.each(resp,function(i,item){\n Contenido += \"<option value='\"+item.id_comuna+\"'>\"+item.nombre+\"</option>\";\n \n });\n\n }else{\n Contenido = \"<option value=''> No existen comunas </option>\";\n\n }\n \n if(form == 1){\n document.getElementById(\"ProsP7\").innerHTML = Contenido;\n\n }else{\n document.getElementById(\"ProsA9\").innerHTML = Contenido;\n\n }\n \n\n }).fail(function( jqXHR, textStatus, responseText) {\n console.log(textStatus+\" => \"+responseText);\n\n });\n\n }", "title": "" }, { "docid": "63a74261fa4b3b0040a6002823ec9220", "score": "0.5479579", "text": "function procesarFormulario(idFormulario)\n{\n\t//console.log(idFormulario);\n\tvar datos = {};\n\t$(idFormulario).find(\"input, select, textarea\").each(\n\tfunction()\n\t{\n\t\tvar $me = $(this);\n\t\t\n\t\tvar campo = $me.data(\"campo\");\n\t\t//console.log(campo);\n\t\t// si no se especificó un campo, ignoramos el elemento\n\t\tif (!campo) return;\n\t\t\n\t\t// dependiendo de que tipo de control se trate\n\t\tvar valor = undefined;\n\t\tswitch ($me[0].nodeName.toUpperCase())\n\t\t{\n\t\t\tcase \"TEXTAREA\":\n\t\t\tcase \"LABEL\":\n\t\t\t\tvalor = $me.text();\n\t\t\t\tbreak;\n\t\t\tcase \"INPUT\":\n\t\t\t\tvar type = $me.attr(\"type\").toUpperCase();\n\t\t\t\tif (type == \"CHECKBOX\" || type == \"RADIOBUTTON\")\n\t\t\t\t\tvalor = $me.prop(\"checked\");\n\t\t\t\telse\n\t\t\t\t\tvalor = $me.val();\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tvalor = $me.val();\n\t\t}\n\t\t\n\t\t// grabamos el valor en el objeto\n\t\tif (valor != undefined)\n\t\t\tdatos[campo] = valor;\n\t});\n\treturn datos;\n}", "title": "" }, { "docid": "a934df8e651edb71af84cbc29d6cd116", "score": "0.54716426", "text": "function fValoresPersona(iCvePersona,cRFC,cRPA,iTipoPersona,cNomRazonSocial,cApPaterno,cApMaterno,cCorreoE,cPseudonimoEmp,\n iCveDomicilio,iCveTipoDomicilio,cCalle,cNumExterior,cNumInterior,cColonia,cCodPostal,cTelefono,\n iCvePais,cDscPais,iCveEntidadFed,cDscEntidadFed,iCveMunicipio,cDscMunicipio,iCveLocalidad,\n cDscLocalidad,lPredeterminado,cDscTipoDomicilio,cDscDomicilio){\n frm.iCvePersona.value = iCvePersona\n frm.cRFC.value = cRFC;\n frm.cRPA.value = cRPA;\n frm.iTipoPersona.value = iTipoPersona;\n frm.cNomRazonSocial.value = cNomRazonSocial;\n if (iTipoPersona == \"1\")\n frm.cNomRazonSocial.value += \" \" + cApPaterno + \" \" + cApMaterno;\n frm.cApPaterno.value = cApPaterno;\n frm.cApMaterno.value = cApMaterno;\n frm.cCorreoE.value = cCorreoE;\n frm.cPseudonimoEmp.value = cPseudonimoEmp;\n\n frm.iCveDomicilio.value = iCveDomicilio;\n frm.iCveTipoDomicilio.value = iCveTipoDomicilio;\n frm.cCalle.value = cCalle;\n frm.cNumExterior.value = cNumExterior;\n frm.cNumInterior.value = cNumInterior;\n frm.cColonia.value = cColonia;\n frm.cCodPostal.value = cCodPostal;\n frm.cTelefono.value = cTelefono;\n frm.iCvePais.value = iCvePais;\n frm.cDscPais.value = cDscPais;\n frm.iCveEntidadFed.value = iCveEntidadFed;\n frm.cDscEntidadFed.value = cDscEntidadFed;\n frm.iCveMunicipio.value = iCveMunicipio;\n frm.cDscMunicipio.value = cDscMunicipio;\n frm.iCveLocalidad.value = iCveLocalidad;\n frm.cDscLocalidad.value = cDscLocalidad;\n frm.lPredeterminado.value = lPredeterminado;\n frm.cDscTipoDomicilio.value = cDscTipoDomicilio;\n frm.cDscDomicilio.value = cDscDomicilio;\n if (window.parent){\n if (window.parent.fValoresPersona)\n window.parent.fValoresPersona(iCvePersona,cRFC,cRPA,iTipoPersona,cNomRazonSocial,cApPaterno,cApMaterno,cCorreoE,cPseudonimoEmp,\n iCveDomicilio,iCveTipoDomicilio,cCalle,cNumExterior,cNumInterior,cColonia,cCodPostal,cTelefono,\n iCvePais,cDscPais,iCveEntidadFed,cDscEntidadFed,iCveMunicipio,cDscMunicipio,iCveLocalidad,\n cDscLocalidad,lPredeterminado,cDscTipoDomicilio,cDscDomicilio);\n }\n fFocusRegistraTramite();\n}", "title": "" }, { "docid": "872545c37aa8d658ea48d161676f987d", "score": "0.54708415", "text": "function loadForm() {\n\n\tform.push({\"id\":\"1.1\", \"description\":\"Finanzamtsnummer - Steuernummer\"});\t\n\tform.push({\"id\":\"2.1\", \"description\":\"für den Kalendermonat\"});\t\t\n\tform.push({\"id\":\"2.2\", \"description\":\"\"});\t\n\tform.push({\"id\":\"3.1\", \"description\":\"BEZEICHNUNG DES UNTERNEHMENS (BLOCKSCHRIFT)\"});\n\tform.push({\"id\":\"3.2\", \"description\":\"STRASSE (BLOCKSCHRIFT)\"});\n\tform.push({\"id\":\"3.3\", \"description\":\"Hausnummer\"});\n\tform.push({\"id\":\"3.4\", \"description\":\"Stiege\"});\n\tform.push({\"id\":\"3.5\", \"description\":\"Türnummer\"});\n\tform.push({\"id\":\"3.6\", \"description\":\"Land\"});\n\tform.push({\"id\":\"3.7\", \"description\":\"Telefonnummer\"});\n\tform.push({\"id\":\"3.8\", \"description\":\"Postleitzahl\"});\n\tform.push({\"id\":\"3.9\", \"description\":\"ORT (BLOCKSCHRIFT)\"});\n\n\tform.push({\"id\":\"4.1\", \"gr\":\"000\", \"vatClass\":\"2\", \"description\":\"Gesamtbetrag der Bemessungsgrundlage für Lieferungen und sonstige Leistungen (ohne den nachstehend angeführten Eigenverbrauch) einschließlich Anzahlungen (jeweils ohne Umsatzsteuer)\"});\t\n\tform.push({\"id\":\"4.2\", \"gr\":\"001\", \"vatClass\":\"2\", \"description\":\"zuzüglich Eigenverbrauch (§ 1 Abs. 1 Z 2, § 3 Abs. 2 und § 3a Abs. 1a)\"});\n\tform.push({\"id\":\"4.3\", \"gr\":\"021\", \"vatClass\":\"2\", \"description\":\"abzüglich Umsätze, für die die Steuerschuld gemäß § 19 Abs. 1 zweiter Satz sowie gemäß § 19 Abs. 1a, 1b, 1c, 1d und 1e auf den Leistungsempfänger übergegangen ist.\"});\n\tform.push({\"id\":\"4.4\", \"description\":\"SUMME\", \"sum\":\"4.1;4.2;-4.3\"});\n\tform.push({\"id\":\"4.5\", \"gr\":\"011\", \"vatClass\":\"2\", \"description\":\"§ 6 Abs. 1 Z 1 iVm § 7 (Ausfuhrlieferungen)\"});\n\tform.push({\"id\":\"4.6\", \"gr\":\"012\", \"vatClass\":\"2\", \"description\":\"§ 6 Abs. 1 Z 1 iVm § 8 (Lohnveredelungen)\"});\n\tform.push({\"id\":\"4.7\", \"gr\":\"015\", \"vatClass\":\"2\", \"description\":\"§ 6 Abs. 1 Z 2 bis 6 sowie § 23 Abs. 5 (Seeschifffahrt, Luftfahrt, grenzüberschreitende Personenbeförderung, Diplomaten, Reisevorleistungen im Drittlandsgebiet usw.).\"});\n\tform.push({\"id\":\"4.8\", \"gr\":\"017\", \"vatClass\":\"2\", \"description\":\"Art. 6 Abs. 1 (innergemeinschaftliche Lieferungen ohne die nachstehend gesondert anzuführenden Fahrzeuglieferungen)\"});\n\tform.push({\"id\":\"4.9\", \"gr\":\"018\", \"vatClass\":\"2\", \"description\":\"Art. 6 Abs. 1, sofern Lieferungen neuer Fahrzeuge an Abnehmer ohne UID-Nummer bzw. durch Fahrzeuglieferer gemäß Art. 2 erfolgten.\"});\n\tform.push({\"id\":\"4.10\", \"gr\":\"019\", \"vatClass\":\"2\", \"description\":\"§ 6 Abs. 1 Z 9 lit. a (Grundstücksumsätze)\"});\n\tform.push({\"id\":\"4.11\", \"gr\":\"016\", \"vatClass\":\"2\", \"description\":\"§ 6 Abs. 1 Z 27 (Kleinunternehmer)\"});\t\t\n\tform.push({\"id\":\"4.12\", \"gr\":\"020\", \"vatClass\":\"2\", \"description\":\"§ 6 Abs. 1 Z (übrige steuerfreie Umsätze ohne Vorsteuerabzug)\"});\n\tform.push({\"id\":\"4.13\", \"description\":\"Gesamtbetrag der steuerpflichtigen Lieferungen, sonstigen Leistungen und Eigenverbrauch (einschließlich steuerpflichtiger Anzahlungen)\", \"sum\":\"4.4;-4.5;-4.6;-4.7;-4.8;-4.9;-4.10;-4.11;-4.12\"});\n\t\n\tform.push({\"id\":\"4.14.1\", \"gr\":\"022\", \"vatClass\":\"2\", \"description\":\"20% Normalsteuersatz\"});\n\tform.push({\"id\":\"4.14.2\", \"gr\":\"022\", \"vatClass\":\"4\", \"description\":\"20% Normalsteuersatz\"});\n\tform.push({\"id\":\"4.15.1\", \"gr\":\"029\", \"vatClass\":\"2\", \"description\":\"10% ermäßigter Steuersatz\"});\n\tform.push({\"id\":\"4.15.2\", \"gr\":\"029\", \"vatClass\":\"4\", \"description\":\"10% ermäßigter Steuersatz\"});\t\t\n\tform.push({\"id\":\"4.16.1\", \"gr\":\"006\", \"vatClass\":\"2\", \"description\":\"13% ermäßigter Steuersatz\"});\n\tform.push({\"id\":\"4.16.2\", \"gr\":\"006\", \"vatClass\":\"4\", \"description\":\"13% ermäßigter Steuersatz\"});\n\tform.push({\"id\":\"4.17.1\", \"gr\":\"037\", \"vatClass\":\"2\", \"description\":\"19% für Jungholz und Mittelberg\"});\n\tform.push({\"id\":\"4.17.2\", \"gr\":\"037\", \"vatClass\":\"4\", \"description\":\"19% für Jungholz und Mittelberg\"});\t\n\tform.push({\"id\":\"4.18.1\", \"gr\":\"052\", \"vatClass\":\"2\", \"description\":\"10% Zusatzsteuer für pauschalierte land- und forstwirtschaftliche Betriebe\"});\n\tform.push({\"id\":\"4.18.2\", \"gr\":\"052\", \"vatClass\":\"4\", \"description\":\"10% Zusatzsteuer für pauschalierte land- und forstwirtschaftliche Betriebe\"});\n\tform.push({\"id\":\"4.19.1\", \"gr\":\"007\", \"vatClass\":\"2\", \"description\":\"7% Zusatzsteuer für pauschalierte land- und forstwirtschaftliche Betriebe\"});\n\tform.push({\"id\":\"4.19.2\", \"gr\":\"007\", \"vatClass\":\"4\", \"description\":\"7% Zusatzsteuer für pauschalierte land- und forstwirtschaftliche Betriebe\"});\n\tform.push({\"id\":\"4.20\", \"gr\":\"056\", \"vatClass\":\"4\", \"description\":\"Steuerschuld gemäß § 11 Abs. 12 und 14, § 16 Abs. 2 sowie gemäß Art. 7 Abs. 4\"});\n\tform.push({\"id\":\"4.21\", \"gr\":\"057\", \"vatClass\":\"4\", \"description\":\"Steuerschuld gemäß § 19 Abs. 1 zweiter Satz, § 19 Abs. 1c, 1e sowie gemäß Art. 25 Abs. 5\"});\t\t\n\tform.push({\"id\":\"4.22\", \"gr\":\"048\", \"vatClass\":\"4\", \"description\":\"Steuerschuld gemäß § 19 Abs. 1a (Bauleistungen)\"});\t\t\t\n\tform.push({\"id\":\"4.23\", \"gr\":\"044\", \"vatClass\":\"4\", \"description\":\"Steuerschuld gemäß § 19 Abs. 1b (Sicherungseigentum, Vorbehaltseigentum und Grundstücke im Zwangsversteigerungsverfahren)\"});\t\t\t\n\tform.push({\"id\":\"4.24\", \"gr\":\"032\", \"vatClass\":\"4\", \"description\":\"Steuerschuld gemäß § 19 Abs. 1d (Schrott und Abfallstoffe)\"});\t\t\t\n\tform.push({\"id\":\"4.25\", \"gr\":\"070\", \"vatClass\":\"2\", \"description\":\"Gesamtbetrag der Bemessungsgrundlagen für innergemeinschaftliche Erwerbe\"});\n\tform.push({\"id\":\"4.26\", \"gr\":\"071\", \"vatClass\":\"2\", \"description\":\"Davon steuerfrei gemäß Art. 6 Abs. 2\"});\n\tform.push({\"id\":\"4.27\", \"description\":\"Gesamtbetrag der steuerpflichtigen innergemeinschaftlichen Erwerbe\", \"sum\":\"4.25;-4.26\"});\t\t\n\t\n\tform.push({\"id\":\"4.28.1\", \"gr\":\"072\", \"vatClass\":\"2\", \"description\":\"20% Normalsteuersatz\"});\n\tform.push({\"id\":\"4.28.2\", \"gr\":\"072\", \"vatClass\":\"4\", \"description\":\"20% Normalsteuersatz\"});\n\tform.push({\"id\":\"4.29.1\", \"gr\":\"073\", \"vatClass\":\"2\", \"description\":\"10% ermäßigter Steuersatz\"});\n\tform.push({\"id\":\"4.29.2\", \"gr\":\"073\", \"vatClass\":\"4\", \"description\":\"10% ermäßigter Steuersatz\"});\n\tform.push({\"id\":\"4.30.1\", \"gr\":\"008\", \"vatClass\":\"2\", \"description\":\"13% ermäßigter Steuersatz\"});\n\tform.push({\"id\":\"4.30.2\", \"gr\":\"008\", \"vatClass\":\"4\", \"description\":\"13% ermäßigter Steuersatz\"});\n\tform.push({\"id\":\"4.31.1\", \"gr\":\"088\", \"vatClass\":\"2\", \"description\":\"19% für Jungholz und Mittelberg\"});\n\tform.push({\"id\":\"4.31.2\", \"gr\":\"088\", \"vatClass\":\"4\", \"description\":\"19% für Jungholz und Mittelberg\"});\n\n\tform.push({\"id\":\"4.32\", \"gr\":\"076\", \"vatClass\":\"2\", \"description\":\"Erwerbe gemäß Art. 3 Abs. 8 zweiter Satz, die im Mitgliedstaat des Bestimmungslandes besteuert worden sind\"});\t\t\t\n\tform.push({\"id\":\"4.33\", \"gr\":\"077\", \"vatClass\":\"2\", \"description\":\"Erwerbe gemäß Art. 3 Abs. 8 zweiter Satz, die gemäß Art. 25 Abs. 2 im Inland als besteuert gelten\"});\n\t\n\tform.push({\"id\":\"5.1\", \"gr\":\"060\", \"vatClass\":\"3\", \"description\":\"Gesamtbetrag der Vorsteuern (ohne die nachstehend gesondert anzuführenden Beträge)\"});\n\tform.push({\"id\":\"5.2\", \"gr\":\"061\", \"vatClass\":\"3\", \"description\":\"Vorsteuern betreffend die entrichtete Einfuhrumsatzsteuer (§ 12 Abs. 1 Z 2 lit. a)\"});\n\tform.push({\"id\":\"5.3\", \"gr\":\"083\", \"vatClass\":\"3\", \"description\":\"Vorsteuern betreffend die geschuldete, auf dem Abgabenkonto verbuchte Einfuhrumsatzsteuer (§ 12 Abs. 1 Z 2 lit. b)\"});\t\n\tform.push({\"id\":\"5.4\", \"gr\":\"065\", \"vatClass\":\"3\", \"description\":\"Vorsteuern aus dem innergemeinschaftlichen Erwerb\"});\n\tform.push({\"id\":\"5.5\", \"gr\":\"066\", \"vatClass\":\"3\", \"description\":\"Vorsteuern betreffend die Steuerschuld gemäß § 19 Abs. 1 zweiter Satz, § 19 Abs. 1c, 1e sowie gemäß Art. 25 Abs. 5\"});\t\t\n\tform.push({\"id\":\"5.6\", \"gr\":\"082\", \"vatClass\":\"3\", \"description\":\"Vorsteuern betreffend die Steuerschuld gemäß § 19 Abs. 1a (Bauleistungen)\"});\n\tform.push({\"id\":\"5.7\", \"gr\":\"087\", \"vatClass\":\"3\", \"description\":\"Vorsteuern betreffend die Steuerschuld gemäß § 19 Abs. 1b (Sicherungseigentum, Vorbehaltseigentum und Grundstücke im Zwangsversteigerungsverfahren)\"});\t\t\t\n\tform.push({\"id\":\"5.8\", \"gr\":\"089\", \"vatClass\":\"3\", \"description\":\"Vorsteuern betreffend die Steuerschuld gemäß § 19 Abs. 1d (Schrott und Abfallstoffe)\"});\n\tform.push({\"id\":\"5.9\", \"gr\":\"064\", \"vatClass\":\"3\", \"description\":\"Vorsteuern für innergemeinschaftliche Lieferungen neuer Fahrzeuge von Fahrzeuglieferern gemäß Art. 2\"});\t\t\n\tform.push({\"id\":\"5.10\", \"gr\":\"062\", \"vatClass\":\"4\", \"description\":\"Davon nicht abzugsfähig gemäß § 12 Abs. 3 iVm Abs. 4 und 5\"});\n\tform.push({\"id\":\"5.11\", \"gr\":\"063\", \"vatClass\":\"3\", \"description\":\"Berichtigung gemäß § 12 Abs. 10 und 11\"});\n\tform.push({\"id\":\"5.12\", \"gr\":\"067\", \"vatClass\":\"3\", \"description\":\"Berichtigung gemäß § 16\"});\n\tform.push({\"id\":\"5.13\", \"description\":\"Gesamtbetrag der abziehbaren Vorsteuer\", \"sum\":\"-5.1;-5.2;-5.3;-5.4;-5.5;-5.6;-5.7;-5.8;-5.9;5.10;-5.11;-5.12\"});\n\t\n\tform.push({\"id\":\"6.1\", \"gr\":\"090\", \"vatClass\":\"3\", \"description\":\"\"});\n\tform.push({\"id\":\"7\", \"gr\":\"095\", \"description\":\"\", \"sum\":\"4.14.2;4.15.2;4.16.2;4.17.2;4.18.2;4.19.2;4.20;4.21;4.22;4.23;4.24;4.28.2;4.29.2;4.30.2;4.31.2;5.13;6.1\"});\n}", "title": "" }, { "docid": "32e03e26312411cc6d2ee93e9497c422", "score": "0.5469043", "text": "function valcamposproveedor(){\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"31\"){\r\n\t\tdocument.form1.nombre2.value='';\r\n\t\tdocument.form1.apellido1.value='';\r\n\t\tdocument.form1.apellido2.value='';\r\n\t\tdocument.form1.nombre2.disabled=true;\r\n\t\tdocument.form1.apellido1.disabled=true;\r\n\t\tdocument.form1.apellido2.disabled=true;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='none';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='';\r\n\t\t\r\n\t\tdiv = document.getElementById('primernom3');\r\n\t\tdiv.style.display ='none';\r\n\t\tdiv2 = document.getElementById('razonso3');\r\n\t\tdiv2.style.display ='';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"13\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\t\r\n\t\tdiv = document.getElementById('primernom3');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso3');\r\n\t\tdiv2.style.display ='none';\r\n\t\t\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"12\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\t\r\n\t\tdiv = document.getElementById('primernom3');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso3');\r\n\t\tdiv2.style.display ='none';\r\n\t\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"22\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\t\r\n\t\tdiv = document.getElementById('primernom3');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso3');\r\n\t\tdiv2.style.display ='none';\r\n\t\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"21\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\t\r\n\t\tdiv = document.getElementById('primernom3');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso3');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"11\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"41\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\t\r\n\t\tdiv = document.getElementById('primernom3');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso3');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"43\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n}", "title": "" }, { "docid": "dbc4aeff0288e278ba74187f301289e7", "score": "0.5466614", "text": "function partidoFormulario()\r\n\t{\r\n\t\t//Evento especial para definir qué botón presioné\r\n\t\t$('.partidoSubmitButton').click(function(){\r\n\t\t\t$('[name=\"partidoFormularioSubmitTipo\"]').val(this.value);\r\n\t\t});\r\n\t\t\r\n\t\tvar formularioPartido = $('#partidoForm');\r\n\t\tfunction partidoCrear()\r\n\t\t{\r\n\t\t\t$('.btn-partido-crear').unbind('click').click(function(e){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tvar t = $(this);\r\n\t\t\t\tvar d = t.data();\r\n\r\n\t\t\t\t//Establecemos los valores al formulario\r\n\t\t\t\tformularioPartido.find('input, select').attr('disabled', false);\r\n\t\t\t\tformularioPartido[0].reset();\r\n\t\t\t\t$('#formPartidoJornada').val(d.jornada);\r\n\t\t\t\t$('#formPartidoId').val(0);\r\n\t\t\t\t$('#formFecha').val((new Date().toJSON().slice(0,10)));\r\n\t\t\t\tsetTime($('#formHora').val(''));\r\n\t\t\t\t$('#noEditable').hide();\r\n\t\t\t\tformularioPartidoModal.modal('show').find('.modal-title').text('Creación de nuevo partido');\r\n\r\n\t\t\t\t//Mostramos/Ocultamos mensajes de error o éxito si es que este formulario ya fue usado anteriormente\r\n\t\t\t\t$('.form-footer-botones, #formPartidoTiempos').show();\r\n\t\t\t\t$('.form-footer-cerrar, .form-success').hide();\r\n\t\t\t\t$('.s-equipo:first').change();\r\n\t\t\t\talertErrorHide();\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//Edición de partido\r\n\t\tfunction partidoEditar()\r\n\t\t{\r\n\t\t\t$('.partido-editar').unbind('click').click(function(e){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tvar t = $(this);\r\n\t\t\t\tvar d = t.data('info');\r\n\r\n\t\t\t\t//Establecemos los valores al formulario\r\n\t\t\t\tformularioPartido[0].reset();\r\n\t\t\t\t$('#formPartidoId').val(d.ID_Partido);\r\n\t\t\t\t$('#formPartidoJornada').val(d.ID_Jornada).attr('disabled', !d.editable);\r\n\t\t\t\t$('#equipo1').val(d.equipos[0].id).attr('disabled', !d.editable);\r\n\t\t\t\t$('#equipo2').val(d.equipos[1].id).attr('disabled', !d.editable);\r\n\t\t\t\t\r\n\t\t\t\t$('#servicio1').prop('checked', (parseInt(d.equipos[0].servicio) === 1));\r\n\t\t\t\t$('#servicio2').prop('checked', (parseInt(d.equipos[1].servicio) === 1));\r\n\t\t\t\t$(\"#equipoS1\").val(d.equipos[0].id);\r\n\t\t\t\t$(\"#equipoS2\").val(d.equipos[1].id);\r\n\t\t\t\t\r\n\t\t\t\t$('#tipoCancha').val(d.TipoCancha).attr('disabled', !d.editable);\r\n\t\t\t\t$('#es_pendiente').val(d.Es_Pendiente).attr('disabled', !d.editable);\r\n\t\t\t\t$('#liguilla').prop('checked', parseInt(d.liguilla) === 1); //.attr('disabled', !d.editable);\r\n\t\t\t\t$('#formFecha').val(d.FechaHora.slice(0,10)).attr('disabled', !d.editable);\r\n\t\t\t\tsetTime($('#formHora').val(d.hora + ':00').attr('disabled', !d.editable));\r\n\r\n\t\t\t\tif(d.editable)\r\n\t\t\t\t\t$('#noEditable').hide();\r\n\t\t\t\telse\r\n\t\t\t\t\t$('#noEditable').show();\r\n\t\t\t\t\r\n\t\t\t\tfor(var i = 0; i < 3; i++)\r\n\t\t\t\t\t$('#formArbitro' + (i + 1)).val(d.arbitros[i]);\r\n\t\t\t\t\r\n\t\t\t\tvar arbitroFaltas = d.arbitrosFaltas.split(',');\r\n\t\t\t\tvar afIndex = 0;\r\n\t\t\t\tfor(var i = 1; i < 4; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor(var ii = 1; ii < 5; ii++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t$('#arbitroFaltas' + i + '' + ii).val(arbitroFaltas[afIndex].trim());\r\n\t\t\t\t\t\tafIndex++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tformularioPartidoModal.modal('show').find('.modal-title').text('Edición de partido');\r\n\r\n\t\t\t\t//Jornada actual\r\n\t\t\t\tjornadaActual = d.ID_Jornada;\r\n\r\n\t\t\t\t//Mostramos/Ocultamos mensajes de error o éxito si es que este formulario ya fue usado anteriormente\r\n\t\t\t\t$('.form-footer-botones, #formPartidoTiempos').show();\r\n\t\t\t\t$('.form-footer-cerrar, .form-success').hide();\r\n\t\t\t\t$('.s-equipo:first').change();\r\n\t\t\t\talertErrorHide();\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//Validar equipos enfrentados\r\n\t\tfunction partidoEquiposComparar()\r\n\t\t{\r\n\t\t\t$('.s-equipo').unbind('change').change(function(){\r\n\t\t\t\tvar t = $(this);\r\n\t\t\t\tvar d = t.data();\r\n\t\t\t\tvar otro = (d.equipo == 2) ? $('#equipo1') : $('#equipo2');\r\n\t\t\t\tif(t.val() == otro.val()) otro.find('option:selected').prop(\"selected\", false).next().prop(\"selected\", true);\r\n\t\t\t}).change();\r\n\t\t}\r\n\r\n\t\t//Validaciones de formulario de partido\r\n\t\tformularioPartido.validator().submit(function (e) {\r\n\t\t\tif(!e.isDefaultPrevented() && !_ajaxBussy_)\r\n\t\t\t{\r\n\t\t\t\t_ajaxBussy_ = true;\r\n\t\t\t\talertErrorHide();\r\n\t\t\t\tbotonesDeshabilitar();\r\n\t\t\t\tformWait.show();\r\n\t\t\t\tformSuccess.hide();\r\n\r\n\t\t\t\t//Enviar solicitud al servidor\r\n\t\t\t\t$.ajax({\r\n\t\t\t\t\turl: _sitePath_ + 'torneo/partidos/partido_submit' + _suffix_,\r\n\t\t\t\t\tdata: formularioPartido.serialize(),\r\n\t\t\t\t\tsuccess: function(data){\r\n\t\t\t\t\t\tif(data.error == 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tformularioPartido.find('.form-footer-cerrar, .form-success').show();\r\n\t\t\t\t\t\t\tformularioPartido.find('.form-footer-botones').hide();\r\n\r\n\t\t\t\t\t\t\t//Recargar página\r\n\t\t\t\t\t\t\tvar jContenedor = $('#jornada-' + $('#formPartidoJornada').val());\r\n\t\t\t\t\t\t\tjContenedor.load(window.location + \" #\" + jContenedor.attr('id') + ' > *', function(){\r\n\t\t\t\t\t\t\t\taccionesInicializar();\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t//Recargar jornada vieja si es necesario\r\n\t\t\t\t\t\t\tif(parseInt(jornadaActual) != parseInt($('#formPartidoJornada').val()))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvar jContenedor = $('#jornada-' + jornadaActual);\r\n\t\t\t\t\t\t\t\tjContenedor.load(window.location + \" #\" + jContenedor.attr('id') + ' > *', function(){\r\n\t\t\t\t\t\t\t\t\taccionesInicializar();\r\n\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//Tipos de error\r\n\t\t\t\t\t\t\tvar msg = _errorMsg_;\r\n\t\t\t\t\t\t\tswitch(data.error)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcase 1: msg = 'Los equipos no pueden ser iguales.'; break;\r\n\t\t\t\t\t\t\t\tcase 2: msg = 'No hay disponibilidad para el tipo de cancha en la fecha y hora seleccionados.'; break;\r\n\t\t\t\t\t\t\t\tcase 3: msg = 'Uno de los equipos seleccionados ya tiene partido programado para esta jornada.'; break;\r\n\t\t\t\t\t\t\t\tcase 9: msg = 'El puntaje de este partido ya se ha establecido. No puede ser editado.'; break;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\talertErrorMsg( '<i class=\"fa fa-warning\"></i> ' + msg );\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t},\r\n\t\t\t\t\terror: function(){ alertErrorMsg(_errorMsg_); },\r\n\t\t\t\t\tcomplete: function(){\r\n\t\t\t\t\t\tbotonesHabilitar();\r\n\t\t\t\t\t\tformWait.hide();\r\n\t\t\t\t\t\t_ajaxBussy_ = false;\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\te.preventDefault();\r\n\t\t});\r\n\r\n\t\tpartidoCrear();\r\n\t\tpartidoEditar();\r\n\t\tpartidoEquiposComparar();\r\n\t}", "title": "" }, { "docid": "e4160e8749a065a46eec9eab8ec2ab01", "score": "0.54558605", "text": "function limpiaCampos(idforma) {\n\t\n}", "title": "" }, { "docid": "5503dfe45c13c731b37c3c95056ff2e5", "score": "0.54555714", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n cen_codigo: false,\n cen_nome: false,\n };\n this.apiService.formVisible = {\n cen_codigo: true,\n cen_nome: true,\n };\n this.permissaoFieldDisabled('centrocus');\n this.permissaoFieldVisible('centrocus');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getcentrocusId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "8f2280a22c4b1b09f57109950adaf8b1", "score": "0.54534274", "text": "function Produto (nome, preco) {\n this.nome = nome,\n this.preco = preco\n}", "title": "" }, { "docid": "81408ca2313cf9545269a24deb28646a", "score": "0.5438178", "text": "function abrirConstancia(form, pag, param) {\n\tvar registros = \"\";\n\tfor(i=0; n=form.elements[i]; i++) {\n\t\tif (n.type == \"checkbox\" && n.name == \"sel\" && n.checked) {\n\t\t\tregistros += n.value + \";\";\n\t\t}\n\t}\n\tvar len = registros.length; len--;\n\tregistros = registros.substr(0, len);\n\t\n\twindow.open(\"pdf_constancias.php?registros=\"+registros, \"\", \"toolbar=no, menubar=no, location=no, scrollbars=yes, height=800, width=800, left=200, top=200, resizable=yes\");\n}", "title": "" }, { "docid": "6a345b1525c9edaa681d6eba56ac4d5d", "score": "0.542907", "text": "function adaptar_formularioPropiedades() {\n $(\"#sm_contenedor_activo\").fadeOut('slow');\n $(\"#sm_contenedor_activoarticulo\").fadeOut('slow');\n $(\"#sm_contenedor_controles\").fadeOut('slow');\n $(\"#sm_contenedor_transporte\").fadeOut('slow');\n $(\"#sm_contenedor_imagenes\").fadeOut('slow');\n $(\"#sm_contenedor_propiedades\").fadeIn('slow');\n //requerido o no del formulario\n $(\"#txtplacaactivo\").removeAttr('required');\n $(\"#hddproveedor\").removeAttr('required');\n $(\"#txtplacavehiculo\").removeAttr('required');\n $(\"#txtnumerochasis\").removeAttr('required');\n $(\"#cmbdepartamento\").removeAttr('required');\n $(\"#txtconsecutivovehiculo\").removeAttr('required');\n}", "title": "" }, { "docid": "b168cee17c3bec2edc5ebdc34ec879a8", "score": "0.54230267", "text": "function envForm() {\n enviarFormulario();\n }", "title": "" }, { "docid": "b99fe97ab57d64971fe627a800f1b4b9", "score": "0.54190195", "text": "function actualizar_clientePagador(){\n\t\tenviarFormulario(\"#form_repLegal_editar\",'ClientePagador/actualizar_repLegalCliente', '#cuadro4');\n\t}", "title": "" }, { "docid": "0176db332b79a52e499740671989e22c", "score": "0.54039097", "text": "function setForm(){\r\n\tgetProject();\r\n\tsetMemberSelect(memberList);\r\n\tsetLastSprint(lastSprint);\r\n\tgetStatus();\r\n}", "title": "" }, { "docid": "7a951159d7a006cd3a631d22ec7670bc", "score": "0.5398626", "text": "function fValoresRepLegal(iCvePersona,cRFC,cRPA,iTipoPersona,cNomRazonSocial,cApPaterno,cApMaterno,cCorreoE,cPseudonimoEmp,\n iCveDomicilio,iCveTipoDomicilio,cCalle,cNumExterior,cNumInterior,cColonia,cCodPostal,cTelefono,\n iCvePais,cDscPais,iCveEntidadFed,cDscEntidadFed,iCveMunicipio,cDscMunicipio,iCveLocalidad,\n cDscLocalidad,lPredeterminado,cDscTipoDomicilio,cDscDomicilio){\n frm.iCveRepLegal.value = iCvePersona\n frm.cRFC2.value = cRFC;\n frm.cRPA2.value = cRPA;\n frm.iTipoPersona2.value = iTipoPersona;\n frm.cNombreSolo2.value = cNomRazonSocial;\n frm.cNomRazonSocial2.value = cNomRazonSocial;\n if (iTipoPersona == \"1\")\n frm.cNomRazonSocial2.value += \" \" + cApPaterno + \" \" + cApMaterno;\n frm.cApPaterno2.value = cApPaterno;\n frm.cApMaterno2.value = cApMaterno;\n frm.cCorreoE2.value = cCorreoE;\n frm.cPseudonimoEmp2.value = cPseudonimoEmp;\n\n frm.iCveDomRepLegal.value = iCveDomicilio;\n frm.iCveTipoDomicilio2.value = iCveTipoDomicilio;\n frm.cCalle2.value = cCalle;\n frm.cNumExterior2.value = cNumExterior;\n frm.cNumInterior2.value = cNumInterior;\n frm.cColonia2.value = cColonia;\n frm.cCodPostal2.value = cCodPostal;\n frm.cTelefono2.value = cTelefono;\n frm.iCvePais2.value = iCvePais;\n frm.cDscPais2.value = cDscPais;\n frm.iCveEntidadFed2.value = iCveEntidadFed;\n frm.cDscEntidadFed2.value = cDscEntidadFed;\n frm.iCveMunicipio2.value = iCveMunicipio;\n frm.cDscMunicipio2.value = cDscMunicipio;\n frm.iCveLocalidad2.value = iCveLocalidad;\n frm.cDscLocalidad2.value = cDscLocalidad;\n frm.lPredeterminado2.value = lPredeterminado;\n frm.cDscTipoDomicilio2.value = cDscTipoDomicilio;\n frm.cDscDomicilio2.value = cDscDomicilio;\n}", "title": "" }, { "docid": "665889eeb06890406a755f8f10cb58a2", "score": "0.5387561", "text": "constructor(controlador){\n\t\tsuper('js/vistas/formularioalta.html')\n\t\tthis.controlador = controlador\n\t\tthis.imagenes = []\n\t}", "title": "" }, { "docid": "90b753c7a227375522717da826138970", "score": "0.5383935", "text": "function pokreniKviz(){\r\n // niz koji popunjavamo tekstom pitanja i ponudjenim odgovorima\r\n // niz ce sadrzati HTML elemente\r\n const output = [];\r\n\r\n // prolazimo petljom kroz sve elemente niza pitanja\r\n // uzimamo pitanje koje je aktuelno u trenutnoj iteraciji i njegov indeks\r\n pitanja.forEach(function(trenutnoPitanje, pitanjeInd){\r\n // niz koji cemo popuniti odgovorima na trenutno pitanje\r\n const odgovori = []; \r\n // petlja koja prolazi svim odgovorima trenutnog pitanja\r\n for(slovo in trenutnoPitanje.odgovori){\r\n // u niz odgovora dodajemo HTML kod za prikaz ponudjenog odgovora\r\n // inputi za odgovor na isto pitanje moraju imati isti name atribut\r\n // odradjujemo da svaki od njih ima name=\"odogovor\"+indeks_trenutnog_pitanja\r\n // na taj nacin ce svi ponudjeni odgovori na pitanje sa indeksom 1 imati name=\"odgovor1\"\r\n // vrijednost odgovora je upravo ono slovo pod kojim je on i ponudjen\r\n // tekst je oblika: \" a : tekst_odgovora \"\r\n odgovori.push(\r\n `<label id=\"${slovo}\">\r\n <input type=\"radio\" name=\"odgovor${pitanjeInd}\" value=\"${slovo}\" >\r\n ${slovo} : ${trenutnoPitanje.odgovori[slovo]}\r\n </label>`\r\n );\r\n }\r\n\r\n // na kraju u output niz koji sadrzi sva pitanja i ponudjene odgovore dodajemo trenutno\r\n // trenutnoPitanje.pitanje je tekst pitanja\r\n // funkcija join od niza pravi string\r\n output.push(\r\n `\r\n <div class=\"pitanje\">${trenutnoPitanje.pitanje}</div>\r\n <div class=\"odgovori\"> ${odgovori.join('')} </div>\r\n `\r\n );\r\n\r\n });\r\n // na kraju popunjavamo div za prikaz pitanja i odgovora\r\n kvizDiv.innerHTML = output.join('');\r\n}", "title": "" }, { "docid": "124cf2b5eb2e9088f6fc3ad2afacd9f9", "score": "0.5374609", "text": "get form() {\n\t\treturn this.__form;\n\t}", "title": "" }, { "docid": "27a0286eb897b220bce01f4959ce93b0", "score": "0.5371319", "text": "function fValoresRepLegal(iCvePersona,cRFC,cRPA,iTipoPersona,cNomRazonSocial,cApPaterno,cApMaterno,cCorreoE,cPseudonimoEmp,\n iCveDomicilio,iCveTipoDomicilio,cCalle,cNumExterior,cNumInterior,cColonia,cCodPostal,cTelefono,\n iCvePais,cDscPais,iCveEntidadFed,cDscEntidadFed,iCveMunicipio,cDscMunicipio,iCveLocalidad,\n cDscLocalidad,lPredeterminado,cDscTipoDomicilio,cDscDomicilio){\n frm.iCveRepLegal.value = iCvePersona\n frm.cRFC2.value = cRFC;\n frm.cRPA2.value = cRPA;\n frm.iTipoPersona2.value = iTipoPersona;\n frm.cNomRazonSocial2.value = cNomRazonSocial;\n if (iTipoPersona == \"1\")\n frm.cNomRazonSocial2.value += \" \" + cApPaterno + \" \" + cApMaterno;\n frm.cApPaterno2.value = cApPaterno;\n frm.cApMaterno2.value = cApMaterno;\n frm.cCorreoE2.value = cCorreoE;\n frm.cPseudonimoEmp2.value = cPseudonimoEmp;\n\n frm.iCveDomRepLegal.value = iCveDomicilio;\n frm.iCveTipoDomicilio2.value = iCveTipoDomicilio;\n frm.cCalle2.value = cCalle;\n frm.cNumExterior2.value = cNumExterior;\n frm.cNumInterior2.value = cNumInterior;\n frm.cColonia2.value = cColonia;\n frm.cCodPostal2.value = cCodPostal;\n frm.cTelefono2.value = cTelefono;\n frm.iCvePais2.value = iCvePais;\n frm.cDscPais2.value = cDscPais;\n frm.iCveEntidadFed2.value = iCveEntidadFed;\n frm.cDscEntidadFed2.value = cDscEntidadFed;\n frm.iCveMunicipio2.value = iCveMunicipio;\n frm.cDscMunicipio2.value = cDscMunicipio;\n frm.iCveLocalidad2.value = iCveLocalidad;\n frm.cDscLocalidad2.value = cDscLocalidad;\n frm.lPredeterminado2.value = lPredeterminado;\n frm.cDscTipoDomicilio2.value = cDscTipoDomicilio;\n frm.cDscDomicilio2.value = cDscDomicilio;\n if (window.parent){\n if (window.parent.fValoresRepLegal)\n window.parent.fValoresRepLegal(iCvePersona,cRFC,cRPA,iTipoPersona,cNomRazonSocial,cApPaterno,cApMaterno,cCorreoE,cPseudonimoEmp,\n iCveDomicilio,iCveTipoDomicilio,cCalle,cNumExterior,cNumInterior,cColonia,cCodPostal,cTelefono,\n iCvePais,cDscPais,iCveEntidadFed,cDscEntidadFed,iCveMunicipio,cDscMunicipio,iCveLocalidad,\n cDscLocalidad,lPredeterminado,cDscTipoDomicilio,cDscDomicilio);\n }\n fFocusRegistraTramite();\n}", "title": "" }, { "docid": "86b6ca7a3d6e43faa68465f6cde6a14b", "score": "0.53677267", "text": "function Cambio() {\n setProductos([...productos, { id: 5, nombre: 'Camisa VueJS', Precio: 20 }])\n }", "title": "" }, { "docid": "f3349a21578a1c0b5040ee0d3c917e72", "score": "0.53622246", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n tip_codigo: false,\n tip_nome: false,\n };\n this.apiService.formVisible = {\n tip_codigo: true,\n tip_nome: true,\n };\n this.permissaoFieldDisabled('tipo_manu');\n this.permissaoFieldVisible('tipo_manu');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.gettipo_manuId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "5a9e83ee46a2419b17ee932dc93d0528", "score": "0.5361835", "text": "function mostrarFormCrearProducto() {\n vista.mostrarPlantilla('formCrearArticulo', 'areaTrabajo');\n document.getElementById(\"btnCrearArticuloLimpiar\").addEventListener(\"click\", limpiarFormularioCrearProducto);\n}", "title": "" }, { "docid": "ce2153b00eadda897dfa341ba19f4d02", "score": "0.53575534", "text": "function populateForm2Js(){\n\t//Primero determinamos el modo en el que estamos;\n\tvar mode = getMMGMode(get('segPaisFrm.accion'), \n\t\tget('segPaisFrm.origen'));\n\t\n\tjsSegPaisId = get('segPaisFrm.id').toString();\n\tjsSegPaisCodPais = get('segPaisFrm.codPais').toString();\n\tjsSegPaisMoneOidMone = get('segPaisFrm.moneOidMone')[0];\n\tjsSegPaisMoneOidMoneAlt = get('segPaisFrm.moneOidMoneAlt')[0];\n\tif(mode == MMG_MODE_CREATE || mode == MMG_MODE_UPDATE_FORM){\n\t\tjsSegPaisDescripcion = buildLocalizedString('segPaisFrm', 1);\n\t}else{\n\t\tjsSegPaisDescripcion = get('segPaisFrm.Descripcion');\n\t}\n\tjsSegPaisIndInteGis = get('segPaisFrm.indInteGis')[0];\n\tjsSegPaisValIden = get('segPaisFrm.valIden')[0];\n\tjsSegPaisIndSaldUnic = get('segPaisFrm.indSaldUnic');\n\tjsSegPaisValProgEjec = get('segPaisFrm.valProgEjec').toString();\n\tjsSegPaisValPorcAlar = get('segPaisFrm.valPorcAlar').toString();\n\tjsSegPaisIndCompAuto = get('segPaisFrm.indCompAuto');\n\tjsSegPaisNumDiasMora = get('segPaisFrm.numDiasMora').toString();\n\tjsSegPaisIndTratAcumDesc = get('segPaisFrm.indTratAcumDesc');\n\tjsSegPaisValTiemRezo = get('segPaisFrm.valTiemRezo').toString();\n\tjsSegPaisValConfSecuCcc = get('segPaisFrm.valConfSecuCcc')[0];\n\tjsSegPaisNumDiasFact = get('segPaisFrm.numDiasFact').toString();\n\tjsSegPaisNumLimiDifePago = get('segPaisFrm.numLimiDifePago').toString();\n\tjsSegPaisIndEmisVenc = get('segPaisFrm.indEmisVenc');\n\tjsSegPaisValMaxiDifeAnlsComb = get('segPaisFrm.valMaxiDifeAnlsComb').toString();\n\tjsSegPaisNumPosiNumeClie = get('segPaisFrm.numPosiNumeClie').toString();\n\tjsSegPaisValFormFech = get('segPaisFrm.valFormFech')[0];\n\tjsSegPaisValSepaMile = get('segPaisFrm.valSepaMile')[0];\n\tjsSegPaisValSepaDeci = get('segPaisFrm.valSepaDeci')[0];\n\tjsSegPaisNumPeriEgre = get('segPaisFrm.numPeriEgre').toString();\n\tjsSegPaisNumPeriReti = get('segPaisFrm.numPeriReti').toString();\n\tjsSegPaisFopaOidFormPago = get('segPaisFrm.fopaOidFormPago')[0];\n\tjsSegPaisValCompTele = get('segPaisFrm.valCompTele').toString();\n\tjsSegPaisIndFletZonaUbig = get('segPaisFrm.indFletZonaUbig')[0];\n\tjsSegPaisValIndiSecuMoni = get('segPaisFrm.valIndiSecuMoni');\n\tjsSegPaisIndSecu = get('segPaisFrm.indSecu')[0];\n\tjsSegPaisIndBalaAreaCheq = get('segPaisFrm.indBalaAreaCheq')[0];\n\tjsSegPaisValUrl = get('segPaisFrm.valUrl').toString();\n\tjsSegPaisIndImpuIncl = get('segPaisFrm.indImpuIncl');\n\t\n}", "title": "" }, { "docid": "de72fdaca9428a1d81518512020343e9", "score": "0.53531003", "text": "function Parametros(){\n anio = { fieldLabel:'ANIO'\n\t ,id:'anio'\n\t ,xtype:'numberfield'\n\t ,width:100\n\t ,allowNegative: false\n\t ,allowDecimals:false\n\t ,maxLength:4\n\t ,minLength:4\n\t ,decimalPrecision:0\n\t ,allowBlank:false\t \n }; \n mes = {id:'mes'\n\t ,xtype: 'genCmbBox'\n\t ,sqlId: 'CoRtTr_AnxMeses'\n\t ,minChars: 1\n\t ,allowBlank:false\n\t ,fieldLabel: 'MES'\n\t ,width:100\n\t ,listWidth: 100\n\t }\n panelParametro = new Ext.FormPanel({\n\titems:[anio, mes]\n });\n panelParametro.render(document.body, 'divIzq01');\n}", "title": "" }, { "docid": "b7f11a5307622623da4e00a482550260", "score": "0.53455967", "text": "function limpiarFormulario() {\n formulario.reset();\n codigoForm.className = \"form-control\";\n cantidadForm.className = \"form-control\";\n urlForm.className = \"form-control\";\n nombreProducto.className = \"form-control\";\n descripcionProducto.className = \"form-control\";\n categoria.className = \"form-control\";\n codigoForm.removeAttribute(\"disabled\")\n categoria.removeAttribute(\"disabled\")\n urlForm.removeAttribute(\"disabled\")\n}", "title": "" }, { "docid": "5bf895a9387a7898dccf82f4167489b8", "score": "0.5344808", "text": "function cambiarValorObjeto(p1){ //podes definir persona tambien\n p1.nombre = 'Maxi';\n p1.apellido = 'Saldivia';\n\n}", "title": "" }, { "docid": "06e8e7604f8ece36ccb3e05595e03218", "score": "0.53368485", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n cla_codigo: false,\n cla_nome: false,\n };\n this.apiService.formVisible = {\n cla_codigo: true,\n cla_nome: true,\n };\n this.permissaoFieldDisabled('classe_manu');\n this.permissaoFieldVisible('classe_manu');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getclasse_manuId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "3e7cb468ee6de7dff6979fa814ff367c", "score": "0.5335622", "text": "function pegaValorForm(event){\n event.preventDefault()\n const formData = new FormData(event.target);\n const data = Object.fromEntries(formData);\n \n return data\n}", "title": "" }, { "docid": "ef72756adab79e96365ba90bd0958186", "score": "0.5331773", "text": "function ObtenerFormaAgregarGrupo()\n{\n $(\"#dialogAgregarGrupo\").obtenerVista({\n nombreTemplate: \"tmplAgregarGrupo.html\",\n despuesDeCompilar: function(pRespuesta) {\n $(\"#dialogAgregarGrupo\").dialog(\"open\");\n }\n });\n}", "title": "" }, { "docid": "bb925c35861de6c9c49081df2b4b64a9", "score": "0.53284353", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n maq_codigo: false,\n pec_codigo: false,\n pec_codintegracao: false,\n pec_custo: false,\n pec_descricao: false,\n pec_estoque: false,\n pec_estoque_min: false,\n pec_imagem: false,\n pec_localizacao: false,\n pec_nome: false,\n pec_nova: false,\n pec_nrserie: false,\n pec_unidade: false,\n };\n this.apiService.formVisible = {\n maq_codigo: true,\n pec_codigo: true,\n pec_codintegracao: true,\n pec_custo: true,\n pec_descricao: true,\n pec_estoque: true,\n pec_estoque_min: true,\n pec_imagem: true,\n pec_localizacao: true,\n pec_nome: true,\n pec_nova: true,\n pec_nrserie: true,\n pec_unidade: true,\n };\n this.permissaoFieldDisabled('pecas');\n this.permissaoFieldVisible('pecas');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getpecasId(id).subscribe(data => {\n data[0].status_reg = 'U';\n if (data[0].pec_imagem) {\n data[0].pec_imagem = this.baseUrl + '/' + data[0].pec_imagem;\n }\n else {\n data[0].pec_imagem = this.baseUrl + '/alternative.png';\n }\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n this.arrmaquinas = this.apimaquinas.getmaquinas().pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_5__[\"map\"])(dados => {\n console.log(dados);\n return dados;\n }));\n }", "title": "" }, { "docid": "124f6b1635cefd531ca0f4f969db5435", "score": "0.53219813", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n esp_codigo: false,\n esp_nome: false,\n };\n this.apiService.formVisible = {\n esp_codigo: true,\n esp_nome: true,\n };\n this.permissaoFieldDisabled('espera');\n this.permissaoFieldVisible('espera');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getesperaId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "a3b7d875f669ab06b38877e5dcfbc98f", "score": "0.5318029", "text": "function cambioDatosPersonalesParticular() {\n var formPersona = $('#datosPersonalesForm');\n var formEmpresa = $('#datosEmpresaForm');\n //suponemos que la fecha ya viene en formato dd/mm/aaaa\n formPersona.find('#fechaNacimiento').val(formEmpresa.find('#fechaNacimiento2').val());\n formPersona.find('#cp').val(formEmpresa.find('#cp2').val());\n var state = formEmpresa.find('#provincia2').val();\n changeCustomSelect(formPersona.find('#select-ul-Provincia li[v=' + state + ']'), formPersona);\n //$(\"input[name=tipoDatosPersonales]:checked\")\n if (formEmpresa.find('#radio_r_men2').hasClass('active')) {\n formPersona.find('#radio_r_men').click();\n } else {\n formPersona.find('#radio_r_women').click();\n }\n\n formPersona.find('#nombre').val(formEmpresa.find('#nombre').val());\n formPersona.find('#apellido').val(formEmpresa.find('#apellido').val());\n formPersona.find('#direccion').val(formEmpresa.find('#direccion').val());\n formPersona.find('#direccion2').val(formEmpresa.find('#direccion2').val());\n formPersona.find('#localidad').val(formEmpresa.find('#localidad').val());\n\n formPersona.find('#prefijo').val(formEmpresa.find('#prefijo').val());\n formPersona.find('#telefono').val(formEmpresa.find('#telefono').val());\n\n formPersona.find('#prefijo2').val(formEmpresa.find('#prefijo2').val());\n formPersona.find('#telefono2').val(formEmpresa.find('#telefono2').val());\n\n $(\"#datosEmpresaDiv\").hide();\n $(\"#datosPersonalesDiv\").show();\n}", "title": "" }, { "docid": "4469ba17040fd2d3bca0c82827fae4dc", "score": "0.5317626", "text": "function limpiarformulario(formulario){\n /* Se encarga de leer todas las etiquetas input del formulario*/\n $(formulario).find('input').each(function() {\n\n switch(this.type) {\n\n case 'password':\n case 'text':\n case 'hidden':\n $(this).val('');\n break;\n case 'checkbox':\n case 'radio':\n this.checked = false;\n }\n });\n \n /* Se encarga de leer todas las etiquetas select del formulario */\n $(formulario).find('select').each(function() {\n $(\"#\"+this.id + \" option[value='']\").attr(\"selected\",true);\n });\n /* Se encarga de leer todas las etiquetas textarea del formulario */\n $(formulario).find('textarea').each(function(){\n $(this).val('');\n });\n $('#grilla tbody').empty();\n fn_cantidad(); \n fn_sumatotal();\n \n}", "title": "" }, { "docid": "f58ee5184455a0096dedfd299d1a44f8", "score": "0.5316738", "text": "function populateForm2Js(){\n\t//Primero determinamos el modo en el que estamos;\n\tvar mode = getMMGMode(get('msgMedioEnvioPaisFrm.accion'), \n\t\tget('msgMedioEnvioPaisFrm.origen'));\n\t\n\tjsMsgMedioEnvioPaisId = get('msgMedioEnvioPaisFrm.id').toString();\n\tjsMsgMedioEnvioPaisPaisOidPais = get('msgMedioEnvioPaisFrm.paisOidPais')[0];\n\tjsMsgMedioEnvioPaisMeenOidMediEnvi = get('msgMedioEnvioPaisFrm.meenOidMediEnvi')[0];\n\tjsMsgMedioEnvioPaisCodEsta = get('msgMedioEnvioPaisFrm.codEsta');\n\t\n}", "title": "" }, { "docid": "0a47326f92572e7410ae446cd8629bad", "score": "0.5314925", "text": "function browseProizvod(){\n\t$(\".fieldsetP\").show();\n\t$( \"#dialog-formP\" ).dialog({\n\t\t\tautoOpen: true,\n\t\t\theight: 700,\n\t\t\twidth: 1150,\n\t\t\tmodal: true,\t//da se zatamni ostatak stranice\n\t\t\tclose: function() {\n\t\t\t\t$(\".filedsetP\").hide();\n\t\t\t}\n\t});\n}", "title": "" }, { "docid": "728d7b5b1aae99b9d7e4c7e985325b4d", "score": "0.5305934", "text": "function CumplimentarFormulario() {\n sTbNombre.val(gMiembroSel.Nombre);\n if (gMiembroSel.Apellidos) sTbApellidos.val(gMiembroSel.Apellidos);\n if (gMiembroSel.Email) sTbEmail.val(gMiembroSel.Email);\n if (gMiembroSel.CiudadNac) sTbCiudadNac.val(gMiembroSel.CiudadNac);\n if (gMiembroSel.CiudadRes) sTbCiudadRes.val(gMiembroSel.CiudadRes);\n if (gMiembroSel.FechaNac) {\n /*\n var anioNac = parseInt(gMiembroSel.FechaNac.slice(0, 4));\n if (anioNac > 0) sTbAnioNac.val(anioNac);\n var diaNac = parseInt(gMiembroSel.FechaNac.slice(6, 8));\n if (diaNac > 0) sTbDiaNac.val(diaNac);\n var mesNac = parseInt(gMiembroSel.FechaNac.slice(4, 6));\n if (mesNac > 0) sDdlMesesNac.val(mesNac + 1);\n */\n var fechaNac = gMiembroSel.FechaNac;\n //console.log('fechaNac: ' + fechaNac);\n sInFechaNac.val(fechaNac.slice(0, 4) + '-' + fechaNac.slice(4, 6) + '-' + fechaNac.slice(6, 8));\n\n };\n if (gMiembroSel.FechaObi) {\n sRbAntepasado.prop('checked', true);\n //sRbAntepasado.mousedown();\n sRbAntepasado.trigger(\"click\");\n /*\n var anioObi = parseInt(gMiembroSel.FechaObi.slice(0, 4));\n if (anioObi > 0) sTbAnioObi.val(anioObi);\n var diaObi = parseInt(gMiembroSel.FechaObi.slice(6, 8));\n if (diaObi > 0) sTbDiaObi.val(diaObi);\n var mesObi = parseInt(gMiembroSel.FechaObi.slice(4, 6));\n if (mesObi > 0) sDdlMesesObi.val(mesObi + 1);*/\n var fechaObi = gMiembroSel.fechaObi;\n sInFechaObi.val(fechaObi.slice(0, 4) + '-' + fechaObi.slice(4, 6) + '-' + fechaObi.slice(6, 8));\n }\n else {\n sRbVida.prop('checked', true);\n //sRbVida.mousedown();\n sRbVida.trigger(\"click\");\n };\n if (gMiembroSel.Sexo == \"M\") {\n //sRbMujer.mousedown();\n sRbMujer.prop('checked', true);\n sRbMujer.trigger(\"click\");\n \n }\n else {\n sRbHombre.prop('checked', true);\n //sRbHombre.mousedown();\n sRbHombre.trigger(\"click\");\n \n };\n if (gMiembroSel.TipoMiembro == '2' || gMiembroSel.TipoMiembro == '3') {\n sForRelacion.show();\n if (gMiembroSel.Sexo == \"M\") {\n sRelacionM.show();\n sRelacionH.hide();\n sDdlRelacionM.val(gMiembroSel.Relacion + 1);\n sDdlRelacionM.selectmenu(\"refresh\", true);\n }\n else {\n sRelacionH.show();\n sRelacionM.hide();\n sDdlRelacionH.val(gMiembroSel.Relacion + 1);\n sDdlRelacionH.selectmenu(\"refresh\", true);\n };\n // sDdlRelacionH.val(gMiembroSel.Relacion + 1);\n // sDdlRelacionM.val(gMiembroSel.Relacion + 1);\n }\n else {\n sForRelacion.hide();\n };\n gNombreImgMiembro = '';\n if (gMiembroSel.Foto) {\n hayFotoAntes = true;\n PonerFotoUsuario(sImgFotoCargada, gMiembroSel.Foto, ((sRbHombre.prop('checked')) ? \"H\" : \"M\"), W_FOTO_USUARIO_MB);\n /* sImgFotoCargada.attr('src', '\\\\Images\\\\users\\\\' + gMiembroSel.Foto);\n if (sImgFotoCargada.width() > sImgFotoCargada.height()) {\n sImgFotoCargada.css('width', '110px');\n sImgFotoCargada.css('height', 'auto');\n }\n else {\n sImgFotoCargada.css('width', 'auto');\n sImgFotoCargada.css('height', '110px');\n };\n sImgFotoCargada.css('display', 'block');\n */\n sBCambiarFoto.show();\n sBSubirFoto.hide();\n }\n else {\n hayFotoAntes = false;\n sBCambiarFoto.hide();\n sBSubirFoto.show();\n };\n hayFotoDespues = hayFotoAntes;\n hayNuevaFoto = false;\n }", "title": "" }, { "docid": "e7e3e2292d794733a3b2f58245d90111", "score": "0.5301341", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n per_codigo: false,\n per_nome: false,\n per_simbolo: false,\n per_tolerancia: false,\n };\n this.apiService.formVisible = {\n per_codigo: true,\n per_nome: true,\n per_simbolo: true,\n per_tolerancia: true,\n };\n this.permissaoFieldDisabled('periodos');\n this.permissaoFieldVisible('periodos');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getperiodosId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "2a469d415df9675076bad074fca0c149", "score": "0.5300061", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n set_codigo: false,\n set_nome: false,\n };\n this.apiService.formVisible = {\n set_codigo: true,\n set_nome: true,\n };\n this.permissaoFieldDisabled('setores');\n this.permissaoFieldVisible('setores');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getsetoresId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "1da117f737f2667876893797e5814f7a", "score": "0.52974284", "text": "function ShowDetallePer(ixPer) {\n // Actualiza datos de la seccion de Directorio \n document.getElementById(\"nombre\").value = FormaNombre(ixPer);\n document.getElementById(\"org\").value = objDirPer.Pers[ixPer].Organiza.trim();\n document.getElementById(\"tel1\").value = objDirPer.Pers[ixPer].TelDirecto.trim();\n document.getElementById(\"tel2\").value = objDirPer.Pers[ixPer].Extension.trim();\n document.getElementById(\"tel3\").value = objDirPer.Pers[ixPer].TelCasa.trim();\n document.getElementById(\"tel4\").value = objDirPer.Pers[ixPer].TelCel.trim();\n document.getElementById(\"mail\").value = objDirPer.Pers[ixPer].eMail.trim();\n document.getElementById(\"fax\").value = objDirPer.Pers[ixPer].FaxDirecto.trim();\n document.getElementById(\"puesto\").value = objDirPer.Pers[ixPer].Puesto.trim();\n document.getElementById(\"coment\").value = objDirPer.Pers[ixPer].Comentarios.trim();\n // Actualiza datos de la seccion de Contactos\n document.getElementById(\"perorg\").value = objDirPer.Pers[ixPer].Organiza.trim();\n document.getElementById(\"pertel1\").value = objDirPer.Pers[ixPer].TelDirecto.trim();\n document.getElementById(\"pertel2\").value = objDirPer.Pers[ixPer].Extension.trim();\n document.getElementById(\"pertel3\").value = objDirPer.Pers[ixPer].TelCasa.trim();\n document.getElementById(\"pertel4\").value = objDirPer.Pers[ixPer].TelCel.trim();\n document.getElementById(\"permail\").value = objDirPer.Pers[ixPer].eMail.trim();\n document.getElementById(\"perfax\").value = objDirPer.Pers[ixPer].FaxDirecto.trim();\n document.getElementById(\"perpuesto\").value = objDirPer.Pers[ixPer].Puesto.trim();\n document.getElementById(\"percoment\").value = objDirPer.Pers[ixPer].Comentarios.trim();\n\n document.getElementById(\"perNomAP\").value = objDirPer.Pers[ixPer].NomAP.trim();\n document.getElementById(\"perNomAM\").value = objDirPer.Pers[ixPer].NomAM.trim();\n document.getElementById(\"perNom1\").value = objDirPer.Pers[ixPer].Nom1.trim();\n document.getElementById(\"perNom2\").value = objDirPer.Pers[ixPer].Nom2.trim();\n document.getElementById(\"idPer\").value = objDirPer.Pers[ixPer].idPer.trim();\n document.getElementById(\"accion\").value = \"C\";\n}", "title": "" }, { "docid": "8dbc41912785b9ed1da0585df666c4e1", "score": "0.52933216", "text": "function valcamposcliente(){\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"31\"){\r\n\t\tdocument.form1.nombre2.value='';\r\n\t\tdocument.form1.apellido1.value='';\r\n\t\tdocument.form1.apellido2.value='';\r\n\t\tdocument.form1.nombre2.disabled=true;\r\n\t\tdocument.form1.apellido1.disabled=true;\r\n\t\tdocument.form1.apellido2.disabled=true;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='none';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"13\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\t\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"12\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"22\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"21\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"11\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"41\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n\tif(document.getElementById(\"tipo_doc\").options[document.getElementById(\"tipo_doc\").selectedIndex].value==\"43\"){\r\n\t\tdocument.form1.nombre2.disabled=false;\r\n\t\tdocument.form1.apellido1.disabled=false;\r\n\t\tdocument.form1.apellido2.disabled=false;\r\n\t\tdiv = document.getElementById('primernom');\r\n\t\tdiv.style.display ='';\r\n\t\tdiv2 = document.getElementById('razonso');\r\n\t\tdiv2.style.display ='none';\r\n\t}\r\n}", "title": "" }, { "docid": "98974f60aead34b69c74f2be212b8283", "score": "0.5280966", "text": "constructor() {\n super();\n \n const _fields = [ \n {\n \"type\": \"input\",\n \"id\": \"palindrome\",\n \"label\": \"Palindrome\",\n \"placeholder\": \"Est un palindrome ?\",\n },\n {\n \"type\": \"radio\",\n \"radios\": [\n {\n \"name\": \"case-sensitive\",\n \"label\": \"Sensible aux majuscules et minuscules\", \n \"value\": \"case-sensitive\",\n \"checked\": '',\n \"labelClasses\": \"radio-inline\",\n \"inputClasses\": \"radio-btn-mar-right\"\n },\n {\n \"name\": \"case-sensitive\",\n \"label\": \"Insensible aux majuscules et minuscules\", \n \"value\": \"case-insensitive\",\n \"checked\": 'checked',\n \"labelClasses\": \"radio-inline mar-left-1x\",\n \"inputClasses\": \"radio-btn-mar-right\"\n }\n ]\n },\n {\n \"type\": \"button\",\n \"id\": \"palindrome-execution\",\n \"label\": \"Vérification\",\n \"buttonType\": \"button\"\n }\n ];\n\n this.data = {\n \"title\": \"Détecteur de Palindrome\",\n \"description\": \"Un palindrome est un mot ou une phrase que l'on peut lire de droite à gauche ou de gauche à droite indisctinctement.<br />\" + \n \"Par exemple, le mot 'kayak' se lit 'kayak' de gauche à droite ou de droite à gauche.\",\n \"fields\": _fields,\n };\n }", "title": "" }, { "docid": "1ce119bc5fb28e59850c8932c585bcf0", "score": "0.5280693", "text": "function createProjectOptionsForm() {\n var paragraph = document.createElement(\"p\");\n var form = document.createElement(\"FORM\");\n form.id = 'projectForm';\n var label = createLabel('Checkmarx Project');\n form.appendChild(label);\n var select = document.createElement(\"SELECT\");\n select.id = 'projectSelect';\n select.innerHTML = createOptions();\n form.appendChild(select);\n var errSpan = createErrSpan(form.id);\n paragraph.appendChild(form);\n paragraph.appendChild(errSpan);\n configurationPage.appendChild(paragraph);\n }", "title": "" }, { "docid": "20be14d32efd9085a4ababca22ae20b4", "score": "0.5280659", "text": "function Producto(nombre,precio){\n this.nombre=nombre;\n this.precio=precio;\n this.disponible=true; //Aqui se asignara por default true para la propiedad disponoble\n}", "title": "" }, { "docid": "4a3dfa2e4045e682abd2fc88ef260be8", "score": "0.5280563", "text": "function remplirFormulaire(index) {\n var objetVignette = recupererObjetVignette(index);\n document.getElementById('index').value = objetVignette.index;\n document.getElementById('saisieCrypto').value = objetVignette.crypto;\n document.getElementById('saisieQuantite').value = objetVignette.quantite;\n document.getElementById('saisieCours').value = objetVignette.cours;\n document.getElementById('saisieJour').value = objetVignette.jour;\n document.getElementById('saisieMois').value = objetVignette.mois;\n document.getElementById('saisieAnnee').value = objetVignette.annee;\n}", "title": "" }, { "docid": "5609ae3842bae24692c8d2c0689a1f8a", "score": "0.5279743", "text": "function setFormProjectData(){\n ProjectFormView.getScope().find('input[name=\"pid\"]').val(project['data']['pid']);\n ProjectFormView.getScope().find('input[name=\"name\"]').val(project['data']['name']);\n ProjectFormView.getScope().find('input[name=\"weekload\"]').val(project['data']['weekload']);\n ProjectFormView.getScope().find('input[name=\"maxhours\"]').val(project['data']['maxhours']);\n ProjectFormView.getScope().find('input[name=\"teamSize\"]').val(project['data']['teamSize']);\n ProjectFormView.getScope().find('input[name=\"rangestart\"]').val(project['data']['rangestart']);\n ProjectFormView.getScope().find('input[name=\"rangeend\"]').val(project['data']['rangeend']);\n ProjectFormView.getScope().find('textarea[name=\"description\"]').text(project['data']['description']);\n }", "title": "" }, { "docid": "c8f405c2acd2c9c10c1f5d133f249aaf", "score": "0.52773327", "text": "function editprodukt(li) {\n const form = li.querySelector(\"form\");\n \n if (form.style.display === \"none\") {\n form.style.display = \"block\";\n } else {\n form.style.display = \"none\";\n }\n return false;\n \n}", "title": "" }, { "docid": "88f78a170e7894f80b9da0785b1ca5fe", "score": "0.527709", "text": "function formataCnpj(p_elemento){\n g_obj_data = p_elemento;\n setTimeout(\"executarFormataCnpj()\", 1);\n }", "title": "" }, { "docid": "956ab371f8e7d7a3d38f1ced17011961", "score": "0.5276509", "text": "resetForm() {\n this.objPEVFields = {\n sApplicantName: '',\n iAdultValue: 1,\n iChildrenValue: 0,\n iNoWithIncome: 1,\n sProcessDate: new Date(),\n sReceiveDate: new Date(),\n bRequestedDrop: false,\n bNoAttachment: false,\n sSourceChannelType: '',\n sFormCode: '',\n sCocCode: '',\n sEmail: '',\n iAnnualInc: 0,\n iTotalPersons: 1,\n bOnProbation: false,\n bPevForm: true,\n sApplicationStatus: '',\n bIsAdjustment: false,\n sAdjustReasonValue: '',\n sCcbContactCode: '',\n sCcbContactDesc: '',\n sCcbContactComment: '',\n sProcessNotes: '',\n sLastModifiedById: '',\n sLastModifiedDate: '',\n sQualifiedBy: '',\n sEIAccountName: '',\n sEIAccountId: '',\n sAssignedTo: '',\n bIsSuccess: false\n };\n this.populateCommentsTextArea('');\n this.incomeInfoList = [{\n iIncomeIndex: 0,\n sNumber: 'Per 1',\n sPersonName: '',\n dEstAnnSal: 0,\n sIncSrcStatus: '',\n iNoDocs: 0,\n sId: ''\n }];\n }", "title": "" }, { "docid": "2079e0fe2f5c11d64749ef2b537c3105", "score": "0.5268149", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n cau_codigo: false,\n cau_nome: false,\n };\n this.apiService.formVisible = {\n cau_codigo: true,\n cau_nome: true,\n };\n this.permissaoFieldDisabled('causa_manu');\n this.permissaoFieldVisible('causa_manu');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getcausa_manuId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "8bdc923880ccb683221edc1fdd589bde", "score": "0.52660435", "text": "function _limparCampos(){\n \t\t$scope.senha.novaSenha = \"\";\n\t\t$scope.senha.confirmaNovaSenha = \"\";\n\t\t$scope.senha.senhaAtual = \"\";\n\t\t$scope.painelProfessorFormSenha.$setPristine();\n \t}", "title": "" }, { "docid": "080bed7f4d985ff220ec6d22cd86c3ff", "score": "0.5262565", "text": "function getDataFromForm() {\n const name = document.getElementById(\"nomeCarroInput\").value;\n const plate = document.getElementById(\"placaCarroInput\").value;\n //chama o construtor do carro pra instanciar um objeto carro\n const car = new Car(name, plate);\n show_info(car);\n}", "title": "" }, { "docid": "b7a2daddcdeabeda50d7ab902b7c599e", "score": "0.52582026", "text": "function populateForm(id){\n Pet.show(id).then(petData =>{\n document.querySelector('#edit-pet-form [name=name]').value=petData.name;\n document.querySelector('#edit-pet-form [name=pet_type]').value=petData.pet_type;\n document.querySelector('#edit-pet-form [name=description]').value=petData.description;\n document.querySelector('#edit-pet-form [name=image_url]').value=petData.image_url;\n document.querySelector('#edit-pet-form [name=is_available]').value=petData.is_available;\n document.querySelector('#edit-pet-form [name=id]').value=petData.id\n })\n}", "title": "" }, { "docid": "e988a31c0fe7dcb74cd24bfcad27620b", "score": "0.52510816", "text": "function productHtml(cameraSelect){\n// appel de id \"nameH1\"et remplissage du code html avec la recuperation du nom de l'object recuperé\n document.getElementById(\"nameH1\").innerHTML = cameraSelect.name;\n\n const image1 = document.getElementsByTagName(\"img\")[1];\n image1.setAttribute('src',cameraSelect.imageUrl);\n\n document.getElementById(\"para_id\").innerHTML ='Référence produit: '+cameraSelect._id;\n document.getElementById(\"desc\").innerHTML = cameraSelect.description;\n\n const price = document.querySelector(\".price\");\n price.innerHTML = cameraSelect.price /100+ ',00 €';\n\n //affiche l'option par défaut\n const option = document.createElement('option');\n option.innerHTML =\"Veuillez choisir votre lentille\";\n const selection = document.querySelector(\"#selection\");\n selection.appendChild(option);\n\n //selection de la lentille\n cameraSelect.lenses.forEach(element => {\n let option = document.createElement('option');\n option.setAttribute('value',element);\n option.innerText = element;\n selection.appendChild(option);\n });\n}", "title": "" }, { "docid": "83b4542ab801f3332086fec5732e30c0", "score": "0.5250001", "text": "function Perro (nombre, edad, vivo) {\n this.nombre = nombre; \n this.edad = edad; \n this.vivo = vivo; \n}", "title": "" }, { "docid": "4238acbd827ecd06774e04072da30ce4", "score": "0.52463174", "text": "function populateForm2Js(){\n\t//Primero determinamos el modo en el que estamos;\n\tvar mode = getMMGMode(get('maeCriteBusquFrm.accion'), \n\t\tget('maeCriteBusquFrm.origen'));\n\t\n\tjsMaeCriteBusquId = get('maeCriteBusquFrm.id').toString();\n\tjsMaeCriteBusquPaisOidPais = get('maeCriteBusquFrm.paisOidPais')[0];\n\tjsMaeCriteBusquAtreOidAtriEsp1 = get('maeCriteBusquFrm.atreOidAtriEsp1')[0];\n\tjsMaeCriteBusquAtreOidAtriEsp2 = get('maeCriteBusquFrm.atreOidAtriEsp2')[0];\n\t\n}", "title": "" }, { "docid": "4765caae153dc8172d271ba4f0102b4a", "score": "0.5245501", "text": "function SetTipoProyecto(data)\n{\n var tipoProyecto = new TipoProyecto();\n \n tipoProyecto.TipoProyectoId = data.TipoProyectoId;\n tipoProyecto.Nombre = data.Nombre;\n \n tipoProyecto.Mueble = CambiarDatoEnteroABool(data.Mueble);\n tipoProyecto.CubiertaAglomerado = CambiarDatoEnteroABool(data.CubiertaAglomerado);\n tipoProyecto.CubiertaPiedra = CambiarDatoEnteroABool(data.CubiertaPiedra);\n tipoProyecto.IVA = CambiarDatoEnteroABool(data.IVA);\n tipoProyecto.LibreIVA = CambiarDatoEnteroABool(data.LibreIVA);\n tipoProyecto.Activo = CambiarDatoEnteroABool(data.Activo);\n \n return tipoProyecto;\n}", "title": "" }, { "docid": "63ba5af00567f178d751182aff4c7acd", "score": "0.5245084", "text": "function limpiar_formularioRec() { /* limpia los datos de los formularios */\n //$(\"#campaignRec\").val(\"\");\n //$(\"#baseRec\").val(\"\");\n //$(\"#estatus\").val(\"\");\n //$(\"#asesorRec\").tokenfield('setTokens', [\"\"]);\n //$(\"#asesorRec\").tokenfield('destroy');\n //$(\"#accion\").val(\"Seleccione opción\");\n //$(\"#CantRec\").val(\"\");\n}", "title": "" }, { "docid": "ac2b2590fe7253abb066469c0e142f7c", "score": "0.52445495", "text": "function mostrarPorciones(event) {\n const nombreGusto = event.target.value;\n const nombreGustoPatron = nombreGusto + \"Patron\";\n const mostrar = (nombreGusto != \"Default\") ? true : false;\n\n const IDSelect = obtenerIDdelDesplegable(event);\n const iPizzaSeleccionada = obtenerInfoDeiPizzaSeleccionada();\n \n const ubicacionEnCanvas = iPizzaSeleccionada.porciones[IDSelect].index;\n // Guardo el gusto que selecciono el usuario\n iPizzaSeleccionada.porciones[IDSelect].gusto = (nombreGusto != \"Default\") ? canvasPizza[nombreGustoPatron] : null;\n\n if(mostrar) {\n canvasPizza.dibujarPorciones(iPizzaSeleccionada.cantidadDePorcionesPorGusto, canvasPizza[nombreGustoPatron], ubicacionEnCanvas);\n } else {\n canvasPizza.reDibujarPorciones(iPizzaSeleccionada);\n }\n }", "title": "" }, { "docid": "d93dba63d2646bc8b8ba9b87c0924ab5", "score": "0.52424866", "text": "envoyer(form) {\n return this.candservice.saveCamp(form.value).subscribe(data => {\n alert('nouvelle campagne enregistrée avec succès !');\n console.log(form.value);\n this.getAllCampagnes();\n });\n }", "title": "" }, { "docid": "e3b997cc4a7f7fc34e3b7ebe0229065c", "score": "0.5237612", "text": "ngOnInit() {\n //************************************************ \n //INICIO - PERMISSOES \n this.apiService.formDisabled = {\n fer_ano: false,\n fer_codigo: false,\n fer_data: false,\n fer_nome: false,\n };\n this.apiService.formVisible = {\n fer_ano: true,\n fer_codigo: true,\n fer_data: true,\n fer_nome: true,\n };\n this.permissaoFieldDisabled('feriados');\n this.permissaoFieldVisible('feriados');\n //FIM - PERMISSOES \n //************************************************ \n //VERIFICA SE A ROTA TEM parametro E EDICAO (FAZ LOAD DOS DADOS DO REGISTRO SELECIONADO E ITENS), SENAO E INSERCAO \n let id = this.router.snapshot.paramMap.get('id');\n if (id) {\n this.apiService.getferiadosId(id).subscribe(data => {\n data[0].status_reg = 'U';\n this.apiService.formData = data[0];\n this.apiService.formData.status_reg = 'U';\n });\n }\n else {\n this.resetForm();\n }\n //LOAD DOS ARRAY CHAVE ESTRANGEIRA \n }", "title": "" }, { "docid": "73d92302ca7ac69244530fdf44d81a5c", "score": "0.5224521", "text": "crearPersonaFormulario() {\n this.setState({nuevaPersona: true});\n this.setState({nombres: \"\"});\n this.setState({apellidos: \"\"});\n }", "title": "" }, { "docid": "92837ffe2c488fe559bb98ce589c3a3a", "score": "0.52213436", "text": "function getProductForForm() {\n sl = \"\";\n var productId = $(\"#productDD\").val();\n //var productName = $(\"#productDD option:selected\").text();\n var productCode = $(\"#productCodeTB\").val();\n var manufacturedDate = $(\"#ManufacturedDate\").val();\n var expireDate = $(\"#ExpireDate\").val();\n var quantity = $(\"#Quantity\").val();\n var unitPrice = $(\"#UnitPrice\").val();\n var totalPrice = quantity * unitPrice;\n var newMrp = $(\"#NewMrp\").val();\n var remarks = $(\"#Remarks\").val();\n\n return { '':sl, ProductId: productId, Code: productCode, ManufacturedDate: manufacturedDate, ExpireDate: expireDate, Quantity: quantity, UnitPrice: unitPrice, TotalPrice: totalPrice, NewMrp: newMrp, Remarks: remarks }\n }", "title": "" }, { "docid": "1e7748e9b5f4b7aee824e9144960d72d", "score": "0.5221015", "text": "function cargarProvinciasRegistrarse(objProvinciasRegistrarse){\n \n //alert(objProvinciasRegistrarse);\n for(var i = 0; i < objProvinciasRegistrarse.length; i++){\n \n var objTmpProvinciasRegistrarse = objProvinciasRegistrarse[i];\n $('#provincia').append($('<option>',{\n text : objTmpProvinciasRegistrarse.nombreProvincia\n }));\n \n }\n \n //fin cargarGeneroRegistrarse\n}", "title": "" }, { "docid": "a2c0d3bec9262cc3d831e4688b94c1d4", "score": "0.5220394", "text": "function Ingreso(){\n\n this.inputDate = moment( new Date() ).format( \"YYYY-MM-DD\" );\n this.listaProductos = [];\n this.page = 0;\n this.product = '';\n this.listaProveedores = new Array();\n this.provider = new Object();\n this.storageUbication = new Object();\n this.listaBodegas = new Array();\n this.listaMarcas = new Array();\n this.unit = new Object();\n this.listaUnidades = new Array();\n this.mark = new Object();\n this.tablaProductos = new Array();\n this.invimaCode = new Object();\n this.expiration_date = moment( new Date() ).format( 'YYYY-MM-DD' );\n this.temp_store = undefined;\n this.temperature = undefined;\n this.subtotal_value = 0;\n this.quant_input = 0;\n this.single_value = 0;\n this.iva = 0;\n this.value = 0;\n this.discount = 0;\n this.order_code = 0;\n this.observation = '';\n this.product_details_id = '';\n this.bill_code = '';\n var _this = this;\n \n \n $('[name=fecha_vencimiento]').datepicker({\n format : 'yyyy-mm-dd'\n });\n\n $('[name=fecha_ingreso]').datepicker({\n format : 'yyyy-mm-dd'\n });\n \n \n\n // Obtiene la lista de los productos para el select\n this.obtenerProductos = function( page ){\n\n\n $.get(\n urls.BASE_API+\"/products/getProducts.json\",\n function(data, status){\n \n if( data.success ){\n \n _this.listaProductos = data.products;\n \n }\n\n }\n );\n\n }\n\n this.obtenerProductos();\n\n\n // Vigila el cambio de valor del productos\n this.watch('product', function( id, oldval, newval ){\n \n if( newval != undefined ){\n $('[name=cup]').val( newval.cup );\n $('[name=forma_farmaceutica]').val( newval.farmaseutic_form.name );\n }\n else{\n\n $('[name=cup]').val( '' );\n $('[name=forma_farmaceutica]').val( '' );\n\n }\n return newval;\n \n });\n\n\n // Obtiene la lista de los proveedores\n this.obtenerProveedores = function(){\n l( 'obtenerProveedores();' );\n providersService.getProviders( function( success ){\n\n _this.listaProveedores = success.provider;\n\n }, \n function( error ){\n\n l('obtenerProveedores()-Error');\n l( error );\n\n } );\n\n }\n this.obtenerProveedores();\n\n\n // Obtiene la lista de bodegas\n this.obtenerBodegas = function(){\n\n storageUbicationsService.getAllStorage(\n\n function( success ){\n\n _this.listaBodegas = success.storage;\n\n },\n function( error ){\n \n l( 'obtenerBodegas()--error' );\n l( error );\n\n }\n\n );\n\n }\n\n this.obtenerBodegas();\n\n\n // Obtiene la lista de marcas\n this.obtenerMarcas = function(){\n\n marksService.getAllMarks(\n \n function( success ){\n\n _this.listaMarcas = success.mark;\n\n },\n function( error ){\n\n l( 'obtenerMarcas()-error' );\n l(error);\n\n }\n \n );\n\n }\n\n this.obtenerMarcas();\n\n // Obtiene la lista de las unidades de medida\n this.obtenerUnidades = function(){\n\n unitsService.getAllUnits(\n\n function( success ){\n\n _this.listaUnidades = success.units;\n\n },\n function( error ){\n\n l( 'obtenerUnidades()-error' );\n l( error );\n\n }\n\n );\n\n }\n this.obtenerUnidades();\n\n // Obtiene un codigo invima de un producto\n this.obtenerCodigosInvima = function(){\n\n invimaCodesService.getInvimaByProduc(\n {\n id : _this.product.id\n },\n function( success ){\n\n if( success.success ){\n _this.invimaCode = success.invimaCode[0];\n }\n else{\n\n _this.invimaCode = {};\n _this.invimaCode.id = false;\n\n }\n\n },\n function( error ){\n\n l( 'obtenerCodigosInvima()-error' );\n l( error );\n\n }\n );\n\n }\n\n\n // Obtiene la lista de los productos ya paginados\n var obtenerProductosPaginados = function( page ){\n \n $.get(\n urls.BASE_API+\"/StorageInputs/productReasume/\"+page+\".json\",\n function(data, status){\n\n if( data.success && data.List.length > 0 ){\n\n \n _this.tablaProductos = data.List;\n\n }else{\n\n _this.page--;\n\n }\n\n }\n )\n\n }\n\n obtenerProductosPaginados();\n\n // Pagina los resultados \n this.watch( 'page', function( id, oldval, newval ){\n \n if( newval >= 0 ){\n obtenerProductosPaginados( newval );\n return newval;\n }\n\n } );\n\n // Añade un codigo invima\n var adicionarInvimacode = function(){\n\n invimaCodesService.add(\n {\n code : _this.invimaCode.code\n },\n function( success ){\n\n _this.invimaCode = success.resultado;\n\n },\n function( error ){\n\n }\n\n );\n\n }\n\n var validarFormulario = function( name, longitud ){\n\n l( 'validarFormulario()' );\n\n var formulario = document.forms[ name ] ;\n var valido = true;\n \n for( var index in formulario ){\n\n\n if( ! isNaN( parseInt( index ) ) ){\n \n if( formulario[ index ].checkValidity() == false ){\n\n $( formulario[ index ] ).css( 'box-shadow', '0px 0px 3px red' );\n valido = false;\n\n }\n else{\n\n $( formulario[ index ] ).css( 'box-shadow', 'none' );\n\n }\n\n }\n else{\n\n break;\n }\n \n }\n\n\n\n return valido; \n\n }\n\n // Inserta los datos en la tabla product_details\n var adicionarDetallesProducto = function(){\n l( 'adicionarDetallesProducto();' );\n var data = {\n expiration_date : _this.expiration_date,\n lot : _this.lot,\n temperature : _this.temperature,\n temp_store : _this.temp_store,\n order_code : _this.order_code,\n products_id : _this.product.id,\n providers_id : _this.provider.id,\n marks_id : _this.mark,\n units_id : _this.unit,\n invima_codes_id : _this.invimaCode.id,\n total : $('[name=total]').val()\n };\n\n productsService.addProductDetails(\n data,\n function( success ){\n\n _this.product_details_id = success.productDetails.id;\n\n },\n function( error ){\n l('adicionarDetallesProducto()-error');\n }\n );\n\n\n }\n\n\n // Inserta en la tabla storage_inputs\n var adicionarIngresosBodega = function(){\n l( 'adicionarIngresosBodega()' );\n \n\n var data = {\n quant_input : _this.quant_input,\n remaining : _this.quant_input,\n observations : _this.observation,\n single_value : _this.single_value,\n value : _this.value,\n bill_code : _this.bill_code,\n state : 1,\n inputDate : _this.inputDate,\n iva : _this.iva,\n subtotal_value : _this.subtotal_value,\n storage_ubications_id : _this.storageUbication,\n product_details_id : _this.product.id,\n discount : _this.discount \n };\n\n StorageInputsService.addInputs(\n data,\n function( success ){\n $('#save-modal').modal('show');\n $('[name=\"person-name\"]').html( $localStorage.person.first_name+\" \"+$localStorage.person.middle_name+\" \"+$localStorage.person.last_name+\" \"+$localStorage.person.last_name_two+\" \" );\n if( success.success ){\n\n $('[name=\"save-message\"\"]').html( 'Se almacenó satisfactoriamente' );\n document.querySelector('[name=\"registro-producto\"]').reset();\n\n }else{\n\n $('[name=\"save-message\"\"]').html( 'No se almacenó la información' );\n\n }\n\n setTimeout(function(){\n\n $('#save-modal').modal('hide');\n\n },3500);\n\n },\n function( error ){\n l( 'adicionarIngresosBodega()-error' );\n l( error );\n\n }\n );\n\n }\n\n // Registra la entrada de un producto a una bodega\n this.registrar = function(){\n \n if( validarFormulario('registro-producto') == true ){\n \n adicionarDetallesProducto();\n adicionarIngresosBodega();\n obtenerProductosPaginados( 0 );\n\n }\n }\n\n // Calcula el iva UNITARIO a partir del valor ingresado\n this.calculateIva = function(){\n l('IVA UNITARIO');\n if( _this.iva.indexOf('%') != -1 ){\n\n var newval = _this.iva.match(/\\d/g);\n _this.iva = \"0.\"+Math.abs( parseInt( newval.join(\"\") ) );\n _this.iva = parseFloat( _this.iva );\n _this.iva = _this.single_value*_this.iva;\n\n }\n else{\n\n _this.iva = _this.iva / _this.quant_input;\n\n }\n\n _this.iva.toFixed( 4 );\n _this.value = (_this.iva * _this.quant_input) + ( _this.subtotal_value - _this.discount );\n \n\n }\n\n }", "title": "" }, { "docid": "192deed0489149f0a29e54922896440c", "score": "0.5216769", "text": "function crearFormularioCaja(){\n return`<form id=\"formulario\">\n <label>Cadena:</label><br>\n <textarea id=\"cadena\" rows=\"7\" cols=\"50\" name=\"description\" value=\"\"></textarea><br><br>\n <label>Tamaño de la fuente (em)</label>\n <select id=\"size\">\n <option value=\"xx-small\">xx-small</option>\n <option value=\"x-small\">x-small</option>\n <option value=\"small\">small</option>\n <option value=\"medium\">medium</option>\n <option value=\"large\">large</option>\n <option value=\"x-large\">x-large</option>\n <option value=\"xx-large\">xx-large</option>\n </select><br><br>\n <label>Tipo de fuente</label>\n <select id=\"tipo\">\n <option value=\"b\">Bold</option>\n <option value=\"strong\">Importante</option>\n <option value=\"i\">Italic</option>\n <option value=\"em\">Emphasized</option>\n <option value=\"mark\">Marked</option>\n <option value=\"small\">Small</option>\n <option value=\"del\">Deleted</option>\n <option value=\"ins\">Inserted</option>\n <option value=\"sub\">Subscript</option>\n <option value=\"sup\">Superscript</option>\n </select><br><br>\n <label>Alineación del texto</label>\n <select id=\"alig\">\n <option value=\"left\">Izquierda</option>\n <option value=\"center\">Centro</option>\n <option value=\"right\">Derecha</option>\n <option value=\"justify\">Justificado</option>\n </select><br><br>\n <label>Decoración del texto</label>\n <select id=\"decoracion\">\n <option value=\"none\">Normal</option>\n <option value=\"overline\">Overline</option>\n <option value=\"line-through\">Line-through</option>\n <option value=\"underline\">Underline</option>\n </select><br><br>\n <label>Color del texto</label>\n <input id=\"color\" type=\"color\" name=\"favcolor\" value=\"#000000\"><br><br>\n <label>Background-color: </label>\n <input id=\"bcolor\" type=\"color\" name=\"favcolor\" value=\"#ffffff\"><br><br>\n <label>Borde (en px)</label>\n <input class=\"form-control\" type=\"number\" max=\"10\" min=\"0\" id=\"borde\"><br><br>\n <label>Tipo de borde</label>\n <select id=\"btipo\">\n <option value=\"none\">none</option>\n <option value=\"dotted\">dotted</option>\n <option value=\"dashed\">dashed</option>\n <option value=\"solid\">solid</option>\n <option value=\"double\">double</option>\n </select><br>\n <label>Color del borde: </label>\n <input id=\"bocolor\" type=\"color\" name=\"favcolor\" value=\"#000000\"><br><br>\n <input class=\"btn btn-success\" id=\"Enviar\" type=\"submit\" value=\"Enviar\" /><br>\n <input class=\"btn btn-danger\" id=\"Cancelar\" type=\"button\" value=\"Cancelar\" /><br><br>\n </form>`;\n}", "title": "" }, { "docid": "f58b70a6530ddb156d969fbfd0c05707", "score": "0.5213487", "text": "function cambioDatosPersonalesEmpresa() {\n var formPersona = $('#datosPersonalesForm');\n var formEmpresa = $('#datosEmpresaForm');\n formEmpresa.find('#fechaNacimiento2').val(formPersona.find('#fechaNacimiento').val());\n formEmpresa.find('#cp2').val(formPersona.find('#cp').val());\n var state = formPersona.find('#provincia').val();\n changeCustomSelect(formEmpresa.find('#select-ul-provincia li[v=' + state + ']'), formEmpresa);\n if (formPersona.find('#radio_r_men').hasClass('active')) {\n formEmpresa.find('#radio_r_men2').click();\n } else {\n formEmpresa.find('#radio_r_women2').click();\n }\n\n formEmpresa.find('#nombre').val(formPersona.find('#nombre').val());\n formEmpresa.find('#apellido').val(formPersona.find('#apellido').val());\n formEmpresa.find('#direccion').val(formPersona.find('#direccion').val());\n formEmpresa.find('#direccion2').val(formPersona.find('#direccion2').val());\n formEmpresa.find('#localidad').val(formPersona.find('#localidad').val());\n\n formEmpresa.find('#prefijo').val(formPersona.find('#prefijo').val());\n formEmpresa.find('#telefono').val(formPersona.find('#telefono').val());\n\n\n formEmpresa.find('#prefijo2').val(formPersona.find('#prefijo2').val());\n formEmpresa.find('#telefono2').val(formPersona.find('#telefono2').val());\n\n $(\"#datosPersonalesDiv\").hide();\n $(\"#datosEmpresaDiv\").show();\n}", "title": "" }, { "docid": "767535c531dba3bc00868b4d16454404", "score": "0.52128613", "text": "function telaReimpressaoDeComprovanteVenda() {\r\n const situacao = autenticacaoLogin()\r\n\r\n if (\r\n JSON.parse(situacao).tipo == 'Administrador'\r\n ) {\r\n let codigoHTML = ''\r\n\r\n codigoHTML += '<h3 class=\"text-center\">2ª Via Comprovante</h3>'\r\n\r\n codigoHTML +=\r\n '<div class=\"card-deck col-6 mx-auto d-block\" style=\"margin-top:30px;\">'\r\n codigoHTML += '<form>'\r\n codigoHTML += '<div class=\"form-row\">'\r\n codigoHTML += '<div class=\"form-group col-md-12\">'\r\n codigoHTML += '<label for=\"nome\">Código ID:</label>'\r\n codigoHTML +=\r\n '<input type=\"text\" class=\"form-control mousetrap\" id=\"codigo\" placeholder=\"Código ID\">'\r\n codigoHTML += '</div>'\r\n codigoHTML += '</div>'\r\n codigoHTML += '<div class=\"form-row\">'\r\n codigoHTML +=\r\n '<button onclick=\"if(validaDadosCampo([\\'#codigo\\'])){gerarSegundaViaComprovante(document.getElementById(\\'codigo\\').value)}else{mensagemDeErro(\\'Preencha o campo código!\\'); mostrarCamposIncorreto([\\'codigo\\'])}\" type=\"button\" class=\"btn btn-success\" style=\"margin: 5px;\"><span class=\"fas fa-file-pdf\"></span> Gerar</button>'\r\n codigoHTML += '</div>'\r\n codigoHTML += '</form>'\r\n codigoHTML += '</div>'\r\n\r\n document.getElementById('janela2').innerHTML = codigoHTML\r\n } else {\r\n mensagemDeErro('Usuário não autorizado!')\r\n }\r\n}", "title": "" } ]
299643ffd83b73c0909ddcb78d56cbd4
6.1.1 The Undefined Type
[ { "docid": "774d4de20ba9127c9b16c07e9d933538", "score": "0.0", "text": "function IsUndefined(x) {\n return x === undefined;\n }", "title": "" } ]
[ { "docid": "81c541e6990cd958f3b9e973f0acde0b", "score": "0.69588387", "text": "function returnUndefined() {}", "title": "" }, { "docid": "9b03419c5c1e278df214b2f6e3fa66c5", "score": "0.69215465", "text": "function NilClass(){}", "title": "" }, { "docid": "9b03419c5c1e278df214b2f6e3fa66c5", "score": "0.69215465", "text": "function NilClass(){}", "title": "" }, { "docid": "07add542ba97bd233ebfe6e2c38e87ac", "score": "0.6711663", "text": "function undefinedType(type, explicit) {\n\t\treturn type + (explicit ? '' : '|[a-z]+');\n\t}", "title": "" }, { "docid": "a27744052152b5be3b7e46740b7bacb3", "score": "0.6664881", "text": "function isUndef(e){return void 0===e||null===e}", "title": "" }, { "docid": "c38ecc50b31d234ad2755bc2ddccd706", "score": "0.65252", "text": "static isUndefined(value) { return typeof value === 'undefined'; }", "title": "" }, { "docid": "c38ecc50b31d234ad2755bc2ddccd706", "score": "0.65252", "text": "static isUndefined(value) { return typeof value === 'undefined'; }", "title": "" }, { "docid": "383d27698b3a6dd09190710cdab4d663", "score": "0.64665145", "text": "function isUndefined(){\n return;\n}", "title": "" }, { "docid": "d87324705a41642f8c64252290918e78", "score": "0.6464622", "text": "function isUndef(v){return v===undefined||v===null;}", "title": "" }, { "docid": "d87324705a41642f8c64252290918e78", "score": "0.6464622", "text": "function isUndef(v){return v===undefined||v===null;}", "title": "" }, { "docid": "d87324705a41642f8c64252290918e78", "score": "0.6464622", "text": "function isUndef(v){return v===undefined||v===null;}", "title": "" }, { "docid": "d87324705a41642f8c64252290918e78", "score": "0.6464622", "text": "function isUndef(v){return v===undefined||v===null;}", "title": "" }, { "docid": "d87324705a41642f8c64252290918e78", "score": "0.6464622", "text": "function isUndef(v){return v===undefined||v===null;}", "title": "" }, { "docid": "d87324705a41642f8c64252290918e78", "score": "0.6464622", "text": "function isUndef(v){return v===undefined||v===null;}", "title": "" }, { "docid": "d231bf633eb1d94fe5e0f6db04f0fa94", "score": "0.6421641", "text": "static isUndefined(value) {\n return typeof value === \"undefined\";\n }", "title": "" }, { "docid": "e7cab6d95126e3c3eb136a9f00b801d5", "score": "0.64106953", "text": "function isUnDef(v){\n return v !== null && v === undefined;\n }", "title": "" }, { "docid": "8af4cd0784c68c5a15e2db611f4011aa", "score": "0.63819396", "text": "function isUndefined(o) {\n return typeof o === 'undefined';\n }", "title": "" }, { "docid": "def7813abe79d39390b5075f5f4aaa18", "score": "0.6361", "text": "function defined(obj){return typeof obj!=='undefined';}", "title": "" }, { "docid": "def7813abe79d39390b5075f5f4aaa18", "score": "0.6361", "text": "function defined(obj){return typeof obj!=='undefined';}", "title": "" }, { "docid": "fbc35432fb0cdf82c5dd06f6e0e6c789", "score": "0.63374513", "text": "function returnUndefined() {\n // this will return undefined\n }", "title": "" }, { "docid": "c78fcd9adc6bd072bdf688bfc7e93268", "score": "0.6327624", "text": "function isUndefined(o) {\n return typeof o === \"undefined\";\n}", "title": "" }, { "docid": "c78fcd9adc6bd072bdf688bfc7e93268", "score": "0.6327624", "text": "function isUndefined(o) {\n return typeof o === \"undefined\";\n}", "title": "" }, { "docid": "c78fcd9adc6bd072bdf688bfc7e93268", "score": "0.6327624", "text": "function isUndefined(o) {\n return typeof o === \"undefined\";\n}", "title": "" }, { "docid": "c78fcd9adc6bd072bdf688bfc7e93268", "score": "0.6327624", "text": "function isUndefined(o) {\n return typeof o === \"undefined\";\n}", "title": "" }, { "docid": "c78fcd9adc6bd072bdf688bfc7e93268", "score": "0.6327624", "text": "function isUndefined(o) {\n return typeof o === \"undefined\";\n}", "title": "" }, { "docid": "299ad6efb0bee929d3662200bb654346", "score": "0.6312428", "text": "function isDef(v) \t\t\t{ return v !== undefined; }", "title": "" }, { "docid": "a5150225ddb103536b4864612896dafe", "score": "0.6301411", "text": "function isUndefined(o) {\n return typeof o === 'undefined';\n}", "title": "" }, { "docid": "0180b651166b223e7facf61e6a817912", "score": "0.62884754", "text": "function Nil() { }", "title": "" }, { "docid": "e830e7e3a2e7947a0cafdbc4614e71f8", "score": "0.6276785", "text": "function _undefinedCoerce() {\n return '';\n}", "title": "" }, { "docid": "8e97288ad7d66474b702c86cf68dbbd8", "score": "0.6261023", "text": "function isUndefined(o) {\n return typeof o === 'undefined';\n}", "title": "" }, { "docid": "04d899f2536e957ef0e698acc658f61c", "score": "0.6247567", "text": "function undefinedValue () {\n try {\n a\n } catch (e) {\n if (e instanceof ReferenceError) {\n return \"not defined\";\n }\n }\n }", "title": "" }, { "docid": "f0e6f9d63588150cd7c2d91539edc62d", "score": "0.62325543", "text": "function isUndefined(v) {\n return typeof v === 'undefined';\n }", "title": "" }, { "docid": "5aba7658b1129ede0b03093f4e0c12ec", "score": "0.6222929", "text": "function _undefined() {\n return exports.PREFIX.undefined;\n}", "title": "" }, { "docid": "a3ac88cc4b5b21bd1e689dcc110ff940", "score": "0.6219528", "text": "function isUndefined(obj) {\r\n return typeof (obj) === 'undefined';\r\n }", "title": "" }, { "docid": "3783007fdf2a7d0fe904930825a9c9c7", "score": "0.62131625", "text": "function isUndefined(object) {\n return typeof object === \"undefined\";\n }", "title": "" }, { "docid": "a5037df3c47046fc89bbfc1a52a25c89", "score": "0.6211238", "text": "function isUndefined(value) {\n return typeof value === \"undefined\";\n }", "title": "" }, { "docid": "8718b645da36fb50086d3a51c30f7e28", "score": "0.62099093", "text": "function isUndefined(value) {\n return typeof value == 'undefined';\n }", "title": "" }, { "docid": "e382992da6875f25717940be0025dcb8", "score": "0.6149099", "text": "isNotDefined(value) {\n\t\tif ((value !== null && typeof value !== 'undefined') || (value && value.hasOwnProperty('length') && value.length > 0))\n\t\t\tthrow new Error(\"expected to be undefined or null: \" + value + \" => \" + typeof value);\n\t}", "title": "" }, { "docid": "142d7e2ada91570a099a4b1b1c5e5541", "score": "0.61442065", "text": "function isUndefined(obj) {\n return typeof obj === 'undefined';\n }", "title": "" }, { "docid": "79392c08769f7c3281537ca41c6b4ea7", "score": "0.61440337", "text": "function isUndefined( value ) {\n return typeof value == 'undefined';\n }", "title": "" }, { "docid": "9c8f37b5d965d7606428882659e20f46", "score": "0.611672", "text": "function TypeUnknown() {\n\tType.call( this, DATA.ATTRIBUTE_TYPE.unknown );\n}", "title": "" }, { "docid": "a74d4a40a413eee9e274e7308ea8f712", "score": "0.6114121", "text": "function undefined_() {\n return raw(new Uint8Array([(7 /* SimpleValue */ << 5) + 23]));\n}", "title": "" }, { "docid": "5938aa1e6017a74a9d03aef2e2254ef4", "score": "0.61135876", "text": "function isUndef( val ) { return val === void 0; }", "title": "" }, { "docid": "acbfd0646827914cd3ebac1ae1f90419", "score": "0.6105119", "text": "function isUndefined( value ){\n\t\treturn typeof value === 'undefined';\n\t}", "title": "" }, { "docid": "98481f554a5693eb7b72dc57d7914f77", "score": "0.6085607", "text": "function displayType(data) {\n return (typeof data === 'undefined')? \"undefined\" : (typeMap[data.constructor.name] || \"unknown type\");\n}", "title": "" }, { "docid": "a55d66e128d74287779f4ff61f29f19d", "score": "0.60798556", "text": "function isUndef (v) {\n\t return v === undefined || v === null\n\t}", "title": "" }, { "docid": "a55d66e128d74287779f4ff61f29f19d", "score": "0.60798556", "text": "function isUndef (v) {\n\t return v === undefined || v === null\n\t}", "title": "" }, { "docid": "1a832e8bcbe762db7ea861e6600c4012", "score": "0.6065955", "text": "function ObjectisUndefined(object) {\n return typeof object == \"undefined\";\n}", "title": "" }, { "docid": "cb7a4461777e5fc70664989da27ffb1f", "score": "0.60539573", "text": "function defined(obj) {\n return typeof obj !== 'undefined';\n }", "title": "" }, { "docid": "cb7a4461777e5fc70664989da27ffb1f", "score": "0.60539573", "text": "function defined(obj) {\n return typeof obj !== 'undefined';\n }", "title": "" }, { "docid": "cbe22c1f58f7f57826393ffc0a026a28", "score": "0.6041593", "text": "function isUndefined$1(value) {\n\t return typeof value === \"undefined\";\n\t}", "title": "" }, { "docid": "0075fdc88daa4dda86c91ab27d23ae5b", "score": "0.6030742", "text": "function isUndefined (data) {\n\t return data === undefined;\n\t }", "title": "" }, { "docid": "34bf663e4412d4970aa7e08856d269dc", "score": "0.6025136", "text": "function isUndefined(value) {\n return ofType(typeof(undefined), value);\n }", "title": "" }, { "docid": "83768b3049b56052ce856dbebe68b0d7", "score": "0.6024017", "text": "function isUndef(val) {\n\t return val === void 0;\n\t }", "title": "" }, { "docid": "83768b3049b56052ce856dbebe68b0d7", "score": "0.6024017", "text": "function isUndef(val) {\n\t return val === void 0;\n\t }", "title": "" }, { "docid": "00f34cb2ad8c540bcffaf05f16abf3a8", "score": "0.60100716", "text": "function exists(type) {\r\n if (type == \"undefined\")\r\n return false;\r\n return true;\r\n}", "title": "" }, { "docid": "321ac677dbde7b339a1ed38574ed8e4d", "score": "0.59960157", "text": "function isUndef(arg) {\n return typeof arg === \"undefined\";\n}", "title": "" }, { "docid": "321ac677dbde7b339a1ed38574ed8e4d", "score": "0.59960157", "text": "function isUndef(arg) {\n return typeof arg === \"undefined\";\n}", "title": "" }, { "docid": "8863b18b0aef5b7a0c4cd440b9566485", "score": "0.59940994", "text": "function isUndefined ( value ) {\n\treturn ( typeof ( value ) === String ( undefined ) );\n}", "title": "" }, { "docid": "742ad79c77e4578efbb82f2dda26c17d", "score": "0.59773725", "text": "function isUndefined(obj) {\n return (typeof obj) === 'undefined';\n}", "title": "" }, { "docid": "ac3c54d8d5693ce9eee1fa5143735172", "score": "0.597623", "text": "function isUndef(v) {\n return v === undefined || v === null;\n }", "title": "" }, { "docid": "c9d70aa5d26ab26878e5df057a8958bd", "score": "0.59716153", "text": "static get Void() { return new Type(TypeKind.Void); }", "title": "" }, { "docid": "747b62a5aa742978a86d541fb77222c0", "score": "0.59707403", "text": "function isUndefined(arg) {\n\treturn (typeof arg === 'undefined');\t\t \t\n}", "title": "" }, { "docid": "6088b74be43a74ba627b91d3fdec1487", "score": "0.5967557", "text": "function isUndef(arg) {\n return typeof arg === \"undefined\";\n}", "title": "" }, { "docid": "b4629ba0e1dee95bb976d6f5e33d8083", "score": "0.5963497", "text": "function isUndefined(obj) {\n return obj === void 0;\n }", "title": "" }, { "docid": "b4629ba0e1dee95bb976d6f5e33d8083", "score": "0.5963497", "text": "function isUndefined(obj) {\n return obj === void 0;\n }", "title": "" }, { "docid": "b4629ba0e1dee95bb976d6f5e33d8083", "score": "0.5963497", "text": "function isUndefined(obj) {\n return obj === void 0;\n }", "title": "" }, { "docid": "b4629ba0e1dee95bb976d6f5e33d8083", "score": "0.5963497", "text": "function isUndefined(obj) {\n return obj === void 0;\n }", "title": "" }, { "docid": "b4629ba0e1dee95bb976d6f5e33d8083", "score": "0.5963497", "text": "function isUndefined(obj) {\n return obj === void 0;\n }", "title": "" }, { "docid": "b4629ba0e1dee95bb976d6f5e33d8083", "score": "0.5963497", "text": "function isUndefined(obj) {\n return obj === void 0;\n }", "title": "" }, { "docid": "b4629ba0e1dee95bb976d6f5e33d8083", "score": "0.5963497", "text": "function isUndefined(obj) {\n return obj === void 0;\n }", "title": "" }, { "docid": "c8a087403ba0eaaf8e28e83fc072d8f6", "score": "0.595664", "text": "function isUndef (v) {\n return v === undefined || v === null\n }", "title": "" }, { "docid": "c8a087403ba0eaaf8e28e83fc072d8f6", "score": "0.595664", "text": "function isUndef (v) {\n return v === undefined || v === null\n }", "title": "" }, { "docid": "c8a087403ba0eaaf8e28e83fc072d8f6", "score": "0.595664", "text": "function isUndef (v) {\n return v === undefined || v === null\n }", "title": "" }, { "docid": "c8a087403ba0eaaf8e28e83fc072d8f6", "score": "0.595664", "text": "function isUndef (v) {\n return v === undefined || v === null\n }", "title": "" }, { "docid": "c8a087403ba0eaaf8e28e83fc072d8f6", "score": "0.595664", "text": "function isUndef (v) {\n return v === undefined || v === null\n }", "title": "" }, { "docid": "c8a087403ba0eaaf8e28e83fc072d8f6", "score": "0.595664", "text": "function isUndef (v) {\n return v === undefined || v === null\n }", "title": "" }, { "docid": "db5b1e256c9eadd2c991f07c3c58e9c7", "score": "0.5955084", "text": "function Z(t){return null!==t&&\"object\"==typeof t}", "title": "" }, { "docid": "49534620b174ddcc23bfaf7783fa2367", "score": "0.5949481", "text": "function isNotDefined(v) {\r\n return v === null || typeof v === 'undefined';\r\n }", "title": "" }, { "docid": "de2796fce4cd6b7509f199e062d5a96f", "score": "0.59423614", "text": "function isUndefined(value) {\n return typeof value === 'undefined';\n}", "title": "" }, { "docid": "6b528615cfd2f44d6b82e1b991fbbc72", "score": "0.59324056", "text": "function findTypesLikeUndefined(doclets) {\n undefinedLikes = ['undefined']; // include type 'undefined' explicitly\n for (var i = doclets.length - 1; i >= 0; --i) {\n var doclet = doclets[i];\n if(doclet.kind === 'typedef') {\n var types = doclet.type.names;\n if (types.indexOf('undefined') !== -1) {\n // the typedef contains 'undefined', so it self is undefinedLike.\n undefinedLikes.push(doclet.longname);\n }\n }\n }\n}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "7023de69b64ddf2084bf987922fd6f80", "score": "0.59303415", "text": "function i(e){return void 0===e||null===e}", "title": "" }, { "docid": "ce933cd03416832e21519d71b0484c23", "score": "0.5927159", "text": "get UNKNOWN() {}", "title": "" }, { "docid": "d527d8d29aca8f4640ca305e03ec4224", "score": "0.5923617", "text": "function isNotUndefined(arg) {\n\treturn !isUndefined(arg);\n}", "title": "" }, { "docid": "163b0252e48012255187a1dd8a6d2029", "score": "0.59163547", "text": "static isUndefined (input) {\n return input == undefined\n }", "title": "" }, { "docid": "b909fa0e52048a1dc6accfb6f35cd93e", "score": "0.5903138", "text": "function isUndef (v) {\r\n return v === undefined || v === null\r\n}", "title": "" }, { "docid": "b909fa0e52048a1dc6accfb6f35cd93e", "score": "0.5903138", "text": "function isUndef (v) {\r\n return v === undefined || v === null\r\n}", "title": "" }, { "docid": "80613dbcad45626d81ae77baae9dad71", "score": "0.59007967", "text": "function isUndef(v) {\n return v === undefined || v === null\n }", "title": "" }, { "docid": "869c61b0d2335790b9ac231679b0f5b2", "score": "0.5896754", "text": "function isUndefined(obj) {\r\n return obj === void 0;\r\n }", "title": "" }, { "docid": "d27f7d7661b4c8e4d9321080a305f6ac", "score": "0.58899003", "text": "get typeDefault()\n {\n return 0;\n }", "title": "" }, { "docid": "4e1311c3ce86d9b356f1eaf164ad9f5b", "score": "0.58846736", "text": "function defined(obj) {\n return typeof obj !== 'undefined';\n }", "title": "" }, { "docid": "4e1311c3ce86d9b356f1eaf164ad9f5b", "score": "0.58846736", "text": "function defined(obj) {\n return typeof obj !== 'undefined';\n }", "title": "" }, { "docid": "cc3f1c1ebb60f0ef0c64c8f6e026b595", "score": "0.58831424", "text": "function IsUndefined(x) {\n\t return x === undefined;\n\t }", "title": "" }, { "docid": "796cf0393fe3e60ca0f3c54778306b36", "score": "0.5881035", "text": "checkForUnknownType(node, type)\n {\n if (!this.getClassDef(type) &&\n !this.getProtocolDef(type) &&\n !this.getTypeDef(type) &&\n !predefinedTypes.has(type))\n {\n let message = `unknown type '${type}'`;\n\n const possibleName = this.findMisspelledName(type);\n\n if (possibleName)\n message += `; did you mean '${possibleName}'?`;\n\n this.addWarning(node, message);\n }\n }", "title": "" } ]
0b3a47630c157a008cc42f9549b1a4de
! vuerouter v3.0.2 (c) 2018 Evan You
[ { "docid": "3a1bca8591b416d8a0534b630a3da51a", "score": "0.0", "text": "function r(t,e){0}", "title": "" } ]
[ { "docid": "cb1f24eda47b3887692062155f72c823", "score": "0.609432", "text": "function vr(){}", "title": "" }, { "docid": "4f1b399154edaf560218b25a2834fdc3", "score": "0.6066595", "text": "function __b_aPxD_aAgzT_aoP7hbI6qzoA(){}", "title": "" }, { "docid": "72148348f3c9fc01fea10d1f8cbd4c7b", "score": "0.60565716", "text": "function _3RhvcSQcujmOU5OTLoz_bAw(){}", "title": "" }, { "docid": "f7137ffc8b0bae68104fc80452a6776c", "score": "0.5969516", "text": "function _5wzrP2I6Vj2DJL7jzmH7UA(){}", "title": "" }, { "docid": "389cc635b45d83e8c46f9a56664fd2bb", "score": "0.58509743", "text": "function ZL(e,t,r,n,s,o,i,a){var c=(\"function\"===typeof r?r.options:r)||{};return c.__file=\"source.vue\",c.render||(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,s&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "b7084992218bc4aa6aadb80055d427e6", "score": "0.5820282", "text": "function _4Xmw8hHFnzuUOt7IaRLq5g() {}", "title": "" }, { "docid": "46d5b421a3f263f051d4f224a73e9936", "score": "0.5798086", "text": "function yFUu8VEDUzGdSSSuDXxzRw(){}", "title": "" }, { "docid": "c3f82fa28e763a160d6d9d4e70ded284", "score": "0.57975715", "text": "function KM(e,t,r,n,s,o,i,a){var c=(\"function\"===typeof r?r.options:r)||{};return c.__file=\"source.vue\",c.render||(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,s&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "ab28b72e23ba4abd20e7872061ba972a", "score": "0.57740325", "text": "onVastReady() {}", "title": "" }, { "docid": "c19081c85ee5e9a2ee07531ac3c8c6f4", "score": "0.57353866", "text": "function kg(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"source.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "498aa23a0c50eb0ad3db5177e551f64d", "score": "0.57134485", "text": "dvr() {\n\n }", "title": "" }, { "docid": "443a4e8241f3ecb23c648894b4261ed7", "score": "0.5675379", "text": "function Di3A8FBIvzOP0yiHovphNQ(){}", "title": "" }, { "docid": "0209a2a31da02094f88999184017ad0f", "score": "0.5654472", "text": "function Wg(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"source.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "604543934f5fbc4d9a17d81775e2e48a", "score": "0.5630687", "text": "function JO(t,e,n,i,r,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"source.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=i,u}", "title": "" }, { "docid": "548f46587d6c081b69fd414afd18c3a5", "score": "0.56051964", "text": "function CuiBJb0tGju_bjvSOrtaPxw(){}", "title": "" }, { "docid": "5d5a5f1710d259d9ffacba41ea29fd3b", "score": "0.5598354", "text": "function d6GxjiFzuj6fvDIOQUJw3g(){}", "title": "" }, { "docid": "94e77804f6ce0d6c2c273a998d910c8f", "score": "0.5588285", "text": "function Zk(t,e,i,n,r,o,s,a){var c=(\"function\"===typeof i?i.options:i)||{};return c.__file=\"source.vue\",c.render||(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "cf89e8f47601da82a1ae1df823f6cd26", "score": "0.55747604", "text": "function Hp(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"source.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "f108477ad12c9b53964781a5d2ecc54a", "score": "0.5558994", "text": "function yF(t,e,i,n,r,o,s,a){var c=(\"function\"===typeof i?i.options:i)||{};return c.__file=\"source.vue\",c.render||(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "754d9ba96f328f849728df6789482bd0", "score": "0.5538276", "text": "function HApm8NWjVjKNbQVa1DQvlA(){}", "title": "" }, { "docid": "2f96026683b6b9271ef4feefbd69872c", "score": "0.55279934", "text": "function vsaOF9fzPDy1qf1UmOyQUQ(){}", "title": "" }, { "docid": "453590f416f6ca0b8b269e834a16236c", "score": "0.55275196", "text": "function _72a4Z_bbNkT6_bTngQiji06g() {}", "title": "" }, { "docid": "cc93fda6e9ad8cc897427b9884256c08", "score": "0.5513413", "text": "function Tq_aQrwWh_bD_aBOiNIUcEaAg(){}", "title": "" }, { "docid": "cea499dc3aaedb0a9367dcfbe002cc75", "score": "0.5510496", "text": "function PuOVUxoA0DGnMJJYXJ28Ww(){}", "title": "" }, { "docid": "16a944f790c32f9f4c8e8c3786556751", "score": "0.5507537", "text": "function LS(t,e,n,i,r,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"source.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=i,u}", "title": "" }, { "docid": "b78e31dfbd5fd11c3fca4276ef31b676", "score": "0.55064374", "text": "function VTUtil(){}", "title": "" }, { "docid": "8e82f37b8735d800939ff9be652b3e7b", "score": "0.5496003", "text": "function tu(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"geom.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "e76732dcb416eb79c0bd273d15a00071", "score": "0.5482463", "text": "function xb(t,e,n,i,r,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"geom.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=i,u}", "title": "" }, { "docid": "4bb766bea2bf19594dfa4b34e4d97b19", "score": "0.5481166", "text": "function vgQA_aOnjgTq8EEzypQtogw() {}", "title": "" }, { "docid": "6927536d1e5e6ea9e09687840fcf8cd8", "score": "0.5475373", "text": "init() {\n\t\t\n\t}", "title": "" }, { "docid": "f25a0533d6f39c2e30cc7db5f6064b99", "score": "0.54633796", "text": "function Lb(t,e,n,i,r,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"geom.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=i,u}", "title": "" }, { "docid": "7bc549bf91aa349cd177ae89ecffa165", "score": "0.5462372", "text": "function __aA8B_bDuuKzS7s5Os_bGMgRg(){}", "title": "" }, { "docid": "87ba02b8aaf08d9aa81a0f67132bcd25", "score": "0.5445741", "text": "function _2WIz9js3_aTyRRmQlZHHvZA() {}", "title": "" }, { "docid": "74c95495bc802c660f5d96993c1ca78c", "score": "0.5440079", "text": "function QJjz4emwkTGj_buhVyJ1fzg(){}", "title": "" }, { "docid": "8bf132bc310b72746ac4afb7aa87f26c", "score": "0.54199624", "text": "function lVjjMls5mTqNefK7rKv6qA(){}", "title": "" }, { "docid": "e317de58c3154bf3aaaf28a2be0dd6d4", "score": "0.5415868", "text": "function jv8IPOznzTOdCFrPhc97Ig(){}", "title": "" }, { "docid": "c5bf779a43590bcf90de8b59da75b953", "score": "0.54102457", "text": "function SigV4Utils() {}", "title": "" }, { "docid": "c5bf779a43590bcf90de8b59da75b953", "score": "0.54102457", "text": "function SigV4Utils() {}", "title": "" }, { "docid": "b36870915304629d2c44ca9b0c395e24", "score": "0.5406554", "text": "static getVersion() { return 1; }", "title": "" }, { "docid": "0f43150d54515cf6e7d7cc76adc5fa35", "score": "0.54058135", "text": "function An(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"source.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "e1fd6370f9dceb24ecc3cd7ebbb8a8e8", "score": "0.5402368", "text": "function SigV4Utils() { }", "title": "" }, { "docid": "394b254528dd61fdb1a2f9f2af96dfcd", "score": "0.53934485", "text": "function ub(t,e,n,i,r,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"geom.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=i,u}", "title": "" }, { "docid": "a755b5b8652bf2f6c2a0cea1bb438356", "score": "0.53866094", "text": "get UV() {}", "title": "" }, { "docid": "2cb8f702caa6aed622f6605ad6582d5e", "score": "0.5368604", "text": "function wD(e,t,r,n,s,o,i,a){var c=(\"function\"===typeof r?r.options:r)||{};return c.__file=\"geom.vue\",c.render||(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,s&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "d4815df3fe21351dbf36ad1b8e770a98", "score": "0.5363698", "text": "get VAG() {}", "title": "" }, { "docid": "51b82234f90fb16d3584f54b2503310b", "score": "0.53598267", "text": "function SigV4Utils(){}", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "78dc4d7acfbc7b81b7ca903afba98639", "score": "0.5358521", "text": "constructor() {\n \n\n \n \n\n \n\n \n }", "title": "" }, { "docid": "b74e36c1f41bce9bec27ad61a01c8853", "score": "0.53519416", "text": "function Ad3CJ05Oejy4H774J7A_bGw(){}", "title": "" }, { "docid": "a03f27cea0cf0d7d27c9b5d480b6f189", "score": "0.53454334", "text": "function vxNj6H8VFjKwXIdd_aik3Tg() {}", "title": "" }, { "docid": "aa822b17c74d59661da6d83fde5803e4", "score": "0.5336747", "text": "function G_bjM0hfvuj_amn1p32jmFYA(){}", "title": "" }, { "docid": "dd36e98e1ca75e190d3e6ca3b3e9c212", "score": "0.53314674", "text": "function r_(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"source.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "ec0b97f6406951af6b99eabede603cc1", "score": "0.533134", "text": "function wi(){}", "title": "" }, { "docid": "777fbac6c8b0c0d17a40a91ce7105db2", "score": "0.53288805", "text": "function BM(t,e,n,i,r,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"layer.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=i,u}", "title": "" }, { "docid": "2fa61a9e3f6c230e222e15a92e3d2cab", "score": "0.5327739", "text": "function Wf(e,t,r,n,s,o,i,a){var c=(\"function\"===typeof r?r.options:r)||{};return c.__file=\"geom.vue\",c.render||(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,s&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "e8a89bd507f24484a2ad4237db6eb42b", "score": "0.53273594", "text": "function Bx(t,e,n,i,r,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"geom.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,r&&(u.functional=!0)),u._scopeId=i,u}", "title": "" }, { "docid": "fa56a91ab1292c7b753a923bb3c38803", "score": "0.5316463", "text": "function Vj(t,e,i,n,r,o,s,a){var c=(\"function\"===typeof i?i.options:i)||{};return c.__file=\"geom.vue\",c.render||(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "3e7e9e9646f88550fefad4316e69e379", "score": "0.5313965", "text": "function kbGTuVSCBjenekexrWe7fA() {}", "title": "" }, { "docid": "9221579bf96aa67013a1c3223e65378d", "score": "0.53069717", "text": "function ma(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"graticule.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "89bd62737a039f89bd61af6984d7ce56", "score": "0.53050125", "text": "function zyUuCZDtHja_aHv7uHGvtZg(){}", "title": "" }, { "docid": "dacbda167a32a723300c142b9f7adee4", "score": "0.52987635", "text": "get uv() {}", "title": "" }, { "docid": "2b81ebfae36b39692514ac3cf2afe1c3", "score": "0.52906376", "text": "ready() {\n }", "title": "" }, { "docid": "a789cb4097a9d986f71241c5c92d24b3", "score": "0.5284926", "text": "function version(){\n\t\treturn \"1.0.0\";\n\t}", "title": "" }, { "docid": "d8c0bcff6690892a2a788962a1a7e2cd", "score": "0.52756065", "text": "function aL(t,e,i,n,r,o,s,a){var c=(\"function\"===typeof i?i.options:i)||{};return c.__file=\"geom.vue\",c.render||(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),c._scopeId=n,c}", "title": "" }, { "docid": "ab9e205f8bf72248368d54505953b516", "score": "0.5273126", "text": "function Ad(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"geom.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "d39c2cd57616c4f44a648d8eddba671e", "score": "0.527015", "text": "function wySSqSiv8z6lz3PALVih7g() {}", "title": "" }, { "docid": "771d6068551834e199827d42a6ad4f9d", "score": "0.5269501", "text": "function xd(t,e,n,r,i,o,a,s){var u=(\"function\"===typeof n?n.options:n)||{};return u.__file=\"geom.vue\",u.render||(u.render=t.render,u.staticRenderFns=t.staticRenderFns,u._compiled=!0,i&&(u.functional=!0)),u._scopeId=r,u}", "title": "" }, { "docid": "1aa44846a035b10a6476a411403abae7", "score": "0.52621657", "text": "function TTEaihOoHTCT8R6eM8B9OA(){}", "title": "" } ]
fd3e80a5d412e47ca5983769d6a9b543
will roll among all the characters of the alphabet
[ { "docid": "fef7ffdb2dc4e7bb34c439dd26a9f802", "score": "0.0", "text": "function get_next_unique_id() {\n var ret = gNextUniqueId + gNextIdChar + '-ft-unq';\n\n function increment_root_string(len)\n {\n var ret = true, endChar;\n if ( len === 0 )\n {\n ret = false;\n }\n else\n {\n endChar = gNextUniqueId.charAt(len-1);\n if ( endChar === 'z' )\n {\n endChar = 'a';\n ret = increment_root_string(len-1);\n }\n else\n {\n endChar = String.fromCharCode(endChar.charCodeAt(0)+1);\n }\n gNextUniqueId = gNextUniqueId.substring(0,len-1) + endChar;\n }\n return ret;\n }\n\n if ( gNextIdChar === 'z' )\n {\n // increment the root string\n if ( !increment_root_string(gUniqueLen) )\n {\n gUniqueLen++;\n gNextUniqueId += 'a';\n }\n gNextIdChar = 'a';\n }\n else\n {\n gNextIdChar = String.fromCharCode(gNextIdChar.charCodeAt(0)+1);\n }\n return ret;\n }", "title": "" } ]
[ { "docid": "84eef37390b3a46b0f3e813ed48211bf", "score": "0.70493805", "text": "function caesarShift (str, key) {\r\n\r\n\t// Wrap the amount\r\n\tif (key < 0)\r\n\t\treturn caesarShift(str, key + 26);\r\n\r\n\t// Make an output variable\r\n\tvar output = '';\r\n\r\n\t// Go through each character\r\n\tfor (var i = 0; i < str.length; i ++) {\r\n\r\n\t\t// Get the character we'll be appending\r\n\t\tvar c = str[i];\r\n\r\n\t\t// If it's a letter...\r\n\t\tif (c.match(/[a-z]/i)) {\r\n\r\n\t\t\t// Get its code\r\n\t\t\tvar code = str.charCodeAt(i);\r\n\r\n\t\t\t// Uppercase letters\r\n\t\t\tif ((code >= 65) && (code <= 90))\r\n\t\t\t\tc = String.fromCharCode(((code - 65 + key) % 26) + 65);\r\n\r\n\t\t\t// Lowercase letters\r\n\t\t\telse if ((code >= 97) && (code <= 122))\r\n\t\t\t\tc = String.fromCharCode(((code - 97 + key) % 26) + 97);\r\n\r\n\t\t}\r\n\r\n\t\t// Append\r\n\t\toutput += c;\r\n\r\n\t}\r\n\t// All done!\r\n\treturn output;\r\n\r\n}", "title": "" }, { "docid": "27f3c99492bb2600db1b18e409403d99", "score": "0.6946884", "text": "function alphabet_char_Shift(str) {\n var all_chars = str.split(\"\");\n for(var i = 0; i < all_chars.length; i++) {\n var n = all_chars[i].charCodeAt() - 'a'.charCodeAt();\n n = (n + 1) % 26;\n all_chars[i] = String.fromCharCode(n + 'a'.charCodeAt());\n }\n return all_chars.join(\"\");\n}", "title": "" }, { "docid": "75c5c3007ffcfe785782a1f0da6d8ca6", "score": "0.6892654", "text": "function ashift (character, key) {\n\t\tvar valuemessage = chartoa(character);\n\t\tvar shift = chartoa(key);\n\t\tvar shiftedletter;\n\t\t\n\t\tif (valuemessage >= 97 && valuemessage <= 122) {\n\t\t\tshiftedletter = atochar(97 + ((valuemessage - 97) + (shift - 96)) % 26);\n\t\t}\n\t\telse if (valuemessage >= 65 && valuemessage <= 90) {\n\t\t\tshiftedletter = atochar(65 + ((valuemessage - 65) + (shift - 96)) % 26);\n\t\t}\t\t\t\n\t\telse {\n\t\t\treturn character;\n\t\t}\n\t\treturn shiftedletter;\n\t}", "title": "" }, { "docid": "2b580da15bb1a620d13af3192ab8f9e2", "score": "0.68316954", "text": "function shiftChars(word, num) {\n const alphabet = [\n 'a','b','c','d','e','f','g','h','i','j','k','l','m',\n 'n','o','p','q','r','s','t','u','v','w','x','y','z'\n ];\n // newStr = \"\"\n //\n // for(let i = 0; i < word.length; i++){\n // let indexOfLetter = alphabet.indexOf(word[i]);\n // let shift = (indexOfLetter + num) % 26;\n // newStr += alphabet[shift]\n // }\n // return newStr\n\n return [...word].map(el => alphabet[(alphabet.indexOf(el) + num) % 26]).join(\"\")\n}", "title": "" }, { "docid": "6bd7997bb8343858de1d6332e3e20ef1", "score": "0.67173207", "text": "function shake() {\n return alphabetGenerator(randomChar());\n}", "title": "" }, { "docid": "976eb1ba064012dd88832bc1e62e30d8", "score": "0.6692383", "text": "function caesarShift(input, shift) {\n\t\n\tvar newString = \"\";\n\t\n\tfor (var i = 0; i < input.length; i++) {\n\t\t\n\t\tvar char = input[i];\n\t\t\n\t\tvar indexofCharacter = alphabet.indexOf(char);\n\t\t\n\t\tvar newPosition = indexofCharacter + shift;\n\t\t\n\t\tif (newPosition > 25) {\n\t\t\t\n\t\t\tnewPosition = newPosition - 26;\n\t\t\t\n\t\t}\n\t\t\n\t\tvar newCharacter = alphabet[newPosition];\n\t\t\n\t\tif (indexofCharacter == -1){\n\t\t\t\n\t\t\tvar newCharacter = char;\n\t\t\t\n\t\t}\n\t\t// Adds character to the string\n\t\tnewString += newCharacter;\n\t\t\n\t}\n\t//Returns the final String\n\treturn newString;\n\t\n}", "title": "" }, { "docid": "3a2b20682f58c49183ff462325fc4b24", "score": "0.6662133", "text": "function alphabet(str){\n var output = \"\";\n var arrayAlpha = str.split(\"\");\n \n \n for(var i = arrayAlpha.length - 1; i >= 0; i--){;\n output += arrayAlpha[i];\n \n } \n return output; \n }", "title": "" }, { "docid": "c7d38bae00f52f36acfd1309f081f983", "score": "0.6622016", "text": "function rotate (sect) {\r\n\tvar move = sect % 26;\r\n\tvar j = 0;\r\n\tfor(i = 0; i < 26; i++) {\r\n\t\tif (i <= (26 - (move + 1))) {\r\n\t\t\tnewalphabet[i] = alphabet[i + move];\r\n\t\t} else {\r\n\t\t\tnewalphabet[i] = alphabet[j];\r\n\t\t\tj++;\r\n\t\t}\r\n\t}\r\n}", "title": "" }, { "docid": "99b508ac59c3efe5aea11d06668bf8d2", "score": "0.6606085", "text": "function characters(newCharacters){if(newCharacters!==undefined){alphabet.characters(newCharacters);}return alphabet.shuffled();}// Export all other functions as properties of the generate function", "title": "" }, { "docid": "47fe313044b03fc8b38286b1ab6ca8d9", "score": "0.660523", "text": "function encipher(str, shift) {\n\nlet everything = '';\n //then take the the index of the string and shift (add or subtract) from that index and return the character at the new index\nfor (let i = 0; i < str.length; i++) {\nlet index = alphabet.indexOf(str[i]);\n\nif (index + shift > alphabet.length -1){\n let leftover = alphabet.length -1 - index;\n everything += \n}\n\n // str[].indexOf([i + shift], 0) = answer\n\n}\n}", "title": "" }, { "docid": "bb18426acdcb5b42557f8d7850fcf131", "score": "0.6597797", "text": "function caesarChar(letter, shift) {\n if (lowerAlphabet.indexOf(letter) !== -1) {\n return lowerAlphabet[(lowerAlphabet.indexOf(letter) + shift)%26];\n } else if (upperAlphabet.indexOf(letter) !== -1) {\n return upperAlphabet[(upperAlphabet.indexOf(letter) + shift)%26];\n } else {\n return letter;\n }\n}", "title": "" }, { "docid": "e4f926ef726bd471d35233ef56a5b097", "score": "0.65405643", "text": "function ciper(srt) {\n debugger\n let letter = ''\n for (var i = 0; i < srt.length; i++) {\n //console.log(srt[i])\n if (srt[i].charCodeAt() + 13 > '90')\n letter += String.fromCharCode(srt[i].charCodeAt() + 13 - 26)\n else letter += String.fromCharCode(srt[i].charCodeAt() + 13)\n }\n return letter\n}", "title": "" }, { "docid": "e3a134c58c2b016ec936d3617e5432f4", "score": "0.65194565", "text": "function alphabeticShift(inputString) {\r\n var anum={\r\n a: 'b', b: 'c', c: 'd', d: 'e', e: 'f', f: 'g', g: 'h', h: 'i', i: 'j', j: 'k', k: 'l', \r\n l: 'm', m: 'n', n: 'o',o: 'p', p: 'q', q: 'r', r: 's', s: 't', t: 'u', \r\n u: 'v', v: 'w', w: 'x', x: 'y', y: 'z', z: 'a'\r\n }\r\n let x = inputString.split(\"\");\r\n \r\n let z = x.map(function(y) {\r\n return y = anum[y];\r\n });\r\n \r\n return z.join(\"\");\r\n }", "title": "" }, { "docid": "d8e0412ba109b6ec87ab71b7ebed0ad2", "score": "0.64409727", "text": "function jumbleSort(str, alphabet){\n\n}", "title": "" }, { "docid": "6d5ec5759b357536da24940731da0ee5", "score": "0.64361346", "text": "if (pattern.test(plaintext.charAt(i))) {\n ciphertext += String.fromCharCode((plaintext.charCodeAt(i) - 97 + shift) % 26 + 97);\n // leaves user error for entering a negative number, should check for offset before adding\n // 97 base again\n }", "title": "" }, { "docid": "2c712aad55738d59cac303cddc7518e3", "score": "0.6423952", "text": "function generateAlphabet() {\n var arr = [];\n for (var i = 97; i <= 122; i++) {\n arr.push(String.fromCharCode(i));\n }\n return arr;\n}", "title": "" }, { "docid": "d0ee57154039d57735d98649118b5076", "score": "0.64148533", "text": "function genAlpha(charA, charZ) {\n let i = charA.charCodeAt(0);\n let j = charZ.charCodeAt(0);\n for (; i <= j; i++)\n alpha.push(String.fromCharCode(i));\n}", "title": "" }, { "docid": "6881af704cf4651348ad7da0dcbd856c", "score": "0.63966846", "text": "drawLetters() {\n const alphabet = {\n A: 9, B: 2, C:2, D:4, E:12, F:2, G:3, H:2, I:9, J:1, K:1, L:4, M:2, N:6, O:8, P:2, Q:1, R:6, S:4, T:6, U:4, V:2, W:2, X:1, Y:2, Z:1\n };\n\n const hand = [];\n\n const onlyLetters = Object.keys(alphabet);\n \n //ASSIGNMENT REQ: The letters should be randomly drawn from a pool of letters\n //Randomization adapted from from w3resource explanation of random approaches in JS: https://www.w3resource.com/javascript-exercises/javascript-array-exercise-35.php\n const randomItem = items => items[Math.floor(Math.random()*items.length)]; \n //close random_item\n let tile = undefined;\n //ASSIGNMENT REQ: Each string should contain exactly one letter\n while (hand.length < 10) {\n tile = (randomItem(onlyLetters));\n\n if(alphabet[tile] > 0) {\n alphabet[tile] -= 1;\n hand.push(tile);\n }//close if\n }//close while loop used to make hand\n return hand;\n }", "title": "" }, { "docid": "958c331205d1b7dde1c4c15c1173bbfe", "score": "0.63669986", "text": "function caesar (input, shift, encode = true) {\n // your solution code here\n const alph = [\n 'a',\n 'b',\n 'c',\n 'd',\n 'e',\n 'f',\n 'g',\n 'h',\n 'i',\n 'j',\n 'k',\n 'l',\n 'm',\n 'n',\n 'o',\n 'p',\n 'q',\n 'r',\n 's',\n 't',\n 'u',\n 'v',\n 'w',\n 'x',\n 'y',\n 'z',\n ];\n //error message\n input = input.toLowerCase ();\n if (shift == null) return false;\n if (shift < -25 || shift === 0 || shift > 25) {\n return false;\n }\n // Make a return variable\n let finished = '';\n if (encode) {\n let amountLeft = 0;\n let newShift = 0;\n\n for (let i = 0; i < input.length; i++) {\n //loop thru input\n //chek if each character in the input is a letter\n\n if (!input[i].match (/[a-z]/)) {\n //if it isn't a letter ignore it\n finished += input[i];\n }\n\n for (let j = 0; j < alph.length; j++) {\n //loop thru alphabet variable we created above\n if (input[i] == alph[j]) {\n //for each character in the alphabet we check if it matches\n //each character in the input\n if (alph[j + shift]) {\n //when it matches we add the letter [amount shift is] spaces away\n finished += alph[j + shift];\n } else if (shift > 0) {\n //check how far on the other side of the alphabet we are shifting\n amountLeft = alph.length - 1 - j;\n newShift = shift - amountLeft;\n //add shifted letter\n finished += alph[newShift - 1];\n } else if (shift < 0) {\n amountLeft = shift + j;\n finished += alph[25 + amountLeft + 1];\n }\n }\n }\n }\n return finished;\n }\n\n if (!encode) {\n for (let i = 0; i < input.length; i++) {\n if (input[i] === ' ') {\n finished += ' ';\n } else if (1 === 1) {\n // access each character in the input\n let char = input[i];\n // check if the character is a letter\n if (char.match (/[a-z]/i)) {\n //turn to a number\n const charcode = input.charCodeAt (i);\n let temp = charcode - 97 - shift;\n if (temp >= 0) {\n char = String.fromCharCode (temp % 26 + 97);\n } else {\n char = String.fromCharCode (26 + temp + 97);\n }\n }\n // add to the finished string\n finished += char;\n }\n }\n return finished.toLowerCase ();\n }\n }", "title": "" }, { "docid": "dd3b6922524f074cddc463679eebd101", "score": "0.6357569", "text": "function caesarCipher(num, string) {\nvar alphabet = [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\"];\nvar splitString = string.toLowerCase().split(\"\");\nvar newString = [];\n for (var i = 0; i < splitString.length; i++) { //iterating through the original string\n if(alphabet.indexOf(splitString[i]) === -1) { //1 If the evaluated character is not in the alphabet array, then push it\n newString.push(splitString[i]);\n }\n else { //2\n if (alphabet.indexOf(splitString[i]) + num > alphabet.length - 1) { //3 If the number that sums the indexOf with the num\n //is larger than the alphabet's length\n newString.push(alphabet[alphabet.indexOf(splitString[i]) + num - alphabet.length]);\n }\n else { //4 regular push with the number being the sum of the splitString[i] + num\n newString.push(alphabet[alphabet.indexOf(splitString[i])+ num]);\n }\n }\n }\n return newString.join(\"\");\n}", "title": "" }, { "docid": "ca110339e0bdca1523098636e7c21108", "score": "0.6313501", "text": "function encryptCeasar(shift, word) {\n const lettersArr = word.split(\"\");\n const newLettersArr = [];\n\n if (shift < 0) {\n return encryptCeasar(shift + 26, word);\n }\n\n lettersArr.forEach((letter) => {\n // If letter\n if (letter.match(/[a-z]/i)) {\n const letterCode = letter.charCodeAt();\n\n // Uppercase letters\n if (letterCode >= 65 && 90 >= letterCode) {\n const newLetter = String.fromCharCode(\n ((letter.charCodeAt() - 65 + shift) % 26) + 65\n );\n newLettersArr.push(newLetter);\n }\n\n // Lowercase letters\n if (letterCode >= 97 && 122 >= letterCode) {\n const newLetter = String.fromCharCode(\n ((letter.charCodeAt() - 97 + shift) % 26) + 97\n );\n newLettersArr.push(newLetter);\n }\n }\n });\n\n const newWord = newLettersArr.join(\"\");\n return newWord;\n}", "title": "" }, { "docid": "a356cef4df689210f5f44b844452400c", "score": "0.63084245", "text": "function cipher() {\n for (var i = 0; i < input.length; i++) {\n var isLetter = false;\n for (var j = 0; j < alphabet.length; j++) {\n if (input[i] === alphabet[j]) {\n toNumber.push((j + shift) % 26);\n isLetter = true;\n }\n }\n if (!isLetter) {\n toNumber.push(input[i]);\n }\n }\n for (var k = 0; k < toNumber.length; k++)\n if (!isNaN(toNumber[k])) {\n if (toNumber[k] === \" \") {\n output += \" \";\n } else {\n output += (alphabet[toNumber[k]]);\n }\n } else {\n output += (toNumber[k]);\n }\n return output;\n}", "title": "" }, { "docid": "ffbcc726641971e8132b6c627ad14842", "score": "0.6305328", "text": "function next(str){\n var alphabet = [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\"];\n var nstr = str.split(\"\");\n for(var i=0; i<nstr.length; i++){\n for(var j=0; j<25; j++){\n if(nstr[i] === alphabet[j]){\n nstr[i] = alphabet[j+1];\n break;\n }\n else if(nstr[i] === alphabet[25]){\n nstr[i] = alphabet[0];\n }\n }\n }\n nstr = nstr.join(\"\");\n return nstr;\n}", "title": "" }, { "docid": "15708339b4f1049131b2d697c0fc9d89", "score": "0.62945986", "text": "function caesar(input, shift, encode = true) {\n // your solution code here\n let a\n //return false if shift value is not present, equal to 0, greater than 25, or less than -25. \n if(!shift || shift == 0 || shift < -25 || shift > 25){\n return false;\n }\n //make an output variable\n let output = \"\";\n //go through each character of input to encode\n for (let i = 0; i < input.length; i++) {\n // handle uppercase letters by changing to lower case\n let code = input.toLowerCase().charCodeAt(i);\n let index = \"\"; \n if (encode) { \n if (code >= 97 && code <= 122) {\n // create variable of shift + character code\n index = code + shift; \n // if index goes after letter z, substract by length of alphabet\n if (index > 122) {\n output += String.fromCharCode(index - 26);\n // if index goes before letter a, add the length of alphabet\n } else if (index < 97) {\n output += String.fromCharCode(index + 26);\n } else {\n output += String.fromCharCode(index)\n }\n // if its not a letter, let it through\n } else {\n output += input.charAt(i);\n }\n } else {\n // create variable of shift - character code\n index = code - shift; \n if (code >= 97 && code <= 122) {\n // if index goes after letter z, substract by length of alphabet\n if (index > 122) {\n output += String.fromCharCode(index - 26);\n // if index goes before letter a, add the length of alphabet\n } else if (index < 97) {\n output += String.fromCharCode(index + 26);\n } else {\n output += String.fromCharCode(index)\n }\n // its not a letter, let it through\n } else {\n output += input.charAt(i);\n }\n }\n } \n return output;\n }", "title": "" }, { "docid": "6606b74209e62ba50317efa4697a13a8", "score": "0.6290486", "text": "function makeBasePass() {\r\n\r\n \r\n for ( var i = 0; i < length; i++ ) {\r\n basePass += lowerLetter.charAt(Math.length(Math.random() * \r\ncharactersLength));\r\n }\r\n\r\n alert(basePass)\r\n\r\n\r\n \r\n}", "title": "" }, { "docid": "5c8301fefd06aa8d05060a8aae1b336a", "score": "0.6255618", "text": "function encrypt(str) {\n var alphabet = 'abcdefghijklmnopqrstuvwxyz'\n \n var count = 0; \n var encryptStr = [];\n\n for (var i = 0; i < alphabet.length; i++) {\n if (str[count] === alphabet[i]) {\n encryptStr.push(alphabet[i+5]) \n count++ \n }\n }\n return encryptStr.join('')\n}", "title": "" }, { "docid": "c78b3dc8fc1eb3bfcb0d4d13eec356e8", "score": "0.62543654", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet_1.characters(newCharacters);\n }\n\n return alphabet_1.shuffled();\n }", "title": "" }, { "docid": "4f6e713905ba9644ccfdade3167be99c", "score": "0.62182784", "text": "function a(e) {\n return e < 26 ? e + 65 : e < 52 ? e + 71 : e < 62 ? e - 4 : e === 62 ? 43 : e === 63 ? 47 : 65;\n }", "title": "" }, { "docid": "29b1b91a3ac95e66eef71445b6dfff5c", "score": "0.6208323", "text": "encrypt(plaintext) {\n let ciphertext = \"\"; // Ciphertext container....\n for (let i = 0; i < plaintext.length; i++) {\n // Does the alphabet have the current character....\n if (this.alphabet.includes(plaintext[i].toLowerCase())) {\n // Find out if the plaintext character is in capital letters\n let isCapital = this.isUpperCase(plaintext[i]);\n \n // Find the index of the plaintext character....\n let char_index = this.alphabet.indexOf(plaintext[i].toLowerCase());\n \n // Shift alphabet to the left by \"key\"\n this.alphabet = this.rotate_left(this.alphabet, this.key);\n \n // Use the index found to add the new ciphered letter to\n // the ciphertext container\n ciphertext += isCapital\n ? this.alphabet[char_index].toUpperCase()\n : this.alphabet[char_index];\n \n // Shift alphabet back to the right by \"key\"\n this.alphabet = this.rotate_right(this.alphabet, this.key);\n } else ciphertext += plaintext[i]; // Just add the non-alphabetic character to the ciphertext container\n }\n \n // Return the ciphertext\n return ciphertext;\n }", "title": "" }, { "docid": "d66abd9da6a89b4f2bc1667c5034256a", "score": "0.6193486", "text": "function doLetterConga(charNumber, wordNumber) {\n\t\tvar c = parseInt(charNumber.substring(5), 10),\t\t\t// get the character number from class name\n\t\t\tw = parseInt(wordNumber.substring(5), 10),\t\t\t// get the word number from class name\n\t\t\th, d, rockingAngle = 30,\n\t\t\tletterToRock = wordNumber + ' > ' + charNumber;\n\n\t\t// non-Microsoft browsers, use rockingAngle of 30 degrees or -30 degrees to rotate the letter.\n\t\t// Since the rockLetter function is defined within doLetterConga, the scope of the variables\n\t\t// defined above extend into rockLetter. This is how we get around passing arguments to rockLetter\n\t\t// when it is called via setInterval.\n\n\t\tfunction rockLetter() {\n\t\t\trockingAngle = rockingAngle * -1;\n\t\t\t$(letterToRock).css({'-moz-transform': 'rotate(' + rockingAngle + 'deg)',\n\t\t\t\t\t\t\t '-webkit-transform': 'rotate(' + rockingAngle + 'deg)'});\n\t\t\twordArray[w].char[c].rockingTimeoutId = window.setTimeout(rockLetter, 300);\n\t\t}\n\n\n\t\tif (c >= wordArray[w].numberOfCharacters) {\t\t\t// if already gone through all letters in word...\n\t\t\tif (w < theHeading.numberOfWords) {\t\t\t\t\t// if not at end of words\n\t\t\t\tdoLetterConga('.char1', '.word' + (w + 1));\t\t\t// repeat this function for 1st char in next word\n\t\t\t}\n\t\t}\n\n\t\t// for the character in *this* instance of the function, rotate the character around the frame\n\t\th = -175 - wordArray[w].char[1].headingOffset;\n\t\td = (w > 1 && c === 1) ? 500 : 0;\n\n\t\t$(charNumber, wordNumber).delay(d).animate({'left': h}, 500, 'easeOutQuad', function () {\t// move on-page letter to left of frame\n\n\t\t\t// Notice: The value of the letterToRock variable is unique to each instance of this doLetterConga function.\n\n\t\t\trockLetter();\t\t// rock letter back and forth\n\n\t\t\tif (c < wordArray[w].numberOfCharacters) {\t\t// repeat this function for remaining letters in word\n\t\t\t\tdoLetterConga('.char' + (c + 1), wordNumber);\n\t\t\t}\n\n\t\t\t$(charNumber, wordNumber).animate({'top': 545}, 3900, 'easeOutQuad', function () {\n\t\t\t\t// move the letter down\n\t\t\t\tvar h = 690 - wordArray[w].char[1].headingOffset;\n\t\t\t\t$(charNumber, wordNumber).animate({'left': h}, 3500, 'easeOutQuad', function () {\n\t\t\t\t\t// move the letter to the right\n\t\t\t\t\t$(charNumber, wordNumber).animate({'top': 0}, 3800, 'easeOutQuad', function () {\n\t\t\t\t\t\t// move back up and to its original position.\n\t\t\t\t\t\t$(charNumber, wordNumber).animate({'left': wordArray[w].char[c].wordOffset}, 2400, 'easeOutQuad', function () {\n\t\t\t\t\t\t\twindow.clearTimeout(wordArray[w].char[c].rockingTimeoutId);\n\t\t\t\t\t\t\tstraightenOutLetter(charNumber, wordNumber);\n\t\t\t\t\t\t\t$(charNumber, '#absoluteHead').css('color', '#fff');\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}", "title": "" }, { "docid": "c4bf6cadae5d3609fc80b6b4f1b90fd1", "score": "0.61886066", "text": "function letterGenerator(letter) {\n\n}", "title": "" }, { "docid": "c7682695fb1b355732b0453f5a6640e2", "score": "0.61723566", "text": "function encryptLetter(input){\r\n\r\n let plainNumber = Number(determineNumber(input));\r\n \r\n let rotNumber = Number(rot.value);\r\n\r\n let cipherNumber = rotNumber + plainNumber;\r\n\r\n //Keep CipherNumber within bounds for letter input\r\n if(cipherNumber > 67){\r\n cipherNumber -= 68;\r\n }\r\n \r\n return determineLetter(cipherNumber);\r\n}", "title": "" }, { "docid": "b47a5ec0aeee610043cb2d45811ced44", "score": "0.6159715", "text": "function missingAlphabets(s) {\n let arr = [...s].reduce((c, x) => (c[x] = (c[x] || 0) + 1, c), {}), max = Math.max(...Object.values(arr));\n return [...\"abcdefghijklmnopqrstuvwxyz\"].map(x => x.repeat(max - (arr[x] || 0))).join(\"\");\n}", "title": "" }, { "docid": "d48d695b87ebc9f25eafce3b1a623ce8", "score": "0.61551476", "text": "function randomLetter(){\r\n\r\n return alphabet.charAt(Math.floor(Math.random() * alphabet.length));\r\n}", "title": "" }, { "docid": "c585cf64c8b8bdb4b153677289882146", "score": "0.61546123", "text": "function characters(newCharacters) {\n\t if (newCharacters !== undefined) {\n\t alphabet.characters(newCharacters);\n\t }\n\t\n\t return alphabet.shuffled();\n\t}", "title": "" }, { "docid": "c817d5e68e1265f56269fae94a169314", "score": "0.6149427", "text": "function alphaSeq (str) {\n str = str.toUpperCase().split('').sort();\n return str.map(a => a + a.toLowerCase().repeat(a.charCodeAt() - 65)).join(',')\n}", "title": "" }, { "docid": "45d5283bf7ac49d8dab4b14f42619dae", "score": "0.6136698", "text": "function genAlphabet(A, Z) {\n var alphabet = [], i = A.charCodeAt(0), j = Z.charCodeAt(0);\n for (; i <= j; i++) {\n alphabet.push(String.fromCharCode(i));\n }\n return alphabet;\n}", "title": "" }, { "docid": "5504442c9581a8aaa2294503a53cc589", "score": "0.61309206", "text": "function missingAlphabets(s) {\n let newStr = s.split('');\n let letters = {};\n let highestCount = 0;\n let result = '';\n \n for(let i = 0; i <= 25; i++){\n let letter = String.fromCharCode(i + 97);\n let ctr = newStr.filter(a => a == letter).length;\n if(ctr != 0){\n letters[letter] = ctr;\n } else {\n letters[letter] = 0;\n };\n if(ctr > highestCount){\n highestCount = ctr;\n };\n };\n \n for(let i = 0; i <= 25; i++){\n result += createLetters(String.fromCharCode(i + 97), highestCount - letters[String.fromCharCode(i + 97)])\n };\n \n return result;\n}", "title": "" }, { "docid": "c13e0b90ef8338191cf82ffa96f12fd1", "score": "0.6130442", "text": "function alphabetGenerator(index) {\n var alphaBank = []; // storing character from A - Z capital\n for (var i = 65; i <= 90; i += 1) {\n alphaBank.push(String.fromCharCode(i));\n }\n return alphaBank[index];\n}", "title": "" }, { "docid": "c7f9ea85f9c546d01603bed5f451bdec", "score": "0.6120299", "text": "function alphaSeq (str) {\n return str.toLowerCase().split('').sort().map(a => a.toUpperCase() + a.repeat(a.charCodeAt(0) - 97)).join(',');\n}", "title": "" }, { "docid": "c5ededa5b2648e27fdf2fbe6963ca4f6", "score": "0.6108856", "text": "function encodeAtbash(str) {\n var alphabet = (\"abcdefghijklmnopqrstuvwxyz\").split(\"\");\n console.log(alphabet);\n\n var textout = '';\n var str = document.getElementById(\"message\").value;\n\n // goes through each letter in the input text\n for (var i = 0; i < str.length; i++) {\n // current letter\n var letter = str[i];\n // the index of the current letter in the alphabet\n var positionInAlphabet = alphabet.indexOf(letter.toLowerCase());\n if (positionInAlphabet > -1) {\n // SWITCH A AND Z\n var newPosition = alphabet.length - 1 - positionInAlphabet;\n // adds the new letter to the output\n textout += alphabet[newPosition];\n } else {\n textout += letter;\n }\n }\n document.getElementById(\"atbash-output\").innerHTML = textout;\n document.getElementById(\"text-output-area\").innerHTML = textout;\n\n}", "title": "" }, { "docid": "0fdeea7ef98112bf2f8a44f99d3bff78", "score": "0.6108552", "text": "function caesar(input, shift, encode = true) {\n // your solution code here\n\n input = input.toLowerCase()\n const alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n \n let result = \"\"\n let newIndex = 0\n\n if (shift === 0 || shift < -25 || shift > 25) {\n return false\n }\n \n for (what in input) {\n\n // in case if the input has space...\n if (alph.indexOf(input[what]) === -1) {\n result = result + input[what]; \n }\n\n alph.find(letter =>{\n if(letter === input[what]){\n if (encode === true) {\n newIndex = alph.indexOf(letter) + shift;\n } else if (encode === false) {\n newIndex = alph.indexOf(letter) - shift;\n }\n\n if (newIndex > 25) {\n newIndex = newIndex - 26;\n } else if (newIndex < 0) {\n newIndex = newIndex + 26;\n }\n result = result + alph[newIndex]\n }\n })\n }\n \n return result\n}", "title": "" }, { "docid": "7f94cbbb4ec9309369ddf17bcf61570a", "score": "0.61078936", "text": "function characters(newCharacters) {\n\t if (newCharacters !== undefined) {\n\t alphabet.characters(newCharacters);\n\t }\n\n\t return alphabet.shuffled();\n\t}", "title": "" }, { "docid": "e0460d62fec54e34da5532f132b146fb", "score": "0.6106461", "text": "function LetterChanges(str) { \n\n let res =\"\";\n \n for (let i=0; i<= str.length - 1; i++ ) {\n \n \n let code = str.charCodeAt(i);\n \n if (code >= 65 && code <= 90 || code >=97 && code <= 122 ) {\n \n code = str.charCodeAt(i) + 1;\n \n if (code === 123) {code = 97}\n if (code === 91) {code = 65}\n \n \n }\n \n let newletter = String.fromCharCode(code);\n \n if (newletter === \"a\" || newletter === \"e\" || newletter === \"i\" || newletter === \"o\" || newletter === \"u\") {\n newletter = newletter.toUpperCase();\n }\n \n res += newletter;\n }\n \n \n return res; \n \n}", "title": "" }, { "docid": "803add18d5493a5ca310ee9c541260bc", "score": "0.6104931", "text": "function accum(s) {\n let textArr = s.split('')\n let mumbleArr = []\n\n textArr.forEach((letter, count) => {\n let mumble = letter.toUpperCase()\n for(let i = 0; i < count; i++){\n mumble += letter.toLowerCase()\n }\n mumbleArr.push(mumble)\n })\n\n return mumbleArr.join('-')\n}", "title": "" }, { "docid": "ef85aa11a4fae2c35efec77ebf212f52", "score": "0.6100806", "text": "function cipher(wordUser) { //la funcion cipher ocupa como parametro la variable\n for (i = 0; i < wordUser.length; i++) { //para modificar cada elemento del string\n var letters = wordUser.charCodeAt(i); //nos regresa el valor en ascii\n\n if (letters >= 97 && letters <= 122) { // si el codigo ascii, es mayor a 97 al 122 se encuentran las letras minusculas\n\n crypted += String.fromCharCode((letters - 97 + 33) % 26 + 97); //entonces nuestra variable c\n } else {\n crypted += String.fromCharCode((letters - 65 + 33) % 26 + 65);\n }\n\n }\n return alert(\" Tu Mensaje Encriptado Es: \" + crypted)\n}", "title": "" }, { "docid": "58cbed651ba82c4d62b454bfacaa6ec0", "score": "0.6099746", "text": "function makecharact() {\n var text = \"\";\n var possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n \n for (var i = 0; i < 10; i++)\n text += possible.charAt(Math.floor(Math.random() * possible.length));\n \n return text;\n }", "title": "" }, { "docid": "b4645603faa02e8a3e79570574e2834e", "score": "0.609603", "text": "function genAlphabet() {\n var indexList = [];\n var charCodeOfA = 'A'.charCodeAt(0);\n\n for (var i = 0; i < 26; i++) {\n indexList.push(String.fromCharCode(charCodeOfA + i));\n }\n\n return indexList;\n}", "title": "" }, { "docid": "618a0bcc68f5b1078f79fb9cd27f3ddd", "score": "0.60938126", "text": "function cipher (string, shift) {\n\n // if (shift < 0) {\n // cipher (string, shift + 26)\n // }\n\n let letters = \"abcdefghijklmnopqrstuvwxyz\"\n let smallString = string.toLowerCase() //lowercases the entered string\n let codedString = '' //accumulator\n\n for (let idx = 0; idx < string.length; idx++) {\n\n let character = smallString.charAt(idx); //character definition\n let idxOfChar = letters.indexOf(character) //idxOfChar definition\n\n //this function wraps the index back around to start at 0. \n let resetIndexOfChar = function (idxOfChar) {\n if (idxOfChar + shift > 25) {\n return idxOfChar += shift - 26\n } else return idxOfChar + shift\n }\n //this function that will input either the character that\n //was entered as input or the new ciphered letter depending on whether its a letter\n let cipherLetter = letters.charAt(resetIndexOfChar(idxOfChar))\n\n function charToNewString (character) {\n if (letters.includes(character)) {\n return cipherLetter\n } else return character\n }\n\n let newChar = charToNewString(character) //Won't pass numbers b/c if not in the\n // letters string it passes as \"-1\" causing all non letters to pass as a letter\n // once \"shift\" is added to it\n\n if (smallString.includes(character)) {\n codedString += newChar\n } else codedString += character\n }\n\n return codedString\n\n}", "title": "" }, { "docid": "1c0f8d20ca3aaec1fac1a2014fe6094d", "score": "0.60930735", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "8d21d1605b5bf6e6c7b3045c923214a8", "score": "0.60805684", "text": "function alphabetWar(str) {\n let leftArr = []\n let leftTotal = 0;\n let rightArr = []\n let rightTotal = 0;\n let arr = str.split('')\n\n // This splits the array into two arrays to group them by left and right.\n let splitter = arr.filter(e => {\n if(e === 'w' || e === 'p' ||e === 'b' || e === 's') {\n leftArr.push(e)\n } else {\n rightArr.push(e)\n }})\n \n // This adds the amount of points for each letter to the Left Total\n let leftMapped = leftArr.map(e => {\n if(e === 'w'){\n leftTotal += 4\n } else if(e === 'p') {\n leftTotal += 3\n } else if(e === 'b') {\n leftTotal += 2\n } else if(e === 's') {\n leftTotal += 1\n }\n })\n\n // This adds the amount of points for each letter to the Right Total\n let rightMapped = rightArr.map(e => {\n if(e === 'm'){\n rightTotal += 4\n } else if(e === 'q') {\n rightTotal += 3\n } else if(e === 'd') {\n rightTotal += 2\n } else if(e === 'z') {\n rightTotal += 1\n }\n })\n\n // This check to see if the leftTotal is greater, less than or equal to the Right Total\n if(leftTotal > rightTotal) {\n return 'Left side wins!'\n } else if(rightTotal > leftTotal) {\n return 'Right side wins!'\n } else {\n return \"Let's fight again!\"\n }\n}", "title": "" }, { "docid": "a3da4aaa7276f214ed8cd5a45636db75", "score": "0.6067336", "text": "function decrypt(word) {\n // your code goes here\n let secondStep = 1;\n let answer = \"\";\n\n for(var i=0;i<word.length;i++){\n let newascii = word.charCodeAt(i);\n newascii -= secondStep;\n\n while(newascii < 97){\n newascii += 26;\n }\n\n answer += String.fromCharCode(newascii);\n secondStep += newascii;\n }\n return answer;\n}", "title": "" }, { "docid": "f23bb2d0aebac6ee5c137518d48b1003", "score": "0.6066194", "text": "function cipher(inputStr) {\n const chars = inputStr.split('');\n const aCode = 'a'.charCodeAt();\n const zCode = 'z'.charCodeAt();\n\n for (let i = 0; i < chars.length; i++) {\n const charCode = chars[i].charCodeAt();\n console.log(`${chars[i]}:${charCode}`);\n let newCode;\n if (charCode + 13 < zCode) {\n newCode = charCode + 13;\n chars[i] = String.fromCharCode(newCode);\n } else {\n const diff = zCode - charCode;\n chars[i] = String.fromCharCode(aCode + diff);\n }\n }\n\n const result = chars.join('');\n console.log(result);\n\n return result;\n}", "title": "" }, { "docid": "bb968f8d98566fd292188bd06a00e2ad", "score": "0.6064596", "text": "function caesarCipherEncryptor(string, key) {\n const shiftedLetters = []\n const newKey = key % 26 //finds new key within the 26 letter alphabet\n for (let letter of string) {\n //for each letter in string, pass letter and key into newLetter func\n shiftedLetters.push(newLetter(letter, newKey))\n }\n return shiftedLetters.join('')\n }", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "a5ce9a5c0d098131a482415f5e1fd0ef", "score": "0.60468495", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet.characters(newCharacters);\n }\n\n return alphabet.shuffled();\n}", "title": "" }, { "docid": "9c0c8e9ef52b571b1ede5957ba30c07b", "score": "0.6043631", "text": "function encodeFunc(input, alphabet) {\n let values = Object.values(alphabet)\n let keys = Object.keys(alphabet)\n let result = \"\"\n \n for(let i = 0; i < input.length; i++) {\n if (!input[i].match(/[a-z]/)) { result += input[i] }\n keys.forEach((key, index) => {\n if(input[i] === key) {result += values[index]}\n })\n }\n return result\n }", "title": "" }, { "docid": "ebe73ca11d4df7b7511c02050444ab06", "score": "0.60417354", "text": "function characters(newCharacters) {\n\t if (newCharacters !== undefined) {\n\t alphabet.characters(newCharacters);\n\t }\n\n\t return alphabet.shuffled();\n\t}", "title": "" }, { "docid": "ec0c8862b148d69de5eb5986ce0e987c", "score": "0.60397077", "text": "function caesar(input, shift, encode = true) {\n // your solution code here\n\n if (!shift || shift === 0 || shift < -25 || shift > 25) return false;\n\n \n\n const lowerInput = input.toLowerCase();\n const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');\n let newStr = '';\n\n for (let i = 0; i < lowerInput.length; i++) {\n\n const letter = lowerInput[i];\n\n if ((!alphabet.includes(letter)) || (letter === \" \")) {\n newStr += letter\n continue\n }\n \n const currentIndex = alphabet.indexOf(letter);\n\n encode === true ? newIndex = currentIndex + shift : newIndex = currentIndex - shift\n\n if (newIndex > 25) newIndex = newIndex - 26;\n \n if (newIndex < 0) newIndex = newIndex + 26;\n\n newStr += alphabet[newIndex]\n \n }\n\n return newStr;\n\n }", "title": "" }, { "docid": "1d51b288faf776d2926a4596207e3ae2", "score": "0.6037922", "text": "function alphabits(str) {\n str = str.toLowerCase()\n var alph = str.split('').sort().join('')\n document.getElementById('alphabetized').textContent = alph\n}", "title": "" }, { "docid": "2304e96351dd93856f6f9fe93f8fbdf6", "score": "0.60364777", "text": "function encrypt()\n{\n userInput = formatInput();\n finalword = \"\";\n\n // Loops through each char in the input string\n for (var i = 0; i < userInput.length; i++)\n {\n // Loops the char through the alphabet array to get the index of the char\n for (var j = 0; j < alphabet.length; j++)\n {\n if(userInput[i] == alphabet[j])\n {\n // Generates a number between 0 and 4\n random = Math.floor(Math.random() * 4);\n\n // Adds the value of the input char with the value of the generated number\n newIndex = ((random * 26) + j);\n\n // If the new index is larger than 99 then take off an iteration of the alphabet\n // there can't be 3 digit numbers\n if (newIndex > 99)\n {\n newIndex -= 26;\n }\n\n // If the new index is lower than 10, add 0 to the start of the variable\n // because there needs to be an even number of numbers to be able to decrypt\n if (newIndex < 10)\n {\n newIndex = (\"0\" + newIndex);\n }\n\n // Builds the output\n finalword += newIndex;\n }\n }\n }\n\n // Print the new output to the output box\n document.getElementById('output').value = finalword;\n}", "title": "" }, { "docid": "2938eb0748b766d7481465cdfd0e8456", "score": "0.60261", "text": "function accum(s) {\n return s.split('').map(function(letter, index){\n\t return letter.repeat(index + 1).toLowerCase();\n\t}).map(function(letters){\n\t return letters.substring(0,1).toUpperCase() + letters.substring(1).toLowerCase()\n\t}).join('-')\n\n}", "title": "" }, { "docid": "a2b8cdd5ab228f423819d184242e29e2", "score": "0.6025109", "text": "function decode_ashift (character, key) {\n\t\tvar valuemessage = chartoa(character);\n\t\tvar shift = chartoa(key);\n\t\tvar shiftedletter;\n\t\t\n\t\tif (valuemessage >= 97 && valuemessage <= 122) {\n\t\t\tshiftedletter = atochar(97 + (((valuemessage - 97) + (26 - (shift - 96))) % 26));\n\t\t}\n\t\telse if (valuemessage >= 65 && valuemessage <= 90) {\n\t\t\tshiftedletter = atochar(65 + (((valuemessage - 65) + (26 - (shift - 96))) % 26));\n\t\t}\t\t\t\n\t\telse {\n\t\t\treturn character;\n\t\t}\n\t\treturn shiftedletter;\n\t}", "title": "" }, { "docid": "9cf424e3c10eafc7a141b1c24a72ae90", "score": "0.60119766", "text": "function caesar(input, shift, encode = true) {\n // your solution code here\n if (shift === undefined || shift === 0 || shift <= -25 || shift >= 25) {\n return false\n }\n // to encode or decode\n if (!encode) shift = shift - (shift * 2);\n // make letters lower case and loop through them\n let lowerCase = input.toLowerCase();\n let result = [...lowerCase].map((element) => {\n const charCoded = element.charCodeAt();\n // when character is anything other than lower case alphabet\n if (charCoded < 97 || charCoded > 122) return String.fromCharCode(charCoded);\n let newNum = charCoded + shift\n // in case newNum is outside the ASCII character set for lower case alphabet\n if (newNum < 97) return String.fromCharCode(newNum + 26);\n if (newNum > 122) return String.fromCharCode(newNum - 26);\n return String.fromCharCode(newNum);\n });\n return result.join(\"\");\n }", "title": "" }, { "docid": "80e5e7d5d44c83c22c12fba5367d9d68", "score": "0.60086596", "text": "function rot13(str) {\n var rotCharArray = [];\n var regEx = /[A-Z]/ ;\n str = str.split(\"\");\n for (var x in str) {\n if (regEx.test(str[x])) {\n // A more general approach\n // possible because of modular arithmetic\n // and cyclic nature of rot13 transform\n console.log(\"before \" + str[x] + \" - \" +str[x].charCodeAt());\n /* to achieve the cyclic value if code reaches the end of the cycle */\n rotCharArray.push((str[x].charCodeAt() - 65 + 13) % 26 + 65);\n console.log((str[x].charCodeAt() - 65 + 13) % 26 + 65)\n } else {\n rotCharArray.push(str[x].charCodeAt());\n }\n }\n console.log(rotCharArray);\n str = String.fromCharCode.apply(String, rotCharArray);\n return str;\n }", "title": "" }, { "docid": "211cf27dc756bb2a443a89adce4e06a0", "score": "0.6008333", "text": "function newLetter() {\n answer = String.fromCharCode(97+Math.floor(Math.random() * 26));\n}", "title": "" }, { "docid": "c5f5db652fe2e93409c899e9b60cf86a", "score": "0.5995408", "text": "function rockLetter() {\n\t\t\trockingAngle = rockingAngle * -1;\n\t\t\t$(letterToRock).css({'-moz-transform': 'rotate(' + rockingAngle + 'deg)',\n\t\t\t\t\t\t\t '-webkit-transform': 'rotate(' + rockingAngle + 'deg)'});\n\t\t\twordArray[w].char[c].rockingTimeoutId = window.setTimeout(rockLetter, 300);\n\t\t}", "title": "" }, { "docid": "5ad8f9927d330daee2863ca830547ace", "score": "0.5988614", "text": "function rotateCipher(){\n //store the # of rotations input in a variable \"number\"\n let number = getElementByID(\"number\").addEventListener(\"\");\n\n//store the text input in a string called \"text\" (whatever I'll work on the variable names)\n\n//for loop where i = 0, i < length of text, increment i\n //check for uppercase\n //if character is uppercase\n //work with ascii values 65 - 90\n //add number of rotations to i\n //else if character is lowercase\n //work with ascii values 97 - 122\n //add number of rotations to i\n //else\n //ignore or continue\n\n}", "title": "" }, { "docid": "9cae72dfde30d863f635f7c168ba6f50", "score": "0.5984045", "text": "function rotateLetter(character) {\n const SHIFT = 26;\n let unicode = character.charCodeAt(0);\n let rotatedUnicode = unicode + 13;\n\n if (isLetter(unicode) === false) {\n return character;\n } else if (isLetter(unicode) === 'uppercase') {\n let asciiRangeEnd = 90;\n\n if (rotatedUnicode > asciiRangeEnd) {\n rotatedUnicode -= SHIFT;\n }\n } else if (isLetter(unicode) === 'lowercase') {\n let asciiRangeEnd = 122;\n\n if (rotatedUnicode > asciiRangeEnd) {\n rotatedUnicode -= SHIFT;\n }\n }\n\n return String.fromCharCode(rotatedUnicode)\n}", "title": "" }, { "docid": "b5a3dd10143b76dc0cd305ab138af130", "score": "0.59750146", "text": "function totalLetters(arr) {\n\n}", "title": "" }, { "docid": "35db1ac6084cb1ca41701de71dc5bc11", "score": "0.5970341", "text": "function runLE(input){\r\n\tvar output = [];\r\n\tvar working = []; \r\n\tfor(var i = 0; i < input.length; i++){\r\n\t\tworking.push(input[i]);\r\n\t}\r\n\tvar count = 0;\r\n\tvar currentLetter = working[0];\r\n\tfor(var i = 0; i < working.length+1; i++){\r\n\t\tif(working[i] === currentLetter){\r\n\t\t\tcurrentLetter = working[i];\r\n\t\t\tcount++;\r\n\t\t\t//console.log('first');\r\n\t\t}else{\r\n\t\t\tif(count > 1){\r\n\t\t\t\toutput.push(count);\r\n\t\t\t}\r\n\t\t\toutput.push(currentLetter);\r\n\t\t\tcount = 1;\r\n\t\t\tcurrentLetter = working[i];\r\n\t\t\t}\r\n\t\t}\r\n\toutput = output.join('');\r\n\treturn output;\r\n}", "title": "" }, { "docid": "8088a9a1795f7d422747984a9b0216ce", "score": "0.5963465", "text": "function switcher(x) {\r\n const alphabet = [\r\n \"z\",\r\n \"y\",\r\n \"x\",\r\n \"w\",\r\n \"v\",\r\n \"u\",\r\n \"t\",\r\n \"s\",\r\n \"r\",\r\n \"q\",\r\n \"p\",\r\n \"o\",\r\n \"n\",\r\n \"m\",\r\n \"l\",\r\n \"k\",\r\n \"j\",\r\n \"i\",\r\n \"h\",\r\n \"g\",\r\n \"f\",\r\n \"e\",\r\n \"d\",\r\n \"c\",\r\n \"b\",\r\n \"a\",\r\n \"!\",\r\n \"?\",\r\n \" \",\r\n ];\r\n return x.reduce((acc, cur) => acc + alphabet[cur - 1], \"\");\r\n}", "title": "" }, { "docid": "a3bab62b5c84fdfd9affd0dd5e17d22b", "score": "0.5962947", "text": "function shiftLetter(letter, shift) {\n const code = charCodeA + ((ordinal(letter) + shift) % 26)\n return String.fromCharCode(code)\n}", "title": "" }, { "docid": "fa00f12cf59b3ccc67f75a22bb96a124", "score": "0.59610105", "text": "function caesar(input, shift, encode = true) {\n // your solution code here\n if (!shift || shift === 0 || shift < -25 || shift > 25) return false;\n\n let alphabet = \"abcdefghijklmnopqrstuvwxyz\";\n let hashTable = {};\n for (let i = 1; i < 27; i++) {\n hashTable[alphabet[i - 1]] = i;\n }\n\n let result = \"\";\n input = input.toLowerCase();\n for (let i = 0; i < input.length; i++) {\n let entries = Object.entries(hashTable);\n if (input[i] in hashTable) {\n let charValue = hashTable[input[i]];\n let temp;\n (encode) ? temp = charValue + shift : temp = charValue - shift;\n if (temp > 26) temp = temp - 26;\n if (temp < 1) temp = 26 + temp;\n let hashEntry = entries.find(el => el[1] === temp);\n result += hashEntry[0];\n } else {\n result += input[i];\n }\n }\n return result;\n }", "title": "" }, { "docid": "b25f557c469a9224858e1d7b751f93f1", "score": "0.59587777", "text": "function caesar(input, shift, encode = true) {\n // your solution code here\n console.log(input);\n \n \n //SHOULD RETURN FALSE IF SHIFT IS TOO MUCH OR 0\n if (!shift || shift === 0 || shift < -25 || shift > 25){\n return false\n }\n //SHOULD IGNORE CAPITAL LETTERS\n input = input.toLowerCase()\n //store number values\n let charcode = []\n let output = \"\"\n \n //check encode to know if decoding or encoding\n if (encode === true){\n \n //loop through input\n for (let i = 0; i < input.length; i++){\n let number = input.charCodeAt(i)\n \n //change each character by shift or unshift\n let shiftedNumber = number + shift\n \n if (number < 97 || number > 122){\n charcode.push(number)\n } else if (shiftedNumber < 97){\n shiftedNumber = shiftedNumber + 26\n charcode.push(shiftedNumber)\n } else if (shiftedNumber > 122) {\n shiftedNumber = shiftedNumber - 26\n charcode.push(shiftedNumber)\n } else {\n charcode.push(shiftedNumber)\n }\n }\n \n for (let i = 0; i < charcode.length; i++){\n output += String.fromCharCode(charcode[i])\n }\n \n //return or console log result\n console.log(output)\n return output\n \n } else {\n //loop through input\n for (let i = 0; i < input.length; i++){\n let number = input.charCodeAt(i)\n //change each character by shift or unshift\n let shiftedNumber = number - shift\n \n if (number < 97 || number > 122){\n charcode.push(number)\n } else if (shiftedNumber < 97){\n shiftedNumber = shiftedNumber + 26\n charcode.push(shiftedNumber)\n } else if (shiftedNumber > 122) {\n shiftedNumber = shiftedNumber - 26\n charcode.push(shiftedNumber)\n } else {\n charcode.push(shiftedNumber)\n }\n }\n \n for (let i = 0; i < charcode.length; i++){\n output += String.fromCharCode(charcode[i])\n }\n \n //return or console log result\n console.log(output)\n return output\n }\n }", "title": "" }, { "docid": "f4277ac04817766c6abae1aaf4b7c490", "score": "0.5958344", "text": "function calculateLetter(numbers) {\n var rest = numbers % 23;\n var letter = LETRAS[rest];\n console.log(numbers + \" \\- \" + letter);\n}", "title": "" }, { "docid": "7cfe01014d1afbc3874834ad6a52f468", "score": "0.59509134", "text": "function generateKeyList() {\n var iteration = key.length;\n for (i = 0; i < iteration; i++) {\n var tempList = [];\n var currentLetter = key.charCodeAt(i);\n for (j = 0; j < 26; j++) {\n if (currentLetter > 90) {\n currentLetter = 65;\n }\n tempList.push(String.fromCharCode(currentLetter));\n currentLetter++;\n }\n keyArray.push(tempList);\n }\n}", "title": "" }, { "docid": "82ae64cd93f4e82f86ddeef6843bb830", "score": "0.59499717", "text": "function getAlphabeticalIndex(letter) {\n return parseInt(letter, 36) - 9;\n}", "title": "" }, { "docid": "59fd66b56cf2eeb27e8447ba49651cb7", "score": "0.59481543", "text": "function caesar(input, shift, encode = true) {\n if(shift === 0||shift < -25||shift > 25||shift === undefined){\n return false;\n }\n //if not encoding, to get to decoded shift = shift-(shift*2)\n if(!encode){\n shift = shift - (shift *2);\n }\n //create accumulator\n let accumulator = \"\";\n //new string\n //eliminate that which would be false\n //for loop\n for( let i = 0; i < input.length; i++){\n let str = input[i].toLowerCase();\n let comparer = str.charCodeAt(); \n if(comparer >= 97 && comparer <= 122){\n const letterNum = comparer - 97;\n let letterShift = shift + letterNum;\n if (letterShift >= 0){\n letterShift = (letterShift %26) + 97;\n }else{\n letterShift += 26;\n letterShift = (letterShift %26) + 97; \n }\n accumulator += String.fromCharCode(letterShift);\n // accumulator += String.fromCharCode(((comparer - 97 + shift) % 26) + 97)\n\n }else{\n accumulator += input[i];\n } \n \n \n }\n return accumulator \n\n }", "title": "" }, { "docid": "a3747c919d057154cdf8e4cdec3adea8", "score": "0.59472424", "text": "function rand_words(int){\n var alpha = \"abcdefghijklmnopqrstuvwxyz\"\n ary = []\n for(var i = 0; i < int; i++){\n\tvar letters = ''\n rand = Math.floor((Math.random() * 10) + 1)\n \tfor(var k = 0; k < rand; k++){\n \t letters = letters + alpha.charAt(Math.floor((Math.random() * 26) + 1))\n \t }\n \t ary.push(letters)\n }\n \tconsole.log(ary)\n return ary\n }", "title": "" }, { "docid": "4dc5871bd4285c97c72c53122c7a2c5e", "score": "0.59458524", "text": "function cipher26 (message) {\n const alphabet = 'abcdefghijklmnopqrstuvwxyz'\n let sum = 0\n let x = 0\n\n return message\n .split('')\n .reduce((acc, val) => {\n x = 0\n while ((sum + x) % 26 !== alphabet.indexOf(val)) {\n x += 1\n }\n\n sum += x\n return acc + alphabet[x]\n }, '')\n}", "title": "" }, { "docid": "3a764dc7161a9b790432a6bc5e1da8f3", "score": "0.5936554", "text": "function LetterChanges(str) {\n var strOut='';\n for (var i = 0; i < str.length; i++) {\n if (1 < str.charCodeAt(i) && str.charCodeAt(i) < 123) {\n strOut += String.fromCharCode(str.charCodeAt(i) + 1);\n }\n }\n return strOut;\n}", "title": "" }, { "docid": "6079bad2a5af5d9011e60464c87e60d3", "score": "0.5928963", "text": "function makingAnagrams(s1, s2){\n var arr = [];\n var count = 0;\n for(var i = 0; i < 26; i++)\n arr.push(0);\n \n for(var i = 0; i < s1.length; i++) {\n arr[ (s1.charCodeAt(i) - 97)] += 1;\n }\n for(var i = 0; i < s2.length; i++){\n arr[(s2.charCodeAt(i) - 97)] -= 1; \n }\n for(var i = 0; i < arr.length; i++){\n count += Math.abs(arr[i]);\n }\n\n return count;\n}", "title": "" }, { "docid": "184d9a9d562ccc2b2d1572d3c58b985d", "score": "0.5927127", "text": "function caesarCipher(str, val){\n val = val % 26; //this will keep -val positive and keep vals larger than 26 from looping too many times\n let string = str.toLowerCase();\n let alphabet = \"abcdefghijklmnopqrstuvwxyz\".split(\"\");\n let result = \"\";\n \n for(var i = 0; i < string.length; i++){\n let currentletter = string[i];\n if(currentletter===\" \"){\n result+= currentletter;\n continue;\n }\n let curIndex = alphabet.indexOf(currentletter);\n let newIndex = curIndex + val;\n if(newIndex > 25){\n newIndex = newIndex - 26;\n }\n if (newIndex < 0){\n newIndex = 26 + newIndex;\n }\n if(str[i]=== str[i].toUpperCase()){ // checks to see if letter in origional string was upper case\n result += alphabet[newIndex].toUpperCase(); \n }\n else{\n result += alphabet[newIndex];\n }\n }\n return result;\n}", "title": "" }, { "docid": "69159e1392bfd40a1ad74272ea6f4ce6", "score": "0.59214467", "text": "function generatePassword(num) {\n var max = 122;\n var min = 48;\n var password = \"\";\n for (var i = 0; i < num; i++) {\n var randomIndex = Math.floor(Math.random() * (max - min + 1) + min);\n while (randomIndex >= 58 && randomIndex <= 64) {\n randomIndex = Math.floor(Math.random() * (max - min + 1) + min);\n }\n var letter = String.fromCharCode(randomIndex);\n password += letter;\n }\n\n console.log(password);\n}", "title": "" }, { "docid": "a9fc62d560bf63419efe922fb2826431", "score": "0.5919901", "text": "function jumbleSort(str, alphabet = null) {\n\n}", "title": "" }, { "docid": "597abaa8988d7c250a1b3975d6d6f257", "score": "0.5918411", "text": "function updateRandomLetter() {\n computerLetter = ('abcdefghijklmnopqrstuvwxyz').split('')[(Math.floor(Math.random() * 26 ))];\n}", "title": "" }, { "docid": "a7afc90d4c743ea2d111c1d3564f070e", "score": "0.59183466", "text": "function characters(newCharacters) {\n if (newCharacters !== undefined) {\n alphabet_1.characters(newCharacters);\n }\n\n return alphabet_1.shuffled();\n }", "title": "" }, { "docid": "8e5507c59cd37b938ede2327ab7be093", "score": "0.5915113", "text": "function myCipher (text) {\n\n var alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split('');\n var letters = text.split(\"\");\n\n var newLetters = letters.map(letter => {\n if (alphabet.indexOf(letter.toUpperCase()) + 13 >= 26) {\n return alphabet[alphabet.indexOf(letter.toUpperCase()) + 13 - 26];\n }\n else {\n return alphabet[alphabet.indexOf(letter.toUpperCase()) + 13];\n }\n \n });\n var result = newLetters.join(\"\");\n return result;\n}", "title": "" }, { "docid": "2e0435c81133d704a28a57deda0154bd", "score": "0.5911093", "text": "function generatePassword(length) {\n console.log(alphabetArray[0].toUpperCase());\n // toUpperCase, toLowerCase\n // Randomize Math.random, Math.floor\n // .charAt()\n}", "title": "" }, { "docid": "9b0972eed68c34be40864206f361fa29", "score": "0.59081554", "text": "function caesarCipher(str,num){\n //Step 2: Break string into an array\n var arr = str.split('');\n //console.log(arr); (test passed)\n \n \n //Step 3: Advance each letter by num places (hard step!)\n \n //Step 3a: set up alphabet\n var alpha = \"abcdefghijklmnopqrstuvwxyz\";\n var alphabet = alpha.split('');\n \n for(var i=0; i<arr.length; i++){\n //Step 3b: look up letters in str/arr\n var letterNum = alphabet.indexOf(arr[i]);\n if(letterNum!==-1){\n //Step 3c: add num and fix if too big\n letterNum=(letterNum+num)%26;\n if(letterNum<0)\n letterNum+=26;\n //Step 3d: convert letterNum to newLetter\n var newLetter = alphabet[letterNum];\n //Step 3e: store the newLetter\n arr[i]=newLetter;\n }\n }\n \n //Step 4: Turn new array back into string\n var res = arr.join('');\n console.log(res);\n \n //Step 5: Print result to the webpage (DOM Manipulation)\n var oldText = document.createElement(\"H3\");\n oldText.textContent = \"Old: \" + str;\n body.appendChild(oldText);\n var newText = document.createElement(\"H3\");\n newText.textContent = \"New: \" + res;\n body.appendChild(newText);\n}", "title": "" }, { "docid": "a35412b30d31180c6bbf4a34315d96b1", "score": "0.5903367", "text": "function repeatedChars (word){\n var result = [];\n //['a']\n var count = 0;\n for (var i = 0; i < word.length; i++){\n //i = 6\n var curr = word[i];//b\n var next = word[i+1];//a\n if (curr === next){\n count++//count = 0\n } else {\n if (count >= 1){\n result.push(curr);\n }\n count = 0;\n }\n }\n return result\n}", "title": "" }, { "docid": "9c246377e72161a95cbecaa12e8d2df3", "score": "0.5903178", "text": "generateRandomLetter() { }", "title": "" } ]
1f1a51d585d8b12f47140d4828cf6e0f
Requests server to resend all connection information
[ { "docid": "cb3dd72aa5cd28788036ce25dfa5f13e", "score": "0.68064296", "text": "function doRequestConnectionInfo()\n{\n _debug('Requesting connection information (Bandwidth and Server)')\n send({\n reason: 'reload-connection-data'\n })\n}", "title": "" } ]
[ { "docid": "882a488fe517759c9d41f9967e243e27", "score": "0.6077981", "text": "async reloadConnection () {\n await this.awaitConnection()\n await this.connection.close(1001, 'Reloading connection.')\n }", "title": "" }, { "docid": "b3d063baccd4cc3109ea666252e3a0cc", "score": "0.5877095", "text": "function completePeerServerConnection() {\n if (obj.authenticated != 1) return;\n obj.send(obj.common.ShortToStr(4));\n obj.send(JSON.stringify({ action: 'info', serverid: obj.parent.serverid, dbid: obj.parent.parent.db.identifier, key: obj.parent.parent.serverKey.toString('hex'), serverCertHash: obj.parent.parent.webserver.webCertificateHashBase64 }));\n obj.authenticated = 2;\n\n // Process any pending data that was received before peer authentication\n for (var i in obj.pendingData) { processServerData(obj.pendingData[i]); }\n obj.pendingData = null;\n }", "title": "" }, { "docid": "c16c39598bf00bbc5be3cf53fad7b0dd", "score": "0.58273745", "text": "async _resumeConnection () {\n // Resume requests that were not completed before disconnect\n for (const req of this.requests) this.retry(req)\n\n // Re-subscribe\n for (const sub of this.subscriptions) {\n this.connection.send(JSON.stringify({\n action: 'SUBSCRIBE',\n room: sub.room\n }))\n }\n }", "title": "" }, { "docid": "080b50a7127ccf33eda829a25416a72c", "score": "0.57033014", "text": "function requestServerReload()\n{\n _debug('Requesting server reload (server list)')\n send({\n reason: 'server-list',\n });\n}", "title": "" }, { "docid": "9a5f293ad475ebbfa83659dce5bece11", "score": "0.5633095", "text": "ack() {\n\t\t// only need to set the remote host etc\n\t\tthis._connecting = false;\n\t\tthis._destroyed = false;\n\t\tthis._pending = false;\n\t\tif (this._server) {\n\t\t\tthis._server._connections.add(this);\n\t\t\tthis._server.emit('connection', this);\n\t\t\tthis._cp.ack();\n\t\t}\n\t\tdefer(() => {\n\t\t\tthis.emit('connect');\n\t\t});\n\t}", "title": "" }, { "docid": "e18758903a9308be12a656e471e71fdd", "score": "0.5614283", "text": "function closeConnections() {\n for (k in self.connection) {\n self.connection[k].closeConnection();\n }\n self.connection = {};\n self.isWaitPingResp = false;\n self.isSentConnect = false;\n self.isWaitConnack = false;\n self.keepAliveInterval = 0;\n stopKeepAliveTimer();\n publishStatus(false);\n }", "title": "" }, { "docid": "ef1c92e4847e05296149d493b4aaf24e", "score": "0.55356765", "text": "function new_con_req(req,res) {\r\n\treq.parsed=url.parse(req.url,true);\r\n\tvar id = parseInt(req.parsed.query.connId);\r\n\tvar tout =parseInt(req.parsed.query.timeout);\r\n\r\n\t//console.log(id + \" \"+ tout);\r\n\tif(isNaN(id))id=0;\r\n\tif(isNaN(tout))tout=0;\r\n\r\n\tconn_obj.push(new Conn_manip());\r\n\tnum_con++;\r\n\r\n\t//console.log(conn_obj[num_con-1].Con_id);\r\n\tconsole.log(\"New connection request\");\r\n\r\n\tconn_obj[num_con-1].start_con(id,tout,function(err,status) {\r\n\r\n\t\tif(!err){\r\n\t\t\tres.writeHead(200,{ \"Content-Type\" : \"application/json\"});\r\n\t\t\tres.end(JSON.stringify({\"status\": status})+\"\\n\");\r\n\t\t}\r\n\r\n\t\telse\r\n\t\t{\r\n\t\t\tres.writeHead(503,{ \"Content-Type\" : \"application/json\"});\r\n\t\t\tres.end(JSON.stringify({\"error\": err})+\"\\n\");\r\n\t\t}\r\n\r\n\t});\r\n\r\n}", "title": "" }, { "docid": "812c21538372bd2fe58fcf70c3dbe2be", "score": "0.5502547", "text": "function onConnectionLost(responseObject) {\n startConnect()\n}", "title": "" }, { "docid": "5072d6aba83b287c8c8eebe12257ad56", "score": "0.54967475", "text": "async finalize() {\n await this.conn.end();\n this.connectionOpen = false;\n }", "title": "" }, { "docid": "7243d1ab93052cebe7b2e5b0edef6a03", "score": "0.5436983", "text": "function killrequest() {\n self.removeAllListeners();\n self.client.removeListener(\"ctcp-privmsg\", dcc_download_handler);\n self.finished = true;\n self.pack_info = {};\n if(self.intervalId){\n clearInterval(self.intervalId);\n intervalId = false;\n }\n }", "title": "" }, { "docid": "67cdb8a859b65be784129e6403f92f39", "score": "0.5433416", "text": "async updateServer_() {\n if (this.writeInProgress || this.notSent.length == 0) {\n return;\n };\n this.writeInProgress = true;\n while (this.notSent.length > 0) {\n await this.writeToDatabase_();\n };\n this.writeInProgress = false;\n }", "title": "" }, { "docid": "542dcc0a96f345e43779b955b3bf357a", "score": "0.53963923", "text": "close() {\n this.connection.end();\n }", "title": "" }, { "docid": "0671d087e7a8865e14f7d6f804cc4365", "score": "0.5383125", "text": "SOCKET_RECONNECT(state, count) {\n console.info(state, count);\n console.log('reconnection');\n }", "title": "" }, { "docid": "64bb3e08973f5fbc621221c34d7f129f", "score": "0.537843", "text": "async function sendRequestWithAutoreconnect(method, params){\n\tlet promise, error, reconnects = 0;\n\twhile({ promise, error } = await sendRequest(method, params), !promise && reconnects++ !== reconnectAttempts) reconnect();\n\tif(error) throw error;\n\treturn promise\n}", "title": "" }, { "docid": "5d5f8ccad642b7bd9a78abd7e557e471", "score": "0.53629833", "text": "function requestData(n) {\n socket.emit('sendRefreshData',n);\n }", "title": "" }, { "docid": "2de81334988bc6194f31c0f6f78a715d", "score": "0.53590614", "text": "_resetConn()\n {\n // Setup the Connection\n this._conn = new Connection();\n\n if (this._isUsingHttps() || this._forceSecureWebSockets) {\n this._log.info(\"Secure connection detected.\");\n this._eftposAddress = this._eftposAddress.replace(\"ws://\", \"wss://\");\n }\n this._conn.Address = this._eftposAddress;\n \n // Register our Event Handlers\n document.addEventListener('ConnectionStatusChanged', (e) => this._onSpiConnectionStatusChanged(e.detail));\n document.addEventListener('MessageReceived', (e) => this._onSpiMessageReceived(e.detail));\n document.addEventListener('ErrorReceived', (e) => this._onWsErrorReceived(e.detail));\n }", "title": "" }, { "docid": "fbff2c039c68d752c6d7dcbdbb94cc9e", "score": "0.53530514", "text": "function serverConnection(){\r\n this.object = {\r\n method:'',\r\n url:'',\r\n data:'',\r\n connect:function(a,b,d){\r\n if(window.XMLHttpRequest){\r\n server_http = new XMLHttpRequest();\r\n }else{\r\n server_http = new ActiveXObject('Microsoft.XMLHTTP');\r\n }\r\n server_http.onprogress = function(event){\r\n console.log(event);\r\n }\r\n server_http.onreadystatechange = function(e){\r\n if(server_http.readyState == 4 && server_http.status == 200){\r\n var res = server_http.responseText;\r\n return res;\r\n }\r\n }\r\n server_http.open(a,b,true);\r\n //server_http.setRequestHeader(\"Content-type\",\"application/x-www-form-urlencoded\");\r\n server_http.send(d);\r\n }\r\n }\r\n}", "title": "" }, { "docid": "02a32acedf0b980bf85c50fcafdf820e", "score": "0.5346282", "text": "requestFinishConnection(connectionId) {\n return requestAPI({\n url: `connections/${connectionId}/request_finish/`,\n method: 'POST'\n })\n }", "title": "" }, { "docid": "239505603a1a36e1e1d02bcf9d020354", "score": "0.5320004", "text": "flush() {\n if (this.res.flush) {\n this.res.flush();\n }\n }", "title": "" }, { "docid": "eff52d34490d3297631154ed6e6fab03", "score": "0.5317401", "text": "closeClonnection(){\n this.connectionObj,end();\n }", "title": "" }, { "docid": "f379b8c76af58dd4d9006fb9cf7c9670", "score": "0.5315358", "text": "static disconnect() {\n this.connection.end();\n }", "title": "" }, { "docid": "74ac50acbf4bbce23c01911ceb14062c", "score": "0.5312309", "text": "function updateData(){\n for (var key in dict){\n openConn(key, 1);\n dict[key].send();\n }\n\n setTimeout(()=> {updateData()}, 5000);\n}", "title": "" }, { "docid": "bb13fce3e9218e80567ed6b15d683421", "score": "0.53028166", "text": "function refreshServer() {\n getTServer(serv).then(function() {\n refreshDetailTable();\n refreshHistoryTable();\n refreshCurrentTable();\n refreshResultsTable();\n });\n}", "title": "" }, { "docid": "6e0ffbaad2b0406214a5dc8c7fa6d6e6", "score": "0.5295739", "text": "reconnect(req, res, next)\n {\n this.sceneManager.stopUpdates();\n this.deviceManager.close();\n this.deviceManager.open();\n this.sceneManager.startUpdates();\n res.json(true);\n }", "title": "" }, { "docid": "a2686e10e0cad05ee097b410207fc0b5", "score": "0.5283896", "text": "pause() {\r\n this.server.close();\r\n this.connections.forEach(cnx => cnx.end());\r\n this.connections = [];\r\n }", "title": "" }, { "docid": "a515af39cfa907c6a3189796c7e3a398", "score": "0.52751386", "text": "function sWaproxMain(){\n\n\t// Listen to connections from rWaprox's.\n\tvar rwaproxServer = net.createServer(function(rwaprox){\n\n\t \tif(config.debug)\tconsole.log(\"Received connection from \" + rwaprox.remoteAddress + \":\" + rwaprox.remotePort);\n\n\t \trwaprox.on('data', function(data){\n\n\t\t\t// Parse http headers\n\t \t\theaders = parseUrl(data.toString());\n\t \t\treq = net.connect(headers.port ? headers.port : 80, headers.host,\n\t \t\tfunction(){\n\t \t\t\trwaprox.write('HTTP/1.1 200 Connection Established\\r\\n' +\n 'Proxy-agent: Node-Proxy\\r\\n' +\n '\\r\\n');\n\t \t\t\treq.write(data);\n\n\t \t\t\treq.on('data', function(data)\n\t \t\t\t{\n\t \t\t\t\tvar processedData = new rabinData(data);\n\t \t\t\t\tvar responseMessage = [];\n\t \t\t\t\tvar thisRWaprox = null;\n\t \t\t\t\tif(!(thisRWaprox = cache[rwaprox.remoteAddress]))\n\t \t\t\t\t{\n\t \t\t\t\t\tif(DEBUG)\tconsole.log(\"Registering new rwaprox with ID \" + rwaprox.remoteAddress);\n\t \t\t\t\t\tthisRWaprox = new rwaproxCache(rwaprox.remoteAddress);\n\t \t\t\t\t\tcache[rwaprox.remoteAddress] = thisRWaprox;\n\t \t\t\t\t\tfor(var i = 0; i < processedData.hashes.length; i++)\n\t \t\t\t\t\t{\n\t \t\t\t\t\t\tthisRWaprox.addHash(processedData.hashes[i]);\n\t \t\t\t\t\t}\n\t \t\t\t\t\tresponseMessage.push(data);\n\t \t\t\t\t}\n\t \t\t\t\telse{\n\t \t\t\t\t\tfor(var i = 0; i < processedData.hashes.length; i++)\n\t \t\t\t\t\t{\n\t \t\t\t\t\t\t// If the rWaprox has the data, just send the hash\n\t \t\t\t\t\t\t// Otherwise, send the data\n\t \t\t\t\t\t\tvar thisHash = processedData.hashes[i];\n\t \t\t\t\t\t\tif(thisRWaprox.hashHash(thisHash))\n\t \t\t\t\t\t\t{\n\t \t\t\t\t\t\t\t// A hashvalue is indicated by beginning with\n\t \t\t\t\t\t\t\t// \"H,\" (as opposed to data);\n\t \t\t\t\t\t\t\tresponseMessage.push(\"H,\" + thisHash);\n\t \t\t\t\t\t\t}\n\t \t\t\t\t\t\telse\n\t \t\t\t\t\t\t{\n\t \t\t\t\t\t\t\tresponseMessage.push(processedData.getChunk(i));\n\t \t\t\t\t\t\t}\n\t \t\t\t\t\t}\n\t \t\t\t\t}\n\n\t \t\t\t\trwaprox.write(responseMessage.join());\n\n\n\t \t\t\t});\n\t \t\t});\n\n\t \t\treq.on('error', function(err){\n\t \t\t\tconsole.log(\"Problem with forwarding request: \" + err.message);\n\t \t\t});\n\t\t});\n\n\t\trwaprox.on('error', function(err){\n\t\t\tconsole.log(\"Error with rwaprox connection \" + err);\n\t\t\trwaprox.close();\n\t\t});\n\t\t\t\n\t \t\t//var proxy_request = http.request({host:, method:, headers:})\n\t \t\n}).listen(config.rWaprox_port, function(){console.log(\"Listening on \" + this.address().port)});\n\n}", "title": "" }, { "docid": "b5b59ef8de4f1f82cc8d4ffcbf3326e7", "score": "0.5249206", "text": "keepAlive() {\n const endpoint = 'sessions';\n const method = 'PUT';\n return this._makeRequest(endpoint, false, method).then(result => this.throwIfFailed(result, 204)).catch(e => this.throwExceptionResponse(e));\n }", "title": "" }, { "docid": "c154b8b3c221cd97b50061efefebf571", "score": "0.52398336", "text": "_reconnect() {\n clearTimeout(this._reconnectDebounce);\n this._reconnectDebounce = setTimeout(() => {\n this._close();\n this._connect();\n }, 100);\n }", "title": "" }, { "docid": "65b7bad50857a09c98e6c523679540d1", "score": "0.52371836", "text": "function refreshClientConnection(clientId) {\n if (connections[clientId] != null) {\n console.log(\"[KEEPALIVE RECEIVED] [\" + clientId + \"]\");\n connections[clientId].lastKeepAlive = (new Date()).getTime();\n }\n}", "title": "" }, { "docid": "89d05241827b818c43b2715b892ddd05", "score": "0.52304226", "text": "function sendResponse() {\n setTimeout(function () {\n self.response.sendResponse();\n }, networkDelay);\n }", "title": "" }, { "docid": "a96cd1d121c257deeec3a2e3f4d7e399", "score": "0.52298146", "text": "function sendRequest() {\n if (pending != null) return;\n pending = Instant.connection.sendSeq({type: 'get-cdata'});\n }", "title": "" }, { "docid": "e50b99726d2266f33d8f10bd6f1a10b5", "score": "0.5207841", "text": "function ConnectionLost(res) {\n if (res.errorCode !== 0) {\n console.log(\"Connection lost:\" + res.errorMessage);\n Connect();\n }\n}", "title": "" }, { "docid": "2ce1b84615156d42a481763d61af36be", "score": "0.51905894", "text": "function refresh() {\n refreshServer();\n}", "title": "" }, { "docid": "93103e457080e0e1d0a08fe4cdc32750", "score": "0.5185716", "text": "addRequest(req, _opts) {\n const opts = Object.assign({}, _opts);\n if (typeof opts.secureEndpoint !== 'boolean') {\n opts.secureEndpoint = isSecureEndpoint();\n }\n if (opts.host == null) {\n opts.host = 'localhost';\n }\n if (opts.port == null) {\n opts.port = opts.secureEndpoint ? 443 : 80;\n }\n if (opts.protocol == null) {\n opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';\n }\n if (opts.host && opts.path) {\n // If both a `host` and `path` are specified then it's most\n // likely the result of a `url.parse()` call... we need to\n // remove the `path` portion so that `net.connect()` doesn't\n // attempt to open that as a unix socket file.\n delete opts.path;\n }\n delete opts.agent;\n delete opts.hostname;\n delete opts._defaultAgent;\n delete opts.defaultPort;\n delete opts.createConnection;\n // Hint to use \"Connection: close\"\n // XXX: non-documented `http` module API :(\n req._last = true;\n req.shouldKeepAlive = false;\n let timedOut = false;\n let timeoutId = null;\n const timeoutMs = opts.timeout || this.timeout;\n const onerror = (err) => {\n if (req._hadError)\n return;\n req.emit('error', err);\n // For Safety. Some additional errors might fire later on\n // and we need to make sure we don't double-fire the error event.\n req._hadError = true;\n };\n const ontimeout = () => {\n timeoutId = null;\n timedOut = true;\n const err = new Error(`A \"socket\" was not created for HTTP request before ${timeoutMs}ms`);\n err.code = 'ETIMEOUT';\n onerror(err);\n };\n const callbackError = (err) => {\n if (timedOut)\n return;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n onerror(err);\n };\n const onsocket = (socket) => {\n if (timedOut)\n return;\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n if (isAgent(socket)) {\n // `socket` is actually an `http.Agent` instance, so\n // relinquish responsibility for this `req` to the Agent\n // from here on\n debug('Callback returned another Agent instance %o', socket.constructor.name);\n socket.addRequest(req, opts);\n return;\n }\n if (socket) {\n socket.once('free', () => {\n this.freeSocket(socket, opts);\n });\n req.onSocket(socket);\n return;\n }\n const err = new Error(`no Duplex stream was returned to agent-base for \\`${req.method} ${req.path}\\``);\n onerror(err);\n };\n if (typeof this.callback !== 'function') {\n onerror(new Error('`callback` is not defined'));\n return;\n }\n if (!this.promisifiedCallback) {\n if (this.callback.length >= 3) {\n debug('Converting legacy callback function to promise');\n this.promisifiedCallback = promisify_1.default(this.callback);\n }\n else {\n this.promisifiedCallback = this.callback;\n }\n }\n if (typeof timeoutMs === 'number' && timeoutMs > 0) {\n timeoutId = setTimeout(ontimeout, timeoutMs);\n }\n if ('port' in opts && typeof opts.port !== 'number') {\n opts.port = Number(opts.port);\n }\n try {\n debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);\n Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);\n }\n catch (err) {\n Promise.reject(err).catch(callbackError);\n }\n }", "title": "" }, { "docid": "93103e457080e0e1d0a08fe4cdc32750", "score": "0.5185716", "text": "addRequest(req, _opts) {\n const opts = Object.assign({}, _opts);\n if (typeof opts.secureEndpoint !== 'boolean') {\n opts.secureEndpoint = isSecureEndpoint();\n }\n if (opts.host == null) {\n opts.host = 'localhost';\n }\n if (opts.port == null) {\n opts.port = opts.secureEndpoint ? 443 : 80;\n }\n if (opts.protocol == null) {\n opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';\n }\n if (opts.host && opts.path) {\n // If both a `host` and `path` are specified then it's most\n // likely the result of a `url.parse()` call... we need to\n // remove the `path` portion so that `net.connect()` doesn't\n // attempt to open that as a unix socket file.\n delete opts.path;\n }\n delete opts.agent;\n delete opts.hostname;\n delete opts._defaultAgent;\n delete opts.defaultPort;\n delete opts.createConnection;\n // Hint to use \"Connection: close\"\n // XXX: non-documented `http` module API :(\n req._last = true;\n req.shouldKeepAlive = false;\n let timedOut = false;\n let timeoutId = null;\n const timeoutMs = opts.timeout || this.timeout;\n const onerror = (err) => {\n if (req._hadError)\n return;\n req.emit('error', err);\n // For Safety. Some additional errors might fire later on\n // and we need to make sure we don't double-fire the error event.\n req._hadError = true;\n };\n const ontimeout = () => {\n timeoutId = null;\n timedOut = true;\n const err = new Error(`A \"socket\" was not created for HTTP request before ${timeoutMs}ms`);\n err.code = 'ETIMEOUT';\n onerror(err);\n };\n const callbackError = (err) => {\n if (timedOut)\n return;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n onerror(err);\n };\n const onsocket = (socket) => {\n if (timedOut)\n return;\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n if (isAgent(socket)) {\n // `socket` is actually an `http.Agent` instance, so\n // relinquish responsibility for this `req` to the Agent\n // from here on\n debug('Callback returned another Agent instance %o', socket.constructor.name);\n socket.addRequest(req, opts);\n return;\n }\n if (socket) {\n socket.once('free', () => {\n this.freeSocket(socket, opts);\n });\n req.onSocket(socket);\n return;\n }\n const err = new Error(`no Duplex stream was returned to agent-base for \\`${req.method} ${req.path}\\``);\n onerror(err);\n };\n if (typeof this.callback !== 'function') {\n onerror(new Error('`callback` is not defined'));\n return;\n }\n if (!this.promisifiedCallback) {\n if (this.callback.length >= 3) {\n debug('Converting legacy callback function to promise');\n this.promisifiedCallback = promisify_1.default(this.callback);\n }\n else {\n this.promisifiedCallback = this.callback;\n }\n }\n if (typeof timeoutMs === 'number' && timeoutMs > 0) {\n timeoutId = setTimeout(ontimeout, timeoutMs);\n }\n if ('port' in opts && typeof opts.port !== 'number') {\n opts.port = Number(opts.port);\n }\n try {\n debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);\n Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);\n }\n catch (err) {\n Promise.reject(err).catch(callbackError);\n }\n }", "title": "" }, { "docid": "93103e457080e0e1d0a08fe4cdc32750", "score": "0.5185716", "text": "addRequest(req, _opts) {\n const opts = Object.assign({}, _opts);\n if (typeof opts.secureEndpoint !== 'boolean') {\n opts.secureEndpoint = isSecureEndpoint();\n }\n if (opts.host == null) {\n opts.host = 'localhost';\n }\n if (opts.port == null) {\n opts.port = opts.secureEndpoint ? 443 : 80;\n }\n if (opts.protocol == null) {\n opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';\n }\n if (opts.host && opts.path) {\n // If both a `host` and `path` are specified then it's most\n // likely the result of a `url.parse()` call... we need to\n // remove the `path` portion so that `net.connect()` doesn't\n // attempt to open that as a unix socket file.\n delete opts.path;\n }\n delete opts.agent;\n delete opts.hostname;\n delete opts._defaultAgent;\n delete opts.defaultPort;\n delete opts.createConnection;\n // Hint to use \"Connection: close\"\n // XXX: non-documented `http` module API :(\n req._last = true;\n req.shouldKeepAlive = false;\n let timedOut = false;\n let timeoutId = null;\n const timeoutMs = opts.timeout || this.timeout;\n const onerror = (err) => {\n if (req._hadError)\n return;\n req.emit('error', err);\n // For Safety. Some additional errors might fire later on\n // and we need to make sure we don't double-fire the error event.\n req._hadError = true;\n };\n const ontimeout = () => {\n timeoutId = null;\n timedOut = true;\n const err = new Error(`A \"socket\" was not created for HTTP request before ${timeoutMs}ms`);\n err.code = 'ETIMEOUT';\n onerror(err);\n };\n const callbackError = (err) => {\n if (timedOut)\n return;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n onerror(err);\n };\n const onsocket = (socket) => {\n if (timedOut)\n return;\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n if (isAgent(socket)) {\n // `socket` is actually an `http.Agent` instance, so\n // relinquish responsibility for this `req` to the Agent\n // from here on\n debug('Callback returned another Agent instance %o', socket.constructor.name);\n socket.addRequest(req, opts);\n return;\n }\n if (socket) {\n socket.once('free', () => {\n this.freeSocket(socket, opts);\n });\n req.onSocket(socket);\n return;\n }\n const err = new Error(`no Duplex stream was returned to agent-base for \\`${req.method} ${req.path}\\``);\n onerror(err);\n };\n if (typeof this.callback !== 'function') {\n onerror(new Error('`callback` is not defined'));\n return;\n }\n if (!this.promisifiedCallback) {\n if (this.callback.length >= 3) {\n debug('Converting legacy callback function to promise');\n this.promisifiedCallback = promisify_1.default(this.callback);\n }\n else {\n this.promisifiedCallback = this.callback;\n }\n }\n if (typeof timeoutMs === 'number' && timeoutMs > 0) {\n timeoutId = setTimeout(ontimeout, timeoutMs);\n }\n if ('port' in opts && typeof opts.port !== 'number') {\n opts.port = Number(opts.port);\n }\n try {\n debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);\n Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);\n }\n catch (err) {\n Promise.reject(err).catch(callbackError);\n }\n }", "title": "" }, { "docid": "93103e457080e0e1d0a08fe4cdc32750", "score": "0.5185716", "text": "addRequest(req, _opts) {\n const opts = Object.assign({}, _opts);\n if (typeof opts.secureEndpoint !== 'boolean') {\n opts.secureEndpoint = isSecureEndpoint();\n }\n if (opts.host == null) {\n opts.host = 'localhost';\n }\n if (opts.port == null) {\n opts.port = opts.secureEndpoint ? 443 : 80;\n }\n if (opts.protocol == null) {\n opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';\n }\n if (opts.host && opts.path) {\n // If both a `host` and `path` are specified then it's most\n // likely the result of a `url.parse()` call... we need to\n // remove the `path` portion so that `net.connect()` doesn't\n // attempt to open that as a unix socket file.\n delete opts.path;\n }\n delete opts.agent;\n delete opts.hostname;\n delete opts._defaultAgent;\n delete opts.defaultPort;\n delete opts.createConnection;\n // Hint to use \"Connection: close\"\n // XXX: non-documented `http` module API :(\n req._last = true;\n req.shouldKeepAlive = false;\n let timedOut = false;\n let timeoutId = null;\n const timeoutMs = opts.timeout || this.timeout;\n const onerror = (err) => {\n if (req._hadError)\n return;\n req.emit('error', err);\n // For Safety. Some additional errors might fire later on\n // and we need to make sure we don't double-fire the error event.\n req._hadError = true;\n };\n const ontimeout = () => {\n timeoutId = null;\n timedOut = true;\n const err = new Error(`A \"socket\" was not created for HTTP request before ${timeoutMs}ms`);\n err.code = 'ETIMEOUT';\n onerror(err);\n };\n const callbackError = (err) => {\n if (timedOut)\n return;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n onerror(err);\n };\n const onsocket = (socket) => {\n if (timedOut)\n return;\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n if (isAgent(socket)) {\n // `socket` is actually an `http.Agent` instance, so\n // relinquish responsibility for this `req` to the Agent\n // from here on\n debug('Callback returned another Agent instance %o', socket.constructor.name);\n socket.addRequest(req, opts);\n return;\n }\n if (socket) {\n socket.once('free', () => {\n this.freeSocket(socket, opts);\n });\n req.onSocket(socket);\n return;\n }\n const err = new Error(`no Duplex stream was returned to agent-base for \\`${req.method} ${req.path}\\``);\n onerror(err);\n };\n if (typeof this.callback !== 'function') {\n onerror(new Error('`callback` is not defined'));\n return;\n }\n if (!this.promisifiedCallback) {\n if (this.callback.length >= 3) {\n debug('Converting legacy callback function to promise');\n this.promisifiedCallback = promisify_1.default(this.callback);\n }\n else {\n this.promisifiedCallback = this.callback;\n }\n }\n if (typeof timeoutMs === 'number' && timeoutMs > 0) {\n timeoutId = setTimeout(ontimeout, timeoutMs);\n }\n if ('port' in opts && typeof opts.port !== 'number') {\n opts.port = Number(opts.port);\n }\n try {\n debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);\n Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);\n }\n catch (err) {\n Promise.reject(err).catch(callbackError);\n }\n }", "title": "" }, { "docid": "16a2113fc3ec2e1a6aaa0e9209427232", "score": "0.51855785", "text": "function connectToServer() {\n\n }", "title": "" }, { "docid": "da3a2867d931ceac1a7a7d02bba08e90", "score": "0.5185198", "text": "function connect() {\n fetch(root + '/connect/' + new Date().getTime(), {method: \"GET\"}).then(\n function (response) {\n response.text().then(function (responseText) {\n const data = JSON.parse(responseText);\n sessionid = data && data.sessionid;\n sseqnum = 1;\n xseqnum = 1;\n if (sessionid) {\n ask();\n hold = false;\n if (queue.length) {\n send();\n }\n } else {\n error(response);\n }\n })\n }, error);\n }", "title": "" }, { "docid": "5c878f27163a2cd026fce8e70c249dfe", "score": "0.51840067", "text": "function sendRequest(ip, portNum, reqObj, callback, bankServer, httpServer) {\n\tif(bankServer.alive && (bankServer.numSent < bankServer.numSentTotal || bankServer.numSentTotal == -1)) {\n\t\tvar options = {\n\t\thostname\t: ip,\n\t\tport\t\t: portNum,\n\t\tmethod \t\t: 'POST',\n\t\tpath \t\t: '/'\n\t\t};\n\t\tvar req = http.request(options, (callback != null)? function(response) {\n\t\t\tgetResponseObj(response, callback);\n\t\t} : handleResponse);\n\t\tvar reqText = JSON.stringify(reqObj);\n\t\treq.write(reqText);\n\t\treq.on('error', function(error) {\n\n\t\t});\n\n\t\treq.end();\n\n\t\tif(httpServer != null) {\n\t\t\tbankServer.numSent++;\n\t\t\tif(bankServer.numSent >= bankServer.numSentTotal && bankServer.numSentTotal != -1) {\n\t\t\t\tlog(\"Server sent it's limit\\nTerminating....\", bankServer);\n\t\t\t\thttpServer.close();\n\t\t\t\tbankServer.alive = false;\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "6fd3d634fb7bd523d274cabbcaa57993", "score": "0.5178611", "text": "function sendResponse() {\n res.send(JSON.stringify(statusData));\n res.end();\n }", "title": "" }, { "docid": "80e330d19db794b2bf2e178dc1c48f02", "score": "0.5166515", "text": "function closedConnection(){\n\t\tconsole.log('Connection closed');\n\t\t// Handle error properly\n\n\t\t// Reconnect\n\t\ttry {\n\t\t\tsetTimeout(() => crestron.connect(\"192.168.1.215\"), 20000);\n\t\t} catch (err) {\n\t\t\tconsole.log(err);\n\t\t}\n\t}", "title": "" }, { "docid": "09c823aecbb279cb4e831c239dfec466", "score": "0.51542443", "text": "respond(query, response, error) {\n if(!(query.ns == 'base' && query.cmd == 'ping'))\n log.info(\"Responding msg '%s:%s' to %s \", query.ns, query.cmd, this.client_key);\n\n query.response = response;\n query.error = error;\n\n delete query.cmd;\n delete query.ns;\n delete query.xargs;\n delete query.args;\n\n this.write(query);\n }", "title": "" }, { "docid": "be681be88ffd2df85045f41e084455b1", "score": "0.5151939", "text": "SOCKET_RECONNECT(state, count) {\n // attempt to reconnect\n state.socket.reconnectionCount = count;\n }", "title": "" }, { "docid": "38a69e96f81b114a4f49aabac8cdfecb", "score": "0.51512593", "text": "connect() {\n var self = this;\n self.status(self.STATUS_WARNING, 'Connecting...');\n\n // Clear polling intervals because first we need a valid connection (maybe NDI Studio Monitor has been closed and initConnection() was fired after an error)\n if (self.timers.pollSources) {\n clearInterval(self.timers.pollSources);\n self.timers.pollSources = null;\n }\n if (self.timers.pollConfiguration) {\n clearInterval(self.timers.pollConfiguration);\n self.timers.pollConfiguration = null;\n }\n if (self.timers.pollRecording) {\n clearInterval(self.timers.pollRecording);\n self.timers.pollRecording = null;\n }\n // This should never happen because retryConnection() is taking care of it. Leaving it here anyway\n if(self.timers.reconnectTimeout) {\n clearTimeout(self.timers.reconnectTimeout);\n self.timers.reconnectTimeout = null;\n }\n\n var path = '/';\n var url = 'http://' + self.config.host + ':' + self.config.port + path;\n\n // First request (without any extra header); if NDI Studio Monitor requires a web password we will get an HTTP 401 and store www-authenticate headers\n self.waitingForResponse = true;\n self.system.emit('rest_get', url, function (err, result) {\n if(self.active) { // Prevent response handling if instance have been disabled while waiting for a response\n if (err !== null) { // Something bad happened, mainly an ECONNREFUSED if NDI Studio Monitor is not running or unreachable\n self.status(self.STATUS_ERROR, result.error.code);\n self.log('error', 'Connection failed (' + result.error.code + ')');\n self.retryConnection(); // Keep trying to connect\n }\n else {\n if(result.response.statusCode == 200) { // NDI Studio Monitor is not requiring a web password\n self.auth.passwordMandatory = false;\n self.waitingForResponse = false;\n if(!isNDIStudioMonitorResponse(result.data)) { // Check if the response if from NDI Studio Monitor\n self.log('warn', 'Unespected response after connection'); // We can't be 100% sure so just put a warn in the log\n }\n if(self.config.useWebPassword === true) { // Not expected because self.config.useWebPassword is true, but everything should work anyway\n self.status(self.STATUS_OK); // Everything will work, no reason to raise a warning on the instance\n self.log('warn', 'Web password is not required'); // Just notify the user that web password is being ignored\n self.startPolling(); // Start to poll for sources, configuration and recording status\n } else { // Everything is fine\n self.status(self.STATUS_OK);\n self.startPolling(); // Start to poll for sources, configuration and recording status\n }\n } else if(result.response.statusCode == 401) { // This is ok, NDI Studio Monitor may require a web password\n self.auth.passwordMandatory = true;\n if(self.config.useWebPassword === false) { // We need to use the web password but in instance config \"Use web password\" is not checked\n self.status(self.STATUS_ERROR, \"Web password is required for login\");\n self.log('error', 'Web password is required for login');\n self.waitingForResponse = false;\n } else { // This is correct, we want to get 401 to get www-authenticate headers if using web password\n self.status(self.STATUS_WARNING, \"Logging in...\");\n self.auth.wwwAuthenticate = result.response.headers['www-authenticate']; // Store www-authenticate headers\n\n // Second request, this time we add the \"Authorization\" header\n self.system.emit('rest_get', url, function (err, result) {\n if(self.active) { // Prevent response handling if instance have been disabled while waiting for a response\n if (err !== null) { // Something really bad happened, mainly an ECONNREFUSED if NDI Studio Monitor has been closed or became unreachable after the first connection\n self.status(self.STATUS_ERROR, result.error.code);\n self.log('error', 'Connection failed (' + result.error.code + ')');\n self.retryConnection();\n }\n else {\n self.waitingForResponse = false;\n if(result.response.statusCode == 401) { // Login failed, username and password are wrong\n self.status(self.STATUS_ERROR, \"Login failed, wrong username or password\");\n self.log('error', 'Login failed, wrong username or password');\n } else if(result.response.statusCode == 200) { // Login success\n self.status(self.STATUS_OK);\n if(!isNDIStudioMonitorResponse(result.data)) { // Check if the response if from NDI Studio Monitor\n self.log('warn', 'Unespected response after connection'); // We can't be 100% sure so just put a warn in the log\n }\n self.startPolling(); // Start to poll for sources, configuration and recording status\n } else { // This is unespected\n self.status(self.STATUS_ERROR, \"Unespected HTTP status code: \" + result.response.statusCode);\n self.log('error', \"Unespected HTTP status code: \" + result.response.statusCode);\n self.retryConnection();\n }\n }\n } else { // Instance has been disabled, \"fail\" silently\n self.waitingForResponse = false;\n }\n }, {\n // Extra headers for rest_get\n Authorization: self.getDigestAuthHeader(result.response.req.method, result.response.req.path, self.auth.wwwAuthenticate, self.auth.userpass)\n });\n }\n } else { // This is unespected\n self.status(self.STATUS_ERROR, \"Unespected HTTP status code: \" + result.response.statusCode);\n self.log('error', \"Unespected HTTP status code: \" + result.response.statusCode);\n self.retryConnection();\n }\n }\n } else { // Instance has been disabled, \"fail\" silently\n self.waitingForResponse = false;\n }\n });\n }", "title": "" }, { "docid": "e49c25b0c0446e7c2f7eb04b8952e17c", "score": "0.5149262", "text": "function keepAlive() {\n\t\tif(server === null || !websockets || !connected)\n\t\t\treturn;\n\t\twsKeepaliveTimeoutId = setTimeout(keepAlive, 30000);\n\t\tvar request = { \"janus\": \"keepalive\", \"session_id\": sessionId, \"transaction\": Janus.randomString(12) };\n\t\tif(token !== null && token !== undefined)\n\t\t\trequest[\"token\"] = token;\n\t\tif(apisecret !== null && apisecret !== undefined)\n\t\t\trequest[\"apisecret\"] = apisecret;\n\t\tws.send(JSON.stringify(request));\n\t}", "title": "" }, { "docid": "56af5b078cd5e4f3c2f46feda39ff87b", "score": "0.5141948", "text": "function keepAlive() {\nif(!server || !websockets || !connected)\nreturn;\nwsKeepaliveTimeoutId = setTimeout(keepAlive, keepAlivePeriod);\nvar request = { \"janus\": \"keepalive\", \"session_id\": sessionId, \"transaction\": Janus.randomString(12) };\nif(token)\nrequest[\"token\"] = token;\nif(apisecret)\nrequest[\"apisecret\"] = apisecret;\nws.send(JSON.stringify(request));\n}", "title": "" }, { "docid": "077c1dd8c4d6f375ae134d5e9be72166", "score": "0.5135524", "text": "function sendOutputAndCloseConnection(client, output, res) {\n\tif (output && res) {\n\t\tconsole.log(`========================\\nOUTPUT AS RECEIVED AND BEFORE SENDING\\n==================\\n`, output)\n\t\tres.json(output)\n\t}\n\n\t// close the database connection after sending the response\n\tclient.close()\n}", "title": "" }, { "docid": "d1df68bbde8fbd7342771ede6bc5e17d", "score": "0.5127757", "text": "function shutdown() {\r\n /* Current JSON structure:\r\n json.Time: Javascript time of the message {date().getTime()}\r\n json.Sender: Name of the sender\r\n json.Msg: Text of the message\r\n */\r\n //TODO: Update shut down JSON payload to match new format\r\n var time = new Date();\r\n var toSend = {\r\n \"Time\": time.getTime(),\r\n \"Sender\": users[0], //User ID 0 is Server Admin user\r\n \"Msg\": \"Server shutting down...\"\r\n };\r\n strSend = JSON.stringify(toSend);\r\n console.log('Shutting down server. Please wait...');\r\n server.connections.forEach(function (conn) {\r\n conn.sendText(strSend);\r\n conn.close();\r\n });\r\n process.exit();\r\n}", "title": "" }, { "docid": "cc7d0f8c057f6f8e3659adf9eac5bff1", "score": "0.51181835", "text": "function send_connection(data){\n msg = JSON.stringify({\n //session: session.id,\n date: Date.now(),\n type: \"connection\",\n value: data\n })\n wss.clients.forEach(function each(client) {\n client.send(msg);\n });\n}", "title": "" }, { "docid": "f1c8d22e9bde5f7e8c48e65a4923fb10", "score": "0.511496", "text": "scheduleRestart () {\n // We cannot restart while either watcher connection or GET query is still\n // in progress. We will get called again when either of them terminates.\n // TODO: How to terminate the watcher connection?\n // Now we simply rely on server to close the conn after timeout\n if (!this.objectStream && !this.getInProg) {\n if (!this.noRestart) {\n setTimeout(this.start.bind(this), 1000 * this.reconnectDelay);\n }\n }\n }", "title": "" }, { "docid": "6ef35ddc00ef0469f078bcb43667a77f", "score": "0.5107533", "text": "function sendString( data ) { // Send string - terminate sql connection\n\t\t\t\t\t\t\t\t\t\t\tRes.end( data );\n\t\t\t\t\t\t\t\t\t\t}", "title": "" }, { "docid": "13a70ea55156b5926f9df747aee11c91", "score": "0.50961834", "text": "function handle_request(req,res){\r\n\treq.parsed_url = url.parse(req.url,true);\r\n\t//console.log(\"Incomming request:( \"+req.method+\")\"+req.url);\r\n\t//console.log(req.parsed_url);\r\n\tvar core_url = req.parsed_url.pathname;\r\n\tif(req.method ==\"GET\")\r\n\t{\r\n\t\tif(core_url==\"/api/request\")\r\n\t\t{\r\n\t\t\tnew_con_req(req,res);\r\n\t\t}\r\n\r\n\t\telse if(core_url==\"/api/serverStatus\")\r\n\t\t{\r\n\r\n\t\t\tserver_status(function(con_detail){\r\n\t\t\t\tres.writeHead(200,{ \"Content-Type\" : \"application/json\"});\r\n\t\t\t\tres.end(JSON.stringify(con_detail)+\"\\n\");\r\n\t\t\t});\r\n\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\r\n\t\t\tres.end(\"Something is wrong with url\");\r\n\r\n\t\t}\r\n\t}\r\n\telse if(req.method==\"PUT\")\r\n\t{\r\n\r\n\t\tif(core_url==\"/api/kill\")\r\n\t\t{\r\n\t\t\t\r\n\t\t\tread_post_put_string(req,res,function (err,con_id) {\r\n\r\n\t\t\t\tconsole.log(\"Reading is done\");\r\n\t\t\t\tvar id = con_id.connId;\r\n\r\n\t\t\t\tif(!err)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\thandle_kill_request(id,function (err,status) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(err){\r\n\t\t\t\t\t\t\tres.writeHead(200,{ \"Content-Type\" : \"application/json\"});\r\n\t\t\t\t\t\t\tres.end(JSON.stringify({\"status\":err})+\"\\n\");\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\tres.writeHead(200,{ \"Content-Type\" : \"application/json\"});\r\n\t\t\t\t\t\t\tres.end(JSON.stringify({\"status\": status})+\"\\n\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\r\n\t\t\t\telse{\r\n\t\t\t\t\tres.writeHead(503,{ \"Content-Type\" : \"application/json\"});\r\n\t\t\t\t\tres.end(JSON.stringify({\"error\": err})+\"\\n\");\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}", "title": "" }, { "docid": "327c5b19e8a31516209c7fbccb7b86d9", "score": "0.5079651", "text": "function closeConnection(req, res, next) {\n req._rdbConn.close();\n}", "title": "" }, { "docid": "cd6d8b3b73b388fdf006495eee951172", "score": "0.5067649", "text": "resume() {\r\n this.server.listen(this.port, this.host);\r\n }", "title": "" }, { "docid": "0ca08aff51e0a9bb916e5b9e1f2ef4b5", "score": "0.5067438", "text": "function SendParameters()\r\n{\r\n if ( serverBusyFlag == true )\r\n {\r\n if ( refreshRetries == 0 )\r\n {\r\n refreshRetries = 1000;\r\n setTimeout(\"refreshCommand()\",10);\r\n }\r\n }\r\n else\r\n {\r\n serverBusyFlag = true;\r\n var commFrame = 1;\r\n // Serialize the parameters we were passed into an XML Packet\r\n var XMLPacket = Hash2XML(GenParams(SortParams(SendParameters.arguments)));\r\n Send(SendParameters.arguments[0], commFrame, XMLPacket);\r\n }\r\n}", "title": "" }, { "docid": "a8199c1a79491283c28f4045af9970b7", "score": "0.50670224", "text": "function update_connection(){\n \n $.post('ajax',{\n action: 'update_connection'\n },function(data){\n \n if(data == \"0\"){\n connection_lost();\n }\n });\n \n}", "title": "" }, { "docid": "6ef2a345a5d89cdb88735f4c674d4d22", "score": "0.5057802", "text": "end() {\n if (this.connection) {\n this.connection.end();\n this.connection = null;\n this.paths = [];\n }\n }", "title": "" }, { "docid": "9edeff6f002b87395eaa1b9c2b64c553", "score": "0.50494087", "text": "function refreshClients() {\n console.log(\"refreshing clients\");\n io.sockets.emit(\"refresh\");\n}", "title": "" }, { "docid": "37a100bccc813dc288397d0989e296c5", "score": "0.50492907", "text": "reset() {\n this.socket = this._newSocket();\n }", "title": "" }, { "docid": "e08a3e0f437e01efe85ff8132e83ab2f", "score": "0.5048976", "text": "function redisFlushall(req, res) {\n /*Grabs a Redis connection from the connection pull and runs Lua script to Delete data from Redis*/\n redisPools[masterClient.connectionOption.host][masterClient.connectionOption.port].getClient(function(client, done) {\n //redisPools[\"localhost\"][redisGetPort].getClient(function(client, done) {\n var scriptManager = new Scripto(client);\n scriptManager.loadFromFile(\"flushScript\", \"lua/flushall.lua\");\n scriptManager.run(\"flushScript\", [], [], function(err, result) {\n done();\n if (err) {\n console.log(err);\n res.send(err);\n return;\n } else {\n result = JSON.parse(result);\n res.send(result);\n }\n });\n });\n }", "title": "" }, { "docid": "093926fd41c65e975e0abbd165d233b6", "score": "0.5046556", "text": "disconnect() {}", "title": "" }, { "docid": "54e86991fe2b2fe5b8bf4d0ab9e7380d", "score": "0.50455236", "text": "close() {\n this._socketInstances.forEach(async (instance) => {\n if (instance.connected) {\n instance.connected = false;\n await instance.socket.close();\n for (let requestResolve of Object.values(instance.requestResolves)) {\n requestResolve.reject(new Error('MetaApi connection closed'));\n }\n instance.requestResolves = {};\n }\n });\n this._synchronizationListeners = {};\n this._latencyListeners = [];\n this._socketInstancesByAccounts = {};\n this._socketInstances = [];\n this._packetOrderer.stop();\n }", "title": "" }, { "docid": "8555b8771812d04c4c2813a0a0921041", "score": "0.5045399", "text": "function doBaseReset() {\n var resetRequest = {};\n resetRequest.resetID = \"RestRequest\";\n resetRequest.usr = user;\n resetRequest.r = roomNo;\n resetRequest.SN = seatNo;\n if (confirm(\"Do you want to Reset the base? One player form other team needs to do the same\")) {\n webSocket.send(JSON.stringify(resetRequest));\n }\n\n}", "title": "" }, { "docid": "fafacfd55cf84ec24c2b7df699f8e773", "score": "0.5042953", "text": "SOCKET_RECONNECT(state, count) {\n console.info(state, count)\n }", "title": "" }, { "docid": "e7775df67d53923b44122ebb2e19f6fe", "score": "0.5040373", "text": "shutdown() {\n return this._sendRequest('shutdown');\n }", "title": "" }, { "docid": "7d1d28ab3c197b6446dcc777c02f512d", "score": "0.5034675", "text": "function reloadXhr() {\n var corsUrl = schemeHostAndPort + '/wsapi/easyXDM/cors/';\n xhr = new easyXDM.Rpc({\n remote: corsUrl\n }, {\n remote: {\n request: {} // request is exposed by /cors/\n }\n });\n }", "title": "" }, { "docid": "d7a7bb1813fe7ffb19e654e2277f0237", "score": "0.50294495", "text": "function sendAllDataRefresh (request) {\n\t\tcompileFriendScheds(request.asker, function (usersArray) {\n\t\t\tsocket.emit(\"S2CcompiledFriendScheds\", {users: usersArray});\n\t\t\tconsole.log(\"Sent compiled friend schedules.\")\n\t\t});\n\t\tgetUserDataByPunName(request.asker, function (userObject) {\n\t\t\t// TODO - minor - switch from jtay20 requesting to view sched to Jason Tay requesting to view sched\n\t\t\tsocket.emit(\"S2CfollowRequests\", {followRequests: userObject.followRequests});\n\t\t\tconsole.log(\"Sent follow requests.\")\n\t\t});\n\t}", "title": "" }, { "docid": "dc78eca918e9a713e64402ff20f27183", "score": "0.5028184", "text": "function dispatch_request(options){\n //request options url path and etc\n // console.log(\"Sending request. Time: \" + Date.now())\n\n let req_headers = new Object();\n let header_array = options.header.split(\"\\r\\n\");\n for (i = 0; i < header_array.length - 1; i += 2)\n {\n req_headers[header_array[i]] = header_array[i+1];\n }\n\n let req_options = {\"host\":cmd_options.hostname, \"setHost\":false, \"path\":options.uri, \"method\":options.method, \"headers\":req_headers, \"port\":8080};\n let editable_options = {\n 'secure': options.secure,\n 'reqbody': options.reqbody,\n 'send_request': true\n };\n pre_request_hook(options, editable_options, req_options);\n\n if(editable_options.send_request === true) {\n //Select the correct request class\n let webreq = editable_options['secure'] ? https : http;\n req_options.port = editable_options['secure'] ? cmd_options.secure_port : cmd_options.port;\n req_options.headers.Host = cmd_options.hostname;\n let req;\n try {\n req = webreq.request(req_options, (res) => {\n // Code for testing\n // res.setEncoding(\"utf-8\")\n // res.on('data', (data)=>{/*console.log(data)*/})\n // res.on('end', ()=>{console.log(\"Finished streaming data for request response.\")})\n\n request_callback_hook(res);\n }); //Create the request\n\n if(editable_options['reqbody'] != \"\")\n req.write(options.reqbody);\n post_request_hook(req, options);\n req.end();\n } catch(err) {\n // console.log(err);\n }\n }\n }", "title": "" }, { "docid": "3a6b896b395aa3c46a2749a35a4c67a2", "score": "0.50273716", "text": "function quitManager() {\n connection.end();\n}", "title": "" }, { "docid": "b810f28e230133e38a5388e60f6890b8", "score": "0.5026374", "text": "function connectionListener(socket) {\n var that = this;\n\n socket.pendingData = \"\";\n console.log(\"NEW CONNECTION ESTABLISHED FROM \" + socket.remoteAddress + ':' + socket.remotePort);\n if (that.timeout) {\n socket.setTimeout(that.timeout);\n }\n socket.on('timeout', function() {\n var serverTimeout = that.emit('timeout', socket);\n if (!serverTimeout) { // no listeners for Server.timeout\n console.log(\"TIMEOUT OF CLIENT ON \" + this.remoteAddress);\n socket.end();\n }\n });\n\n socket.on('error', function socketOnError(e) {\n that.emit('clientError', e, socket);\n });\n \n socket.on('close', function () {\n console.log(\"CONNECTION OF CLIENT ENDED\");\n });\n \n var dataListener = function (data) {\n console.log(\"DATA RECEIVED FROM \" + socket.remoteAddress + ':' + socket.remotePort);\n handleRequest(data.toString(), socket);\n };\n \n socket.on('data', dataListener);\n\n var handleRequest = function (dataStr, socket) { \n console.log(\"HANDLING DATA FROM \" + socket.remoteAddress + ':' + socket.remotePort);\n try {\n var req = new ClientRequest(socket);\n var res = new ServerResponse(socket);\n\n var dataLeft = parser.parseHttpRequest(req, socket.pendingData + dataStr);\n \n var shouldKeepAlive = isPersistentConnection(req);\n res.shouldKeepAlive = shouldKeepAlive;\n \n socket.pendingData = \"\";\n that.emit('request', req, res);\n \n if (!shouldKeepAlive) {\n socket.removeListener(\"data\", dataListener);\n return;\n }\n \n // Try to handle the data left in the data string (Excluding the http request that have been parsed and handled)\n if (dataLeft) {\n handleRequest(dataLeft, socket);\n }\n \n } catch (e) {\n if (e instanceof parser.NotHttpRequest) {\n res.writeError(500);\n } else if (e instanceof parser.PartialHttpRequest) {\n socket.pendingData += dataStr;\n } else if (e instanceof parser.UsupportedHttpMethod) {\n res.writeError(405);\n }\n } \n };\n}", "title": "" }, { "docid": "73b8d9a54afd59efc000ea7c9b3a0f2b", "score": "0.50254136", "text": "addRequest(req, _opts) {\n const ownOpts = Object.assign({}, _opts);\n if (typeof ownOpts.secureEndpoint !== 'boolean') {\n ownOpts.secureEndpoint = isSecureEndpoint();\n }\n // Set default `host` for HTTP to localhost\n if (ownOpts.host == null) {\n ownOpts.host = 'localhost';\n }\n // Set default `port` for HTTP if none was explicitly specified\n if (ownOpts.port == null) {\n ownOpts.port = ownOpts.secureEndpoint ? 443 : 80;\n }\n const opts = Object.assign(Object.assign({}, this.options), ownOpts);\n if (opts.host && opts.path) {\n // If both a `host` and `path` are specified then it's most likely the\n // result of a `url.parse()` call... we need to remove the `path` portion so\n // that `net.connect()` doesn't attempt to open that as a unix socket file.\n delete opts.path;\n }\n delete opts.agent;\n delete opts.hostname;\n delete opts._defaultAgent;\n delete opts.defaultPort;\n delete opts.createConnection;\n // Hint to use \"Connection: close\"\n // XXX: non-documented `http` module API :(\n req._last = true;\n req.shouldKeepAlive = false;\n // Create the `stream.Duplex` instance\n let timedOut = false;\n let timeout = null;\n const timeoutMs = this.timeout;\n const freeSocket = this.freeSocket;\n function onerror(err) {\n if (req._hadError)\n return;\n req.emit('error', err);\n // For Safety. Some additional errors might fire later on\n // and we need to make sure we don't double-fire the error event.\n req._hadError = true;\n }\n function ontimeout() {\n timeout = null;\n timedOut = true;\n const err = new Error(`A \"socket\" was not created for HTTP request before ${timeoutMs}ms`);\n err.code = 'ETIMEOUT';\n onerror(err);\n }\n function callbackError(err) {\n if (timedOut)\n return;\n if (timeout !== null) {\n clearTimeout(timeout);\n timeout = null;\n }\n onerror(err);\n }\n function onsocket(socket) {\n let sock;\n function onfree() {\n freeSocket(sock, opts);\n }\n if (timedOut)\n return;\n if (timeout != null) {\n clearTimeout(timeout);\n timeout = null;\n }\n if (isAgentBase(socket) || isHttpAgent(socket)) {\n // `socket` is actually an `http.Agent` instance, so\n // relinquish responsibility for this `req` to the Agent\n // from here on\n socket.addRequest(req, opts);\n return;\n }\n if (socket) {\n sock = socket;\n sock.on('free', onfree);\n req.onSocket(sock);\n return;\n }\n const err = new Error(`no Duplex stream was returned to agent-base for \\`${req.method} ${req.path}\\``);\n onerror(err);\n }\n if (typeof this.callback !== 'function') {\n onerror(new Error('`callback` is not defined'));\n return;\n }\n if (!this.promisifiedCallback) {\n if (this.callback.length >= 3) {\n // Legacy callback function - convert to a Promise\n this.promisifiedCallback = promisify_1.default(this.callback);\n }\n else {\n this.promisifiedCallback = this.callback;\n }\n }\n if (typeof timeoutMs === 'number' && timeoutMs > 0) {\n timeout = setTimeout(ontimeout, timeoutMs);\n }\n if ('port' in opts && typeof opts.port !== 'number') {\n opts.port = Number(opts.port);\n }\n try {\n Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);\n }\n catch (err) {\n Promise.reject(err).catch(callbackError);\n }\n }", "title": "" }, { "docid": "4c2f700556eaa745139d6c0b250cd428", "score": "0.50160444", "text": "function startResponse( cb ) { \n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t @private\n\t\t\t\t\t\t\t\t @method startResponse\n\t\t\t\t\t\t\t\t Start a session by attaching sql, cert, client, profile and session info to this request req with callback res(error). \n\t\t\t\t\t\t\t\t @param {Object} req request\n\t\t\t\t\t\t\t\t @param {Function} res response\n\t\t\t\t\t\t\t\t * */\n\t\t\t\t\t\t\t\t\tfunction res(data) { // Session response callback\n\n\t\t\t\t\t\t\t\t\t\t// Session terminators respond with a string, file, db structure, or error message.\n\n\t\t\t\t\t\t\t\t\t\tfunction sendString( data ) { // Send string - terminate sql connection\n\t\t\t\t\t\t\t\t\t\t\tRes.end( data );\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tfunction sendFile(path,file,type,area) { // Cache and send file to client - terminate sql connection\n\n\t\t\t\t\t\t\t\t\t\t\t// Trace(`SENDING ${path}`);\n\n\t\t\t\t\t\t\t\t\t\t\tvar \n\t\t\t\t\t\t\t\t\t\t\t\tcache = TOTEM.cache,\n\t\t\t\t\t\t\t\t\t\t\t\tnever = cache.never,\n\t\t\t\t\t\t\t\t\t\t\t\tcache = (never[file] || never[type]) ? {} : cache[area] || cache[type] || {};\n\n\t\t\t\t\t\t\t\t\t\t\t//Log(path, cache[path] ? \"cached\" : \"!cached\");\n\n\t\t\t\t\t\t\t\t\t\t\tif ( buf = cache[path] )\n\t\t\t\t\t\t\t\t\t\t\t\tsendString( buf );\n\n\t\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\t\tFS.readFile( path, (err,buf) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (err)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendError( errors.noFile );\n\n\t\t\t\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendString( cache[path] = new Buffer(buf) );\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\t\t\n\n\t\t\t\t\t\t\t\t\t\tfunction sendError(err) { // Send pretty error message - terminate sql connection\n\t\t\t\t\t\t\t\t\t\t\tswitch ( req.type ) {\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"html\":\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"db\":\n\t\t\t\t\t\t\t\t\t\t\t\t\tRes.end( errors.pretty(err) );\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\t\t\t\tRes.end( err+\"\" );\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tfunction sendObject(obj) {\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\tsendString( JSON.stringify(obj) );\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tcatch (err) { // infinite cycle\n\t\t\t\t\t\t\t\t\t\t\t\tsendError( errors.badReturn );\n\t\t\t\t\t\t\t\t\t\t\t}\t\t\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tfunction sendRecords(recs) { // Send records via converter\n\t\t\t\t\t\t\t\t\t\t\tif ( route = filterRecords[req.type] ) // process record conversions\n\t\t\t\t\t\t\t\t\t\t\t\troute(recs, req, recs => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (recs) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tswitch ( typeOf(recs) ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase \"Error\":\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendError( recs );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase \"String\":\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendString( recs );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase \"Array\":\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase \"Object\":\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendObject( recs );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t} \n\n\t\t\t\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendError( errors.badReturn );\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\telse \n\t\t\t\t\t\t\t\t\t\t\t\tsendObject( recs );\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tvar\n\t\t\t\t\t\t\t\t\t\t\treq = Req.req,\n\t\t\t\t\t\t\t\t\t\t\tsql = req.sql,\n\t\t\t\t\t\t\t\t\t\t\tmimes = MIME.types,\n\t\t\t\t\t\t\t\t\t\t\tmime = mimes[ isError(data||0) ? \"html\" : req.type ] || mimes.html;\n\n\t\t\t\t\t\t\t\t\t\t// set appropriate headers to prevent http-parse errors when using master-worker proxy\n\t\t\t\t\t\t\t\t\t\tif ( req.encrypted )\n\t\t\t\t\t\t\t\t\t\t\tRes.setHeader(\"Set-Cookie\", [\"client=\"+req.client, \"service=\"+TOTEM.host.name] );\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t\t\tRes.setHeader(\"Content-Type\", mime);\n\t\t\t\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t\t\t\tRes.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n\t\t\t\t\t\t\t\t\t\tRes.setHeader(\"Access-Control-Allow-Methods\", \"GET, POST, PUT, DELETE, OPTIONS\");\n\t\t\t\t\t\t\t\t\t\tRes.setHeader(\"Access-Control-Allow-Headers\", '*');\n\t\t\t\t\t\t\t\t\t\tRes.setHeader(\"Status\", \"200 OK\");\n\t\t\t\t\t\t\t\t\t\tRes.setHeader(\"Vary\", \"Accept\");\n\t\t\t\t\t\t\t\t\t\t//self.send_header('Content-Type', 'application/octet-stream')\n\t\t\t\t\t\t\t\t\t\t*/\n\n\t\t\t\t\t\t\t\t\t\tRes.statusCode = 200;\n\n\t\t\t\t\t\t\t\t\t\tif (data != null)\n\t\t\t\t\t\t\t\t\t\t\tswitch ( typeOf(data) ) { // send based on its type\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"Error\": \t\t\t// send error message\n\t\t\t\t\t\t\t\t\t\t\t\t\tsendError( data );\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"Function\": \t\t\t// send file (search or direct)\n\t\t\t\t\t\t\t\t\t\t\t\t\tsendFile( data(), req.file, req.type, req.area );\n\t\t\t\t\t\t\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t\t\t\t\t\t\tif ( (search = req.query.search) && paths.mysql.search) \t\t// search for file via (e.g. nlp) score\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsql.query(paths.mysql.search, {FullSearch:search}, (err, files) => {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (err) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendError( errors.noFile );\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendError( errors.noFile ); // reserved functionality\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\t\t\telse {\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif ( credit = paths.mysql.credit) // credit/charge client when file pulled from file system\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsql.query( credit, {Name:req.node,Area:req.area} )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.on(\"result\", file => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (file.Client != req.client)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsql.query(\"UPDATE openv.profiles SET Credit=Credit+1 WHERE ?\",{Client: file.Client});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsendFile( data(), req.file, req.type, req.area );\n\t\t\t\t\t\t\t\t\t\t\t\t\t} */\n\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"Array\": \t\t\t// send data records \n\t\t\t\t\t\t\t\t\t\t\t\t\tsendRecords(data);\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"String\": \t\t\t// send message\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"Buffer\":\n\t\t\t\t\t\t\t\t\t\t\t\t\tsendString(data);\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase \"Object\":\n\t\t\t\t\t\t\t\t\t\t\t\tdefault: \t\t\t\t\t// send data record\n\t\t\t\t\t\t\t\t\t\t\t\t\tsendObject(data);\n\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\tsendError( errors.noData );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (sock = req.reqSocket )\t// have a valid request socket so ....\n\t\t\t\t\t\t\t\t\t\tvalidateClient(req, err => {\n\t\t\t\t\t\t\t\t\t\t\tif (err)\n\t\t\t\t\t\t\t\t\t\t\t\tres(err);\n\n\t\t\t\t\t\t\t\t\t\t\telse \n\t\t\t\t\t\t\t\t\t\t\tif ( getSession = paths.mysql.getSession )\n\t\t\t\t\t\t\t\t\t\t\t\treq.sql.query(getSession, {Client: req.client}, (err,ses) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif ( err )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tres(err);\n\n\t\t\t\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treq.session = new Object( ses[0] || {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tClient: \"[email protected]\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tConnects: 1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//ipAddress : \"unknown\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLocation: \"unknown\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tJoined: new Date()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcb( res );\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\telse { // using dummy sessions\n\t\t\t\t\t\t\t\t\t\t\t\treq.session = {};\n\t\t\t\t\t\t\t\t\t\t\t\tcb( res );\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\telse \t// lost reqest socket for some reason so ...\n\t\t\t\t\t\t\t\t\t\tres( errors.lostConnection );\n\t\t\t\t\t\t\t\t}", "title": "" }, { "docid": "3c02be3cf1d55906e0fae24a07a3e693", "score": "0.50137633", "text": "Send() {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.client.write(Buffer.from(this.data), 'utf8');\n\t\t\t// callback when we get answer\n\t\t\tthis.client.on('data', data => { \n\t\t\t\tthis.client.destroy(); \n\t\t\t\treturn resolve(data); \n\t\t\t});\n\t\t\t// if error handler\n\t\t\tthis.client.on('error', data => {\n\t\t\t\tthis.client.destroy(); \n\t\t\t\treturn reject('Error: Cannot connect to server!');\n\t\t\t});\t\t\t\n\t\t});\n\t}", "title": "" }, { "docid": "6bc20cb933736f007a564cdbfddf3dbb", "score": "0.5012873", "text": "request_server_info() {\n const message = message_1.Message.create('SERVER-INFO-REQ', {});\n const promise = this._connection.send_with_reply(message);\n return promise.then((reply) => reply.content);\n }", "title": "" }, { "docid": "9a88e9be09eaead80e68155d44b443fd", "score": "0.5009624", "text": "signal() {\n const wrtcSettings = this.settings;\n const uri = wrtcSettings.uri;\n //a timeout can occure while the datachannel is estabilishing the connection.\n //if already connected, dont restart negociation \n if (this.lastState == 'connected' && this.channel.readyState == 'open')\n return;\n if (this.channel) {\n this.channel.close();\n this.lastState = 'retry';\n }\n if (this.remainingRetries <= 0) {\n this.tSocket.emit('close');\n return;\n }\n this.remainingRetries--;\n this.makeOffer().then((pc) => {\n if (Util.isNodejs) {\n const url = require(\"url\");\n const postDataObj = {};\n postDataObj[Protocol.signal] = JSON.stringify(pc.localDescription);\n const post_data = qs.stringify(postDataObj);\n const parsedURI = url.parse(uri);\n const post_options = {\n host: parsedURI.hostname,\n port: parsedURI.port,\n path: '/wrtc-' + wrtcSettings.prefix,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'Content-Length': post_data.length\n }\n };\n const post_req = http.request(post_options, (res) => {\n res.setEncoding('utf8');\n res.on('data', (chunk) => {\n const resp = JSON.parse(chunk);\n this.getAnswer(resp[Protocol.signal]);\n this.remainingRetries = wrtcSettings.retries;\n });\n });\n post_req.write(post_data);\n post_req.end();\n post_req.on('error', (error) => {\n setTimeout(() => this.signal(), 3000);\n });\n //\n }\n else {\n const xhr = new XMLHttpRequest();\n const params = Protocol.signal + '=' + JSON.stringify(pc.localDescription);\n const parser = document.createElement('a');\n parser.href = uri;\n xhr.open(\"POST\", '//' + parser.hostname + ':' + parser.port + '/wrtc-' + wrtcSettings.prefix, true);\n //Send the proper header information along with the request\n xhr.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\n //xhr.setRequestHeader(\"Content-length\", params.length.toString());\n //xhr.setRequestHeader(\"Connection\", \"close\");\n xhr.onreadystatechange = () => {\n if (xhr.readyState == 4 && xhr.status == 200) {\n const resp = JSON.parse(xhr.responseText);\n this.getAnswer(resp[Protocol.signal]);\n this.remainingRetries = wrtcSettings.retries;\n }\n else {\n if (xhr.readyState == 4 && xhr.status != 200) {\n setTimeout(() => this.signal(), 3000);\n }\n }\n };\n xhr.send(params);\n }\n this.tSocket.update(this.channel);\n })\n .catch((error) => this.tSocket.emit('error', error));\n }", "title": "" }, { "docid": "c2acefedebff052ebe40081b6709237c", "score": "0.5008063", "text": "function keepalive () {\n conn && settings.keepAlive.val && conn.sendText(\"IDLE\");\n setTimeout(keepalive, settings.keepAliveTime.val*1000.0);\n}", "title": "" }, { "docid": "e93a94e79d1eecfca29efa88edf9dc70", "score": "0.50046545", "text": "function complete(){\n\tres.send(context);\n\tres.end();\n }", "title": "" }, { "docid": "7f26ef53928c865ae845ef8a09e20465", "score": "0.5000848", "text": "function TestServer () {\n coap.createServer(function (req, res) {\n console.log(\"Got request. Waiting 500ms\");\n setTimeout(() => {\n res.setOption('Block2', new Buffer([0x6]))\n console.log(\"Sending Back Test Buffer\")\n res.end(testBuffer)\n console.log(\"Sent Back\")\n }, 500);\n }).listen()\n}", "title": "" }, { "docid": "df294bd0836c402a281dd3e868577c9d", "score": "0.49995935", "text": "function onclose() {\n onerror(\"socket closed\");\n }", "title": "" }, { "docid": "37a10776b4ce80096b9c5273631d4adb", "score": "0.4999138", "text": "function updateConnection(e) {\n self.updateConnection(e.context);\n }", "title": "" }, { "docid": "f73494abd0cbb9c9fe640d14f0d4cc26", "score": "0.4997996", "text": "close(){\n this.conn.close();\n this.conn = null;\n this.connected = false;\n }", "title": "" }, { "docid": "fc263294675c912eb9fc2151a078ae58", "score": "0.49951148", "text": "function onConnection(sock){\n\t\tconsole.log('rifle_socket :: onConnection');\n\t\tsocket = sock;\n\t\tsocket.on('refresh-request', onRefreshRequest);\n\t}", "title": "" }, { "docid": "b3c20a92fde1fb119789c53f7089edb2", "score": "0.49896696", "text": "function sendRequest(type, options) {\n\t // Both remove and removeAll use the type 'remove' in the protocol\n\t var normalizedType = type === 'removeAll' ? 'remove' : type;\n\t return socket.hzRequest({ type: normalizedType, options: options }) // send the raw request\n\t .takeWhile(function (resp) {\n\t return resp.state !== 'complete';\n\t });\n\t }", "title": "" }, { "docid": "5565bb57e7993e6b6eebc1824126890b", "score": "0.49895334", "text": "function sendRequest() {\r\n // reset _remainingRetries\r\n _remainingRetries = _parameters.retryCount;\r\n\r\n // call _ajaxProcessor.request\r\n _ajaxProcessor.request(_parameters);\r\n }", "title": "" }, { "docid": "7a163a8a22c4090c513cef4f7cfa9e20", "score": "0.49830487", "text": "sendData(data) {\n const self = this\n if (self.connection.readyState === self.connection.OPEN) {\n self.connection.send(JSON.stringify(data))\n } else {\n self.connection.onopen = () => {\n self.connection.send(JSON.stringify(data))\n }\n }\n }", "title": "" }, { "docid": "570743da5bb0b0e38e1dc146907629d1", "score": "0.4980301", "text": "function onclose() {\r\n onerror(\"socket closed\");\r\n }", "title": "" }, { "docid": "4f39633829d9f39a8d8b95e8220c8051", "score": "0.49770778", "text": "function sendResponse() {\r\n // wait till everybody is finished\r\n if (successes.length + errors.length < serverMethodsMap.length) {\r\n return;\r\n }\r\n // Execute the \"success\" callback\r\n if (successes.length !== 0) {\r\n var result = successes.reduce(function (obj, success) {\r\n obj.method = success.method;\r\n obj.called_with = success.called_with;\r\n obj.returned = success.returned;\r\n obj.all_return_values.push({\r\n executed_by: success.executed_by,\r\n returned: success.returned\r\n });\r\n obj.executed_by = success.executed_by;\r\n return obj;\r\n }, { all_return_values: [] });\r\n\r\n // If we get errors from one of the getServers add them to the success object that will be resolved.\r\n if (errors.length !== 0) {\r\n result.all_errors = [];\r\n errors.forEach(function (obj) {\r\n result.all_errors.push({\r\n // executed_by : obj.executed_by, // we don't get executed_by object from the error clientInvocations\r\n name: obj.method.name,\r\n message: obj.message\r\n });\r\n });\r\n }\r\n\r\n success(result);\r\n\r\n } else if (errors.length !== 0) { // Execute the \"error\" callback\r\n error(errors.reduce(function (obj, error) {\r\n obj.method = error.method;\r\n obj.called_with = error.called_with;\r\n obj.message = error.message;\r\n obj.all_errors.push({\r\n executed_by: error.executed_by,\r\n message: error.message\r\n });\r\n // obj.executed_by = success.executed_by;\r\n return obj;\r\n }, { all_errors: [] }));\r\n }\r\n }", "title": "" }, { "docid": "387ce88b8afb2eaa8cc6c1728935b003", "score": "0.4975405", "text": "function keepAlive() {\n $.ajax({\n url: \"../../webapi/records/keepalive\",\n type: \"POST\",\n dataType: \"text\",\n contentType: \"text/plain\",\n cache: false,\n data: \"keep-alive\",\n success: function(data) {\n //console.log(\"Success: \" + data);\n },\n error: function(xhr, status, error) {\n showError(msg.obs_errorKeepAliveFailed + \": \" + error);\n }\n });\n}", "title": "" }, { "docid": "abad2b91d4a06cf8b0e494c3be2d92a1", "score": "0.49753857", "text": "setupRESTServer() {\n return new Promise((resolv, reject) => {\n app.get('/ssg_peerid', (req, res) => {\n res.send(this.skyway.myPeerid)\n })\n\n // /stream/:handle_id?method=[start|stop]&src=${src_peerid}\n app.get('/stream/:handle_id', (req, res) => {\n const handle_id = req.params.handle_id\n const method = req.query.method\n const src = req.query.src\n\n if( !handle_id.match(/^[0-9a-fA-F]{16}$/) || !((method===\"start\" && src.length > 4) || (method === \"stop\")) ){\n let message = \"invalid queries: \" + JSON.stringify({handle_id, method, src})\n logger.warn(message)\n res.status(400).send(message)\n\n return\n }\n\n switch(method) {\n case 'start':\n this.startStreaming(handle_id, src)\n break;\n case 'stop':\n this.stopStreaming(handle_id)\n break;\n default:\n }\n\n res.send('ok')\n })\n\n app.get('/room/:name', (req, res) => {\n const method = req.query.method\n const name = req.params.name\n\n if(!method.match(/^(join|leave)$/) || !(name.length > 2)) {\n let mesg = 'invalid queries: ' + JSON.stringify({method, name})\n logger.warn(mesg)\n res.status(400).send(mesg)\n return\n }\n\n switch(method) {\n case 'join':\n this.skyway.sendRoomJoin(name)\n break\n case 'leave':\n this.skyway.sendRoomLeave(name)\n break\n default:\n break\n }\n\n res.send('ok')\n })\n\n app.delete('/connection/:peerid', (req, res) => {\n const peerid = req.params.peerid\n\n this.ssgStore.dispatch(removeConnection(peerid))\n res.send('ok')\n })\n\n app.get('/connections', (req, res) => {\n const {connections} = this.ssgStore.getState().sessions\n res.json(connections)\n })\n\n app.get('/connection/:id', (req, res) => {\n const id = req.params.id\n const {connections} = this.ssgStore.getState().sessions\n\n res.json(connections[id])\n })\n\n app.listen(this.ports.SIGNALING_CONTROLLER, () => {\n logger.info(`start REST Server on port ${this.ports.SIGNALING_CONTROLLER}`)\n resolv()\n }).on('error', err => reject(err))\n })\n }", "title": "" }, { "docid": "bc8d35924b4d93b2af86d58f6db93f02", "score": "0.49746183", "text": "function secureClose(conn) {\n if (conn.readyState === 1 || conn.readyState === 2) {\n conn.close();\n }\n}", "title": "" }, { "docid": "26cceb3f6165ea6062c2f05607f5f61c", "score": "0.49720952", "text": "function commit() {\n container.proxy.reqBuilder.host = parsedHost.host;\n container.proxy.reqBuilder.port = container.options.port || parsedHost.port;\n container.proxy.requestModule = parsedHost.module;\n resolve(container);\n }", "title": "" }, { "docid": "34792e172c538618356e53b33f3b5387", "score": "0.49718264", "text": "disconnect() { }", "title": "" }, { "docid": "d5d8009f950ea6e256390efaaa6aa170", "score": "0.4971794", "text": "async function declineRequest() {\n await socket.emit('declineConnectionReq', {\n me: document.getElementById('me').value,\n them: document.getElementById('them').value\n });\n document.getElementById('_refuse').click();\n}", "title": "" }, { "docid": "5f6f2db2034d9e51e98b6dcf2d5eec42", "score": "0.49693054", "text": "SOCKET_RECONNECT(state, count) {\n //window.console.info(\"ws reconnect: \", state, count)\n if (count < 10) {\n window.console.info('ws reconnect attempt: #', count);\n state.socket.isConnected = false;\n }\n else {\n window.location.reload();\n }\n }", "title": "" }, { "docid": "c735df7753e410a9fc4b9d9d6016408f", "score": "0.4964498", "text": "async function SMServerFetch(path, indata, emptyResponseIsOk) {\n var SERVER_IP = await SettingsManager.readSetting(\"SMSERVER_IP\");\n var SERVER_PORT = await SettingsManager.readSetting(\"SMSERVER_PORT\");\n var SERVER_PASSWORD = await SettingsManager.readSetting(\"SMSERVER_PASSWORD\");\n var Log = new LogLib.Log(\"SMServerAPI.js\",\"SMServerFetch\");\n //TODO: DEAL WITH RESPONSE CODES AS OUTLINED IN SMSERVER API\n //TODO: HANDLE ECONNRESET: Error: socket hang up\n\n //TODO: Check if SMServer certificate stays the same across installs?\n //Not sure if the Node version on Cydia supports fetch, so we're writing our own fetch function!\n //TODO: If we get ECONNRESET, wait and try again\n\n path += \"?\";\n for (property in indata) {\n if (indata.hasOwnProperty(property)) {\n path += property + \"=\" + encodeURIComponent(indata[property]) + \"&\";\n // console.log(property);\n }\n }\n path = path.slice(0, -1); //Removes the \"&\" from the end\n\n var makeRequest = function(path) {\n return new Promise((resCb, rejCb) => {\n Log.v(\"Making request to \"+path);\n var options = {\n host: SERVER_IP,\n port: SERVER_PORT,\n path: path\n };\n\n callback = function(response) {\n var str = '';\n\n //another chunk of data has been received, so append it to `str`\n response.on('data', function (chunk) {\n str += chunk;\n });\n\n //the whole response has been received, so we just print it out here\n response.on('end', function () {\n Log.v(\"Request finished successfully, parsing...\");\n var responseIsEmpty = (str == \"\" || str == undefined);\n // Log.w(\"Response is empty: \"+responseIsEmpty);\n if (emptyResponseIsOk && responseIsEmpty) {\n resCb({});\n return; //Stops evaluating errors\n } else {\n try {\n var parsed = JSON.parse(str);\n resCb(parsed);\n } catch (err) {\n Log.e(\"Couldn't parse JSON: \"+str);\n //TODO: Test what happens if the password is wrong and handle that error\n rejCb(\"Error: Couldn't parse JSON: \"+parsed);\n }\n }\n });\n }\n\n\n //There's no way SMServer has a signed certificate, so this is used to disable certificate checking.\n //SMServer doesn't work on HTTP for some reason, so we must deal with its self-signed cert.\n //This would be really dangerous, but seeing as we're only talking to localhost there's not much that can MITM this.\n\n var req = https.request(options, callback);\n req.end();\n req.on('error', function(e) {\n if (emptyResponseIsOk) {\n //do nothing\n } else {\n rejCb(e);\n }\n });\n });\n }\n\n var response = null;\n var requestSuccessful = false;\n for (var i = 0; i < 5; i++) {\n try {\n var response_try = await makeRequest(path);\n response = response_try;\n requestSuccessful = true;\n break;\n } catch (err) {\n if (err.code == \"ECONNREFUSED\") {\n Log.w(\"Connection to \"+SERVER_IP+\" was refused. SMServer could be busy or offline. Retrying in 5s...\")\n } else {\n Log.e(err+\". Retrying in 5s...\");\n }\n }\n }\n if (!requestSuccessful) {\n Log.e(\"Request was unsuccessful after trying multiple times. See above warning for details\");\n throw \"Request unsuccessful\";\n }\n // return await makeRequest(path);\n return response;\n}", "title": "" }, { "docid": "dfe961c76457e11a343151c75333e7ba", "score": "0.49621838", "text": "function disconnect() {\n if (obj.authenticated == 3) { obj.parent.ClearPeerServer(obj, obj.peerServerId); obj.authenticated = 0; }\n if ((obj.connectionState == 15) && (obj.connectHandler != null)) { obj.connectHandler(0); }\n if (obj.ws != null) { obj.ws.close(); obj.ws = null; }\n if (obj.retryTimer != null) { clearTimeout(obj.retryTimer); obj.retryTimer = null; }\n // Re-try connection\n if (obj.connectionState >= 1) { obj.connectionState = 1; if (obj.retryTimer == null) { obj.retryTimer = setTimeout(connect, getConnectRetryTime()); } }\n }", "title": "" }, { "docid": "d9339afcfcca9f04b5f6dea72769cf29", "score": "0.4959483", "text": "function connessioneClient() {\n if (statoConn == 0) { \n client.connect(port, host, function () {\n statoConn = 1;\n ee.emit('Logga', 'Connessione', 'Connesso al Server Raspberry');\n })\n }\n}", "title": "" }, { "docid": "c17f8391832414d151e22c2c2b84261b", "score": "0.49549493", "text": "SOCKET_RECONNECT(state, count) {\n console.info(state, count);\n }", "title": "" }, { "docid": "c42fc7570cdd99d9dbb26a66ebc1f09c", "score": "0.49536833", "text": "flushEvents() {\n this.notSent = this.notSent.concat(this.activeChanges);\n this.activeChanges = [];\n this.updateServer_();\n }", "title": "" } ]
21451ebc2076abe5a163b78677ff0c3f
Renders content based on which payment type is choosen
[ { "docid": "e1d2e766e5fc21eb8598959a388cca53", "score": "0.6714128", "text": "function onPaymentTypeChange(e) {\n\n let exMonth = docDotQS(\".expiration-box\");\n let exYear = docDotQS(\".credit-card-box\");\n let paypalbox = docDotQS(\"#paypal\");\n let bitcoinbox = docDotQS(\"#bitcoin\");\n\n // If credit card chosen\n if (e.target.value === \"credit-card\") {\n exMonth.style.display = \"\";\n exYear.style.display = \"\";\n paypalbox.style.display = \"none\";\n bitcoinbox.style.display = \"none\";\n\n } else {\n\n exMonth.style.display = \"none\";\n exYear.style.display = \"none\";\n \n // If paypal chosen\n if (e.target.value === \"paypal\") {\n paypalbox.style.display = \"\";\n bitcoinbox.style.display = \"none\";\n } else {\n // If bitcoin chosen\n paypalbox.style.display = \"none\";\n bitcoinbox.style.display = \"\"\n }\n }\n}", "title": "" } ]
[ { "docid": "83e7d543fa589a5abc738bab825f7199", "score": "0.6767057", "text": "function displayPaymentInfo(paymentMethod) {\n if (paymentMethod == 'Credit Card') {\n document.querySelector('#credit-card').style.display = 'block';\n paypal.style.display = 'none';\n bitcoin.style.display = 'none';\n } else if (paymentMethod == 'PayPal') {\n document.querySelector('#credit-card').style.display = 'none';\n paypal.style.display = 'block';\n bitcoin.style.display = 'none';\n } else if (paymentMethod == 'Bitcoin') {\n document.querySelector('#credit-card').style.display = 'none';\n paypal.style.display = 'none';\n bitcoin.style.display = 'block';\n } else if (paymentMethod == 'Select Payment Method') {\n document.querySelector('#credit-card').style.display = 'none';\n paypal.style.display = 'none';\n bitcoin.style.display = 'none';\n }\n}", "title": "" }, { "docid": "02c52dde06ce938b56577b189bad4adf", "score": "0.65593016", "text": "renderBasedOnType() {\r\n switch (this.type) {\r\n case 'audio':\r\n return this.renderAudioCard();\r\n default:\r\n return this.renderBase();\r\n }\r\n }", "title": "" }, { "docid": "ba870d5a22178728027e48fbf4b393f4", "score": "0.6361743", "text": "function paymentType(mofPayment){\n\tdocument.getElementById(\"termsDiv\").style.display=\"flex\";\n\ttype = mofPayment;\n\tif(document.getElementById(\"termsCheck\").checked != false){\n\t\tdocument.getElementById('confirmBtn').style.display='block';\n\t}\n\telse{\n\t\tdocument.getElementById('confirmBtn').style.display='none';\n\t}\n}", "title": "" }, { "docid": "445b763d02646ef7faba6229f809af80", "score": "0.6289684", "text": "function displayPaymentDetails(){\n if ($(\"#payment\").val() === \"credit card\") {creditCardPayment.show()}\n else creditCardPayment.hide();\n if ($(\"#payment\").val() === \"paypal\") {payPalPayment.show()}\n else payPalPayment.hide();\n if ($(\"#payment\").val() === \"bitcoin\") {bitcoinPayment.show()}\n else bitcoinPayment.hide();\n}", "title": "" }, { "docid": "ca3489947545c696289faa5b54e509bb", "score": "0.62117755", "text": "function show_payment_method_page_content() {\n\tif (checksameurl(location.href, payment_methods_page) == true && payment_methods_auto_content == true) {\n\t\tdocument.write('<h6>' + translate_sentence('How can I pay?') + '</h6>');\n\t\tdocument.write(translate_sentence('You can pay on checkout when you add your product to shopping cart. We have two methods: Credit card and Paypal') + '. ');\n\t\tdocument.write('<br/><br/><h6>' + translate_sentence('What credit cards do we accept?') + '</h6>');\n\t\tdocument.write(translate_sentence('We accept the credit cards most used') + ': ' + translate_sentence('Mastercard, Visa, American Express, Discover and Aurora'));\n\t\tdocument.write('<br/><br/><h6>' + translate_sentence('What advantages do I have if I pay with paypal?') + '</h6>');\n\t\tdocument.write(translate_sentence('You can get many advantages') + ': ');\n\t\tdocument.write(translate_sentence('Secure system and secure payments, buy and pay with your mobile or tablet, no membership fees or service charges, discount coupons') + '...');\n\t}\n}", "title": "" }, { "docid": "50cec3342c6aae89f2eea9353996edb8", "score": "0.6198888", "text": "function paymentMethod() {\n const creditCardPayment = document.getElementById(\"credit-card\");\n const paypalPayment = document.getElementById(\"paypal\");\n const bitcoinPayment = document.getElementById(\"bitcoin\");\n\n //sets payment type to credit card on page load\n paymentMenu.children[1].selected = true;\n paypalPayment.style.display = \"none\";\n bitcoinPayment.style.display = \"none\";\n\n paymentMenu.addEventListener(\"change\", (e) => {\n const clickedPayment = e.target.value;\n \n if (clickedPayment === \"paypal\") {\n creditCardPayment.style.display = \"none\";\n paypalPayment.style.display = \"\";\n bitcoinPayment.style.display = \"none\";\n } else if (clickedPayment === \"bitcoin\") {\n creditCardPayment.style.display = \"none\";\n paypalPayment.style.display = \"none\";\n bitcoinPayment.style.display = \"\";\n } else {\n creditCardPayment.style.display = \"\";\n paypalPayment.style.display = \"none\";\n bitcoinPayment.style.display = \"none\";\n }\n }); \n}", "title": "" }, { "docid": "3ba1665261b97db7fe298dd229387567", "score": "0.61216253", "text": "function pt4PaymentTypeChange() {\n if ($('#pt4_paymentMethod option:selected').first().attr('value') == 'JP_EFT_WIRE') {\n $('.pt4_eft_wire').show();\n $('.pt4_check').hide();\n } else {\n $('.pt4_eft_wire').hide();\n $('.pt4_check').show();\n // When switching to check, always set default mailing address\n useProfileAddress();\n }\n $('.pt4_hidden').hide();\n }", "title": "" }, { "docid": "c44b129432b27272f1bc2df6949e7336", "score": "0.5963649", "text": "render() {\n const { isPaying, paymentMethod } = this.state;\n const {\n merchant_reference,\n amount,\n currency,\n product_name,\n user_id,\n paymentMethods\n } = this.props.url.query;\n\n return (\n <Page>\n <div className=\"row\">\n <div className=\"col-sm-6 col-sm-8 col-sm-offset-3 col-md-offset-2\">\n <LatipayLogo />\n <h2>\n {CURRENCIES_CODE_SIGN[currency]}\n {numeral(amount).format('0,0.00')}\n <small>{currency}</small>\n </h2>\n\n <div className=\"page-header lat-page-header\">\n <h5>请选择支付方式</h5>\n </div>\n <div className=\"lat-invoice-pay-methods\">\n {paymentMethods.map(pm => (\n <label\n key={pm}\n className=\"lat-invoce-pay-method\"\n htmlFor={`pay-${pm}`}\n >\n <input\n id={`pay-${pm}`}\n type=\"radio\"\n name=\"pay-method\"\n onClick={() => this.setPaymentMethod(pm)}\n />\n <img src={`/static/pay-${pm}.png`} alt={pm} />\n </label>\n ))}\n\n <style jsx>{`\n .lat-invoice-pay-methods {\n display: flex;\n flex-wrap: wrap;\n }\n .lat-invoce-pay-method {\n width: 25%;\n min-width: 150px;\n }\n .lat-invoce-pay-method img {\n width: 100px;\n margin: 1em;\n }\n `}</style>\n </div>\n {paymentMethod && (\n <button\n className=\"btn btn-success\"\n type=\"submit\"\n onClick={this.submit}\n disabled={isPaying}\n >\n &nbsp; &nbsp; &nbsp;PAY &nbsp; &nbsp; &nbsp;\n </button>\n )}\n <div className=\"page-header lat-page-header\">\n <h5>订单信息</h5>\n </div>\n\n <div className=\"lat-table\">\n <div className=\"table-responsive\">\n <table className=\"table table-hover \">\n <tbody>\n <tr>\n <td>产品信息</td>\n <td>{product_name}</td>\n </tr>\n <tr>\n <td>订单编号</td>\n <td>{merchant_reference}</td>\n </tr>\n <tr>\n <td>订单创建人</td>\n <td>{user_id}</td>\n </tr>\n </tbody>\n </table>\n <style jsx>{`\n td:first-of-type {\n width: 30%;\n }\n .attachment {\n text-decoration: underline;\n }\n `}</style>\n </div>\n </div>\n </div>\n </div>\n </Page>\n );\n }", "title": "" }, { "docid": "480b2f813452a2042b4b387e724863b6", "score": "0.5857387", "text": "function payment (input1, input2, input3, input4){\n let clickedPayment = paymentType.options[paymentType.selectedIndex];\n if (clickedPayment.value == input1){\n input2.style.display = 'block';\n input3.style.display = 'none';\n input4.style.display = 'none';\n }\n}", "title": "" }, { "docid": "393688e8ab2b19ceb9de6854c979bf60", "score": "0.5780176", "text": "function handlePaymentMethod(payment_method) {\r\n setPaymentTypeSelect(payment_method);\r\n\r\n switch(payment_method) {\r\n case 'paypal':\r\n setBlockVisibility(payment_by_paypal_block_class_name, true);\r\n setBlockVisibility(payment_by_card_block_class_name, false);\r\n setBlockVisibility(payment_by_check_block_class_name, false);\r\n break;\r\n case 'card':\r\n setBlockVisibility(payment_by_card_block_class_name, true);\r\n setBlockVisibility(payment_by_paypal_block_class_name, false);\r\n setBlockVisibility(payment_by_check_block_class_name, false);\r\n break;\r\n case 'check':\r\n setBlockVisibility(payment_by_check_block_class_name, true);\r\n setBlockVisibility(payment_by_card_block_class_name, false);\r\n setBlockVisibility(payment_by_paypal_block_class_name, false);\r\n break;\r\n }\r\n }", "title": "" }, { "docid": "20beb59736a9ea77100ef63b018794ad", "score": "0.57589024", "text": "function updatePaymentMethod()\n{\n let paymentMethod = paymentSelector.value;\n if(paymentMethod === 'select method')\n {\n paymentMethod = 'credit-card';\n document.querySelector('#payment option[value=\"credit card\"]').selected = true;\n document.querySelector('#payment option[value=\"select method\"]').style.display = 'none'; \n }\n\n if(paymentMethod === 'credit card')\n {\n paymentMethod = 'credit-card';\n }\n\n document.querySelector('#credit-card').style.display = 'none';\n document.querySelector('#paypal').style.display = 'none';\n document.querySelector('#bitcoin').style.display = 'none';\n document.querySelector(`#${paymentMethod}`).style.display = 'block';\n}", "title": "" }, { "docid": "e174d2caa70b3cbb3ffbea57866b743c", "score": "0.5753872", "text": "function hidePaymentOptions () {\n\n const selectedOption = $(\"#payment :selected\").text();\n\n // Hides all payment options\n $(\".credit-card\").hide();\n $(\"#payment-options p\").hide();\n\n // Shows the selected payment option\n if (selectedOption === \"Credit Card\") {\n $(\".credit-card\").show();\n } else if (selectedOption === \"PayPal\") {\n $(\"#payment-options p\").eq(0).show();\n } else if (selectedOption === \"Bitcoin\") {\n $(\"#payment-options p\").eq(1).show();\n }\n\n}", "title": "" }, { "docid": "8938f001e9b2f02b8b6f321253dc9d14", "score": "0.5752008", "text": "function renderPrices() {\n billingPeriodChoice.render();\n hideBillingAddress();\n selectDeliveryCountry();\n }", "title": "" }, { "docid": "48a4e8e830456cd4e92f0b1a93e55960", "score": "0.56734425", "text": "render(){\n const payment = this.props.payment;\n let dispPayment = this.state.dispPayment;\n\n const buttonSave = () => {\n if (this.state.isEdit) {\n return (\n <button\n onClick={() => this.props.onSave(this.state.dispPayment)}\n className='btn btn-danger'>\n Save\n </button>\n )\n }\n\n return undefined;\n }\n\n const showPaymentId = () => {\n const paymentCodeName = payment ? payment.codeName : '';\n const paymentIdStr = payment ? payment._id._str : '';\n return (<Link to={`/managePanel/payments/${paymentIdStr}`}>{paymentCodeName}</Link>)\n }\n\n\n const showDate = () => {\n if (this.state.isEdit){\n return(\n <DatePicker value={dispPayment.date}\n onChange={ this.onChangeDate } />\n )\n }\n\n return <span>{payment ? payment.date : ''}</span>\n }\n\n const showAmount = () => {\n if (this.state.isEdit){\n return(\n <input type=\"number\"\n min=\"0\"\n max=\"99999\"\n value={dispPayment.amount}\n onChange={(e) => this.onChangeAmount(e.target.value)} />\n )\n }\n\n return <span>{payment ? payment.amount : ''}</span>\n }\n\n const showStatus = () => {\n if (this.state.isEdit) {\n return (\n <div className='col-xs-8 form-horizontal'>\n <select className=' form-control' onChange={(e) => this.onChangeStatus(e.target.value)}>\n <option className='' value={this.state.dispPayment.status}>{this.state.dispPayment.status}</option>\n {\n paymentStateTypes.map((el, key) => {\n if (el !== this.state.dispPayment.status) {\n return (\n <option key={key} value={el}>{el}</option>\n )\n }\n return undefined;\n }\n )}\n </select>\n </div>\n )\n }\n\n return <span>{payment ? payment.status : ''}</span>\n }\n\n const renderCheckBoxAndSave = () => {\n if (!this.props.readOnly) {\n if (!this.state.isEdit) {\n return (\n <th className=\"noPrint\">\n <input type=\"checkbox\" \n onChange={() => this.props.onSelect(payment._id)}\n ref={(ref) => this.checkbox = ref}/>\n </th>\n )\n } else {\n return (\n <th className=\"noPrint\">\n <button\n onClick={ () => this.props.onSave(this.state.dispPayment) }\n className='btn btn-danger'>\n Save\n </button>\n </th>\n )\n }\n } \n\n return null;\n }\n\n\n return(\n <tr className=\"PaymentTabRow\">\n { renderCheckBoxAndSave() }\n <td>\n { /*buttonSave()*/ }\n { showPaymentId() }\n </td>\n <td>{ showDate() }</td>\n <td>{ showAmount() }</td>\n <td>{ showStatus() }</td>\n </tr>\n )\n }", "title": "" }, { "docid": "50a59bd9d017873cdd62cd3697f8131e", "score": "0.56733733", "text": "renderContent() {\n\t\tswitch (this.props.auth) {\n\t\t\tcase null:\n\t\t\treturn \"\"; // we dont know if the user is logged in or not\n\n\t\t\tcase false:\n\t\t\t\treturn (\n\t\t\t\t\t<li><a href=\"/auth/google\">Login with Google</a></li>\n\t\t\t\t);\n\n\t\t\tdefault:\n\t\t\t\treturn [\n\t\t\t\t\t\t<li key=\"1\"><Payments /></li>,\n\t\t\t\t\t\t<li key=\"2\"><a href=\"/api/logout\">Logout</a></li>\n\t\t\t\t];\n\n\t\t}\n\t}", "title": "" }, { "docid": "935e39194963f56b46abe738cf355446", "score": "0.5644446", "text": "render() {\n if (this.format === 'card-icon') return this.cardIconFormatTemplate;\n if (this.format === 'card-hero') return this.cardHeroFormatTemplate;\n if (this.format === 'image') return this.imageFormatTemplate;\n\n return this.textFormatTemplate;\n }", "title": "" }, { "docid": "dcac76d8ba7c194ca8ef8a7bddf0355b", "score": "0.5641173", "text": "function initPayment(){\n paymentOptions[1].selected = true;\n //we use nextElementSibling because the divs don't have id or class in the HTML\n displayPayment (creditCardDiv);\n /* creditCardDiv.style.display = '';\n paypalDiv.style.display = 'none';\n bitcoinDiv.style.display = 'none'; */\n }", "title": "" }, { "docid": "21e8fd9b84091141f98030fdde07614e", "score": "0.56370205", "text": "render() {\n if (this.state.selected == DELIVERY) {\n return <div class=\"nested-view-width mx-auto\">\n <ul class=\"nav nav-tabs\">\n <li class=\"left-tab nav-item delivery-collection\">\n <a class=\"nav-link delivery-collection delivery-collection-tabs text-center\" href=\"#\" onClick={() => this.setState({ selected: DELIVERY })} ><i class=\"fas fa-truck\"></i> Delivery</a>\n </li>\n <li class=\"middle-tab nav-item deactive-tab\">\n <a class=\"deactive-tab nav-link text-center\" href=\"#\" onClick={() => this.setState({ selected: COLLECTION })}><i class=\"fas fa-hand-holding\"></i> Collection</a>\n </li>\n <li class=\"right-tab nav-item deactive-tab\">\n <a class=\"deactive-tab nav-link text-center\" href=\"#\" onClick={() => this.setState({ selected: EAT_IN })}><i class=\"fas fa-utensils\"></i> Eat-In</a>\n </li>\n </ul>\n <div class=\"tab-box delivery-collection tab-box-text\">\n <h5 class=\"delivery-collection delivery-font\">CONTACT-FREE DELIVERY</h5>\n <p>Our deliveries are carried out in a way that guarantees the safety of our customers and drivers. All orders will need to be paid online by credit/debit card.</p>\n <div class=\"input-group mb-3\">\n <input onChange={event => this.setPostcode(event.target.value)} type=\"text\" class=\"form-control\" placeholder=\"Postcode\" aria-label=\"Postcode\" aria-describedby=\"basic-addon2\" />\n <div class=\"input-group-append\">\n <button onClick={(event) => this.goToNextPage(event)} class=\"btn btn-outline-secondary\" type=\"button\">Start my Order</button>\n </div>\n </div>\n </div>\n </div>\n } else if (this.state.selected == COLLECTION) {\n return <div class=\"nested-view-width mx-auto\">\n <ul class=\"nav nav-tabs\">\n <li class=\"left-tab nav-item deactive-tab\">\n <a class=\"deactive-tab nav-link text-center\" href=\"#\" onClick={() => this.setState({ selected: DELIVERY })}><i class=\"fas fa-truck\"></i> Delivery</a>\n </li>\n <li class=\"middle-tab nav-item delivery-collection\">\n <a class=\"nav-link delivery-collection delivery-collection-tabs text-center\" href=\"#\" onClick={() => this.setState({ selected: COLLECTION })}><i class=\"fas fa-hand-holding\"></i> Collection</a>\n </li>\n <li class=\"right-tab nav-item deactive-tab\">\n <a class=\"deactive-tab nav-link text-center\" href=\"#\" onClick={() => this.setState({ selected: EAT_IN })}><i class=\"fas fa-utensils\"></i> Eat-In</a>\n </li>\n </ul>\n <div class=\"tab-box delivery-collection tab-box-text\">\n <h5 class=\"delivery-collection\">CONTACT-FREE COLLECTION</h5>\n <p>Our restaurant is operating contact-free collection following government guidelines and regulations. Click below to place your order.</p>\n <div class=\"input-group mb-3\">\n <div class=\"input-group-append\">\n <button onClick={(event) => this.goToNextPage(event)} class=\"btn btn-outline-secondary\" type=\"button\">Start my Order</button>\n </div>\n </div>\n </div>\n </div>\n } else {\n return <div class=\"nested-view-width mx-auto\">\n <ul class=\"nav nav-tabs\">\n <li class=\"left-tab nav-item deactive-tab\">\n <a class=\"deactive-tab nav-link text-center\" href=\"#\" onClick={() => this.setState({ selected: DELIVERY })}><i class=\"fas fa-truck\"></i> Delivery</a>\n </li>\n <li class=\"middle-tab nav-item deactive-tab\">\n <a class=\"deactive-tab nav-link text-center\" href=\"#\" onClick={() => this.setState({ selected: COLLECTION })}><i class=\"fas fa-hand-holding\" ></i> Collection</a>\n </li>\n <li class=\"right-tab nav-item delivery-collection\">\n <a class=\"nav-link delivery-collection delivery-collection-tabs text-center\" href=\"#\" onClick={() => this.setState({ selected: EAT_IN })}><i class=\"fas fa-utensils\"></i> Eat-In</a>\n </li>\n </ul>\n <div class=\"tab-box delivery-collection tab-box-text\">\n <h5 class=\"delivery-collection\">Eat-In</h5>\n <p>Unforunately due to current circumstances we cannot allow customer's to eat on the premises. Collection and delivery are still available.</p>\n\n </div>\n </div>\n }\n\n }", "title": "" }, { "docid": "d50e0211ec80c42e27a255bc5ea13318", "score": "0.56278455", "text": "function EnablePaymentSectionDisplay() {\n const $paymentSelect = $(\"#payment\");\n const options = $paymentSelect.children();\n\n function HideAll() {\n for (let i = 0; i < options.length; i++) {\n $(\".\" + $(options[i]).data(\"connectedtocssclass\")).hide();\n }\n }\n\n function ShowSelectedPaymentSection() {\n HideAll();\n\n let selectedOption = $paymentSelect.find(\"option:selected\");\n let cssClass = \".\" + $(selectedOption).data(\"connectedtocssclass\");\n\n $(cssClass).show();\n }\n\n $paymentSelect.on(\"change\", ShowSelectedPaymentSection);\n ShowSelectedPaymentSection();\n }", "title": "" }, { "docid": "60fadb84426d418fd890dfe9f48d7639", "score": "0.5617641", "text": "function updatePaymentDiv(paymentValue) {\n\n function setCreditCard() {\n selected(paymentSelection.options[1]);\n }\n\n function handleDiv(paymentOption) {\n switch (paymentOption) {\n case \"Credit Card\": {\n hideElement(paypalDiv);\n hideElement(bitcoinDiv);\n showElement(creditCardDiv);\n break;\n }\n\n case \"PayPal\": {\n hideElement(bitcoinDiv);\n hideElement(creditCardDiv);\n showElement(paypalDiv);\n break;\n }\n\n case \"Bitcoin\": {\n hideElement(paypalDiv);\n hideElement(creditCardDiv);\n showElement(bitcoinDiv);\n break;\n }\n\n default: {\n break;\n }\n }\n }\n\n if (paymentValue == selectPaymentValue) {\n setCreditCard();\n } else {\n handleDiv(paymentValue);\n }\n}", "title": "" }, { "docid": "10aa0239d7fe036b68da91c3b4fdbb26", "score": "0.56025255", "text": "renderPayment(root) {\n new PaymentModule(this.totalAmount()).start(root)\n\n }", "title": "" }, { "docid": "5a30d787660ce74be838a728e3d360b1", "score": "0.5595313", "text": "renderPage() {\t\t\n\t\tswitch (this.props.data.active) {\n\t\t\tcase 'user': \n\t\t\t\treturn this.renderUserInfo(this.props.data.body);\t\t\t\n\t\t\tcase 'repos': \n\t\t\t\treturn this.renderRepos(this.props.data.body);\n\t\t\tcase 'about': \n\t\t\t\treturn this.renderAbout();\t\t\t\t\t\n\t\t}\n\t}", "title": "" }, { "docid": "647b2b89053df099279292c4abb7049a", "score": "0.55828124", "text": "function render() {\r\n let content = '';\r\n if (STORE.view === 'home') {\r\n $('main').html(welcomePage());\r\n }\r\n else if (STORE.view === 'question') {\r\n content = questionAsked();\r\n content += generateAnswers();\r\n content += questionAndScoreStanding();\r\n $('main').html(`<form>${content}</form>`);\r\n } else if (STORE.view === 'feedback') {\r\n answerFeedback();\r\n } else if (STORE.view === 'score') {\r\n finalScore();\r\n }\r\n}", "title": "" }, { "docid": "58947f974ec6f6072872b920177069a5", "score": "0.5577633", "text": "function render() {\n if (STORE.view === 'start') {\n renderStartQuiz();\n $('.intro').show();\n $('.quiz').hide();\n $('.result').hide();\n $('.quizStatus').hide();\n } else if (STORE.view === 'quiz') {\n renderQuestionText();\n renderQuizStatusBar();\n $('.intro').hide();\n $('.quiz').show();\n $('.result').hide();\n $('.quizStatus').show();\n } else if (STORE.view === 'questionResult') {\n renderQuestionResult();\n renderQuizStatusBar();\n $('.intro').hide();\n $('.quiz').hide();\n $('.result').show();\n $('.quizStatus').show();\n } else if (STORE.view === 'finalResult') {\n renderFinalResult();\n $('.intro').hide();\n $('.quiz').hide();\n $('.result').show();\n $('.quizStatus').hide();\n }\n }", "title": "" }, { "docid": "597c5ce32aaf13a00cc9e14a84a11930", "score": "0.5577092", "text": "function selectPaymentMethod() {\n paymentMethod = $(this).text();\n chosePaymentMethod = true;\n $(\"#paymentMethodMenuButton\").text(paymentMethod);\n if (paymentMethod == \"Card\") {\n $(\"#selectCardMenu\").show();\n } else {\n $(\"#selectCardMenu\").hide();\n }\n}", "title": "" }, { "docid": "8fc4f5e675979a4d57d686d22cf490ed", "score": "0.5538881", "text": "getPaymentType() {\n if (this.paidInFullAt || this.paidOutsideAppAt) {\n return 'COMPLETE';\n }\n return 'OUTSTANDING';\n }", "title": "" }, { "docid": "cc182174e29fb7338b1dcc955decbb72", "score": "0.55347776", "text": "function renderUserPage(type) {\n switch (type) {\n case 'register':\n return [\n '<section>',\n '<h2>Registreren</h2>',\n '<form method=\"post\" action=\"/user/register\" class=\"user-form\">',\n '<fieldset>',\n '<label>',\n 'Gebruikersnaam',\n '<input type=\"text\" name=\"username\">',\n '</label>',\n '<label>',\n 'Wachtwoord',\n '<input type=\"password\" name=\"password\">',\n '</label>',\n '<label>',\n 'Herhaal wachtwoord',\n '<input type=\"password\" name=\"passwordcopy\">',\n '</label>',\n '<input type=\"submit\">',\n '</fieldset>',\n '<fieldset>',\n '<p>Al een account? <a href=\"/user/login\">Log in</a>!</p>',\n '</fieldset>',\n '</form>',\n '</section>'\n ].join('\\n');\n break;\n case 'login':\n return [\n '<section>',\n '<h2>Inloggen</h2>',\n '<form method=\"post\" action=\"/user/login\" class=\"user-form\">',\n '<fieldset>',\n '<label>',\n 'Gebruikersnaam',\n '<input type=\"text\" name=\"username\">',\n '</label>',\n '<label>',\n 'Wachtwoord',\n '<input type=\"password\" name=\"password\">',\n '</label>',\n '<input type=\"submit\">',\n '</fieldset>',\n '<fieldset>',\n '<p>Nog geen account? <a href=\"/user/register\">Registreer</a>!</p>',\n '</fieldset>',\n '</form>',\n '</section>'\n ].join('\\n');\n break;\n }\n}", "title": "" }, { "docid": "d609258f3ca7562669bcf7a52bd1658f", "score": "0.5530807", "text": "render() {\n return (\n <div\n className=\"card\"\n onClick={() => this.props.clickHandler(this.props.bill)}\n >\n <div className=\"card-body\">\n <h2 className=\"card-company-name\">{this.props.bill.company_name}</h2>\n <h4 className=\"card-amount\">Amount Due:</h4>\n <p>${this.props.bill.amount}</p>\n <h4 className=\"card-amount\">Payment Due Date: </h4>\n <p>{this.props.bill.payment_due}</p>\n <h4 className=\"card-category\">Category: </h4>\n <p>{this.props.bill.category}</p>\n {this.props.isDefault ? null : (\n <button onClick={() => this.props.handlePaid(this.props.bill)}>\n {this.props.bill.paid ? \"Paid\" : \"Pay This Week\"}\n </button>\n )}\n <hr />\n </div>\n </div>\n );\n }", "title": "" }, { "docid": "7c338444ec9714a8122498b504a79e82", "score": "0.5526718", "text": "function displayPaymentOptions(firstLoad){\n if (firstLoad){\n $(\"#payment option\").first().hide();\n $(\"option[value='credit card']\").prop(\"selected\", true);\n}\n $(\"#payment option\").each((i, option) => {\n const modOptionValue = option.value.replace(/\\s/, \"-\");\n const paymentDiv = `#${modOptionValue}`;\n if ($(option).is(\":selected\")){\n $(paymentDiv).show()\n } else {\n $(paymentDiv).hide()\n }\n });\n}", "title": "" }, { "docid": "79765217951b9dc8e0569047d1b63bc8", "score": "0.55088276", "text": "function updatePaymentInfo() {\n \n var man_py=$('#payment').val();\n if(man_py==\"PayPal\")\n {$('#paypal').slideDown();\n $('#bitcoin').slideUp();\n $('.credit-card').hide();\n }\n else if(man_py==\"Bitcoin\")\n {$('#bitcoin').slideDown();\n $('#paypal').slideUp();\n $('.credit-card').hide();\n }\n\n else\n {$('.credit-card').show();\n $('#paypal').slideUp();\n $('#bitcoin').slideUp();\n}\n \n}", "title": "" }, { "docid": "0f27815ec41e8a6570d8be8585b65e67", "score": "0.5469296", "text": "render(){\n \n const { invoice, auth, idc, userType, rating_value } = this.props;\n if (!auth.uid) return <Redirect to=\"/signin\" />\n \n if(this.props.idc){\n this.state.invoiceId = this.props.idc;\n this.state.invoice = this.props.invoice;\n }\n\n if(this.props.status){\n \n this.state.processing = this.props.status.processing;\n this.state.done = this.props.status.done;\n \n } else {\n if (userType === 'AYLI'){\n this.props.confirmStatus(this.state);\n }\n }\n\n // Save the JSX template depending on the user type to pay the invoice\n const method = (userType === 'Customer') ? (\n <div className=\"input-field buttons\">\n <NavLink to={'/pay/' + idc}><button className=\"btn light-blue lighten-3 z-depth-0\" id=\"confirm\" type=\"submit\" name=\"action\">Pay<i className=\"material-icons right\">payment</i></button></NavLink>\n </div>\n ) : null;\n\n // Save the JSX template depending on the user type to rate the SC\n const rating = (userType === 'Customer') ? (\n <div>\n <div className=\"input-field\">\n <h4>Rating: </h4>\n <ReactStars count={5} value={rating_value} onChange={this.handleChange} size={24} activeColor=\"#ffd700\" />\n </div>\n <div>\n <h5 className=\"grey-text\">Review</h5>\n <div className=\"input-field col s12\">\n <label htmlFor=\"invoiceComment\">Please comment the service quality</label>\n <textarea id=\"invoiceComment\" className=\"materialize-textarea\" onChange={this.handleChange}></textarea>\n </div>\n </div>\n <br />\n <br />\n <br />\n <div className=\"file-field input-field multiImage-second\">\n <div className=\"btn #ef9a9a red lighten-3\">\n <span><i className=\"material-icons left\">cloud_upload</i>File</span>\n <input id=\"servicePhoto\" type=\"file\" multiple onChange={this.handleChangeFile} />\n </div>\n <div className=\"file-path-wrapper\">\n <input className=\"file-path validate\" type=\"text\" placeholder=\"Upload one or more files\"/>\n </div>\n <ul className=\"list-inline imgList row\">\n { this.state.invoicePhotos && this.state.invoicePhotos.map((item) => {\n //console.log(item);\n //console.log(this.state);\n const id = Math.random(); \n if(item.url){ \n return ( \n \n <li key={id}>\n <div className=\"col s2\"> \n <img className=\"materialboxed thumbnail responsive-img\" width=\"650\" height=\"650\" src={item.url} /> \n </div>\n </li>\n \n )\n }\n }) \n \n }\n </ul>\n </div>\n </div>\n ) : null; \n\n \n if (!this.state.processing && this.state.done){\n \n this.state.done = '';\n }\n\n // Update the status of the ED depending on the status registered in the databse server\n \n if (!this.state.processing){\n button1 = <a className=\"waves-effect waves-light btn-large col s2 push-s1 #ef9a9a red lighten-3\"id=\"processing\" type=\"submit\" name=\"action\" onClick={this.handleClick1}>In process</a>\n button11 = <a className=\"btn-large disabled col s2 push-s1\">In process</a>\n }\n if (!this.state.done){\n button2 = <a className=\"waves-effect waves-light btn-large col s4 push-s2 #ef9a9a red lighten-3\" id=\"done\" type=\"submit\" name=\"action\" onClick={this.handleClick2}>We are waiting for you!</a>\n button22 = <a className=\"btn-large disabled col s4 push-s2\">We are waiting for you!</a>\n }\n if (this.state.processing){\n button1 = <a className=\"btn-large disabled col s2 push-s1\">In process</a>\n button11 = <a className=\"waves-effect waves-light btn-large col s2 push-s1 #ef9a9a red lighten-3\">In process</a>\n }\n if(this.state.done){\n button2 = <a className=\"btn-large disabled col s4 push-s2\">We are waiting for you!</a>\n button22 = <a className=\"waves-effect waves-light btn-large col s4 push-s2 pulse #ef9a9a red lighten-3\">We are waiting for you!</a>\n }\n\n if ((!this.state.processing) && (!this.state.done)) {\n button33 = <a className=\"waves-effect waves-light btn-large col s2 pulse #ef9a9a red lighten-3\">Accepted</a>\n } else {\n button33 = <a className=\"waves-effect waves-light btn-large col s2 #ef9a9a red lighten-3\">Accepted</a>\n }\n \n if (this.state.processing && !this.state.done){\n button1 = <a class=\"btn-large disabled col s2 push-s1\">In process</a>\n button11 = <a class=\"waves-effect waves-light btn-large col s2 push-s1 pulse #ef9a9a red lighten-3\">In process</a>\n } else if (this.state.processing && this.state.done){\n button1 = <a class=\"btn-large disabled col s2 push-s1\">In process</a>\n button11 = <a class=\"waves-effect waves-light btn-large col s2 push-s1 #ef9a9a red lighten-3\">In process</a>\n button2 = <a class=\"btn-large disabled col s4 push-s2\">We are waiting for you!</a>\n button22 = <a class=\"waves-effect waves-light btn-large col s4 push-s2 pulse #ef9a9a red lighten-3\">We are waiting for you!</a>\n \n }\n\n \n\n const status = (userType === 'AYLI') ? (\n <div className=\"hey\">\n <h3>Proposal Status:</h3>\n <br />\n <div className=\"track row\">\n <a className=\"btn-large disabled col s2\">Accepted</a>\n { button1 }\n { button2 }\n </div>\n </div>\n ) : (\n <div className=\"row\">\n <h3>Proposal Status:</h3>\n <br />\n <div className=\"track row\">\n { button33 }\n { button11 }\n { button22 }\n </div>\n </div>\n );\n \n \n // JSX template to display the invoice details based on the payment property value\n if (invoice) {\n const offer1 = (invoice.nOffers === 'one offer') ? (\n <p>Cost of Offer 1: { invoice.cost1 }</p>\n ): null;\n const offer2 = (invoice.nOffers === 'two offers') ? (\n <div>\n <p>Cost of Offer 1: { invoice.cost1 }</p>\n <p>Cost of Offer 2: { invoice.cost2 }</p>\n </div>\n ): null;\n const offer3 = (invoice.nOffers === 'three offers') ? (\n <div>\n <p>Cost of Offer 1: { invoice.cost1 }</p>\n <p>Cost of Offer 2: { invoice.cost2 }</p>\n <p>Cost of Offer 3: { invoice.cost3 }</p>\n </div>\n ): null;\n //console.log(invoice)\n if (invoice.payment === 'NOT YET'){ \n return (\n <div className=\"container section invoice-details\">\n <div className=\"card z-depth-0\">\n <div className=\"card-content\">\n <span className=\"card-title\">INVOICE REGARDING SERVICE NUMBER: { invoice.id }</span>\n <p>Company Name: { invoice.authorCompanyName }</p>\n <p>Company ID: { invoice.authorCompanyId }</p>\n <p>Company TAX ID: { invoice.companyTaxId }</p>\n <p>Company EMAIL: { invoice.companyEmail }</p>\n <p>Offer Description: { invoice.offerDescription }</p>\n <p>Offers Number: { invoice.nOffers }</p>\n { offer1 }\n { offer2 }\n { offer3 }\n <p>User First & Last Name: { invoice.authorFirstName } { invoice.authorLastName }</p>\n <p>User ID: { invoice.userId }</p>\n <p>User Email Address: { invoice.userEmail }</p>\n </div>\n <div className=\"card-action grey lighten-4 grey-text\">\n <div>Invoice ID: { idc[0] }</div>\n <div>{moment(invoice.invoiceCreatedAt.toDate()).calendar()}</div>\n </div>\n <br/>\n <div className=\"row\">\n { method }\n { rating }\n </div>\n <br/>\n \n { status }\n \n </div>\n </div>\n )\n } else if (invoice.payment === 'PENDING'){ \n return (\n <div className=\"container section invoice-details\">\n <div className=\"card z-depth-0\">\n <div className=\"card-content\">\n <span className=\"card-title\">INVOICE REGARDING SERVICE NUMBER: { invoice.id }</span>\n <p>Company Name: { invoice.authorCompanyName }</p>\n <p>Company ID: { invoice.authorCompanyId }</p>\n <p>Company TAX ID: { invoice.companyTaxId }</p>\n <p>Company EMAIL: { invoice.companyEmail }</p>\n <p>Offer Description: { invoice.offerDescription }</p>\n <p>Offers Number: { invoice.nOffers }</p>\n { offer1 }\n { offer2 }\n { offer3 }\n <p>User First & Last Name: { invoice.authorFirstName } { invoice.authorLastName }</p>\n <p>User ID: { invoice.userId }</p>\n <p>User Email Address: { invoice.userEmail }</p>\n </div>\n <div className=\"card-action grey lighten-4 grey-text\">\n <div>Invoice ID: { idc[0] }</div>\n <div>{moment(invoice.invoiceCreatedAt.toDate()).calendar()}</div>\n </div>\n <br/>\n <div className=\"row\">\n <div className=\" look input-field buttons\">\n <button className=\"btn disabled\">Pending<i className=\"material-icons right\">access_time</i></button> \n </div>\n { rating }\n </div>\n \n <br/>\n \n { status }\n \n </div>\n </div>\n )\n } else if (invoice.payment === 'PROCEEDED'){\n return (\n <div className=\"container section invoice-details\">\n <div className=\"card z-depth-0\">\n <div className=\"card-content\">\n <span className=\"card-title\">INVOICE REGARDING SERVICE NUMBER: { invoice.id }</span>\n <p>Company Name: { invoice.authorCompanyName }</p>\n <p>Company ID: { invoice.authorCompanyId }</p>\n <p>Company TAX ID: { invoice.companyTaxId }</p>\n <p>Company EMAIL: { invoice.companyEmail }</p>\n <p>Offer Description: { invoice.offerDescription }</p>\n <p>Offers Number: { invoice.nOffers }</p>\n { offer1 }\n { offer2 }\n { offer3 }\n <p>User First & Last Name: { invoice.authorFirstName } { invoice.authorLastName }</p>\n <p>User ID: { invoice.userId }</p>\n <p>User Email Address: { invoice.userEmail }</p>\n </div>\n <div className=\"card-action grey lighten-4 grey-text\">\n <div>Invoice ID: { idc[0] }</div>\n <div>{moment(invoice.invoiceCreatedAt.toDate()).calendar()}</div>\n </div>\n <div className=\"row\">\n <div className=\"input-field buttons\">\n <button className=\"btn disabled\">Proceeded<i className=\"material-icons right\">check</i></button> \n </div>\n { rating }\n </div>\n \n <br/>\n \n { status }\n \n </div>\n </div>\n )\n } else {\n return (\n <div className=\"container center\">\n <p>Problem is detected in the payment status! Please contact the administrator using the CONTACT section.</p>\n </div>\n )\n }\n } else {\n return (\n <div className=\"container center\">\n <p>Loading Invoice...</p>\n </div>\n )\n }\n }", "title": "" }, { "docid": "7587f37f3779a399e1268d01a0d61959", "score": "0.5465283", "text": "render() {\n return (\n <section>\n <div className=\"main section\">\n <div className=\"main_wraper payment\">\n <div className=\"container\">\n <div className=\"row\">\n <div className=\"col-sm-12 col-xs-12\">\n <div className=\"payment_top section\">\n <div className=\"payment_l\">\n <label>Total</label>\n <span className=\"value\">1 205,00€ HT</span>\n </div>\n <div className=\"payment_r pull-right\">\n <button className=\"btn-primary\">CONTINUER</button>\n </div>\n </div>\n </div>\n <div className=\"col-sm-8 col-xs-12 payment_con\">\n <h1>Etape 2 - Choix du moyen de paiement</h1>\n <p>Vous pouvez payer par carte dès maintenant ou par chèque en différé</p>\n <div className=\"payment_wrap section\">\n <div className=\"payment_option\">\n <label>\n <input name=\"payment\" defaultChecked type=\"radio\" />\n <span className=\"ckeckname\">Carte de crédit / Carte de débit </span>\n <span className=\"checkmark\" />\n <span className=\"payment_img\"><img src={paymentOptionImg} alt=\"payment\" className=\"img-responsive\" /></span>\n </label>\n </div>\n <div className=\"payment_option\">\n <label>\n <input name=\"payment\" defaultChecked type=\"radio\" />\n <span className=\"ckeckname\">Chèque</span>\n <span className=\"checkmark\" />\n </label>\n </div>\n <a href=\"#\" className=\"btn-primary\">payer 1446,00€</a>\n </div>\n </div>\n <div className=\"col-sm-4 col-xs-12 payment_main\">\n <div className=\"credit_summery\">\n <div className=\"summery_head\">\n <h5>Récapitulatif</h5>\n <a href=\"#\" className=\"purple\">Modifier</a>\n </div>\n\n <PanelGroup accordion id=\"accordion\" activeKey={this.state.activePanelKey} onSelect={this.handlePanelSelect}>\n <Panel eventKey=\"collapseOne\">\n <Panel.Heading>\n <Panel.Title toggle>\n <div className=\"item_summery\">\n <div className=\"item_avtar\">\n <img src={festivitiesImg} alt=\"festivities\" className=\"img-responsive\" />\n </div>\n <div className=\"item_det\">\n <p>Fêtes de fin d’année 2018 Noël et Nouvel An</p>\n <span>385,00€</span>\n </div>\n </div>\n </Panel.Title>\n </Panel.Heading>\n <Panel.Body collapsible>\n <p>Surpression locale en visibilité internet sur la thématique de Noël et Nouvel An. Un kit de bannières, une page d’aterissage, une rédaction de contenu. </p>\n <div className=\"summery_list section\">\n <ul>\n <li><label>Destinataires</label><p>Voltaire, Mérignac, Prado, Moi </p></li>\n <li><label>Type</label><p>Préstation ponctuelle</p></li>\n <li><label>Période)</label><p>du 18-01-2018 au 16-02-2018</p></li>\n </ul>\n </div>\n </Panel.Body>\n </Panel>\n <Panel eventKey=\"collapseTow\">\n <Panel.Heading>\n <Panel.Title toggle>\n <div className=\"item_avtar\">\n <img src={laSemaineImg} alt=\"La-semaine\" className=\"img-responsive\" />\n </div>\n <div className=\"item_det\">\n <p>La semaine du goût</p>\n <span>385,00€</span>\n </div>\n </Panel.Title>\n </Panel.Heading>\n <Panel.Body collapsible>\n <p>Surpression locale en visibilité internet sur la thématique de Noël et Nouvel An. Un kit de bannières, une page d’aterissage, une rédaction de contenu. </p>\n <div className=\"summery_list section\">\n <ul>\n <li><label>Destinataires</label><p>Voltaire, Mérignac, Prado, Moi </p></li>\n <li><label>Type</label><p>Préstation ponctuelle</p></li>\n <li><label>Période)</label><p>du 18-01-2018 au 16-02-2018</p></li>\n </ul>\n </div>\n </Panel.Body>\n </Panel>\n </PanelGroup>\n\n <div className=\"total_summry\">\n <div className=\"summery_list section\">\n <ul>\n <li><label>Sous-Total</label><p>1 205,00€</p></li>\n <li><label>TVA (20%)</label><p>241,00€</p></li>\n </ul>\n </div>\n <div className=\"summery_list section\">\n <ul>\n <li><label>Total</label><p>1446,00€</p></li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </section>\n );\n }", "title": "" }, { "docid": "0440a1f3490491bbdaefb8e8480960c1", "score": "0.5443707", "text": "function showHideCashCounterpartyDetailBlockConf(type){\n\tswitch (type)\n\t{\n\tcase \"H\":\n\t //uCash_cp samirj\n\t $(\"#uCashSide2_2\").hide();\n\t\t$(\"#uCashSide2_3\").hide();\n\t\t$(\"#uCashSide2_4\").hide();\n\t\t$(\"#uCashSide2_51\").hide();\n\t\t$(\"#uCashSide2_52\").hide();\n\t\t$(\"#uCashSide2_6\").hide();\n\t\t$(\"#uCashSide2_7\").hide();\n\t\t$(\"#cashCpdetails\").hide();\n\t\tbreak;\n\tcase \"S\":\n\t $(\"#uCashSide2_2\").show();\n\t\t$(\"#uCashSide2_3\").show();\n\t\t$(\"#uCashSide2_4\").show();\n\t\t$(\"#uCashSide2_51\").show();\n\t\t$(\"#uCashSide2_52\").show();\n\t\t$(\"#uCashSide2_6\").show();\n\t\t$(\"#uCashSide2_7\").show();\n\t\t$(\"#cashCpdetails\").show();\n\t\tbreak;\n\t}\n}", "title": "" }, { "docid": "e10776b5f0e7c1650a5db65061a0a283", "score": "0.54426795", "text": "function display(type,form)\n{\n var acctype = nlapiGetFieldText('custrecord_account_type');\n if (type == 'create' || type == 'edit') \n\t{\n if (acctype == 'Accounts Receivable' || acctype == 'Accounts Payable' || acctype == 'Unbilled Receivable') \n\t\t{ \n form.getField('custrecord_revalue_balance').setDisplayType('inline');\n if (acctype == 'Unbilled Receivable') \n\t\t\t{\n form.getField('custrecord_eliminate_tran').setDisplayType('disabled');\n form.getField('custrecord_coa_misc').setDisplayType('normal');\n }\n else \n\t\t\t{\n form.getField('custrecord_eliminate_tran').setDisplayType('normal');\n form.getField('custrecord_coa_misc').setDisplayType('disabled');\n }\n form.getField('custrecord_currency_value').setDisplayType('disabled');\n form.getField('custrecord_def_account_ea').setDisplayType('disabled');\n form.getField('custrecord_expense_track_ea').setDisplayType('disabled');\n }\n else if (acctype == 'Deferred Revenue' || acctype == 'Deferred Expense' || acctype == 'Other Asset' || acctype == 'Other Current Asset' || acctype == 'Fixed Asset') \n\t\t{\n\t\t\tform.getField('custrecord_revalue_balance').setDisplayType('normal');\n\t\t\tif (acctype == 'Fixed Asset') {\n\t\t\t\tform.getField('custrecord_eliminate_tran').setDisplayType('disabled');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tform.getField('custrecord_eliminate_tran').setDisplayType('normal');\n\t\t\t}\n\t\t\tif (acctype == 'Deferred Revenue' || acctype == 'Deferred Expense' || acctype == 'Fixed Asset') {\n\t\t\t\tform.getField('custrecord_currency_value').setDisplayType('disabled');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tform.getField('custrecord_currency_value').setDisplayType('normal');\n\t\t\t}\n\t\t\tform.getField('custrecord_def_account_ea').setDisplayType('disabled');\n\t\t\tform.getField('custrecord_coa_misc').setDisplayType('normal');\n\t\t\tform.getField('custrecord_expense_track_ea').setDisplayType('disabled');\n\t\t}\n\t\telse if (acctype == 'Bank' || acctype == 'Credit Card') { \n\t\t\tform.getField('custrecord_revalue_balance').setDisplayType('normal');\n\t\t\tform.getField('custrecord_eliminate_tran').setDisplayType('disabled');\n\t\t\tif (acctype == 'Bank') {\n\t\t\t\tform.getField('custrecord_currency_value').setDisplayType('normal');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tform.getField('custrecord_currency_value').setDisplayType('disabled');\n\t\t\t}\n\t\t\tform.getField('custrecord_def_account_ea').setDisplayType('disabled');\n\t\t\tform.getField('custrecord_coa_misc').setDisplayType('disabled');\n\t\t\tform.getField('custrecord_expense_track_ea').setDisplayType('disabled');\n\t\t}\n\t\telse if (acctype == 'Cost of Goods Sold' || acctype == 'Equity' || acctype == 'Expense' || acctype == 'Income' || acctype == 'Other Expense' || acctype == 'Other Income') \n\t\t{ \n\t\t\tform.getField('custrecord_revalue_balance').setDisplayType('disabled');\n\t\t\tform.getField('custrecord_eliminate_tran').setDisplayType('normal');\n\t\t\tif (acctype == 'Equity') {\n\t\t\t\tform.getField('custrecord_def_account_ea').setDisplayType('disabled');\n\t\t\t\tform.getField('custrecord_coa_misc').setDisplayType('normal');\n\t\t\t\tform.getField('custrecord_expense_track_ea').setDisplayType('disabled');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tform.getField('custrecord_def_account_ea').setDisplayType('normal');\n\t\t\t\tform.getField('custrecord_coa_misc').setDisplayType('normal');\n\t\t\t\tif (acctype == 'Income' || acctype == 'Other Income') \n\t\t\t\t{\n\t\t\t\t\tform.getField('custrecord_expense_track_ea').setDisplayType('disabled');\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tform.getField('custrecord_expense_track_ea').setDisplayType('normal');\n\t\t\t\t}\n\t\t\t}\n\t\t\tform.getField('custrecord_currency_value').setDisplayType('disabled'); \n\t\t}\n\t\telse if (acctype == 'Long Term Liability' || acctype == 'Other Current Liability') { \n\t\t\tform.getField('custrecord_revalue_balance').setDisplayType('normal');\n\t\t\tform.getField('custrecord_eliminate_tran').setDisplayType('normal');\n\t\t\tform.getField('custrecord_currency_value').setDisplayType('normal'); \n\t\t\tform.getField('custrecord_def_account_ea').setDisplayType('disabled');\n\t\t\tform.getField('custrecord_coa_misc').setDisplayType('normal');\n\t\t\tform.getField('custrecord_expense_track_ea').setDisplayType('disabled');\n\t\t}\n }\n}", "title": "" }, { "docid": "7084e3eb65333f55e34b1f4f665560a8", "score": "0.54189086", "text": "function display(payment,payment2,payment3){\r\n\tbackToSummery();\r\n\tpayment2.style.display=\"none\";\r\n\tpayment.style.display=\"block\";\r\n\tbackToColor();\r\n\tpayment3.style.background=\"#fff\";\r\n}", "title": "" }, { "docid": "857f47ca2f1444c49d5559fafd0b5091", "score": "0.541256", "text": "function templatize(data, type) {\n var str = '';\n\n str += '<img src=\"' + data.icon + '\" />' +\n '<h4>' + data.name + '</h4>' +\n '<div class=\"desc\">' + data.description + '</div>';\n\n\n if(!isBuiltin(data.name)) {\n str += '<div class=\"purchase\">';\n\n if(isPurchased(data.name)) {\n str += '<div class=\"purchased\">purchased</div>';\n }\n else {\n str += '<button data-type=\"' + type + '\" data-item=\"' + data.name + '\">Buy for ' + formatPrice(data.price) + '</button>';\n }\n str += '</div>';\n }\n\n return str;\n }", "title": "" }, { "docid": "d406bd1f747759b0e673befa81cb3c9d", "score": "0.5403488", "text": "function showModal(type) {\n console.log('showModal invoked. type: ', type);\n // Depending on the type, render the modal\n\n // Set up variables\n let modalTitle = '';\n let modalBody = '';\n let modalButtons = '';\n let modalButtonText = 'Got it';\n let modalOnclick = false;\n\n // Possible modal types:\n\n switch (type) {\n case 'tax':\n modalTitle = 'Taxes!';\n modalBody = `You've hit a tax. All players with 12 cards or more will lose half their cards. The player(s)\n with <em>${taxDescription}</em> get an additional coin.`;\n break;\n\n case 'new turn':\n modalTitle = `<span class=\"player-turn\"></span>'s Turn`;\n modalBody = `Heads up: the turn is changing. It is now <em><span class=\"player-turn\"></span>'s</em> turn.\n Anyone who takes from their board will have to pay <span class=\"player-turn\"></span> a one coin\n tax.`;\n break;\n\n case 'final round':\n modalTitle = `The end is nigh!`;\n modalBody = `<span id=\"final-player\">${finalPlayer}</span> has <span id=\"final-points\">${finalPlayerPoints}</span> points, which has triggered the final round. Play will continue until it is <span id=\"final-round\">${finalPlayerName}</span>'s turn.</p>\n <p>Reminder: The person with the most points wins, if there's a tie, the person with the most coins\n left wins.`;\n break;\n\n case 'expedition':\n modalTitle = `A new expedition`;\n modalBody = `You've found a new expedition. This will be added to the expeditions board and can be purchased on your turn if you have the correct resources.`;\n break;\n\n case 'additional move':\n modalTitle = `You gained a move!`;\n modalBody = `You've earned an additional move for being a risk-taker and having <em>${shipColors}</em> different colored ships on the board!`;\n break;\n\n case 'must draw':\n modalTitle = `Must draw at least one card`;\n modalBody = `Sorry. Them's the rules. You have to draw at least one card before you can end your turn. Take it up\n with Alexander Pfister.`;\n break;\n\n case 'governor purchased':\n modalTitle = `You gained a move`;\n modalBody = `The Governor you just purchased has given you an additional move`;\n break;\n \n case 'admiral bonus':\n modalTitle = `You got some coins`; \n modalBody = `You've earned <span id=\"admiral-bonus\">${admiralBonus}</span> additional coins from the Admirals in your crew.\n Hoo-arrh!`;\n break;\n \n case 'phase two':\n modalTitle = `Can't draw any more`;\n modalBody = `Once you have taken a card from the board, you can't draw any more cards from the deck. RTFM.`;\n break;\n\n case 'deck disabled':\n modalTitle = `Deck is disabled`;\n modalBody = `You can't make any more moves. Time to pass the turn to someone else Greedy McGreedyPants.`;\n modalOnclick = `onclick=\"endTurn()\"`;\n break;\n \n case 'not your turn':\n modalTitle = `Not your turn`;\n modalBody = `You can only draw cards when it's your turn. (The blue dot next to a player's name indicates whose turn it is.)`;\n break;\n\n case 'two ships':\n modalTitle = `Oh no!`;\n modalBody = `You pushed your luck too far. There are two ships of the same color on the board! Sadly, this is the end of this turn.`;\n modalOnclick = `onclick=\"twoShips()\"`;\n modalButtonText = 'End turn';\n break;\n\n case 'defeat ship':\n modalTitle = `Defeat this ship?`;\n modalBody = `Looks like you've got enough firepower to defeat this ship, would you like to blast it into the deep, or keep it on the board?`;\n modalOnclick = `onclick=\"defeatShip()\"`;\n modalButtonText = `Defeat it!`;\n break;\n\n case 'moves left':\n modalTitle = `Still have moves left`;\n modalBody = `Hey what's the rush, there are still moves you can take. Are you sure you want to end your turn?`;\n modalOnclick = `onclick=\"clearMoves()\"`;\n modalButtonText = 'End my turn';\n break;\n \n default:\n break;\n }\n\n modalHtml = `\n <div class=\"modal-dialog modal-dialog-centered\" role=\"document\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <h5 class=\"modal-title\">${modalTitle}</h5>\n <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\" ${type === 'tax' ? `id=\"tax-modal-body\"` : ''}>\n <div id=\"defeat-ship\" class=\"d-flex justify-content-center\">${shipToDefeat !== null ? composeCard(shipToDefeat, 'modal') : ''}</div>\n <div id=\"tax-card\" class=\"d-flex justify-content-center\">${type === 'tax' ? composeCard(taxCard, 'modal') : ''}</div>\n <p>${modalBody}</p>\n </div>\n <div class=\"modal-footer\">\n ${type === 'defeat ship' ? `<button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\"\n onclick=\"declineDefeatOption()\">Keep it</button>` : ''}\n ${type === 'moves left' ? `<button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Cancel</button>` : ''}\n <button type=\"button\" class=\"btn btn-primary\" ${modalOnclick ? modalOnclick : ''} data-dismiss=\"modal\">${modalButtonText}</button>\n </div>\n </div>\n </div>\n `;\n\n getModal.innerHTML = modalHtml; // render the HTML\n $('#modal').modal(); // trigger the modal\n \n}", "title": "" }, { "docid": "0aa0e715af390ad05fcea908d9466c4d", "score": "0.5390948", "text": "function payment(payment_type, uid) {\n ClientPayment.close_credit(payment_type, uid)\n .then(closeSuccessFn, closeErrorFn);\n\n /**\n * @name closeSuccessFn\n * @desc Update ClubCard array on view\n */\n function closeSuccessFn(data, status, headers, config) {\n console.log('success')\n activate()\n }\n\n /**\n * @name closeErrorFn\n * @desc console log error\n */\n function closeErrorFn(data, status, headers, config) {\n console.log(data);\n }\n }", "title": "" }, { "docid": "46d070b0e338b19a8fd9420151736ff9", "score": "0.53858685", "text": "function show_shipping_handling_page_content() {\n\tif (checksameurl(location.href, shipping_handling_page) == true && shipping_handling_auto_content == true) {\n\t\tdocument.write('<h6>' + translate_sentence('What shipping methods do you offer?') + '</h6>');\n\t\tdocument.write(translate_sentence('The order will be sent directly to your address') + '. ');\n\t\tdocument.write(translate_sentence('The total shipping time is the order picking + handling time + shipping time') + '. ');\n\t\tdocument.write(translate_sentence('Normally, the processing time is very low') + '. ');\n\t\tdocument.write(translate_sentence('The shipping methods available are') + ':<p>');\n\t\tfor (var i = 0; i < shipping_types.length; i++) {\n\t\t\tdocument.write(translate_sentence(shipping_types[i][0]) + ' (' + shipping_types[i][1] + ' ' + translate_sentence('days approx.') + ')<br>');\n\t\t}\n\t\tdocument.write('</p><br>* ' + translate_sentence('The shipping time can vary depending on the country') + '. ');\n\t\tdocument.write(translate_sentence('You will choose the shipping method on checkout') + '.');\n\t\tdocument.write('<br/><br/><h6>' + translate_sentence('How do I calculate shipping costs?') + '</h6>');\n\t\tif (shipping_method == 1) {\n\t\t\tif (shipping_types.length == 1) {\n\t\t\t\tdocument.write(translate_sentence('The shipping cost is') + shipping_types[0][4] + ' ' + translate_sentence('regardless of the products you buy'));\n\t\t\t} else {\n\t\t\t\tdocument.write(translate_sentence('The shipping cost will vary depending the shipping method you select') + '. ');\n\t\t\t\tdocument.write(translate_sentence('You can see it on checkout') + '.');\n\t\t\t}\n\t\t} else {\n\t\t\tdocument.write(translate_sentence('The shipping cost will vary depending the shipping method you select') + '. ');\n\t\t\tdocument.write(translate_sentence('The shipping cost will also vary depending on the weight of the products you add to cart') + '.');\n\t\t}\n\t\tif (track_price !== false) {\n\t\t\tdocument.write('<br/><br/><h6>' + translate_sentence('How can I track my package?') + '</h6>');\n\t\t\tdocument.write(translate_sentence('If you choose the tracking number on checkout, you will get your tracking number and you will track') + '.');\n\t\t}\n\t\tdocument.write('<br/><br/><h6>' + translate_sentence('Do you ship to my country?') + '</h6>');\n\t\tif (world_shipping == true) {\n\t\t\tdocument.write(translate_sentence('Do not worry! We send to worldwide') + '.');\n\t\t} else {\n\t\t\tdocument.write(translate_sentence('Actually we send to') + ': ');\n\t\t\tif (country_list.length == 1) { document.write(translate_sentence(country_list[0]) + '. '); }\n\t\t\telse {\n\t\t\t\tfor (var i = 0; i < country_list.length; i++) {\n\t\t\t\t\tif (i == country_list.length - 1) { document.write(' ' + translate_sentence('and') + ' '); }\n\t\t\t\t\tdocument.write(translate_sentence(country_list[i]));\n\t\t\t\t\tif (i != country_list.length - 1) { document.write(', '); }\n\t\t\t\t}\n\t\t\t\tdocument.write('. '+ translate_sentence('If you do not find your county in the list, contact us') + '.');\n\t\t\t}\n\t\t}\n\t\tdocument.write('<br/><br/><h6>' + translate_sentence('If custom duties are incurred, who is responsible?') + '</h6>');\n\t\tdocument.write(translate_sentence('It is the responsibility of the customer for any custom duty fees that may be charged upon delivery') + '. ');\n\t\tdocument.write(translate_sentence('The import duty will depend of the custom policies of each country') + '. ');\n\t\tdocument.write('<br/><br/><h6>' + translate_sentence('If the Package held by Customs, who will be responsible for Package clearance?') + '</h6>');\n\t\tdocument.write(translate_sentence('If the items are detained by Customs after the shipment is done, the buyer is responsible for clearance of the detained items') + '. ');\n\t\tdocument.write('<br/><br/><h6>' + translate_sentence('How do I change my shipping address?') + '</h6>');\n\t\tdocument.write(translate_sentence('If your order has been sent, you cannot change your shipping address. If the packet is not sent, contact us quickly') + '. ');\n\t}\n}", "title": "" }, { "docid": "3065957dd49c431366cf15e175e110a9", "score": "0.5341474", "text": "function setPaymentPanel(value) {\n if (\n document.getElementsByTagName(\"form\")[0]\n .childNodes[3] &&\n document.getElementsByTagName(\"form\")[0]\n .childNodes[3]\n ) {\n document.getElementsByTagName(\n \"form\"\n )[0].childNodes[3].style.display = value;\n document.getElementsByTagName(\n \"form\"\n )[0].childNodes[4].style.display = value;\n }\n }", "title": "" }, { "docid": "97579b6c2425a5b3a09b22ab2a5dfdd6", "score": "0.53351355", "text": "function changePaymentMethod() {\t\t\t\n\tvar form = document.ftForm1;\t\t\n\tvar paymentMethod;\n\tfor (var i = 0; i < form.payment_method.length; i++) {\n\t\tif (form.payment_method[i].checked == true) {\n\t\t\tpaymentMethod = form.payment_method[i].value ;\n\t\t\tbreak;\n\t\t}\n\t}\t\n\tvar trCardNumber = document.getElementById('tr_card_number');\n\tvar trExpDate = document.getElementById('tr_exp_date');\n\tvar trCvvCode = document.getElementById('tr_cvv_code');\n\tvar trCardType = document.getElementById('tr_card_type') ;\n\tvar trCardHolderName = document.getElementById('tr_card_holder_name');\n\tvar trCardHead = document.getElementById('tr_card_head');\n\t//var trBankList = document.getElementById('tr_bank_list');\n\tmethod = methods.Find(paymentMethod);\n\tif (method.getCreditCard()) {\n\t\ttrCardHead.style.display = \"\";\n\t\ttrCardNumber.style.display = \"\";\t\t\t\t\n\t\ttrExpDate.style.display = \"\";\t\t\t\t\n\t\ttrCvvCode.style.display = \"\";\n\t\tif (method.getCardType()) {\n\t\t\ttrCardType.style.display = '';\n\t\t} else {\n\t\t\ttrCardType.style.display = 'none';\n\t\t}\n\t\tif (method.getCardHolderName()) {\n\t\t\ttrCardHolderName.style.display = '';\n\t\t} else {\n\t\t\ttrCardHolderName.style.display = 'none';\n\t\t}\n\t} else {\n\t\ttrCardHead.style.display = \"none\";\n\t\ttrCardNumber.style.display = \"none\";\t\t\t\t\n\t\ttrExpDate.style.display = \"none\";\t\t\t\t\n\t\ttrCvvCode.style.display = \"none\";\n\t\ttrCardType.style.display = 'none';\n\t\ttrCardHolderName.style.display = \"none\";\t\t\n\t}\n\t\n\t\n\t//if (paymentMethod == 'os_ideal') {\n\t\t//trBankList.style.display = '' ;\n\t//} else {\n\t\t//if (trBankList) {\n\t\t\t//trBankList.style.display = 'none' ;\n\t\t//}\n\t//}\t\n}", "title": "" }, { "docid": "adbe446989b5402186564ecd8c53ee9f", "score": "0.53280705", "text": "function displayPayment (divPayment) {\n //first reset\n creditCardDiv.style.display = 'none';\n paypalDiv.style.display = 'none';\n bitcoinDiv.style.display = 'none';\n //second assign\n divPayment.style.display = '';\n }", "title": "" }, { "docid": "92eb7193d092bfbe9985d29ef88ae61e", "score": "0.5327808", "text": "function render(type, ...data){\n switch(type) {\n case 'questlist': \n renderQuestList(...data); \n break; \n case 'quest-dialog': \n renderQuestDialog(...data); \n break; \n default: \n break; \n }\n}", "title": "" }, { "docid": "d608e699376fda737cc1fc05b2099321", "score": "0.5327693", "text": "renderDnsFormFromType(type){\n const { textDescriptionStyle, buttonLocationStyle } = styles;\n switch(type){\n case '0':\n return(\n <View>\n <CardSection>\n <Input\n label=\"Host Name:\"\n placeholder=\"mmsuite.company.com\"\n onChangeText={ this.onDomainNameChanged.bind(this) }\n value={ this.props.domain }\n />\n </CardSection>\n <CardSection>\n <Input\n label=\"TTL:\"\n placeholder=\"604800s = 1 week\"\n onChangeText={ this.onTTLChanged.bind(this) }\n value={ this.props.ttl }\n keyboardType=\"numeric\"\n />\n </CardSection>\n <CardSection>\n <View style={ buttonLocationStyle }>\n { this.renderApplyButton(this.state.dnsRecordType) }\n </View>\n </CardSection>\n </View>\n );\n case '1':\n return(\n <Text style={ textDescriptionStyle }>NS Records Coming Soon</Text>\n );\n case '2':\n return(\n <Text style={ textDescriptionStyle }>CNAME Records Coming Soon</Text>\n );\n case '3':\n return(\n <Text style={ textDescriptionStyle }>SOA Records Coming Soon</Text>\n );\n case '4':\n return(\n <Text style={ textDescriptionStyle }>PTR Records Coming Soon</Text>\n );\n case '5':\n return(\n <Text style={ textDescriptionStyle }>MX Records Coming Soon</Text>\n );\n default:\n }\n }", "title": "" }, { "docid": "9733b29f4bd34e5c89a800f03ca45dd9", "score": "0.53108674", "text": "function choosePayoutMethod(value) {\n var method_id = value;\n switch(method_id) {\n \n case '1' :\n jQuery(\"#saving\").show();\n jQuery(\"#tobank\").hide();\n jQuery(\"#topaypal\").hide();\n break;\n case '2' :\n jQuery(\"#saving\").hide();\n jQuery(\"#tobank\").show();\n jQuery(\"#topaypal\").hide();\n break;\n case '3' :\n jQuery(\"#saving\").hide();\n jQuery(\"#topaypal\").show();\n jQuery(\"#tobank\").hide();\n break;\n default :\n jQuery(\"#saving\").show();\n jQuery(\"#tobank\").hide();\n jQuery(\"#topaypal\").hide();\n break;\n }\n\n}", "title": "" }, { "docid": "ef4dfe501dfcabb297c0f1c26d9f8bbe", "score": "0.5258753", "text": "render() {\n var displayContent = () => {\n var activeTab = this.props.activeTab;\n if (activeTab === 1) {\n return <Text />;\n } else if (activeTab === 2) {\n return <Image />;\n } else if (activeTab === 3) {\n return <Video />;\n } else if (activeTab === 4) {\n return <Table />;\n } else if (activeTab === 5) {\n return <Email />;\n } else {\n return <Zoom />;\n }\n };\n return displayContent();\n }", "title": "" }, { "docid": "ec27fe6b080d5430704325000b8dc2be", "score": "0.5252295", "text": "function processPaymentStatus(paymentStatus)\n{\n if (!rowPaymentStatus)\n return;\n\n $(rowPaymentStatus).removeClass(\"warning\");\n $(rowPaymentStatus).removeClass(\"danger\");\n $(rowPaymentStatus).removeClass(\"success\");\n for (var i = 0; i < 4; i++)\n {\n $(\"#feeInfo\" + i).toggle(i == paymentStatus);\n $(\"#feeStatus\" + i).toggle(i == paymentStatus);\n }\n switch (paymentStatus)\n {\n case 0: // paid\n $(rowPaymentStatus).addClass(\"success\");\n $(feeMoreToPayDisp).hide();\n $(feeOverpaidDisp).hide();\n if (feeTotal == 0)\n {\n $(\"#feeInfo0\").hide();\n $(\"#feeStatus0\").hide();\n $(rowPaymentStatus).hide();\n }\n break;\n case 1: // overpaid\n $(feeMoreToPayDisp).hide();\n $(feeOverpaidDisp).show();\n $(rowPaymentStatus).addClass(\"success\");\n $(rowPaymentStatus).show();\n break;\n case 2: // more to pay\n $(feeMoreToPayDisp).show();\n $(feeOverpaidDisp).hide();\n $(rowPaymentStatus).addClass(\"warning\");\n $(rowPaymentStatus).show();\n if (feePaymentDlgValue)\n feePaymentDlgValue.value = feeMoreToPayDisp.get();\n break;\n case 3: // not paid\n $(feeMoreToPayDisp).show();\n $(feeOverpaidDisp).hide();\n $(rowPaymentStatus).addClass(\"danger\");\n $(rowPaymentStatus).show();\n if (feePaymentDlgValue)\n feePaymentDlgValue.value = feeMoreToPayDisp.get();\n break;\n default:\n break;\n }\n}", "title": "" }, { "docid": "f5bd1443e7708832ebd01f32ab3f8588", "score": "0.52521384", "text": "function setPaymentTypeSelect(payment_method) {\r\n \r\n var bank_account_type_element = document.getElementsByName(bank_account_type_name);\r\n\r\n if (payment_type_select_id){\r\n var payment_type_select = document.getElementById(payment_type_select_id);\r\n }\r\n\r\n if (bank_account_type_element.length){\r\n var bank_account_type = document.getElementsByName(bank_account_type_name)[0];\r\n }\r\n\r\n switch(payment_method) {\r\n case 'paypal':\r\n if (payment_type_select){\r\n window.addSelectValue(payment_type_select, 'PayPal', 'Paypal', true);\r\n window.removeSelectValue(payment_type_select, 'ACH');\r\n }\r\n\r\n if (typeof bank_account_type == 'object'){\r\n bank_account_type.value = '';\r\n }\r\n break;\r\n case 'card':\r\n if (payment_type_select){\r\n window.removeSelectValue(payment_type_select, 'Paypal');\r\n window.removeSelectValue(payment_type_select, 'ACH');\r\n }\r\n\r\n if (typeof bank_account_type == 'object'){\r\n bank_account_type.value = '';\r\n }\r\n break;\r\n case 'check':\r\n if (payment_type_select){\r\n window.addSelectValue(payment_type_select, 'Check', 'ACH', true);\r\n window.removeSelectValue(payment_type_select, 'Paypal');\r\n }\r\n\r\n if (typeof bank_account_type == 'object'){\r\n bank_account_type.value = 'Checking';\r\n }\r\n break;\r\n }\r\n\r\n }", "title": "" }, { "docid": "cde1d92d68d4a7bb2e4ffcb6151a3e40", "score": "0.5250877", "text": "function storagePayment(type)\n{\n if(type== 'usual')\n {\n document.getElementById('storage-cost').innerText= 0;\n \n }\n else if(type== 'medium')\n {\n document.getElementById('storage-cost').innerText= 100;\n }\n else if(type== 'large')\n {\n document.getElementById('storage-cost').innerText= 180;\n }\n finalTotal();\n\n}", "title": "" }, { "docid": "811caebef84d6123739a6c23e73edd4c", "score": "0.5244541", "text": "function setupView(type) {\r\n // Set link to return to when back button is pressed\r\n document.getElementById('link').setAttribute('href', localStorage.getItem('link'));\r\n\r\n // Get data from localStorage based on type of flight\r\n var index = -1;\r\n var data = {};\r\n\r\n if (type == 0) {\r\n data = JSON.parse(localStorage.getItem('chosenDeparture'));\r\n }\r\n\r\n else {\r\n data = JSON.parse(localStorage.getItem('chosenReturn'));\r\n }\r\n\r\n // Populate info template\r\n var parentDiv = $('#info');\r\n var template = Handlebars.compile(document.getElementById('infoTemplate').innerHTML);\r\n var html = template(data);\r\n parentDiv.append(html);\r\n}", "title": "" }, { "docid": "86663b3c5d0ee8cf24e1a63c6226be97", "score": "0.52420926", "text": "function defaultPayment (index){\n paymentType.selectedIndex = index\n bitcoin.style.display = 'none';\n paypal.style.display = 'none';\n selectPayment.disabled = true;\n}", "title": "" }, { "docid": "a01785f64f6301d11d8a8c8b60b3b830", "score": "0.524044", "text": "function showFirst() {\n const request1 = new PaymentRequest(\n [{supportedMethods: 'https://bobpay.test'}, {supportedMethods: 'https://alicepay.test'}],\n {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});\n request1.show();\n}", "title": "" }, { "docid": "2a88253579e54b5067db8605cb30b792", "score": "0.52377564", "text": "function Payment () {\n return (\n <div class='payment-page-container'>\n <h1 class='secure'><span class=\"icomoon-lock align-items-center pr-3\"></span><img class='lock' src={Lock}/>Secure Payment</h1>\n <div class='payment-page'>\n \n <div class='cart'>\n <h1 class='cart-title'>Your cart</h1>\n </div>\n <div>\n <div class='summary'>\n <h1>Summary</h1>\n <h3>Total</h3>\n \n <a class='href' href='https://www.paypal.com/paypalme/tenniscoachesofnyc'>\n <button class='stripe-checkout'>Proceed to checkout</button>\n <h4 class='href'>-OR-</h4>\n <a href='https://www.paypal.com/paypalme/tenniscoachesofnyc'>\n <button class='paypal-checkout' >Checkout with <table border=\"0\" cellpadding=\"10\" cellspacing=\"0\" align=\"center\"><tr><td align=\"center\"></td></tr><tr><td align=\"center\"><a href=\"https://www.paypal.com/paypalme/tenniscoachesofnyc\" title=\"How PayPal Works\" onclick=\"javascript:window.open('https://www.paypal.com/paypalme/tenniscoachesofnyc','WIPaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700'); return false;\"><img src=\"https://www.paypalobjects.com/webstatic/mktg/logo/pp_cc_mark_37x23.jpg\" border=\"0\" alt=\"PayPal Logo\" /></a></td></tr></table></button></a></a>\n </div>\n {/* <a target=\"_blank\" rel=\"noopener noreferrer\" href='http://paypal.me/tenniscoachesofnyc'><img src=\"https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png\" alt=\"Check out with PayPal\" /></a>\n <h2 class='or'>Or:</h2>\n <a target=\"_blank\" rel=\"noopener noreferrer\" href='https://venmo.com/Artemie-Amari'><img class='venmo' src={Venmo}/></a> */}\n {/* <div class='accepted'>\n <h3>Accepted Payment Methods</h3>\n </div> */}\n </div>\n </div>\n </div>\n );\n }", "title": "" }, { "docid": "a4b38c16c744a8ea6d1b203dccea7115", "score": "0.5227234", "text": "function showCorByType(type)\n\t\t\t{\n\t\t\t\n\t\t\t\tif(type==\"ALL\")\n\t\t\t\t\t{\n\t\t\t\t\t$(\"#tbl_corres .corType_all\").show();\n\t\t\t\t\t$(\"#tbl_corres .corType_draft\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_letter\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_object\").hide();\n\t\t\t\t\t}\n\t\t\t\telse if(type==\"DRAFT\")\n\t\t\t\t\t{\n\t\t\t\t\t$(\"#tbl_corres .corType_draft\").show()\n\t\t\t\t\t$(\"#tbl_corres .corType_all\").hide();\n\t\t\t\t\t\n\t\t\t\t\t$(\"#tbl_corres .corType_letter\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_object\").hide();\n\t\t\t\t\t}\n\t\t\t\telse if(type==\"LETTER\")\n\t\t\t\t{\n\t\t\t\t\t$(\"#tbl_corres .corType_letter\").show();\n\t\t\t\t\t$(\"#tbl_corres .corType_all\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_draft\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_object\").hide();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse if(type==\"OBJECT\")\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\t$(\"#tbl_corres .corType_object\").show();\n\t\t\t\t\t$(\"#tbl_corres .corType_letter\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_all\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_draft\").hide();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t$(\"#tbl_corres .corType_all\").show();\n\t\t\t\t\t$(\"#tbl_corres .corType_draft\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_letter\").hide();\n\t\t\t\t\t$(\"#tbl_corres .corType_object\").hide();\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t}", "title": "" }, { "docid": "95a60982ba0ade2bafde972625a75991", "score": "0.5222207", "text": "function raNumberInputDisplayCheck()\r\n {\r\n if ($claimType == 'Warranty')\r\n {\r\n $('#claimdetails-ranumber-div').show();\r\n }\r\n else\r\n {\r\n $('#claimdetails-ranumber-div').hide();\r\n }\r\n }", "title": "" }, { "docid": "95a60982ba0ade2bafde972625a75991", "score": "0.5222207", "text": "function raNumberInputDisplayCheck()\r\n {\r\n if ($claimType == 'Warranty')\r\n {\r\n $('#claimdetails-ranumber-div').show();\r\n }\r\n else\r\n {\r\n $('#claimdetails-ranumber-div').hide();\r\n }\r\n }", "title": "" }, { "docid": "bfe85f72eb42f9831003f5d6bfd60ad4", "score": "0.5219435", "text": "showViewComp (type) {\n\t\t\tthis.$axios.get('api/do_m_scrpt_code/getThisScrpt/'+this.manu_script_id).then(res => {\n\t\t\t\tif (type == 'add') {\n\t\t\t\t\tthis.allManScrpt = res.data.data;\n\t\t\t\t\tthis.is_view_com = true;\n\t\t\t\t} else this.$emit('rowFunc','AuthorManuscriptView',res.data.data);\n\t\t\t});\n\t\t}", "title": "" }, { "docid": "3f03169938e04b8eddda34c20ba5a267", "score": "0.5184385", "text": "function handleSameCashDiffCashConf(type){\n\tswitch (type)\n\t{\n\t\tcase \"D\":\n\t\t\tcashButtonstatus =\"S\";\t\t\n\t\t\t$(\"#diffCashFlag\").val(\"D\");\n $(\"#uCashSide2_1\").show();\n\t\t $(\"#uCashSide2_2\").show();\n\t\t $(\"#uCashSide2_3\").show();\n\t\t $(\"#uCashSide2_4\").show();\n\t\t $(\"#uCashSide2_51\").show();\n\t\t\t$(\"#uCashSide2_52\").show();\n\t\t $(\"#uCashSide2_6\").show();\n\t\t $(\"#uCashSide2_7\").show();\n\t\t $(\"#uCashSide2_8\").show();\n\t\t $(\"#uCashSide2_9\").show();\n\t\t $(\"#uCashSide2_10\").show();\n\t\t $(\"#cashOurdetails\").show();\n\t\t $(\"#cashCpdetails\").show();\n\t\t\thandleSSILayoutForCashConf();\n\t\t\tbreak;\n\t\tcase \"S\":\n\t\t\tcashButtonstatus =\"D\";\n\t\t\t$(\"#diffCashFlag\").val(\"S\");\n\t\t\t$(\"#uCashSide2_1\").hide();\n\t\t $(\"#uCashSide2_2\").hide();\n\t\t $(\"#uCashSide2_3\").hide();\n\t\t $(\"#uCashSide2_4\").hide();\n\t\t $(\"#uCashSide2_51\").hide();\n\t\t\t$(\"#uCashSide2_52\").hide();\n\t\t $(\"#uCashSide2_6\").hide();\n\t\t $(\"#uCashSide2_7\").hide();\n\t\t $(\"#uCashSide2_8\").hide();\n\t\t $(\"#uCashSide2_9\").hide();\n\t\t $(\"#uCashSide2_10\").hide();\n\t\t $(\"#cashOurdetails\").hide();\n\t\t $(\"#cashCpdetails\").hide();\n\t\t\tbreak;\n\t}\n}", "title": "" }, { "docid": "5bbed93bd02ee5ed588c198a87156d6f", "score": "0.51714677", "text": "render(){\n //RENDER LOGIC HERE\n\n return(\n <div class=\"five columns offset-by-half text-center payCell\">\n <Pricing />\n <Options />\n </div>\n )\n }", "title": "" }, { "docid": "3b0779b36cfd08672da09257ffbd5eb9", "score": "0.51696557", "text": "render() {\n return (\n <div>\n <PageHeader pageTitle='Make a Monetary Contribution'/>\n \n {/* stripe components */}\n </div>\n )\n }", "title": "" }, { "docid": "f526e82d70c6614dd5447f3faec5c8e8", "score": "0.515869", "text": "function formatOutput () {\n\n // one country selected, either by search criteria or by clicking the buttob\n if(theCountry.name !== undefined ) {\n return (\n <div>\n {ListCountryDetails(theCountry)}\n </div>\n )\n }\n\n // no matches with the name\n if(foundCountries.length === 0 ) {\n return (\n <div>\n <p>No macthes </p>\n </div>\n )\n }\n\n // listing 2 ... 10 countries based on the seach criteria with the select button\n if ((foundCountries.length >= 2) && (foundCountries.length <= 10)) {\n return (foundCountries.map(buildRowToSelect)) \n }\n\n return (\n <div>\n <p>Too many matches, specify an other filter </p>\n </div>\n )\n }", "title": "" }, { "docid": "448586a941255ea2993004f396002a64", "score": "0.51534915", "text": "function PaymentDetails(radio_id)\n\t{\n\t\tvar airtel= document.getElementById('airtel');\n\t\tvar mtn= document.getElementById('mtn');\n\t\tvar visa= document.getElementById('visa');\n\t\tvar zoona= document.getElementById('zoona');\n\t\tvar mtnblock = \"MTN Money\";\n\t\tvar airtelblock = \"Airtel Money\";\n\t\tvar zoonablock = \"Zoona\";\n\t\tvar visablock = \"Visa\";\n\t\t\n\t\t// selected radio button blocks the display of other forms\n\t\tif(radio_id==mtnblock){\n\t\t\tmtn.style.display=\"block\";\t\t\t\t\t\n\t\t\tairtel.style.display=\"none\";\n\t\t\tvisa.style.display=\"none\";\n\t\t\tzoona.style.display=\"none\";\n\t\t}else if(radio_id==airtelblock){\n\t\t\t$('#airtel').show();\n\t\t\tmtn.style.display=\"none\";\n\t\t\tairtel.style.display=\"block\";\n\t\t\tvisa.style.display=\"none\";\n\t\t\tzoona.style.display=\"none\";\n\t\t}else if(radio_id==visablock){\n\t\t\tmtn.style.display=\"none\";\n\t\t\tairtel.style.display=\"none\";\n\t\t\tvisa.style.display=\"block\";\n\t\t\tzoona.style.display=\"none\";\n\t\t}else if(radio_id==zoonablock){\n\t\t\tmtn.style.display=\"none\";\n\t\t\tairtel.style.display=\"none\";\n\t\t\tvisa.style.display=\"none\";\n\t\t\tzoona.style.display=\"block\";\n\t\t}else{\n\t\t\t alert(\"Sorry!\");\n\t\t}\n\t}", "title": "" }, { "docid": "885d86697632fa629e3c97f3193b43f9", "score": "0.5149272", "text": "function render(){\n $('main').html(choiceTemplate());\n}", "title": "" }, { "docid": "9bb089c7b4a3476d69c00568e72cdff2", "score": "0.51465917", "text": "function cash_payment(){\n if($(\"payment_is_cash\").checked ==true) {\n $(\"cash_div\").show();\n }\n else{\n $(\"cash_div\").hide();\n }\n }", "title": "" }, { "docid": "2a5966886cad78864f5920590bd4a726", "score": "0.5133202", "text": "function showPurchases() {\n app.getView().render('account/giftregistry/purchases');\n}", "title": "" }, { "docid": "c49189b9e4600df4c9aeb508e5338f1c", "score": "0.51238286", "text": "render($$) {\n let elementCitation = this.props.node.find('element-citation')\n let publicationType = elementCitation.getAttribute('publication-type')\n let el = $$('div').addClass('sc-edit-ref')\n\n if(publicationType === 'journal') {\n el.append(this._renderJournalRefForm($$))\n } else if (publicationType === 'book') {\n el.append(this._renderBookRefForm($$))\n } else {\n el.append(`Editing of the publication type ${publicationType} is not yet supported in this Alpha version.`)\n }\n return el\n }", "title": "" }, { "docid": "f54cfab9acec7620dced465c926f6cb6", "score": "0.5121224", "text": "function listPaymentMethods() {\n PagSeguroDirectPayment.getPaymentMethods({\n amount: Amount,\n success: function (data) {\n // Returns available payment methods.\n $.each(data.paymentMethods.CREDIT_CARD.options, function (i, obj) {\n $('.credit-card').append(\"<div><img src=https://stc.pagseguro.uol.com.br/\" + obj.images.MEDIUM.path + \" />\" + obj.name + \"</div>\");\n });\n\n $('.boleto').append(\"<div><img src=https://stc.pagseguro.uol.com.br/\" + data.paymentMethods.BOLETO.options.BOLETO.images.MEDIUM.path + \">\" + data.paymentMethods.BOLETO.name + \"</div>\");\n\n $.each(data.paymentMethods.ONLINE_DEBIT.options, function (i, obj) {\n $('.debit').append(\"<div><img src=https://stc.pagseguro.uol.com.br/\" + obj.images.MEDIUM.path + \">\" + obj.name + \"</div>\");\n });\n }\n });\n}", "title": "" }, { "docid": "60d220be335d4a75e4cf1272d1d7f51d", "score": "0.51136416", "text": "function renderSwitcher(latestStatus) {\n switch (latestStatus) {\n case 'QUOTATION':\n return <PurchaseOrderQuotationContent \n purchaseOrderStateData={purchaseOrderStateData} \n purchaseOrderMetaData={purchaseOrderMetaData}\n />\n case 'CONFIRMED':\n return <PurchaseOrderConfirmedContent \n purchaseOrderStateData={purchaseOrderStateData} \n purchaseOrderMetaData={purchaseOrderMetaData}\n />\n case 'RECEIVED':\n return <PurchaseOrderReceivedContent \n purchaseOrderStateData={purchaseOrderStateData} \n purchaseOrderMetaData={purchaseOrderMetaData}\n />\n case 'FULFILLED':\n return <PurchaseOrderFulfilledContent \n purchaseOrderStateData={purchaseOrderStateData} \n purchaseOrderMetaData={purchaseOrderMetaData}\n />\n case 'CANCELLED':\n return <PurchaseOrderCancelledContent \n purchaseOrderStateData={purchaseOrderStateData} \n purchaseOrderMetaData={purchaseOrderMetaData}\n />\n default:\n return <Spin>Loading</Spin>\n }\n }", "title": "" }, { "docid": "1254d13bc331d98e884683a57aaae97d", "score": "0.5112822", "text": "function render(type, ...data){\n switch(type) {\n case 'questlist':\n renderQuestList(...data);\n break;\n case 'quest-dialog':\n renderQuestDialog(...data);\n break;\n case 'update-game-menu':\n debugger; \n updateGameMenu();\n break;\n case 'start-progress-bar': \n updateProgressBar(...data);\n break; \n default:\n break;\n }\n}", "title": "" }, { "docid": "ccc975e0f41806374fb68040d0487012", "score": "0.5110554", "text": "function showReceipt(trxType, ccIndex) {\n var winOptions = \"width=650,height=550,location=no,menubar=no,status=no,toolbar=no\";\n if (trxType == 'CR') {\n window.open(\"../reports/showCreditReceipt.htm?csrfToken=\" + csrfToken + \"&ccIndex=\" + ccIndex,\n \"_blank\", winOptions);\n } else if (trxType == 'S') {\n window.open(\"../reports/showSettlementReceipt.htm?csrfToken=\" + csrfToken + \"&ccIndex=\" + ccIndex,\n \"_blank\", winOptions);\n } else {\n window.open(\"../reports/showReceipt.htm?csrfToken=\" + csrfToken, \"_blank\", winOptions);\n }\n}", "title": "" }, { "docid": "8aea70f4c3390321c05402b0bb329d06", "score": "0.51105", "text": "function renderCalculator(mission) {\n let condition = mission.Condition;\n let conditionType = condition.ConditionType;\n if ([\"ResourceQuantity\", \"IndustryUnlocked\", \"ResourcesEarnedSinceSubscription\"].includes(conditionType)) {\n // First figure out which industry to display and calculate\n let industryId = \"\";\n if (conditionType == \"ResourceQuantity\") {\n industryId = getGenerator(condition.ConditionId).IndustryId;\n } else if (conditionType == \"IndustryUnlocked\") {\n // Choose the industry to the left of the one to unlock.\n let unlockableIndustryIndex = getData().Industries.findIndex(i => i.Id == condition.ConditionId);\n industryId = getData().Industries[unlockableIndustryIndex - 1].Id;\n } else if (conditionType == \"ResourcesEarnedSinceSubscription\") {\n if (condition.ConditionId.toLowerCase() == \"scientist\") {\n // We currently don't support a calculator collecting science\n return \"Mission type currently unsupported. Check back next event!\";\n }\n \n industryId = getIndustryByResource(condition.ConditionId).Id;\n }\n \n // Display comrade inputs, shared inputs, and generator inputs\n let html = `<table class=\"calcTable\"><tr><td class=\"pr-3\"><span class=\"mt-1 resourceIcon comrades float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"comrades\" placeholder=\"# of Comrades\"></span></td><td><span class=\"mt-1 resourceIcon comradesPerSec float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"comradesPerSec\" placeholder=\"Comrades/second\"></span></td></tr>`;\n html += `<tr><td class=\"pr-3\"><span class=\"mt-1 resourceIcon power float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"power\" placeholder=\"Power\"></span></td><td><span class=\"mt-1 resourceIcon discount float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"discount\" placeholder=\"Discount\"></span></td></tr>`;\n html += `<tr><td class=\"pr-3\"><span class=\"mt-1 resourceIcon critChance float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"critChance\" placeholder=\"Crit Chance\"></span></td><td><span class=\"mt-1 resourceIcon critPower float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"critPower\" placeholder=\"Crit Power\"></span></td></tr>`;\n \n let generators = getData().Generators.filter(g => g.IndustryId == industryId);\n for (let generator of generators) {\n let id = generator.Id;\n let name = resourceName(id);\n html += `<tr><td class=\"pr-3\"><span class=\"mt-1 resourceIcon float-left mr-2\" style=\"background-image: url('img/${currentMode}/${id}.png');\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"${id}-count\" placeholder=\"# of ${name}\"></span></td><td><span class=\"mt-1 resourceIcon speed float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"${id}-speed\" placeholder=\"Speed\"></span></td></tr>`;\n \n // Band-aid fix for tier-1 power rares in the motherland\n if (currentMode == \"main\" && id == generators[0].Id) {\n html += `<tr><td>&nbsp;</td><td><span class=\"mt-1 resourceIcon power float-left mr-2\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"${id}-power\" placeholder=\"Power\"></span></td></tr>`;\n }\n }\n \n let resource = getResourceByIndustry(industryId);\n html += `<tr><td class=\"pr-3\"><span class=\"mt-1 resourceIcon float-left mr-2\" style=\"background-image: url('img/${currentMode}/${resource.Id}.png');\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"resources\" placeholder=\"# of ${resourceName(resource.Id)}\"></span></td>`;\n if (conditionType == \"ResourcesEarnedSinceSubscription\") {\n html += `<td><span class=\"mt-1 resourceIcon float-left mr-2\" style=\"background-image: url('img/${currentMode}/${resource.Id}.png');\">&nbsp;</span><span class=\"calcInputContainer\"><input type=\"text\" class=\"form-control\" id=\"resourceProgress\" placeholder=\"Mission Progress\"></span></td></tr>`;\n } else {\n html += \"<td></td></tr>\";\n }\n html += \"</table>\";\n \n html += `<div class=\"form-check\"><input class=\"form-check-input\" type=\"checkbox\" value=\"\" id=\"configAutobuy\"><label class=\"form-check-label\" for=\"configAutobuy\">Auto-buy highest-tier generator</label></div>`;\n \n if (conditionType == \"ResourceQuantity\") {\n html += `<div class=\"form-check\"><input class=\"form-check-input\" type=\"checkbox\" value=\"\" id=\"configComradeLimited\" onclick=\"clickComradeLimited('${condition.ConditionId}')\"><label class=\"form-check-label\" for=\"configComradeLimited\">Limited by comrades only</label></div>`;\n }\n \n html += `<div class=\"form-inline\"><label for=\"configMaxDays\" class=\"mr-2\">Max Days:</label><input type=\"number\" class=\"form-control w-25\" min=\"1\" value=\"1\" id=\"configMaxDays\" placeholder=\"Max Days\"> \n <a class=\"btn btn-link infoButton\" tabindex=\"-1\" role=\"button\" data-toggle=\"popover\" data-trigger=\"focus\" data-content=\"Higher Max Days allows you to simulate further, but increases time when simulation doesn't succeed.\">&#9432;</a></div>`;\n \n html += `<p><strong>Result:</strong> <span id=\"result\"></span></p>`;\n html += `<input type=\"hidden\" id=\"missionId\" value=\"${mission.Id}\"><input type=\"hidden\" id=\"industryId\" value=\"${industryId}\">`;\n html += `<p><button id=\"calcButton\" class=\"btn btn-primary\" type=\"button\" onclick=\"doProductionSim()\">Calculate!</button></p>`;\n \n return html;\n } else {\n return \"Mission type currently unsupported. Check back next event!\";\n }\n}", "title": "" }, { "docid": "cef8a8ba2f200a76ff20930b3b657457", "score": "0.5110007", "text": "function product_type_click() {\n\tvar type = $('#product_type').val();\n\tif (type == 'variant') {\n\t\t$('.js-non-variant-unit-div').hide();\n\t\t$('#js-non-variant-weight-div').hide();\n\t\t$('#js-non-variant-dimentions-div').hide();\n\t\t$('.js-variant-div').show();\n\t\t// $('.js-variant-price-div').hide();\n\t} else {\n\t\tselect_type();\n\t\t// $('.js-non-variant-unit-div').show();\n\t\t$('.js-variant-div').hide();\n\t\t$('.js-variant-price-div').hide();\n\t}\n}", "title": "" }, { "docid": "3ddf81129e4964ea9094a5c3a7a7356f", "score": "0.5106962", "text": "function renderResponsiveTradesHTML(tradeType) {\n const openTrades = STATE.getOpenTrades();\n let container;\n let data;\n switch (tradeType) {\n case 'open':\n container = $('.tab-content #open-trades');\n data = STATE.getOpenTrades();\n break;\n case 'pending':\n container = $('.tab-content #pending-orders');\n data = STATE.getPendingTrades();\n break;\n case 'closed':\n container = $('.tab-content #closed-trades');\n data = STATE.getClosedTrades();\n break;\n }\n const rowsHTML = [];\n openTrades.forEach(trade => {\n rowsHTML.push(getResponsiveTradesRow(trade))\n })\n container.empty().append(`\n <div class=\"responsive-trades\">\n ${rowsHTML.join('')}\n ${getResponsiveTradesFooter(data.length, tradeType)}\n </div>`)\n registerTradeEvents();\n }", "title": "" }, { "docid": "9be1b7e12eb67b4af4c1122d3a7232fa", "score": "0.5100591", "text": "render() {\n if (this.state.isBeingEdited === false) {\n return this.renderQuote();\n } else {\n return this.renderEditForm();\n }\n }", "title": "" }, { "docid": "e3bb9a47de633398d63fa9028d138a9b", "score": "0.5100435", "text": "function dealType(type){\n\n\tshowAjaxLoader();\n\t\n\t//make ajax call\n\tjQuery.ajax({\n\t\ttype\t:\t'post',\n\t\turl\t\t:\t'index.php?task=filterDeals&view=deals&format=raw&tmpl=component',\n\t\tdata\t:\t'type='+type,\n\t\tdataType:\t'html',\n\t\tsuccess\t:\tfunction(data){\n\n\t\t\thideAjaxLoader();\n\t\t\t\n\t\t\t//assign new html\n\t\t\tjQuery.when(jQuery(\"#deals\").empty())\n\t\t\t.then(function(){\n\t\t\t\tjQuery(\"#deals\").html(data);\n\t\t\t});\n\t\t\t\n\t\t\t//update link message\n\t\t\tjQuery(\"#\"+current_area).html(jQuery(\"#deal_type a.filter_\"+type).text());\n\t\t\t\n\t\t}\n\t});\n\t\n}", "title": "" }, { "docid": "9bd7199efe52415f9e83fafa600bd461", "score": "0.50970256", "text": "function changeUserType(itm){\r\n\r\n if(itm == 'p') // primary user !\r\n {\r\n var ap_emptype = $(\"#ap_emptype\").val();\r\n var ap_resident = $(\"#ap_resident\").val();\r\n \r\n if(ap_emptype == '1' && ap_resident == '1'){\r\n var theTemplateScript = $(\"#tab1-psindian-template\").html();\r\n }\r\n else if(ap_emptype == '1' && ap_resident == '2'){\r\n var theTemplateScript = $(\"#tab1-psnri-template\").html();\r\n \r\n }\r\n else if(ap_emptype == '2' && ap_resident == '1'){\r\n var theTemplateScript = $(\"#tab1-pspindian-template\").html();\r\n\r\n }\r\n else if(ap_emptype == '2' && ap_resident == '2'){\r\n \r\n var theTemplateScript = $(\"#tab1-pspnri-template\").html();\r\n\r\n }\r\n else if(ap_emptype == '3' && ap_resident == '1'){\r\n\r\n var theTemplateScript = $(\"#tab1-psnpindian-template\").html();\r\n\r\n }\r\n else if(ap_emptype == '3' && ap_resident == '2'){\r\n \r\n var theTemplateScript = $(\"#tab1-psnpnri-template\").html();\r\n \r\n }\r\n\r\n var theTemplate = Handlebars.compile(theTemplateScript);\r\n $('#ppersontype').html(theTemplate());\r\n\r\n\r\n $('.income_amount').each(function(e,v) {\r\n var inc = $(this).val().replace(/,/g, \"\");\r\n inc = (ap_emptype == 1) ? (inc/12) : inc;\r\n if(inc != '') {\r\n if(e == 0) {\r\n $('#ap_grossincome').val(parseInt(inc));\r\n $('#ap_netincome').val(parseInt(inc));\r\n }\r\n }\r\n });\r\n\r\n }\r\n else if(itm == 'c'){\r\n\r\n var ap_emptype = $(\"#cp_emptype\").val();\r\n var ap_resident = $(\"#cp_resident\").val();\r\n \r\n\r\n if(ap_emptype == '1' && ap_resident == '1'){\r\n var theTemplateScript = $(\"#tab1-csindian-template\").html();\r\n }\r\n else if(ap_emptype == '1' && ap_resident == '2'){\r\n var theTemplateScript = $(\"#tab1-csnri-template\").html();\r\n \r\n }\r\n else if(ap_emptype == '2' && ap_resident == '1'){\r\n var theTemplateScript = $(\"#tab1-cspindian-template\").html();\r\n\r\n }\r\n else if(ap_emptype == '2' && ap_resident == '2'){\r\n \r\n var theTemplateScript = $(\"#tab1-cspnri-template\").html();\r\n\r\n }\r\n else if(ap_emptype == '3' && ap_resident == '1'){\r\n\r\n var theTemplateScript = $(\"#tab1-csnpindian-template\").html();\r\n\r\n }\r\n else if(ap_emptype == '3' && ap_resident == '2'){\r\n \r\n var theTemplateScript = $(\"#tab1-csnpnri-template\").html();\r\n \r\n }\r\n\r\n\r\n var theTemplate = Handlebars.compile(theTemplateScript);\r\n $('#cpersontype').html(theTemplate());\r\n\r\n }\r\n\r\n dynamic_bind();\r\n refreshSection();\r\n\r\n }", "title": "" }, { "docid": "13393791412ad2f1deeeae1b3010e829", "score": "0.50936246", "text": "function processPayment(req, res) { \n // Find the transaction by transport key\n var txn = _.find(state.transactions, { 'transportKey': req.query.TransportKey });\n\n if (txn===undefined) {\n return renderer.renderErrorResponse(res, \"FAILED\", \"Invalid Transport Key\", req.query.Format);\n }\n\n // Send the appropriate response body.\n if((/multitender/i).test(txn.clerkId)) {\n renderer.renderLoyaltyMultitenderResponse(res, txn.validationKey, txn.amount, req.query.Format);\n } else {\n renderer.renderSingleTenderResponse(res, txn.validationKey, txn.amount, req.query.Format);\n }\n \n // Remove the transaction now that the transport key has been used\n state.transactions = _.reject(state.transactions, { 'transportKey': req.query.TransportKey });\n}", "title": "" }, { "docid": "220144eb5de449049ab90cac6a80d430", "score": "0.5087822", "text": "function render(){\n let html='';\n if (store.quizStarted === false){\n html = generateStartPage();\n }else if (store.giveFeedback === true){\n html = generateQuestionsPage();\n } else if (store.giveFeedback === false && store.questionNumber === store.questions.length -1){\n html = generateLastPage();\n }\n else {\n html= generateRightWrong();\n }\n \n $('main').html(html);\n}", "title": "" }, { "docid": "44b687383f4b0efec89a177332e8db15", "score": "0.5082154", "text": "render() {\n this.formatPrice(5); // console.log() 'skaicius 5'\n const { plan: p } = this.props;\n return (\n <div className=\"mobile-plan\">\n <h6 className=\"plan__header\">{p.headerTitle}</h6>\n <h2 className=\"plan__dataAllow\">{p.dataAlowed} GB</h2>\n <small className=\"plan__dataEU\">Iš jų {p.dataEU} GB ES/EEE</small>\n <p className=\"plan__min-sms\">{p.minSms}</p>\n <div className=\"plan__features\">\n <div className=\"hr\"></div>\n <ul className=\"features__list\">\n {p.features?.length > 0 &&\n p.features.map((f) => (\n <li key={f.title}>\n <img className=\"features__check\" src={ListImage} alt=\"check\" />\n <span>{f.title}</span>\n </li>\n ))}\n </ul>\n <div className=\"hr\"></div>\n </div>\n <div className=\"plan__bottom\">\n <div className=\"bottom__price-part\">\n <h3 className=\"bottom__price\">\n {/* {p.price && p.price.commitment} <span>&euro;/men</span> */}\n {/* p.price? - pasitikrina ar turi reiksme iki ? .commitment */}\n {this.props.beIsipareigojimu\n ? this.formatPrice(p.price?.commitment)\n : this.formatPrice(p.price?.noCommitment)}\n <span>&euro;/{p.period}</span>\n </h3>\n <small className=\"bottom__term\">{p.contractLength?.commitment}</small>\n </div>\n <button className=\"plan__cta\">{p.ctaButton}</button>\n </div>\n </div>\n );\n }", "title": "" }, { "docid": "ab4a82771095e7d3b480666d95af1157", "score": "0.50700974", "text": "function takePayment(){\n\tif(localStorage.getItem(\"nOfSongs\")==1){\n\t\tdocument.getElementById('totalMoney').innerHTML='Payable Amount - ₹65';\n\t\tplanselect = 'single';\n\t\tprice = '₹65';\n\t}\n\telse if(localStorage.getItem(\"nOfSongs\")==2){\n\t\tdocument.getElementById('totalMoney').innerHTML='Payable Amount - ₹100';\n\t\tplanselect = 'basic';\n\t\tprice = '₹100';\n\t}\n\telse if(localStorage.getItem(\"nOfSongs\")==5){\n\t\tdocument.getElementById('totalMoney').innerHTML='Payable Amount - ₹240';\n\t\tplanselect = 'pro';\n\t\tprice = '₹240';\n\t}\n\telse{\n\t\tdocument.getElementById('totalMoney').innerHTML='Payable Amount - ₹400';\n\t\tplanselect = 'extreme';\n\t\tprice = '₹400';\n\t}\n\tdocument.getElementById(\"heading\").style.display=\"none\";\n\tdocument.getElementById(\"searchDiv\").style.display=\"none\";\n\tdocument.getElementById(\"closeSearch\").style.display=\"none\";\n\tdocument.getElementById(\"blurDiv\").style.display=\"none\";\n\tdocument.getElementById(\"songsDiv\").style.display=\"none\";\n\tdocument.getElementById('pBody').style.display='block';\n\tconsole.warn(\"PAYMENT PAGE\");\n\tdocument.getElementById('saveUndoDiv').style.display='none';\n\tdocument.getElementById('takePayment').style.display='block';\n\tdocument.getElementById('blurDiv').style.display='none';\n\tlocalStorage.setItem('nOfSongs',0);\n}", "title": "" }, { "docid": "ed26f4fc70a7dde71e6369e0f24f1902", "score": "0.5068665", "text": "render() {\n // const cartitems = this.props.navigation.getParam('cartitems');\n const { cart, cartTotal } = this.props;\n console.log(this.props);\n return (\n <>\n <Header style={{ backgroundColor: '#C1E319' }}>\n <Left>\n <TouchableOpacity onPress={() => this.props.navigation.goBack()}>\n <MaterialIcons name=\"arrow-back\" size={25} color=\"#fff\" />\n </TouchableOpacity>\n </Left>\n <Body>\n <Title>Check Out</Title>\n </Body>\n <Right></Right>\n </Header>\n\n <Content style={{ backgroundColor: \"#fff\" }}>\n <LoadingComponent />\n <View style={{ margin: 15 }}>\n <Text style={{ fontSize: 25, fontWeight: \"bold\" }}>Select a payment method</Text>\n </View>\n <View style={{ marginHorizontal: 15, borderRadius: 5, borderWidth: 1, borderColor: \"#e7e7e7\" }}>\n <TouchableOpacity onPress={() => this.setState({ paymenttype: \"cash\" })} style={{ flexDirection: \"row\", padding: 13, borderBottomWidth: 1, borderColor: \"#e7e7e7\" }}> \n <Radio onPress={() => this.setState({ paymenttype: \"cash\" })} selected={this.state.paymenttype == 'cash' ? true : false} />\n <Text style={{ fontSize: 18, fontWeight: \"bold\" }}> Cash</Text>\n </TouchableOpacity>\n <TouchableOpacity onPress={() => this.setState({ paymenttype: \"paypal\" })} style={{ flexDirection: \"row\", padding: 13 }}>\n <Radio onPress={() => this.setState({ paymenttype: \"paypal\" })} selected={this.state.paymenttype == 'paypal' ? true : false} />\n <Text style={{ fontSize: 18, fontWeight: \"bold\" }}> Paypal</Text>\n </TouchableOpacity>\n </View>\n\n <View style={{ margin: 15 }}>\n <Text style={{ fontSize: 25, fontWeight: \"bold\" }}>Select Order Type</Text>\n </View>\n <View style={{ marginHorizontal: 15, borderRadius: 5, borderWidth: 1, borderColor: \"#e7e7e7\" }}>\n <TouchableOpacity onPress={() => this.setState({ ordertype: \"collection\" })} style={{ flexDirection: \"row\", padding: 13, borderBottomWidth: 1, borderColor: \"#e7e7e7\" }}>\n <Radio onPress={() => this.setState({ ordertype: \"collection\" })} selected={this.state.ordertype == 'collection' ? true : false} />\n <Text style={{ fontSize: 18, fontWeight: \"bold\" }}> Collection</Text>\n </TouchableOpacity>\n <TouchableOpacity onPress={() => this.setState({ ordertype: \"delivery\" })} style={{ flexDirection: \"row\", padding: 13 }}>\n <Radio onPress={() => this.setState({ ordertype: \"delivery\" })} selected={this.state.ordertype == 'delivery' ? true : false} />\n <Text style={{ fontSize: 18, fontWeight: \"bold\" }}> Delivery</Text>\n </TouchableOpacity>\n </View>\n {\n this.state.ordertype == 'delivery' ?\n <>\n <View style={{ margin: 15 }}>\n <Text style={{ fontSize: 25, fontWeight: \"bold\" }}>Delivery Information</Text>\n </View>\n <View style={{ marginHorizontal: 15, borderRadius: 5, borderWidth: 1, borderColor: \"#e7e7e7\" }}>\n <View style={{ padding: 13, }}>\n\n <Input\n value={this.state.address}\n onChangeText={(value) => this.setState({ address: value })}\n placeholder={'Address'}\n style={{ borderWidth: 1, paddingHorizontal: 5, borderRadius: 5, fontSize: 13, height: 35, fontWeight: \"bold\", paddingLeft: 5, borderColor: \"lightgrey\" }} />\n\n\n <Input\n value={this.state.postalcode}\n onChangeText={(value) => this.setState({ postalcode: value })}\n placeholder={'Postal Code'}\n style={{ marginTop: 15, borderWidth: 1, paddingHorizontal: 5, borderRadius: 5, fontSize: 13, height: 35, fontWeight: \"bold\", paddingLeft: 5, borderColor: \"lightgrey\" }} />\n\n <Input\n value={this.state.message}\n onChangeText={(value) => this.setState({ message: value })}\n multiline={true}\n numberOfLines={4}\n placeholder={'Special Message'}\n underlineColorAndroid=\"transparent\"\n style={{ marginTop: 15, borderWidth: 1, paddingHorizontal: 5, borderRadius: 5, fontSize: 13, height: 100, fontWeight: \"bold\", paddingLeft: 5, borderColor: \"lightgrey\", textAlignVertical: 'top', }} />\n </View>\n </View>\n </>\n : null\n\n }\n\n <>\n <View style={{ margin: 15 }}>\n <Text style={{ fontSize: 25, fontWeight: \"bold\" }}>Delivery Date &amp; Time</Text>\n </View>\n <View style={{ marginHorizontal: 15, borderRadius: 5, borderWidth: 1, borderColor: \"#e7e7e7\" }}>\n <View style={{ padding: 13, }}>\n {\n this.state.showtimepicker ?\n <DateTimePicker\n timeZoneOffsetInMinutes={0}\n value={\n this.state.deliverydate.getDate() !== this.state.deliverytime.getDate() ? this.state.deliverydate : this.state.deliverytime\n }\n mode={'time'}\n is24Hour={false}\n display=\"default\"\n onChange={this.onTimeChange}\n /> : null\n }\n\n {\n this.state.showdatepicker ?\n <DateTimePicker\n minimumDate={new Date()}\n locale={\"en\"}\n animationType={\"fade\"}\n value={this.state.deliverydate}\n mode={'date'}\n display=\"default\"\n onChange={this.onDateChange}\n /> : null\n }\n <TouchableOpacity onPress={() => this.showDatepicker()}>\n <Input\n disabled\n value={this.state.deliverydate.toString().substring(4, 15)}\n placeholder={'Delivery Date'}\n style={{ marginTop: 15, borderWidth: 1, paddingHorizontal: 5, borderRadius: 5, fontSize: 13, height: 35, fontWeight: \"bold\", paddingLeft: 5, borderColor: \"lightgrey\" }} />\n </TouchableOpacity>\n\n <TouchableOpacity onPress={() => this.showTimepicker()}>\n <Input\n disabled\n value={this.state.deliverytime.toString().substring(15, 21)}\n placeholder={'Delivery Time'}\n style={{ marginTop: 15, borderWidth: 1, paddingHorizontal: 5, borderRadius: 5, fontSize: 13, height: 35, fontWeight: \"bold\", paddingLeft: 5, borderColor: \"lightgrey\" }} />\n </TouchableOpacity>\n\n </View>\n </View>\n </>\n \n </Content>\n <Footer style={{ height: 100 }}>\n <FooterTab style={{ borderRadius: 0 }}>\n\n <View style={{ borderTopWidth: 1, borderBottomWidth: 1, borderColor: '#DDD', flex: 1, padding: 10, backgroundColor: '#FFF' }}>\n <View style={{ flex: 1, flexDirection: \"column\", paddingTop: 0, paddingBottom: 0 }}>\n\n <View style={{ paddingVertical: 4, flexDirection: 'row', justifyContent: 'space-between' }}>\n <View>\n <Text style={styles.totalCaptionTextStyle}>Sub Total</Text>\n </View>\n <View>\n <Text style={styles.totalTextStyle}>£{cartTotal.toFixed(2)}</Text>\n </View>\n </View>\n <View style={{ paddingVertical: 4, flexDirection: 'row', justifyContent: 'space-between' }}>\n <View>\n <Text style={styles.totalCaptionTextStyle}>Tax</Text>\n </View>\n <View>\n <Text style={styles.totalTextStyle}>£ 0.00</Text>\n </View>\n </View>\n <View style={{ paddingVertical: 4, flexDirection: 'row', justifyContent: 'space-between' }}>\n <View>\n <Text style={styles.totalCaptionTextStyle}>Grand Total</Text>\n </View>\n <View>\n <Text style={styles.totalTextStyle}>£ {cartTotal.toFixed(2)}</Text>\n </View>\n </View>\n </View>\n </View>\n\n </FooterTab>\n </Footer>\n\n <Footer >\n <FooterTab>\n <Button style={{ backgroundColor: '#C1E319' }} onPress={() => this.saveBoard()}><Text style={{ fontWeight: \"bold\", color: \"#fff\" }}>Complete Order</Text></Button>\n </FooterTab>\n </Footer>\n </>\n )\n }", "title": "" }, { "docid": "351a8cd9b74ad0b761c45d6095232954", "score": "0.5063181", "text": "function show_checkout_content() {\n\tif (checksameurl(location.href, checkoutpage) == true) {\n\t\t// Checkout table\n\t\tdocument.write('<div class=\"simpleCart_items\"></div><div id=\"cartTotal\">');\n\t\tdocument.write('<div id=\"empty_cart\"><a href=\"javascript:;\" class=\"simpleCart_empty\">' + translate_sentence('Empty cart') + '</a></div>');\n\t\tdocument.write('<div class=\"total_quantity\">' + translate_sentence('You have') + ' <strong><span class=\"simpleCart_quantity\"></span></strong> ' + translate_sentence('item(s) in cart') + '</div>');\n\t\tif (shipping_method == 2) { document.write('<div class=\"total_amount\">' + translate_sentence('Total weight') + ': <strong><span class=\"simpleCart_weight\"></span>g</strong></div>'); }\n\t\tdocument.write('<div class=\"total_amount\">' + translate_sentence('Subtotal in Cart') + ': <strong><span class=\"simpleCart_total\"></span></strong></div>');\n\t\tdocument.write('<div class=\"total_amount\">' + translate_sentence('Shipping cost'));\n\t\tdocument.write(': <strong><span class=\"simpleCart_shipping\"></span></strong></div><div class=\"total_amount\">' + translate_sentence('Paypal commission'));\n\t\tdocument.write(': <strong><span class=\"simpleCart_tax\"></span></strong></div><div class=\"total_amount grandtotal\">');\n\t\tdocument.write(translate_sentence('Grand total') + ': <strong><span class=\"simpleCart_grandTotal\"></span></strong></div></div>');\n\t\t// Checkout table\n\t\t\n\t\t//Shipping methods\n\t\ti_shipping = localStorage.getItem('i_shipping');\n\t\tdocument.write('<center><div id=\"shipping_types\">');\n\t\tif (free_shipping_from > 0){\n\t\t\tdocument.write('<div class=\"separation\"><span>' + translate_sentence('If your purchase is over') + ' ' + format_currency(free_shipping_from) + ', ');\n\t\t\tdocument.write(translate_sentence('your shipping will be free!') + '</span> (' + translate_sentence(shipping_types[0][0]) + ')</div>');\n\t\t}\n\t\tdocument.write(translate_sentence('Shipping methods') + ': <select onChange=\"update_shipping(this.selectedIndex)\" id=\"sel_shipping\" name=\"sel_shipping\">');\n\t\tfor(var i=0; i < shipping_types.length; i++){\n\t\t\t//alert('i_shipping ' + i_shipping);\n\t\t\tif (i == i_shipping) {\n\t\t\t\tdocument.write('<option value=\"1\" selected>');\n\t\t\t} else {\n\t\t\t\tdocument.write('<option value=\"1\">');\n\t\t\t}\n\t\t\tdocument.write(translate_sentence(shipping_types[i][0]) + ' (' + shipping_types[i][1] + ' ' + translate_sentence('days approx.') +')</option>');\n\t\t}\n\t\tdocument.write('</select></div></center>');\n\t\t//Shipping methods\n\t\t\n\t\t// Tracking number\n\t\tif (track_price !== false) {\n\t\t\tdocument.write('<div id=\"track_wrap\"><center><div class=\"add_track\"><div class=\"item_image\">');\n\t\t\tdocument.write('<img class=\"item_thumb\" src=\"https://lh5.googleusercontent.com/-0fOox7Snmhs/U11aqpau6LI/AAAAAAAABAk/Db1QGyEEwqU/s100-no/track-number.png\" alt=\"' + translate_sentence('Tracking number') + '\" title=\"' + translate_sentence('Tracking number') + '\"></div>');\n\t\t\tdocument.write('<select class=\"item_color\" style=\"display: none;\"><option value=\"-\">-</option></select>');\n\t\t\tdocument.write('<select class=\"item_size\" style=\"display: none;\"><option value=\"-\">-</option></select>');\n\t\t\tdocument.write('<div class=\"product-summary\"><div class=\"item_name\">Tracking number</div><div class=\"item_description\">');\n\t\t\tdocument.write(translate_sentence('Get the tracking number of your order and stay calm!') + '</div><div class=\"track_price\">');\n\t\t\tdocument.write(format_currency(parseFloat(track_price)) + '</div></div><a class=\"item_add button\" href=\"javascript:;\">');\n\t\t\tdocument.write(translate_sentence('Add to cart') + '</a></div></center></div>');\n\t\t\tdocument.write('<div class=\"item_price\" style=\"display: none;\">' + parseInt(track_price) + '</div>');\n\t\t}\n\t\t// Tracking number\n\t\t\n\t\t//Set selected country\n\t\ti_country = localStorage.getItem('i_country');\n\t\tif (i_country === null || typeof i_country === 'undefined') {\n\t\t\ti_country = localStorage.setItem('i_country', 0);\n\t\t\ti_country = localStorage.getItem('i_country');\n\t\t}\n\t\t//Set selected country\n\t\t\t\n\t\t//Available countries in cart\n\t\tif (world_shipping == false) {\n\t\t\tdocument.write('<center><div id=\"countries\">' + translate_sentence('Select your country') + ': <select id=\"selcountries\" name=\"selcountries\">');\n\t\t\tcountry_list.unshift('...');\n\t\t\tfor(var i=0; i < country_list.length; i++){\n\t\t\t\tif (i == i_country) {\n\t\t\t\t\tdocument.write('<option value=\"' + i + '\" selected>');\n\t\t\t\t} else {\n\t\t\t\t\tdocument.write('<option value=\"' + i + '\">');\n\t\t\t\t}\n\t\t\t\tdocument.write(translate_sentence(country_list[i]) + '</option>');\n\t\t\t}\n\t\t\tdocument.write('</select></div></center>');\n\t\t}\n\t\t//Available countries in cart\n\t\t\n\t\t//Show cart text and place the order button\n\t\tdocument.write('<center>* ' + translate_sentence('You can pay with credit card or PayPal') + '.<br />');\n\t\tif (certified_shipping == true) {\n\t\t\tdocument.write('* ' + translate_sentence('Your packet will be sent with tracking number if you order it') + '.<br />');\n\t\t}\n\t\tdocument.write('* ' + translate_sentence('Do you have any question?') + ' ');\n\t\tshowpagelink(contactuspage, translate_sentence('Contact us!'));\n\t\tdocument.write('<br /></center>');\n\n\t\tif (world_shipping == true) {\n\t\t\tdocument.write('<a class=\"simpleCart_checkout button turquoise\" href=\"javascript:;\"><span class=\"checkout_btn\">' + translate_sentence('Place the order') + '</span></a>');\n\t\t} else {\n\t\t\tvar selcountries = 0;\n\t\t\twindow.onload = function() {\n\t\t\t\tdocument.getElementById(\"selcountries\").onchange=function(){\n\t\t\t\t\tselcountries = document.getElementById(\"selcountries\").value;\n\t\t\t\t\ti_country = localStorage.setItem('i_country', selcountries);\n\t\t\t\t\ti_country = localStorage.getItem('i_country');\n\t\t\t\t\tif (selcountries > 0){\n\t\t\t\t\t\tdocument.getElementById(\"place_button\").style.display = \"block\";\n\t\t\t\t\t\tdocument.getElementById(\"disable-button\").style.display = \"none\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdocument.getElementById(\"place_button\").style.display = \"none\";\n\t\t\t\t\t\tdocument.getElementById(\"disable-button\").style.display = \"block\";\n\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t document.getElementById(\"selcountries\").onchange();\n\t\t\t}\n\t\t\tdocument.write('<a style=\"display: none;\" id=\"place_button\" class=\"simpleCart_checkout button turquoise\" href=\"javascript:;\"><span class=\"checkout_btn\">' + translate_sentence('Place the order') + '</span></a>');\n\t\t\tdocument.write('<div id=\"disable-button\">' + translate_sentence('Select your country') + '</div>');\n\t\t}\n\t\t//Show cart text and place the order button\n\t}\n}", "title": "" }, { "docid": "689b14cdc3181a81960dbd0ef1d16726", "score": "0.5062288", "text": "function initCardPaymentType() {\n var group = $('.scenario_block_origin .card_payment_group').clone();\n initIcheck(group.find('.card_type input'));\n group.insertBefore($('.message_bot_area .fixedsidebar-content .text_button_next'));\n // $('.message_bot_area .fixedsidebar-content').append(group);\n}", "title": "" }, { "docid": "e74cd85bec9ff58d3c1f4a4a8f8b2341", "score": "0.5058181", "text": "function sendData() {\n if (EditorContent && EditorContent.MACheckoutSupported && GetPaymentType() == 0) {\n ProcessCCPayment();\n }\n }", "title": "" }, { "docid": "52ffc398b3efada51b3b1913c33a4318", "score": "0.50515234", "text": "function showRegistrationsHelpContent() {\r\n var needGST = (parseboolean(applicationType.taxi) || parseboolean(applicationType.turnOver75k) || parseboolean(applicationType.limo) || parseboolean(applicationType.isFTC) || parseboolean(applicationType.isLCT));\r\n if (needGST) {\r\n // $('#gstHelp').show();\r\n $('#gstHelpHeader').show();\r\n\r\n // following code to switch on some help content for gst help\r\n/* if (parseboolean(applicationType.taxi)) {\r\n $(\"#liTaxi\").show();\r\n }\r\n\r\n if (parseboolean(applicationType.turnOver75k)) {\r\n $(\"#liMoreThan75k\").show();\r\n }\r\n\r\n if (parseboolean(applicationType.limo)) {\r\n $(\"#liLimo\").show();\r\n } */\r\n }\r\n if (parseboolean(registrations.isTFN)) {\r\n // $(\"#tfnHelp\").show();\r\n $(\"#tfnHelpHeader\").show();\r\n // $(\"#helpBusinessStructureSelected\").html(applicationType.name);\r\n }\r\n if (parseboolean(registrations.isCompany)) {\r\n // $(\"#companyHelp\").show();\r\n $(\"#companyHelpHeader\").show();\r\n }\r\n if (parseboolean(registrations.isBusinessName)) {\r\n // $(\"#businessNameHelp\").show();\r\n $(\"#businessNameHelpHeader\").show();\r\n/* if (applicationType.name === soleTraderName) {\r\n $(\"#yourOwnNameInHelp\").show();\r\n $(\"#yourOwnNameInHelp1\").show();\r\n }\r\n else if (applicationType.name === companyName) {\r\n $(\"#theCompanyNameInHelp1\").show();\r\n $(\"#theCompanyNameInHelp\").show();\r\n } else if (applicationType.name === partnershipName) {\r\n $(\"#yourPartnersNameInHelp\").show();\r\n $(\"#yourPartnersNameInHelp1\").show();\r\n } */\r\n }\r\n\r\n if (parseboolean(registrations.isPAYG)) {\r\n // $(\"#paygHelp\").show();\r\n $(\"#paygHelpHeader\").show();\r\n if (parseboolean(registrations.isCompany)) {\r\n $(\"#divCompanyPAYG\").show();\r\n// if (parseboolean(applicationType.hasEmployee)) {\r\n// $(\"#paygCompanyHasEmployee\").show();\r\n// }\r\n// else {\r\n// $(\"#paygCompanyNoEmployee\").show();\r\n// }\r\n }\r\n else {\r\n $(\"#divNonCompanyPAYG\").show();\r\n }\r\n }\r\n\r\n if (parseboolean(registrations.isFBT)) {\r\n // $('#fbtHelp').show();\r\n $('#fbtHelpHeader').show();\r\n\r\n }\r\n if (needGST && parseboolean(registrations.isLCT)) {\r\n // $('#lctHelp').show();\r\n $('#lctHelpHeader').show();\r\n }\r\n if (needGST && parseboolean(registrations.isFTC)) {\r\n // $('#ftcHelp').show();\r\n $('#ftcHelpHeader').show();\r\n }\r\n if (needGST && parseboolean(registrations.isWET)) {\r\n // $('#wetHelp').show();\r\n $('#wetHelpHeader').show();\r\n }\r\n if (!needGST) {\r\n // $('#gstHelp1').show();\r\n $('#gstHelp1Header').show();\r\n if (parseboolean(registrations.isFTC)) {\r\n $(\"#ftcHelpHeader1\").show();\r\n // $(\"#ftcHelp1\").show();\r\n }\r\n if (parseboolean(registrations.isLCT)) {\r\n $(\"#lctHelpHeader1\").show();\r\n // $(\"#lctHelp1\").show();\r\n }\r\n if (parseboolean(registrations.isWET)) {\r\n $(\"#wetHelpHeader1\").show();\r\n // $(\"#wetHelp1\").show();\r\n }\r\n }\r\n}", "title": "" }, { "docid": "31cfa46912346fd1a3eb122ff5cd9539", "score": "0.5047183", "text": "function billTypeText(billType) {\n\t\t\tvar text=\"\";\n\t\t\tif (billType) {\n\t\t\t\tif (billType === \"hr\") {\n\t\t\t\t\ttext = \"by the House as a bill\";\n\t\t\t\t} else if ( billType === \"hres\") {\n\t\t\t\t\ttext = \"by the House as a resolution\";\n\t\t\t\t} else if ( billType === \"hconres\") {\n\t\t\t\t\ttext = \"by the House as a concurrent resolution\";\n\t\t\t\t} else if ( billType === \"hjres\") {\n\t\t\t\t\ttext = \"by the House as a joint resolution\";\n\t\t\t\t} else if (billType === \"s\") {\n\t\t\t\t\ttext = \"by the Senate as a bill\";\n\t\t\t\t} else if ( billType === \"sres\") {\n\t\t\t\t\ttext = \"by the Senate as a resolution\";\n\t\t\t\t} else if ( billType === \"sconres\") {\n\t\t\t\t\ttext = \"by the Senate as a concurrent resolution\";\n\t\t\t\t} else if ( billType === \"sjres\") {\n\t\t\t\t\ttext = \"by the Senate as a joint resolution\";\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn text;\n\t\t}", "title": "" }, { "docid": "fcdb1780509efd116ef6f07616b5f17a", "score": "0.5044908", "text": "async renderWidget(req, type, data, options) {\n try {\n const manager = self.getWidgetManager(type);\n if (!manager) {\n // No manager available - possibly a stale widget in the database\n // of a type no longer in the project\n self.warnMissingWidgetType(type);\n return '';\n }\n data.type = type;\n return manager.output(req, data, options);\n } catch (e) {\n console.error(e);\n throw e;\n }\n }", "title": "" }, { "docid": "90f8e319ecd2e24e4077d3a3abab8401", "score": "0.5044213", "text": "getContents() {\n const {\n sessionView,\n } = this.props;\n\n switch (sessionView) {\n case PICK_SESSION_VIEW:\n return this.renderSessions();\n case PICK_PEER_TO_REVIEW_VIEW:\n return this.renderReviewablePeers();\n case EDITABLE_QS_VIEW:\n return this.renderEditableQs();\n case READ_ONLY_QS_VIEW:\n return this.renderReadableQs();\n case PICK_PEER_TO_READ_VIEW:\n return this.renderReviewablePeers();\n case READ_PEERS_REVIEWS_VIEW:\n return this.renderReviewablePeers();\n default:\n return <div/>;\n }\n\n }", "title": "" }, { "docid": "f6c85c46e8558d909d6a58293c945f69", "score": "0.5040701", "text": "function typeToShow(typeCard){\n\n let showType = \"\";\n\n if (typeCard === 2){\n showType = \"vegetable\";\n } else if (typeCard === 3){\n showType = \"animal\";\n } else if(typeCard === 4){\n showType = \"user\";\n } else if(typeCard === 1){\n showType = \"\";\n }\n return showType;\n}", "title": "" }, { "docid": "5095fbf4fb5fd3ef943a5ac0e3f71758", "score": "0.5038511", "text": "render(){\n const { auth, invoices, invoiceList } = this.props;\n \n // Redirect the user to the sign in page if it is not authenticated\n if (!auth.uid) return <Redirect to=\"/signin\" />\n\n // Initialize the listener for the dropdown list\n window.$(document).ready(function () {\n window.$(\".dropdown-button\").dropdown();\n });\n\n // save a JSX snippet according to the claim proprety value in the state\n const content = (this.state.claim === 'yes') ? (\n <div>\n <br />\n \n <div className=\"invoice-list\">\n <ul id=\"invoiceId\" className=\"dropdown-content\">\n { \n invoices && invoices.map((item) => {\n const invoice = invoiceList[item];\n return ( \n \n <li key={item}> \n <a className=\"blue-text text-lighten-3\" onClick={() => {this.handleClickSecond(item)}}>Company Name: { invoice.authorCompanyName }, INVOICE REGARDING SERVICE NUMBER: { invoice.service.serviceId }</a> \n </li>\n \n )\n }) }\n </ul>\n <a className=\"btn dropdown-button #ef9a9a red lighten-3\" id=\"botton\" data-beloworigin=\"true\" data-hover=\"true\" data-activates=\"invoiceId\" dropdown=\"true\">{this.state.invoiceId}<i className=\"material-icons right\">arrow_drop_down</i></a>\n <div className=\"text-danger\">{this.state.errors.invoiceIderr}</div>\n </div>\n\n <div className=\"input-field\">\n <label htmlFor=\"title\">Title</label>\n <input type=\"text\" id=\"title\" onChange={this.handleChange}/>\n <div className=\"text-danger\">{this.state.errors.titleerr}</div>\n </div>\n <div className=\"input-field\">\n <label htmlFor=\"body\">Message</label>\n <textarea id=\"body\" className=\"materialize-textarea\" onChange={this.handleChange}></textarea>\n <div className=\"text-danger\">{this.state.errors.bodyerr}</div>\n </div>\n\n </div>\n ) : (\n <div>\n\n <div className=\"input-field\">\n <label htmlFor=\"title\">Title</label>\n <input type=\"text\" id=\"title\" onChange={this.handleChange}/>\n <div className=\"text-danger\">{this.state.errors.titleerr}</div>\n </div>\n <div className=\"input-field\">\n <label htmlFor=\"body\">Message</label>\n <textarea id=\"body\" className=\"materialize-textarea\" onChange={this.handleChange}></textarea>\n <div className=\"text-danger\">{this.state.errors.bodyerr}</div>\n </div>\n\n </div>\n )\n\n // JSX template to display the contact component in the browser\n return (\n <div className=\"container\">\n <form onSubmit={this.handleSubmit} className=\"white\">\n <h5 className=\"grey-text text-darken-3\">Contact Us</h5>\n <div className=\"claim-type\">\n <ul id=\"claim\" className=\"dropdown-content\">\n <li><a id=\"yes\" className=\"blue-text text-lighten-3\" onClick={this.handleClick}>Yes</a></li>\n <li><a id=\"no\" className=\"blue-text text-lighten-3\" onClick={this.handleClick}>No</a></li>\n </ul>\n <a className=\"btn dropdown-button #ef9a9a red lighten-3\" data-beloworigin=\"true\" data-hover=\"true\" data-activates=\"claim\" dropdown=\"true\" name=\"\">{this.state.claim}<i className=\"material-icons right\">arrow_drop_down</i></a>\n <div className=\"text-danger\">{this.state.errors.claimerr}</div>\n </div>\n { content }\n <div className=\"input-field\">\n <button className=\"btn light-blue lighten-3\">Send</button>\n </div>\n </form>\n </div>\n )\n }", "title": "" }, { "docid": "b9f77c03baf1843f679a5e83b0310fa1", "score": "0.5027731", "text": "function paymentMethod (element1, element2,element3, display1, display2){\nelement1.style.display = display1;\nelement2.style.display = display1;\nelement3.style.display = display2;\n\n}", "title": "" }, { "docid": "7c253a278d6cc9879e9e702a31d01218", "score": "0.5023741", "text": "function displayBox(groupedData) {\n\n for (let dataKey in groupedData) {\n document.getElementById(\n \"displayBox\"\n ).innerHTML += `<div class=\"lineWrap\"><div class=\"card-date-transaction\">\n <div class=\"dateLapping\">\n <p >${new Date(dataKey).toDateString()}</p>\n </div\n </div></div>`;\n ``;\n for (let i = 0; i < groupedData[dataKey].length; i++) {\n let type = groupedData[dataKey][i].type;\n let direction = groupedData[dataKey][i].direction;\n\n if (type === 1 && direction === 1) {\n document.getElementById(\n \"displayBox\"\n ).innerHTML += `<div class=\"alignment-right\"><div class=\"displayCard\">\n <p class=\"amount\">\n &#8377; ${groupedData[dataKey][i].amount}\n </p>\n <p class=\"transactionMessage\"> You paid</p>\n <div class=\"transaction-id\">\n <p>Transaction ID</p>\n <p>${groupedData[dataKey][i].id}</p>\n </div>\n </div>\n </div>\n <div class=\"date-time-right\">\n <p>${new Date(\n groupedData[dataKey][i].startDate\n ).toDateString()}, ${new Date(\n groupedData[dataKey][i].startDate\n ).toLocaleTimeString()}</p>\n </div>`;\n }\n else if (type === 1 && direction === 2) {\n document.getElementById(\n \"displayBox\"\n ).innerHTML += `<div class=\"alignment-left\"><div class=\"displayCard\">\n <p class=\"amount\">\n &#8377; ${groupedData[dataKey][i].amount}\n </p>\n <p class=\"transactionMessage\"> You received</p>\n <div class=\"transaction-id\">\n <p>Transaction ID</p>\n <p>${groupedData[dataKey][i].id}</p>\n </div>\n </div>\n </div>\n <div class=\"date-time-left\">\n <p>${new Date(\n groupedData[dataKey][i].startDate\n ).toDateString()}, ${new Date(\n groupedData[dataKey][i].startDate\n ).toLocaleTimeString()}</p>\n </div>`;\n }\n else if (type === 2 && direction === 2) {\n // Pay and Decline Button and Align BOX Left\n document.getElementById(\n \"displayBox\"\n ).innerHTML += `<div class=\"alignment-left\"><div class=\"displayCard\">\n <p class=\"amount\">\n &#8377; ${groupedData[dataKey][i].amount}\n </p>\n <p class=\"received\"> Request received</p>\n <button>Pay</button>\n <button>Decline</button>\n </div>\n </div>\n <div class=\"date-time-left\">\n <p>${new Date(\n groupedData[dataKey][i].startDate\n ).toDateString()}, ${new Date(\n groupedData[dataKey][i].startDate\n ).toLocaleTimeString()}</p>\n </div>`;\n }\n else if (type === 2 && direction === 1) {\n document.getElementById(\n \"displayBox\"\n ).innerHTML += `<div class=\"alignment-right\"><div class=\"displayCard\">\n <p class=\"amount\">\n &#8377; ${groupedData[dataKey][i].amount}\n </p>\n <p class=\"transactionMessage\"> You requested</p>\n <div class=\"transaction-id\">\n <button>Cancel</button>\n </div>\n </div>\n </div>\n <div class=\"date-time-right\">\n <p>${new Date(\n groupedData[dataKey][i].startDate\n ).toDateString()}, ${new Date(\n groupedData[dataKey][i].startDate\n ).toLocaleTimeString()}</p>\n </div>`;\n }\n }\n }\n}", "title": "" }, { "docid": "85af4fc8653d183a0533e0043d8fb54b", "score": "0.50215644", "text": "function display() {\n\t\"use strict\";\n\tif ($(\"cash\").checked === true) {\n\t\treturn \"\\nYour Total Will Be Paid Cash\";\n\t} else if ($(\"card\").checked === true) {\n\t\treturn \"\\nYour Total Will Be Charged On Your Card\";\n\t}\n\treturn this;\n}", "title": "" }, { "docid": "73797f118598522155f435d8bbcdb818", "score": "0.50206673", "text": "static get template() {\n\n // Tag the returned template literal with the html helper function\n // to convert it into an instance of HTMLTemplateElement\n\n return html`\n <style include=\"\">\n\n paper-card{\n width:75%;\n display:inline-block;\n margin-top: 3%;\n }\n\n paper-button.indigo {\n background-color: var(--paper-indigo-500);\n color: white;\n --paper-button-raised-keyboard-focus: {\n background-color: var(--paper-indigo-500) !important;\n color: white !important;\n };\n }\n paper-button.disabled {\n color: white;\n background-color: bisque;\n }\n\n .payment-form{\n\n position: absolute;\n top: 45%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 50%;\n }\n\n .card-actions{\n text-align: center;\n }\n a#shoppinCart {\n display: none;\n }\n\n\n paper-button.custom{\n width: 100%;\n font-size: 20px;\n font-weight: 700;\n margin: 20px 0px;\n }\n\n .card-content h3{\n text-align: center;\n font-size: 30px;\n text-transform: uppercase;\n }\n\n @media (max-width: 800px) {\n paper-card{\n width:100%;\n }\n\n .payment-form{\n\n width: 80%;\n }\n\n /*Removing the outline for the iput fields Starts Here*/\n gold-cc-input{\n outline: none;\n }\n\n gold-cc-expiration-input{\n outline: none;\n }\n /*Removing the outline for the iput fields Ends Here*/\n </style>\n\n\n\n <!-- navigation path from one page to another -->\n <app-location route=\"{{route}}\"></app-location>\n <!-- payment form starts here -->\n <div class=\"payment-form\">\n <!-- To display card I'm using paper card -->\n <paper-card class=\"rate\">\n <!-- Content inside the paper card -->\n <div class=\"card-content\">\n <h3>Payment</h3>\n <!-- credicard input field starts Here -->\n <gold-cc-input\n auto-validate\n label=\"Card number\"\n value =\"4111 1111 1111 1111\"\n error-message=\"Enter valid visa or mastercard\"\n card-types='[\"visa\", \"mastercard\"]'\n required >\n </gold-cc-input>\n <!-- credicard input field Ends Here-->\n <!-- expiredate input field Starts Here-->\n <gold-cc-expiration-input label=\"Date\"></gold-cc-expiration-input>\n <!-- expiredate input field Ends Here-->\n <!-- cvv code starts here -->\n <paper-input name=\"cardCvv\" placeholder=\"CVV\" auto-validate pattern=\"[0-9]{3}\" maxlength=\"3\" error-message=\"CVV\" required ></paper-input>\n <!-- cvv code ends here -->\n </div>\n <div class=\"card-actions\">\n <!-- Paper buuton for login using polymer component -->\n <paper-button raised on-click=\"_payment\" class=\"custom indigo\">Proceed</paper-button>\n </div>\n </paper-card>\n <!-- To display card I'm using paper card -->\n </div>\n <!-- payment form ends here -->\n `;\n }", "title": "" }, { "docid": "49848afb2af9c933ea6ab74c4a6334ff", "score": "0.5018986", "text": "function showDataInView(type, content1, content2){\n document.getElementById('view_details_div').setAttribute('class','view_details_div_class');\n var element = document.createElement(\"div\");\n if(type == 1){\n element.setAttribute('class','sheet_date');\n element.innerHTML = content1;\n }else if(type == 2){\n element.setAttribute('class','sheet_detail');\n element.innerHTML = content1 + ': ' + content2;\n }else if(type == 3){\n element.setAttribute('class','sheet_detail');\n element.innerHTML = content1;\n }\n document.getElementById('view_details_div').appendChild(element);\n}", "title": "" }, { "docid": "e42c690df3fa7c1638b098448302dd3e", "score": "0.50182235", "text": "function render() {\n let html = generateHeader();\n\n if (store.error) {\n generateError();\n }\n\n // check if form displayed\n if (store.adding) {\n html += generateBookmarkForm();\n }\n\n html += generateAllBookmarkCards();\n\n $('main').html(html);\n }", "title": "" }, { "docid": "cb5c6511cbc37b1da024baf73262a26c", "score": "0.501607", "text": "get paymentText(){return $('span=Pay now for peace of mind. Save later if you need to make a necessary change to your itinerary.')}", "title": "" }, { "docid": "9e865cd6f8c7c9c67a57f0e1c7f47696", "score": "0.50097185", "text": "renderClosedOutParty() {\n const party = this.props.party;\n var payments = this.props.party.payments.filter((payment) => {\n return (payment.payee._id == this.props.currentUser._id || payment.payer._id == this.props.currentUser._id)\n });\n if (payments.length == 0) {\n return;\n }\n\n return (\n <div className='panel panel-default'>\n <div className='panel-body'>\n <h3 className=\"party-title\">{party.title}</h3>\n\n <div className=\"col-md-4\">\n <p className=\"date\"><span className=\"glyphicon glyphicon-calendar\"></span> Date: {this.renderDate()}</p>\n <p className=\"host\"><span className=\"glyphicon glyphicon-user\"></span> Host: {party.host.email}</p>\n <p className=\"location\"><span className=\"glyphicon glyphicon-map-marker\"></span> Location: {party.location}</p>\n <p className=\"description\">{party.description}</p>\n </div>\n <div className='col-md-8'>\n <p>From this party, these payments involve you:</p>\n <ul>\n { payments.map((payment, key) => {\n var rounded_amount = Math.round(payment.amount*100)/100\n if (payment.payer._id == this.props.currentUser._id) {\n return (<li key={key}> You owe {payment.payee.email} {rounded_amount} dollars.</li>);\n } else {\n return (<li key={key}> {payment.payer.email} owes you {rounded_amount} dollars.</li>)\n }\n })}\n </ul>\n <p>Have the payments been completed by everyone?</p>\n <button className=\"btn btn-default\" onClick={this.clearPayments}>Yes</button>\n </div>\n </div>\n </div>\n );\n }", "title": "" }, { "docid": "a32068dbcb2d66a75d50ca1fd5fe51c8", "score": "0.500719", "text": "render(){\n switch (this.state.tab) {\n case TABS.FX_TABLE:\n return <FXTable table={this.props.tables.fxrates} onReturn={this.onReturn} />;\n case TABS.HIRING_MANAGERS:\n return <HiringManagers onReturn={this.onReturn} />;\n case TABS.PAY_GRADES:\n return <PayGrades onReturn={this.onReturn} />;\n case TABS.SKILLS:\n return <Skills onReturn={this.onReturn} />;\n case TABS.USERS:\n return <Users onReturn={this.onReturn} />;\n case TABS.HR_ROLES:\n return <HRRoles onReturn={this.onReturn} />;\n case TABS.MAIN:\n default:\n return <AdminPanelComponent onClick={this.onClick} />;\n }\n }", "title": "" }, { "docid": "f82481bab0e044e0d6d89f49675bee82", "score": "0.5002158", "text": "render(){\n\t\tswitch(this.state.pageToShow){\n\t\t\tcase 'info':\n\t\t\t\treturn this.renderOfficeInfo();\n\t\t\tcase 'edit':\n\t\t\t\treturn (\n\t\t\t\t\t<EditOffice office = {this.state.office}\n\t\t\t\t\t\treturnToInfo= {() => this.setPageToShow('info')} \n\t\t\t\t\t\tupdateOfficeInfo = {this.updateOfficeInfo}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\tdefault:\n\t\t\t\treturn (\n\t\t\t\t\t<div>\n\t\t\t\t\t\tError: unxpected pageToShow in OfficeInfo<br/>\n\t\t\t\t\t\tpageToShow= {this.state.pageToShow}\n\t\t\t\t\t</div>\n\t\t\t\t);\n\t\t}\n\t}", "title": "" } ]
4d12fbba1a652fd565b3c165d94791e1
See if world/location has a proof
[ { "docid": "18928cfc8ee2d836ffb16d89a9cce4ee", "score": "0.70874846", "text": "function getProofs(world) {\n var proof = false;\n for(var i = 0; i < world.length; i++) {\n if(world.includes(proofs[0]) || world.includes(proofs[1]) || world.includes(proofs[2])) {\n proof = true;\n }\n }\n return proof;\n}", "title": "" } ]
[ { "docid": "3d4285f05deeaa34f7f7ad99cbdb7913", "score": "0.6345847", "text": "fulfilled(world){\n let yes=true;\n\n //check if relevant object is present\n if(world.objects[this.parent_object]==undefined)\n yes=false; //it doesn't exist in world\n\n else if(world.rooms.includes(this.parent_object))\n {\n if(world.location!=this.parent_object)\n yes=false; //player not in the relevant room\n }\n else if(!world.objects[world.location].contents.includes(this.parent_object))\n {\n yes=false; //object not in the room\n }\n\n //check ownership\n if(this.owner!=\"\"){ //ownership condition present\n if(this.has)\n {\n if(world.objects == undefined || !world.objects[this.owner].contents.includes(this.object))\n yes=false;\n }\n else\n {\n if(world.objects[this.owner].contents != undefined && world.objects[this.owner].contents.includes(this.object))\n {\n yes=false;\n }\n }\n }\n\n //check status\n if(this.object_status!=\"\" && world.objects[this.object].status != this.object_status)\n {\n yes=false;\n }\n\n return yes;\n }", "title": "" }, { "docid": "83c84faab6e56b351ddfb004f5fafedf", "score": "0.5714281", "text": "function check(location) {\n if (!location.ochaId || !location.coordinates || (location.level() < 4)) {\n return true\n }\n var found = _.find(source, function(x) {\n\treturn (x.ADM3_CODE === location.ochaId || x.ADM4_CODE === location.ochaId) })\n\tif (found) {\n\t var right = ((found.LONGITUDE == location.coordinates.lon) && (found.LATITUDE == location.coordinates.lat)) ||\n\t ((found.LONGITUDE == location.parent.coordinates.lon) && (found.LATITUDE == location.parent.coordinates.lat))\n\t if (!right) {\n\t console.log('lon:' + found.LATITUDE + ' ' + location.coordinates.lat + ' lat: ' + found.LONGITUDE + ' ' + location.coordinates.lon);\n\t }\n\t return right\n\t}\n else { return true }\n }", "title": "" }, { "docid": "d4decbb313a3ae8ebdb633810021178b", "score": "0.558391", "text": "function isGoodLocation(location) {\n return location.id && location.latitude && location.longitude && location.text;\n }", "title": "" }, { "docid": "68b21b96764d541f7c554a6bc6c617c4", "score": "0.5574963", "text": "function isNearby() {\n\treturn true;\n}", "title": "" }, { "docid": "1a9778f3452a37dadb4f4d7b35e378f9", "score": "0.5497563", "text": "function physicsCheckAboveLand(){\n return viewOrigin[0] >= -1.0 && viewOrigin[0] < 1.0 && viewOrigin[1] >= -1.0 && viewOrigin[1] < 1.0;\n}", "title": "" }, { "docid": "7c41666f151b087d18d78eb6f38025a8", "score": "0.5467126", "text": "verifyProof() {\n // This is similar to the previous lab,\n // except that the proof is part of the block already.\n let h = this.hash();\n let n = this.constructor.numZeroes(h);\n return n >= NUM_LEADING_ZEROES;\n }", "title": "" }, { "docid": "7255d17786289d4e4e23f1fff70577ca", "score": "0.546223", "text": "function __isPlant(entity) {\n var t = entity.t;\n return (t == \"P\" || t == \"p\");\n}", "title": "" }, { "docid": "34dedbd1d31b922ce181eac72c686258", "score": "0.54472506", "text": "function verify(numFeatures, numWells, numPolys){\n //initialize the variables for the functions to be used\n \n if (dwte.value < bedrock.value){\n error_message('Your desired elevation is lower than the bedrock elevation');\n return false;\n }\n\n if (iwte.value < bedrock.value){\n error_message('Your initial elevation is lower than the bedrock elevation');\n return false;\n }\n\n if (dwte.value > dwte.value){\n error_message('Your desired elevation is higher than the initial elevation');\n return false;\n }\n\n if (k.value <= 0){\n error_message('Hydraulic conductivity must have a positive value, adjust your input');\n return false;\n }\n\n if (numFeatures == 0) {\n error_message(\"You dont have any features, please provide a boundary and well locations\");\n return false;\n }\n\n if (numWells == 0) {\n error_message('You need wells to perform the analysis, please add at least one well');\n return false;\n }\n else if (numPolys == 0) {\n error_message('You need a boundary for your analysis, please add a boundary');\n return false;\n }\n else if (numPolys > 1) {\n error_message('You have more than one Perimeter, delete the extra(s)');\n return false;\n }\n \n //If you are to hear without a return, everyting must be OK\n return true;\n }", "title": "" }, { "docid": "8b7a30d1fdd36cd8fb3505215d714bbb", "score": "0.53573096", "text": "get hasAdditiveReferencePose() {}", "title": "" }, { "docid": "3fb74529eb77784dfac5bded25076569", "score": "0.533615", "text": "function is_valid(world, rx, ry){\n\t// out of bounds \n\tif ((rx >= 20) || (rx <= 1) || (ry >= 20) || (ry <= 1)) {\n\t\treturn false;\n\t}\n\t// check if the requested position is occupied \t\n\tfor (var i = 0; i < world.actors.length; i++){\n\t\tif (world.actors[i][2] == rx && world.actors[i][3] == ry){\n\t//\t\tif (stage.clientActors[i][0] == \"player\" ){\n\t//\t\t\treturn true;\n\t//\t\t}\n\t//\t\telse { //then obstruction is a box or wall \n\t\t\t\treturn false;\n\t//\t\t\t}\n\t\n\t\t\t}\n\t\t}\n\treturn true;\n }", "title": "" }, { "docid": "07895da96dcbd7477a4dc031b18a9191", "score": "0.53314793", "text": "function isGoal(x, y, goal) {\r\n return (\r\n x === goal.x &&\r\n y === goal.y\r\n )\r\n}", "title": "" }, { "docid": "af1639126bd20f23725b0e633fab6a6e", "score": "0.5307011", "text": "function HasPossition(){\n\tvar status = true\n\t//Return if we have a possition or not\n\n\treturn status;\n}", "title": "" }, { "docid": "6e5758f6a627df2c29930f26a2477e68", "score": "0.53055924", "text": "function checkauthorizedGeoLocation(){\n if(typeof localStorage['authorizedGeoLocation'] == \"undefined\" || localStorage['authorizedGeoLocation'] == \"0\" ) {\n return false;\n } else {\n return true;\n }\n}", "title": "" }, { "docid": "02cf4e54869a82ce3c6cad7473f15fd7", "score": "0.5291673", "text": "function checkMod(location){\r\n if(raceTrack[location].modToken.value == 0){\r\n return false;\r\n }\r\n else{\r\n return true;\r\n }\r\n}", "title": "" }, { "docid": "6107bb84e4a78315af253131e704e3b3", "score": "0.52740467", "text": "function check(tet){\n var ret = false;\n var i1 = getIndex(tet.tData.pos1x,tet.tData.pos1y);\n var i2 = getIndex(tet.tData.pos2x,tet.tData.pos2y);\n var i3 = getIndex(tet.tData.pos3x,tet.tData.pos3y);\n var i4 = getIndex(tet.tData.pos4x,tet.tData.pos4y);\n // document.write(i1+'-'+i2+'-'+i3+'-'+i4);\n ret = ret || squares[i1].set;\n ret = ret || squares[i2].set;\n ret = ret || squares[i3].set; \n ret = ret || squares[i4].set;\n return !ret;\n //if(squares[i1]==null){\n // t(\"null!!\");\n\n \n}", "title": "" }, { "docid": "48de18cfaa37922dc126e9788e792d0d", "score": "0.52573776", "text": "function evaluateTruthy(){var res=this.evaluate();if(res.confident)return !!res.value;}", "title": "" }, { "docid": "36448da9a41b00027ea5438c5d77de8e", "score": "0.52488494", "text": "function existSomethingThere(coorX,coorY){\r\n // Search if the object generated is placed where is a rover\r\n for(var coordinateEqualInRover in rover){\r\n if(rover[coordinateEqualInRover].x === coorX && rover[coordinateEqualInRover].y === coorY){\r\n return true;\r\n }\r\n }\r\n // Search if the object generated is placed where is another obstacle\r\n for(var coordinateEqualInObstacle in obstacles){\r\n if(obstacles[coordinateEqualInObstacle].x === coorX && obstacles[coordinateEqualInObstacle].y === coorY){\r\n return true;\r\n }\r\n }\r\n return false; //false = not exist\r\n}", "title": "" }, { "docid": "36ae1168bfba43deeb909461cc4b62e9", "score": "0.52484596", "text": "function check(who) {\n if (who.appearence == 'feathers' && (typeof who.quack == 'function')) {\n who.quack(\"i can quak like Duck\");\n return true;\n }\n return false;\n}", "title": "" }, { "docid": "ce11075ca0a8defb0bd20864146b6650", "score": "0.5232009", "text": "function correctInput() {\n if(typeof solution === 'undefined') {\n alert('Please define a solution before loading this file!');\n return false;\n }\n\n if( ! solution.hasOwnProperty('ScenarioDescription')) {\n alert('The defined solution must define a ScenarioDescription property!');\n return false;\n }\n\n if( ! solution.hasOwnProperty('Entities')) {\n alert('The defined solution must define a Entities property!');\n return false;\n }\n if( solution.Entities.length > 17) {\n alert('The entities are barely visible for more than 18 entities!');\n return false;\n }\n\n if( ! solution.hasOwnProperty('Moves')) {\n alert('The defined solution must define a Moves property!');\n return false;\n }\n\n return true;\n}", "title": "" }, { "docid": "63a33eeaaabb4f947a7a3a6cb1023e63", "score": "0.5230119", "text": "isLocated() {\n return (this._x !== null) && (this._y !== null)\n && (this._level !== null);\n }", "title": "" }, { "docid": "ecbd5776cfcde52377764481d85fc354", "score": "0.52185833", "text": "function isAlive (x, y, world) {\n const { arr, height, width } = world\n return x >= 0 && y >= 0 && x < width && y < height && arr[y * width + x]\n}", "title": "" }, { "docid": "55c53d4444c95dd6c0aa7b44e565d955", "score": "0.52038956", "text": "_optimalAnyOtherWith(f) {\n var checker, self;\n self = this._world.selfManager.self();\n checker = function(x) {\n return x !== self && x.projectionBy(f);\n };\n return this.exists(checker);\n }", "title": "" }, { "docid": "46403cb627b36f138701c6fd5cd3f5fc", "score": "0.5196667", "text": "function checkWall(point, map) {\n\tif (map[point[0]][point[1]] != false) return true;\n}", "title": "" }, { "docid": "cf28efd402403ed49a63ccfe2c973f9f", "score": "0.5169347", "text": "function validateLocation(location) {\n\n return new Promise(function (resolve, reject) {\n fetchLocation(location).then(function (res, err) {\n console.log(res);\n resolve(true)\n })\n .catch(function (err) {\n reject(false)\n })\n })\n}", "title": "" }, { "docid": "63b1194693b8110e6daf657e385a76da", "score": "0.5167741", "text": "function checkUlr() {\n map.addLocate();\n if(!url.getParameter('coords')){\n //If the url does not have coordiantes - locate the user\n map.locate.start();\n } else {\n //If the ulr does have coordiantes - locate the artwork\n map.focusArtwork(url.getParameter('coords'));\n }\n }", "title": "" }, { "docid": "358af367dbc8301abbf6222335393034", "score": "0.51667184", "text": "function check(location) {\n if (!location.ochaId || (location.level() < 4)) {\n return true\n }\n var found = _.find(source, function(x) { return (x.ADM4_CODE === location.ochaId) })\n if (found) {\n var right = (found.ADM3_CODE == location.parent.ochaId) && (found.ADM2_CODE == location.parent.parent.ochaId || found.ADM2_CODE ===\"\")\n if (!right) {\n\tconsole.log(location.level() + ' ' + location.name + ' ' + location.ochaId);\n }\n return right\n } else { return true }\n }", "title": "" }, { "docid": "ffb37a66dff99c9fa84812e3021c24c5", "score": "0.51652855", "text": "function is_occupied(world,x,y){\n\tfor (var i = 0; i < world.actors.length; i++){\n\t\tif(world.actors[i][2] == x && world.actors[i][3] == y){\n\t\t\treturn true;\n\t\t}\n\t\n\t}\n\treturn false;\n}", "title": "" }, { "docid": "0111a6158ab1b4f86a068a6806f50020", "score": "0.5164741", "text": "function checkHasPositionalTracking () {\n var position = new THREE.Vector3();\n return (function () {\n if (isMobile() || isGearVR()) { return false; }\n controls.update();\n dolly.updateMatrix();\n position.setFromMatrixPosition(dolly.matrix);\n if (position.x !== 0 || position.y !== 0 || position.z !== 0) {\n return true;\n }\n return false;\n })();\n}", "title": "" }, { "docid": "0111a6158ab1b4f86a068a6806f50020", "score": "0.5164741", "text": "function checkHasPositionalTracking () {\n var position = new THREE.Vector3();\n return (function () {\n if (isMobile() || isGearVR()) { return false; }\n controls.update();\n dolly.updateMatrix();\n position.setFromMatrixPosition(dolly.matrix);\n if (position.x !== 0 || position.y !== 0 || position.z !== 0) {\n return true;\n }\n return false;\n })();\n}", "title": "" }, { "docid": "0111a6158ab1b4f86a068a6806f50020", "score": "0.5164741", "text": "function checkHasPositionalTracking () {\n var position = new THREE.Vector3();\n return (function () {\n if (isMobile() || isGearVR()) { return false; }\n controls.update();\n dolly.updateMatrix();\n position.setFromMatrixPosition(dolly.matrix);\n if (position.x !== 0 || position.y !== 0 || position.z !== 0) {\n return true;\n }\n return false;\n })();\n}", "title": "" }, { "docid": "db8d4411a97313d202c4cf758c9b9654", "score": "0.5145915", "text": "get isPopulation () {\r\n\t\tif (this.alignment != \"player\") {\r\n\t\t\treturn false;\r\n\t\t} else if (this.subType == \"special\" || this.species == \"mechanical\") {\r\n\t\t\treturn false;\r\n\t\t} else {\r\n\t\t\t//return (this.place == \"home\")\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}", "title": "" }, { "docid": "12aa3f60022f477e24e317f0f4d2c8fc", "score": "0.5143458", "text": "function handle_FP(formula,subj,pred,obj){var o1=formula.any(subj,pred,undefined);if(!o1){return false;// First time with this value\n}// log.warn(\"Equating \"+o1.uri+\" and \"+obj.uri + \" because FP \"+pred.uri); //@@\nformula.equate(o1,obj);return true;}// handle_FP", "title": "" }, { "docid": "ab622eede251411dcf91d4a37441550f", "score": "0.5113143", "text": "function checkIfGoodMonsterWithPacman() {\r\n\tif (((monster5Good.i == shape.i) && (monster5Good.j == shape.j) && isMonster5Alive)) {\r\n\t\tscore = score + 50;\r\n\t\tboardMonster[monster5Good.i][monster5Good.j] = 0;\r\n\t\tisMonster5Alive = false;\r\n\t}\r\n}", "title": "" }, { "docid": "e105a7d5c995fe7fd34d2114c925e3aa", "score": "0.51060855", "text": "function checkProposedLocationIsValid(locationJson) {\n console.log('checkProposedLocationIsValid');\n if (locationJson.status == \"ZERO_RESULTS\") {\n // Either show an error if it isn't on Google's API... \n console.log('Proposed location is invalid.')\n displayNoSuchLocationErrorMessage();\n } else {\n // ... Else, continiue this app's chain of functions.\n console.log('Proposed location is valid.')\n // In case the error message is already displayed\n removeNoSuchLocationErrorMessage();\n let locationObject = locationJson.results[0];\n // Center the map\n goToLocation(locationObject);\n handleNewHeatmapRequest(locationObject);\n // Switched off to make testing easier:\n // revealMap();\n }\n}", "title": "" }, { "docid": "d8f0a32612b00844eaaef2fbf4ae1cea", "score": "0.5081553", "text": "function isPartyPerson(name) {\n\tfor (var i = 0; i < PARTY_PEOPLE.length; i++) {\n\t\tif (PARTY_PEOPLE[i] == name) return true;\n\t}\n\treturn false;\n}", "title": "" }, { "docid": "b295aee4fadbc069694c0213ca62bfea", "score": "0.5055142", "text": "function checkBounds(people_coord){\n\tinParis = false;\n\tbound = [49,2.35];\n\tdist = math.distance(bound, paris_coord);\n\tdist_people = math.distance(people_coord, paris_coord);\n\n\t//Check for NaN values (note math.distance() return NaN if one parameter is NaN)\n\tif (dist_people != NaN){\n\t\tif (dist_people <= dist){\n\t\t\tinParis = true;\n\t\t}\n\t}\n\n\treturn inParis;\n}", "title": "" }, { "docid": "c2c7378b57d71871368da1b21857a216", "score": "0.5054219", "text": "async verifyLocation(stub, args) {\n // Estonia ship going to Denmark\n // e.g. '{\"Args\":[\"verifyLocation\", \"9762687\", \"Denmark\"]}'\n console.info('============= START : Verify Location ===========');\n if (args.length !== 2) {\n throw new Error('Incorrect number of arguments. Expecting 2 argument (imo, country)');\n }\n let imo = args[0];\n let country = args[1];\n\n // Get the country's borders\n let maAsBytes = await stub.getState(country);\n let borders = JSON.parse(maAsBytes).borders;\n if (!maAsBytes || maAsBytes.toString().length <= 0) {\n throw new Error(country + ' does not exist: ');\n }\n\n let api = `http://oracle/${imo}`;\n const result = await rp(api, { json: true }).catch((err) => {console.error(err);});\n let shipLat = Number(result.entries[0].lat);\n let shipLng = Number(result.entries[0].lng);\n console.log(`The ship is now at ${shipLat}, ${{shipLng}}`);\n if (geolocation.insidePolygon([shipLng, shipLat], borders)) {\n console.info('============= END : Verify Location (true) ===========');\n return Buffer.from('true');\n } else {\n console.info('============= END : Verify Location (false) ===========');\n return Buffer.from('false');\n }\n }", "title": "" }, { "docid": "e8840256b2edf338c41d53a245bf880a", "score": "0.50493044", "text": "function isGoalState(state, goal) {\ngoalx = Math.floor(goal[0] / (1 * GRID_SIZE));\ngoaly = Math.floor(goal[1] / (1 * GRID_SIZE));\nstatex = Math.floor(state[0] / (1 * GRID_SIZE));\nstatey = Math.floor(state[1] / (1 * GRID_SIZE));\n\nif ((goalx == statex) && (goaly == statey)) return true;\nelse return false;\n}", "title": "" }, { "docid": "253e2a4a7723cb5af17dbbbf13aee3d3", "score": "0.5026306", "text": "function checkCorrectAnswer(answer){\n return answer===word||(synonyms!=null&&synonyms.indexOf(answer))>0\n }", "title": "" }, { "docid": "83237eacf9c2e12113b156b881f1670c", "score": "0.50211793", "text": "function pawncheck (piece, location)\n {\n var incheck;\n var x1 = getNumber (piece.location[0]);\n var x2 = getNumber(location[0]);\n var xdiff = Math.abs (x1-x2);\n var y1 = parseInt (piece.location[1]);\n var y2 = parseInt (location[1]);\n var ydiff = Math.abs (y1-y2);\n\t\n if (xdiff == 1 && ydiff == 1)\n {\n incheck = true;\n }\n\t\n else\n {\n incheck = false;\n }\n return incheck;\n }", "title": "" }, { "docid": "2abc8d85d97c980e41e5bf8be040c521", "score": "0.5018399", "text": "function CheckProximity() {\n}", "title": "" }, { "docid": "30b7be3d73cb4fd12f826fecb95aec5b", "score": "0.500864", "text": "isLondon() {\n return (this.type === 2);\n }", "title": "" }, { "docid": "2b83e32eef230e7d8fe96eb990b659f9", "score": "0.5004173", "text": "situation() {\n const point = this.nextPos();\n let x,y;\n x = point.x;\n y = point.y;\n \n if(x < 0 || x >= map.rowL || y < 0 || y > map.colL) {\n return 'out'\n };\n \n for(let i =0; i < this.body.length; i++) {\n if(x === this.body[i].x && y === this.body[i].y) {\n return 'same'\n }\n };\n \n if(map.hasColor(x,y)) {\n return 'food';\n };\n \n return 'empty';\n \n \n \n \n \n }", "title": "" }, { "docid": "6641763de606b920c5b6be74db3933d0", "score": "0.50026137", "text": "function checkGoal(){\n if(player.x>=endpoint.x - 20 && player.x<=endpoint.x + 20)\n {\n if(player.y>=endpoint.y - 20 && player.y<=endpoint.y + 20)\n {\n won = true;\n }\n }\n}", "title": "" }, { "docid": "0ad2fd478a1569a8d63622698fcdd704", "score": "0.49975386", "text": "function checkCanyon(t_canyon)\n{\n if(gameChar_world_x < t_canyon.x_pos + t_canyon.width/2 - 10 && gameChar_world_x > t_canyon.x_pos - t_canyon.width/2 + 10 && gameChar_y == floorPos_y){\n isPlummeting = true;\n }\n}", "title": "" }, { "docid": "bfdc2c9c5c3c757777b99a6e2bac0e53", "score": "0.49969804", "text": "shouldQuarantine() {\n if (this.passengers.some(passengers => passengers.isHealthy === false)) {\n return true\n } else { \n return false\n }\n \n }", "title": "" }, { "docid": "57a44b30c30ed3e028168152850b3acd", "score": "0.49904776", "text": "function checkEyePlants(org, eye) {\n var eyeInput;\n if(eye == \"r\") {\n eyeInput = \"peLR\";\n }else if(eye == \"l\") {\n eyeInput = \"peLL\"\n } else {\n throw \"Invalid eye asked for; use l (left) or r (right) for the checkEye function.\";\n return;\n }\n\n for (var j = 0; j < org.morph.eyeRes; j++) {\n org.nn.inputs[eyeInput + j].value = -1;\n }\n\n for (var k = 0; k < plants.length; k++) {\n if (plants[k] == null) {\n continue; //no null plant\n }\n var target = plants[k];\n //eye distance is distance between eye and the radius center of another organism.\n var eyeDis = Math.sqrt(findDis(org.morph.eye.pos[eye].x, org.morph.eye.pos[eye].y, target.x, target.y));\n if (eyeDis > target.cal + org.morph.eye.range) {\n continue; //target out of range.\n } else if (eyeDis < target.r) {\n for (var j = 0; j < org.morph.eyeRes; j++) {\n org.nn.inputs[eyeInput + j].value = 1;\n }\n break; //eye is on top of a target.\n }\n\n for (var j = 0; j < org.morph.eyeRes; j++) {\n if (org.nn.inputs[eyeInput + j].value == 1) {\n continue;\n }\n org.nn.inputs[eyeInput + j].value = lineToPulse(org.morph.eye.pos[eye].x, org.morph.eye.pos[eye].y,\n org.morph.eye.pos[eye][j].x, org.morph.eye.pos[eye][j].y, target.x, target.y, target.cal);\n }\n }\n}", "title": "" }, { "docid": "df80aa6888a3d0ce30707cca2b70c6c8", "score": "0.4986122", "text": "function check() {\n var i = 0;\n var feature;\n while(feature = find(\"sp\",i)) {\n if (feature.geometry.CLASS_NAME != \"OpenLayers.Geometry.Point\") {\n return false;\n }\n if (i > 0) {\n feature = find(\"link\", i-1);\n if (!feature || feature.geometry.CLASS_NAME != \"OpenLayers.Geometry.LineString\") {\n return false;\n }\n }\n i++;\n }\n return true;\n }", "title": "" }, { "docid": "d389361167ec3f473f94e381c9589b2a", "score": "0.49822658", "text": "function checkHasPositionalTracking () {\n var vrDisplay = controls.getVRDisplay();\n if (isMobile() || isGearVR()) { return false; }\n return vrDisplay && vrDisplay.capabilities.hasPosition;\n}", "title": "" }, { "docid": "d389361167ec3f473f94e381c9589b2a", "score": "0.49822658", "text": "function checkHasPositionalTracking () {\n var vrDisplay = controls.getVRDisplay();\n if (isMobile() || isGearVR()) { return false; }\n return vrDisplay && vrDisplay.capabilities.hasPosition;\n}", "title": "" }, { "docid": "e2d7bb58732c2e587baea5e8b5018d80", "score": "0.49767292", "text": "function checkForLanding(){\n return collidePointRect(mouseX, mouseY, x, y, 80, 63);\n}", "title": "" }, { "docid": "e51073afa922d0611257426c514c296f", "score": "0.4967319", "text": "function inAnyChal() {\n if (game.challenge>0) return true\n if (game.chal8==1) return true\n if (game.chal9==1) return true\n if (game.omegaChallenge==1) return true\n return false\n return false\n}", "title": "" }, { "docid": "120a8fbc838bc9d0e0e2b76a5aa2de28", "score": "0.49652597", "text": "function didTifStudyPhilo(){\n var philoDegree = prompt('Does Tif have a degree in Philosophy? (yes or no)').toLowerCase();\n if(philoDegree === 'y' || philoDegree === 'yes') {\n score ++;\n alert('Yeah...I am in a constant state of existentialism, LOL');\n // console.log('Does Tif have a degree in Philosophy? ' + philoDegree + ' is correct');\n } else if(philoDegree === 'n' || philoDegree === 'no') {\n alert('Sadly, you\\'re wrong. I majored in Philosophy of the Mind');\n // console.log('Does Tif have a degree in Philosophy? ' + philoDegree + ' is incorrect');\n } else {\n alert('Please enter yes or no');\n }\n}", "title": "" }, { "docid": "30d0b21cb6bfc442e12ec607f0e8f718", "score": "0.49647808", "text": "function checkCanyon(t_canyon)\n{\n if(gameChar_world_x>t_canyon.x_pos && gameChar_world_x<t_canyon.x_pos+t_canyon.width && gameChar_y>=floorPos_y){\n isPlummeting=true;\n }\n \n if(isPlummeting==true){\n gameChar_y+=2;\n }\n}", "title": "" }, { "docid": "a741609b670cec7330553de40214b52b", "score": "0.49635786", "text": "function checkDependentTalent(talent) {\r\n\r\n\tif(talent.requires) {\r\n\t\t\r\n\t\tvar reqTalent = talentLookup[talent.requires];\r\n\t\tif(reqTalent && reqTalent.pts < reqTalent.maxPts) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\t\t\r\n\r\n\treturn true;\r\n}", "title": "" }, { "docid": "4d709cc041ad15833933cc268e08241b", "score": "0.49624044", "text": "function checkIfFoodEaten() {\n // [x,y]\n const snakeHeadX = snake.location[0];\n const snakeHeadY = snake.location[1];\n const foodLocation = food.location;\n if (snakeHeadX === foodLocation[0] && snakeHeadY === foodLocation[1])\n {\n return true;\n }\n return false;\n }", "title": "" }, { "docid": "4032806ff3b60db4cf00b38fdd5114a0", "score": "0.49559578", "text": "function createWorldList(world) {\n var checks = [];\n for(var i = 0; i < locationList.length; i++) {\n if(world.includes(locationList[i])) {\n checks.push(rewardList[i]);\n }\n }\n return checks;\n}", "title": "" }, { "docid": "8b527d345a0ba73e9d1a944a5726a1f2", "score": "0.49557188", "text": "function checkIfMonsterWithPacman() {\r\n\tif (((monster1.i == shape.i) && (monster1.j == shape.j)) ||\r\n\t\t((monster2.i == shape.i) && (monster2.j == shape.j)) ||\r\n\t\t((monster3.i == shape.i) && (monster3.j == shape.j)) ||\r\n\t\t((monster4.i == shape.i) && (monster4.j == shape.j))) {\r\n\t\tlife--;\r\n\t\tscore = score - 10;\r\n\t\tfindPacmanPlace();\r\n\t\tputMonstersInRightPlace();\r\n\t} else if (life <= 0) {\r\n\t\twindow.clearInterval(interval);\r\n\t}\r\n}", "title": "" }, { "docid": "867db3ed198416a0738993e755e5d5f2", "score": "0.49555767", "text": "isAt(otherLocation) {\n return this.latitude === otherLocation.latitude && this.longitude === otherLocation.longitude;\n }", "title": "" }, { "docid": "818439ef560e2e48a6c7812e7da88528", "score": "0.49481383", "text": "function checkForWorld(callback) {\n\tlet worldPath = mcutil.getWorld(parameters.world);\n\tosutil.checkDirectory(worldPath, function (success, err) {\n\t\tif (err) {\n\t\t\t// Other error\n\t\t\toutput.error(err);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\telse if (!success) {\n\t\t\t// World doesn't exist\n\t\t\toutput.error('World \\\"' + parameters.world + '\\\" does not exist!');\n\t\t\tprocess.exit(1);\n\t\t}\n\t\telse {\n\t\t\t// Success\n\t\t\toutput.success('Found World \\\"' + parameters.world + '\\\" at ' + worldPath);\n\t\t\tcallback();\n\t\t}\n\t});\n}", "title": "" }, { "docid": "94accd0d6636397762c8a6869ca95ebe", "score": "0.4942353", "text": "function defined (thing) {\n\t return thing !== void 0;\n\t }", "title": "" }, { "docid": "94accd0d6636397762c8a6869ca95ebe", "score": "0.4942353", "text": "function defined (thing) {\n\t return thing !== void 0;\n\t }", "title": "" }, { "docid": "da8d66cc1d533672013a22b637b2ddde", "score": "0.49409392", "text": "function handle_IFP(formula,subj,pred,obj){var s1=formula.any(undefined,pred,obj);if(!s1){return false;// First time with this value\n}// log.warn(\"Equating \"+s1.uri+\" and \"+subj.uri + \" because IFP \"+pred.uri); //@@\nformula.equate(s1,subj);return true;}// handle_IFP", "title": "" }, { "docid": "92e1d95a1c5cda139416e28f0d6780fc", "score": "0.49306858", "text": "static askLocationQuestion() {\n return 'Would you like to find another location? ';\n }", "title": "" }, { "docid": "a313f87115f6ea71cb1f09251b09a9c4", "score": "0.4923804", "text": "function checkProblemSpecification(text, clauses, variables) {\r\n let aux1 = []\r\n let numVariaveis\r\n let numClausulas\r\n let flag = false\r\n for(let i = 0; i < text.length; i++) {\r\n if(text[i][0] == 'p') {\r\n aux1 = text[i].split(' ')\r\n numVariaveis = aux1[2]\r\n numClausulas = aux1[3]\r\n i = text.length\r\n flag = true\r\n }\r\n if(numVariaveis == variables.length && numClausulas == clauses.length) {\r\n return true\r\n }\r\n }\r\n if (flag == false) {\r\n console.log(\"\\nThis file has no 'p' signaling at the beginning of the specification line in the header.\")\r\n return true\r\n } else {\r\n console.log(\"\\nThe specification of the problem in the header doesn't match the specification extracted from the clauses.\")\r\n return false\r\n }\r\n }", "title": "" }, { "docid": "4949fb630b6d85ba3fa391af6cebc5c3", "score": "0.49215463", "text": "function isHomeTown(town){\n if(town === 'San Francisco'){\n return 'True'; \n }\n\n else{\n return 'False'; \n }\n}", "title": "" }, { "docid": "d077cb542b4a8da13cbc30776473b0ec", "score": "0.49173772", "text": "function containsTheta(d){ return (d.lb < theta && d.ub > theta)? true : false; }", "title": "" }, { "docid": "31f5cda415afd564943eabdde7b7ae0a", "score": "0.4911337", "text": "function checkIfCompleted() {\n\t\tvar isMissingCheckin = false;\n\t\tfor (var i = 0; i < locationArray.length; i++) {\n\t\t\tvar location = locationArray[i];\n\t\t\tif (location.foursquareCheckin === undefined) {\n\t\t\t\tisMissingCheckin = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!isMissingCheckin) {\n\t\t\tcreatePlace();\n\t\t}\n\n\t}", "title": "" }, { "docid": "06731ae7b23dd8ad1b3ce1688df88acd", "score": "0.4909735", "text": "static get doesSceneHaveManualPortals() {}", "title": "" }, { "docid": "ebe78344acd20ed4960113e63a5dfeb1", "score": "0.49088746", "text": "function truth() {\n\tif (mood === \"yes\") {\n\t\tconsole.log(\"yes\");\n\t} else {\n\tprompt(\"I think you can BELEIVE. Do you BELEIVE yet?\");\n\t}\n}", "title": "" }, { "docid": "eeba52721bc3a6fc8b5f4a640c6759b2", "score": "0.48948258", "text": "function isEquationSolved(formula) { \n\tconsole.log('\\nisEquationSolved - formula: ' + formula);\n\n\tvar numOfVars;\n\n\tvar formulaArr = formula.split('=');\n\n\tvar NumOfTargets_leftSide = formulaArr[0].split(fObj.target).length-1; \t\n\tvar NumOfTargets_rightSide = formulaArr[1].split(fObj.target).length-1;\t\n\tconsole.log('isEquationSolved - NumOfTargets_leftSide: ' + NumOfTargets_leftSide + ', NumOfTargets_rightSide: ' + NumOfTargets_rightSide);\n\n\t// if (NumOfTargets_leftSide == NumOfTargets_rightSide) { \t// <--- ADDED 9/6-2017 // COMMENTED OUT 13/6-2017\n\t// \talert('KRITISK FEJL FRA \"ligning.js\" - isEquationSolved(formula): Ligningen har ingen løsning da NumOfTargets_leftSide = NumOfTargets_rightSide = ' + NumOfTargets_rightSide);\n\t// \treturn 0;\n\t// }\n\n\tif (NumOfTargets_leftSide > NumOfTargets_rightSide) { // If eg. x*x*a = x*b ---> x = a/b\n\t\tconsole.log('isEquationSolved - A0');\n\t\tnumOfVars = sc.returnParenthesisObj_formula_mod(formulaArr[0]).equationSide_mod.replace(/(\\+|\\-|\\*|\\/)/g, '@').split('@').length;\n\t} else {\n\t\tconsole.log('isEquationSolved - A1');\n\t\tnumOfVars = sc.returnParenthesisObj_formula_mod(formulaArr[1]).equationSide_mod.replace(/(\\+|\\-|\\*|\\/)/g, '@').split('@').length;\n\t}\n\tconsole.log('isEquationSolved - numOfVars: ' + JSON.stringify( numOfVars ));\n\n\tif (numOfVars == 1) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}", "title": "" }, { "docid": "42af81867838e487a7a4c5e172c49180", "score": "0.4888744", "text": "function r(r,e){return r.isGeographic||r.isWebMercator&&(e?.geographic??!0)}", "title": "" }, { "docid": "8d541272e9f8da9e37ea7330a57dddb0", "score": "0.48832545", "text": "function canWalkHere(x, y)\n\t{\n\t\treturn ((world[x] != null) &&\n\t\t\t(world[x][y] != null) &&\n\t\t\t(world[x][y] <= maxWalkableTileNum));\n\t}", "title": "" }, { "docid": "11431c14db7703cffdca2c669a38bd11", "score": "0.48831105", "text": "function square_belongs_to_p(x, y) {\n\tvar size = piece_size()\n\tvar mask = piece_mask()\n\tvar mx = x - p.x\n\tvar my = y - p.y\n\treturn \tmx >= 0 && mx < size.width && \n\t\t\tmy >= 0 && my < size.height && \n\t\t\tmask[my][mx] == 'x'\n\n}", "title": "" }, { "docid": "d9b8d707eb8b2cdefb1eebd6529b4f2d", "score": "0.48825702", "text": "function canWalkHere(y, x) {\n return ((world[x] !== null) &&\n (world[x][y] !== null) &&\n (world[x][y] <= maxWalkableTileNum));\n }", "title": "" }, { "docid": "b5584fe011ecf2d732d9d0625719923c", "score": "0.4880944", "text": "function checkGuess(correct_word, given_word)\n{\n if(correct_word.localCompare(given_word) == 0)\n {\n return true;\n }\n else\n {\n // <TBD> Check if there are any synonym matches\n return false;\n }\n}", "title": "" }, { "docid": "abe7cf7e9c944d5d568590e5f1c2b648", "score": "0.4878488", "text": "function sortWorldLists(proof, worldName) {\n if(proof) {\n proofLocations.push(worldName);\n var index = allworlds.indexOf(worldName);\n allworlds.splice(index, 1);\n }\n}", "title": "" }, { "docid": "bd20fb452fce2fcae0b3a2aca94475a7", "score": "0.48709136", "text": "nearEnemy () \n {\n for (let l of theGame.leaders.values ()) \n {\n // Skip if leader is friendly\n if (l.player.playerId == this.player.playerId)\n {\n continue; \n } \n \n const distanceSquared = this.distanceSquareFromLeader (l);\n if (distanceSquared < visibilityRadiusSquared) \n {\n return true;\n }\n }\n \n return false; \n }", "title": "" }, { "docid": "637c70c93827c3e840472241351de3b9", "score": "0.48690698", "text": "function check() {\n if (phrases.indexOf(t2) === -1 && indexOfPhrases.includes(i) === false && indexOfPhrases.includes(j) === false) {\n return true;\n }\n }", "title": "" }, { "docid": "11c02a8e621d1339708e2f95eecfb711", "score": "0.48680606", "text": "function checkStreetUnderMarker() {\n var coord = window.pointFeature.getGeometry().getCoordinates();\n coord = ol.proj.transform(coord, 'EPSG:3857', 'EPSG:4326');\n var lon = coord[0];\n var lat = coord[1];\n var revGeocode = 'https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon +'&zoom=17';\n var street = \"\";\n $.getJSON(revGeocode, function( response ) {\n // get lat + lon from first match\n var data = response;\n console.log( response.address.road )\n window.streetSelected = response.address.road;\n // console.log(response)\n checkAnswer();\n\n });\n\n return 0;\n}", "title": "" }, { "docid": "2efe4891c913abfe45ab94b74d500495", "score": "0.48635495", "text": "hasWishAndProtect() {\n return store.doesTeamPokemonHaveTheseMoves(['wish', [\n 'protect',\n 'detect',\n 'banefulbunker',\n 'spikyshield',\n 'kingsshield',\n ]])\n }", "title": "" }, { "docid": "4a4b3d5828fc66cb1ba81c1d94cc1246", "score": "0.48614258", "text": "function checkVictory(){\n let victorySatisfied = true;\n let node, visited, has_mine;\n // walk the grid\n Object.keys(grid).forEach(function(key){\n // check if there are any nodes which don't have a mine but haven't been visited\n node = grid[key];\n visited = node.visited;\n contains_mine = node.contains_mine;\n if (!contains_mine && !visited){\n victorySatisfied = false;\n }\n });\n return victorySatisfied;\n}", "title": "" }, { "docid": "e6a6502740e7052e6d6815af0637c8c4", "score": "0.48581654", "text": "function check(mX,mY,locX,locY,tempRsize){\n if(mX>locX && mX<locX + tempRsize && mY>locY && mY<locY + tempRsize){\n console.log(\"in box\");\n // can return true or false, numbers, strings\n return true;\n }else{\n return false;\n }\n}", "title": "" }, { "docid": "54415cb16e8d0b367fa6bf72e66921f0", "score": "0.48556164", "text": "isVisible(robot) {\n return ('unit' in robot);\n }", "title": "" }, { "docid": "54415cb16e8d0b367fa6bf72e66921f0", "score": "0.48556164", "text": "isVisible(robot) {\n return ('unit' in robot);\n }", "title": "" }, { "docid": "54415cb16e8d0b367fa6bf72e66921f0", "score": "0.48556164", "text": "isVisible(robot) {\n return ('unit' in robot);\n }", "title": "" }, { "docid": "eb017be37065f39aa96cef65bb8f15ef", "score": "0.48535758", "text": "waitingForConfidenceFromPlayer(player) {\n return this.friendConfidence === undefined && this.friend == player;\n }", "title": "" }, { "docid": "3d7ed795e859b69f1b6fdc7632abfbad", "score": "0.48499438", "text": "function isValid(country) {\n return (country.data.geography && \n country.data.geography.geographic_coordinates && \n country.data.geography.geographic_coordinates.latitude && \n country.data.geography.geographic_coordinates.latitude.degrees && \n country.data.geography.geographic_coordinates.longitude && \n country.data.geography.geographic_coordinates.longitude.degrees && \n country.data.energy && \n country.data.energy.carbon_dioxide_emissions_from_consumption_of_energy && \n country.data.energy.carbon_dioxide_emissions_from_consumption_of_energy.megatonnes && \n country.data.people && \n country.data.people.population && \n country.data.people.population.total);\n}", "title": "" }, { "docid": "3ab722dff8e868725a9fabee0fe7f21d", "score": "0.4845973", "text": "function anyTiesExist(standings) {\n for(var i in standings) {\n if(standings[i].ties > 0) { return true; }\n }\n return false;\n}", "title": "" }, { "docid": "338f1ac3a5444997f26224c2d23bbf5a", "score": "0.48386282", "text": "function isGroundData(body) {\n return body.hasOwnProperty(\"ground\")\n}", "title": "" }, { "docid": "7b2f2eb46335093d5ceb701eb748bf9d", "score": "0.4837256", "text": "async function verifierVerifyProof(proofReq, proof, schemas, credDefs) {\n return indy.verifierVerifyProof(proofReq, proof, schemas, credDefs, {}, {});\n }", "title": "" }, { "docid": "dde83b3791a81e849da22b7eda69b65b", "score": "0.48345265", "text": "groundPredicate(mesh){\n if (mesh.id == \"ground\"){\n return true\n }\n return false\n }", "title": "" }, { "docid": "aa5888ab3454bc68f29cf7d39048427c", "score": "0.48326695", "text": "function hasScored() {\r\n if ((x > goalX && x < goalX + 35) && (y > goalY + 5 && y < goalY + 80)) {\r\n goal = true;\r\n }\r\n}", "title": "" }, { "docid": "7772becb74cfed65e82376882426f03e", "score": "0.4831925", "text": "function checkCityLegality(coords, player, vertexList){\n\tvar vert = BoardState.findVertices(vertexList,coords)[0];\n\tif(vert.structure != 1){ // Ensures settlement is already present\n\t\treturn false;\n\t}\n\tif(vert.playerID != player.id){ // Ensures settlement belongs to correct player\n\t\treturn false;\n\t}\n\treturn true;\n}", "title": "" }, { "docid": "b960fa9cb5ae03b92e9ff8ba58c2fa0d", "score": "0.48311847", "text": "checkPlaceReq(placeReq, initWorkerList) {\n return RFC.isWellFormedPlaceReq(placeReq) &&\n RC.isValidPlace(initWorkerList, placeReq[1], placeReq[2]);\n }", "title": "" }, { "docid": "22d887cfdd1a44b74ff16f091aaf7c5d", "score": "0.48293906", "text": "verificar_p(mX,mY){\n if (mX >= ((this.posx)-((this._shape[0].length*this.longitud)/2) ) && mX <= ((this.posx)+((this._shape[0].length*this.longitud)/2))) {\n if (mY >= ((this.posy)-((this._shape.length*this.longitud)/2)) && mY <= ((this.posy)+((this._shape.length*this.longitud)/2))){\n return true;\n }\n }\n }", "title": "" }, { "docid": "d58be2e6f4799c86d09cad11b873ec7e", "score": "0.48236352", "text": "function isValidWalk(walk) {\r\n //north - вверх\r\n //west - лево\r\n //east - право\r\n //south - вниз\r\n //да, я географический кретин\r\n let location = {\r\n horizontal: 0,\r\n vertical: 0\r\n };\r\n for (let p in walk){\r\n walk[p] == 'n' ? location.vertical++ : \r\n walk[p] == 's' ? location.vertical--:\r\n walk[p] == 'w' ? location.horizontal++:\r\n walk[p] == 'e' ? location.horizontal--: null;\r\n //console.log('location: ' + location.horizontal+ ' ' + location.vertical);\r\n //console.log(walk[p]+ '\\n---');\r\n }\r\n console.log(location.horizontal==0 && location.vertical == 0 && walk.length == 10 ? true : false);\r\n}", "title": "" }, { "docid": "261c4827ae9ac924cec175a309634fc3", "score": "0.48234543", "text": "function checkifyesfilled3()\n{\n if (checkifyes(\"personaleffect\"))\n {\n if (!checkfilled('whateffect'))\n {\n return false\n }\n }\n return true\n}", "title": "" }, { "docid": "0b7e4953450db31a9aa73f25895b11c0", "score": "0.48231927", "text": "function evaluateTruthy() {\n\t\t var res = this.evaluate();\n\t\t if (res.confident) return !!res.value;\n\t\t}", "title": "" }, { "docid": "0b7e4953450db31a9aa73f25895b11c0", "score": "0.48231927", "text": "function evaluateTruthy() {\n\t\t var res = this.evaluate();\n\t\t if (res.confident) return !!res.value;\n\t\t}", "title": "" } ]
6e725f4c451cc2109bd18770b70fffd9
IF we have a valid file handle and there are messages to be written, write them. if the queue length and queue index are equal, then we clear the queue and set the index back to 0, because we caught up with all our messages, and mark writing as false. If we don't have any queued messages or a valid file handle, mark writing as false. If we are writing, we're not done with the queue, and a valid file handle, write the next message!
[ { "docid": "c32f8a217ec07f29c55732f67643d09a", "score": "0.60939926", "text": "function writeMessageIfNeeded() {\n\t\t\tif(Zale.Trace._fileHandle >= 0) {\n\t\t\t\tif(Zale.Trace._queue.length > 0) {\n\t\t\t\t\tif(Zale.Trace._queue.length == Zale.Trace._queueIdx) {\n\t\t\t\t\t\tZale.Trace._queue.length = 0;\n\t\t\t\t\t\tZale.Trace._queueIdx = 0;\n\t\t\t\t\t\tZale.Trace._writing = false;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tZale.Trace._writing = true;\n\t\t\t\t\t\tlet msg = Zale.Trace._queue[Zale.Trace._queueIdx];\n\t\t\t\t\t\tlet output = \"\";\n\t\t\t\t\t\tif(msg.type != null) {\n\t\t\t\t\t\t\tlet rightNow = new Date();\n\t\t\t\t\t\t\toutput = \"[\" + msg.type.toUpperCase();\n\t\t\t\t\t\t\tif(!Zale.Trace._truncate) {\n\t\t\t\t\t\t\t\toutput += \" (\" + Zale.Trace._instanceID + \") \";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet hours = rightNow.getHours();\n\t\t\t\t\t\t\tlet ampm = rightNow.getHours() >= 12 ? \"pm\" : \"am\";\n\t\t\t\t\t\t\thours = hours == 0 ? 12 : hours;\n\t\t\t\t\t\t\tif(hours > 12) {\n\t\t\t\t\t\t\t\thours -= 12;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet today = (rightNow.getMonth() + 1) + \"/\" + rightNow.getDate() + \"/\" + rightNow.getFullYear();\n\t\t\t\t\t\t\tlet now = hours.padZero(2) + \":\" + rightNow.getMinutes().padZero(2) + \":\" + rightNow.getSeconds().padZero(2);\n\t\t\t\t\t\t\toutput += \" \" + today + \" \" + now + ampm + \"] \";\n\t\t\t\t\t\t}\n\t\t\t\t\t\toutput += msg.message + \"\\r\\n\";\n\t\t\t\t\t\tfs.write(Zale.Trace._fileHandle, output, null, 'utf8', verifyWrite);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tZale.Trace._writing = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tZale.Trace._writing = false;\n\t\t\t}\n\t\t}", "title": "" } ]
[ { "docid": "26a979796690764e599cfded92c80750", "score": "0.678121", "text": "function writeNextMessage() {\n if (!messageStorageQueue.length) return\n var message = messageStorageQueue.shift()\n var lineToWrite = JSON.stringify(message) + \"\\n\"\n var fileName = getStorageFileNameForMessage(message)\n // TODO: Do we need to datasync to be really sure data is written?\n fs.appendFile(fileName, lineToWrite, function (err) {\n if (err) {\n log(\"Problem writing file\", err)\n return\n }\n scheduleMessageWriting()\n })\n}", "title": "" }, { "docid": "d70fbdef43c1f4817f71f422d4c73c00", "score": "0.60705507", "text": "function flush() {\n if (paused) { return; }\n for (var i = 0, l = queue.length; i < l; i++) {\n var item = queue[i];\n stream.emit(\"data\", item.doc, item.meta);\n counter--;\n }\n queue.length = 0;\n process.nextTick(checkDone);\n }", "title": "" }, { "docid": "e6dc522834be6dce224b956583309ba5", "score": "0.6064885", "text": "function flushMessageQueue (connection, queue) {\n while (queue[0]) {\n var message = queue[0];\n\n while (message.output.length > 0) {\n if (connection.readyState !== \"open\" && connection.readyState !== \"writeOnly\") {\n return true;\n }\n\n var data = message.output.shift();\n var encoding = message.outputEncodings.shift();\n\n connection.send(data, encoding);\n }\n\n if (!message.finished) break;\n\n message.emit(\"sent\");\n queue.shift();\n\n if (message.closeOnFinish) return true;\n }\n return false;\n}", "title": "" }, { "docid": "23fd0b89958d34ac535a6bb70cfdb296", "score": "0.5871826", "text": "handleQueue() {\n\t\tif (this.queue.length > 0) {\n\t\t\tconst that = this;\n\t\t\tif (typeof this.statusCallback !== 'undefined' && this.statusCallback !== null) {\n\t\t\t\tthis.statusCallback(1 - this.queue.length / this.queueLength);\n\t\t\t}\n\t\t\tif (this.findSound(this.queue[0]) !== -1) {\n\t\t\t\tthis.queue.splice(0, 1);\n\t\t\t\tthis.handleQueue();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.sounds.push(new SoundObjectItem(this.queue[0], (() => {\n that.handleQueue();\n\t\t\t}), 1));\n\t\t\tthis.queue.splice(0, 1);\n\t\t} else {\n\t\t\tthis.loadingQueue = false;\n\t\t\t\tconsole.log('finished with queue.');\n\t\t\t\tif (typeof this.queueCallback !== 'undefined' && this.queueCallback !== 0) {\n\t\t\t\t\tthis.queueCallback();\n\t\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "a3e11556f27fc5a930750db0123a0662", "score": "0.58484584", "text": "function queueSend () {\n\n if (self.is_connected && is_transmitting === 0 && message_queue.length > 0) {\n\n var obj = message_queue.shift();\n is_transmitting = obj.id;\n self.emit(\"debug\", 'sending data: ' + obj.data);\n \n itach.write(obj.data + \"\\r\\n\");\n obj.callback(false);\n }\n return;\n }", "title": "" }, { "docid": "59587a5c7c07d412de979145cac055f3", "score": "0.57673055", "text": "writeNext() {\n const msg = this.buffered.shift();\n if (msg !== undefined) {\n this.writeNow(msg);\n }\n }", "title": "" }, { "docid": "9dafe7141afff392ceb7bb4dd9e04c75", "score": "0.5714142", "text": "sendMsg() {\n console.log(\"CLIENT: Message queue called in sendMsg\");\n if (!this.msgQueue.isEmpty()) {\n // Retrieve next message\n let [hash, msg] = this.msgQueue.getMessage();\n console.log(\"CLIENT: Sending a new message to client\", msg);\n\n this.isWaiting = true;\n this.currentHash = hash;\n let msgStatus = this.socket.write(JSON.stringify(msg));\n console.log(\"CLIENT: sendMsg sent a message with status\", msgStatus);\n return;\n }\n console.log(\"CLIENT: Message queue had other messages in sendMsg\");\n }", "title": "" }, { "docid": "d0740f9a9ff87716f7debab02435ea3b", "score": "0.5711078", "text": "static processQueue() {\n if (this.isProcessingQueue) return;\n this.isProcessingQueue = true; // True, we are busy, add row to queue and exit\n\n this.db ? this.emptyQueue() : this.openDb();\n }", "title": "" }, { "docid": "7ecf1473a4c8fc3854f5c8d4dff39b3e", "score": "0.56816727", "text": "function startSync() {\r\n\tif (fnQueue.length == 0) {\r\n\t\treturn;\r\n\t};\r\n\tif (queueItem != null) {\r\n\t\treturn setTimeout(startSync, 1000);\r\n\t}\r\n\tqueueItem = fnQueue.shift();\r\n\t//console.log((new Date()).toISOString() + ' - ' + queueItem.filename);\r\n\r\n\tfs.stat(queueItem.filename, (err, stat) => {\r\n\t\t//console.log(\"Deleted\", queueItem.filename);\r\n\t\tif (err) {\r\n\t\t\tif (err.errno != -2) {\r\n\t\t\t\tconsole.error(err);\r\n\t\t\t\t// the rest is silence... :)\r\n\t\t\t\tqueueItem = null;\r\n\t\t\t\treturn setTimeout(startSync, 0);\r\n\t\t\t}\r\n\t\t\tconsole.log((new Date()).toISOString() + ' - Deleted ' + queueItem.filename);\r\n\t\t\tsocket.emit('delete', {\r\n\t\t\t\tfilename: queueItem.filename.substr(thedir.length + 1).replace(/\\\\/g, '/')\r\n\t\t\t});\r\n\t\t\tqueueItem = null;\r\n\t\t\treturn setTimeout(startSync, 0);\r\n\t\t};\r\n\t\t\r\n\t\t//console.log(\"Modified\", queueItem.filename);\r\n\t\tfs.readFile(queueItem.filename, (err, filecontent) => {\r\n\t\t\tif (err) {\r\n\t\t\t\tconsole.error(err);\r\n\t\t\t\t// the rest is silence... :)\r\n\t\t\t\tqueueItem = null;\r\n\t\t\t\treturn setTimeout(startSync, 0);\r\n\t\t\t};\r\n\t\t\tconsole.log((new Date()).toISOString() + ' - Modified ' + queueItem.filename);\r\n\t\t\tsocket.emit('mod', {\r\n\t\t\t\tfilename: queueItem.filename.substr(thedir.length + 1).replace(/\\\\/g, '/'),\r\n\t\t\t\tcontent: filecontent\r\n\t\t\t});\r\n\t\t\tqueueItem = null;\r\n\t\t\treturn setTimeout(startSync, 0);\r\n\t\t});\r\n\t});\r\n}", "title": "" }, { "docid": "b0e6d0771240e9fb7b3521a4f88e1bfc", "score": "0.5680172", "text": "checkQueue() {\n\t\tif (this.sendQue && this.lastCmd && this.lastCmd != '') {\n\t\t\tlet now = Date.now();\n\t\t\t// early retry?\n\t\t\tif ((this.lastCmdAt + this.CMD_INTERVAL) > now) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// try to send a few times, otherwise move on\n\t\t\tif ((this.lastCmdTries++) < 5) {\n\t\t\t\tthis.sendIt(this.lastCmd);\n\t\t\t} else {\n\t\t\t\tthis.sendQue.shift();\n\t\t\t\tif (this.sendQue.length>0) {\n\t\t\t\t\tthis.sendIt(this.sendQue[0]);\n\t\t\t\t} else {\n\t\t\t\t\tthis.lastCmd = '';\n\t\t\t\t\tthis.lastCmdTries = 1;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "4c671c7a738508de0d38f796d4b1a512", "score": "0.5651561", "text": "function processQueue(){\n // Move forward if there is an item left in the queue, otherwise check to see if we are finished\n if(queue.length > 0) {\n console.log('Processing: ' + scraping.length + ' | Queued: ' + queue.length + ' | Completed: ' + scraped.length);\n // Add last item from pages_to_crawl queue\n scraping.push(queue[queue.length - 1]);\n\n // Process the last item in the queue\n loadListing(scraping[scraping.length - 1]);\n\n queue.pop();\n } else if (scraped.length > 30 && scraping.length == 0 && queue.length == 0){\n // console.log('**** FINISHED CRAWLING *****');\n // processResults();\n }\n }", "title": "" }, { "docid": "150dc38d032624f7a63266acad3c0ae2", "score": "0.56049186", "text": "function sendQueuedMessages() {\n var queue = self.sendQueue;\n self.sendQueue = [];\n for (var k = 0; k < queue.length; k++) {\n self.sendMessage(queue[k]);\n }\n }", "title": "" }, { "docid": "e7c3d107a4fd09b19fcca19315d0571c", "score": "0.55848587", "text": "function verifyWrite(err, bytesWritten, string) {\n\t\t\tif(err != null) {\n\t\t\t\tinternalError(\"There was an error writing a message to the log file.\");\n\t\t\t\tinternalError(err);\n\t\t\t\tsetTimeout(function() { writeMessageIfNeeded(); }, 1000);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tZale.Trace._queueIdx++;\n\t\t\twriteMessageIfNeeded();\n\t\t}", "title": "" }, { "docid": "691197cb602c1a6888435445f726d17f", "score": "0.55667275", "text": "flush() {\n let fileQueue = this.fileQueue;\n\n if (fileQueue) {\n fileQueue.flush();\n }\n\n let files = this.files;\n\n if (files.length === 0) {\n return;\n }\n\n let allFilesHaveSettled = files.every((file) => {\n return ['uploaded', 'aborted'].includes(file.state);\n });\n\n if (allFilesHaveSettled) {\n this.files.forEach((file) => set(file, 'queue', null));\n set(this, 'files', A());\n }\n }", "title": "" }, { "docid": "dbcef33746c4ef906b85ed1fb5779c03", "score": "0.55513", "text": "static emptyQueue() {\n if (this.queue.length) {\n const transaction = this.db.transaction(_LOG_STORE, 'readwrite');\n const objectStore = transaction.objectStore((_LOG_STORE));\n\n while (this.queue.length) {\n objectStore.add(this.queue.shift());\n }\n }\n this.isProcessingQueue = false;\n }", "title": "" }, { "docid": "f20b4cf429a549d77e58043b56b0b0dc", "score": "0.5541287", "text": "function processQueue() {\n\n // If we have a message in the message queue, removed it from the queue and send it to slack\n if (messages.length > 0) {\n sendSlack(messages.shift());\n }\n\n // If there are over 10 messages in the queue, send the suppression message if it has not been sent and delete all the messages in the queue after 10\n if (messages.length > 10) {\n if (!suppressed.isSuppressed) {\n suppressed.isSuppressed = true;\n suppressed.date = new Date().getTime();\n sendSlack({\n name: 'pm2-slack',\n event: 'suppressed',\n description: 'Messages are being suppressed due to rate limiting.'\n });\n }\n messages.splice(10, messages.length);\n }\n\n // If the suppression message has been sent over 1 minute ago, we need to reset it back to false\n if (suppressed.isSuppressed && suppressed.date < (new Date().getTime() - 60000)) {\n suppressed.isSuppressed = false;\n }\n\n // Wait 10 seconds and then process the next message in the queue\n setTimeout(function() {\n processQueue();\n }, 10000);\n}", "title": "" }, { "docid": "5d09d70a50387f0e7b70f1ee5a5a9767", "score": "0.55330616", "text": "function process() {\n // If the queue is not empty\n if (queue.length > 0) {\n // Get the next message ID\n const id = queue[0]\n // Attempt to read the message from disk\n try {\n const message = readFileSync(\"_asap_\" + id, \"cbor\")\n const timeout = message[2]\n // If the message has expired\n if (timeout < Date.now()) {\n // Dequeue the message\n dequeue(id)\n }\n // If the message has not expired\n else {\n // Attempt to send the message\n try {\n peerSocket.send(message)\n } catch (error) {\n debug && console.log(error)\n }\n }\n }\n // If the message could not be read from disk\n catch {\n // Dequeue the message\n dequeue(id)\n }\n }\n}", "title": "" }, { "docid": "f4ac49a7714bfc3b8bed289161ca7396", "score": "0.54697436", "text": "tryWriteBegin() {\n if (this.pendingWrites.length > 0 || this.currentReads.length > 0) {\n return false;\n }\n //do sync writeBegin\n log.assert(this.currentWrite == null, \"race, current write should not be possible while start writing (tryWriteBegin)\");\n const writeId = this.writeCounter++;\n let thisWrite = promise.CreateExposedPromise({ writeId });\n this.pendingWrites.push(thisWrite);\n this.currentWrite = thisWrite;\n log.assert(this.currentWrite === this.pendingWrites[0], \"current write should be at head of queue. (tryWriteBegin)\");\n return true;\n }", "title": "" }, { "docid": "3c7c94febe14d85e9138a3b6a0598cd2", "score": "0.54066634", "text": "checkAndFlushBuffer() {\n\n if (!this.logStream || !this.buffer.length) {\n return; //will do nothing\n }\n\n if (this.buffer.length >= this.bufferFlushSize) {\n return this.processBuffer(); //will end with a buffer being send to disk\n }\n\n clearTimeout(this._timeout); //buffer limit not reached, reset a timer to process buffer after timeout, if no more logs are sent\n\n const self = this;\n this._timeout = setTimeout(function(){ self.processBuffer(); }, this.bufferTimeout);\n }", "title": "" }, { "docid": "f918a1516068b0b2144dddca63cd5c29", "score": "0.5379063", "text": "_process() {\n if (this.size === 0 || this.isPaused) {\n this.isRunning = false;\n this.isPaused = false;\n this.opts.complete();\n return;\n } else {\n this.isRunning = true;\n }\n // Return index to first item in queue (in FIFO order).\n const index = this._processIndex();\n try {\n // Remove item from queue\n this.remove(index);\n // Collect upload request data\n const data = uploadPayload([this.opts.get(index)], this.opts.historyId);\n // Initiate upload request\n this._processSubmit(index, data);\n } catch (e) {\n // Parse error message for failed upload item\n this.opts.error(index, String(e));\n // Continue queue\n this._process();\n }\n }", "title": "" }, { "docid": "ff0d6470847e5e89607bd9b1b2bd267d", "score": "0.53670996", "text": "function processChunkQueues(self, i, j, k) {\n var done = true\n // both queues are sorted by ascending distance\n if (self._chunkIDsToRemove.length) {\n var remove = parseChunkID( self._chunkIDsToRemove.pop() )\n removeChunk( self, remove[0], remove[1], remove[2] )\n done = false\n }\n if (self._chunkIDsPendingCreation.length >= self._maxChunksPendingCreation) return done\n if (self.noa.rendering._chunksToMesh.length >= self._maxChunksPendingMeshing) return done\n if (self._chunkIDsToAdd.length) {\n var id = self._chunkIDsToAdd.shift()\n var toadd = parseChunkID(id)\n requestNewChunk( self, id, toadd[0], toadd[1], toadd[2] )\n done = false\n }\n return done\n}", "title": "" }, { "docid": "1b69148bb5d5936fa54c8bc3de8c3965", "score": "0.5350324", "text": "function writeMessages(messages, tx, callback, currentMessageIdx = 0) {\r\n\r\n\tif (currentMessageIdx >= messages.length) {\r\n\t\tcallback(null);\r\n\t\treturn;\r\n\t}\r\n\t\r\n\ttx.write(messages[currentMessageIdx], false, function(error) {\r\n\t\tif (error) {\r\n\t\t\tcallback(error);\r\n\t\t} else {\r\n\t\t\twriteMessages(messages, tx, callback, currentMessageIdx + 1);\r\n\t\t}\r\n\t});\r\n\r\n}", "title": "" }, { "docid": "0c628388a14986b55b3f746067cc5ea9", "score": "0.5348393", "text": "function processQueue() {\n startingQueueLength = cardQueue.length;\n recursiveProcess();\n}", "title": "" }, { "docid": "ce277ad6a0fc234b28ea9e3b770c4595", "score": "0.532408", "text": "function repoSendTransactionQueue(repo, path, queue) {\r\n // Mark transactions as sent and increment retry count!\r\n var setsToIgnore = queue.map(function (txn) {\r\n return txn.currentWriteId;\r\n });\r\n var latestState = repoGetLatestState(repo, path, setsToIgnore);\r\n var snapToSend = latestState;\r\n var latestHash = latestState.hash();\r\n for (var i = 0; i < queue.length; i++) {\r\n var txn = queue[i];\r\n assert(txn.status === 0 /* RUN */, 'tryToSendTransactionQueue_: items in queue should all be run.');\r\n txn.status = 1 /* SENT */;\r\n txn.retryCount++;\r\n var relativePath = newRelativePath(path, txn.path);\r\n // If we've gotten to this point, the output snapshot must be defined.\r\n snapToSend = snapToSend.updateChild(relativePath /** @type {!Node} */, txn.currentOutputSnapshotRaw);\r\n }\r\n var dataToSend = snapToSend.val(true);\r\n var pathToSend = path;\r\n // Send the put.\r\n repo.server_.put(pathToSend.toString(), dataToSend, function (status) {\r\n repoLog(repo, 'transaction put response', {\r\n path: pathToSend.toString(),\r\n status: status\r\n });\r\n var events = [];\r\n if (status === 'ok') {\r\n // Queue up the callbacks and fire them after cleaning up all of our\r\n // transaction state, since the callback could trigger more\r\n // transactions or sets.\r\n var callbacks = [];\r\n for (var i = 0; i < queue.length; i++) {\r\n queue[i].status = 2 /* COMPLETED */;\r\n events = events.concat(repo.serverSyncTree_.ackUserWrite(queue[i].currentWriteId));\r\n if (queue[i].onComplete) {\r\n // We never unset the output snapshot, and given that this\r\n // transaction is complete, it should be set\r\n var node = queue[i].currentOutputSnapshotResolved;\r\n var ref = new Reference(repo, queue[i].path);\r\n var snapshot = new DataSnapshot(node, ref, PRIORITY_INDEX);\r\n callbacks.push(queue[i].onComplete.bind(null, null, true, snapshot));\r\n }\r\n queue[i].unwatcher();\r\n }\r\n // Now remove the completed transactions.\r\n repoPruneCompletedTransactionsBelowNode(repo, repo.transactionQueueTree_.subTree(path));\r\n // There may be pending transactions that we can now send.\r\n repoSendReadyTransactions(repo, repo.transactionQueueTree_);\r\n eventQueueRaiseEventsForChangedPath(repo.eventQueue_, path, events);\r\n // Finally, trigger onComplete callbacks.\r\n for (var i = 0; i < callbacks.length; i++) {\r\n exceptionGuard(callbacks[i]);\r\n }\r\n }\r\n else {\r\n // transactions are no longer sent. Update their status appropriately.\r\n if (status === 'datastale') {\r\n for (var i = 0; i < queue.length; i++) {\r\n if (queue[i].status === 3 /* SENT_NEEDS_ABORT */) {\r\n queue[i].status = 4 /* NEEDS_ABORT */;\r\n }\r\n else {\r\n queue[i].status = 0 /* RUN */;\r\n }\r\n }\r\n }\r\n else {\r\n warn('transaction at ' + pathToSend.toString() + ' failed: ' + status);\r\n for (var i = 0; i < queue.length; i++) {\r\n queue[i].status = 4 /* NEEDS_ABORT */;\r\n queue[i].abortReason = status;\r\n }\r\n }\r\n repoRerunTransactions(repo, path);\r\n }\r\n }, latestHash);\r\n }", "title": "" }, { "docid": "a1c624de0df097d2e4ace4db290d5ac7", "score": "0.5317681", "text": "async function handleMessagesQueue() {\r\n for (; ;) {\r\n for (const channelId in messagesQueue)\r\n sendMessage(channelId, messagesQueue[channelId]);\r\n\r\n messagesQueue = {};\r\n\r\n await sleep(config.messagesDelay);\r\n }\r\n}", "title": "" }, { "docid": "8daf2d42e6d7511c8be159601eb6f3c0", "score": "0.52795625", "text": "async writeBegin() {\n const writeId = this.writeCounter++;\n let thisWrite = promise.CreateExposedPromise({ writeId });\n this.pendingWrites.push(thisWrite);\n //wait until it's this write's turn\n while (this.pendingWrites[0].tags.writeId !== writeId) {\n await this.pendingWrites[0];\n }\n //wait while there are still active reads\n while (this.currentReads.length > 0) {\n await bluebird_1.default.all(this.currentReads);\n }\n //now on the item\n log.assert(this.currentWrite == null, \"race, current write should not be possible while start writing\");\n this.currentWrite = thisWrite;\n log.assert(this.currentWrite === this.pendingWrites[0], \"current write should be at head of queue. (writeBegin)\");\n }", "title": "" }, { "docid": "318e34f1936b0af4436260b92c9ce77f", "score": "0.5268146", "text": "function checkQueue() {\n if (!queueStarted && io.sockets.adapter.rooms[queueRoom].length > 1) {\n queueStarted = true;\n startQueue();\n }\n}", "title": "" }, { "docid": "97108fee10d3698f58fc9e1d41fb0712", "score": "0.5264714", "text": "function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit('drain');}}// if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "97108fee10d3698f58fc9e1d41fb0712", "score": "0.5264714", "text": "function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit('drain');}}// if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "97108fee10d3698f58fc9e1d41fb0712", "score": "0.5264714", "text": "function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit('drain');}}// if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "f469e7ff9fc05cdcb54a481ab3fe5203", "score": "0.5262226", "text": "function flush () {\n\t flushing = true\n\t run(queue)\n\t internalQueueDepleted = true\n\t run(userQueue)\n\t reset()\n\t}", "title": "" }, { "docid": "3677b24be9faa38bb797f4a5fc557fac", "score": "0.52581996", "text": "function repoSendTransactionQueue(repo, path, queue) {\n // Mark transactions as sent and increment retry count!\n var setsToIgnore = queue.map(function (txn) {\n return txn.currentWriteId;\n });\n var latestState = repoGetLatestState(repo, path, setsToIgnore);\n var snapToSend = latestState;\n var latestHash = latestState.hash();\n for (var i = 0; i < queue.length; i++) {\n var txn = queue[i];\n (0,_firebase_util__WEBPACK_IMPORTED_MODULE_2__.assert)(txn.status === 0 /* RUN */, 'tryToSendTransactionQueue_: items in queue should all be run.');\n txn.status = 1 /* SENT */;\n txn.retryCount++;\n var relativePath = newRelativePath(path, txn.path);\n // If we've gotten to this point, the output snapshot must be defined.\n snapToSend = snapToSend.updateChild(relativePath /** @type {!Node} */, txn.currentOutputSnapshotRaw);\n }\n var dataToSend = snapToSend.val(true);\n var pathToSend = path;\n // Send the put.\n repo.server_.put(pathToSend.toString(), dataToSend, function (status) {\n repoLog(repo, 'transaction put response', {\n path: pathToSend.toString(),\n status: status\n });\n var events = [];\n if (status === 'ok') {\n // Queue up the callbacks and fire them after cleaning up all of our\n // transaction state, since the callback could trigger more\n // transactions or sets.\n var callbacks = [];\n var _loop_1 = function (i) {\n queue[i].status = 2 /* COMPLETED */;\n events = events.concat(syncTreeAckUserWrite(repo.serverSyncTree_, queue[i].currentWriteId));\n if (queue[i].onComplete) {\n // We never unset the output snapshot, and given that this\n // transaction is complete, it should be set\n callbacks.push(function () {\n return queue[i].onComplete(null, true, queue[i].currentOutputSnapshotResolved);\n });\n }\n queue[i].unwatcher();\n };\n for (var i = 0; i < queue.length; i++) {\n _loop_1(i);\n }\n // Now remove the completed transactions.\n repoPruneCompletedTransactionsBelowNode(repo, treeSubTree(repo.transactionQueueTree_, path));\n // There may be pending transactions that we can now send.\n repoSendReadyTransactions(repo, repo.transactionQueueTree_);\n eventQueueRaiseEventsForChangedPath(repo.eventQueue_, path, events);\n // Finally, trigger onComplete callbacks.\n for (var i = 0; i < callbacks.length; i++) {\n exceptionGuard(callbacks[i]);\n }\n }\n else {\n // transactions are no longer sent. Update their status appropriately.\n if (status === 'datastale') {\n for (var i = 0; i < queue.length; i++) {\n if (queue[i].status === 3 /* SENT_NEEDS_ABORT */) {\n queue[i].status = 4 /* NEEDS_ABORT */;\n }\n else {\n queue[i].status = 0 /* RUN */;\n }\n }\n }\n else {\n warn('transaction at ' + pathToSend.toString() + ' failed: ' + status);\n for (var i = 0; i < queue.length; i++) {\n queue[i].status = 4 /* NEEDS_ABORT */;\n queue[i].abortReason = status;\n }\n }\n repoRerunTransactions(repo, path);\n }\n }, latestHash);\n}", "title": "" }, { "docid": "a6b7743418ba2db1f8c6277809f2927c", "score": "0.52434933", "text": "function processQueue () {\n\t queue.forEach(function (func) { $mdUtil.nextTick(func); });\n\t queue = [];\n\t }", "title": "" }, { "docid": "a6b7743418ba2db1f8c6277809f2927c", "score": "0.52434933", "text": "function processQueue () {\n\t queue.forEach(function (func) { $mdUtil.nextTick(func); });\n\t queue = [];\n\t }", "title": "" }, { "docid": "34bede536d966ea2af98db529b6fbf99", "score": "0.52198917", "text": "jumpQueue(position) {\n if (!Number.isInteger(position)) {\n return {\n respond: true,\n messages: [\n {\n type: 'text',\n text: 'Please enter a valid integer!'\n }\n ]\n };\n }\n\n if (position > this.queue.length) {\n return {\n respond: true,\n messages: [\n {\n type: 'text',\n text: 'There aren\\'t that many pairs in the queue!'\n }\n ]\n };\n }\n\n // remove from queue, then mark as entered\n const currPw = this.queue.splice(this.queue.length - position, 1)[0];\n this.passwordToId[currPw][0] = 1;\n\n // write back to data.json file\n let data = {\n \"Queue\": this.queue,\n \"ID to Password\": this.idToPassword,\n \"Password to ID\": this.passwordToId,\n \"ID to Username\": this.idToUsername\n };\n\n this.currentJob.then(() => {\n this.jsonfile.writeFile(this.filepath, data, {spaces: 2}, (err) => {\n if (err) throw err;\n console.log('Data updated.');\n });\n });\n\n return {\n respond: true,\n messages: [\n {\n type: 'text',\n text: 'Confirmed entrance for specified group.'\n }\n ]\n };\n }", "title": "" }, { "docid": "982d3cd230b215cd2803b1b2f0c2e70d", "score": "0.5217601", "text": "function flush () {\n\t run(queue)\n\t internalQueueDepleted = true\n\t run(userQueue)\n\t reset()\n\t}", "title": "" }, { "docid": "4c251ec179779d78a2b8ca3122104460", "score": "0.5217102", "text": "function repoSendTransactionQueue(repo, path, queue) {\n // Mark transactions as sent and increment retry count!\n var setsToIgnore = queue.map(function (txn) {\n return txn.currentWriteId;\n });\n var latestState = repoGetLatestState(repo, path, setsToIgnore);\n var snapToSend = latestState;\n var latestHash = latestState.hash();\n for (var i = 0; i < queue.length; i++) {\n var txn = queue[i];\n Object(__WEBPACK_IMPORTED_MODULE_2__firebase_util__[\"assert\"])(txn.status === 0 /* RUN */, 'tryToSendTransactionQueue_: items in queue should all be run.');\n txn.status = 1 /* SENT */;\n txn.retryCount++;\n var relativePath = newRelativePath(path, txn.path);\n // If we've gotten to this point, the output snapshot must be defined.\n snapToSend = snapToSend.updateChild(relativePath /** @type {!Node} */, txn.currentOutputSnapshotRaw);\n }\n var dataToSend = snapToSend.val(true);\n var pathToSend = path;\n // Send the put.\n repo.server_.put(pathToSend.toString(), dataToSend, function (status) {\n repoLog(repo, 'transaction put response', {\n path: pathToSend.toString(),\n status: status\n });\n var events = [];\n if (status === 'ok') {\n // Queue up the callbacks and fire them after cleaning up all of our\n // transaction state, since the callback could trigger more\n // transactions or sets.\n var callbacks = [];\n var _loop_1 = function (i) {\n queue[i].status = 2 /* COMPLETED */;\n events = events.concat(syncTreeAckUserWrite(repo.serverSyncTree_, queue[i].currentWriteId));\n if (queue[i].onComplete) {\n // We never unset the output snapshot, and given that this\n // transaction is complete, it should be set\n callbacks.push(function () {\n return queue[i].onComplete(null, true, queue[i].currentOutputSnapshotResolved);\n });\n }\n queue[i].unwatcher();\n };\n for (var i = 0; i < queue.length; i++) {\n _loop_1(i);\n }\n // Now remove the completed transactions.\n repoPruneCompletedTransactionsBelowNode(repo, treeSubTree(repo.transactionQueueTree_, path));\n // There may be pending transactions that we can now send.\n repoSendReadyTransactions(repo, repo.transactionQueueTree_);\n eventQueueRaiseEventsForChangedPath(repo.eventQueue_, path, events);\n // Finally, trigger onComplete callbacks.\n for (var i = 0; i < callbacks.length; i++) {\n exceptionGuard(callbacks[i]);\n }\n }\n else {\n // transactions are no longer sent. Update their status appropriately.\n if (status === 'datastale') {\n for (var i = 0; i < queue.length; i++) {\n if (queue[i].status === 3 /* SENT_NEEDS_ABORT */) {\n queue[i].status = 4 /* NEEDS_ABORT */;\n }\n else {\n queue[i].status = 0 /* RUN */;\n }\n }\n }\n else {\n warn('transaction at ' + pathToSend.toString() + ' failed: ' + status);\n for (var i = 0; i < queue.length; i++) {\n queue[i].status = 4 /* NEEDS_ABORT */;\n queue[i].abortReason = status;\n }\n }\n repoRerunTransactions(repo, path);\n }\n }, latestHash);\n}", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "a9470e25c8b40c047de9aaadaa2d82be", "score": "0.5210018", "text": "function processQueue () {\n queue.forEach(function (func) { $mdUtil.nextTick(func); });\n queue = [];\n }", "title": "" }, { "docid": "3d7ae6b8f47c348422907019077e0e7b", "score": "0.52078044", "text": "function handle_sms_queue(which) {\n \n\n var ref = admin.database().ref('queue/sms/' + which);\n\n ref.on('child_added', (childSnapshot) => {\n\n try {\n var childKey = childSnapshot.key;\n var childData = childSnapshot.val();\n if (childData && childData.phone && childData.message) {\n send_sms( childData.phone, childData.message );\n console.debug(' sent ' + childData.message + ' to ' + childData.phone);\n childSnapshot.ref.remove();\n }\n } catch(err) {\n console.debug(' %s', err);\n childSnapshot.ref.set(childKey + '/status', 'failed');\n childSnapshot.ref.set(childKey + '/error', err);\n }\n });\n}", "title": "" }, { "docid": "c54e1d4c6f7a3cc50b4ae73ae9d3ba38", "score": "0.5191706", "text": "function handleNextFile() {\n if (currentFileID >= allFiles.length) {\n locked = false;\n } else {\n if (!allFiles[currentFileID].size || allFiles[currentFileID].size <= 0) {\n locked = false;\n $(\".file.\" + currentFileID + \" .progressbar\").css(\"display\",\"none\");\n $(\".file.\" + currentFileID).css('background-color', '#DAA');\n $(\".file.\" + currentFileID + \" .progress .resulttextbox\").val('Empty or invalid file.');\n currentFileID++;\n return false;\n }\n\n locked = true;\n var blob = allFiles[currentFileID];\n var worker = new Worker(\"/js/upload.webworker.js\");\n var msg = {file: blob, fileID: currentFileID, collectionID: uuid};\n worker.postMessage(msg);\n $(\"#dropzoneLabel\").css('display','none');\n worker.onmessage = function(e) {\n if (e.data.action == 'SUCCESS') {\n if(allFiles.length > 1) $(\".collection\").css(\"display\", \"block\");\n $(\".file.\" + currentFileID + \" .progressbar\").css(\"display\",\"none\");\n uploadFinish(e.data.fileName, currentFileID);\n allFiles[currentFileID] = 1;\n currentFileID++;\n handleNextFile();\n } else if (e.data.action == 'FAIL') {\n locked = false;\n $(\".file.\" + currentFileID + \" .progressbar\").css(\"opacity\",\"0.5\");\n $(\".file.\" + currentFileID + \" .progressbar\").css(\"background-color\",\"#DDD\");\n $(\".file.\" + currentFileID).css('background-color', '#DAA');\n $(\".file.\" + currentFileID + \" .progress .resulttextbox\").val('Upload failed.');\n allFiles[currentFileID] = 1;\n currentFileID++;\n handleNextFile();\n return false;\n } else if (e.data.action == 'PROGRESS') {\n $(\".file.\" + currentFileID + \" .progressbar\").width((100*e.data.sent) + \"%\");\n }\n };\n }\n }", "title": "" }, { "docid": "10d5e8a686d6d9638692015709b5f64b", "score": "0.5178403", "text": "_writeSync () {\n this._batchEntries()\n while (this._written.length) {\n this._publisher.publish(this._written.shift())\n }\n while (this._batches.length) {\n this._publisher.publish(this._batches.shift())\n }\n }", "title": "" }, { "docid": "6f9a42b0f4942cd6230a1c9907c3ad52", "score": "0.51778007", "text": "_checkQueue() {\n /**\n * @event Client#debug\n * @type {String}\n * @description used for debugging of the internals of the library\n * @private\n */\n this.client.emit('debug', `Checking queue Length: ${this.connectQueue.length} LastAttempt: ${this.lastConnectionAttempt} Current Time: ${Date.now()}`);\n if (this.connectQueue.length > 0 && this.lastConnectionAttempt <= Date.now() - 6000) {\n this._connectShard(...this.connectQueue.splice(0, 1));\n }\n }", "title": "" }, { "docid": "0d52a925a8f86238fe3058f93995f80f", "score": "0.5177158", "text": "function onwriteDrain(stream, state) {\r\n if (state.length === 0 && state.needDrain) {\r\n state.needDrain = false;\r\n stream.emit('drain');\r\n }\r\n } // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "10b8437876d3744443cf6e19e42b841e", "score": "0.51613164", "text": "enqueue(item) {\n if(this.queueLine.length < this.queueSize){\n this.queueLine.push(item);\n };\n }", "title": "" }, { "docid": "67584d82b7b04daea82929cb84dfd758", "score": "0.5148164", "text": "_processQueue() {\n // eslint-disable-next-line no-empty\n while (this._tryToStartAnother()) { }\n }", "title": "" }, { "docid": "67584d82b7b04daea82929cb84dfd758", "score": "0.5148164", "text": "_processQueue() {\n // eslint-disable-next-line no-empty\n while (this._tryToStartAnother()) { }\n }", "title": "" }, { "docid": "dba897be1a1b628c469ff3698c0db22a", "score": "0.5147694", "text": "_flush() {\n if (this.flushing ||\n this.queue.length === 0 ||\n this.buffer.updating) {\n return;\n }\n\n const { type, args, subj } = this.queue.pop();\n this.flushing = subj;\n try {\n switch(type) {\n case BUFFER_APPEND:\n this.buffer.appendBuffer(args); break;\n case BUFFER_REMOVE:\n this.buffer.remove(args.start, args.end); break;\n }\n } catch(e) {\n this._onError(e);\n }\n }", "title": "" }, { "docid": "46baea8f0e1df9999288f1ac0d145719", "score": "0.51462907", "text": "function next() {\n if (processed_queue.length > 0) {\n self.postMessage(processed_queue.shift());\n return;\n }\n }", "title": "" }, { "docid": "bc0f2c6bd0fd68b0b1ab1f1952736c4f", "score": "0.5144554", "text": "function flushQueue() {\n for (var msg; msg = this.queue.shift() ;) {\n\t\t\tsendDataToObservers.call(this, msg.data);\n }\n }", "title": "" }, { "docid": "ee988a47c3b27839eaaa7340fd62fee5", "score": "0.51109326", "text": "function queueComplete(numFilesUploaded) {\r\n\t //this.getStats().successful_uploads;\r\n}", "title": "" }, { "docid": "0ca7615b6f3a4252b1b50738954c49b4", "score": "0.5097686", "text": "function processQueue() {\n\tif (!configured) {\n\t\treturn;\n\t}\n\n\tvar toBeSent = outgoing;\n\toutgoing = [];\n\n\tfunction onError() {\n\t\tcheckOnline(true);\n\t\toutgoing = outgoing.concat(toBeSent);\n\t\tif (debugging) {\n\t\t\tconsole.debug(\"Request failed (\" + toBeSent.length + \" packets waiting)\");\n\t\t}\n\t}\n\n\tfunction onLoad() {\n\t\tif (req.status == 200) {\n\t\t\tcheckOnline(false);\n\t\t\thandleEvent(JSON.parse(req.responseText))\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t}\n\n\tvar req = createRequest();\n\treq.onerror = onError;\n\treq.onload = onLoad;\n\treq.send(JSON.stringify(toBeSent));\n}", "title": "" }, { "docid": "ef5a5ed4807c6c2a693233598ff8f725", "score": "0.50903916", "text": "function outputWriter(message) {\n\t\tshould.exist(message);\n\t\tmessage.should.match(/^\\d+ messages$/);\n\t\twriteCount++;\n\t}", "title": "" }, { "docid": "8eae57d5a7f76e26305b7d731dd4d626", "score": "0.5087982", "text": "dequeue() {\n while (!this.deflating && this.queue.length) {\n const [fn, ...params] = this.queue.shift();\n\n this.bufferedBytes = params[0].length;\n fn.apply(this, params);\n }\n }", "title": "" }, { "docid": "92242cec1a2590faa9249d08a5b83563", "score": "0.5087205", "text": "function _rollQueue() {\n if (this.queue.length) {\n var currentWait = _quotaWaitTime(this.quota, this.options.QPS);\n if (currentWait === 0) {\n var requestFunction = this.queue.shift();\n requestFunction();\n this.quota.calls++;\n }\n this.quota.to = setTimeout(this.queueHandler, currentWait);\n }\n\n}", "title": "" }, { "docid": "92242cec1a2590faa9249d08a5b83563", "score": "0.5087205", "text": "function _rollQueue() {\n if (this.queue.length) {\n var currentWait = _quotaWaitTime(this.quota, this.options.QPS);\n if (currentWait === 0) {\n var requestFunction = this.queue.shift();\n requestFunction();\n this.quota.calls++;\n }\n this.quota.to = setTimeout(this.queueHandler, currentWait);\n }\n\n}", "title": "" }, { "docid": "a6f41757d72c554d8cb14abe4bcc9cf6", "score": "0.5087123", "text": "enqueue(data) {\n if (this.hasRoom()) {\n this.queue.addToTail(data);\n this.size++;\n } else {\n throw new Error('The Queue is now full, but should not be since the max size is infinity, breaking physics left and right!');\n }\n }", "title": "" }, { "docid": "46ffde94fe018d226ac2c6ce7fd9b3b7", "score": "0.50858176", "text": "function flush () {\n\t\t flushing = true\n\t\t run(queue)\n\t\t run(userQueue)\n\t\t reset()\n\t\t}", "title": "" }, { "docid": "bba2727e989777ac449bc83433ffd8bc", "score": "0.5082196", "text": "async flush() {\n if (this.err !== null)\n throw this.err;\n if (this.usedBufferBytes === 0)\n return;\n let numBytesWritten = 0;\n try {\n numBytesWritten = await this.writer.write(this.buf.subarray(0, this.usedBufferBytes));\n }\n catch (e) {\n this.err = e;\n throw e;\n }\n this.checkBytesWritten(numBytesWritten);\n this.usedBufferBytes = 0;\n }", "title": "" }, { "docid": "bba2727e989777ac449bc83433ffd8bc", "score": "0.5082196", "text": "async flush() {\n if (this.err !== null)\n throw this.err;\n if (this.usedBufferBytes === 0)\n return;\n let numBytesWritten = 0;\n try {\n numBytesWritten = await this.writer.write(this.buf.subarray(0, this.usedBufferBytes));\n }\n catch (e) {\n this.err = e;\n throw e;\n }\n this.checkBytesWritten(numBytesWritten);\n this.usedBufferBytes = 0;\n }", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" }, { "docid": "0660589de9014b20b4e14ce556b4f261", "score": "0.50689995", "text": "function onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n} // if there's something in the buffer waiting, then process it", "title": "" } ]
4a11b5be1ce29b15b11a0279f2050d92
Render any loading content that you like here
[ { "docid": "d8e5f064a1d228be32b23496ec7c0fbe", "score": "0.0", "text": "render() {\n return (\n <View style={styles.container}>\n <ActivityIndicator />\n <StatusBar barStyle=\"default\" />\n </View>\n );\n }", "title": "" } ]
[ { "docid": "29efc790bd8ca4e5d10a08c787a9eab1", "score": "0.73802", "text": "renderLoader() {\n return '<div class=\"loader\"></div>';\n }", "title": "" }, { "docid": "eca2529e5d78bfaf2e312242d8d7115f", "score": "0.73353636", "text": "function renderLoadingScreen(text) {\n clearWrapper();\n Render.h1(\"div.wrapper\", text);\n\n Render.br(\"div.wrapper\");\n\n Render.div(\"div.wrapper\", \"loading\");\n}", "title": "" }, { "docid": "947ed2d375ac4501d0fdb4e1111cab51", "score": "0.72143143", "text": "renderLoading() {\n document.getElementById(\"result-list\").innerHTML = '<div class=\"loading\">Searching for books . . .</div>';\n }", "title": "" }, { "docid": "5f4c48dcad5cdca918aa4a2f12ea668e", "score": "0.72083676", "text": "renderContentLoading() { return <Loading /> }", "title": "" }, { "docid": "64ecb98c712ff8d517d3c16373f8f953", "score": "0.7101822", "text": "render() {\n return (this.props.ready) ? this.renderPage() :\n <div className={'loaderStyle'}>\n <Loader inverted active size='big'>Getting Cars</Loader>\n </div>;\n\n }", "title": "" }, { "docid": "e8af79c564510f7777d2a81105f6130c", "score": "0.7059217", "text": "renderLoading() {\n return (this.renderTemplate('loading', null) ||\n html `\n <div class=\"event\">\n <div class=\"event-time-container\">\n <div class=\"event-time-loading loading-element\"></div>\n </div>\n <div class=\"event-details-container\">\n <div class=\"event-subject-loading loading-element\"></div>\n <div class=\"event-location-container\">\n <div class=\"event-location-icon-loading loading-element\"></div>\n <div class=\"event-location-loading loading-element\"></div>\n </div>\n <div class=\"event-location-container\">\n <div class=\"event-attendee-loading loading-element\"></div>\n <div class=\"event-attendee-loading loading-element\"></div>\n <div class=\"event-attendee-loading loading-element\"></div>\n </div>\n </div>\n </div>\n `);\n }", "title": "" }, { "docid": "6bddbb48fa51f2fe245af30e4eab0e3d", "score": "0.70568043", "text": "function renderLoading(into) {\n\t\tcontainer.innerHTML = \n\t\t`<div class=\"second-wrapper\">\n\t\t\t<div class=\"circle-loader\">\n\t\t\t\t<div class=\"circle circle_four\"></div>\n\t\t\t\t<div class=\"circle circle_three\"></div>\n\t\t\t\t<div class=\"circle circle_two\"></div>\n\t\t\t\t<div class=\"circle circle_one\"></div>\n\t\t\t</div>\n\t\t</div>`\n\t}", "title": "" }, { "docid": "3447b4c1bb87261dc8c897bdb29a3cd5", "score": "0.7020601", "text": "renderLoading()\n {\n\n return(<Loader>Loading Data</Loader>)\n\n }", "title": "" }, { "docid": "228818c4141a2d175d17d99163a9522d", "score": "0.69934314", "text": "function loading(ctx, next) {\n\tvar el = document.createElement('div');\n\tel.classList.add('loader');\n\tdocument.getElementById('main-container').appendChild(el);\n\tnext();\n}", "title": "" }, { "docid": "f9d0eddf68e547ebbd48be5f25e6853f", "score": "0.6981044", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader>Getting data</Loader>;\n }", "title": "" }, { "docid": "10d5c6207a55250f517b9cdc19d5241c", "score": "0.6968844", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Fetching Data</Loader>;\n }", "title": "" }, { "docid": "495fc050e7825f930f2279fcbc640c22", "score": "0.69594365", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "d1423dfb8f951ba6624841f2b53cd405", "score": "0.69091314", "text": "render() {\n return (this.state.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "d1423dfb8f951ba6624841f2b53cd405", "score": "0.69091314", "text": "render() {\n return (this.state.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "2e480b7d678da6607f8768133933af49", "score": "0.69028497", "text": "function loading(ctx,next){ //Función o middleare del loader (Spinner), en pagejs(libreria) se colocan dos parametros en todo middleware\n let el = document.createElement('div'); //Crear elemento div en memoria\n el.classList.add('loader'); //Agregar la clase loader al elemento div\n document.getElementById('main-container').appendChild(el);// Seleccionamos el contenedor main y le agregamos el elemento del loader (div)\n next(); //Llamar al siguiente middleware (asyncLoad), de lo contrario no funcionara (IMPORTANT)\n }", "title": "" }, { "docid": "3223cf2603f4903fa29ab0fb8b348063", "score": "0.6856449", "text": "render() {\n return <div className=\"default-loader\">Loading</div>\n }", "title": "" }, { "docid": "48f5718880a6bf344d311cfa2bafbb7d", "score": "0.68350995", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader>Getting data</Loader>;\n }", "title": "" }, { "docid": "48f5718880a6bf344d311cfa2bafbb7d", "score": "0.68350995", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader>Getting data</Loader>;\n }", "title": "" }, { "docid": "48f5718880a6bf344d311cfa2bafbb7d", "score": "0.68350995", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader>Getting data</Loader>;\n }", "title": "" }, { "docid": "48f5718880a6bf344d311cfa2bafbb7d", "score": "0.68350995", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader>Getting data</Loader>;\n }", "title": "" }, { "docid": "61d669822ee521195bfa6eb74c043cd2", "score": "0.68232226", "text": "function show_loader()\n {\n loader = get_loader();\n\n if (opts.customLoaderProc !== false) {\n opts.customLoaderProc(loader);\n } else {\n el = $(opts.container).find(opts.item).last();\n el.after(loader);\n loader.fadeIn();\n }\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "bd9d690344373207c32c364076c9640d", "score": "0.68224186", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "34a8dfed00bce393cef2058edfdb540e", "score": "0.6810161", "text": "renderContentConditional() {\n if (this.props.loading) {\n return this.renderContentLoading()\n } else {\n return this.renderContent()\n }\n }", "title": "" }, { "docid": "5822c47eea4715ef37bb5a3c23ebe157", "score": "0.6808715", "text": "executeRender()\n {\n\n if(this.state.isError)\n {\n\n return this.renderError();\n\n }\n else if(this.state.isLoaded)\n {\n\n return this.renderLoaded();\n\n }\n else\n {\n\n return this.renderLoading();\n\n }\n\n }", "title": "" }, { "docid": "5c803f693bf9be1ba0d665ae03566a7b", "score": "0.6805876", "text": "function renderizarLoading() {\r\n\t$('#root').empty();\r\n\tlet loadingText = document.createElement(\"h1\");\r\n\tloadingText.innerText = 'Loading...';\r\n\t$('#root')[0].appendChild(loadingText);\r\n}", "title": "" }, { "docid": "6a7a12fdd86c3059a07c9894edb4f0e1", "score": "0.6801754", "text": "_showLoading() {\n // Must be implemented in superclass.\n }", "title": "" }, { "docid": "649dc98ba0a4378404af509d32bc2782", "score": "0.6768273", "text": "function loading() {\n push();\n textFont(workSansRegular);\n textSize(24);\n textStyle(BOLD);\n textAlign(CENTER, CENTER);\n fill(255, 255, 255);\n text(`Loading ${modelName}...`, width / 2, 805);\n pop();\n}", "title": "" }, { "docid": "eced7bb1181de767a134dd81b3a69fb0", "score": "0.673689", "text": "loaderHtml(){\n switch (this.state.type.toLowerCase()){\n\n case 'first':\n return (\n <div className=\"lds-hourglass\"></div>\n )\n case 'second':\n return (\n <div className=\"lds-roller\">\n <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>\n </div>\n )\n default:\n return (\n <h1>Here is default loader content</h1>\n )\n }\n }", "title": "" }, { "docid": "84cba7ea29529b4fde2f6fe6416f5334", "score": "0.6725172", "text": "function loading() {\n loader.hidden = false;\n quoteContainer.hidden = true;\n}", "title": "" }, { "docid": "78d1719bc6b7feb0e9f5888a8bda2986", "score": "0.6710134", "text": "waitingData() {\n return `\n ${Loading()}\n ${new Header().render()}\n `;\n }", "title": "" }, { "docid": "a2d0be38355e202704bd516cb4c6f55a", "score": "0.668944", "text": "function loading() {\n loader.hidden = false;\n quoteContainer.hidden = true;\n}", "title": "" }, { "docid": "760c34c7567b7c648209d6970af018e0", "score": "0.6684305", "text": "function showLoading() {\n UI.view(\"loading-page\");\n}", "title": "" }, { "docid": "789ecc139a7fe0b121cdf9886d5382d1", "score": "0.66753584", "text": "render() {\n return <FullLoading />;\n }", "title": "" }, { "docid": "b1feef478d687b7b16ea89192cb46f44", "score": "0.66753066", "text": "render() {\n return (this.props.ready && this.props.ready2) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "8d9aab8d8c4b1f70699fa1772e74e9b4", "score": "0.6629604", "text": "function showLoading() {\n const url = window._server + '/res/ureport-asserts/icons/loading.gif';\n const h = $(window).height() / 2,\n w = $(window).width() / 2;\n const cover = $(`<div class=\"ureport-loading-cover\" style=\"position: absolute;left: 0px;top: 0px;width:${w * 2}px;height:${h * 2}px;z-index: 1199;background:rgba(222,222,222,.5)\"></div>`);\n $(document.body).append(cover);\n const loading = $(`<div class=\"ureport-loading\" style=\"text-align: center;position: absolute;z-index: 1120;left: ${w - 35}px;top: ${h - 35}px;\"><img src=\"${url}\">\n <div style=\"margin-top: 5px\">打印数据加载中...</div></div>`);\n $(document.body).append(loading);\n}", "title": "" }, { "docid": "9cb72e8b4d3127eb609dc828d98ffdf0", "score": "0.6615001", "text": "function loading() {\r\n loader.hidden = false;\r\n quoteContainer.hidden = true;\r\n}", "title": "" }, { "docid": "cfee340a845ade13857df4c2ccc08216", "score": "0.6559209", "text": "function showLoadingView() {\n\n}", "title": "" }, { "docid": "cfee340a845ade13857df4c2ccc08216", "score": "0.6559209", "text": "function showLoadingView() {\n\n}", "title": "" }, { "docid": "a9025a5a979e75f248f0e44c7271bd81", "score": "0.65573555", "text": "render() {\n if (this.state.loading) {\n return [\n <Placeholder\n key=\"placeholder\"\n label={__('Loading Every Action')}>\n <Spinner />\n </Placeholder>\n\n ];\n } else {\n // Render as html.\n // https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml\n return <div id={this.state.scriptAdded} dangerouslySetInnerHTML={{ __html: this.state.actionTagContent }} />;\n }\n }", "title": "" }, { "docid": "0a3db3c92bf131447450bc2871043726", "score": "0.6556718", "text": "function runLoader(text) {\n jQuery('#whiteBackgroundHolder').html('<div class=\"loaderContent\">' + text + '&nbsp;&nbsp;<img src=\"'+config_url + 'img/ajax-loader.gif\" border=\"0\" width=\"16\"></div>');\n}", "title": "" }, { "docid": "1b6979167aee63f2b054608ef286a099", "score": "0.652696", "text": "showLoading(){\n\t\tthis.recipeBox.innerHTML = `<div class=\"lds-css ng-scope\">\n\t\t<div class=\"lds-spinner\" style=\"100%;height:100%\"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>`;\n\t}", "title": "" }, { "docid": "1113c06c29b0a60cfa0c90afb32fcf99", "score": "0.65266615", "text": "render() {\n return (this.props.ready && this.props.patientsReady) ? this.renderPage() : <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "2d8cdfef903b03042c1821867e1f27d1", "score": "0.65234387", "text": "function loading(){\n loader.hidden=false;\n quoteContainer.hidden=true;\n}", "title": "" }, { "docid": "c6bfe467addf436dcfcf90fa186caf85", "score": "0.65231955", "text": "render() {\n return html `\n <div class=\"private-host\">\n ${this.loadingState === ClrLoadingState.LOADING ? iconSpinner : ''}\n ${this.loadingState === ClrLoadingState.SUCCESS ? iconSpinnerCheck : ''}\n ${this.loadingState === ClrLoadingState.DEFAULT ? html `<span><span><slot></slot></span></span>` : ''}\n ${this.hiddenButtonTemplate}\n </div>\n `;\n }", "title": "" }, { "docid": "30a3411a5d0d7aa0ec7845db238d30cd", "score": "0.64983416", "text": "function Loading (){\n return(<div className=\"loader\"></div>);\n }", "title": "" }, { "docid": "b35f3f6585c9131ccedff00462395005", "score": "0.6486682", "text": "function initLoading()\r\n {\r\n if(data.loading === null) return;\r\n\r\n sm_loading = new sm.loading(data.loading);\r\n $item.prepend(sm_loading.get());\r\n }", "title": "" }, { "docid": "3a4a30283c3160d56668b0ac7b02533a", "score": "0.6476239", "text": "function showLoading (selector) {\n let html = \"<div class='text-center'>\";\n html += \"<img src='images/ajax-loader.gif'></div>\";\n insertHtml(selector, html);\n }", "title": "" }, { "docid": "b0f2bee4c1097c121441f328d7c6c8e3", "score": "0.6445386", "text": "function loadingBlockTemplate(){\n\tvar html = '<div class=\"block_is_loading\"></div>';\n\treturn html;\n}", "title": "" }, { "docid": "d65deea026053642a667e3d7080eab48", "score": "0.64440674", "text": "onShowLoading() {\n $(\"#loading, .loading-display\").show();\n }", "title": "" }, { "docid": "ee719e4f609f322de34bb75f026bbb77", "score": "0.64395195", "text": "function showLoader() { $loader.show(100); disableInputs(); }", "title": "" }, { "docid": "e7c855013a88e0c209913d8b1cf52765", "score": "0.64363176", "text": "function LoadingContainer() {\n return (\n <Loading>\n <Loading.Wrapper>\n <Loading.Text>Loading</Loading.Text>\n <div className=\"lds-ring\"><div></div><div></div><div></div><div></div></div>\n </Loading.Wrapper>\n </Loading>\n )\n}", "title": "" }, { "docid": "1af0a9f5e1cb2102590dfe3df66a3e45", "score": "0.6436101", "text": "function showLoadingScreen() {\n $('#result_gallery').remove();\n $('#eexcess_thumb').hide();\n settings.hostTag.find('.pagination').remove();\n $widgets.error.hide();\n $widgets.list.empty();\n $('.empty_result').hide();\n $widgets.loader.show();\n }", "title": "" }, { "docid": "3fcff385dc2c76425119b7d1b84c3f5e", "score": "0.6433344", "text": "function insertLoader () {\n\treturn '<div class=\"vertical-align loader\"><div class=\"showbox\"><div class=\"loader\"><svg class=\"circular\" viewBox=\"25 25 50 50\"><circle class=\"path\" cx=\"50\" cy=\"50\" r=\"20\" fill=\"none\" stroke-width=\"2\" stroke-miterlimit=\"10\"/></svg></div></div></div>';\n}", "title": "" }, { "docid": "7c4ba270f2f6cfdddb3d0bbfaacf5bcf", "score": "0.6418962", "text": "render() {\n return (\n <div className=\"jumbotron\">\n <div className=\"container\">\n {\n this.data.isLoading ? this.showSpinner() : this.showGoals()\n }\n </div>\n </div>\n )\n }", "title": "" }, { "docid": "a4dfcdc301235a462013aaf902b26b69", "score": "0.64111185", "text": "render() {\n let dataLoaded = this.state.display != null;\n return(\n dataLoaded ?\n <div >\n {this.state.display}\n </div>\n :\n <div>Loading...</div>\n );\n }", "title": "" }, { "docid": "109264a9a2db689a2ff5ffc0c463c160", "score": "0.6405465", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Creating Your Profile</Loader>;\n }", "title": "" }, { "docid": "109264a9a2db689a2ff5ffc0c463c160", "score": "0.6405465", "text": "render() {\n return (this.props.ready) ? this.renderPage() : <Loader active>Creating Your Profile</Loader>;\n }", "title": "" }, { "docid": "64b16709bb097f13cc88c5089786b024", "score": "0.6398542", "text": "if(this.state.loaded == 'false'){\n\t\t\treturn(\n\t\t\t\t<View style={styles.container}>\n\t\t\t\t\t<Text>Loading...</Text>\n\t\t\t\t</View>\n\t\t\t);\n\t\t}", "title": "" }, { "docid": "ebfa26859cb427a1c6cfbac4f4c8b510", "score": "0.6385719", "text": "function loading_start() {\r\n\t\t$('iframe[name=\"page\"]').css('display', 'none');\r\n\t\t$('.loader-container').css('display', 'block');\r\n\t}", "title": "" }, { "docid": "e55065039611f7743d1799f31ad0f4f5", "score": "0.6368238", "text": "renderContent(){}", "title": "" }, { "docid": "412aac5b44e8035f43b956033ef4e0c1", "score": "0.6354252", "text": "function startLoading(){\n if(isLoading) return;\n let searchResults = document.getElementById(\"searchResults\");\n let div = document.createElement(\"DIV\");\n let img = document.createElement(\"IMG\");\n div.id = \"loadContent\";\n img.className = \"load-image\";\n img.src = \"./assets/images/loading.gif\";\n div.appendChild(img);\n document.body.appendChild(div);\n searchResults.style.display = \"none\";\n isLoading = !isLoading;\n}", "title": "" }, { "docid": "0420c7db27d0adfa8df34692a7d2bd0c", "score": "0.6353597", "text": "function showLoadingView() {\n $(\"#loading\").show();\n}", "title": "" }, { "docid": "2f23ca6b363c8cd941145118154dd9d2", "score": "0.6341206", "text": "function showLoader(message) {\n if (message === undefined) {\n message = 'Loading ...';\n }\n $('.camping-loader').html('<div class=\"response-layer\"><div class=\"wrapper\"><figure itemscope=\"\" itemtype=\"http://schema.org/ImageObject\"><img src=\"assets/images/wallet-loading.png\" class=\"max-width-160 width-100\" alt=\"Loader\"></figure><div class=\"message lato-bold fs-24\">' + message + '</div></div></div>');\n $('.response-layer').show();\n}", "title": "" }, { "docid": "65f5449b27880fc197fa435c7c07cdcd", "score": "0.63400155", "text": "function showLoader() {\r\n\t\r\n\t\r\n}", "title": "" }, { "docid": "5425793419f75557591e5e4f1270e662", "score": "0.63380367", "text": "render() {\n if(this.props.ready) {\n if(!!this.props.item)\n return this.renderPage();\n else\n return <>ERROR: ITEM NOT FOUND</> //TODO: make page for error message\n }\n else\n return <Loader active>Getting data</Loader>;\n }", "title": "" }, { "docid": "c19a41651b16f79ee925f7c601bf23d8", "score": "0.6337342", "text": "function showLoading (selector) {\n var html = '<div class=\"text-center\">';\n html += '<img id=\"ajax-loader\" src=\"assets/images/ajax-loader.gif\"></div>';\n insertHtml(selector, html);\n }", "title": "" }, { "docid": "b5b4f6264a1493f586f26389cddd7f6b", "score": "0.63358647", "text": "render() {\n return (\n <Loading />\n );\n }", "title": "" }, { "docid": "469ee8462740fa08da0824e5002383df", "score": "0.63352406", "text": "render() {\n return (\n <IndexPageView loading={ this.state.httpReqInProgress } />\n );\n }", "title": "" }, { "docid": "9f50f3e9d411898f779d0a85cf7f6807", "score": "0.6334625", "text": "render() {\n if (this.state.isLoading) {\n return this.renderLoadingView();\n }\n \n return this.renderListView();\n }", "title": "" }, { "docid": "9b8ed707f5182369d8f757ae7b068392", "score": "0.63321257", "text": "function renderLoad() {\n var allPlaces = orderUtils.getItem(\"allPlaces\", []),\n loadButton = document.querySelector(\".js-load\"),\n placesList = document.querySelector(\".js-placesList\"),\n closeFucntion = createModals.prototype.closeModal;\n // render places if they are saved in local storage\n if (allPlaces.length) {\n placesList.innerHTML = \"\";\n loadButton.removeAttribute(\"disabled\");\n [].forEach.call(allPlaces, function(item) {\n placesList.innerHTML += '<p class=\"js-closeModal js-loadPlace\" data-id=\"orderReset\">' + item + \"</p>\";\n });\n } else {\n // disable load places button if there aren't places in local storage\n loadButton.setAttribute(\"disabled\", true);\n }\n // get app language\n getLanguage();\n // add event listeners to close modal buttons\n orderUtils.eventHandler(\".js-closeModal\", \"click\", closeFucntion);\n }", "title": "" }, { "docid": "f80f9c2d464c288a67f853dd20c0a36b", "score": "0.63305426", "text": "function LoadingWidget() {\n return (\n <Widget>\n <Widget.Header>\n <Loading.Line />\n </Widget.Header>\n <Widget.Content>\n <Loading.Img />\n <Loading.Parag />\n <form>\n <Loading.Alter>\n <Loading.Line />\n </Loading.Alter>\n <Loading.Alter>\n <Loading.Line />\n </Loading.Alter>\n <Loading.Alter>\n <Loading.Line />\n </Loading.Alter>\n <Loading.Alter>\n <Loading.Line />\n </Loading.Alter>\n <Loading.Button>\n <Loading.Line />\n </Loading.Button>\n </form>\n </Widget.Content>\n </Widget>\n )\n}", "title": "" }, { "docid": "ec77b0bc7d33e6c9643dcf5e3b0a5b21", "score": "0.6318267", "text": "render() {\n if (this.state.loading) {\n return (\n <div className=\"Page-Play\">\n <LoadingBar />\n </div>\n )\n }\n\n if (!this.state.complete) {\n return this.renderGame()\n } else {\n return this.renderScore()\n }\n }", "title": "" }, { "docid": "669586f63544d0ea035beb67921d7b0b", "score": "0.6301429", "text": "displayLoadingUI() {\n if (!DomManagement.IsWindowObjectExist()) {\n return;\n }\n const loadingScreen = this.loadingScreen;\n if (loadingScreen) {\n loadingScreen.displayLoadingUI();\n }\n }", "title": "" }, { "docid": "4b58b216f1dc36c332da379e47941419", "score": "0.6298767", "text": "function loadingFormat() {\n $(\"#svg-plot\").css(\"opacity\",0.1)\n $(\"#loading-page\").css(\"display\",\"block\")\n}", "title": "" }, { "docid": "ff4be481dca13750b3342c2e36d66845", "score": "0.62987393", "text": "function showLoader() {\n $(\"#content\").hide();\n $(\"#spinner\").show();\n}", "title": "" }, { "docid": "faf3c0d4b9691d0ae70ac75116d26bdd", "score": "0.6298441", "text": "function viewNext(){\n $('body').html('<img src=\"images/loading.gif\" />').load(\"index.html\");\n}", "title": "" }, { "docid": "4250079e675a55f17fcc0d98910b4281", "score": "0.6291995", "text": "function showLoader()\r\n{\r\n $( \"div#loaderDiv\" ).show();\r\n $( \"div#contentDiv\" ).hide();\r\n}", "title": "" } ]
fe9a26590e742a23a10cf5dd30204f8e
move Updates the position according to velocity Lowers energy power Handles wrapping
[ { "docid": "3264d1f1ecf2d28f47e5e63c0917d956", "score": "0.73407924", "text": "move() {\n // Update position\n this.x += this.vx;\n this.y += this.vy;\n // Update health\n this.health = this.health - this.healthLossPerMove;\n this.health = constrain(this.health, 0, this.maxHealth);\n // Handle wrapping\n this.handleWrapping();\n // }\n }", "title": "" } ]
[ { "docid": "821f76e9f82f841fb4b0f038e3204d75", "score": "0.7826235", "text": "move() {\n // Set velocity via noise()\n this.vx = map(noise(this.tx), 0, 1, -this.speed, this.speed);\n this.vy = map(noise(this.ty), 0, 1, -this.speed, this.speed);\n // Update health\n this.health = constrain(this.health, 0, this.maxHealth);\n // Update position\n this.x += this.vx;\n this.y += this.vy;\n // Update time properties\n this.tx += 0.01;\n this.ty += 0.01;\n // Handle wrapping\n this.handleWrapping();\n }", "title": "" }, { "docid": "65a4d4828d5eab64a5c8b26175640751", "score": "0.7779609", "text": "move() {\n this.lastLocation = this.location.copy()\n this.addForce(gravity)\n this.calculate()\n this.location.add(this.velocity)\n this.enviromentDetection();\n }", "title": "" }, { "docid": "a63dd153678fa8d77942d98859672681", "score": "0.7693329", "text": "move() {\n\t\tthis.x += this.vx;\n\t\tthis.y += this.vy;\n\n\t\tthis.vx *= .95;\n\t\tthis.vy *= .95;\n\n\t\t// Turn off speed\n\t\tif (this.powerUpBank[POWER_UP.SPEED] != null \n\t\t\t&& this.speed > 10 \n\t\t\t&& (gameClock - this.powerUpBank[POWER_UP.SPEED].start) > 200) {\n\n\t\t\tthis.speed = 6;\n\t\t\tthis.powerUpBank[POWER_UP.SPEED] = null;\n\t\t\tthis.glowBackground.speed.setVisible(false);\n\t\t}\n\n\t\tif (this.invincible\n\t\t\t&& (gameClock - this.powerUpBank[POWER_UP.INVINCIBLE].start > 200)) {\n\t\t\tthis.invincible = false;\n\t\t\tthis.glowBackground.invincible.setVisible(false);\n\t\t}\n\n\t\t// water\n\t\t// if (this.vx > 0)\n\t\t// \tthis.vx -= .1;\n\t\t// else\n\t\t// \tthis.vx += .1;\n\t\t// if (this.vy > 0)\n\t\t// \tthis.vy -= .1;\t\n\t\t// else\n\t\t// \tthis.vy += .1;\t\n\t}", "title": "" }, { "docid": "54abe7087970a25b0a55471c3fd0d67b", "score": "0.76019675", "text": "move() {\n\n this.vPos.translate(this.vVel);\n if (outOfBounds(this.vPos)) {\n this.loop();\n }\n }", "title": "" }, { "docid": "7e5f9bbfeba6a0b111c9bc4c2c60301c", "score": "0.7598341", "text": "move() {\n\n this.position.add(this.velocity);\n }", "title": "" }, { "docid": "baec117c5cfe9e3f3a3fc877edb92d0a", "score": "0.7581729", "text": "move() {\n // Update position\n this.x += this.vx;\n this.y += this.vy;\n // Update health\n this.health = this.health - this.healthLossPerMove;\n this.health = constrain(this.health, 0, this.maxHealth);\n //Update battery\n this.batteryLevel = this.batteryLevel - this.batteryLossPerMove;\n this.batteryLevel = constrain(this.batteryLevel, 0, this.maxBatteryLevel);\n // Handle wrapping\n this.handleWrapping();\n }", "title": "" }, { "docid": "73e4db1b85bd218b052d94efb63ed923", "score": "0.75564617", "text": "move() {\n this.y += this.yVelocity;\n this.x += this.xVelocity;\n }", "title": "" }, { "docid": "7617688c33305f05687700680cb0e764", "score": "0.7396359", "text": "move()\n {\n //check reflection before update\n if(this.x.x + this.v.x > X-this.radius*2 || this.x.x < 0)\n {\n this.v.x *= -1;\n }\n if(this.x.y + this.v.y > Y-this.radius*2 || this.x.y < 0)\n {\n this.v.y *= -1;\n }\n //update with velocity\n this.x.x += this.v.x;\n this.node.style.left = this.x.x + \"px\";\n this.x.y += this.v.y;\n this.node.style.top = this.x.y + \"px\";\n }", "title": "" }, { "docid": "ae2689fc9b051fbaba11fcf008869897", "score": "0.73491395", "text": "move() {\n // Update position\n this.x += this.vx;\n this.y += this.vy;\n // Update health\n this.health = this.health - this.healthLossPerMove;\n this.health = constrain(this.health, 0, this.maxHealth);\n // Handle wrapping\n this.handleWrapping();\n }", "title": "" }, { "docid": "ae2689fc9b051fbaba11fcf008869897", "score": "0.73491395", "text": "move() {\n // Update position\n this.x += this.vx;\n this.y += this.vy;\n // Update health\n this.health = this.health - this.healthLossPerMove;\n this.health = constrain(this.health, 0, this.maxHealth);\n // Handle wrapping\n this.handleWrapping();\n }", "title": "" }, { "docid": "94c92af0699553bf1d972a6a0fe49fae", "score": "0.73077995", "text": "move() {\n this.speed *= GROUNDSPEED_DECAY_MULT;\n if (this.keyHeld_Gas) {\n this.speed += DRIVE_POWER;\n }\n if (this.keyHeld_Reverse) {\n this.speed -= REVERSE_POWER;\n }\n if (Math.abs(this.speed) > MIN_SPEED_TO_TURN) {\n if (this.keyHeld_TurnLeft) {\n this.ang -= TURN_RATE;\n }\n if (this.keyHeld_TurnRight) {\n this.ang += TURN_RATE;\n }\n }\n\n this.x += Math.cos(this.ang) * this.speed;\n this.y += Math.sin(this.ang) * this.speed;\n\n this.track.carTrackHandling(this);\n }", "title": "" }, { "docid": "22dfee4fefdf1007cc650e70c05018e7", "score": "0.72588325", "text": "move() {\n this.wall_bounce()\n\n this.position = this.position.map(\n (pos, idx) => pos + this.speed[idx]);\n }", "title": "" }, { "docid": "bf2bfbf53a8ad36ba5cec93cab012ece", "score": "0.72181946", "text": "move() {\n // Update position\n this.x += this.vx;\n this.y += this.vy;\n //increase shield health slowly, constraining it within max and min\n this.health += .01;\n this.health = constrain(this.health, 0, this.maxHealth);\n // Handle wrapping\n this.handleWrapping();\n }", "title": "" }, { "docid": "407341ac51c2427697d790eb856db759", "score": "0.7098878", "text": "move() {\n this.x -= this.speed;\n }", "title": "" }, { "docid": "b35d3cf00c5cd02340738c2bb74a214e", "score": "0.7062695", "text": "move(dt) {\n this.acceleration.x = 0;\n this.acceleration.y = 0;\n if (this.startFlapping == true) {\n this.propelFoward();\n this.startFlapping = false;\n }\n this.acceleration.y += this.applyGravity();\n this.setVelocity(dt);\n let newX = this.currentPosition.x += this.currentVelocity.x * dt;\n let newY = this.currentPosition.y += this.currentVelocity.y * dt;\n this.setPosition(newX, newY);\n }", "title": "" }, { "docid": "245ab250ae4b0c5446cbcc8a3e76aae4", "score": "0.7061942", "text": "move(ev) {\n\n const MOVE_DELTA = 0.01;\n const ANGLE_DELTA = 0.005;\n const GRAVITY_DELTA = 0.025;\n const VECTOR_DIV = 10;\n const JUMP_SPEED = 0.75;\n const EPS = 0.0001;\n const BRAKE_SPEED = MOVE_DELTA;\n const BACKWARD_ACC = 1.0;\n\n // Compute acceleration\n let s = Math.hypot(this.speed.x, this.speed.z);\n if (this.canJump) {\n\n this.acc = MOVE_DELTA * 1.0 / Math.sqrt(Math.exp(s));\n if (this.moveDir == -1) {\n\n this.acc = BRAKE_SPEED * 2;\n\n // Stop braking and start moving backwards\n if((Math.abs(this.target.x) < EPS || \n this.speed.x/this.target.x >= 0) &&\n (Math.abs(this.target.y) < EPS || \n this.speed.z/this.target.z >= 0)) {\n\n this.acc = BACKWARD_ACC;\n }\n }\n }\n\n // Update jumping\n if (this.jumpTimer > 0.0) {\n\n this.jumpTimer -= ev.step;\n this.speed = this.jumpDir.clone();\n this.speed.scalarMul(JUMP_SPEED);\n }\n\n // Update speed axes\n this.speed.x = updateSpeedAxis(\n this.speed.x, this.target.x, \n this.acc * ev.step);\n this.speed.z = updateSpeedAxis(\n this.speed.z, this.target.z, \n this.acc * ev.step);\n this.speed.y = updateSpeedAxis(\n this.speed.y, this.target.y, \n GRAVITY_DELTA * ev.step);\n\n // Update rotation speed\n this.angleSpeed = updateSpeedAxis(\n this.angleSpeed, \n this.angleTarget, \n ANGLE_DELTA * ev.step);\n\n // Update position\n this.pos.x += this.speed.x * ev.step;\n this.pos.z += this.speed.z * ev.step;\n this.pos.y += this.speed.y * ev.step;\n\n // Update angle\n this.angle += this.angleSpeed * ev.step;\n this.angle = negMod(this.angle, Math.PI*2);\n\n // Update pose vectors\n updateVectorMovement(this.poseFront, this.front, VECTOR_DIV, ev.step);\n updateVectorMovement(this.poseLeft, this.left, VECTOR_DIV, ev.step);\n updateVectorMovement(this.poseUp, this.up, VECTOR_DIV, ev.step);\n\n // Update front & left vectors\n this.frontDir.x = Math.cos(this.angle);\n this.frontDir.z = -Math.sin(this.angle);\n\n // Compute default directions\n this.leftDir.x = -this.frontDir.z;\n this.leftDir.z = this.frontDir.x;\n\n this.left = this.leftDir.clone();\n this.front = this.frontDir.clone();\n this.up = new Vector3(0, 1, 0);\n\n this.shadowPos.x = this.pos.x;\n this.shadowPos.y = this.pos.y;\n }", "title": "" }, { "docid": "37a992ff769ca5bf0264e0bf48548505", "score": "0.7042965", "text": "move() {\n this.x += this.vx;\n this.y += this.vy;\n\n this.handleWrapping(); // Calls the handleWrapping method, note the use of \"this\"\n }", "title": "" }, { "docid": "698bf63efc816ca94fd6f1daf84760b5", "score": "0.703626", "text": "step() {\n this.position.add(this.velocity);\n }", "title": "" }, { "docid": "f8c6feec57baac92b84aa26677aca446", "score": "0.7033666", "text": "move() {\n this.change = this.mouthGap == 0 ? -this.change : this.change;\n this.mouthGap = (this.mouthGap + this.change) % (Math.PI / 4) + Math.PI / 64;\n this.x += this.horizontalVelocity;\n this.y += this.verticalVelocity;\n }", "title": "" }, { "docid": "daef9abe43f32de15fbfa4a136afc932", "score": "0.70059973", "text": "move() {\n this.posX += this.deltaX;\n this.posY += this.deltaY;\n }", "title": "" }, { "docid": "e223f09d7ab9d4a8d4422e7c38b1aaa6", "score": "0.69857156", "text": "move() {\n this.updatePosition().updateDirections();\n }", "title": "" }, { "docid": "d3b6e346477e699c1128818d6bc33ac3", "score": "0.69402254", "text": "function moveEars(){\n step = step + direction;\n if (step > num_steps) {\n direction = -1;\n step = num_steps-1;\n }\n if (step < 0) {\n direction = 1;\n step = 1;\n }\n position = calculateServoPos(step);\n scaled_pos = scaleServoPos(position);\n setServo(PIN_PWM_l,scaled_pos);\n setServo(PIN_PWM_r,1-scaled_pos);\n}", "title": "" }, { "docid": "5e407f56a1b8ddd3cfb4bc8781e26cc1", "score": "0.69305515", "text": "move() {\n this.dy += this.gravity;\n this.x += this.dx;\n this.y += this.dy;\n this.a -= 1.5;\n }", "title": "" }, { "docid": "154321b2b3d5674ed0f55d717aafc50e", "score": "0.6883529", "text": "move(velocity = {x: 0, y: 0}, dt) {\n this.pos.x += velocity.x * dt;\n this.pos.y += velocity.y * dt;\n }", "title": "" }, { "docid": "f0b7c09f274019636d5ff7cf65bad805", "score": "0.68743604", "text": "move() {\n if(this.pos.x > width || this.pos.x < 0){\n this.vel.x = -this.vel.x;\n }\n \n if(this.pos.y > height || this.pos. y < 0){\n this.vel.y = -this.vel.y\n }\n \n this.pos.add(this.vel);\n }", "title": "" }, { "docid": "540ad5ec69946a3bea6f6e71eba4d5f2", "score": "0.6831858", "text": "move() {\n this.pos.y += this.vy;\n this.vy += this.gravity;\n this.pos.y = constrain(this.pos.y, 0, height - this.r);\n }", "title": "" }, { "docid": "0631c7b513dd7e4873fa25bd2d510138", "score": "0.6811029", "text": "function move(){\n\t//TODO update looksto\n\tif(dist() == 0){\n \t\tspeedx = speedx + Math.min(Math.max(-35, launchx /5), 35);\n \t\tspeedy = speedy + Math.max(-35, (Math.min(launchy, 0)));\n\t}\n\ttouch_pressed = false;\n}", "title": "" }, { "docid": "ca85023e8b6b7770ee84407eff115670", "score": "0.6790323", "text": "move() {\n this.y += this.vy;\n }", "title": "" }, { "docid": "11a7a1d0b9335e0b2f54d85e8624890c", "score": "0.6786099", "text": "move(){\r\n\t\t//gli elettroni si muovono di moto rettilineo\r\n\t\tthis.r = this.r + this.rSpeed;\r\n\t\t//composto ad un moto circolare uniforme\r\n\t\tthis.a = this.a + this.tSpeed;\r\n this.x = cx+this.r*cos(+this.a); \r\n\t\tthis.y = cy+this.r*sin(-this.a);\r\n\t}", "title": "" }, { "docid": "d858271ef5d5b05927f20640df04c1c0", "score": "0.6771796", "text": "Move() {\n this.Speed *= GROUNDSPEED_DECAY_MULT;\n if(this.keyHeld_Gas){\n this.Speed += DRIVER_POWER;\n\n }\n if(this.keyHeld_Reverse){\n this.Speed -= REVERSE_POWER;\n }\n if(this.keyHeld_TurnLeft){\n if(Math.abs(this.Speed) > MIN_SPEED_TO_TURN){\n this.Ang -= TURN_RATE;\n }\n }\n if(this.keyHeld_TurnRight){\n if(Math.abs(this.Speed) > MIN_SPEED_TO_TURN){\n this.Ang += TURN_RATE;\n }\n }\n\n this.X += Math.cos(this.Ang) * this.Speed;\n this.Y += Math.sin(this.Ang) * this.Speed;\n\n carTrackHandling(this);\n }", "title": "" }, { "docid": "de0b89a388a5d1ae062d93db2e9edf6e", "score": "0.6768256", "text": "move() {\n this.x += this.vx;\n this.y += this.vy;\n }", "title": "" }, { "docid": "de0b89a388a5d1ae062d93db2e9edf6e", "score": "0.6768256", "text": "move() {\n this.x += this.vx;\n this.y += this.vy;\n }", "title": "" }, { "docid": "b96c3e6b2ef72fd29c17f1f19eaa2e59", "score": "0.6761325", "text": "move(){\r\n\t\tthis.weapon.attack();\r\n\t\tthis.collision();\r\n\t\tthis.erase();\r\n\t\tswitch(this.act.dir){\r\n\t\t\tcase \"L\": this.moveLeft(); break;\r\n\t\t\tcase \"R\": this.moveRight(); break;\r\n\t\t}\r\n\t\tif(this.act.jump == \"jumping\"){this.moveUp()};\r\n\t\tif(this.act.jump == \"falling\"){this.moveDown()};\r\n\t\tthis.draw();\r\n\t}", "title": "" }, { "docid": "3264c18a2118a54bb6c76abd311a20e6", "score": "0.6753254", "text": "move(){\n\t\tvar step = createVector(Noise.simplex2(this.offset, 0) * this.speed, Noise.simplex2(0, this.offset) * this.speed);\n\t\tthis.x += step.x;\n\t\tthis.y += step.y;\n\t\tthis.offset += this.increment;\n\n\t\t//calculate angle based on direction\n\t\tthis.theta = step.heading() + 90;\n\n\t\tif (this.x > width){\n\t\t\tthis.x = 0;\n\t\t} else if (this.x < 0){\n\t\t\tthis.x = width;\n\t\t}\n\n\t\tif (this.y > height){\n\t\t\tthis.y = 0;\n\t\t} else if (this.y < 0){\n\t\t\tthis.y = height;\n\t\t}\n\t}", "title": "" }, { "docid": "3264c18a2118a54bb6c76abd311a20e6", "score": "0.6753254", "text": "move(){\n\t\tvar step = createVector(Noise.simplex2(this.offset, 0) * this.speed, Noise.simplex2(0, this.offset) * this.speed);\n\t\tthis.x += step.x;\n\t\tthis.y += step.y;\n\t\tthis.offset += this.increment;\n\n\t\t//calculate angle based on direction\n\t\tthis.theta = step.heading() + 90;\n\n\t\tif (this.x > width){\n\t\t\tthis.x = 0;\n\t\t} else if (this.x < 0){\n\t\t\tthis.x = width;\n\t\t}\n\n\t\tif (this.y > height){\n\t\t\tthis.y = 0;\n\t\t} else if (this.y < 0){\n\t\t\tthis.y = height;\n\t\t}\n\t}", "title": "" }, { "docid": "3778cf0d25dc84bddeef7bb9c9ec90c8", "score": "0.67204005", "text": "move() {\n //this.xVel += xVel;\n this.x = this.x + this.xVel;\n this.y = this.y + this.yVel;\n this.checkWalls();\n this.checkBalls();\n }", "title": "" }, { "docid": "2b6574dbcca068735d424a5dc1cdf1fb", "score": "0.6719333", "text": "move() {\n let prevX, prevY;\n if (this.x != null && this.y != null) {\n prevX = this.x;\n prevY = this.y;\n\n //position and destination are different, move\n if (this.x !== this.destinationX || this.y !== this.destinationY) {\n //a series of vector operations to move toward a point at a linear speed\n\n // create vectors for position and dest.\n let destination = createVector(this.destinationX, this.destinationY);\n let position = createVector(this.x, this.y);\n\n // Calculate the distance between your destination and position\n let distance = destination.dist(position);\n\n // this is where you actually calculate the direction\n // of your target towards your rect. subtraction dx-px, dy-py.\n let delta = destination.sub(position);\n\n // then you're going to normalize that value\n // (normalize sets the length of the vector to 1)\n delta.normalize();\n\n // then you can multiply that vector by the desired speed\n let increment = delta.mult((this.speed * deltaTime) / 1000);\n\n /*\n IMPORTANT\n deltaTime The system variable deltaTime contains the time difference between \n the beginning of the previous frame and the beginning of the current frame in milliseconds.\n the speed is not based on the client framerate which can be variable but on the actual time that passes\n between frames. \n */\n\n position.add(increment);\n //update x and y value\n this.x = round(position.x);\n this.y = round(position.y);\n }\n }\n }", "title": "" }, { "docid": "b5d36531c5789adacd9562516ff9aad0", "score": "0.66945386", "text": "move() {\n this.vx = random(-1, 1);\n this.vy = random(-1, 1);\n this.x += this.vx;\n this.y += this.vy;\n this.enlarge();\n this.handleWrapping();\n }", "title": "" }, { "docid": "5719bfe37342fd6685566c7459488a2d", "score": "0.6694023", "text": "function move() {\n\n\t\t\t\tif (static) {\t\t\t\t\t\n\t\t\t\t\tif (on) {\n\t\t\t\t\t\t\tcontrols.autoRotate = true;\n\t\t\t\t\t\t\tcontrols.autoRotateSpeed = 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontrols.autoRotate = false;\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tcontrols.autoRotate = false;\n\n\t\t\t\t\tif (on) {\n\t\t\t\t\t\tvar s = speed;\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar s = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar vector = direction.clone().multiplyScalar(s,s,s);\n\t\t\t\t\tground.position.x += vector.x;\n\t\t\t\t\tif(ground.position.x > 100) {\n\t\t\t\t\t\tresetGround();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}", "title": "" }, { "docid": "67994cbde46b0b6b69194c319a56e673", "score": "0.66928303", "text": "move() {\n this.x += (this.dir * this.speed);\n if (this.x < 0 || this.x > width) {\n this.dir = -this.dir;\n this.x += (this.dir * this.speed);\n }\n this.y = this.baseY + sin(radians(frameCount * 2)) * 40;\n\n this.w = 50 * this.dir;\n }", "title": "" }, { "docid": "5aa8479b9e43a030cead5c1b6a4efd16", "score": "0.6676362", "text": "move() {\n this.x += this.xVel;\n this.xVel += this.xvelrand;\n\n if (this.x > width - this.r || this.x < 0) {\n this.xVel = -this.xVel;\n }\n\n this.y += this.yVel;\n this.yVel += this.yvelrand;\n\n if (this.y > height - this.r || this.y < 0) {\n this.yVel = -this.yVel;\n }\n }", "title": "" }, { "docid": "641b1a9b25fc17dc3072d9ff41181441", "score": "0.667328", "text": "move() {\n // Derive mouse vertical direction.\n let touchYPosition = touches.length > 0 ? touches[touches.length - 1].y : this.position.y;\n let touchYDirection = touchYPosition - this.position.y;\n\n if (Math.abs(touchYDirection) <= this.height / 6) {\n this.setVelocity(createVector(0, 0));\n } else {\n this.setVelocity(createVector(0, touchYDirection < 0 ? -1 : 1));\n }\n\n // Update computer paddle position and redraw at new position.\n this._update();\n this.draw();\n }", "title": "" }, { "docid": "04de4482750d5e0c7103a69b5285784d", "score": "0.66665316", "text": "move() {\n this.theta += 3;\n this.x += this.dx;\n this.y += sin(this.theta) * this.amplitude;\n }", "title": "" }, { "docid": "8c94c5b6b506ac411c0da06c8cfa9246", "score": "0.6665468", "text": "move() {\n\t\t\tlet currentTime = new Date().getTime(),\n\t\t\t\tellapsedTime = currentTime - this.startMoveTime,\n\t\t\t\tt = ellapsedTime / this.duration,\n\t\t\t\tmoveProgress;\n\n\t\t\t// TODO: handle end/begining of map reach\n\t\t\tif (this.moving === true) {\n\t\t\t\tif (ellapsedTime >= this.duration) {\n\t\t\t\t\tthis.moving = false;\n\t\t\t\t\tthis.viewportX = this.viewportTargetX;\n\t\t\t\t\tthis.viewportY = this.viewportTargetY;\n\t\t\t\t\t// TODO: send endMove event ?\n\t\t\t\t} else {\n\t\t\t\t\tmoveProgress = this.easing(t, ellapsedTime, 0, 1, this.duration);\n\n\t\t\t\t\t// console.log('moving', this.viewportX);\n\n\t\t\t\t\tthis.viewportX = this.viewportStartX + moveProgress * this.viewportSpeedX | 0;\n\t\t\t\t\tthis.viewportY = this.viewportStartY + moveProgress * this.viewportSpeedY | 0;\n\t\t\t\t}\n\t\t\t\tthis.isDirty = true;\n\t\t\t} else if (this.masterObject) {\n\t\t\t\t// TODO: this has nothing to do in this method!\n\t\t\t\tthis.checkMasterPosition();\n\t\t\t\tthis.checkForTriggers();\n\t\t\t}\n\n\t\t\t// first move platforms\n\t\t\tthis.movePlatforms();\n\n\t\t\t// then move normal objects\n\t\t\tthis.moveObjects();\n\t\t}", "title": "" }, { "docid": "66250ac3a8eefae9e6204c6015da8731", "score": "0.6664731", "text": "function Move () {\n\t// \"normalizacja\" celu => przeniesienie go na te sama wysokosc, co gracz\n\tvar normalizedTargetPoint = NormalizeTargetPoint(targetPoint);\n\t// roznica miedzy aktualnym polozeniem a \"znormalizowanym\" celem\n\tvar transl = normalizedTargetPoint - transform.position;\n\t\n\t// automatyczne przyspieszenie\n\tspeed = Mathf.Lerp(speed, maxSpeed, Time.deltaTime * acceleration);\n\t\n\t// zmiana celu tak dlugo, az cel jest wystarczajaco daleko, czyli\n\t// okolo sekundy ruchu z aktualna predkoscia od gracza\n\twhile (transl.magnitude < speed) {\n\t\ttargetPoints.RemoveAt(0);\n\t\tnormalizedTargetPoint = NormalizeTargetPoint(targetPoints[0]);\n\t\ttransl = normalizedTargetPoint - transform.position;\n\t}\n\ttargetPoint = targetPoints[0];\n\t\n\t// jesli gracz nie skacze, to nastepuje aktualizacja kierunku ruchu\n\tif (!IsJumping()) {\n\t\tvar prevRot = transform.rotation;\n\t\tvar rot = prevRot;\n\t\trot.SetLookRotation(transl);\n\t\ttransform.rotation = Quaternion.Slerp(prevRot, rot, angleAcceleration);\n\t}\n\telse if (!jumpingReachedApex && vSpeed.y <= 0.0) {\n\t\tjumpingReachedApex = true;\n\t}\n\t\n\t// wyznaczanie ruchu\n\tvar prevPos = transform.position;\n\tvar movement = transform.rotation * (speed * Vector3.forward * Time.deltaTime);\n\t\n\t// ruch uwzgledniajacy ruch w pionie\n\tApplyGravity();\n\tmovement = movement + Time.deltaTime * vSpeed;\n\t\n\tvar controller : CharacterController = GetComponent(CharacterController);\n\tcontroller.Move(movement);\n\t\n\tif (debugDraw) {\n\t\tDebug.DrawLine(prevPos - Vector3(0, 0.4, 0), transform.position - Vector3(0, 0.4, 0), Color.red, 10000.0);\n\t}\n}", "title": "" }, { "docid": "0ae2320294bfe90faeecd017f7116050", "score": "0.6663899", "text": "move() {\n this.pos.y+=this.speed\n if (this.pos.y>height) {\n this.pos.y = 0;\n }\n }", "title": "" }, { "docid": "5b7c5dcb64c566694f443bf15772957c", "score": "0.6635446", "text": "move(timeDelta) {\n // let speed = 1.5;\n \n \n const velocityScale = timeDelta / NORMAL_FRAME_TIME_DELTA;\n this.pos[0] += this.vel[0] * velocityScale + this.acc[0] * (velocityScale * velocityScale) / 2;\n this.pos[1] += this.vel[1] * velocityScale + this.acc[1] * (velocityScale * velocityScale) / 2;\n this.vel[0] += this.acc[0] * velocityScale;\n this.vel[1] += this.acc[1] * velocityScale;\n\n }", "title": "" }, { "docid": "a78ccea61236e1837e4c6a80bbe80bdc", "score": "0.6621164", "text": "move(){\n // Change acceleration of Dot only if it has taken steps less than the number of \n // directions in its Brain\n if(this.brain.directions.length > this.brain.step){\n this.acc = this.brain.directions[this.brain.step];\n this.brain.step++; \n }\n // If Dot has already taken all the directions in its Brain, then kill it.\n else{\n this.dead = true;\n }\n // Change velocity by adding acceleration\n this.vel.add(this.acc);\n // Limiting the velocity of the Dot, so it doesn't go too fast\n this.vel.limit(5);\n // Change position of Dot by adding velocity\n this.pos.add(this.vel);\n }", "title": "" }, { "docid": "52bab6de592759ac3156999c7e1feeab", "score": "0.66120696", "text": "move() {\n\t\t/*\n\t\tif(this.pathStage < turningPoints.length && this.y > turningPoints[this.pathStage+1].y){\n\t\t\tthis.pathStage +=1;\n\t\t}*/\n\t\tswitch(turningPoints[this.pathStage].direction){\n\t\t\tcase 3:\n\t\t\t\t// Right\n\t\t\t\tthis.x += this.v;\n if(this.x > turningPoints[this.pathStage+1].x){\n this.pathStage += 1;\n }\n\t\t\t\tbreak;\n\t\t\tcase 6:\n\t\t\t\t// Down\n\t\t\t\tthis.y += this.v;\n if(this.pathStage < (turningPoints.length-1) && this.y > turningPoints[this.pathStage+1].y){\n this.pathStage += 1;\n }\n\t\t\t\tbreak;\n\t\t\tcase 9:\n\t\t\t\t// Left\n\t\t\t\tthis.x -= this.v;\n if(this.x < turningPoints[this.pathStage+1].x){\n this.pathStage += 1;\n }\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log(\"You are definitely doing something wrong\");\n\t\t}\n\t}", "title": "" }, { "docid": "377dd2de4ea42b1a73ae32c94922f597", "score": "0.6605059", "text": "move() {\n\n this.leftY -= this.speed;\n this.rightY -= this.speed;\n\n }", "title": "" }, { "docid": "e9ab7aa650033685c15e13b5de44f7d3", "score": "0.65847576", "text": "move(){\n var step = createVector(Noise.simplex2(this.offset, 0) * this.speed, Noise.simplex2(0, this.offset) * this.speed);\n this.x += step.x;\n this.y += step.y;\n this.offset += this.increment;\n\n //calculate angle based on direction\n this.theta = step.heading() + 180;\n\n if (this.x > width){\n this.x = 0;\n } else if (this.x < 0){\n this.x = width;\n }\n\n if (this.y > height){\n this.y = 0;\n } else if (this.y < 0){\n this.y = height;\n }\n }", "title": "" }, { "docid": "6f58fb316d3af8eb2612c38ca4051cdb", "score": "0.65587145", "text": "wander(){\n\t\tthis.vel = this.vel.plus(vec2.fromAng(this.mov, this.speed * dt));\n\t}", "title": "" }, { "docid": "d7c2b8468b4e0830084cbe6983a9fe88", "score": "0.6552135", "text": "move() {\n this.speedX += this.accX;\n this.speedY += this.accY;\n this.x += this.speedX;\n this.y += this.speedY;\n }", "title": "" }, { "docid": "47723a154d1a78fa2752f730ed0f6e53", "score": "0.6548176", "text": "moveLeft() {\n this.pos.x -= moveSpeed;\n }", "title": "" }, { "docid": "ee90de893e7aa678a35d4faa2ee79a52", "score": "0.65373284", "text": "pos() {\n // this.x += this.speedX;\n // console.log(this.x + this.speedX);\n\n\n // limiters to movement\n if (this.x + this.speedX <= 600 - this.width && this.x + this.speedX > 0) {\n this.x += this.speedX;\n }\n\n if (this.y + this.speedY < 500 && this.y + this.speedY > 0) {\n this.y += this.speedY;\n }\n // this.x += this.speedX;\n // this.y += this.speedY;\n }", "title": "" }, { "docid": "6acd3c0ade1700c26f3c5cf68bdc8723", "score": "0.6534994", "text": "moves () {\n this.x -= this.speed;\n }", "title": "" }, { "docid": "9ec06dd0d0dc1554578f109f6256c8be", "score": "0.6515036", "text": "function move() {\n\tblip.x = blip.x + blip.xspeed;\n\tblip2.x = blip2.x + blip2.xspeed;\n\tblip3.x = blip3.x - blip3.xspeed; // use - to move the x position to the left.\n\tblip4.x = blip4.x - blip4.xspeed;\n}", "title": "" }, { "docid": "2dce9280eea98db518eb70b3a4b3e7ca", "score": "0.65090007", "text": "move(amt){\n const vel = this.getAngle(this.heading);\n this.pos.x += amt*vel.x;\n this.pos.y += amt*vel.y;\n }", "title": "" }, { "docid": "2252667280c44137584373eb8153fe45", "score": "0.6502814", "text": "move(x, y) {\n this.pos.x += x;\n this.pos.y += y;\n\t\tthis.render();\n }", "title": "" }, { "docid": "19adf409911d18e594cfdf38e9240656", "score": "0.6472382", "text": "move(){\n var step = createVector(Noise.simplex2(this.offset, 0) * this.speed, Noise.simplex2(0, this.offset) * this.speed);\n this.x += step.x;\n this.y += step.y;\n this.offset += this.increment;\n\n //calculate angle based on direction\n this.theta = step.heading() + 90;\n\n if (this.x > width){\n this.x = 0;\n } else if (this.x < 0){\n this.x = width;\n }\n\n if (this.y > height){\n this.y = 0;\n } else if (this.y < 0){\n this.y = height;\n }\n }", "title": "" }, { "docid": "1d947110241cb20444fbe5c695a2d8fa", "score": "0.6470281", "text": "move(deltaX, deltaY){\n this.x += deltaX;\n this.y += deltaY;\n }", "title": "" }, { "docid": "4b8279d63ee9f73a8a18a9c9891596cc", "score": "0.64649117", "text": "update() {\n if (this.direction === 'ltr' && this.x <= 800) {\n this.x += this.speed;\n\n if (this.x >= 800) {\n this.direction = 'rtl';\n this.x -= this.speed;\n }\n }\n if (this.direction === 'rtl' && this.x >= 0) {\n this.x -= this.speed;\n\n if (this.x <= 0) {\n this.direction = 'ltr';\n this.x += this.speed;\n }\n }\n }", "title": "" }, { "docid": "43a7edcdf17c65754b37d8d75373d8a6", "score": "0.6464502", "text": "update() {\n this.pos.add(this.vel)\n this.vel.add(this.acc)\n this.acc.mult(0)\n this.vel.limit(12)\n }", "title": "" }, { "docid": "31a6423d61ef27d162ca4620b0a5cc61", "score": "0.64541984", "text": "move(dt, closestPlayer, direction, velocity) {\n \n if (closestPlayer !== null && closestPlayer.position.distanceTo(this.position) < closestPlayer.size+this.size) {\n this.takeControl(closestPlayer);\n }\n\n\t\tif (this.controlledBy !== null) {\n this.speed.x = 0;\n this.speed.y = 0;\n\n this.position = this.controlledBy.position.addPolar(closestPlayer.size+this.size, closestPlayer.direction);\n\t\t}\n else {\n\n this.direction = direction;\n this.speed.x = Math.cos(direction) * velocity;\n this.speed.y = Math.sin(direction) * velocity;\n\n let newX = this.position.x + this.speed.x;\n let newY = this.position.y + this.speed.y;\n\n // limit x coordinate to game area\n if (newX > this.gameArea.size.width && !this.gameArea.goals.some(goal => goal.isInside(this.position))) {\n newX = this.gameArea.size.width;\n }\n else if (newX < 0 && !this.gameArea.goals.some(goal => goal.isInside(this.position))) {\n newX = 0;\n }\n // limit y coordinate to game area\n if (newY > this.gameArea.size.height && !this.gameArea.goals.some(goal => goal.isInside(this.position))) { //toimiiko tämä some?\n newY = this.gameArea.size.height;\n }\n else if (newY < 0 && !this.gameArea.goals.some(goal => goal.isInside(this.position))) {\n newY = 0;\n }\n\n this.position = new Position(newX, newY);\n }\n }", "title": "" }, { "docid": "814132ac083fa87b98410fd93fd33712", "score": "0.6442404", "text": "move(direction) {\r\n if (\r\n this.currentPlayer.move === true &&\r\n this.currentPlayer.movementCount > 0\r\n ) {\r\n let newCoordonate = this.calculateNewCoordonate(direction)\r\n let oldCoordonate = this.currentPlayer.movementOfplayer()\r\n if (this.mapGame.cells[this.currentPlayer.x][this.currentPlayer.y].checkIfCellExist(newCoordonate.x, newCoordonate.y)) {\r\n if (this.mapGame.cells[this.currentPlayer.x][this.currentPlayer.y].checkIfCellHasobstacle(newCoordonate.x, newCoordonate.y)) {\r\n this.mapGame.cells[newCoordonate.x][newCoordonate.y].transferObjetCells(newCoordonate)\r\n this.currentPlayer.initCoordonate(oldCoordonate)\r\n this.currentPlayer.updateCoordonate(newCoordonate)\r\n if (this.mapGame.cells[this.currentPlayer.x][this.currentPlayer.y].checkIfCellHasWeapon(newCoordonate.x, newCoordonate.y)) {\r\n this.swapWeapon(this.currentPlayer.x, this.currentPlayer.y);\r\n }\r\n if (this.mapGame.cells[this.currentPlayer.x][this.currentPlayer.y].checkIfCellContainFighter(this.currentPlayer.x, this.currentPlayer.y)) {\r\n this.fight()\r\n }\r\n this.updateBoard(oldCoordonate.x, oldCoordonate.y);\r\n this.mapGame.cells[this.currentPlayer.x][this.currentPlayer.y].unsetlightAccessibleCells();\r\n this.mapGame.cells[this.currentPlayer.x][this.currentPlayer.y].lightAccessibleCells(this.currentPlayer.x, this.currentPlayer.y)\r\n this.currentPlayer.movementCount--;\r\n }\r\n }\r\n }\r\n if (\r\n this.currentPlayer.movementCount === 0 &&\r\n this.currentPlayer.move === true\r\n ) {\r\n this.currentPlayer.movementCount = 3;\r\n this.nextToPlay();\r\n }\r\n }", "title": "" }, { "docid": "33f250309141d898e098c1e016a8d8c4", "score": "0.6439837", "text": "move() {\n\n // Movement \n this.x += this.velX * tileSize;\n this.y += this.velY * tileSize;\n\n }", "title": "" }, { "docid": "7652bd5ce47eed4e54fd8c6b5090ad62", "score": "0.64347464", "text": "moveH(multMaxSpeed=1,multAcceleration=1){\n let move = this.mind&&this.mind.wantsToMove;\n if(!move)move=0;\n let slowDown=false; \n if(move==0){ // if no input\n if(this.isGrounded){\n if(this.vx!=0) move = (this.vx<0) ? 1 : -1;\n //if(this.vx<0)move+=2;\n //if(this.vx>0)move-=2;\n slowDown=true;\n }\n } else {\n\n // turn around fast:\n if(move>0&&this.vx<0)move+=2;\n if(move<0&&this.vx>0)move-=2;\n }\n\n this.vx+=this.a*move*+multAcceleration*game.time.dt;\n \n // Clamp horizontal velocity:\n const clamp=this.maxv*+multMaxSpeed;\n if(this.vx>clamp)this.vx=clamp;\n if(this.vx<-clamp)this.vx=-clamp;\n\n // Apply velocity:\n this.rect.x+=this.vx*game.time.dt;\n // Prevent ping-ponging:\n if(slowDown){\n if(move<0&&this.vx<0)this.vx=0;\n if(move>0&&this.vx>0)this.vx=0;\n }\n }", "title": "" }, { "docid": "89b49279934b451c0de4e80f38bfe386", "score": "0.64252883", "text": "move(position) {\n this.position = position;\n }", "title": "" }, { "docid": "8dfe95d941def46cdf64fd262dd207b5", "score": "0.64223826", "text": "function motionengine(e) {\r\n var mainobjoffset = $(crossmain).offset().left;\r\n var dsocx = jQuery(window).scrollLeft();\r\n var dsocy = jQuery(window).scrollTop();\r\n var curposy = (window.event) ? event.clientX : ((e.clientX) ? e.clientX: \"\");\r\n\t\r\n curposy -= mainobjoffset - dsocx;\r\n\r\n var leftbound = (menuwidth - options.restarea) / 2 - 100;\r\n var rightbound = (menuwidth + options.restarea) / 2 + 100;\r\n if (curposy > rightbound) {\r\n \t \r\n scrollspeed = (curposy - rightbound) / ((menuwidth - options.restarea) / 2) * options.maxspeed;\r\n clearTimeout(righttime);\r\n \r\n if (movestate != \"left\") moveleft();\r\n }\r\n else if (curposy < leftbound) {\r\n scrollspeed = (leftbound - curposy) / ((menuwidth - options.restarea) / 2) * options.maxspeed;\r\n clearTimeout(lefttime);\r\n if (movestate != \"right\") moveright();\r\n }\r\n else\r\n scrollspeed = 0;\r\n }", "title": "" }, { "docid": "a841be8e26fbe22939d6525c1a2d6363", "score": "0.6421163", "text": "function move(){\n var now = Dn();\n if(movementCooldown + movementTimer < now || moveOrder){\n movementTimer = Dn();\n\n\n var eX = ent.getPos().x;\n var eY = ent.getPos().y;\n if(moveOrder){\n f = moveOrder.x < eX ? -1 : 1;\n ent.moveX(f * movementSpeed);\n f = moveOrder.y < eY ? -1 : 1;\n ent.moveY(f * movementSpeed);\n } else {\n var d = dist(pX,pY,eX,eY);\n var maxReach = Ma(150,d/2);\n var dir = eX > pX ? -1 : 1;\n var distX = getRandomArbitrary(50,maxReach);\n var x = dir*distX + eX;\n dir = eY > pY ? -1 : 1;\n var distY = getRandomArbitrary(50,maxReach);\n var y = dir*distY + eY;\n moveOrder = {x:x,y:y};\n //console.log(\"THERE?\",moveOrder);\n }\n\n if(moveOrder && hits(moveOrder.x, moveOrder.y, 10, 10,\n eX, eY, ent.getDim().w, ent.getDim().h)) {\n moveOrder = false;\n movementCooldown = getRandomArbitrary(500, 2000);\n }\n }\n }", "title": "" }, { "docid": "fa91b4005f9a1da6dc7555b4ed9a0750", "score": "0.6420288", "text": "update() {\n if (this.entity.component('collisions').getFromLeft()) {\n this.entity.velocity.setX(this.speed);\n }\n\n if (this.entity.component('collisions').getFromRight()) {\n this.entity.velocity.setX(-this.speed);\n }\n }", "title": "" }, { "docid": "98bae7363fe4221c5eb484928498762e", "score": "0.641399", "text": "move(direction) {\n if (direction === MOVE_LEFT && this.x > 0) {\n if (this.horizontalSpeed > 0) {\n this.horizontalSpeed = -.1;\n }\n else if (this.horizontalSpeed >= -.8) {\n this.horizontalSpeed -= .05;\n }\n }\n else if (direction === MOVE_RIGHT && ((this.x + PLAYER_WIDTH) < GAME_WIDTH)) {\n if (this.horizontalSpeed < 0) {\n this.horizontalSpeed = .1;\n }\n else if (this.horizontalSpeed <= .8) {\n this.horizontalSpeed += .05;\n }\n }\n else if (direction === MOVE_UP && this.y > 0) {\n if (this.verticalSpeed > 0) {\n this.verticalSpeed -= .1;\n }\n else if (this.verticalSpeed >= -.6) {\n this.verticalSpeed -= .05;\n }\n }\n else if (direction === MOVE_DOWN && ((this.y + PLAYER_HEIGHT) < GAME_HEIGHT)) {\n if (this.verticalSpeed < 0) {\n this.verticalSpeed += .1;\n }\n else if (this.verticalSpeed < .6) {\n this.verticalSpeed += .05;\n }\n }\n }", "title": "" }, { "docid": "2db62183902b89c4d8fa063b9d48d302", "score": "0.6408704", "text": "move() {\n this.posX = this.startX + (this.dX * this.speed);\n this.posY = this.startY + (this.dY * this.speed);\n if (this.leftPressed && this.posX > 16) {\n this.dX -= 1;\n } else if (this.rightPressed && this.posX < (this.canvas.width - 16 - this.width)) {\n this.dX += 1;\n }\n\n if (this.upPressed && this.posY > 16) {\n this.dY -= 1;\n } else if (this.downPressed && this.posY < (this.canvas.height - 16 - this.height)) {\n this.dY += 1;\n }\n }", "title": "" }, { "docid": "e9db763d964709ec295826048eda170c", "score": "0.6401934", "text": "updatePos() {\n let speed = 0.25;\n this.x = round(lerp(this.x, this.i * GSIZE, speed));\n this.y = round(lerp(this.y, this.j * GSIZE, speed));\n }", "title": "" }, { "docid": "6ad7a7c17b70689dbba33e23e2875113", "score": "0.63985765", "text": "function moveStep(){\n\t\tmove(\n\t\t\tcharacter.real_x+(target.real_x-character.real_x)/3,\n\t\t\tcharacter.real_y+(target.real_y-character.real_y)/3\n\t\t\t);\n}", "title": "" }, { "docid": "c04e00b22fc650e2f9f17cc6247579bd", "score": "0.6387204", "text": "update() {\r\n // Update velocity\r\n this.velocity.add(this.acceleration);\r\n // Limit speed\r\n this.velocity.limit(this.maxspeed);\r\n this.pos.add(this.velocity);\r\n // Reset accelerationelertion to 0 each cycle\r\n this.acceleration.mult(0);\r\n }", "title": "" }, { "docid": "705debdd927d47c813f98188ef296f87", "score": "0.6386702", "text": "update() {\r\n\t\t//horizontal movement\r\n\t\tif (this.x != this.lBound && this.x != this.rBound) {\r\n\t\t\tthis.x += this.xMove;\r\n\t\t}\r\n\t\tif (this.x <= this.lBound || this.x >= this.rBound) {\r\n\t\t\tthis.xMove *= -1;\r\n\t\t\tthis.x += this.xMove;\r\n\t\t}\r\n\t\t//vertical movement\r\n\t\tif (this.y != this.uBound && this.y != this.dBound) {\r\n\t\t\tthis.y += this.yMove;\r\n\t\t}\r\n\t\tif (this.y <= this.uBound || this.y >= this.dBound) {\r\n\t\t\tthis.yMove *= -1;\r\n\t\t\tthis.y += this.yMove;\r\n\t\t}\r\n\t}", "title": "" }, { "docid": "cfb5a7ae112fc8b85a4275f171fa4d16", "score": "0.6384548", "text": "update() {\n this.x = this.x + this.xspeed;\n this.y = this.y + this.yspeed;\n }", "title": "" }, { "docid": "3850178c41ae073d69901d5043ddc985", "score": "0.6384221", "text": "update() {\n if (this.pinned) return;\n\n this.vel = Vector.sub(this.pos, this.oldPos).scale(this.heax.friction);\n\n this.oldPos.x = this.pos.x;\n this.oldPos.y = this.pos.y;\n\n this.vel.add(this.heax.gravity);\n\n if (this.pos.y >= this.heax.height - this.radius && this.vel.lenSqr() > 0) {\n this.vel.x *= this.heax.groundFriction;\n }\n\n this.pos.add(this.vel);\n }", "title": "" }, { "docid": "cfd6b1b7157b54999da9eb3a1250267e", "score": "0.63790566", "text": "move(){\n //string for the animation to be played\n var move_animation = '';\n //verify that the player has a physics body in order to move in the world\n if (this.body === undefined)\n return;\n\n //reset the player body velocity\n this.body.velocity.x=0; // change x velocity only so y can carry over for gravity\n\n //if the set has 'ArrowUp' event and the player on the floor or the player on an item then change his y velocity\n //because it means he is going up\n if(this.keys.up.isDown && (this.body.onFloor()||this.body.touching.down)){\n this.body.velocity.y= -this.speed *2;\n }\n //if set has 'ArrowLeft' even then change the player x velocity by negative so he can go to the left\n if(this.keys.left.isDown){\n this.body.velocity.x= -this.speed;\n //using the key that references the animation created to move to the left\n move_animation ='left';\n }\n //if the set has 'ArrowRight' event then change player x velocity by positive so he can go to the right\n if(this.keys.right.isDown){\n this.body.velocity.x= this.speed;\n //using the key that references the animation created to move to the right\n move_animation='right';\n }\n //iF THERE IS AN ANIMATION THEN PLAY IT\n if(move_animation){\n this.anims.play(move_animation,true);\n }\n //if not then play idle animation\n else{\n //set stationary poses\n this.anims.play('idle',true);\n }\n }", "title": "" }, { "docid": "161cb43acdfee98d23aabe392344c282", "score": "0.63741916", "text": "update() {\n\t\tthis.posX = this.posX + this.speed;\n\t\tif (this.posX > 500) {\n\t\t\tthis.posX = 0;\n\t\t\t// \"+1\" to avoid speed of 0\n\t\t\tthis.speed = 1 + Math.floor(Math.random() * Math.floor(4));\n\t\t}\n\t}", "title": "" }, { "docid": "c3a6e5d1d3e9dffd35dcc1ed44760523", "score": "0.63639575", "text": "function changespeed()\n{\n\tvar dis = dist();\n\tif(left_pressed) moveleft();\n\tif(right_pressed) moveright();\n\tif(up_pressed) moveup();\n\tif(touch_pressed) move();\n\tif(posx + speedx < 46)\n\t{\n\t\tposx = 46; speedx = - speedx;\n\t}\n\telse{\n\t\tif(posx + speedx > 482)\n\t\t{\n\t\t\tposx = 482;\n\t\t\tspeedx = - speedx;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(speedx >= 0 && dis == 0) speedx = Math.max(0, speedx - 5);\n\t\t\tif(speedx < 0 && dist == 0) speedx=Math.min(0, speedx + 5);\n\t\t\tposx += speedx;\n\t\t}\n\t}\n\tif(dis <= speedy){\n\t\tspeedy = 0;\n\t\tposy += dis;\n\t}\n\telse{\n\t\tposy += speedy;\n\t\tspeedy = speedy + 5;\n\t}\n\tif(posy > 500) lost = true;\n}", "title": "" }, { "docid": "159b371b39084216e8e1c1465e7e5f91", "score": "0.6357733", "text": "move(direction, amount=1){\n this.on_signal(direction, amount);\n }", "title": "" }, { "docid": "8a35cfdc137a4266b8ff71496f944d94", "score": "0.6356649", "text": "move(){\n this.posY = this.posY += 1;\n if(this.posY > height){\n this.posY = 0;\n }\n }", "title": "" }, { "docid": "f149a5c569d4bb97df0676a4a6bd1bf1", "score": "0.63501483", "text": "moveParticle() {\n if (this.x < 0 || this.x > p5.width)\n this.xSpeed *= -1;\n if (this.y < 0 || this.y > p5.height)\n this.ySpeed *= -1;\n this.x += this.xSpeed;\n this.y += this.ySpeed;\n }", "title": "" }, { "docid": "f149a5c569d4bb97df0676a4a6bd1bf1", "score": "0.63501483", "text": "moveParticle() {\n if (this.x < 0 || this.x > p5.width)\n this.xSpeed *= -1;\n if (this.y < 0 || this.y > p5.height)\n this.ySpeed *= -1;\n this.x += this.xSpeed;\n this.y += this.ySpeed;\n }", "title": "" }, { "docid": "1d39a2eebc6d72a8ca27da96147c5569", "score": "0.63433975", "text": "handleInput() {\n if (keyIsDown(LEFT_ARROW)) {\n this.vx = -PADDLE_SPEED;\n }\n else if (keyIsDown(RIGHT_ARROW)) {\n this.vx = PADDLE_SPEED;\n }\n else {\n this.vx = 0;\n }\n }", "title": "" }, { "docid": "055769270bbe90b7874dc9439d0e4719", "score": "0.63395166", "text": "move() {\n\n\t\tif(this.courseCorrection) {\n\t\t\tthis.courseCorrectionDuration -= 1;\n\t\t\tif(this.courseCorrectionDuration<1) {\n\t\t\t\tthis.headForDestination();\n\t\t\t\tthis.courseCorrection = false;\n\t\t\t}\n\t\t}\n\n\t\tlet worldX = this.worldX;\n\t\tlet worldY = this.worldY;\n\n\t\t/* Do the movement calculation */\n\t\tif(this.direction >= 0 && this.direction <= 90) {\n\t\t\tworldX += this.velocity * Math.sin(this.direction*Math.PI/180);\n\t\t\tworldY -= this.velocity * Math.cos(this.direction*Math.PI/180);\n\t\t} else if(this.direction > 90 && this.direction <= 180) {\n\t\t\tworldX += this.velocity * Math.cos((this.direction-90)*Math.PI/180);\n\t\t\tworldY += this.velocity * Math.sin((this.direction-90)*Math.PI/180);\n\t\t} else if(this.direction > 180 && this.direction <= 270) {\n\t\t\tworldX -= this.velocity * Math.sin((this.direction-180)*Math.PI/180);\n\t\t\tworldY += this.velocity * Math.cos((this.direction-180)*Math.PI/180);\n\t\t} else if(this.direction > 270 && this.direction <=360) {\n\t\t\tworldX -= this.velocity * Math.cos((this.direction-270)*Math.PI/180);\n\t\t\tworldY -= this.velocity * Math.sin((this.direction-270)*Math.PI/180);\n\t\t}\n\t\tif(this.world.isOceanAt(worldX, worldY)) {\n\n\t\t\t/* Detect the edge of the world */\n\t\t\tif(worldX < this.game.width/2) worldX = Math.floor(this.game.width/2);\n\t\t\tif(worldY < this.game.height/2) worldY = Math.floor(this.game.height/2);\n\t\t\tif(worldX > this.world.width*this.world.blockSize) worldX = this.world.width*this.world.blockSize;\n\t\t\tif(worldY > this.world.height*this.world.blockSize) worldY = this.world.height*this.world.blockSize;\n\n\t\t\t/* Move to the new position */\n\t\t\tthis.worldX = worldX;\n\t\t\tthis.worldY = worldY;\n\t\t} else {\n\t\t\t\n\t\t\t/* Do course correction */\n\t\t\tthis.courseCorrection = true;\n\t\t\tthis.courseCorrectionDuration = 90;\n\n\t\t\tthis.direction += 10;\n\t\t\tif(this.direction>360) this.direction = this.direction - 360;\n\t\t\tthis.direction = Math.floor(Math.random()*360);\n\t\t\t\n\n\t\t\t/* Detect port */\n\t\t\tlet block = this.world.getBlockAt(worldX, worldY);\n\n\t\t\t// if port - dock with it / show welcome / etc..\n\t\t\tif(block==5) {\n\t\t\t\tthis.dockAtPort(Math.floor(worldX/this.world.blockSize), Math.floor(worldY/this.world.blockSize));\n\t\t\t\t//console.log(`Ship docked at ${this.dockedAt.name} destination ${this.destination.name}`);\n\t\t\t\tthis.pickRandomDestination();\n\t\t\t\tthis.leavePort();\n\t\t\t\tthis.headForDestination();\n\t\t\t\t//console.log(`New destination ${this.destination.name}`);\n\t\t\t}\n\n\t\t}\n\t}", "title": "" }, { "docid": "340402771c02d946cc74dac76393ea05", "score": "0.63319063", "text": "move(dT) {\n this.x += this.v * dT;\n }", "title": "" }, { "docid": "cc2203fb1f67ba4fba1cc2d17a933ac5", "score": "0.63249946", "text": "move() {\n this.x += this.vx * this.direction.x;\n this.y += this.vy * this.direction.y;\n this.rotation += this.valpha;\n //this.radius*= Math.abs((this.valpha*0.01+1));\n }", "title": "" }, { "docid": "7b6f68235895f86e14e749c2f785161e", "score": "0.6321303", "text": "move(x,y) {\n this.x -= (this.x - x)*this.speed;\n this.y -= (this.y - y)*this.speed;\n }", "title": "" }, { "docid": "2ce2887e82517ed3d70e0ac386bf443b", "score": "0.63163227", "text": "moveParticle() {\n if (this.x < 0 || this.x > width)\n this.xSpeed *= -1;\n if (this.y < 0 || this.y > height)\n this.ySpeed *= -1;\n \n this.x += this.xSpeed;\n this.y += this.ySpeed;\n }", "title": "" }, { "docid": "5b770333438dc7381045dbb0dba642c6", "score": "0.63116026", "text": "updateSpd(){\n this.resetSpeed();\n if(this.pressingRight){\n this.spdX = this.moveAmount;\n }\n else if(this.pressingLeft){\n this.spdX = -this.moveAmount;\n }\n else if(this.pressingUp){\n this.spdY = -this.moveAmount;\n }\n else if(this.pressingDown){\n this.spdY = this.moveAmount;\n }\n }", "title": "" }, { "docid": "e23b14b548dc0c8d90f5514e7d23fed2", "score": "0.63043904", "text": "updatePosition() {\n this.x += this.speed * this.xDir;\n this.y += this.speed * this.yDir;\n if (this.y >= height || this.y <= 0) {\n this.yDir *= -1;\n }\n if (this.x >= width || this.x <= 0) {\n this.xDir *= -1;\n }\n }", "title": "" }, { "docid": "83210e20ba6ff9415c8496ea65dfd7da", "score": "0.62945163", "text": "moveRight() {\n this.pos.x += moveSpeed;\n }", "title": "" }, { "docid": "eccdb94e6a0febe23456068918324f86", "score": "0.62906235", "text": "function Update(){\n\tmoveDirection = mushroomDirection.GetComponent(mushroomCollider).mushroomDirection;\n\t\n\tif(moveDirection){\n\t\tmushroomSpeed = 1;\n\t}\n\tif(!moveDirection){\n\t\tmushroomSpeed = -1;\n\t}\n\ttransform.Translate(mushroomSpeed * Time.deltaTime, 0,0);\n}", "title": "" }, { "docid": "3c01f2c517ec5091d3bdef0a64afa68b", "score": "0.6282496", "text": "moveModel(speed) {\n\t\t// Calculate forward vector\n\t\tvar rot = this.bot.getRotation();\n\t\tvar forward = [\n\t\t\tMath.sin(glMatrix.toRadian(rot[1])),\n\t\t\t0,\n\t\t\tMath.cos(glMatrix.toRadian(rot[1]))\n\t\t];\n\t\t// Normalize forward vector\n\t\tvec3.normalize(forward, forward);\n\t\t// Calculate a forward * speed to get get velocity\n\t\tvec3.mul(forward, [speed, speed, speed], forward);\n\t\t// Translate top and bot\n\t\tthis.translateModel(forward, this.top);\n\t\tthis.translateModel(forward, this.bot);\n\t\t// Move camera\n\t\tthis.camera.transCamera(forward);\n\t\t// Update end of turret position\n\t\tvec3.add(this.bombPos, this.bombPos, forward);\n\t}", "title": "" }, { "docid": "55d24c0a1a65b4125e0297593386769e", "score": "0.62755793", "text": "move(distance){\n this.x += distance;\n }", "title": "" }, { "docid": "896b53c59a75ac69a2c79add9281bb45", "score": "0.6268329", "text": "updateVelocity(newVelocity) {\r\n this.v = newVelocity;\r\n }", "title": "" }, { "docid": "19103ce66761fba0f15d9b731e7b7f91", "score": "0.6263361", "text": "update() {\n this.position.add(this.velocity);\n this.edges();\n }", "title": "" } ]
629d259e672fb4510b550734d89b5efa
Get list of Categories
[ { "docid": "ae0d47b50e04d01499401bb36c97cfbf", "score": "0.74785537", "text": "function getCategories(){\r\n return new Promise((resolve, reject) => {\r\n const categoryURL = \"http://api.icndb.com/categories\";\r\n http.get(categoryURL, (res) => {\r\n res.on(\"data\", (data) => {\r\n const category = JSON.parse(data);\r\n resolve(category);\r\n });\r\n });\r\n });\r\n}", "title": "" } ]
[ { "docid": "2f0653bd64902ac285bcbe70d78f80f7", "score": "0.84273016", "text": "async getAllCategories() {\n return await apiService.get('categories');\n }", "title": "" }, { "docid": "834d3af37ac6765c5cdb4a1fc2324268", "score": "0.79745126", "text": "function getCategories(){\n\t\t\t\treturn $http.get( settings.DATA_URL)\n\t\t\t\t\t\t\t.then(function(response){\n\t\t\t\t\t\t\t\treturn response.data.categories;\n\t\t\t\t\t\t\t}//success\n\t\t\t\t\t\t\t, function(error){\n\t\t\t\t\t\t\t\tconsole.log('get categories:',error);\n\t\t\t\t\t\t\t});\n\t\t\t}//get categories", "title": "" }, { "docid": "e4937cfa3590c74dd6c02bacb3dbaf13", "score": "0.7869302", "text": "function getCategories() {\n return Category.find({}).exec();\n}", "title": "" }, { "docid": "7fc8278405acdb26faf542024483bc88", "score": "0.77917427", "text": "apiCategoriesListGet() {\n return this.client.then((client) => {\n return client.apis['API Category (Collection)'].get_api_categories(\n this._requestMetaData(),\n );\n });\n }", "title": "" }, { "docid": "0ea19dbab4d12295a2db74945211a2c5", "score": "0.7676095", "text": "function getCategories() {\n return $http.get('categories.json')\n .then(httpGetCompleted)\n .catch(httpGetFailed);\n\n function httpGetCompleted(response) {\n return response.data;\n }\n function httpGetFailed(error) {\n return error;\n }\n }", "title": "" }, { "docid": "5530768b7af38bd098e75a0ab1cbe581", "score": "0.7631678", "text": "function getCategories(callback){\n getReq(api.rootUrl + \"/categories/\" + api.version, callback);\n}", "title": "" }, { "docid": "697975ac9cd81c4bf24ce53b415a7a69", "score": "0.7559045", "text": "get allCategories() {\n return this._categoriesList;\n }", "title": "" }, { "docid": "f242c2ef67c390302975cfcbbcb74268", "score": "0.75278246", "text": "product_list_categories(){\n\t\treturn this.http.get('/categories')\n\t}", "title": "" }, { "docid": "b83f66f44084f46cc8fe8abfe9c2581b", "score": "0.7518737", "text": "async getCategories() {\r\n var categories = [];\r\n // get the category of each item\r\n var data = await this.getAllItems();\r\n data.forEach(function(item) {\r\n if(!categories.includes(item.catalogCategory))\r\n {\r\n categories.push(item.catalogCategory);\r\n }\r\n });\r\n return categories;\r\n }", "title": "" }, { "docid": "c2bbffc3d387eabad6a84fbb406ca35a", "score": "0.7504777", "text": "function getAll() {\n return db('categories');\n}", "title": "" }, { "docid": "f19f86317a030c8ba93456556a76ad0a", "score": "0.7432553", "text": "getCategories(){\n return Api().get(\"/category\")\n }", "title": "" }, { "docid": "fa7526acc87c1042075e2436b3454a11", "score": "0.74242544", "text": "function getCategories() {\n let return_data = null;\n XHR.setCallback(function (data) {\n return_data = JSON.parse(data);\n },\n function (error) {\n console.log('There was a failure: ' + error);\n });\n XHR.GET('/parse/classes/categories');\n if (return_data.results[0] === undefined) {\n return null;\n }\n return return_data;\n}", "title": "" }, { "docid": "61cceaf72a66e284bfbe4436d96d2db5", "score": "0.74049425", "text": "static async getListCategories () {\n const db = await Mongo.instance().getDb();\n\n const listCategories = await db.collection(collections.VARIABLE_COLL).distinct('category');\n\n if (!listCategories) {\n return new Error('Can not found any categories');\n }\n listCategories.sort();\n return listCategories;\n }", "title": "" }, { "docid": "f8decd01d723712596e793ceb931bd28", "score": "0.7270789", "text": "function getCategories() {\n _sendRequest('https://api.budgetbakers.com/api/v1/categories',\n function () {\n if (this.readyState === 4) {\n var categories = JSON.parse(this.responseText);\n\n $.each(categories, function(i, object) {\n data[object.id] = {\n label: object.name,\n color: object.color,\n id: object.id,\n records: []\n }\n });\n }\n });\n }", "title": "" }, { "docid": "792c6d244388f8732b23d9b70870147f", "score": "0.7264789", "text": "function getAllCategories() {\n return new Promise((resolve, reject) => {\n Category.find({}, (err, categories) => {\n if (err) return reject(err);\n resolve(categories);\n });\n });\n}", "title": "" }, { "docid": "9efd283d81916aaf2a3dfda2fd54dfac", "score": "0.7204569", "text": "function getCategories() {\n fetch(\"/categories\")\n .then(checkStatus)\n .then(response => response.json())\n .then(populateCategorySelect)\n .catch(handleError);\n}", "title": "" }, { "docid": "9efd283d81916aaf2a3dfda2fd54dfac", "score": "0.7204569", "text": "function getCategories() {\n fetch(\"/categories\")\n .then(checkStatus)\n .then(response => response.json())\n .then(populateCategorySelect)\n .catch(handleError);\n}", "title": "" }, { "docid": "0a95338177e9dee565a3e736209765f7", "score": "0.71961665", "text": "async function getCategories() {\n const listCategories = await category.getCategories();\n category.showList(listCategories);\n //Get the params URL for assign class to Category Link\n let params = new URLSearchParams(location.search);\n const categoryId = params.get('categoryId');\n //Change the class to active Category\n category.setActive(categoryId);\n}", "title": "" }, { "docid": "3b7c48be7734eea42b23113fd42532c2", "score": "0.7194439", "text": "function getCategories() {\n return fetch('https://www.themealdb.com/api/json/v1/1/categories.php')\n .then(\n (data) => data.json()\n );\n}", "title": "" }, { "docid": "0b5e3318090cdd77cbc0476f0b932815", "score": "0.7178191", "text": "getList(cb) {\n return this.dataProvider.send({type: 'category.list'}).then(cb);\n }", "title": "" }, { "docid": "1a8e8d4b2d2f3ed0fcf064bb71656854", "score": "0.7147012", "text": "get CATEGORIES() {\n var categories = this.mozContact.categories || [];\n return new Property('CATEGORIES').textList(categories);\n }", "title": "" }, { "docid": "bf72c7bd8976b9e6b0ae1beb3736e4fa", "score": "0.7129879", "text": "function Categories() {\r\n const _all = [\r\n {\r\n name: 'Access Security',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Boon Edam USA', 'Delta Turnstiles'],\r\n description: 'Browse through library of products for free download....'\r\n },\r\n {\r\n name: 'Optical Turnstiles',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Boon Edam USA', 'Delta Turnstiles'],\r\n description: ''\r\n },\r\n {\r\n name: 'Appliances',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Kenmore'],\r\n description: ''\r\n },\r\n {\r\n name: 'Dishwashers',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Kenmore'],\r\n description: ''\r\n },\r\n {\r\n name: 'AV',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Cable Tray',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Chalfant', 'Kenmore'],\r\n description: ''\r\n },\r\n {\r\n name: 'Ceilings',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Homasote'],\r\n description: ''\r\n },\r\n {\r\n name: 'Countertops',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Door Hardware',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Doors',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Drains',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Flooring',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Furniture',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Mailboxes',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Lighting',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Paints & Coatings',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['National Gypsum'],\r\n description: ''\r\n },\r\n {\r\n name: 'Piping',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Railings',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Roofing',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Security Cameras',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Skylights',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: [],\r\n description: ''\r\n },\r\n {\r\n name: 'Revolving Doors',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Boon Edam USA'],\r\n description: \"\"\r\n },\r\n {\r\n name: 'Access Gates',\r\n type: enums.entityType.category,\r\n subcategories: [],\r\n manufacturers: ['Boon Edam USA'],\r\n description: \"\"\r\n }\r\n ];\r\n\r\n return new DataTable(_all);\r\n}", "title": "" }, { "docid": "64c6c094773ea7e7554f48efdd49f980", "score": "0.7128953", "text": "async getCategories(){\n const response = await fetch('https://www.thecocktaildb.com/api/json/v1/1/list.php?c=list');\n const data = await response.json();\n\n return {data};\n }", "title": "" }, { "docid": "d049f1dd35cadb725def916896746a82", "score": "0.71150225", "text": "function getAllCats() {\n $http.get('/api/constant/getallCategory').then(function(res) {\n $scope.cats = res.data;\n })\n }", "title": "" }, { "docid": "e12183be1a6bcfa59394e104f078de2f", "score": "0.7086694", "text": "function obtenerCategorias() {\n\treturn ajax('obtenerCategorias', null);\n}", "title": "" }, { "docid": "41ea3201b7a39e60f12fff772fa2c0e4", "score": "0.7076933", "text": "function getCategory() {\n $.get('/api/category', renderCategoryList);\n }", "title": "" }, { "docid": "04fb3318e0573f76e0c266498087686c", "score": "0.7068212", "text": "gatherCategories(){\n \tfetchCategories().then((data) => {\n \t\tconst parseData = JSON.parse(data)\n \t\tconst categories = Object.keys(parseData.categories).map((key) => {\n \t\t\treturn parseData.categories[key].name\n \t\t})\n\t \t\tthis.props.addCats(categories)\n \t})\n }", "title": "" }, { "docid": "7b53e71f1b6b8e4d450f543077573c76", "score": "0.7046839", "text": "function getCats() {\n $http.get('/api/constant/getallCategory').then(function(res) {\n $scope.categoriesUrl = res.data;\n })\n }", "title": "" }, { "docid": "d5ab14f89369544677d96f8a107b1a98", "score": "0.702462", "text": "getCategories() {\n const category$ = this.categoryService.getCategoryList();\n category$.subscribe((res) => {\n this.categoryList = res.response_data;\n });\n }", "title": "" }, { "docid": "ad13c4ffc4027dc11732f25b29b7fd30", "score": "0.698953", "text": "function getCategories() { \n\tvar fs = require('fs');\n\tvar cats = getSettings( 'cats' );\n\n\tif( 1 || typeof cats === 'undefined' || typeof cats.length === 'undefined' || cats.length === 0 ) { \n\t\tif( fs.existsSync( 'default_cats.json' ) ) { \n\t\t\tcats = fs.readFileSync(\"default_cats.json\");\n\t\t\ttry { \n\t\t\t\tcats = JSON.parse( cats );\n\t\t\t} catch ( e ) { \n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tsaveSettings( 'cats', cats );\n\t\t}\n\t}\n\n\treturn cats;\n}", "title": "" }, { "docid": "de65ad7b24f78df8f5ea9c5a8df93488", "score": "0.6985073", "text": "async function getCategories() {\n let json;\n try {\n UI.$loader.style.transition = \"margin-top 0.3s\";\n UI.$loader.style.marginTop = \"0\";\n const resp = await fetch(\"https://opentdb.com/api_category.php\");\n json = resp.json();\n } catch (e) {\n return e;\n } finally {\n UI.$loader.style.marginTop = \"-3px\";\n }\n return json;\n }", "title": "" }, { "docid": "88f8f1abcc3ab09c77e763373fe06eb1", "score": "0.6983642", "text": "function getCatList(req, res) {\n catModel.getAllCats(function(error, results) {\n res.json(results);\n });\n}", "title": "" }, { "docid": "2ceede6525b654d63a953798a4138d3a", "score": "0.69789463", "text": "function getCategories() {\n\t\t\tDrinkService.getCategories($rootScope.userLogin.token).success(function (res) {\n\t\t\t\t$rootScope.list_categories = res;\n\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tvar _arr = $scope.data_detail.category;\n\t\t\t\t\t$rootScope.list_categories.forEach(function (el) {\n\t\t\t\t\t\tfor (var i = 0; i < _arr.length; i++) {\n\t\t\t\t\t\t\tvar element = _arr[i];\n\t\t\t\t\t\t\tif (element == el.id) {\n\t\t\t\t\t\t\t\tel.selected = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}, 400);\n\n\t\t\t}).error(function (err, stt, res) {\n\t\t\t\tif (err.detail){\n toastr.error(err.detail);\n }\n for( var key in err){\n var x = 'err.'+key;\n toastr.error(key.toUpperCase()+\": \"+eval(x)[0]);\n }\n\t\t\t})\n\t\t}", "title": "" }, { "docid": "f05121a5b9668dff36cad3c570eab67c", "score": "0.697703", "text": "function getCategories(req, res) {\n const params = {\n TableName: tableName\n };\n dynamoDB.scan(params, function(err, data) {\n if (err)\n return utils.error(res, 500, \"Internal Server Error\");\n return res.json({\n categories: data.Items.filter(item => item.type == \"category\"),\n })\n });\n}", "title": "" }, { "docid": "993b9aaf130960288e8b2dcef2292a1c", "score": "0.6975832", "text": "getAllCategories() {\n\n this.dataBase.getData(\"/categories/_design/allcategories/_view/new-view\", true, '').then( data => {\n if (data) {\n this.allCategories = data;\n this.getNewsForCategory(this.allCategories);\n mvc.apply();\n this.slide(0);\n } else {\n this.getAllCategories();\n }\n }, () => {\n this.getAllCategories();\n });\n\n }", "title": "" }, { "docid": "70ff41f8f73fbb148924e90bacdbcb80", "score": "0.6964378", "text": "function getCategoriesInfo() {\n\t\treturn identifyCategories(categories, navigator.userAgent.toLowerCase());\n\t}", "title": "" }, { "docid": "9dafe04dbfb9bfef9ca60203ebe73595", "score": "0.6944602", "text": "function categories() {\n\t\t\t\t\t\tif ($scope.currentBatch) {\n\t\t\t\t\t\t\tcaliberDelegate.qc.getAllAssessmentCategories(\n\t\t\t\t\t\t\t\t\t$scope.currentBatch.batchId,\n\t\t\t\t\t\t\t\t\t$scope.currentWeek).then(\n\t\t\t\t\t\t\t\t\tfunction(response) {\n\t\t\t\t\t\t\t\t\t\t$scope.categories = response;\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}", "title": "" }, { "docid": "76314d931c35254d16f998e7c10e28ae", "score": "0.69401735", "text": "function getCategories(classifieds) {\n\t\t\t\t\tvar categories = [];\n\t\t\t\t\t// iterating throught it, each items from it\n\t\t\t\t\tangular.forEach(classifieds, function(item){\n\t\t\t\t\t\t// for each item get the category of it\n\t\t\t\t\t\tangular.forEach(item.categories, function(category){\n\t\t\t\t\t\t\tcategories.push(category);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\t// we want to put unique category to avoid duplicate results\n\t\t\t\t\treturn _.uniq(categories);\n\t\t\t\t}", "title": "" }, { "docid": "c7ddc1e853ddd7b9f3414909fc8513dd", "score": "0.69194293", "text": "function CATEGORIES() {}", "title": "" }, { "docid": "08cff8991507db553285532cdf222fda", "score": "0.68858707", "text": "getCategory() {\n this.categortList = this.base.list('Category');\n return this.categortList.snapshotChanges();\n }", "title": "" }, { "docid": "c95182589a261916871097ed8de2696c", "score": "0.6877722", "text": "async function getCategories(){\n console.info('Buscando todos las categorias');\n let message = '';\n //Conectamos con las queries\n let categories = await queries\n .categories\n .getAll()\n .then(data => {\n //Si se consiguio la info\n if(data){\n console.info('Informacion de categorias obtenida');\n return data;\n }\n else{\n //Si no se consiguieron datos\n console.info('No existen categorias registrados en la BD');\n message = 'No existen categorias registrados en la BD';\n return null;\n }\n })\n .catch(err => {\n console.error(`Error en Query SELECT de Category : ${err}`);\n message = 'Ocurrio un error al obtener las categorias';\n return null;\n });\n return { categories, message };\n}", "title": "" }, { "docid": "fb83808b055aa417da14928493e84c6a", "score": "0.6791622", "text": "static getCategories(title, limit) {\n limit = (limit < 0) ? 1 : limit;\n limit = (limit > 50) ? 50 : limit;\n return new Promise((resolve, reject) => {\n try {\n this.callAPI(this.createURLString('categories', [title]) + '&clshow=!hidden' + `&cllimit=${limit};`, result => {\n try {\n resolve(makeResultArray(result, 'categories', 'title'));\n } catch (err) {\n reject(err);\n }\n }, (err) => reject(err));\n } catch (err) {\n reject(err);\n }\n });\n }", "title": "" }, { "docid": "aaa0a5145e511fd2b356deafa4088db7", "score": "0.67613566", "text": "function index (req,res){\n var response = categoriesDA.getAllCategories();\n res.json(response);\n}", "title": "" }, { "docid": "9455db578aad4e034d0fd49f721cfdd3", "score": "0.6748167", "text": "categoryNames(state) {\n return state.categories.map(cat => cat.name)\n }", "title": "" }, { "docid": "d4fe5321c9b229af20edda648d3b923a", "score": "0.6746815", "text": "function getCategories (ic) {\n var cats = [];\n var obj = {};\n var table = connection.query(\"select * from dokuapp.categories\");\n table\n .on('error', function(err) {\n if (err.code === 'PROTOCOL_CONNECTION_LOST') {\n reconnect();\n }\n console.log(\"sql: \" + table.sql)\n console.log(err)// Handle error, an 'end' event will be emitted after this as well\n })\n .on('fields', function(fields) {\n //\n })\n .on('result', function(row) {\n // Pausing the connnection is useful if your processing involves I/O\n connection.pause();\n obj[row.name] = JSON.parse(row.fields);\n cats.push(row.name);\n //, function() {\n connection.resume();\n //});\n })\n .on('end', function() {\n // all rows have been received\n });\n if (ic) {\n return cats;\n } else {\n return obj;\n }\n}", "title": "" }, { "docid": "286ac29ba2811c241690fe71fa9dd49b", "score": "0.67336416", "text": "function getVideoCategories() {\n return openRealm().then(realm => {\n return realm.objects(VideoCategory.schema.name);\n });\n}", "title": "" }, { "docid": "277a3f186a540fb3fab7d5d5f352788f", "score": "0.6718142", "text": "async getCategoriesAPI() {\n // query categories\n const categoriesResponse = await fetch(`https://www.eventbriteapi.com/v3/categories/?token=${this.auth_token}`);\n\n // Wait for the response and return as json\n const categories = await categoriesResponse.json();\n\n return { categories };\n }", "title": "" }, { "docid": "ee99ba9180775f92301bb55266d1ce93", "score": "0.671559", "text": "categoryLoader() {\n return listOfCategories;\n }", "title": "" }, { "docid": "9164490b8232326e170577668cf3d03a", "score": "0.6711736", "text": "function getAllCategory(req, res) {\n models.Category.findAll().then(Categorys => {\n return res.status(200).send({ message: Categorys })\n }).catch(error => {\n return res.status(500).send({ message: `Error al consultar la categoria ${error}` })\n })\n}", "title": "" }, { "docid": "3924a0074086460fd2e656fd9c34cef0", "score": "0.67064875", "text": "async function getAllCategories(){\r\n return new Promise((resolve,reject)=>{\r\n fetch(baseURL + '/categories').then((response)=>{\r\n if(response.ok)\r\n resolve(response.json());\r\n else reject();\r\n }).catch((err)=>{ reject({ errors: [{ param: \"Server\", msg: \"Cannot communicate\" }] }) })\r\n });\r\n}", "title": "" }, { "docid": "9855f71135e11468152456cd262a3d26", "score": "0.66897905", "text": "loadCategories(){\n CategoryUtils.getCurrentCategories()\n .then( list => { Dispatcher.handleClientAction(Cons.CATEGORY_LIST_UPDATED, list) })\n .catch( err => {} );\n }", "title": "" }, { "docid": "5938375a8529cdfd57d706fdb486d9c0", "score": "0.6654954", "text": "async function getCategories() {\n const categoriesUrl = 'https://www.themealdb.com/api/json/v1/1/categories.php'\n try {\n const response = await axios.get(categoriesUrl)\n const categoriesArray = response.data.categories\n optionValue(categoriesArray)\n } catch (err) {\n console.error(err)\n }\n}", "title": "" }, { "docid": "b54aae07020ee578ff8f7528ee484563", "score": "0.66531783", "text": "async function getAllCategoriesAsync() {\n const sql = `SELECT * FROM categories`;\n const categories = await dal.executeAsync(sql);\n return categories;\n}", "title": "" }, { "docid": "40ca7fd9d038206b9b0b91a74f8db548", "score": "0.66356516", "text": "static getCategories(accessToken, country = COUNTRY, locale = LOCALE, limit = FETCH_LIMIT, offset = FETCH_OFFSET) {\n\n\t\tlet params = [\n\t\t\t`country=${country}`,\n\t\t\t`locale=${locale}`,\n\t\t\t`limit=${limit}`,\n\t\t\t`offset=${offset}`\n\t\t].join('&');\n\n\t\treturn this.get(null, `/browse/categories?${params}`, accessToken)\n\t}", "title": "" }, { "docid": "82caceed4c58981168ebc804789c6d45", "score": "0.6622798", "text": "function getCategories(all) {\n\t// check argument\n\tif (typeof all == 'undefined') {\n\t\tall = false;\n\t}\n\n\t// empty array\n\tvar results = [];\n\n\t// create recored set\n\tvar categoryRS;\n\tif(all) {\n\t\tcategoryRS = db_conn.execute('SELECT title,icon,enabled FROM category ORDER BY title ASC');\n\t} else {\n\t\tcategoryRS = db_conn.execute('SELECT title,icon,enabled FROM category WHERE enabled = \"1\" ORDER BY title ASC');\n\t}\n\n\t// loop through recored set and trace the contents\n\twhile(categoryRS.isValidRow()) {\n\t\t// create category\n\t\tvar c = {\n\t\t\ttitle: categoryRS.fieldByName('title'),\n\t\t\ticon: categoryRS.fieldByName('icon'),\n\t\t\tenabled: categoryRS.fieldByName('enabled')\n\t\t};\n\n\t\t// push category\n\t\tresults.push(c);\n\n\t\t// get next record set\n\t\tcategoryRS.next();\n\t}\n\t// close record set\n\tcategoryRS.close();\n\n\t// close db\n\t//db.close();\n\n\t// return results\n\treturn results;\n}", "title": "" }, { "docid": "1fe2fad61b12e222205a5e57012b1a7d", "score": "0.6617823", "text": "async function getListOfAllCategories() {\n return new Promise(function(resolve, reject) {\n mysql.pool.query(\"SELECT `categoryId`, `categoryName` FROM `Categories` ORDER BY `categoryName` ASC;\", (err, rows, fields) => {\n if (err) {\n logIt(\"getListOfCategories() ERROR: \" + err);\n reject(\"ERROR in selecting courses\");\n }\n\n resolve(rows);\n });\n })\n}", "title": "" }, { "docid": "5ff383a0cc1214b3027a1023d08cc20b", "score": "0.661032", "text": "async function loadCategories() {\n const categorySelector = document.querySelector('.Category-selector');\n const categories = await foursquare.getCategories();\n if (categorySelector) {\n categories.response.categories.map(category => {\n const opt = document.createElement('option');\n opt.text = category.name;\n opt.name = category.name;\n categorySelector.appendChild(opt);\n });\n }\n}", "title": "" }, { "docid": "07759091efd362e6082bf44e1fbc265e", "score": "0.6609301", "text": "constructor () {\n this.categories = []\n }", "title": "" }, { "docid": "21f868f0cdd7403b7740e8aca45b96a3", "score": "0.6606561", "text": "function UP_CATEGORIES(yeah) {\n return up_('categories', {\n tabulate(data) {\n const table = data.map((category) => [\n category.id,\n category.attributes.name,\n category.relationships.parent.data\n ? category.relationships.parent.data.id\n : 'all',\n ]);\n return [UP_CATEGORIES_HEADINGS, ...table, ['all', 'All', '']];\n },\n });\n}", "title": "" }, { "docid": "f6551998520d91fe3d6777a9c4bc1dc5", "score": "0.6605877", "text": "function getCategories(data) {\n // Just select the first player to get the keys\n var categories = Object.keys(data[getPlayerNames(data)[0]]);\n var cat = [],\n i = 0;\n for (i; i < categories.length; i++) {\n cat.push(categories[i]);\n }\n return cat;\n}", "title": "" }, { "docid": "fb04d0760f6423dfd451d26166b8beae", "score": "0.65821594", "text": "async getCategories({ commit, state }) {\n\t\t\ttry {\n\t\t\t\tconst [error, categories] = await QuestionsAPI.getCategories();\n\t\t\t\tstate.questionsError = error;\n\n\t\t\t\tif (categories) commit(\"setCategories\", categories.trivia_categories);\n\t\t\t\telse commit(\"setQuestionsError\", error);\n\t\t\t} catch (error) {\n\t\t\t\tcommit(\"setQuestionsError\", error.message);\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "0fa8a1ade3707fdcb695f85de9414318", "score": "0.6580845", "text": "function loadAllCategories(callbackpanelid){\n\t\tvar result;\n\t\tds.get(baseURL + \"/main/dataSource/manager.do?method=loadDataSourceCategories\", function(data){\n\t\t\tresult = data;\n\t\t}, null, true, callbackpanelid);\n\t\treturn result;\n\t}", "title": "" }, { "docid": "5b952035e94282ebd17b50e52abc5bc8", "score": "0.65754974", "text": "function getCategories() {\n var deferred = $q.defer();\n\n if (categories) {\n console.log(categories);\n deferred.resolve(categories);\n } else {\n $http.get('/categories')\n .then(function (response) {\n console.log(response);\n deferred.resolve(cacheCategories(response));\n });\n }\n return deferred.promise;\n }", "title": "" }, { "docid": "cb7d8f4ee730a4f2d7bc66aa24284ce6", "score": "0.6575129", "text": "function getCategories(args) {\n Y.log('Entering Y.doccirrus.api.formtemplate.getCategories', 'info', NAME);\n Y.log('DEPRECATED Y.doccirrus.api.formtemplate.getCategories, should no longer be needed, form folders are now stored in database', 'warn', NAME);\n if (args && args.callback) {\n args.callback = require(`${ process.cwd() }/server/utils/logWrapping.js`)(Y, NAME)\n .wrapAndLogExitAsync(args.callback, 'Exiting Y.doccirrus.api.formtemplate.getCategories');\n }\n args.callback(null, Y.dcforms.categories);\n }", "title": "" }, { "docid": "b124f88d0e56ad05044511d1aabe51d3", "score": "0.6570893", "text": "function get() {\n if (service.categories === null) {\n var query = databaseService.child('categories').orderByChild('name');\n service.categories = new $firebaseArray(query);\n }\n return service.categories.$loaded();\n }", "title": "" }, { "docid": "ec822795efc08e000ec1e811b8407055", "score": "0.6566534", "text": "function readCategories(category, callback){\n getConnection();\n var sql = \"SELECT id, Name FROM categories ORDER BY Name \";\n connection.query(sql, function(err, rows, fields){\n if(err){\n console.log(err);\n callback(err, null);\n }else{\n var categories = [];\n for (var i in rows){\n var cur = rows[i];\n categories.push(cur);\n }\n // console.log('readCategories. categories = '+JSON.stringify(categories));\n callback(null, categories);\n }\n });\n}", "title": "" }, { "docid": "aa1eb3c070aedfb4fb50bea9710067cd", "score": "0.6549542", "text": "function buildCategories(categories){\n let list = $(\"<ul>\");\n for(var i =0; i < categories.length ; i++){\n let listItem = $(\"<li>\");\n listItem.text((categories[i].name).replace(\"Entertainment: \", \"\").replace(\"Science: \",\"\")).attr(\"data-id\",categories[i].id).addClass(\"categories\");\n list.append(listItem);\n }\n categoryList.append(list);\n }", "title": "" }, { "docid": "feea76ec6e504c5768babe18e9364d44", "score": "0.65473896", "text": "getMergedCategories() {\n var entityManager = ynab.YNABSharedLib.defaultInstance.entityManager;\n var mCats = entityManager.getAllNonTombstonedMasterCategories();\n\n subCategories.length = 0;\n\n for (var i = 0; i < mCats.length; i++) {\n var mCat = mCats[i];\n\n // Ignore certain categories!\n if (mCat.isHidden !== true && mCat.name !== 'Internal Master Category') {\n var tCats = entityManager.getSubCategoriesByMasterCategoryId(mCat.getEntityId());\n for (var j = 0; j < tCats.length; j++) {\n var subCategory = tCats[j];\n\n // Ignore certain categories!\n if (subCategory.isHidden !== true && !subCategory.isTombstone && subCategory.name !== 'Uncategorized Transactions') {\n subCategory.toolkitName = mCat.name + '_' + subCategory.name; // Add toolkit specific attribute\n subCategories.push(subCategory);\n }\n }\n }\n }\n\n return subCategories;\n }", "title": "" }, { "docid": "7cf3c0332ed3337f1368a3fc66991bb3", "score": "0.6546499", "text": "getCategories (offset, limit) {\n var self = this;\n return new Promise(function (resolve, fail) {\n self._request('GET', '/browse/categories', {\n offset: offset,\n limit: limit\n }).then(function (result) {\n resolve(result); \n }, function (err) {\n fail(err);\n });\n });\n }", "title": "" }, { "docid": "e438c4a66eed8fa83563b01ae95a9eed", "score": "0.65306026", "text": "function getCategorieen($scope) {\n $http.get(CATEGORIEEN_API_ENDPOINT.url + '/list').success(response => {\n $scope.categorieen = response.categorieen;\n });\n }", "title": "" }, { "docid": "32a75b786e85a6b8b16b9b0e9a8e47b6", "score": "0.6526867", "text": "async function fetchCategoriesFromAPI() {\n const data = await fetchData(TOTAL_CATEGORIES_URL);\n return data.trivia_categories;\n}", "title": "" }, { "docid": "f8fa2bd6fbf8a03edda1ab6c8cf5797c", "score": "0.6519668", "text": "async function fetchCategories() {\n\ttry {\n\t\tlet { data } = await axios.get('/api/categories.php')\n\n\t\t// Da parse para number no id e no parent\n\t\tdata = data.map(v => {\n\t\t\tv['id'] = +v['id']\n\t\t\tv['parent'] = +v['parent']\n\t\t\treturn v\n\t\t})\n\n\t\tfor (let v of data) {\n\t\t\tcategories.set(v.id, v)\n\t\t}\n\t} catch (err) {\n\t\tconsole.error('Error fetching categories:', err)\n\t}\n}", "title": "" }, { "docid": "7203456f9ac48252cef5cf122d6bf1d2", "score": "0.65156984", "text": "async function getListOfCategories() {\n return new Promise(function(resolve, reject) {\n mysql.pool.query(\"SELECT `categoryId`, `categoryName` FROM `Categories` INNER JOIN `Courses` ON `categoryId` = `categoryFk` WHERE `isLive` = 1 ORDER BY `categoryName` ASC;\", (err, rows, fields) => {\n if (err) {\n logIt(\"getListOfCategories() ERROR: \" + err);\n reject(\"ERROR in selecting courses\");\n }\n\n resolve(rows);\n });\n })\n}", "title": "" }, { "docid": "e0000b83b6e6cd92784414941dca42c5", "score": "0.65105546", "text": "function listarCategorias() {\n\t\t\n\t\t//Peticion AJAX de listas\n\t\t$.ajax({\n\t\t\turl: routeService + 'categorias.php',\n\t\t\ttype: \"GET\",\n\t\t\tsuccess: function (response) {\n\t\t\t\t\n\t\t\t\t//Variable almacenar respuesta\n\t\t\t\tlet jsonTask = response;\n\n\t\t\t\t//Plantilla para llenar los formularios\n\t\t\t\tlet template = '';\n\n\t\t\t\t//llenar plantilla con datos\n\t\t\t\tjsonTask.forEach(task => {\n\t\t\t\t\ttemplate += `\n\t\t\t\t<option value=${task.idCategoria}>${task.descripcion}</option>`\n\t\t\t\t});\n\n\t\t\t\t//Mostrar datos como opciones en formularios\n\t\t\t\t$(\"#book-idCat\").html(template);\n\t\t\t\t$(\"#book-s-idCat\").append(template);\n\t\t\t}\n\t\t})\n\t}", "title": "" }, { "docid": "0098c1e6a12e34f2420643b676250822", "score": "0.65041196", "text": "async index({ auth }) {\n const categories = await Category.query()\n .where('user_id', auth.current.user.id)\n .fetch()\n\n return categories\n }", "title": "" }, { "docid": "8b1bd20e45ea6f4e675e067120d08811", "score": "0.6492366", "text": "function getCategories(key) {\n\t\t\tvm.categories[key] = [];\n\t\t\temployerService.getCategories().then(function (response) {\n\t\t\t\tif (response.status == 200) {\n\t\t\t\t\tif (response.data.categories && response.data.categories.length > 0) {\n\t\t\t\t\t\tvm.primaryCat = response.data.categories;\n\t\t\t\t\t\tvm.originalCategoriesCount = response.data.categories.length;\n\t\t\t\t\t\tif (key == 0) {\n\t\t\t\t\t\t\tvm.categories[key] = response.data.categories;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvm.categories[key] = response.data.categories.filter(checkSelectedCategoryExists);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, function (error) {\n\t\t\t\ttoastr.error(error.data.error, 'Error');\n\t\t\t});\n\t\t} //END getCategories()", "title": "" }, { "docid": "7bdb23903c2367d7803d0d76b3d923d7", "score": "0.64850295", "text": "function getCategories(categories){\n categoryRef.once('value',snap=>{\n snap.forEach(subject=>{\n categories.push(subject.val().subject);\n });\n });\n}", "title": "" }, { "docid": "44bfc71bfb120f4a4a9ee34116dba60d", "score": "0.64801615", "text": "function getCategories (requestParams, sessionInfo, cb) {\n\n //todo validate parameters\n\n function apiDone(err, bundledResult) {\n if (!err) {\n cb.ok(bundledResult.formatResponse);\n }\n else {\n errorHandler.he_api_errorHandler (err, cb.error);\n }\n }\n\n var tasks = createTasks (requestParams, sessionInfo);\n aggregator.executeTasks(tasks, 0 /* requestId */, \"getCategories-Accedo\" /* midjetId */, sessionInfo.fc, apiDone);\n}", "title": "" }, { "docid": "2468fd8a662ea127b2c3417db921b758", "score": "0.647966", "text": "function allCategories(callback) {\n etc.startMongoDB('Categories', function (err, Categories, db) {\n if (err) return callback(err, null, null, null);\n Categories.find({}, {'_id': 1}).toArray(function (err, categories) {\n if (err) return callback(err, null, Categories, db);\n return callback(err, etc.primaryKeysList(categories), Categories, db);\n });\n });\n}", "title": "" }, { "docid": "d7d78920ad17e23bc36ef2c2234e0de2", "score": "0.6478102", "text": "async function getCategories() {\n await axios\n .get(dbCategories)\n .then(result => {\n setCategories(result.data);\n })\n .catch(error => {\n console.log(error);\n });\n }", "title": "" }, { "docid": "33af46981ca46c07279328f12d4776c6", "score": "0.64728546", "text": "function getAllCategories(req, res) {\n //get all of the genres\n var query = `\n SELECT DISTINCT category\n FROM Species\n ORDER BY category\n `;\n connection.execute(query, function (err, rows, fields) {\n if (err) console.log(\"Query error: \", err);\n else {\n console.log(rows.rows);\n res.json(rows.rows);\n }\n });\n}", "title": "" }, { "docid": "76771e0d076f55bdce24805ce3e83ee1", "score": "0.6468649", "text": "async obtenerCategorias() {\n //consultar categorias a la API de eventbrite\n const respuestaCategorias = await fetch\n (`https://www.eventbriteapi.com/v3/categories/?token=${this.token_auth}`);\n //esoerar respuesta y devolver el json\n const categorias = await respuestaCategorias.json();\n\n //devolvemos el resultado\n return {\n categorias\n }\n\n }", "title": "" }, { "docid": "5f5af2e6f0c8448f01783492e3c8efc2", "score": "0.6466348", "text": "getAppCategoryList ( category ) {\n const categoryLists = this.getAppsByCategory()\n\n return categoryLists[category]\n }", "title": "" }, { "docid": "f87c283d56cf4dd6fd0917e45dcaf329", "score": "0.64657944", "text": "function getCategories() {\n\t\t\tvar barData = [];\n\t\t\tvar catg = self.data.data;\n\t\t\tfor (var i=0 ; i < catg.length ; i++) {\n\t\t\t\tbarData.push([catg[i].category, catg[i].importance]);\n\t\t\t}\n\t\t\treturn barData;\n\t\t}", "title": "" }, { "docid": "c2085352b5f5042612ff2c54c77343f0", "score": "0.64601207", "text": "function getCategories({ from, to }) {\n return db.categories\n .filter((cat) => !cat.deleted)\n .offset(from)\n .limit(to - from + 1)\n .toArray();\n }", "title": "" }, { "docid": "a32329d03188a9fc602d6510558adc48", "score": "0.6444622", "text": "function populateCategories() {\n var currCategories = new Array();\n getCatList(function(cat){\n // i think this will only be the case if we saved cat...\n if(cat.categories) {\n currCategories = cat.categories;\n for(var i=0; i < currCategories.length; i++) {\n addCategoryToPanel(currCategories[i]);\n }\n }\n });\n}", "title": "" }, { "docid": "4aad6da8347f3df33e579a53d07e3b9d", "score": "0.64410347", "text": "listCategories(parent, { listId }) {\n\t\t\treturn InterestCategoryModel.byList(listId);\n\t\t}", "title": "" }, { "docid": "cbfad5d08bd7498c122ee55d742bff5e", "score": "0.64347255", "text": "async getCategories(){\n\t\ttry {\n\t\t\tconst response = await fetch(this.URL + \"/images/category\");\n\n\t\tif(response.status==200){\n\t\t\tconst responseParse = await response.json()\n\t\t\treturn new Promise((res,rej)=>{\n\t\t\t\tres(responseParse)\n\t\t\t})\n\t\t}else\n\t\t\treturn null;\n\n\t\t}catch(e) {\n\t\t\tconsole.log(e);\n\t\t}\n\t}", "title": "" }, { "docid": "1774f6004a2e051fdb251c14fc5c2cbc", "score": "0.6425637", "text": "function constructCategoryArray() {\n let categoryContainers = document.getElementsByClassName('category-container');\n\n let categoryArray = [];\n for (let categoryContainer of categoryContainers) {\n categoryArray.push({\n id: categoryContainer.categoryData.id,\n title: categoryContainer.categoryData.title\n });\n }\n return categoryArray;\n }", "title": "" }, { "docid": "3c7aaeb928b9c1e63a7c7dbbce69364b", "score": "0.6424499", "text": "function getCategories(data) {\n let category = {};\n if(data === \"Electronics\") {\n category.top = ['Phones', 'Tables', 'TV', 'Gaming', 'Headphones'];\n category.addition = ['Printers', 'Fitness Tracker', 'Cameras']\n \n }\n if(data === \"Furniture\") {\n category.top = ['Couch', 'Mattress', 'Chairs', 'Patio'];\n category.addition = ['Kitchen', 'Bedroom', 'Living Room']\n }\n if(data === \"Toys\") {\n category.top = ['LEGO', 'Puzzles', 'Arts', 'Board Games'];\n category.addition = ['Bikes', 'Hover Board', 'Plush Toys']\n }\n return category;\n}", "title": "" }, { "docid": "abc7a1718b2963eb40cd76ac37dbe0a1", "score": "0.6412496", "text": "get categories() {\n return this.args.categories || this.args.settings || [];\n }", "title": "" }, { "docid": "88c2752e3d809023c926385297edbf33", "score": "0.64120007", "text": "function getAllCategory(){\n\n modelListCategory.clear();\n var db = getDatabase();\n \n db.transaction(function(tx) {\n var rs = tx.executeSql('select c.id, c.cat_name, r.current_amount from category c left join category_report_current r where r.id_category = c.id');\n for(var i =0;i < rs.rows.length;i++){\n modelListCategory.append(rs.rows.item(i));\n }\n }\n );\n }", "title": "" }, { "docid": "318a76be62149adc4aa9f76f221b3fa5", "score": "0.64004236", "text": "async getCategoriesAPI(){\n\n // Query the API\n const urlResponse = await fetch(`https://www.eventbriteapi.com/v3/categories/?token=${this.auth_token}`);\n\n //Hold for the response and then return as json\n const categories = await urlResponse.json();\n\n // return the categories object\n\n return {\n categories\n }\n }", "title": "" }, { "docid": "778bf1fde851ae98d6b735e3d2a81197", "score": "0.6391281", "text": "function Categories (barset) {\n try {\n var retValue = [\n { CategoryID: 215, CategoryName: \"Beer/Wine\", Count: 5 },\n { CategoryID: 558, CategoryName: \"Hot Drinks\", Count: 7 },\n { CategoryID: 401, CategoryName: \"Snacks\", Count: 4 },\n { CategoryID: 85, CategoryName: \"Soft Drinks\", Count: 3 },\n { CategoryID: 87, CategoryName: \"Fruit\", Count: 10 },\n { CategoryID: 214, CategoryName: \"Spirits\", Count: 6 }\n ];\n return retValue;\n }\n catch (err) {\n ex.Log(err, this.Name + \".Categories(Barset:\" + barset + \")\");\n return [];\n }\n }", "title": "" }, { "docid": "9ea8d9729966d3eac111dc46bf37a5b3", "score": "0.63572645", "text": "function getAccountingCategoryList(){\n api.expenseAccountSetting.getAccountingCategoryList()\n .success(function(data){\n //$scope.categoryList = data;\n $scope.categoryList = [];\n _.forEach(data,function(item){\n $scope.categoryList.push({id:item.code,name:item.name,code:item.code});\n\n });\n });\n }", "title": "" }, { "docid": "3b000bdd0649313d45ad2ebee856d282", "score": "0.6356455", "text": "function getCategoryListData(request, content, callback) {\n\t/* Prepare Queries */\n\tvar sqlAllItemsFromList = 'SELECT id, name, position FROM category order by position';\n\t//console.log(req);\n\tvar sql = mysql.format(sqlAllItemsFromList);\n\tpool.query(sql, function(err, rows, fields) {\n\t\tif (err) callback(err);\n\t\t//console.log(rows);\n\t\tcallback(null, rows);\n\t});\n}", "title": "" }, { "docid": "5642d83df5e6363d787a30dcc8795de8", "score": "0.6352401", "text": "function listCategories(){\n for (var key in categories) {\n // check if the property/key is defined in the object itself, not in parent\n if (categories.hasOwnProperty(key)) {\n document.getElementById(\"category_list\").innerHTML += key.toString()+\" \";\n }\n }\n }", "title": "" }, { "docid": "9ecf97ceaeb6f78489a8578d7016753f", "score": "0.63192695", "text": "function loadCategories() {\r\n categoryDataFactory.getAll()\r\n .success(function (data) {\r\n $scope.leftBarCategories = data;\r\n });\r\n }", "title": "" }, { "docid": "c3c51a1c4ccc0a666df791a1dda095c4", "score": "0.6316327", "text": "function getCategories(parentId)\n{\n\tconsole.log(\"Function :: getCategories, for parentId - \" + parentId);\t\n\tvar rest = new Object();\n\tvar restURL = webServerIP+\"/PSAP/Categories?type=CATEGORY&parentId=\" + parentId;\n\tgetRESTRequest(restURL,true);\n}", "title": "" }, { "docid": "4e982fe843044e707bc7bb37ce27f6e6", "score": "0.6313508", "text": "function getAllCategories(){\n\tvar records_array = [];\n\treturn new Promise(function(resolve, reject) {\n\t\tbase('Business Category').select({\n\t\tview: \"View - Customer Business Categories\"\n\t}).eachPage(function page(records, fetchNextPage) {\n\t\tconsole.log( records.length );\n\t\trecords.forEach(function(record) {\n\t\t\t//==== create array of values and send back to http request\n\t\t\trecords_array.push({\n\t\t\t\t'BusinessRef' : record.get('Business Ref'),\n\t\t\t\t'BusinessType' : record.get('BusinessType')\n\t\t\t}); \n\t\t});\n\t\tfetchNextPage();\n\t\tif( records_array.length > 100 ){\n\t\t\tresolve(records_array);\n\t\t}\n\t}, function done(err) {\n\t\tif (err) { console.error(err); return; }\n\t});\n\t\t \n\t\n\t})\n}", "title": "" } ]
a3807b76b861d44aa4f641d53b5dba6c
Add as transformed class selector(s), then remove the deprecated attribute selector
[ { "docid": "cf2274f28fef638ced9fef2a74328d90", "score": "0.0", "text": "function translateWithValueToCssClass(scope, element, attrs) {\n var updateFn = updateClassWithValue(element, className, attrs);\n var unwatch = attrs.$observe(attrs.$normalize(className), updateFn);\n\n updateFn(getNormalizedAttrValue(className, attrs, \"\"));\n scope.$on(\"$destroy\", function() { unwatch(); });\n }", "title": "" } ]
[ { "docid": "695ac70040ff263347af176aaf899984", "score": "0.65910447", "text": "function addNewSelectors() {\n var elements = document.querySelectorAll(oldSelectors.join());\n var elementsLen = elements.length;\n\n while (elementsLen--) {\n var element = elements[elementsLen];\n\n element.className = element.className\n // Agrega el nuevo selector al className del elemento con la clase antigua\n .replace(OLD_SELECTORS_REGEX, function (_) {\n var space = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n var oldSelector = arguments[2];\n var size = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';\n\n return space\n // Antiguo selector\n + oldSelector + size + ' '\n // Nuevo selector\n + selectors[oldSelector] + size;\n });\n }\n }", "title": "" }, { "docid": "5adb0d436a12d9f26abc814fa99ca264", "score": "0.61957586", "text": "_cleanClassAttribute() {\n const classList = this.classList;\n\n Array.apply(null, this.classList).filter(klass => {\n return klass === 'fa' || klass.indexOf('fa-') === 0 || klass.indexOf('ion-') === 0 || klass.indexOf('zmdi-') === 0;\n }).forEach(className => {\n classList.remove(className);\n });\n\n classList.remove('zmdi');\n classList.remove('ons-icon--ion');\n }", "title": "" }, { "docid": "ef3dc9ac8ba7218992e77240bdaa8a85", "score": "0.60741466", "text": "_cleanClassAttribute() {\n util.arrayFrom(this.classList)\n .filter(className => /^(fa$|fa-|ion-|zmdi-)/.test(className))\n .forEach(className => this.classList.remove(className));\n\n this.classList.remove('zmdi');\n this.classList.remove('ons-icon--ion');\n }", "title": "" }, { "docid": "451c6ea2ed1769fdba307a6e409dfac3", "score": "0.6044793", "text": "function attributeWithoutValue(className) {\n return ['$mdUtil', '$interpolate', \"$log\", function(_$mdUtil_, _$interpolate_, _$log_) {\n $mdUtil = _$mdUtil_;\n $interpolate = _$interpolate_;\n $log = _$log_;\n\n return {\n restrict: 'A',\n compile: function(element, attr) {\n var linkFn;\n if (config.enabled) {\n // immediately replace static (non-interpolated) invalid values...\n\n validateAttributeValue( className,\n getNormalizedAttrValue(className, attr, \"\"),\n buildUpdateFn(element, className, attr)\n );\n\n translateToCssClass(null, element);\n\n // Use for postLink to account for transforms after ng-transclude.\n linkFn = translateToCssClass;\n }\n\n return linkFn || angular.noop;\n }\n };\n }];\n\n /**\n * Add as transformed class selector, then\n * remove the deprecated attribute selector\n */\n function translateToCssClass(scope, element) {\n element.addClass(className);\n }\n }", "title": "" }, { "docid": "451c6ea2ed1769fdba307a6e409dfac3", "score": "0.6044793", "text": "function attributeWithoutValue(className) {\n return ['$mdUtil', '$interpolate', \"$log\", function(_$mdUtil_, _$interpolate_, _$log_) {\n $mdUtil = _$mdUtil_;\n $interpolate = _$interpolate_;\n $log = _$log_;\n\n return {\n restrict: 'A',\n compile: function(element, attr) {\n var linkFn;\n if (config.enabled) {\n // immediately replace static (non-interpolated) invalid values...\n\n validateAttributeValue( className,\n getNormalizedAttrValue(className, attr, \"\"),\n buildUpdateFn(element, className, attr)\n );\n\n translateToCssClass(null, element);\n\n // Use for postLink to account for transforms after ng-transclude.\n linkFn = translateToCssClass;\n }\n\n return linkFn || angular.noop;\n }\n };\n }];\n\n /**\n * Add as transformed class selector, then\n * remove the deprecated attribute selector\n */\n function translateToCssClass(scope, element) {\n element.addClass(className);\n }\n }", "title": "" }, { "docid": "451c6ea2ed1769fdba307a6e409dfac3", "score": "0.6044793", "text": "function attributeWithoutValue(className) {\n return ['$mdUtil', '$interpolate', \"$log\", function(_$mdUtil_, _$interpolate_, _$log_) {\n $mdUtil = _$mdUtil_;\n $interpolate = _$interpolate_;\n $log = _$log_;\n\n return {\n restrict: 'A',\n compile: function(element, attr) {\n var linkFn;\n if (config.enabled) {\n // immediately replace static (non-interpolated) invalid values...\n\n validateAttributeValue( className,\n getNormalizedAttrValue(className, attr, \"\"),\n buildUpdateFn(element, className, attr)\n );\n\n translateToCssClass(null, element);\n\n // Use for postLink to account for transforms after ng-transclude.\n linkFn = translateToCssClass;\n }\n\n return linkFn || angular.noop;\n }\n };\n }];\n\n /**\n * Add as transformed class selector, then\n * remove the deprecated attribute selector\n */\n function translateToCssClass(scope, element) {\n element.addClass(className);\n }\n }", "title": "" }, { "docid": "451c6ea2ed1769fdba307a6e409dfac3", "score": "0.6044793", "text": "function attributeWithoutValue(className) {\n return ['$mdUtil', '$interpolate', \"$log\", function(_$mdUtil_, _$interpolate_, _$log_) {\n $mdUtil = _$mdUtil_;\n $interpolate = _$interpolate_;\n $log = _$log_;\n\n return {\n restrict: 'A',\n compile: function(element, attr) {\n var linkFn;\n if (config.enabled) {\n // immediately replace static (non-interpolated) invalid values...\n\n validateAttributeValue( className,\n getNormalizedAttrValue(className, attr, \"\"),\n buildUpdateFn(element, className, attr)\n );\n\n translateToCssClass(null, element);\n\n // Use for postLink to account for transforms after ng-transclude.\n linkFn = translateToCssClass;\n }\n\n return linkFn || angular.noop;\n }\n };\n }];\n\n /**\n * Add as transformed class selector, then\n * remove the deprecated attribute selector\n */\n function translateToCssClass(scope, element) {\n element.addClass(className);\n }\n }", "title": "" }, { "docid": "451c6ea2ed1769fdba307a6e409dfac3", "score": "0.6044793", "text": "function attributeWithoutValue(className) {\n return ['$mdUtil', '$interpolate', \"$log\", function(_$mdUtil_, _$interpolate_, _$log_) {\n $mdUtil = _$mdUtil_;\n $interpolate = _$interpolate_;\n $log = _$log_;\n\n return {\n restrict: 'A',\n compile: function(element, attr) {\n var linkFn;\n if (config.enabled) {\n // immediately replace static (non-interpolated) invalid values...\n\n validateAttributeValue( className,\n getNormalizedAttrValue(className, attr, \"\"),\n buildUpdateFn(element, className, attr)\n );\n\n translateToCssClass(null, element);\n\n // Use for postLink to account for transforms after ng-transclude.\n linkFn = translateToCssClass;\n }\n\n return linkFn || angular.noop;\n }\n };\n }];\n\n /**\n * Add as transformed class selector, then\n * remove the deprecated attribute selector\n */\n function translateToCssClass(scope, element) {\n element.addClass(className);\n }\n }", "title": "" }, { "docid": "864b8b449a65ef608d5a70a5e085fec7", "score": "0.59953153", "text": "function attributeWithoutValue(className) {\r\n return ['$mdUtil', '$interpolate', \"$log\", function(_$mdUtil_, _$interpolate_, _$log_) {\r\n $mdUtil = _$mdUtil_;\r\n $interpolate = _$interpolate_;\r\n $log = _$log_;\r\n\r\n return {\r\n restrict: 'A',\r\n compile: function(element, attr) {\r\n var linkFn;\r\n if (config.enabled) {\r\n // immediately replace static (non-interpolated) invalid values...\r\n\r\n validateAttributeValue( className,\r\n getNormalizedAttrValue(className, attr, \"\"),\r\n buildUpdateFn(element, className, attr)\r\n );\r\n\r\n translateToCssClass(null, element);\r\n\r\n // Use for postLink to account for transforms after ng-transclude.\r\n linkFn = translateToCssClass;\r\n }\r\n\r\n return linkFn || angular.noop;\r\n }\r\n };\r\n }];\r\n\r\n /**\r\n * Add as transformed class selector, then\r\n * remove the deprecated attribute selector\r\n */\r\n function translateToCssClass(scope, element) {\r\n element.addClass(className);\r\n }\r\n }", "title": "" }, { "docid": "dd4cb8ca9671b72e9991de817516b264", "score": "0.566198", "text": "function _handleAttributes(oldNode, newNode, rule, clearInternals) {\n var attributes = {}, // fresh new set of attributes to set on newNode\n setClass = rule.set_class, // classes to set\n addClass = rule.add_class, // add classes based on existing attributes\n addStyle = rule.add_style, // add styles based on existing attributes\n setAttributes = rule.set_attributes, // attributes to set on the current node\n allowedClasses = currentRules.classes,\n i = 0,\n classes = [],\n styles = [],\n newClasses = [],\n oldClasses = [],\n classesLength,\n newClassesLength,\n currentClass,\n newClass,\n attributeName,\n method;\n\n if (setAttributes) {\n attributes = wysihtml5.lang.object(setAttributes).clone();\n }\n\n // check/convert values of attributes\n attributes = wysihtml5.lang.object(attributes).merge(_checkAttributes(oldNode, rule.check_attributes)).get();\n\n if (setClass) {\n classes.push(setClass);\n }\n\n if (addClass) {\n for (attributeName in addClass) {\n method = addClassMethods[addClass[attributeName]];\n if (!method) {\n continue;\n }\n newClass = method(wysihtml5.dom.getAttribute(oldNode, attributeName));\n if (typeof(newClass) === \"string\") {\n classes.push(newClass);\n }\n }\n }\n\n if (addStyle) {\n for (attributeName in addStyle) {\n method = addStyleMethods[addStyle[attributeName]];\n if (!method) {\n continue;\n }\n\n newStyle = method(wysihtml5.dom.getAttribute(oldNode, attributeName));\n if (typeof(newStyle) === \"string\") {\n styles.push(newStyle);\n }\n }\n }\n\n\n if (typeof(allowedClasses) === \"string\" && allowedClasses === \"any\" && oldNode.getAttribute(\"class\")) {\n if (currentRules.classes_blacklist) {\n oldClasses = oldNode.getAttribute(\"class\");\n if (oldClasses) {\n classes = classes.concat(oldClasses.split(WHITE_SPACE_REG_EXP));\n }\n\n classesLength = classes.length;\n for (; i<classesLength; i++) {\n currentClass = classes[i];\n if (!currentRules.classes_blacklist[currentClass]) {\n newClasses.push(currentClass);\n }\n }\n\n if (newClasses.length) {\n attributes[\"class\"] = wysihtml5.lang.array(newClasses).unique().join(\" \");\n }\n\n } else {\n attributes[\"class\"] = oldNode.getAttribute(\"class\");\n }\n } else {\n // make sure that wysihtml5 temp class doesn't get stripped out\n if (!clearInternals) {\n allowedClasses[\"_wysihtml5-temp-placeholder\"] = 1;\n allowedClasses[\"_rangySelectionBoundary\"] = 1;\n allowedClasses[\"wysiwyg-tmp-selected-cell\"] = 1;\n }\n\n // add old classes last\n oldClasses = oldNode.getAttribute(\"class\");\n if (oldClasses) {\n classes = classes.concat(oldClasses.split(WHITE_SPACE_REG_EXP));\n }\n classesLength = classes.length;\n for (; i<classesLength; i++) {\n currentClass = classes[i];\n if (allowedClasses[currentClass]) {\n newClasses.push(currentClass);\n }\n }\n\n if (newClasses.length) {\n attributes[\"class\"] = wysihtml5.lang.array(newClasses).unique().join(\" \");\n }\n }\n\n // remove table selection class if present\n if (attributes[\"class\"] && clearInternals) {\n attributes[\"class\"] = attributes[\"class\"].replace(\"wysiwyg-tmp-selected-cell\", \"\");\n if ((/^\\s*$/g).test(attributes[\"class\"])) {\n delete attributes[\"class\"];\n }\n }\n\n if (styles.length) {\n attributes[\"style\"] = wysihtml5.lang.array(styles).unique().join(\" \");\n }\n\n // set attributes on newNode\n for (attributeName in attributes) {\n // Setting attributes can cause a js error in IE under certain circumstances\n // eg. on a <img> under https when it's new attribute value is non-https\n // TODO: Investigate this further and check for smarter handling\n try {\n newNode.setAttribute(attributeName, attributes[attributeName]);\n } catch(e) {}\n }\n\n // IE8 sometimes loses the width/height attributes when those are set before the \"src\"\n // so we make sure to set them again\n if (attributes.src) {\n if (typeof(attributes.width) !== \"undefined\") {\n newNode.setAttribute(\"width\", attributes.width);\n }\n if (typeof(attributes.height) !== \"undefined\") {\n newNode.setAttribute(\"height\", attributes.height);\n }\n }\n }", "title": "" }, { "docid": "44f9a6feabea24afa756fac028912de9", "score": "0.56386226", "text": "function _handleAttributes(oldNode, newNode, rule, clearInternals) {\r\n var attributes = {}, // fresh new set of attributes to set on newNode\r\n setClass = rule.set_class, // classes to set\r\n addClass = rule.add_class, // add classes based on existing attributes\r\n addStyle = rule.add_style, // add styles based on existing attributes\r\n setAttributes = rule.set_attributes, // attributes to set on the current node\r\n allowedClasses = currentRules.classes,\r\n i = 0,\r\n classes = [],\r\n styles = [],\r\n newClasses = [],\r\n oldClasses = [],\r\n classesLength,\r\n newClassesLength,\r\n currentClass,\r\n newClass,\r\n attributeName,\r\n method;\r\n\r\n if (setAttributes) {\r\n attributes = wysihtml5.lang.object(setAttributes).clone();\r\n }\r\n\r\n // check/convert values of attributes\r\n attributes = wysihtml5.lang.object(attributes).merge(_checkAttributes(oldNode, rule.check_attributes)).get();\r\n\r\n if (setClass) {\r\n classes.push(setClass);\r\n }\r\n\r\n if (addClass) {\r\n for (attributeName in addClass) {\r\n method = addClassMethods[addClass[attributeName]];\r\n if (!method) {\r\n continue;\r\n }\r\n newClass = method(wysihtml5.dom.getAttribute(oldNode, attributeName));\r\n if (typeof(newClass) === \"string\") {\r\n classes.push(newClass);\r\n }\r\n }\r\n }\r\n\r\n if (addStyle) {\r\n for (attributeName in addStyle) {\r\n method = addStyleMethods[addStyle[attributeName]];\r\n if (!method) {\r\n continue;\r\n }\r\n\r\n newStyle = method(wysihtml5.dom.getAttribute(oldNode, attributeName));\r\n if (typeof(newStyle) === \"string\") {\r\n styles.push(newStyle);\r\n }\r\n }\r\n }\r\n\r\n\r\n if (typeof(allowedClasses) === \"string\" && allowedClasses === \"any\" && oldNode.getAttribute(\"class\")) {\r\n if (currentRules.classes_blacklist) {\r\n oldClasses = oldNode.getAttribute(\"class\");\r\n if (oldClasses) {\r\n classes = classes.concat(oldClasses.split(WHITE_SPACE_REG_EXP));\r\n }\r\n\r\n classesLength = classes.length;\r\n for (; i<classesLength; i++) {\r\n currentClass = classes[i];\r\n if (!currentRules.classes_blacklist[currentClass]) {\r\n newClasses.push(currentClass);\r\n }\r\n }\r\n\r\n if (newClasses.length) {\r\n attributes[\"class\"] = wysihtml5.lang.array(newClasses).unique().join(\" \");\r\n }\r\n\r\n } else {\r\n attributes[\"class\"] = oldNode.getAttribute(\"class\");\r\n }\r\n } else {\r\n // make sure that wysihtml5 temp class doesn't get stripped out\r\n if (!clearInternals) {\r\n allowedClasses[\"_wysihtml5-temp-placeholder\"] = 1;\r\n allowedClasses[\"_rangySelectionBoundary\"] = 1;\r\n allowedClasses[\"wysiwyg-tmp-selected-cell\"] = 1;\r\n }\r\n\r\n // add old classes last\r\n oldClasses = oldNode.getAttribute(\"class\");\r\n if (oldClasses) {\r\n classes = classes.concat(oldClasses.split(WHITE_SPACE_REG_EXP));\r\n }\r\n classesLength = classes.length;\r\n for (; i<classesLength; i++) {\r\n currentClass = classes[i];\r\n if (allowedClasses[currentClass]) {\r\n newClasses.push(currentClass);\r\n }\r\n }\r\n\r\n if (newClasses.length) {\r\n attributes[\"class\"] = wysihtml5.lang.array(newClasses).unique().join(\" \");\r\n }\r\n }\r\n\r\n // remove table selection class if present\r\n if (attributes[\"class\"] && clearInternals) {\r\n attributes[\"class\"] = attributes[\"class\"].replace(\"wysiwyg-tmp-selected-cell\", \"\");\r\n if ((/^\\s*$/g).test(attributes[\"class\"])) {\r\n delete attributes[\"class\"];\r\n }\r\n }\r\n\r\n if (styles.length) {\r\n attributes[\"style\"] = wysihtml5.lang.array(styles).unique().join(\" \");\r\n }\r\n\r\n // set attributes on newNode\r\n for (attributeName in attributes) {\r\n // Setting attributes can cause a js error in IE under certain circumstances\r\n // eg. on a <img> under https when it's new attribute value is non-https\r\n // TODO: Investigate this further and check for smarter handling\r\n try {\r\n newNode.setAttribute(attributeName, attributes[attributeName]);\r\n } catch(e) {}\r\n }\r\n\r\n // IE8 sometimes loses the width/height attributes when those are set before the \"src\"\r\n // so we make sure to set them again\r\n if (attributes.src) {\r\n if (typeof(attributes.width) !== \"undefined\") {\r\n newNode.setAttribute(\"width\", attributes.width);\r\n }\r\n if (typeof(attributes.height) !== \"undefined\") {\r\n newNode.setAttribute(\"height\", attributes.height);\r\n }\r\n }\r\n }", "title": "" }, { "docid": "6cd61011fd29e7d9ef05be73d21a23b8", "score": "0.5629224", "text": "function classStripper(idList, className, aaIto){\n let l = idList\n for (let i = 0; i < l.length; i++) {\n e(l[i]).classList.remove(className)\n }\n if (aaIto) { e(aaIto).classList.add(className) }\n}", "title": "" }, { "docid": "3da66425670c437f9f522f040801e069", "score": "0.55914927", "text": "function addInternalSelectors(){\n //adding internal class names to void problem with common ones\n $(options.sectionSelector).each(function(){\n $(this).addClass(SECTION);\n });\n $(options.slideSelector).each(function(){\n $(this).addClass(SLIDE);\n });\n }", "title": "" }, { "docid": "3da66425670c437f9f522f040801e069", "score": "0.55914927", "text": "function addInternalSelectors(){\n //adding internal class names to void problem with common ones\n $(options.sectionSelector).each(function(){\n $(this).addClass(SECTION);\n });\n $(options.slideSelector).each(function(){\n $(this).addClass(SLIDE);\n });\n }", "title": "" }, { "docid": "3da66425670c437f9f522f040801e069", "score": "0.55914927", "text": "function addInternalSelectors(){\n //adding internal class names to void problem with common ones\n $(options.sectionSelector).each(function(){\n $(this).addClass(SECTION);\n });\n $(options.slideSelector).each(function(){\n $(this).addClass(SLIDE);\n });\n }", "title": "" }, { "docid": "ccd1940722fbd2510b0e68e121d720f2", "score": "0.5562753", "text": "classRemove(className) {\n\n // Starter className\n let started = this.className,\n cl = className,\n\n // Goint to array :D\n replaced = cl.replace(' ', ',').split(','),\n replaced2 = started.trim().replace(' ', ',').split(',');\n\n\n\n for(let i = 0 ; i < replaced.length ; i++) {\n let r = replaced[i];\n\n for(let j = 0 ; j < replaced2.length ; j++) {\n let k = replaced2[j]\n\n // If classNames are same - remove this\n if(r == k) {\n replaced2[j] = ''\n }\n }\n }\n\n let finale = \"\"\n\n // Finale = all replaced array which alive\n for(let i = 0 ; i < replaced2.length ;i++) {\n finale += replaced2[i]\n }\n\n this.className = finale;\n\n // Return this element for chain calling function\n return this;\n }", "title": "" }, { "docid": "ae255c7320108871ddb107f69a9983ae", "score": "0.55437493", "text": "function patchClass(el, value, isSVG) {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');\n }\n if (value == null) {\n el.removeAttribute('class');\n } else if (isSVG) {\n el.setAttribute('class', value);\n } else {\n el.className = value;\n }\n}", "title": "" }, { "docid": "539110813bffc8707ffacd969c7de6b3", "score": "0.5529361", "text": "function patchClass(el, value, isSVG) {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');\n }\n if (value == null) {\n el.removeAttribute('class');\n }\n else if (isSVG) {\n el.setAttribute('class', value);\n }\n else {\n el.className = value;\n }\n}", "title": "" }, { "docid": "539110813bffc8707ffacd969c7de6b3", "score": "0.5529361", "text": "function patchClass(el, value, isSVG) {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');\n }\n if (value == null) {\n el.removeAttribute('class');\n }\n else if (isSVG) {\n el.setAttribute('class', value);\n }\n else {\n el.className = value;\n }\n}", "title": "" }, { "docid": "539110813bffc8707ffacd969c7de6b3", "score": "0.5529361", "text": "function patchClass(el, value, isSVG) {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');\n }\n if (value == null) {\n el.removeAttribute('class');\n }\n else if (isSVG) {\n el.setAttribute('class', value);\n }\n else {\n el.className = value;\n }\n}", "title": "" }, { "docid": "539110813bffc8707ffacd969c7de6b3", "score": "0.5529361", "text": "function patchClass(el, value, isSVG) {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');\n }\n if (value == null) {\n el.removeAttribute('class');\n }\n else if (isSVG) {\n el.setAttribute('class', value);\n }\n else {\n el.className = value;\n }\n}", "title": "" }, { "docid": "539110813bffc8707ffacd969c7de6b3", "score": "0.5529361", "text": "function patchClass(el, value, isSVG) {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');\n }\n if (value == null) {\n el.removeAttribute('class');\n }\n else if (isSVG) {\n el.setAttribute('class', value);\n }\n else {\n el.className = value;\n }\n}", "title": "" }, { "docid": "2079fb58f35bbb7e1d8808f98ca6eaba", "score": "0.5520178", "text": "function patchClass(el, value, isSVG) {\r\n // directly setting className should be faster than setAttribute in theory\r\n // if this is an element during a transition, take the temporary transition\r\n // classes into account.\r\n const transitionClasses = el._vtc;\r\n if (transitionClasses) {\r\n value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');\r\n }\r\n if (value == null) {\r\n el.removeAttribute('class');\r\n }\r\n else if (isSVG) {\r\n el.setAttribute('class', value);\r\n }\r\n else {\r\n el.className = value;\r\n }\r\n}", "title": "" }, { "docid": "7aed8835d3aae048bd33236e55e0014b", "score": "0.55069876", "text": "removeClass(className) {\n\t const classList = this.attr(\"class\").split(\" \");\n\t const newClassList = [];\n\t classList.forEach(oldClass => {\n\t if (oldClass !== className) { newClassList.push(oldClass); }\n\t });\n\t this.attr(\"class\", newClassList.join(' '));\n\t }", "title": "" }, { "docid": "4fec3a1d1cc94f95fb008ff18eb0b786", "score": "0.54951274", "text": "function setClasses( classes ) {\n var className = docElement.className;\n var classPrefix = Modernizr._config.classPrefix || '';\n\n if (isSVG) {\n className = className.baseVal;\n }\n\n // Change `no-js` to `js` (we do this independently of the `enableClasses`\n // option)\n // Handle classPrefix on this too\n if(Modernizr._config.enableJSClass) {\n var reJS = new RegExp('(^|\\\\s)'+classPrefix+'no-js(\\\\s|$)');\n className = className.replace(reJS, '$1'+classPrefix+'js$2');\n }\n\n if(Modernizr._config.enableClasses) {\n // Add the new classes\n className += ' ' + classPrefix + classes.join(' ' + classPrefix);\n isSVG ? docElement.className.baseVal = className : docElement.className = className;\n }\n\n }", "title": "" }, { "docid": "4699e284a16cdb65751d38a02841b03a", "score": "0.5472125", "text": "preprocess (selected) {\n let add = {\n 'selectors': [],\n '@supports': new Supports(Prefixes, this)\n }\n for (let name in selected.add) {\n let prefixes = selected.add[name]\n if (name === '@keyframes' || name === '@viewport') {\n add[name] = new AtRule(name, prefixes, this)\n } else if (name === '@resolution') {\n add[name] = new Resolution(name, prefixes, this)\n } else if (this.data[name].selector) {\n add.selectors.push(Selector.load(name, prefixes, this))\n } else {\n let props = this.data[name].props\n\n if (props) {\n let value = Value.load(name, prefixes, this)\n for (let prop of props) {\n if (!add[prop]) {\n add[prop] = { values: [] }\n }\n add[prop].values.push(value)\n }\n } else {\n let values = (add[name] && add[name].values) || []\n add[name] = Declaration.load(name, prefixes, this)\n add[name].values = values\n }\n }\n }\n\n let remove = { selectors: [] }\n for (let name in selected.remove) {\n let prefixes = selected.remove[name]\n if (this.data[name].selector) {\n let selector = Selector.load(name, prefixes)\n for (let prefix of prefixes) {\n remove.selectors.push(selector.old(prefix))\n }\n } else if (name === '@keyframes' || name === '@viewport') {\n for (let prefix of prefixes) {\n let prefixed = `@${prefix}${name.slice(1)}`\n remove[prefixed] = { remove: true }\n }\n } else if (name === '@resolution') {\n remove[name] = new Resolution(name, prefixes, this)\n } else {\n let props = this.data[name].props\n if (props) {\n let value = Value.load(name, [], this)\n for (let prefix of prefixes) {\n let old = value.old(prefix)\n if (old) {\n for (let prop of props) {\n if (!remove[prop]) {\n remove[prop] = {}\n }\n if (!remove[prop].values) {\n remove[prop].values = []\n }\n remove[prop].values.push(old)\n }\n }\n }\n } else {\n for (let p of prefixes) {\n let olds = this.decl(name).old(name, p)\n if (name === 'align-self') {\n let a = add[name] && add[name].prefixes\n if (a) {\n if (p === '-webkit- 2009' && a.includes('-webkit-')) {\n continue\n } else if (p === '-webkit-' && a.includes('-webkit- 2009')) {\n continue\n }\n }\n }\n for (let prefixed of olds) {\n if (!remove[prefixed]) {\n remove[prefixed] = {}\n }\n remove[prefixed].remove = true\n }\n }\n }\n }\n }\n\n return [add, remove]\n }", "title": "" }, { "docid": "1402134a9a0999abd153bef49df4dd3f", "score": "0.5461749", "text": "function _tag_classname_change() {\n app.specimen[app.selectedTagIndex].class = app.specimen[app.selectedTagIndex].class.replace(/ /g, '-');\n\n var blockSelector = app.currentselector;\n var newBlockSelector = app.specimen[app.selectedTagIndex].class;\n\n for (var bp in app.breakpoints) {\n var thisBp = app.breakpoints[bp];\n\n /**\n * Element was assigned an existing class\n */\n if (thisBp.styles[newBlockSelector]) {\n /**\n * Remove previous class if not used elsewhere\n */\n\n if( _isUnusedClass(blockSelector) ) {\n delete thisBp.styles[blockSelector];\n }\n }\n\n /**\n * Element was assigned a new class\n * Clonse previous styles into the new class\n * then, remove the previous class\n */\n else if (thisBp.styles[blockSelector]) {\n thisBp.styles[newBlockSelector] = Object.assign({}, thisBp.styles[blockSelector]);\n\n if( _isUnusedClass(blockSelector) ) {\n delete thisBp.styles[blockSelector];\n }\n }\n }\n\n app.$forceUpdate();\n _tag_select(app.selectedTagIndex);\n}", "title": "" }, { "docid": "31a3398f44afa11b415b552c3c3b610a", "score": "0.5436682", "text": "function setCssClass(cssClass, elements, oldClass) {\n if (!Object(_syncfusion_ej2_base__WEBPACK_IMPORTED_MODULE_0__[\"isNullOrUndefined\"])(oldClass) && oldClass !== '') {\n Object(_syncfusion_ej2_base__WEBPACK_IMPORTED_MODULE_0__[\"removeClass\"])(elements, oldClass.split(' '));\n }\n if (!Object(_syncfusion_ej2_base__WEBPACK_IMPORTED_MODULE_0__[\"isNullOrUndefined\"])(cssClass) && cssClass !== '') {\n Object(_syncfusion_ej2_base__WEBPACK_IMPORTED_MODULE_0__[\"addClass\"])(elements, cssClass.split(' '));\n }\n }", "title": "" }, { "docid": "2b38709777108f834b58120db7157016", "score": "0.54021895", "text": "function removeClasses() {\n theString.removeAttribute(\"class\");\n}", "title": "" }, { "docid": "b1d23aa494c0121591b4b90c3847efc8", "score": "0.53926134", "text": "_removeClass(className) {\n this.container.className = _(this.container.className.split(' '))\n .without(className)\n .join(' ');\n }", "title": "" }, { "docid": "4d92f29b1a038a4b053b006f1db7cdcf", "score": "0.5390172", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!cls.trim()){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}}else{var cur=' '+el.getAttribute('class')+' ';var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}el.setAttribute('class',cur.trim());}}", "title": "" }, { "docid": "4d92f29b1a038a4b053b006f1db7cdcf", "score": "0.5390172", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!cls.trim()){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}}else{var cur=' '+el.getAttribute('class')+' ';var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}el.setAttribute('class',cur.trim());}}", "title": "" }, { "docid": "4d92f29b1a038a4b053b006f1db7cdcf", "score": "0.5390172", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!cls.trim()){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}}else{var cur=' '+el.getAttribute('class')+' ';var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}el.setAttribute('class',cur.trim());}}", "title": "" }, { "docid": "4d92f29b1a038a4b053b006f1db7cdcf", "score": "0.5390172", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!cls.trim()){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}}else{var cur=' '+el.getAttribute('class')+' ';var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}el.setAttribute('class',cur.trim());}}", "title": "" }, { "docid": "9cf99013b787917d24fc4a8887de7e6d", "score": "0.53820527", "text": "function _handleAttributes(oldNode, newNode, rule, clearInternals) {\n var attributes = {}, // fresh new set of attributes to set on newNode\n setClass = rule.set_class, // classes to set\n addClass = rule.add_class, // add classes based on existing attributes\n addStyle = rule.add_style, // add styles based on existing attributes\n setAttributes = rule.set_attributes, // attributes to set on the current node\n checkAttributes = rule.check_attributes, // check/convert values of attributes\n allowedClasses = currentRules.classes,\n i = 0,\n classes = [],\n styles = [],\n newClasses = [],\n oldClasses = [],\n classesLength,\n newClassesLength,\n currentClass,\n newClass,\n attributeName,\n newAttributeValue,\n method,\n oldAttribute;\n\n if (setAttributes) {\n attributes = wysihtml5.lang.object(setAttributes).clone();\n }\n\n if (checkAttributes) {\n for (attributeName in checkAttributes) {\n method = attributeCheckMethods[checkAttributes[attributeName]];\n if (!method) {\n continue;\n }\n oldAttribute = _getAttribute(oldNode, attributeName);\n if (oldAttribute || (attributeName === \"alt\" && oldNode.nodeName == \"IMG\")) {\n newAttributeValue = method(oldAttribute);\n if (typeof(newAttributeValue) === \"string\") {\n attributes[attributeName] = newAttributeValue;\n }\n }\n }\n }\n\n if (setClass) {\n classes.push(setClass);\n }\n\n if (addClass) {\n for (attributeName in addClass) {\n method = addClassMethods[addClass[attributeName]];\n if (!method) {\n continue;\n }\n newClass = method(_getAttribute(oldNode, attributeName));\n if (typeof(newClass) === \"string\") {\n classes.push(newClass);\n }\n }\n }\n\n if (addStyle) {\n for (attributeName in addStyle) {\n method = addStyleMethods[addStyle[attributeName]];\n if (!method) {\n continue;\n }\n\n newStyle = method(_getAttribute(oldNode, attributeName));\n if (typeof(newStyle) === \"string\") {\n styles.push(newStyle);\n }\n }\n }\n\n\n if (typeof(allowedClasses) === \"string\" && allowedClasses === \"any\" && oldNode.getAttribute(\"class\")) {\n attributes[\"class\"] = oldNode.getAttribute(\"class\");\n } else {\n // make sure that wysihtml5 temp class doesn't get stripped out\n if (!clearInternals) {\n allowedClasses[\"_wysihtml5-temp-placeholder\"] = 1;\n allowedClasses[\"_rangySelectionBoundary\"] = 1;\n allowedClasses[\"wysiwyg-tmp-selected-cell\"] = 1;\n }\n\n // add old classes last\n oldClasses = oldNode.getAttribute(\"class\");\n if (oldClasses) {\n classes = classes.concat(oldClasses.split(WHITE_SPACE_REG_EXP));\n }\n classesLength = classes.length;\n for (; i<classesLength; i++) {\n currentClass = classes[i];\n if (allowedClasses[currentClass]) {\n newClasses.push(currentClass);\n }\n }\n\n if (newClasses.length) {\n attributes[\"class\"] = wysihtml5.lang.array(newClasses).unique().join(\" \");\n }\n }\n\n // remove table selection class if present\n if (attributes[\"class\"] && clearInternals) {\n attributes[\"class\"] = attributes[\"class\"].replace(\"wysiwyg-tmp-selected-cell\", \"\");\n if ((/^\\s*$/g).test(attributes[\"class\"])) {\n delete attributes[\"class\"];\n }\n }\n\n if (styles.length) {\n attributes[\"style\"] = wysihtml5.lang.array(styles).unique().join(\" \");\n }\n\n // set attributes on newNode\n for (attributeName in attributes) {\n // Setting attributes can cause a js error in IE under certain circumstances\n // eg. on a <img> under https when it's new attribute value is non-https\n // TODO: Investigate this further and check for smarter handling\n try {\n newNode.setAttribute(attributeName, attributes[attributeName]);\n } catch(e) {}\n }\n\n // IE8 sometimes loses the width/height attributes when those are set before the \"src\"\n // so we make sure to set them again\n if (attributes.src) {\n if (typeof(attributes.width) !== \"undefined\") {\n newNode.setAttribute(\"width\", attributes.width);\n }\n if (typeof(attributes.height) !== \"undefined\") {\n newNode.setAttribute(\"height\", attributes.height);\n }\n }\n }", "title": "" }, { "docid": "9cf99013b787917d24fc4a8887de7e6d", "score": "0.53820527", "text": "function _handleAttributes(oldNode, newNode, rule, clearInternals) {\n var attributes = {}, // fresh new set of attributes to set on newNode\n setClass = rule.set_class, // classes to set\n addClass = rule.add_class, // add classes based on existing attributes\n addStyle = rule.add_style, // add styles based on existing attributes\n setAttributes = rule.set_attributes, // attributes to set on the current node\n checkAttributes = rule.check_attributes, // check/convert values of attributes\n allowedClasses = currentRules.classes,\n i = 0,\n classes = [],\n styles = [],\n newClasses = [],\n oldClasses = [],\n classesLength,\n newClassesLength,\n currentClass,\n newClass,\n attributeName,\n newAttributeValue,\n method,\n oldAttribute;\n\n if (setAttributes) {\n attributes = wysihtml5.lang.object(setAttributes).clone();\n }\n\n if (checkAttributes) {\n for (attributeName in checkAttributes) {\n method = attributeCheckMethods[checkAttributes[attributeName]];\n if (!method) {\n continue;\n }\n oldAttribute = _getAttribute(oldNode, attributeName);\n if (oldAttribute || (attributeName === \"alt\" && oldNode.nodeName == \"IMG\")) {\n newAttributeValue = method(oldAttribute);\n if (typeof(newAttributeValue) === \"string\") {\n attributes[attributeName] = newAttributeValue;\n }\n }\n }\n }\n\n if (setClass) {\n classes.push(setClass);\n }\n\n if (addClass) {\n for (attributeName in addClass) {\n method = addClassMethods[addClass[attributeName]];\n if (!method) {\n continue;\n }\n newClass = method(_getAttribute(oldNode, attributeName));\n if (typeof(newClass) === \"string\") {\n classes.push(newClass);\n }\n }\n }\n\n if (addStyle) {\n for (attributeName in addStyle) {\n method = addStyleMethods[addStyle[attributeName]];\n if (!method) {\n continue;\n }\n\n newStyle = method(_getAttribute(oldNode, attributeName));\n if (typeof(newStyle) === \"string\") {\n styles.push(newStyle);\n }\n }\n }\n\n\n if (typeof(allowedClasses) === \"string\" && allowedClasses === \"any\" && oldNode.getAttribute(\"class\")) {\n attributes[\"class\"] = oldNode.getAttribute(\"class\");\n } else {\n // make sure that wysihtml5 temp class doesn't get stripped out\n if (!clearInternals) {\n allowedClasses[\"_wysihtml5-temp-placeholder\"] = 1;\n allowedClasses[\"_rangySelectionBoundary\"] = 1;\n allowedClasses[\"wysiwyg-tmp-selected-cell\"] = 1;\n }\n\n // add old classes last\n oldClasses = oldNode.getAttribute(\"class\");\n if (oldClasses) {\n classes = classes.concat(oldClasses.split(WHITE_SPACE_REG_EXP));\n }\n classesLength = classes.length;\n for (; i<classesLength; i++) {\n currentClass = classes[i];\n if (allowedClasses[currentClass]) {\n newClasses.push(currentClass);\n }\n }\n\n if (newClasses.length) {\n attributes[\"class\"] = wysihtml5.lang.array(newClasses).unique().join(\" \");\n }\n }\n\n // remove table selection class if present\n if (attributes[\"class\"] && clearInternals) {\n attributes[\"class\"] = attributes[\"class\"].replace(\"wysiwyg-tmp-selected-cell\", \"\");\n if ((/^\\s*$/g).test(attributes[\"class\"])) {\n delete attributes[\"class\"];\n }\n }\n\n if (styles.length) {\n attributes[\"style\"] = wysihtml5.lang.array(styles).unique().join(\" \");\n }\n\n // set attributes on newNode\n for (attributeName in attributes) {\n // Setting attributes can cause a js error in IE under certain circumstances\n // eg. on a <img> under https when it's new attribute value is non-https\n // TODO: Investigate this further and check for smarter handling\n try {\n newNode.setAttribute(attributeName, attributes[attributeName]);\n } catch(e) {}\n }\n\n // IE8 sometimes loses the width/height attributes when those are set before the \"src\"\n // so we make sure to set them again\n if (attributes.src) {\n if (typeof(attributes.width) !== \"undefined\") {\n newNode.setAttribute(\"width\", attributes.width);\n }\n if (typeof(attributes.height) !== \"undefined\") {\n newNode.setAttribute(\"height\", attributes.height);\n }\n }\n }", "title": "" }, { "docid": "69cd2c783fa3766a1b5bf6c893a95732", "score": "0.5380989", "text": "function remAtt(){\n for(let field of inputFields){\n field.removeAttribute('class');\n }\n}", "title": "" }, { "docid": "6bd5997830605587df76d5b83080ab86", "score": "0.53781766", "text": "function getClassAttrSelector(className) {\n return \"[class~='\" + className + \"']\";\n}", "title": "" }, { "docid": "c095e1f7efdb0aceb4f7da2024cbb5fb", "score": "0.5376437", "text": "function setClasses( classes ) {\n var className = docElement.className;\n var classPrefix = Modernizr._config.classPrefix || '';\n\n // Change `no-js` to `js` (we do this regardles of the `enableClasses`\n // option)\n // Handle classPrefix on this too\n var reJS = new RegExp('(^|\\\\s)'+classPrefix+'no-js(\\\\s|$)');\n className = className.replace(reJS, '$1'+classPrefix+'js$2');\n\n if(Modernizr._config.enableClasses) {\n // Add the new classes\n className += ' ' + classPrefix + classes.join(' ' + classPrefix);\n docElement.className = className;\n }\n\n }", "title": "" }, { "docid": "f5e3e0f2b06d3d483edf71cc22f222fc", "score": "0.53743863", "text": "function _handleAttributes(oldNode, newNode, rule, clearInternals) {\n var attributes = {}, // fresh new set of attributes to set on newNode\n setClass = rule.set_class, // classes to set\n addClass = rule.add_class, // add classes based on existing attributes\n addStyle = rule.add_style, // add styles based on existing attributes\n setAttributes = rule.set_attributes, // attributes to set on the current node\n checkAttributes = rule.check_attributes, // check/convert values of attributes\n allowedClasses = currentRules.classes,\n i = 0,\n classes = [],\n styles = [],\n newClasses = [],\n oldClasses = [],\n classesLength,\n newClassesLength,\n currentClass,\n newClass,\n attributeName,\n newAttributeValue,\n method;\n\n if (setAttributes) {\n attributes = wysihtml5.lang.object(setAttributes).clone();\n }\n\n if (checkAttributes) {\n for (attributeName in checkAttributes) {\n method = attributeCheckMethods[checkAttributes[attributeName]];\n if (!method) {\n continue;\n }\n oldAttribute = _getAttribute(oldNode, attributeName);\n if (oldAttribute || (attributeName === \"alt\" && oldNode.nodeName == \"IMG\")) {\n newAttributeValue = method(oldAttribute);\n if (typeof(newAttributeValue) === \"string\") {\n attributes[attributeName] = newAttributeValue;\n }\n }\n }\n }\n\n if (setClass) {\n classes.push(setClass);\n }\n\n if (addClass) {\n for (attributeName in addClass) {\n method = addClassMethods[addClass[attributeName]];\n if (!method) {\n continue;\n }\n newClass = method(_getAttribute(oldNode, attributeName));\n if (typeof(newClass) === \"string\") {\n classes.push(newClass);\n }\n }\n }\n\n if (addStyle) {\n for (attributeName in addStyle) {\n method = addStyleMethods[addStyle[attributeName]];\n if (!method) {\n continue;\n }\n\n newStyle = method(_getAttribute(oldNode, attributeName));\n if (typeof(newStyle) === \"string\") {\n styles.push(newStyle);\n }\n }\n }\n\n\n if (typeof(allowedClasses) === \"string\" && allowedClasses === \"any\" && oldNode.getAttribute(\"class\")) {\n attributes[\"class\"] = oldNode.getAttribute(\"class\");\n } else {\n // make sure that wysihtml5 temp class doesn't get stripped out\n if (!clearInternals) {\n allowedClasses[\"_wysihtml5-temp-placeholder\"] = 1;\n allowedClasses[\"_rangySelectionBoundary\"] = 1;\n allowedClasses[\"wysiwyg-tmp-selected-cell\"] = 1;\n }\n\n // add old classes last\n oldClasses = oldNode.getAttribute(\"class\");\n if (oldClasses) {\n classes = classes.concat(oldClasses.split(WHITE_SPACE_REG_EXP));\n }\n classesLength = classes.length;\n for (; i<classesLength; i++) {\n currentClass = classes[i];\n if (allowedClasses[currentClass]) {\n newClasses.push(currentClass);\n }\n }\n\n if (newClasses.length) {\n attributes[\"class\"] = wysihtml5.lang.array(newClasses).unique().join(\" \");\n }\n }\n\n // remove table selection class if present\n if (attributes[\"class\"] && clearInternals) {\n attributes[\"class\"] = attributes[\"class\"].replace(\"wysiwyg-tmp-selected-cell\", \"\");\n if ((/^\\s*$/g).test(attributes[\"class\"])) {\n delete attributes.class;\n }\n }\n\n if (styles.length) {\n attributes[\"style\"] = wysihtml5.lang.array(styles).unique().join(\" \");\n }\n\n // set attributes on newNode\n for (attributeName in attributes) {\n // Setting attributes can cause a js error in IE under certain circumstances\n // eg. on a <img> under https when it's new attribute value is non-https\n // TODO: Investigate this further and check for smarter handling\n try {\n newNode.setAttribute(attributeName, attributes[attributeName]);\n } catch(e) {}\n }\n\n // IE8 sometimes loses the width/height attributes when those are set before the \"src\"\n // so we make sure to set them again\n if (attributes.src) {\n if (typeof(attributes.width) !== \"undefined\") {\n newNode.setAttribute(\"width\", attributes.width);\n }\n if (typeof(attributes.height) !== \"undefined\") {\n newNode.setAttribute(\"height\", attributes.height);\n }\n }\n }", "title": "" }, { "docid": "439d4a395e89418226d3ce5e7bb909d3", "score": "0.53623056", "text": "function patchClass(el, value, isSVG) {\n if (value == null) {\n value = '';\n }\n if (isSVG) {\n el.setAttribute('class', value);\n }\n else {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value\n ? [value, ...transitionClasses]\n : [...transitionClasses]).join(' ');\n }\n el.className = value;\n }\n}", "title": "" }, { "docid": "439d4a395e89418226d3ce5e7bb909d3", "score": "0.53623056", "text": "function patchClass(el, value, isSVG) {\n if (value == null) {\n value = '';\n }\n if (isSVG) {\n el.setAttribute('class', value);\n }\n else {\n // directly setting className should be faster than setAttribute in theory\n // if this is an element during a transition, take the temporary transition\n // classes into account.\n const transitionClasses = el._vtc;\n if (transitionClasses) {\n value = (value\n ? [value, ...transitionClasses]\n : [...transitionClasses]).join(' ');\n }\n el.className = value;\n }\n}", "title": "" }, { "docid": "2b0b3cff7cc4d2807ffe82ba12fe4ef7", "score": "0.5355907", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}el.setAttribute('class',cur.trim());}}", "title": "" }, { "docid": "2b0b3cff7cc4d2807ffe82ba12fe4ef7", "score": "0.5355907", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}el.setAttribute('class',cur.trim());}}", "title": "" }, { "docid": "2b0b3cff7cc4d2807ffe82ba12fe4ef7", "score": "0.5355907", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}el.setAttribute('class',cur.trim());}}", "title": "" }, { "docid": "185bcdb03a06b325e8847ab3c8240339", "score": "0.53339297", "text": "function _cleanupClasses(target) {\n for (var i = 0; i < this._dirtyClasses.length; i++) target.classList.remove(this._dirtyClasses[i]);\n this._dirtyClasses = [];\n }", "title": "" }, { "docid": "094e48e800f49c3aefdcd3e0c4dcf4e0", "score": "0.53109443", "text": "function addInternalSelectors(){\n container.find(options.sectionSelector).addClass(SECTION);\n container.find(options.slideSelector).addClass(SLIDE);\n }", "title": "" }, { "docid": "094e48e800f49c3aefdcd3e0c4dcf4e0", "score": "0.53109443", "text": "function addInternalSelectors(){\n container.find(options.sectionSelector).addClass(SECTION);\n container.find(options.slideSelector).addClass(SLIDE);\n }", "title": "" }, { "docid": "094e48e800f49c3aefdcd3e0c4dcf4e0", "score": "0.53109443", "text": "function addInternalSelectors(){\n container.find(options.sectionSelector).addClass(SECTION);\n container.find(options.slideSelector).addClass(SLIDE);\n }", "title": "" }, { "docid": "68b85e03bd3ff677042c0e3d2a6c5646", "score": "0.53021485", "text": "function removeClasses() { // function to run after the css animation \"wriggle\" contained in the class \"mismatch\"\n mismatch.parentNode.parentNode.classList.remove(\"mismatch\");\n mismatch.parentNode.parentNode.removeAttribute(\"style\");\n mismatch.removeAttribute(\"style\");\n }", "title": "" }, { "docid": "bd9723340b9ff73a6d1486f3edae47c0", "score": "0.5296373", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n }", "title": "" }, { "docid": "bd9723340b9ff73a6d1486f3edae47c0", "score": "0.5296373", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n }", "title": "" }, { "docid": "3d2491326af5c794900b5f5774b14bc6", "score": "0.52950907", "text": "function removeClass(c) {this.className=xClass(this.className, c);}", "title": "" }, { "docid": "1c966be1a8ac1bfdaa41bd605cb35164", "score": "0.528717", "text": "function addInternalSelectors() {\n container.find(options.sectionSelector).addClass(SECTION);\n container.find(options.slideSelector).addClass(SLIDE);\n }", "title": "" }, { "docid": "96534f65f5df2c0c72ac97e450f209f0", "score": "0.5283625", "text": "updateClasses () {\n if (!this.classes) return;\n\n toggleClass(this.el, this.classNames.dirty, this.flags.dirty);\n toggleClass(this.el, this.classNames.pristine, this.flags.pristine);\n toggleClass(this.el, this.classNames.valid, !!this.flags.valid);\n toggleClass(this.el, this.classNames.invalid, !!this.flags.invalid);\n toggleClass(this.el, this.classNames.touched, this.flags.touched);\n toggleClass(this.el, this.classNames.untouched, this.flags.untouched);\n }", "title": "" }, { "docid": "55c1981a5fec0faf44615de1ea34ab5c", "score": "0.5273603", "text": "function addInternalSelectors(){\r\n container.find(options.sectionSelector).addClass(SECTION);\r\n container.find(options.slideSelector).addClass(SLIDE);\r\n }", "title": "" }, { "docid": "d00e52642dcd7ee733f5ede8c9820c4a", "score": "0.5265711", "text": "function w3RemoveClass(element, name) {\r\n var i, arr1, arr2;\r\n arr1 = element.className.split(\" \");\r\n arr2 = name.split(\" \");\r\n for (i = 0; i < arr2.length; i++) {\r\n while (arr1.indexOf(arr2[i]) > -1) {\r\n arr1.splice(arr1.indexOf(arr2[i]), 1);\r\n }\r\n }\r\n element.className = arr1.join(\" \");\r\n}", "title": "" }, { "docid": "e1f532b165740f571cf91ed31a5028a2", "score": "0.5262712", "text": "function w3RemoveClass(element, name) {\r\n var i, arr1, arr2;\r\n arr1 = element.className.split(\" \");\r\n arr2 = name.split(\" \");\r\n for (i = 0; i < arr2.length; i++) {\r\n while (arr1.indexOf(arr2[i]) > -1) {\r\n arr1.splice(arr1.indexOf(arr2[i]), 1);\r\n }\r\n }\r\n element.className = arr1.join(\" \");\r\n}", "title": "" }, { "docid": "70b7270dea03673a0608f39933f0ce9c", "score": "0.52619505", "text": "removeClass(elementName, nameOfClass) {\n let i, arrayOfElementClassNames, arrayOfClass;\n arrayOfElementClassNames = elementName.className.split(' ');\n arrayOfClass = nameOfClass.split(' ');\n for (let i in arrayOfClass) {\n if(i < arrayOfClass.length) {\n while (arrayOfElementClassNames.indexOf(arrayOfClass[i]) > -1) {\n arrayOfElementClassNames.splice(arrayOfElementClassNames.indexOf(arrayOfClass[i]), 1);\n }\n }\n }\n elementName.className = arrayOfElementClassNames.join(' ');\n }", "title": "" }, { "docid": "6ca510cd3f49bdab5df273c88a5184bd", "score": "0.5256746", "text": "function addEnhanceClass(){\n\t\tdocElem.className += \" \" + docClasses.join(\" \");\n\t}", "title": "" }, { "docid": "f693087dbdb14584b4f4261ded790128", "score": "0.5244592", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "f693087dbdb14584b4f4261ded790128", "score": "0.5244592", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "f693087dbdb14584b4f4261ded790128", "score": "0.5244592", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "f693087dbdb14584b4f4261ded790128", "score": "0.5244592", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "f693087dbdb14584b4f4261ded790128", "score": "0.5244592", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "f693087dbdb14584b4f4261ded790128", "score": "0.5244592", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "f693087dbdb14584b4f4261ded790128", "score": "0.5244592", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "88b366c56366bf36fa17897a4963e650", "score": "0.52436703", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1); \n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "88b366c56366bf36fa17897a4963e650", "score": "0.52436703", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1); \n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "88b366c56366bf36fa17897a4963e650", "score": "0.52436703", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1); \n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "a79b401e234679f793747967a111e37e", "score": "0.524107", "text": "function removeClasses(selected){\n try{\n selected.className = selected.className.replace(\"boysenBlue\" , '' );\n selected.className = selected.className.replace(\"boysenPurple\" , '' );\n selected.className = selected.className.replace(\"boysenRed\" , '' );\n selected.className = selected.className.replace(\"hoverEffect\" , '' );\n }\n catch(e){\n // //console.log.log(e);\n }\n}", "title": "" }, { "docid": "075c0787b63f0bf2802c899ef7f95fba", "score": "0.52397335", "text": "function reapplyStyle(classname)\n {\n if (classname in oldClasses)\n Set.add(newClasses, classname);\n }", "title": "" }, { "docid": "06dc362e9537f5cfd5a5fc895f172fab", "score": "0.5220587", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "06dc362e9537f5cfd5a5fc895f172fab", "score": "0.5220587", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "06dc362e9537f5cfd5a5fc895f172fab", "score": "0.5220587", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "06dc362e9537f5cfd5a5fc895f172fab", "score": "0.5220587", "text": "function w3RemoveClass(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "7e7e659a09a10e7405d30da33be6c92b", "score": "0.5213929", "text": "function w3RemoveClass(element, name){\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "764a8b9564c0e175d8807d08705d2da0", "score": "0.5213607", "text": "function addInternalSelectors(){\n addClass($(options.sectionSelector, container), SECTION);\n addClass($(options.slideSelector, container), SLIDE);\n }", "title": "" }, { "docid": "764a8b9564c0e175d8807d08705d2da0", "score": "0.5213607", "text": "function addInternalSelectors(){\n addClass($(options.sectionSelector, container), SECTION);\n addClass($(options.slideSelector, container), SLIDE);\n }", "title": "" }, { "docid": "e0aee7b615d26ce00e0c72e54c3922ef", "score": "0.52134645", "text": "addClass(className) {\n\t let oldClass = this.attr(\"class\");\n\t this.attr(\"class\", oldClass + ' ' + className);\n\t }", "title": "" }, { "docid": "02df990f5e2c50d1d9377119a42b898c", "score": "0.5208835", "text": "removeSuggestedChildren(e){\n const dropDownChildren = this.inputRefs.dropDownOptions.current;\n let dropDownClasses = dropDownChildren.getAttribute('class');\n\n if(dropDownClasses.indexOf('pz-show') !== -1){\n dropDownClasses = dropDownClasses.replace('pz-show', 'pz-hide');\n dropDownChildren.setAttribute('class', dropDownClasses)\n }\n }", "title": "" }, { "docid": "2788cd70f420c1ddb32f49758299816f", "score": "0.52051616", "text": "function yp_classes_clean(data){\n\t\treturn data.replace(/ui-draggable-handle|yp-yellow-pencil-loaded|yp-element-resized|yp-selected-handle|yp-parallax-disabled|ready-for-drag|yp_onscreen|yp_hover|yp_click|yp_focus|yp-selected-others|yp-selected|yp-demo-link|yp-live-editor-link|yp-yellow-pencil|wt-yellow-pencil|yp-content-selected|yp-hide-borders-now|ui-draggable|yp-target-active|yp-yellow-pencil-disable-links|yp-closed|yp-medium-device|yp-small-device|yp-large-device|yp-metric-disable|yp-css-editor-active|wtfv|yp-clean-look|yp-has-transform|yp-will-selected|yp-selected|yp-fullscreen-editor|context-menu-active|yp-yellow-pencil-demo-mode|yp-element-resizing|yp-element-resizing-width-left|yp-element-resizing-width-right|yp-element-resizing-height-top|yp-element-resizing-height-bottom|context-menu-active|yp-left-selected-resizeable/gi,'');\n\t}", "title": "" }, { "docid": "4cf72c3e597c4758a10f6d71363aca9b", "score": "0.5200432", "text": "function RemoveObsoleteClassRefsScanner( obsoleteClasses )\n{\n\tthis.obsoleteClasses = obsoleteClasses;\n}", "title": "" }, { "docid": "973f36bb1078d9ce786ccd279028823d", "score": "0.5197236", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}if(!el.classList.length){el.removeAttribute('class');}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}cur=cur.trim();if(cur){el.setAttribute('class',cur);}else{el.removeAttribute('class');}}}", "title": "" }, { "docid": "973f36bb1078d9ce786ccd279028823d", "score": "0.5197236", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}if(!el.classList.length){el.removeAttribute('class');}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}cur=cur.trim();if(cur){el.setAttribute('class',cur);}else{el.removeAttribute('class');}}}", "title": "" }, { "docid": "973f36bb1078d9ce786ccd279028823d", "score": "0.5197236", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}if(!el.classList.length){el.removeAttribute('class');}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}cur=cur.trim();if(cur){el.setAttribute('class',cur);}else{el.removeAttribute('class');}}}", "title": "" }, { "docid": "973f36bb1078d9ce786ccd279028823d", "score": "0.5197236", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(/\\s+/).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}if(!el.classList.length){el.removeAttribute('class');}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}cur=cur.trim();if(cur){el.setAttribute('class',cur);}else{el.removeAttribute('class');}}}", "title": "" }, { "docid": "c05acd0eae0c4cf2e143f05eb4449dec", "score": "0.51946276", "text": "function transformClassElement(element) {\r\n element = ts.visitEachChild(element, visitor, context);\r\n var decoratorsToKeep = [];\r\n var toLower = [];\r\n try {\r\n for (var _a = __values(element.decorators || []), _b = _a.next(); !_b.done; _b = _a.next()) {\r\n var decorator = _b.value;\r\n if (!shouldLower(decorator, typeChecker)) {\r\n decoratorsToKeep.push(decorator);\r\n continue;\r\n }\r\n toLower.push(decorator);\r\n }\r\n }\r\n catch (e_7_1) { e_7 = { error: e_7_1 }; }\r\n finally {\r\n try {\r\n if (_b && !_b.done && (_c = _a.return)) _c.call(_a);\r\n }\r\n finally { if (e_7) throw e_7.error; }\r\n }\r\n if (!toLower.length)\r\n return [undefined, element, []];\r\n if (!element.name || element.name.kind !== ts.SyntaxKind.Identifier) {\r\n // Method has a weird name, e.g.\r\n // [Symbol.foo]() {...}\r\n diagnostics.push({\r\n file: element.getSourceFile(),\r\n start: element.getStart(),\r\n length: element.getEnd() - element.getStart(),\r\n messageText: \"cannot process decorators on strangely named method\",\r\n category: ts.DiagnosticCategory.Error,\r\n code: 0,\r\n });\r\n return [undefined, element, []];\r\n }\r\n var name = element.name.text;\r\n var mutable = ts.getMutableClone(element);\r\n mutable.decorators = decoratorsToKeep.length ?\r\n ts.setTextRange(ts.createNodeArray(decoratorsToKeep), mutable.decorators) :\r\n undefined;\r\n return [name, mutable, toLower];\r\n var e_7, _c;\r\n }", "title": "" }, { "docid": "b22e559094be353f5e6e7dcd2578c593", "score": "0.5188332", "text": "removeClass(name) {\n this.current.className = this.current.className\n .split(/\\W+/)\n .filter(function(element) { return element !== name })\n .join(' ');\n return this;\n }", "title": "" }, { "docid": "7c8b80405eefb0c2eb396dc1131a7406", "score": "0.5177069", "text": "function removeDeveloperCardStyles(){\n\n [...document.querySelectorAll('.developer-card')].forEach( x => \n\n x.classList.remove('about-us-selected-developer')\n\n );\n\n}", "title": "" }, { "docid": "b581da6f3b8067ab834936dadcce2f9d", "score": "0.5165656", "text": "old(prefix) {\n return new OldSelector(this, prefix)\n }", "title": "" }, { "docid": "34346f8b011c6570f12146199622455a", "score": "0.516124", "text": "function addInternalSelectors(){\r\n addClass($(options.sectionSelector, container), SECTION);\r\n addClass($(options.slideSelector, container), SLIDE);\r\n }", "title": "" }, { "docid": "34346f8b011c6570f12146199622455a", "score": "0.516124", "text": "function addInternalSelectors(){\r\n addClass($(options.sectionSelector, container), SECTION);\r\n addClass($(options.slideSelector, container), SLIDE);\r\n }", "title": "" }, { "docid": "1a7961993dea0dedebec0006fd9f6879", "score": "0.51544243", "text": "function ieSvgRemoveClass(element, clazz) {\n var classNameValue = element.className.baseVal;\n classNameValue = classNameValue.replace(clazz, '');\n element.className.baseVal = classNameValue;\n }", "title": "" }, { "docid": "3bb7a57716077b8ec7421d81048e2de3", "score": "0.5144882", "text": "function setAsUnworked(classSelector) {\n $(\".button.\" + classSelector).addClass(\"unworkedClass\")\n }", "title": "" }, { "docid": "6f97c22dc071f22608710ab5d55edb67", "score": "0.5140791", "text": "removeClass(...classNames) {\n if (this.isNodeList()) {\n this.node.forEach((x) => x.classList.remove(...classNames));\n return this;\n }\n this.node.classList.remove(...classNames);\n return this;\n }", "title": "" }, { "docid": "cef8e90b5dbce5f142a52a98864d9dd2", "score": "0.513794", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(whitespaceRE).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}if(!el.classList.length){el.removeAttribute('class');}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}cur=cur.trim();if(cur){el.setAttribute('class',cur);}else{el.removeAttribute('class');}}}", "title": "" }, { "docid": "cef8e90b5dbce5f142a52a98864d9dd2", "score": "0.513794", "text": "function removeClass(el,cls){/* istanbul ignore if */if(!cls||!(cls=cls.trim())){return;}/* istanbul ignore else */if(el.classList){if(cls.indexOf(' ')>-1){cls.split(whitespaceRE).forEach(function(c){return el.classList.remove(c);});}else{el.classList.remove(cls);}if(!el.classList.length){el.removeAttribute('class');}}else{var cur=\" \"+(el.getAttribute('class')||'')+\" \";var tar=' '+cls+' ';while(cur.indexOf(tar)>=0){cur=cur.replace(tar,' ');}cur=cur.trim();if(cur){el.setAttribute('class',cur);}else{el.removeAttribute('class');}}}", "title": "" }, { "docid": "f159f415192cc8901536be504329e563", "score": "0.5128926", "text": "old (prefix) {\n return new OldSelector(this, prefix)\n }", "title": "" }, { "docid": "2a3b9fe2d41c8c36b9c29d832103116e", "score": "0.5115927", "text": "function legacyAppendClass() {\n if (!transitionSupport) return;\n\n var basicClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, '' + eventType);\n if (basicClassName) nodeClasses.add(basicClassName);\n\n if (eventActive) {\n var activeClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, eventType + '-active');\n if (activeClassName) nodeClasses.add(activeClassName);\n }\n }", "title": "" }, { "docid": "2a3b9fe2d41c8c36b9c29d832103116e", "score": "0.5115927", "text": "function legacyAppendClass() {\n if (!transitionSupport) return;\n\n var basicClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, '' + eventType);\n if (basicClassName) nodeClasses.add(basicClassName);\n\n if (eventActive) {\n var activeClassName = Object(_util__WEBPACK_IMPORTED_MODULE_12__[\"getTransitionName\"])(transitionName, eventType + '-active');\n if (activeClassName) nodeClasses.add(activeClassName);\n }\n }", "title": "" } ]
813f7b323343005864b9c832893998c3
Normalize the name of a technology.
[ { "docid": "9569e31687b1962445bd0b90a5943b66", "score": "0.0", "text": "function normalize(values) {\n return _.map(values, (val) => {\n var nom = val[0].trim().toLowerCase();\n if (normes[nom]) {\n return { nom: normes[nom], nomOrigine: val[0], connaissance: Number(val[1]), envie: Number(val[2]) }\n }\n\n console.log('no norm for: \"' + val[0] + '\"')\n return { nom: val[0].trim().toLowerCase(), nomOrigine: val[0], connaissance: Number(val[1]), envie: Number(val[2]) }\n })\n}", "title": "" } ]
[ { "docid": "d1a495381e90c9d3ffb240730085b705", "score": "0.6903554", "text": "function normalize(name) {\n return name.replace(/[- _]+/g, '').toLowerCase();\n }", "title": "" }, { "docid": "d1a495381e90c9d3ffb240730085b705", "score": "0.6903554", "text": "function normalize(name) {\n return name.replace(/[- _]+/g, '').toLowerCase();\n }", "title": "" }, { "docid": "a7a191f416a0f836231a03f6d7832745", "score": "0.6837826", "text": "function normalizeName(name) {\n return name.replace(/\\s+/g, '-').toLowerCase();\n}", "title": "" }, { "docid": "fa1a18ec612475d657574100ffb5c7f0", "score": "0.65880287", "text": "function normalize(name) {\n var normalized = '';\n\n for (var i = 12; i < name.length; i += 1) {\n normalized += name[i] === '-' ? name[i++].toUpperCase() : name[i];\n }\n\n return normalized;\n}", "title": "" }, { "docid": "e48f0c7b1d88a606a35dd5ee41be2905", "score": "0.6554092", "text": "function normalizeName(name) {\n return name.toLowerCase();\n}", "title": "" }, { "docid": "e48f0c7b1d88a606a35dd5ee41be2905", "score": "0.6554092", "text": "function normalizeName(name) {\n return name.toLowerCase();\n}", "title": "" }, { "docid": "c70a81d6657bf892745e536bd6c0eedd", "score": "0.644804", "text": "function normalizeName(n) {\n return libutils.no_accent(n.toLowerCase());\n // return n.toLowerCase().replace(' ', '_');\n }", "title": "" }, { "docid": "d652bf0461829a64923eb908f1d69fc1", "score": "0.6398642", "text": "function normalize (name) {\n let normalized = ''\n\n for (let i = 12; i < name.length; i += 1) {\n normalized += name[i] === '-' ? name[i++].toUpperCase() : name[i]\n }\n\n return normalized\n}", "title": "" }, { "docid": "47cdb35106e36ffb49d70cd4d3f4a09e", "score": "0.62632453", "text": "function sanitiseName (name) {\n\treturn name.replace(/ /g, '_').toLowerCase();\n}", "title": "" }, { "docid": "ed2df3d6876abee48e1c4f88af988f90", "score": "0.61905223", "text": "function normalizeTag(tag) {\n return tag.replace(/[^a-z0-9-]/gi, '').toLowerCase();\n }", "title": "" }, { "docid": "915876cfadc84ada5ef2418e21e6a437", "score": "0.6172123", "text": "function normalizeDepartment(department) {\n\tswitch(department) {\n\t\tcase \"SD\" : return \"Software Development\";\n\t\tcase \"BD\" : return \"Business Development\";\n\t\tcase \"HR\" : return \"Human Resource\";\n \t}\n}", "title": "" }, { "docid": "15c974136b8f63163a7f1dc83c026274", "score": "0.60615903", "text": "function cleanNameForWineEnthusiast(name) {\n\t\t\t\t\tname = name.toLowerCase().replace('reserve', 'reserv').replace(' &', \"\");\n\t\t\t\t\tname = name.split(\" \").join(\"+\");\n\t\t\t\t\tname = name.split(\"-\").join(\"+\");\n\t\t\t\t\treturn name;\n\t\t\t\t}", "title": "" }, { "docid": "661c96bba5663a4b6a7b7624957103a8", "score": "0.60108584", "text": "function normalizeUnitName(unitName) {\r\n\t\treturn unitName.replace(/^\\s+|\\s+$/g, \"\").replace(/(s|m?en)$/, \"\")\r\n\t}", "title": "" }, { "docid": "045b6392f1ee20c4199a7d5e0e3d8631", "score": "0.5997339", "text": "function normalizeSpeakerName(name) {\n\t\tname = name.replace(/\\s+/g, '_');\n\t\tname = name.replace('.', '');\n\t\t// prefix so that we can process/differentiate classes better!\n\t\tif (!name.startsWith('speaker_')) {\n\t\t\tname = 'speaker_' + name;\n\t\t}\n\t\treturn name;\n\t}", "title": "" }, { "docid": "a1f6e4347c6fad2954dc53890db8a8af", "score": "0.5984249", "text": "function normalize(word) {\n return stem(word.toLowerCase()).replace(/[^a-z]/g, '');\n}", "title": "" }, { "docid": "a1f6e4347c6fad2954dc53890db8a8af", "score": "0.5984249", "text": "function normalize(word) {\n return stem(word.toLowerCase()).replace(/[^a-z]/g, '');\n}", "title": "" }, { "docid": "f25d95b7af23e50735f59ec5901f3ee6", "score": "0.5984016", "text": "function directiveNormalize(name) {\n\t return name\n\t .replace(PREFIX_REGEXP, '')\n\t .replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {\n\t return offset ? letter.toUpperCase() : letter;\n\t });\n\t }", "title": "" }, { "docid": "ecf67e301b0c4b9e85c83e3ac26d42c7", "score": "0.59803915", "text": "function cleanName(name) {\n if(!name || typeof name != 'string') return name;\n return name.toLowerCase();\n}", "title": "" }, { "docid": "48db03131cffa2ada5c03e0a1ac655a1", "score": "0.5941641", "text": "function convertToTypable(name) {\n const split = name.split(' ');\n const lowercasedWords = split.map(word => word.toLowerCase().replace(/\\//g, ''));\n return lowercasedWords.join('-');\n}", "title": "" }, { "docid": "c62f817cfca84b9e32e3140e2c7ff371", "score": "0.5924409", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {\n return offset ? letter.toUpperCase() : letter;\n });\n }", "title": "" }, { "docid": "c62f817cfca84b9e32e3140e2c7ff371", "score": "0.5924409", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {\n return offset ? letter.toUpperCase() : letter;\n });\n }", "title": "" }, { "docid": "c62f817cfca84b9e32e3140e2c7ff371", "score": "0.5924409", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {\n return offset ? letter.toUpperCase() : letter;\n });\n }", "title": "" }, { "docid": "c62f817cfca84b9e32e3140e2c7ff371", "score": "0.5924409", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {\n return offset ? letter.toUpperCase() : letter;\n });\n }", "title": "" }, { "docid": "24c35e23dba3e5a795ae3ff91b42c704", "score": "0.5923994", "text": "function directiveNormalize(name) {\r\n return name\r\n .replace(PREFIX_REGEXP, '')\r\n .replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {\r\n return offset ? letter.toUpperCase() : letter;\r\n });\r\n }", "title": "" }, { "docid": "c865936ac7720943cc7edb42d2735044", "score": "0.5896255", "text": "function shortenPlatformname(name){\n name = name.toLowerCase().replace(/\\s+/g, '');\n return {\n 'playstation3':'ps3',\n 'playstation4':'ps4',\n 'ps3':'ps3',\n 'ps4':'ps4',\n 'xboxone':'xbox one',\n 'xbox360':'xbox 360',\n 'wii':'wii',\n 'wiiu':'wii u'\n }[name];\n}", "title": "" }, { "docid": "e8916d5cce6484d80dd175607b79c5ee", "score": "0.58535737", "text": "function directiveNormalize(name){return name.replace(PREFIX_REGEXP,'').replace(SPECIAL_CHARS_REGEXP,fnCamelCaseReplace);}", "title": "" }, { "docid": "8312a2d5021064e6356c652950c38391", "score": "0.58254856", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, function(_, letter, offset) {\n return offset ? letter.toUpperCase() : letter;\n });\n}", "title": "" }, { "docid": "8312a2d5021064e6356c652950c38391", "score": "0.58254856", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, function(_, letter, offset) {\n return offset ? letter.toUpperCase() : letter;\n });\n}", "title": "" }, { "docid": "8312a2d5021064e6356c652950c38391", "score": "0.58254856", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, function(_, letter, offset) {\n return offset ? letter.toUpperCase() : letter;\n });\n}", "title": "" }, { "docid": "3b50c8d46778c76848d78f1016f2f2d1", "score": "0.5769678", "text": "function sanitizeName(name) {\n\t// TODO: strip invisible format characters\n\treturn name.\n\t\t// Space normalization\n\t\treplace(/\\s+/g, ' ').\n\t\t// Control characters\n\t\treplace(/[\\0-\\x1f]/g, '');\n}", "title": "" }, { "docid": "ae7f99e77b6fcd519dfca986fd3afd77", "score": "0.57436305", "text": "function directiveNormalize(name) {\n\t return name\n\t .replace(PREFIX_REGEXP, '')\n\t .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n\t}", "title": "" }, { "docid": "80241ec4d255e8feba8ca183c7df883f", "score": "0.569281", "text": "static normalizePlayer(playerName) {\n\n // protect against `playerName` being undefined\n\n if (! playerName) {\n playerName = '';\n }\n\n // After the switch to custom slots multi name players like living room became living-room. Revert the string back to what it was\n\n playerName = playerName.replace(\"-\", \" \");\n if (playerName.toLowerCase() == \"livingroom\")\n playerName = \"living room\";\n\n return playerName;\n }", "title": "" }, { "docid": "3700d538b67c7bedf745e0721b04caf1", "score": "0.56799257", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n}", "title": "" }, { "docid": "3700d538b67c7bedf745e0721b04caf1", "score": "0.56799257", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n}", "title": "" }, { "docid": "3700d538b67c7bedf745e0721b04caf1", "score": "0.56799257", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n}", "title": "" }, { "docid": "3700d538b67c7bedf745e0721b04caf1", "score": "0.56799257", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n}", "title": "" }, { "docid": "3700d538b67c7bedf745e0721b04caf1", "score": "0.56799257", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n}", "title": "" }, { "docid": "3700d538b67c7bedf745e0721b04caf1", "score": "0.56799257", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n}", "title": "" }, { "docid": "3700d538b67c7bedf745e0721b04caf1", "score": "0.56799257", "text": "function directiveNormalize(name) {\n return name\n .replace(PREFIX_REGEXP, '')\n .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace);\n}", "title": "" }, { "docid": "ed2831aa38ea9dcc1b9cf7e34c8c570b", "score": "0.56644547", "text": "function slug(name) {\r\n return name.replace(/[- _]+/g, \"\").toLowerCase();\r\n }", "title": "" }, { "docid": "ed2831aa38ea9dcc1b9cf7e34c8c570b", "score": "0.56644547", "text": "function slug(name) {\r\n return name.replace(/[- _]+/g, \"\").toLowerCase();\r\n }", "title": "" }, { "docid": "892c4de26ba83cb22cd8c7b5f277a775", "score": "0.56578124", "text": "function normalize_spec(spec) {\n return spec.replace(/([^ ])_/g, \"$1 _\").replace(/_([^ ])/g, \"_ $1\");\n }", "title": "" }, { "docid": "6c5a7573cf9ef2749d7e0b7bf307b484", "score": "0.56532836", "text": "function directiveNormalize(name) {\n return camelCase(name[$fog$1580](PREFIX_REGEXP, $fog$1583));\n}", "title": "" }, { "docid": "eca742210de75cc99f5b07b343cc039f", "score": "0.5639232", "text": "function convertName(name){\n return name.replace(/ /g, \"_\").replace(/\\//g, \"_\").replace(/\\./g, \"__\").replace(/-/g,\"_\");\n }", "title": "" }, { "docid": "3ca0317ab2eb3c8f08f3ce225a0caa53", "score": "0.5632251", "text": "function directiveNormalize(name){return camelCase(name.replace(PREFIX_REGEXP,\"\"))}", "title": "" }, { "docid": "d5b4513855445674fb3aa81702384b8e", "score": "0.56287026", "text": "function tagName(name) {\n if (name.includes(\":\"), 1) {\n return name.replace(/:/,\"-\").toLowerCase(); }\n }", "title": "" }, { "docid": "8a995ba5a1ad05b4f02af4e760ecd77f", "score": "0.562397", "text": "function clean(name){\n if(name){\n return name.trim().toLowerCase()\n .replace(/\\s{1,}/gi,'_')\n .replace(/[^a-z0-9_]/g,'')\n .replace(/^_|_$/g,'');\n }\n else return name;\n }", "title": "" }, { "docid": "ace2fd44df8cd4bb48ed21e8adea66fd", "score": "0.5607893", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n }", "title": "" }, { "docid": "e18142150763739f8eecc72ca43eed6e", "score": "0.55964607", "text": "function slug(name) {\n return name.replace(/[- _]+/g, \"\").toLowerCase();\n }", "title": "" }, { "docid": "e18142150763739f8eecc72ca43eed6e", "score": "0.55964607", "text": "function slug(name) {\n return name.replace(/[- _]+/g, \"\").toLowerCase();\n }", "title": "" }, { "docid": "e18142150763739f8eecc72ca43eed6e", "score": "0.55964607", "text": "function slug(name) {\n return name.replace(/[- _]+/g, \"\").toLowerCase();\n }", "title": "" }, { "docid": "e18142150763739f8eecc72ca43eed6e", "score": "0.55964607", "text": "function slug(name) {\n return name.replace(/[- _]+/g, \"\").toLowerCase();\n }", "title": "" }, { "docid": "3dec3f951ab10c0cce7643b0fd894769", "score": "0.5577168", "text": "function searchableName(name) {\n\t// TODO: normalize homoglyphs (including stuff like l and 1)\n\t// TODO: sanitize invalid unicode\n\t// TODO: strip combining characters\n\treturn sanitizeName(name).toLowerCase().replace(/[\\s\\/]+/g, '');\n}", "title": "" }, { "docid": "b1ff2d86aeed6dece052187f5e1f04ea", "score": "0.5566308", "text": "function cleanFilterName(filterName) {\n return filterName.replace(/^\\s+|\\s+$/g, '').toLowerCase();\n }", "title": "" }, { "docid": "743c9b8b2672976cd7b6a829753366f3", "score": "0.5563653", "text": "sanitizeName(name) {\n if (name == null) {\n Log.error('String to be sanitized is null. Default to ERROR_UNKNOWN')\n return 'ERROR_UNKNOWN'\n }\n if ('$' === name) {\n return 'value'\n }\n name = name.replace(new RegExp('\\\\[\\\\]', 'g'), '')\n name = name.replace(new RegExp('\\\\[', 'g'), '_')\n name = name.replace(new RegExp('\\\\]', 'g'), '')\n name = name.replace(new RegExp('\\\\(', 'g'), '_')\n name = name.replace(new RegExp('\\\\)', 'g'), '')\n name = name.replace(new RegExp('\\\\.', 'g'), '_')\n name = name.replace(new RegExp('-', 'g'), '_')\n name = name.replace(new RegExp(' ', 'g'), '_')\n return name.replace(new RegExp('[^a-zA-Z0-9_]', 'g'), '')\n }", "title": "" }, { "docid": "1ad4c6f95e9857a7ea23e2ff42261299", "score": "0.5552104", "text": "function simplifyName(name)\n{\n return name.replace(/\\[.*?\\]|\\.mkv|\\.mp4/g,\"\").replace(/[^\\w]|\\d/g,\"\").toLowerCase();\n}", "title": "" }, { "docid": "60fb919ae0b8e4a4d363aeaba73434d2", "score": "0.55518", "text": "function directiveNormalize(name) {\n\t return camelCase(name.replace(PREFIX_REGEXP, ''));\n\t}", "title": "" }, { "docid": "60fb919ae0b8e4a4d363aeaba73434d2", "score": "0.55518", "text": "function directiveNormalize(name) {\n\t return camelCase(name.replace(PREFIX_REGEXP, ''));\n\t}", "title": "" }, { "docid": "60fb919ae0b8e4a4d363aeaba73434d2", "score": "0.55518", "text": "function directiveNormalize(name) {\n\t return camelCase(name.replace(PREFIX_REGEXP, ''));\n\t}", "title": "" }, { "docid": "1e165df59462c0bb190543a7a4ba8254", "score": "0.55482936", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n }", "title": "" }, { "docid": "300ed2053ce71353ead10f95e512e466", "score": "0.55480075", "text": "function directiveNormalize(name) {\r\n return camelCase(name.replace(PREFIX_REGEXP, ''));\r\n}", "title": "" }, { "docid": "f14a8a9c3ee743e61fe98092b5c0569f", "score": "0.55477136", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n }", "title": "" }, { "docid": "79dc25bd78b38c97c150d744e722241b", "score": "0.55296254", "text": "static normalizedNic(name) {\n // check if the NIC is not an email (it could be the case for US users)\n if (/[@.]+/.test(name)) {\n return name;\n }\n return endsWith(name, '-ovh') ? name : `${name}-ovh`;\n }", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "f6f317c1b68a12c20f60911f53105df5", "score": "0.5494168", "text": "function directiveNormalize(name) {\n return camelCase(name.replace(PREFIX_REGEXP, ''));\n}", "title": "" }, { "docid": "0b528b91a15530425976655ee566e768", "score": "0.5493258", "text": "function formatedName(name){\n name = name.substring(0, name.lastIndexOf(\".\"));\n if(name.indexOf(\"(\") > 0){\n name = name.substring(0, name.indexOf(\"(\"));\n }\n name = name.replace(/_/g, \" \");\n return name; \n}", "title": "" }, { "docid": "86e4d6848d8999c2b88ade6eff2aae98", "score": "0.549296", "text": "_formatFlavorName (name) {\n return name.replace(/^ML_/, '');\n }", "title": "" }, { "docid": "d1da7bca06d66367d9ae0b66052764b5", "score": "0.54882413", "text": "validateName() {\n this.name = this.name.replace(/[^a-z0-9]/gi, '_').toLowerCase();\n }", "title": "" }, { "docid": "547e078145160400ac1737f0f2b7b0b5", "score": "0.54866713", "text": "function normalization(input) {\n let normalized = \"\";\n input = input.toLowerCase();\n if (input.length > 0) {\n input = input.substring(0, 1).toUpperCase() + input.substring(1);\n\n normalized = input;\n\n return normalized;\n }\n}", "title": "" }, { "docid": "f84bc41b8f6796e8a495f7784d9006c3", "score": "0.54586667", "text": "function convertPlatformName(name) {\n\t return PLATFORM_MAP[name] || name;\n\t }", "title": "" }, { "docid": "5428aef2a4bd1fee9ef4d6df95512a1d", "score": "0.5435796", "text": "function convertPlatformName(name) {\n\t return PLATFORM_MAP[name] || name;\n\t}", "title": "" }, { "docid": "5428aef2a4bd1fee9ef4d6df95512a1d", "score": "0.5435796", "text": "function convertPlatformName(name) {\n\t return PLATFORM_MAP[name] || name;\n\t}", "title": "" }, { "docid": "5428aef2a4bd1fee9ef4d6df95512a1d", "score": "0.5435796", "text": "function convertPlatformName(name) {\n\t return PLATFORM_MAP[name] || name;\n\t}", "title": "" } ]
28ab32e0fb18c7650d085742c499d1dd
Push a copy of the current modelview matrix onto the matrix stack.
[ { "docid": "c8b41d3abb6eb0c70d462ff6da35e7b9", "score": "0.86891353", "text": "function pushMatrix() {\n matrixStack.push(mat4.clone(modelview));\n}", "title": "" } ]
[ { "docid": "94c03461098030e634b1056cc3edd2de", "score": "0.8382524", "text": "function pushMatrix() {\n\t\tmatrixStack.push(mat4.clone(viewMatrix));\n\t\trefreshViewProjectionMatrix = true;\n\t}", "title": "" }, { "docid": "ef7c85de98238e5a7632636c0da29506", "score": "0.81865096", "text": "function mvPushMatrix() {\n\tvar copy = mat4.clone(mvMatrix);\n\tmvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "11d1a0eff1734fd13bb1a13ada05daad", "score": "0.817885", "text": "function mvPushMatrix() {\r\n var copy = mat4.clone(mvMatrix);\r\n mvMatrixStack.push(copy);\r\n}", "title": "" }, { "docid": "11d1a0eff1734fd13bb1a13ada05daad", "score": "0.817885", "text": "function mvPushMatrix() {\r\n var copy = mat4.clone(mvMatrix);\r\n mvMatrixStack.push(copy);\r\n}", "title": "" }, { "docid": "11d1a0eff1734fd13bb1a13ada05daad", "score": "0.817885", "text": "function mvPushMatrix() {\r\n var copy = mat4.clone(mvMatrix);\r\n mvMatrixStack.push(copy);\r\n}", "title": "" }, { "docid": "11d1a0eff1734fd13bb1a13ada05daad", "score": "0.817885", "text": "function mvPushMatrix() {\r\n var copy = mat4.clone(mvMatrix);\r\n mvMatrixStack.push(copy);\r\n}", "title": "" }, { "docid": "11d1a0eff1734fd13bb1a13ada05daad", "score": "0.817885", "text": "function mvPushMatrix() {\r\n var copy = mat4.clone(mvMatrix);\r\n mvMatrixStack.push(copy);\r\n}", "title": "" }, { "docid": "4c1c19f4a80d63714935f1ccc6cd782d", "score": "0.8158952", "text": "function mvPushMatrix() {\r\n\tvar copy = mat4.clone(mvMatrix);\r\n\tmvMatrixStack.push(copy);\r\n}", "title": "" }, { "docid": "4ca5120ecc449909e49a890dbc666ee2", "score": "0.8149035", "text": "function mvPushMatrix() {\n var copy = mat4.clone(mvMatrix);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "4ca5120ecc449909e49a890dbc666ee2", "score": "0.8149035", "text": "function mvPushMatrix() {\n var copy = mat4.clone(mvMatrix);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "4ca5120ecc449909e49a890dbc666ee2", "score": "0.8149035", "text": "function mvPushMatrix() {\n var copy = mat4.clone(mvMatrix);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "4ca5120ecc449909e49a890dbc666ee2", "score": "0.8149035", "text": "function mvPushMatrix() {\n var copy = mat4.clone(mvMatrix);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "4ca5120ecc449909e49a890dbc666ee2", "score": "0.8149035", "text": "function mvPushMatrix() {\n var copy = mat4.clone(mvMatrix);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "4ca5120ecc449909e49a890dbc666ee2", "score": "0.8149035", "text": "function mvPushMatrix() {\n var copy = mat4.clone(mvMatrix);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "b44b990af89e3d3bc8dfd4bcf84a39b5", "score": "0.802502", "text": "function mvPushMatrix() {\n\tvar copy = mat4.create();\n\tmat4.set(mvMatrix, copy);\n\tmvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "2755ad0d631afbca92bbafe3152200a9", "score": "0.80116403", "text": "function mvPushMatrix() {\n var copy = mat4.create();\n mat4.set(mvMatrix, copy);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "d9cb66e03ce8a43a64f905212fadb517", "score": "0.7995751", "text": "function mvPushMatrix() {\n var copy = mat4.clone(mvMatrix1);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "80860c995ffa7fe4a62c401510ba0e30", "score": "0.79814744", "text": "function mvPushMatrix() {\n var copy = mat4.create();\n mat4.set(mvMatrix, copy);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "80860c995ffa7fe4a62c401510ba0e30", "score": "0.79814744", "text": "function mvPushMatrix() {\n var copy = mat4.create();\n mat4.set(mvMatrix, copy);\n mvMatrixStack.push(copy);\n}", "title": "" }, { "docid": "0c7893a8a1d486398e816948a3c5f464", "score": "0.791768", "text": "function mvPushMatrix() \r\n{\r\n var copy = mat4.create();\r\n mat4.set(mvMatrix, copy);\r\n mvMatrixStack.push(copy);\r\n}", "title": "" }, { "docid": "049905e6a3ac9785000d3881fe3ccd98", "score": "0.7579706", "text": "function gPush() {\n MS.push(modelMatrix);\n}", "title": "" }, { "docid": "5e2c93f668b35731313843b58495e3a0", "score": "0.7441821", "text": "function gPush() {\n MS.push(modelMatrix) ;\n}", "title": "" }, { "docid": "176355c78503a998c7dc61ce2db85d8b", "score": "0.7308519", "text": "function pushMatrix(self) {\n var current;\n var stack;\n var current_depth = self.depth;\n var type;\n\n self.depth++;\n for (var i in self.matrices) {\n stack = self.matrices[i];\n current = stack[current_depth];\n type = (current.length == 9 ? mat3 : mat4);\n stack[self.depth] = stack[self.depth] || type.create();\n type.set(current, stack[self.depth]);\n }\n }", "title": "" }, { "docid": "60f6871737855c437b870f09a86c14ac", "score": "0.7156055", "text": "function mvPushMatrix(m,gContext) {\n if (m) {\n gContext.mvMatrixStack.push(m.dup());\n gContext.mvMatrix = m.dup();\n } else {\n gContext.mvMatrixStack.push(gContext.mvMatrix.dup());\n }\n}", "title": "" }, { "docid": "77c5e05e57d5c3cfb008a31b26219d42", "score": "0.70335937", "text": "function mPushMatrix() {\n let copy = mat4.clone(mMatrix);\n mMatrixPilha.push(copy);\n}", "title": "" }, { "docid": "cd3d8f5f4ae3d5f7c599b29987e2e385", "score": "0.6932765", "text": "function popMatrix() {\n modelview = matrixStack.pop();\n}", "title": "" }, { "docid": "e76cbb948dc6f18a4479f790f6ea26c6", "score": "0.67624974", "text": "function pushMatrix(m) { // Store the specified matrix to the array\r\n var m2 = new Matrix4(m);\r\n g_matrixStack.push(m2);\r\n}", "title": "" }, { "docid": "1ab72b1f5d7a616a1d1e5dbe09c772ff", "score": "0.6738803", "text": "function pushMatrix(m) { // Store the specified matrix to the array\n var m2 = new Matrix4(m);\n g_matrixStack.push(m2);\n}", "title": "" }, { "docid": "764555fe0e796ef3fbf2d245277e2180", "score": "0.6720241", "text": "function pushMatrix(m) { // Store the specified matrix to the array\n var m2 = new Matrix4(m);\n g_matrixStack.push(m2);\n}", "title": "" }, { "docid": "764555fe0e796ef3fbf2d245277e2180", "score": "0.6720241", "text": "function pushMatrix(m) { // Store the specified matrix to the array\n var m2 = new Matrix4(m);\n g_matrixStack.push(m2);\n}", "title": "" }, { "docid": "ce14152a46c2d23c879e3efc78d3cb1c", "score": "0.67178524", "text": "pushViewMatrix() {\n // We want to look down -z, so create a lookat point in that direction\n glMatrix.vec3.add(this.viewPt, this.eyePt, this.viewDir);\n // Then generate the lookat matrix and initialize the MV matrix to that view\n glMatrix.mat4.lookAt(mvMatrix,this.eyePt,this.viewPt,this.up);\n // lightPosition = staticLightPos*mvMatrix;\n //Draw Terrain\n mvPushMatrix();\n }", "title": "" }, { "docid": "75161347f8c22527a0851da901e6a075", "score": "0.6178276", "text": "function popMatrix() {\n\t\tviewMatrix = matrixStack.pop();\n\t\trefreshViewProjectionMatrix = true;\n\t}", "title": "" }, { "docid": "3040a7d3fb74d8c64fc4ff926ff27d4b", "score": "0.6085972", "text": "pushState() {\n this.depth++;\n this.stack.push({\n matrix: this.curr.matrix.clone(),\n hsv: this.curr.hsv.clone(),\n blend: utils.extend({}, this.curr.blend),\n alpha: this.curr.alpha\n });\n return this;\n }", "title": "" }, { "docid": "646e846da4ec3c3ff4019792fbc51c6a", "score": "0.58929497", "text": "function Stack(){\n this.stack = [];\n this.push = function(matrix){\n this.stack.push(mat4.clone(matrix));\n }\n this.pop = function(){\n return this.stack.pop();\n }\n}", "title": "" }, { "docid": "3556d1dc912e63f1912fdba489c42414", "score": "0.5867952", "text": "function mvPopMatrix() {\r\n if (mvMatrixStack.length == 0) {\r\n throw \"Invalid popMatrix!\";\r\n }\r\n mvMatrix = mvMatrixStack.pop();\r\n}", "title": "" }, { "docid": "3556d1dc912e63f1912fdba489c42414", "score": "0.5867952", "text": "function mvPopMatrix() {\r\n if (mvMatrixStack.length == 0) {\r\n throw \"Invalid popMatrix!\";\r\n }\r\n mvMatrix = mvMatrixStack.pop();\r\n}", "title": "" }, { "docid": "3556d1dc912e63f1912fdba489c42414", "score": "0.5867952", "text": "function mvPopMatrix() {\r\n if (mvMatrixStack.length == 0) {\r\n throw \"Invalid popMatrix!\";\r\n }\r\n mvMatrix = mvMatrixStack.pop();\r\n}", "title": "" }, { "docid": "3556d1dc912e63f1912fdba489c42414", "score": "0.5867952", "text": "function mvPopMatrix() {\r\n if (mvMatrixStack.length == 0) {\r\n throw \"Invalid popMatrix!\";\r\n }\r\n mvMatrix = mvMatrixStack.pop();\r\n}", "title": "" }, { "docid": "a7a96dea0a41a198485b6ffab24dca82", "score": "0.5865373", "text": "pushFrame() {\n this.stack.push(this.ra);\n this.stack.push(this.stack.fp);\n this.stack.fp = this.stack.sp - 1;\n }", "title": "" }, { "docid": "b1aeba1ae6dae2c378fc6aa148f336e9", "score": "0.5863533", "text": "function uploadModelViewMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "b1aeba1ae6dae2c378fc6aa148f336e9", "score": "0.5863533", "text": "function uploadModelViewMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "b1aeba1ae6dae2c378fc6aa148f336e9", "score": "0.5863533", "text": "function uploadModelViewMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "b193b27692c36078c0b7026b4d704816", "score": "0.58473474", "text": "function uploadModelViewMatrixToShader() {\n\tgl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "98cb8d8eea2b4cca2ab513ed6f0ca1ef", "score": "0.584227", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "98cb8d8eea2b4cca2ab513ed6f0ca1ef", "score": "0.584227", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "a7cc9d65adccc6938d97a7b59e6eac7e", "score": "0.58401996", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "a7cc9d65adccc6938d97a7b59e6eac7e", "score": "0.58401996", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "a7cc9d65adccc6938d97a7b59e6eac7e", "score": "0.58401996", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "a7cc9d65adccc6938d97a7b59e6eac7e", "score": "0.58401996", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "78c7b9d6f5f6e3c5c9b71ae9cd6ce4f4", "score": "0.5834595", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length == 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "78c7b9d6f5f6e3c5c9b71ae9cd6ce4f4", "score": "0.5834595", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length == 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "78c7b9d6f5f6e3c5c9b71ae9cd6ce4f4", "score": "0.5834595", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length == 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "2c7e93c3b383a132677a5da5b683eb4a", "score": "0.5833233", "text": "function mvPopMatrix() \r\n{\r\n if (mvMatrixStack.length == 0) \r\n throw \"Invalid popMatrix!\";\r\n \r\n mvMatrix = mvMatrixStack.pop();\r\n}", "title": "" }, { "docid": "fc61e4080ce26f786e1092a2238e8211", "score": "0.58224493", "text": "pushFrame() {\n this[INNER_VM].pushFrame();\n }", "title": "" }, { "docid": "b7512fba2d4f7d18bf530de91996adf9", "score": "0.58173794", "text": "function uploadModelViewMatrixToShader() {\r\n\tgl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "ef535ea771f22c71f39fc9f95da53317", "score": "0.5793401", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length === 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "fdc38476317074920fa7c5dc337e261c", "score": "0.57918537", "text": "function mvPopMatrix() {\n\tif (mvMatrixStack.length == 0) {\n\t\tthrow \"Invalid popMatrix!\";\n\t}\n\tmvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "5c2d31cf718b306fe42b82539b30d302", "score": "0.57899183", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length == 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "5c2d31cf718b306fe42b82539b30d302", "score": "0.57899183", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length == 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "5c2d31cf718b306fe42b82539b30d302", "score": "0.57899183", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length == 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "7b63bc53d5c494c70d598dba313bba96", "score": "0.57845604", "text": "function mvPopMatrix() {\r\n\tif (mvMatrixStack.length == 0) {\r\n\t\tthrow \"Invalid popMatrix!\";\r\n\t}\r\n\tmvMatrix = mvMatrixStack.pop();\r\n}", "title": "" }, { "docid": "df67fa68c77c4ca9209aa3aaac91e620", "score": "0.5776959", "text": "push() {\n this.stack.push(Object.assign({}, this.state))\n }", "title": "" }, { "docid": "136de835df3e2b63a3ae4ab38fc74078", "score": "0.5758", "text": "function mvPopMatrix() {\n if (mvMatrixStack.length == 0) {\n throw \"Invalid popMatrix!\";\n }\n mvMatrix1 = mvMatrixStack.pop();\n}", "title": "" }, { "docid": "1dafb44af34f9b38427d8212b06e5cf3", "score": "0.57514", "text": "function gPop() {\n modelMatrix = MS.pop();\n}", "title": "" }, { "docid": "5a4f20276b9732b60cfec956348d4f53", "score": "0.56718785", "text": "function gPop() {\n modelMatrix = MS.pop() ;\n}", "title": "" }, { "docid": "3ee604b5da6f38b5015adf6c1e0736f3", "score": "0.5651409", "text": "pushFrame() {\n this.stack.push(this.ra);\n this.stack.push(this.fp);\n this.fp = this.sp - 1;\n }", "title": "" }, { "docid": "4f704bfd54daf5cadaa07f1cb86f365d", "score": "0.5621278", "text": "function uploadModelViewMatrixToShader1() {\n gl.uniformMatrix4fv(shaderProgram1.mvMatrixUniform, false, mvMatrix1);\n}", "title": "" }, { "docid": "b18d9d7bf39d469ce0af30c8552c9691", "score": "0.55889076", "text": "_copyMatrix() {\n let newMat = this._createMatrix();\n for (let i = 0; i < this.rows; i++) {\n newMat[i] = [...this.matrix[i]];\n }\n return newMat;\n }", "title": "" }, { "docid": "8ecfa3c51b986b96f323a118754ee8d6", "score": "0.5585259", "text": "function updateModelViewMatrix(matrix) {\n gl.uniformMatrix4fv(gl.program.uModelViewMatrix, false, matrix);\n}", "title": "" }, { "docid": "c66e400222daa0a5482dad72f8612d47", "score": "0.54319066", "text": "function uploadModelViewMatrixToShader(program) {\r\n gl.uniformMatrix4fv(program.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "d78be86c0ea034b7639363dd31ce20b8", "score": "0.5404581", "text": "pushNewValues(AllMatrix)\n {\n let FlatMatrices = AllMatrix[0].slice();\n \n for( let i = 0 ; i < this.allLayersArray.length; i++)\n {\n this.WeightMatrices[i].modify(FlatMatrices[i])\n this.Biases[i].modify(AllMatrix[1][i].slice())\n }\n }", "title": "" }, { "docid": "9acf1f210c9c8f08be1e5f665ae6bc51", "score": "0.54022443", "text": "set matrix(value){this.modelProperties.matrix = value;}", "title": "" }, { "docid": "550dfe1ff595411243a473fa2ffac86b", "score": "0.5375031", "text": "push(item) {\n this.#stack.push(item);\n }", "title": "" }, { "docid": "647f05a5e995bacfabc68df566388da4", "score": "0.5369542", "text": "function cameraPush() {\n var pInst = this;\n var camera = pInst.camera;\n\n //awkward but necessary in order to have the camera at the center\n //of the canvas by default\n if(!camera.init && camera.position.x === 0 && camera.position.y === 0)\n {\n camera.position.x=pInst.width/2;\n camera.position.y=pInst.height/2;\n camera.init = true;\n }\n\n camera.mouseX = pInst.mouseX+camera.position.x-pInst.width/2;\n camera.mouseY = pInst.mouseY+camera.position.y-pInst.height/2;\n\n if(!camera.active)\n {\n camera.active = true;\n pInst.push();\n pInst.scale(camera.zoom);\n pInst.translate(-camera.position.x+pInst.width/2/camera.zoom, -camera.position.y+pInst.height/2/camera.zoom);\n }\n}", "title": "" }, { "docid": "cbc246284328be279297d640e9f1772b", "score": "0.5360689", "text": "updateMatrix(){\n this.matrix = Matrix3x3.FromProperties({\n position: this.getPosition(),\n rotation: this.getRotation(),\n scale: this.getScale(),\n anchorshift: this.getAnchorShift()\n });\n }", "title": "" }, { "docid": "9a7f974d65580bf34b2def87e51b7ac5", "score": "0.5342256", "text": "function pushState() {\n var gl = regl._gl;\n undoStack.push(stored_pixels);\n if (undoStack.length > 30) {\n undoStack.shift();\n }\n}", "title": "" }, { "docid": "ba966a85306611048aea55ec031d8b65", "score": "0.53394914", "text": "_updateStack(stack){\n //Viewlist add\n var index = this.findStackInViewList(stack.id);\n if (!~index)\n this.viewList.push(stack)\n\n this.emit('stackUpdated',stack);\n }", "title": "" }, { "docid": "2815ab5d054f7108edd37faf3c1e47bc", "score": "0.53326786", "text": "function push() {\n var lastState = newState(),\n i;\n\n copyModelState(lastState);\n list[listState.index + 1] = lastState;\n\n // Drop the oldest state if we went over the max list size\n if (list.length > listState.maxSize) {\n list.splice(0, 1);\n listState.startCounter++;\n } else {\n listState.index++;\n }\n listState.counter = listState.index + listState.startCounter;\n\n // Send push request to external objects defining TickHistoryCompatible Interface.\n for (i = 0; i < externalObjects.length; i++) {\n externalObjects[i].push();\n }\n\n invalidateFollowingState();\n listState.length = list.length;\n }", "title": "" }, { "docid": "64eb6ac70b45b5bf7a126f25ec6564c9", "score": "0.53007215", "text": "updateMatrix(){\n this.matrix = Matrix3x3.FromProperties({\n origin: this.getOrigin(),\n rotation: this.getRotation(),\n scale: this.getScale(),\n translation: this.getTranslation()\n });\n }", "title": "" }, { "docid": "d06aa9f66738e45bf9129a544b85e3e6", "score": "0.5297805", "text": "observe(matrix) {\n this.states.push({\n name: 'observe',\n product: new Matrix(),\n forwardFn: () => { },\n backpropagationFn: () => { },\n });\n return matrix;\n }", "title": "" }, { "docid": "3146d62b809ec17e4fff9fe4dd7e09cb", "score": "0.5287658", "text": "function updateModelViewMatrix() {\r\n let mv = glMatrix.mat4.fromRotationTranslationScale(glMatrix.mat4.create(),\r\n glMatrix.quat.fromEuler(glMatrix.quat.create(), ...rotation), position, scale);\r\n gl.uniformMatrix4fv(gl.program.uModelViewMatrix, false, mv);\r\n}", "title": "" }, { "docid": "bcb82ee244b2569962c60c94a702e94a", "score": "0.5283641", "text": "toggleModelMatrixHandInPlace() {\n const m = this._m;\n m[2] *= -1;\n m[6] *= -1;\n m[8] *= -1;\n m[9] *= -1;\n m[14] *= -1;\n this._markAsUpdated();\n }", "title": "" }, { "docid": "9cded4aed8b51e7fe08c1d7c95f9ec2d", "score": "0.52753645", "text": "function viewMatrix(eye, focus, up){\n //z represent deep between eye and focus\n var z = unitVector(vectorBetweenTwoPoints(eye, focus));\n //x is perpendicular of z that hellp us to create our new coordinate system\n var x = unitVector(vectorProduct(up,z));\n //y is perpendicular of z and x and the coordinate system is ready\n var y = unitVector(vectorProduct(z,x));\n //the last row of the matrix represent (0,0,0) in\n //our new coordinate system (projection of -eye)\n var matrix = [\n x[0], y[0], z[0], 0,\n x[1], y[1], z[1], 0,\n x[2], y[2], z[2], 0,\n -scalarProduct(x, eye),\n -scalarProduct(y, eye),\n -scalarProduct(z, eye),1];\n return new Float32Array(matrix);\n}", "title": "" }, { "docid": "c378d10d222b2bb1150eb6f34185ef6f", "score": "0.5266171", "text": "copy(matrix) {\n for (let i = 0; i < matrix.elements.length; i++) {\n this.elements[i] = matrix.elements[i];\n }\n\n return this;\n }", "title": "" }, { "docid": "225843ad63d50f88aad489fcf31c371c", "score": "0.52588075", "text": "function updateMatrixState() {\n objMatrixState.copy(obj.matrix);\n\n //reset all matrices because the state has been updated\n translateMatrix.makeTranslation(0, 0, 0);\n rotateMatrix.identity(); //not really needed\n scaleMatrix.makeScale(1, 1, 1);\n notchCounter = 0;\n quatState.copy(gizmosR.quaternion);\n}", "title": "" }, { "docid": "1aa8026057125c7843817a225396e8c1", "score": "0.52315795", "text": "function setMV() {\n modelViewMatrix = mult(viewMatrix,modelMatrix) ;\n gl.uniformMatrix4fv(modelViewMatrixLoc, false, flatten(modelViewMatrix) );\n normalMatrix = inverseTranspose(modelViewMatrix) ;\n gl.uniformMatrix4fv(normalMatrixLoc, false, flatten(normalMatrix) );\n}", "title": "" }, { "docid": "b61f08e6abd8f298f472d0bf0292173a", "score": "0.5194254", "text": "function updateModelView(modelView) {\n gl.uniformMatrix4fv(locations.modelView, false, flatten(modelView));\n}", "title": "" }, { "docid": "4a151fcf6004f4ceff927384c280053c", "score": "0.5182573", "text": "function setMV() {\n modelViewMatrix = mult(viewMatrix, modelMatrix);\n gl.uniformMatrix4fv(modelViewMatrixLoc, false, flatten(modelViewMatrix));\n normalMatrix = inverseTranspose(modelViewMatrix);\n gl.uniformMatrix4fv(normalMatrixLoc, false, flatten(normalMatrix));\n}", "title": "" }, { "docid": "f869c9b2ac07f9887ba5af298b303174", "score": "0.5156165", "text": "updateViewProjMatrix () {\n\t\tthis.viewProjMatrix.set();\n\t\n\t\tthis.viewProjMatrix.scale(0.5);\n\t\tthis.viewProjMatrix.scale(this.windowSize);\n\t\tthis.viewProjMatrix.rotate(this.rotation);\n\t\tthis.viewProjMatrix.translate(this.position);\n\n\t\tthis.viewProjMatrix.invert();\n\t}", "title": "" }, { "docid": "ba50aceaa8f2406e1cb2204fe0bc0ecd", "score": "0.51288384", "text": "pushFrame() {\n this.stack.push(this.registers[$ra]);\n this.stack.push(this.registers[$fp]);\n this.registers[$fp] = this.registers[$sp] - 1;\n }", "title": "" }, { "docid": "546692a406829510af732f972de12f02", "score": "0.5114539", "text": "addVertex() {\n this.size++;\n this.matrix.push([]);\n for (let i = 0; i < this.size; i++) {\n this.matrix[i][this.size - 1] = 0;\n this.matrix[this.size - 1][i] = 0;\n }\n }", "title": "" }, { "docid": "3f53ce9efb76838f975b60edd962dacc", "score": "0.51044434", "text": "hold () {\n\t\tif(this.hold_matrix != null ) {\n\t\t\tlet new_hold_matrix = this.matrix;\n\t\t\tthis.reset(this.hold_matrix);\n\t\t\tthis.hold_matrix = new_hold_matrix;\n\t\t} else {\n\t\t\tthis.hold_matrix = this.matrix;\n\t\t\tthis.reset();\n\t\t}\n\t}", "title": "" }, { "docid": "d4cba43819304bfe5ff8b12d24fa6cd3", "score": "0.509502", "text": "copyTo(matrix) {\n return matrix.a = this.a, matrix.b = this.b, matrix.c = this.c, matrix.d = this.d, matrix.tx = this.tx, matrix.ty = this.ty, matrix;\n }", "title": "" }, { "docid": "87b3c3d32ef747c4444e99cabde0c8ad", "score": "0.50893074", "text": "addToStack(stack, elem) {\n stack.push(elem);\n this.seen[elem.index] = 1;\n }", "title": "" }, { "docid": "ff1531c4bd3c7e59a38b6707670bed97", "score": "0.50805426", "text": "render() {\n this.shader.setUniform(\"u_ModelMatrix\", this.modelMatrix.elements);\n }", "title": "" }, { "docid": "2369b2c86b65498d534278bcd6cd9087", "score": "0.50747687", "text": "function makeModelTransform(currModel) {\n modelsArray.push( currModel );\n var pMatrix = mat4.create(); // projection matrix\n var vMatrix = mat4.create(); // view matrix\n var mMatrix = mat4.create(); // model matrix\n var pvMatrix = mat4.create(); // hand * proj * view matrices\n var pvmMatrix = mat4.create(); // hand * proj * view * model matrices\n\n mat4.perspective(pMatrix,0.5*Math.PI,1,0.1,10); // create projection matrix\n mat4.lookAt(vMatrix,Eye,Center,Up); // create view matrix\n mat4.multiply(pvMatrix,pvMatrix,pMatrix); // projection\n mat4.multiply(pvMatrix,pvMatrix,vMatrix); // projection * view\n \n var zAxis = vec3.create(), sumRotation = mat4.create(), temp = mat4.create(), negCtr = vec3.create();\n\n // move the model to the origin\n mat4.fromTranslation(mMatrix,vec3.negate(negCtr,currModel.center)); \n \n // scale for highlighting if needed\n if (currModel.on)\n mat4.multiply(mMatrix,mat4.fromScaling(temp,vec3.fromValues(1.2,1.2,1.2)),mMatrix); // S(1.2) * T(-ctr)\n \n // rotate the model to current interactive orientation\n vec3.normalize(zAxis,vec3.cross(zAxis,currModel.xAxis,currModel.yAxis)); // get the new model z axis\n mat4.set(sumRotation, // get the composite rotation\n currModel.xAxis[0], currModel.yAxis[0], zAxis[0], 0,\n currModel.xAxis[1], currModel.yAxis[1], zAxis[1], 0,\n currModel.xAxis[2], currModel.yAxis[2], zAxis[2], 0,\n 0, 0, 0, 1);\n mat4.multiply(mMatrix,sumRotation,mMatrix); // R(ax) * S(1.2) * T(-ctr)\n \n // translate back to model center\n mat4.multiply(mMatrix,mat4.fromTranslation(temp,currModel.center),mMatrix); // T(ctr) * R(ax) * S(1.2) * T(-ctr)\n\n // translate model to current interactive orientation\n mat4.multiply(mMatrix,mat4.fromTranslation(temp,currModel.translation),mMatrix); // T(pos)*T(ctr)*R(ax)*S(1.2)*T(-ctr)\n\n return mMatrix;\n \n} // end make model transform", "title": "" }, { "docid": "8cddd42e2843484f36bf7ed22ea0d2c9", "score": "0.50485337", "text": "enqueue (item) {\n this.inputStack.push(item)\n }", "title": "" }, { "docid": "73842e6e410e9f5233110164ed78d945", "score": "0.50427765", "text": "function makeModelTransform(currModel) {\n var zAxis = vec3.create(), sumRotation = mat4.create(), temp = mat4.create(), negCtr = vec3.create();\n\n // move the model to the origin\n mat4.fromTranslation(mMatrix,vec3.negate(negCtr,currModel.center)); \n \n // scale for highlighting if needed\n if (currModel.on)\n mat4.multiply(mMatrix,mat4.fromScaling(temp,vec3.fromValues(1.2,1.2,1.2)),mMatrix); // S(1.2) * T(-ctr)\n \n // rotate the model to current interactive orientation\n vec3.normalize(zAxis,vec3.cross(zAxis,currModel.xAxis,currModel.yAxis)); // get the new model z axis\n mat4.set(sumRotation, // get the composite rotation\n currModel.xAxis[0], currModel.yAxis[0], zAxis[0], 0,\n currModel.xAxis[1], currModel.yAxis[1], zAxis[1], 0,\n currModel.xAxis[2], currModel.yAxis[2], zAxis[2], 0,\n 0, 0, 0, 1);\n mat4.multiply(mMatrix,sumRotation,mMatrix); // R(ax) * S(1.2) * T(-ctr)\n \n // translate back to model center\n mat4.multiply(mMatrix,mat4.fromTranslation(temp,currModel.center),mMatrix); // T(ctr) * R(ax) * S(1.2) * T(-ctr)\n\n // translate model to current interactive orientation\n mat4.multiply(mMatrix,mat4.fromTranslation(temp,currModel.translation),mMatrix); // T(pos)*T(ctr)*R(ax)*S(1.2)*T(-ctr)\n \n } // end make model transform", "title": "" }, { "docid": "684a6945241663b18acc4c537fb3ac1e", "score": "0.5027103", "text": "push(element){\n\t\t++this.top;\n\t\tthis.StackArry[this.top] = element;\n\t}", "title": "" }, { "docid": "2b8d091fb02ebbda8d6e13f165860fd0", "score": "0.502084", "text": "append(matrix) {\n const a1 = this.a, b1 = this.b, c1 = this.c, d1 = this.d;\n return this.a = matrix.a * a1 + matrix.b * c1, this.b = matrix.a * b1 + matrix.b * d1, this.c = matrix.c * a1 + matrix.d * c1, this.d = matrix.c * b1 + matrix.d * d1, this.tx = matrix.tx * a1 + matrix.ty * c1 + this.tx, this.ty = matrix.tx * b1 + matrix.ty * d1 + this.ty, this;\n }", "title": "" } ]
9cd8a25a931a15142e3d2e140f501dac
RFC 2822 compliant regex for checking valid email addresses
[ { "docid": "a4900b0d24879dce2677bc3dc9b0a319", "score": "0.705129", "text": "function isValidEmailAddress(email) {\n return email.match(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/);\n}", "title": "" } ]
[ { "docid": "4d9b29dd352abcd14a44de0716609250", "score": "0.7508389", "text": "function isEmail( value ) {\n\t// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/\n\treturn /^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))$/i.test(value);\n}", "title": "" }, { "docid": "c6c176d099af182a68792416f9cc3201", "score": "0.7444136", "text": "function isValidEmailAddress(emailAddress) {\r\n var pattern = new RegExp(/^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?$/i);\r\n return pattern.test(emailAddress);\r\n}", "title": "" }, { "docid": "83928319d0f4acd07e4ed9c20ff657a6", "score": "0.73310006", "text": "function isValidEmailAddress(emailAddress) {\r\n\t\tvar pattern = new RegExp(/^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?$/i);\r\n\t\treturn pattern.test(emailAddress);\r\n\t}", "title": "" }, { "docid": "f62c3b09098637c2eef02595271b25f8", "score": "0.7321462", "text": "function valid_email_address(email) {\n var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/i);\n return pattern.test(email);\n }", "title": "" }, { "docid": "4c40db51f66868dac9200c0c550a915c", "score": "0.7320503", "text": "emailIsValid(email) {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);\n }", "title": "" }, { "docid": "e2173ce2bed171561aea443aa566b9a8", "score": "0.7295188", "text": "function mightBeEmail(s) {\n\t // There's no point trying to validate rfc822 fully, just look for ...@...\n\t return (/[^@]+@[^@]+/).test(s);\n\t}", "title": "" }, { "docid": "e2173ce2bed171561aea443aa566b9a8", "score": "0.7295188", "text": "function mightBeEmail(s) {\n\t // There's no point trying to validate rfc822 fully, just look for ...@...\n\t return (/[^@]+@[^@]+/).test(s);\n\t}", "title": "" }, { "docid": "e2173ce2bed171561aea443aa566b9a8", "score": "0.7295188", "text": "function mightBeEmail(s) {\n\t // There's no point trying to validate rfc822 fully, just look for ...@...\n\t return (/[^@]+@[^@]+/).test(s);\n\t}", "title": "" }, { "docid": "037e7d6454cf60095e29614cbde3061d", "score": "0.7281196", "text": "function CheckEmail(email){\n if(/(?!.*\\.{2})^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i.test(email)){\n return true;\n }\n else {\n return false;\n }\n}", "title": "" }, { "docid": "e4213738b382990b1435f3bffe7fc86b", "score": "0.7235869", "text": "function mightBeEmail(s) {\n\t // There's no point trying to validate rfc822 fully, just look for ...@...\n\t return (/[^@]+@[^@]+/.test(s)\n\t );\n\t}", "title": "" }, { "docid": "b62ce0131b145bd0374a47dff4cfbe5b", "score": "0.7218186", "text": "function validateEmail(email) \n{\n var regexp = /\\S+@\\S+\\.\\S+/;\t//format: [email protected] \n return regexp.test(email);\t\t//Not perfect but is sufficient enough\n}", "title": "" }, { "docid": "ab793116d390b5eff532399aefdcf273", "score": "0.71850073", "text": "function emailcheck(email) {\n var pattern = /^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i;\n var result = pattern.test(email);\n return result;\n}", "title": "" }, { "docid": "ccc88f16148d3a2fb3ab843f09a9e394", "score": "0.7184714", "text": "function checkEmail ( str ) {\n var myreg = /(^[a-zA-Z]+[@][a-zA-Z]+[.][a-zA-Z]{3}$)/;\n return myreg.test(str);\n}", "title": "" }, { "docid": "b43d84e164e83975f2b344d62fc61a6a", "score": "0.7183093", "text": "function isValidEmail(emailAddress) {\r\n var pattern = new RegExp(/^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?$/i);\r\n return pattern.test(emailAddress);\r\n }", "title": "" }, { "docid": "d5b86b587264dcae507e9e3a65a27855", "score": "0.71781784", "text": "function validEmail(text)\n{\n if(text.match(/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/)) {\n return true;\n }\n else\n {\n return false;\n }\n}", "title": "" }, { "docid": "d5b86b587264dcae507e9e3a65a27855", "score": "0.71781784", "text": "function validEmail(text)\n{\n if(text.match(/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/)) {\n return true;\n }\n else\n {\n return false;\n }\n}", "title": "" }, { "docid": "18e866da93bdff6ec78dd93b799345aa", "score": "0.7175274", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = new RegExp(/^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?$/i);\n return pattern.test(emailAddress);\n }", "title": "" }, { "docid": "2aad016c1c169e6e7a9efcffa44f22c8", "score": "0.7133018", "text": "function validateEmail(email) \n{\n var re = /^(?:[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$/;\n return re.test(email);\n}", "title": "" }, { "docid": "c7d781a70bed279ca5392a69e360c06a", "score": "0.71316814", "text": "function emailIsValid(email) {\n\tvar filter=/\\S+@\\S+/;\n\treturn filter.test(email);\n}", "title": "" }, { "docid": "d32ac3441bd2857df1c3494d2015f6b5", "score": "0.7129667", "text": "function emailIsValid(email) \n{\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);\n}", "title": "" }, { "docid": "ff1c4827d8b5d61eca9cb9afa9d2f549", "score": "0.71195936", "text": "function validateEmail(email)\n{\n var splitted = email.match(\"^(.+)@(.+)$\");\n if (splitted == null) return false;\n if (splitted[1] != null)\n {\n var regexp_user = /^\\\"?[\\w-_\\.]*\\\"?$/;\n if (splitted[1].match(regexp_user) == null) return false;\n }\n if (splitted[2] != null)\n {\n var regexp_domain = /^[\\w-\\.]*\\.[A-Za-z]{2,4}$/;\n if (splitted[2].match(regexp_domain) == null)\n {\n var regexp_ip = /^\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\]$/;\n if (splitted[2].match(regexp_ip) == null) return false;\n } // if\n return true;\n }\n return false;\n}", "title": "" }, { "docid": "a95ecdb6572bfe98c359013c757f78be", "score": "0.70798695", "text": "function email_validation(email){\n var mailformat = /^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/;\n if(email.match(mailformat)){\n return true;\n }\n else{\n return false\n }\n }", "title": "" }, { "docid": "346cf965f97bce3b749d069645b7088d", "score": "0.7070839", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = /^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i;\n return pattern.test(emailAddress);\n}", "title": "" }, { "docid": "be790d3dd8761bf00e893db963973225", "score": "0.70615876", "text": "function isValidEmail_old(email)\n{\n // First, we check that there's one @ symbol, and that the lengths are right\n if (!/^[^@]{1,64}@[^@]{1,255}$/.test(email)) {\n // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.\n return false;\n }\n // Split it into sections.\n email_array = email.split('@');\n local_array = email_array[0].split('.');\n for (i = 0; i < local_array.length; i++) {\n if (!'/^(([A-Za-z0-9!$%&\\'*+/=?^_`{|}~-][A-Za-z0-9!$%&\\'*+/=?^_`{|}~\\.-]{0,63})|(\\\"[^(\\\\|\\\")]{0,62}\\\"))$/'.test(local_array[i])) {\n return false;\n }\n }\n if (!/^\\[?[0-9\\.]+\\]?$/.test(email_array[1])) {\n // Check if domain is IP. If not, it should be valid domain name\n domain_array = email_array[1].split('.');\n if (domain_array.length < 2) {\n return false; // Not enough parts to domain\n }\n for (i = 0; i < domain_array.length; i++) {\n if (!/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$/.test(domain_array[i])) {\n return false;\n }\n }\n }\n return true;\n}", "title": "" }, { "docid": "acafd54785977b9ab38c661c68286f8e", "score": "0.70603836", "text": "function isValid(str) {\r var emailFilter = /^.+@.+\\..{2,3}$/;\r if(!(str.match(emailFilter))) {\r return false;\r } \r else {\r return true;\r }\r}", "title": "" }, { "docid": "1014f54c922e9069a92b4c45d6aa82a3", "score": "0.7057834", "text": "function mightBeEmail(s) {\n // There's no point trying to validate rfc822 fully, just look for ...@...\n return typeof s === 'string' && s.indexOf('@') !== -1;\n }", "title": "" }, { "docid": "4a011907f85cf4e6e140e716f05cdef2", "score": "0.7036985", "text": "function mightBeEmail(s) {\n // There's no point trying to validate rfc822 fully, just look for ...@...\n return typeof s === 'string' && s.indexOf('@') !== -1;\n}", "title": "" }, { "docid": "4a011907f85cf4e6e140e716f05cdef2", "score": "0.7036985", "text": "function mightBeEmail(s) {\n // There's no point trying to validate rfc822 fully, just look for ...@...\n return typeof s === 'string' && s.indexOf('@') !== -1;\n}", "title": "" }, { "docid": "0d3f1779518100a7e426cca2fe8498b7", "score": "0.70195967", "text": "function isValidEmail(address) {\n\tif (address.indexOf('@') < 1) return false;\n\tvar name = address.substring(0, address.indexOf('@'));\n\tvar domain = address.substring(address.indexOf('@') + 1);\n\tif (name.indexOf('(') != -1 || name.indexOf(')') != -1 || name.indexOf('<') != -1 || name.indexOf('>') != -1 || name.indexOf(',') != -1 || name.indexOf(';') != -1 || name.indexOf(':') != -1 || name.indexOf('\\\\') != -1 || name.indexOf('\"') != -1 || name.indexOf('[') != -1 || name.indexOf(']') != -1 || name.indexOf(' ') != -1) return false;\n\tif (domain.indexOf('(') != -1 || domain.indexOf(')') != -1 || domain.indexOf('<') != -1 || domain.indexOf('>') != -1 || domain.indexOf(',') != -1 || domain.indexOf(';') != -1 || domain.indexOf(':') != -1 || domain.indexOf('\\\\') != -1 || domain.indexOf('\"') != -1 || domain.indexOf('[') != -1 || domain.indexOf(']') != -1 || domain.indexOf(' ') != -1) return false;\n\treturn true;\n}", "title": "" }, { "docid": "871e6c1d51955a6be3dce1cfa7497a58", "score": "0.69978476", "text": "function emailIsValid(email){\n let pattern = /\\S+@\\S+\\.\\S+/;\n return pattern.test(email);\n}", "title": "" }, { "docid": "dca52f907532963214cec55da6f3bb3d", "score": "0.69744796", "text": "function validEmail(email) {\r\n return /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/.test(email);\r\n}", "title": "" }, { "docid": "31e728afbcf4da1d85f307a5a4bd840e", "score": "0.69717515", "text": "function validateEmail(email) {\n if (email.value !== \"\") {\n var regex = /([a-z0-9][-a-z0-9_\\+\\.]*[a-z0-9])@([a-z0-9][-a-z0-9\\.]*[a-z0-9]\\.(arpa|root|aero|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|tv|me|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|([0-9]{1,3}\\.{3}[0-9]{1,3}))+$/;\n if (!regex.test(email.value)) {\n var error = \"Please enter an email formatted as [email protected]\";\n return error;\n } else {\n return false;\n }\n }\n}", "title": "" }, { "docid": "7b6a9109e0a6928cc5f4241ab14f70f8", "score": "0.69653565", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = /^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i;\n return pattern.test(emailAddress);\n}", "title": "" }, { "docid": "d01d679d5cb37d0a6071db5f9f35087f", "score": "0.6960049", "text": "function isValidEmail(email) {\n var acceptedSymbols = [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\",\n \"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"0\",\".\",\"_\"];\n var alphabet = [\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\"];\n // Contains one and only one \"@\" symbol\n var splitAtEmail = email.split(\"@\");\n if (splitAtEmail.length > 2) {\n return false;\n }\n // All the characters before the \"@\" symbol are alphanumeric, underscores, or dots \".\"\n var emailFirstHalf = splitAtEmail[0];\n for (var i = 0; i < emailFirstHalf.length; i++) {\n if (acceptedSymbols.indexOf(emailFirstHalf[i]) === -1) {\n return false;\n }\n }\n // There is one and only one dot \".\" after the \"@\" symbol\n var splitDotEmail = splitAtEmail[1].split(\".\");\n if (splitDotEmail.length > 2) {\n return false;\n }\n // Besides the dot \".\", all the characters after the \"@\" are in the alphabet (no numbers or underscores)\n var emailSecondHalf = splitDotEmail[0];\n for (var j = 0; j < emailSecondHalf.length; j++) {\n if (alphabet.indexOf(emailSecondHalf[j]) === -1) {\n return false;\n }\n }\n return true;\n}", "title": "" }, { "docid": "2b412c18440b0753e8f91a73d1b4cc03", "score": "0.69487846", "text": "validateEmail(email) {\n var re = /^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$/i;\n return re.test(email);\n }", "title": "" }, { "docid": "3e53e018f446eee57bf62e9f598989aa", "score": "0.69347024", "text": "function emailIsValid (email) {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)\n}", "title": "" }, { "docid": "238142c640883f6fd3f799af3b377ad0", "score": "0.69334334", "text": "function validateEmail(email) {\n const regEx = /\\S+@\\S+\\.\\S+/;\n const patternMatches = regEx.test(email);\n return patternMatches;\n}", "title": "" }, { "docid": "8e249a5cc7aadcf2d51eb04bedb53af7", "score": "0.6905474", "text": "function validateEmail(email) \r\n{\r\n var re = /\\S+@\\S+\\.\\S+/;\r\n return re.test(email);\r\n}", "title": "" }, { "docid": "3552cdfd4506437cee60c04afad86afd", "score": "0.69016236", "text": "function validateEmail(email){ \n if(email.match(/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/)) \n return true;\n else\n return false;\n }", "title": "" }, { "docid": "d60bae7a2db127536ea776d30090675d", "score": "0.68963146", "text": "function validateEmail(email) {\n return emailRE.test(email);\n}", "title": "" }, { "docid": "bb69b56770fd5ec143d61086b35cd5de", "score": "0.6894996", "text": "function emailIsValid(email) {\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)\n}", "title": "" }, { "docid": "c3b927197321050946e2e6b5127327ca", "score": "0.6890407", "text": "validateEmail(inp) {\n if (/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/.test(inp)) // email must match this pattern\n {\n return true;\n }\n else {\n return false;\n }\n }", "title": "" }, { "docid": "a6836c4aba56662d6d635933d7cd4bed", "score": "0.6889655", "text": "function isValidEmail (str) {\n return /^[a-zA-Z0-9._-]+@[a-z0-9._-]{2,}\\.[a-z]{2,4}$/.test(str)\n}", "title": "" }, { "docid": "2b12eb9d80b049c38a385b9ed1f5c475", "score": "0.6889308", "text": "function email_pattern(email) {\n var regex = /^([a-zA-Z0-9_.+-])+\\@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$/;\n return regex.test(email);\n }", "title": "" }, { "docid": "617c3c96b97b0c01bbcbbc61c4f4d005", "score": "0.6887487", "text": "function validateEmail(email) {\n var checkFor = /\\S+@\\S+\\.\\S+/;\n return checkFor.test(email);\n}", "title": "" }, { "docid": "17e5e052ac92fadf4f6b20819da7864b", "score": "0.68759745", "text": "function isProperEmail(argEmail) {\n\tif (charOccurences(argEmail, '@') + charOccurences(argEmail, '.') < 2)\n\t\treturn false\n\n\tvar atPos = argEmail.indexOf('@')\n\tvar dotPos = argEmail.indexOf('.')\n\n\tif((atPos == 0) || (atPos == (argEmail.length - 1)))\n\t\treturn false\n\n\tif((dotPos == 0) || (dotPos == (argEmail.length - 1)))\n\t\treturn false\n\t\n\t/* This logic is incorrect JMA 12/18/03 */\n\t/* if((atPos > dotPos) || (atPos == (dotPos - 1)))\n\t\treturn false */\n\t\n\t/* The following variable tells the rest of the function whether or not\n\tto verify that the address ends in a two-letter country or well-known\n\tTLD. 1 means check it, 0 means don't. */\n \n\tvar checkTLD=1;\n \n\t/* The following is the list of known TLDs that an e-mail address must end with. */\n \n\tvar knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;\n \n\t/* The following pattern is used to check if the entered e-mail address\n\tfits the user@domain format. It also is used to separate the username\n\tfrom the domain. */\n \n\tvar emailPat=/^(.+)@(.+)$/;\n \n\t/* The following string represents the pattern for matching all special\n\tcharacters. We don't want to allow special characters in the address. \n\tThese characters include ( ) < > @ , ; : \\ \" . [ ] */\n \n\tvar specialChars=\"\\\\(\\\\)><@,;:\\\\\\\\\\\\\\\"\\\\.\\\\[\\\\]\";\n \n\t/* The following string represents the range of characters allowed in a \n\tusername or domainname. It really states which chars aren't allowed.*/\n \n\tvar validChars=\"\\[^\\\\s\" + specialChars + \"\\]\";\n \n\t/* The following pattern applies if the \"user\" is a quoted string (in\n\twhich case, there are no rules about which characters are allowed\n\tand which aren't; anything goes). E.g. \"jiminy cricket\"@disney.com\n\tis a legal e-mail address. */\n \n\tvar quotedUser=\"(\\\"[^\\\"]*\\\")\";\n \n\t/* The following pattern applies for domains that are IP addresses,\n\trather than symbolic names. E.g. joe@[123.124.233.4] is a legal\n\te-mail address. NOTE: The square brackets are required. */\n \n\tvar ipDomainPat=/^\\[(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\]$/;\n \n\t/* The following string represents an atom (basically a series of non-special characters.) */\n \n\tvar atom=validChars + '+';\n \n\t/* The following string represents one word in the typical username.\n\tFor example, in [email protected], john and doe are words.\n\tBasically, a word is either an atom or quoted string. */\n \n\tvar word=\"(\" + atom + \"|\" + quotedUser + \")\";\n \n\t// The following pattern describes the structure of the user\n \n\tvar userPat=new RegExp(\"^\" + word + \"(\\\\.\" + word + \")*$\");\n \n\t/* The following pattern describes the structure of a normal symbolic\n\tdomain, as opposed to ipDomainPat, shown above. */\n \n\tvar domainPat=new RegExp(\"^\" + atom + \"(\\\\.\" + atom +\")*$\");\n \n\t/* Finally, let's start trying to figure out if the supplied address is valid. */\n \n\t/* Begin with the coarse pattern to simply break up user@domain into\n\tdifferent pieces that are easy to analyze. */\n \n\tvar matchArray=argEmail.match(emailPat);\n \n\tif (matchArray==null)\n\t\t{\n \n\t\t/* Too many/few @'s or something; basically, this address doesn't\n\t\teven fit the general mould of a valid e-mail address. */\n \n\t\treturn false;\n\t\t}\n\tvar user=matchArray[1];\n\tvar domain=matchArray[2];\n \n\t// Start by checking that only basic ASCII characters are in the strings (0-127).\n \n\tfor (i=0; i<user.length; i++)\n\t\t{\n\t\tif (user.charCodeAt(i)>127)\n\t\t\t{\n\t\t\treturn false;\n\t\t\t}\n\t\t}\n\tfor (i=0; i<domain.length; i++)\n\t\t{\n\t\tif (domain.charCodeAt(i)>127)\n\t\t\t{\n\t\t\treturn false;\n\t\t\t}\n\t\t}\n \n\t// See if \"user\" is valid \n \n\tif (user.match(userPat)==null)\n\t\t{\n\t\t// user is not valid\n\t\treturn false;\n\t}\n \n\t/* if the e-mail address is at an IP address (as opposed to a symbolic\n\thost name) make sure the IP address is valid. */\n \n\tvar IPArray=domain.match(ipDomainPat);\n\tif (IPArray!=null)\n\t\t{\n\t\t// this is an IP address\n\t\tfor (var i=1;i<=4;i++)\n\t\t\t{\n\t\t\tif (IPArray[i]>255)\n\t\t\t\t{\n\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\treturn true;\n\t\t}\n \n\t// Domain is symbolic name. Check if it's valid.\n \n\tvar atomPat=new RegExp(\"^\" + atom + \"$\");\n\tvar domArr=domain.split(\".\");\n\tvar len=domArr.length;\n\tfor (i=0;i<len;i++)\n\t\t{\n\t\tif (domArr[i].search(atomPat)==-1)\n\t\t\t{\n\t\t\treturn false;\n\t\t\t}\n\t\t}\n \n\t/* domain name seems valid, but now make sure that it ends in a\n\tknown top-level domain (like com, edu, gov) or a two-letter word,\n\trepresenting country (uk, nl), and that there's a hostname preceding \n\tthe domain or country. */\n \n\tif (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)\n\t\t{\n\t\treturn false;\n\t\t}\n \n\t// Make sure there's a host name preceding the domain.\n\tif (len<2)\n\t\t{\n\t\treturn false;\n\t\t}\n \n\t// If we've gotten this far, everything's valid!\n\treturn true;\n}", "title": "" }, { "docid": "cf6de824e65939dcbfca2ab512fbefb3", "score": "0.68625426", "text": "validateEmail(email) {\n var re = /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(email);\n }", "title": "" }, { "docid": "839c7f765cca7a7f37f43e91ec7422c8", "score": "0.68611604", "text": "validateEmail(email) {\n const re = /^(([^<>()\\[\\]\\.,;:\\s@\\\"]+(\\.[^<>()\\[\\]\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@(([^<>()[\\]\\.,;:\\s@\\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\\"]{2,})$/i;\n return re.test(email);\n }", "title": "" }, { "docid": "774362daa2eb3d9d17f7d8bf08043078", "score": "0.6858985", "text": "validateEmail(email) {\n\t\t//regex string taken from http://emailregex.com/\n var re = /^(([^<>()\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(email);\n\t}", "title": "" }, { "docid": "542e9c8289fd0f1ef15ac0bc4a1281f5", "score": "0.68586415", "text": "function validate_email(email) {\n if (/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/.test(email.value)) {\n return (true);\n }\n return (false);\n}", "title": "" }, { "docid": "f9f881c4eb66bc5fed441c62e86bb98a", "score": "0.6853207", "text": "function emailValido(mail) {\r\r\n\treturn mail.match(/[0-9A-Za-z\\.\\_\\-]+\\@{1,1}[0-9A-Za-z\\_\\-]+\\.{1,1}[0-9A-Za-z\\_\\-]+/);\r\r\n}", "title": "" }, { "docid": "6fd165beb0acf90243ca57a20e0ea982", "score": "0.6846536", "text": "isValidEmail(email) {\n if (/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/.test(email)) {\n return true;\n }\n return false;\n }", "title": "" }, { "docid": "e7abb069104a46f110fb1279a7f98378", "score": "0.68422496", "text": "function validateEmail(inputText) {\n var emailFormat = /^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{3})+$/;\n if (inputText.match(emailFormat)) {\n return true;\n } else {\n return false;\n }\n }", "title": "" }, { "docid": "49333bbbc27e65483c2065110ec28d0d", "score": "0.68401617", "text": "function validEmailAddressNaked(str) {\n //alert('validEmailAddressNaked(' + str + ')');\n var at=\"@\";\n var dot=\".\";\n var atIndex=str.indexOf(at);\n var stringLength=str.length;\n var dotIndex=str.indexOf(dot);\n if (atIndex==-1 || atIndex===0 || atIndex>=(stringLength-4)) { badEmailAlert(); return false; }\n if (dotIndex==-1 || dotIndex===0 || dotIndex>=(stringLength-2)) { badEmailAlert(); return false; }\n if (str.indexOf(at,(atIndex+1))!=-1) { badEmailAlert(); return false; }\n if (str.substring(atIndex-1,atIndex)==dot || str.substring(atIndex+1,atIndex+2)==dot) { badEmailAlert(); return false; }\n if (str.indexOf(dot,(atIndex+2))==-1) { badEmailAlert(); return false; }\n if (str.indexOf(\" \")!=-1) { badEmailAlert(); return false; }\n return true;\n}", "title": "" }, { "docid": "1080c5874841cd5e6d95d5a6721c7e03", "score": "0.6833816", "text": "function valid_address(val) {\n return val.match(/^[[email protected]]+$/);\n}", "title": "" }, { "docid": "b4b99bd54b613c20e30ced56d31bb450", "score": "0.6828877", "text": "function isValidEmail(emailAddress) {\r\n\r\nvar pattern = new RegExp(/^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i);\r\n\r\n return pattern.test(emailAddress);\r\n\r\n}", "title": "" }, { "docid": "0556b004b407c3a8e08199b50fb10ad6", "score": "0.6827936", "text": "function validateEmail(){\n \tif( !(/\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)/) ) {\n \t\talert ('Ingrese un email valido!');\n \t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\treturn true\n\t\t}\n\t}", "title": "" }, { "docid": "53bda59ce19eed7eb10bc79f8f95cc75", "score": "0.68275136", "text": "function isValidEmail(email) {\n return /^[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,4}$/.test(email)\n && /^(?=.{1,64}@.{4,64}$)(?=.{6,100}$).*/.test(email);\n}", "title": "" }, { "docid": "3d618399ef69596611276c7a8a7c7ccb", "score": "0.6824756", "text": "function checkEmailRfc(arg)\n{\n return /^([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22))*\\x40([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d))*$/.test( arg );\n}", "title": "" }, { "docid": "ef2c9f17b84045fbb7fe34ba58ce44ac", "score": "0.67997015", "text": "function validateEmail(email){\n var re = /\\S+@\\S+\\.\\S+/;\n //return true if valid email\n return re.test(email);\n}", "title": "" }, { "docid": "2e534149f088506e9dc9fbef8b9c4131", "score": "0.6794622", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = /^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i;\n return pattern.test(emailAddress);\n }", "title": "" }, { "docid": "1d5ab993287059ec1d654a04b0644671", "score": "0.67936647", "text": "function checkEmailAddress(str) {\n if(str.includes('@') && str.includes('.') && str.lastIndexOf('@') !== str.length - 1 && str.lastIndexOf('.') !== str.length - 1 && str.indexOf('.', str.indexOf('@')) !== str.indexOf('@') + 1 && str.lastIndexOf('.', str.indexOf('@')) !== str.indexOf('@') - 1 && str.includes('..') === false && str.indexOf('@') !== 0 && str.lastIndexOf('.') > str.indexOf('@')){\n log('valid email?', true)\n }\n else {\n log('valid email?', false)\n }\n\n}", "title": "" }, { "docid": "0c5e28a1eb5d5f739af992e1318418d8", "score": "0.6790467", "text": "function validateEmail(email) { // regex text email validation from SO\n var re = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(email);\n}", "title": "" }, { "docid": "8995772fcb19b02b81dec9e76b55cb14", "score": "0.67875814", "text": "function validateEmail(email) {\n if (email.search(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/)) {\n return false;\n }\n return true;\n}", "title": "" }, { "docid": "ecd16f1e114e0211061bc6250f9637d1", "score": "0.67772585", "text": "function validaEmail(inputField) {\r\n if (!validateNonEmpty(inputField))\r\n return false;\r\n if (validateRegEx(\"/^\\w+@\\w+\\.\\w{2,3}$/\", inputField.value))\r\n return false;\r\n return true;\r\n}", "title": "" }, { "docid": "49c646aea6c9d46fea0b861d115f2e61", "score": "0.67747366", "text": "function validateEmail(email){\n regex = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}/igm;\n return regex.test(email);\n }", "title": "" }, { "docid": "27d8fb207c9e405763f7d93b331c2bfc", "score": "0.6772674", "text": "function validateMail(mail) {\n var rfc2822regex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;\n return rfc2822regex.test(mail);\n}", "title": "" }, { "docid": "2d89a656a3c306371e5855812c1ae4f9", "score": "0.6772589", "text": "function validateEmail(mail) \n { \n if (/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/.test(mail)) \n { \n return (true);\n } \n return (false); \n}", "title": "" }, { "docid": "7e4c8f0b95d29a3e8abc044ca9f82633", "score": "0.6769134", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = /^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i;\n return pattern.test(emailAddress);\n }", "title": "" }, { "docid": "ef1ae816e891c82f7abe801dd8b3e736", "score": "0.674451", "text": "function valid(email) {\n myArr = email.toLowerCase().split('');\n \n if (myArr.indexOf('@') == -1) {\n return false;\n } \n if (myArr.indexOf('.') == -1) {\n return false;\n } \n var firstCharIsLetter = email[0].match(/[a-z]/);\n\n if (firstCharIsLetter == null) {\n return false\n }\n var emailParts = email.split('@');\n var emailParts2 = email.split('.');\n\n if (emailParts[0].match(/[a-z0-9_]/) && emailParts[1].match(/[a-z0-9_\\-]/) && emailParts2[1].match(/[a-z0-9_]/)) {\n return true\n }\n \n}", "title": "" }, { "docid": "7e91e59ffef788691e6d6a05b8cbc466", "score": "0.6743847", "text": "function isValidEmail(givenStr){\n var retStatus = false;\n try{\n var regex = /^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/;\n if(givenStr.match(regex) && givenStr!==''){\n retStatus = true;\n }\n }catch(ex){\n // console.log(\"problem in isValidEmail ex=>\"+ex);\n }\n return retStatus;\n}", "title": "" }, { "docid": "80bf15b4f689299f4d29a9159b796414", "score": "0.67353046", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = /^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i;\n return pattern.test(emailAddress);\n }", "title": "" }, { "docid": "3ae3450628301fe9868d4ee5140ed760", "score": "0.6733692", "text": "function validateEmail(email) {\n var emailReg = new RegExp(/^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i);\n var valid = emailReg.test(email);\n if (!valid) {\n return false;\n } else {\n return true;\n }\n }", "title": "" }, { "docid": "6c54d0d5c5dbade7d7ab9af66db14f36", "score": "0.6722436", "text": "function testValidEmail(testString){\n return EMAIL_REGEX.test(testString);\n}", "title": "" }, { "docid": "7cd5c1db299f55663345da4b9d3904be", "score": "0.6720792", "text": "function isEmailAddress( text ) {\nvar email = EMAIL_ADDRESS_PATTERN;\nreturn email.test( text );\n}", "title": "" }, { "docid": "1873b3f0adf9064efa35b51b17f09f29", "score": "0.6717103", "text": "function isValidEmailAddress(emailAddress) {\n\t\t\tvar pattern = /^([a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+(\\.[a-z\\d!#$%&'*+\\-\\/=?^_`{|}~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+)*|\"((([ \\t]*\\r\\n)?[ \\t]+)?([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f\\x21\\x23-\\x5b\\x5d-\\x7e\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))*(([ \\t]*\\r\\n)?[ \\t]+)?\")@(([a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\d\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.)+([a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]|[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF][a-z\\d\\-._~\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[a-z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])\\.?$/i;\n\t\t\treturn pattern.test(emailAddress);\n\t\t}", "title": "" }, { "docid": "c2272a4012ee14358bc47cf3d5c5cb78", "score": "0.6712028", "text": "function validateEmail(email){\n var emailReg = new RegExp(/^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i);\n var valid = emailReg.test(email);\n\n if(!valid) {\n return false;\n } else {\n return true;\n }\n }", "title": "" }, { "docid": "e22813f541c66e94b65bd770c8a443ef", "score": "0.6702168", "text": "function validateEmailAddress() {\n var re = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n if(!re.test($(\"#email\").val())) {\n displayError($(\"#email\"), \"Invalid Email Address\");\n }\n}", "title": "" }, { "docid": "66d576741cbd9661e65bbd37f38f767a", "score": "0.6699937", "text": "function validateEmail(sEmail) {\r\nvar filter = /^[\\w\\-\\.\\+]+\\@[a-zA-Z0-9\\.\\-]+\\.[a-zA-z0-9]{2,4}$/;\r\n\t\r\nif (filter.test(sEmail)) {\r\n\treturn true;\r\n\t}\r\nelse {\r\n\treturn false;\r\n\t}\r\n}", "title": "" }, { "docid": "eaffdd1230a5f18d65859a959eabb485", "score": "0.6698519", "text": "function isValidEmail(emailAddress) {\r\n\t\treturn (/^\\w+([\\+\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,4})+$/.test(emailAddress));\r\n\t}", "title": "" }, { "docid": "07aec63f0e6769d72596216ce37ebb26", "score": "0.66976935", "text": "function isValidEmail(input) {\n\tregx = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;\n\treturn regx.test(input);\n}", "title": "" }, { "docid": "9226b2135e33d6241bb21b3f9b051a0f", "score": "0.66915065", "text": "function validateEmail(email) {\n var regex = /\\S+@\\S+\\.\\S+/;\n return regex.test(email);\n }", "title": "" }, { "docid": "bc6a3daea57d2d58142a715282490c66", "score": "0.6689522", "text": "function isThisAnEmail(str4){\n var mf= /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$/;\n if(str4.match(mf)){\n return true;\n\n } else{\n return false;\n }\n\n}", "title": "" }, { "docid": "a097c457a9bf597799e0c3cd41b462d4", "score": "0.6689056", "text": "function validateEmail(email){\r\n\tinvalidChars = \" /:,;\"\r\n\tif(email == \"\"){ //email cannot be empty\r\n\t\treturn false;\r\n\t}\r\n\r\n\tfor(i=0; i<invalidChars.length; i++){ //check for invalid characters\r\n\t\tbadChar = invalidChars.charAt(i);\r\n\t\tif(email.indexOf(badChar,0) != -1){\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tatPos = email.indexOf(\"@\",1); //there must be one \"@\" symbol\r\n\tif(atPos == -1){\r\n\t\treturn false;\r\n\t}\r\n\tif(email.indexOf(\"@\",atPos+1) != -1){ //check to make sure only one \"@\" symbol\r\n\t\treturn false;\r\n\t}\r\n\r\n\tperiodPos = email.indexOf(\".\",atPos);\r\n\tif (periodPos == -1){ // make sure there is one \".\" after the \"@\"\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif(periodPos+3 > email.length){ // must be at least 2 chars after the \".\"\r\n\t\treturn false;\r\n\t}\r\n\treturn true;\r\n}", "title": "" }, { "docid": "7439789fcd39b3c0cc89bf65f13a572b", "score": "0.66871107", "text": "function checkValidEmailAddress(container) {\r\n var target = $(\"#email, input.email\", container); // either with id of email, or with class email\r\n var emailAddress = target.val();\r\n if( emailAddress ) {\r\n var pattern = new RegExp(/^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i);\r\n if( !pattern.test(emailAddress) ) {\r\n showValidation(target, \"Please check the format of your email address, it should read like [email protected]\", container);\r\n return false;\r\n }\r\n }\r\n return true;\r\n}", "title": "" }, { "docid": "064f869f07b0f8f78209e18d4b875c4b", "score": "0.6685168", "text": "function isEmail(value) {\n\tinvalidChars = \" /:,;\";\n\tif (value==\"\") return false;\n\t\n\tfor (i=0; i<invalidChars.length;i++) {\n\t badChar = invalidChars.charAt(i);\n\t if (value.indexOf(badChar,0) != -1) return false;\n\t}\n\t\n\tatPos = value.indexOf(\"@\", 1);\n\tif (atPos == -1) return false;\n\tif (value.indexOf(\"@\", atPos + 1) != -1) return false;\n\t\n\tperiodPos = value.indexOf(\".\", atPos);\n\tif (periodPos == -1) return false;\n\t\n\tif (periodPos+3 > value.length) return false;\n\n\treturn true;\n}", "title": "" }, { "docid": "a3c274356860fbdead26d3d4d6f821b6", "score": "0.66841114", "text": "function ValidateEmail(mail) {\n var mailformat = /^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/;\n if(mail.value.match(mailformat)){\n return true;\n } else {\n alert(\"You have entered an invalid email address!\");\n return false;\n }\n}", "title": "" }, { "docid": "fe4b983a464563c292aef3066b6acf7b", "score": "0.6683008", "text": "function ValidateEmail(mail) \r\n{\r\n if (/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/.test(mail))\r\n {\r\n return (true)\r\n } \r\n return (false)\r\n}", "title": "" }, { "docid": "8222131372db4ebc80c659ccfeb78451", "score": "0.6682104", "text": "function emailValidator() {\n return function(x) {\n var validEmail = /^([A-Za-z0-9\\x27\\x2f!#$%&*+=?^_`{|}~-]+(\\.[A-Za-z0-9\\x27\\x2f!#$%&*+=?^_`{|}~-]+)*)@(([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]|[a-zA-Z0-9]{1,63})(\\.([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]|[a-zA-Z0-9]{1,63}))*\\.[a-zA-Z0-9]{2,63})$/\n var localPart = x.substring(0, x.indexOf('@'))\n return (localPart.length <= 64 && validEmail.test(x)).orFailure(\"invalid_email\")\n }\n}", "title": "" }, { "docid": "03699fbb87d13a3248805486a27742e0", "score": "0.6680779", "text": "function emailValidate(email) {\n //Surround the variable with a carrot and $ so that the email address can only follow the rules within. \n //First character must be a letter\n //After the first dot after the @ symbol, we want only letters and they can only be between 2 and 8 characters, e.g.(.com, .pizza, .io), etc.\n //The last argument is optional in case you have a .io.com since I added the ?\n var regExp = /^([a-z])([a-z\\d\\._]+)@([a-z\\d_]+)\\.([a-z]{2,8})(\\.[a-z]{2-8})?$/i;\n\n //The if/else statement will test whether this is valid or invalid wiht the built-in text method to search for a match between a regex and string\n if (regExp.test(email)) {\n return \"valid\";\n } else {\n return \"invalid\";\n }\n}", "title": "" }, { "docid": "1b9e835ba562001e4886265547ee2df6", "score": "0.66772133", "text": "function checkEmail(email){\n return /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/.test(email);\n}", "title": "" }, { "docid": "19edd159b152f1c81d5f577a00dcf529", "score": "0.66697764", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = new RegExp(/^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i);\n return pattern.test(emailAddress);\n}", "title": "" }, { "docid": "19edd159b152f1c81d5f577a00dcf529", "score": "0.66697764", "text": "function isValidEmailAddress(emailAddress) {\n var pattern = new RegExp(/^((\"[\\w-\\s]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w-\\s]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)/i);\n return pattern.test(emailAddress);\n}", "title": "" }, { "docid": "27f5a0fef256c4b3ea5f97187dcb2d23", "score": "0.66669726", "text": "function emailInputStringValidation (input) {\n var val = input.val();\n var afterAt = val.slice(val.indexOf(\"@\")+1);\n var test = val.indexOf(\"@\") <= 0 || val.lastIndexOf(\"@\") === (val.length - 1) || val.indexOf(\"@\") !== val.lastIndexOf(\"@\") || afterAt.length <= 6 || afterAt.indexOf(\".\") <= 0 || afterAt.lastindexOf(\".\") === (afterAt.length - 1);\n \n return test? false : true;\n }", "title": "" }, { "docid": "459fbb50e61c6dc1126b0587eb5c3cd9", "score": "0.6663844", "text": "function validateEmailAllowNull(email){\r\n\tinvalidChars = \" /:,;\";\r\n\tfor(i=0; i<invalidChars.length; i++){ //check for invalid characters\r\n\t\tbadChar = invalidChars.charAt(i);\r\n\t\tif(email.indexOf(badChar,0) != -1){\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tatPos = email.indexOf(\"@\",1); //there must be one \"@\" symbol\r\n\tif(atPos == -1){\r\n\t\treturn false;\r\n\t}\r\n\tif(email.indexOf(\"@\",atPos+1) != -1){ //check to make sure only one \"@\" symbol\r\n\t\treturn false;\r\n\t}\r\n\r\n\tperiodPos = email.indexOf(\".\",atPos);\r\n\tif (periodPos == -1){ // make sure there is one \".\" after the \"@\"\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif(periodPos+3 > email.length){ // must be at least 2 chars after the \".\"\r\n\t\treturn false;\r\n\t}\r\n\treturn true;\r\n}", "title": "" }, { "docid": "cbafc83bf4ee6e5ff35856dcd95c0408", "score": "0.66634244", "text": "function validateEmail(email){\n var pattern = /^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/;\n return pattern.test(email);\n}", "title": "" }, { "docid": "c94d66956eb6eb64acc488b7faec95c4", "score": "0.66631407", "text": "function validateEmail(email) {\n var re = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return email.match(re);\n}", "title": "" }, { "docid": "a0cd3a459bceefccddc10c3ed0a07d3b", "score": "0.66512644", "text": "function validateEmail(email){\n var pattern = /\\S+@\\S+\\.com|net|edu|org$/;\n return pattern.test(email);\n}", "title": "" }, { "docid": "04d3d4285fc4ddd38959ab4ccc9d3bb1", "score": "0.66473025", "text": "function isRFC822ValidEmail(sEmail) {\n console.log(sEmail);\n \n var sQtext = '[^\\\\x0d\\\\x22\\\\x5c\\\\x80-\\\\xff]';\n var sDtext = '[^\\\\x0d\\\\x5b-\\\\x5d\\\\x80-\\\\xff]';\n var sAtom = '[^\\\\x00-\\\\x20\\\\x22\\\\x28\\\\x29\\\\x2c\\\\x2e\\\\x3a-\\\\x3c\\\\x3e\\\\x40\\\\x5b-\\\\x5d\\\\x7f-\\\\xff]+';\n var sQuotedPair = '\\\\x5c[\\\\x00-\\\\x7f]';\n var sDomainLiteral = '\\\\x5b(' + sDtext + '|' + sQuotedPair + ')*\\\\x5d';\n var sQuotedString = '\\\\x22(' + sQtext + '|' + sQuotedPair + ')*\\\\x22';\n var sDomain_ref = sAtom;\n var sSubDomain = '(' + sDomain_ref + '|' + sDomainLiteral + ')';\n var sWord = '(' + sAtom + '|' + sQuotedString + ')';\n var sDomain = sSubDomain + '(\\\\x2e' + sSubDomain + ')*';\n var sLocalPart = sWord + '(\\\\x2e' + sWord + ')*';\n var sAddrSpec = sLocalPart + '\\\\x40' + sDomain; // complete RFC822 email address spec\n var sValidEmail = '^' + sAddrSpec + '$'; // as whole string\n\n var reValidEmail = new RegExp(sValidEmail);\n \n if(reValidEmail.test( $.trim(sEmail) )) {\n return true;\n }\n \n return false;\n}", "title": "" }, { "docid": "fecd665125fa1e2b511ba4aaa57cc979", "score": "0.66452223", "text": "function echeck(email) { \r\n var re = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\r\n return re.test(email);\r\n}", "title": "" } ]
fea2ddb88e48c015485880fad315b8b1
'Back to Products' and 'Continue Shopping' button selectors
[ { "docid": "661946e0735b29303e8c44e1ca85b142", "score": "0.7734348", "text": "get backToProductsBtn() { return $('#back-to-products') }", "title": "" } ]
[ { "docid": "ef25b74748742e8555524f1c24772f4f", "score": "0.66455835", "text": "function changeProductsByKey(e) {\n if ($('.quickview').is(':visible')) {\n if (e.which == '37') {\n navContainer.find(\".product-previous a\").trigger('click');\n } else if (e.which == '39') {\n navContainer.find(\".product-next a\").trigger('click');\n }\n }\n }", "title": "" }, { "docid": "bffb7a69238d051ffe3b97ef6213de45", "score": "0.66051626", "text": "function gotoProducts()\n {\n $state.go('app.e-commerce.products');\n }", "title": "" }, { "docid": "fdb1e641694278eb612a3ef2ec1c6336", "score": "0.62591434", "text": "function previousProduct(e) {\n e.preventDefault();\n\n app.progress.show();\n\n var params = app.util.getQueryStringParams(navContainer.find(\".product-previous a\").attr(\"href\").replace(\"#\", \"&\"));\n params.pid = navContainer.find(\".product-previous\").data(\"pid\");\n options.url = buildProductNavUrl(app.util.getPipeUrl('Product-Show'), params);\n app.product.get(options);\n }", "title": "" }, { "docid": "1594e531ecb021620e21ee3eb93e7c6c", "score": "0.6003298", "text": "goToShoppingCart(){\n genericActions.click(headerPage.shoppingCart.container);\n }", "title": "" }, { "docid": "8b689ce74b03625ce122cdf5b6b70b8b", "score": "0.59847856", "text": "clickCheckoutButton(){\n genericActions.click(shoppingCartPage.checkoutButton);\n }", "title": "" }, { "docid": "1c58f056458c2539d1ec90facea840e5", "score": "0.59708446", "text": "function goBackToCart() {\n router.backTo('cart', {mode: 'default'});\n }", "title": "" }, { "docid": "26ce57392f8ccb955ab9650a5e998983", "score": "0.592116", "text": "function onProductListBack(){\n firstPage = 1;\n flagSearch = false;\n HomeScreen.show();\n if(count === -1) {\n \thomeInit();\n }\n}", "title": "" }, { "docid": "9ec8324fa84b3867e36bbe9b9e265b47", "score": "0.58562195", "text": "function click_menuButton_shop(){\n menuButton_shop.click();\n }", "title": "" }, { "docid": "9005cc25fe64f96948a7b0a10094fad6", "score": "0.57883567", "text": "getProduct(e) {\n\n if ($(e.target).parents().eq(4).hasClass('latest')) {\n \n if (e.target.classList.contains(\"addToCartBtn\")) {\n e.preventDefault()\n local.productInfo(e.target.parentElement);\n }\n }\n if ($(e.target).parents().eq(6).hasClass('tabcontain')) {\n \n\n if (e.target.classList.contains(\"stretched-link\")) {\n e.preventDefault()\n \n local.productInfo(e.target.parentElement.parentElement.parentElement);\n }\n }\n\n\n\n\n }", "title": "" }, { "docid": "04a7eef47f98b5df496e113024f9aea0", "score": "0.57760257", "text": "function goToPreviousPage() {\n if (firstPage > 1) {\n firstPage--;\n if (flagSearch === true) {\n CustomSearchService();\n } else {\n getProductListData();\n }\n } else if (firstPage === 1) {\n ProductListScreen.prev.setVisibility(false);\n }\n}", "title": "" }, { "docid": "d95eb6ee505e8b062f242708370548e2", "score": "0.57652014", "text": "function backBtn() {\n sel('.show').style.display = 'block';\n sel('.operate').style.display = 'flex';\n sel('.edit').style.display = 'block';\n sel('.add').style.display = 'none';\n}", "title": "" }, { "docid": "a8bef42218293f354c75090624ff890b", "score": "0.5740039", "text": "function goToProducts() {\n return element(by.cssContainingText('.access_controlled', 'Products')).click();\n}", "title": "" }, { "docid": "885db129455e22100ca5e190962e2d16", "score": "0.5712791", "text": "function backToServicePurchase() {\n $('.back-to-purchase').click(function () {\n var userServiceId = $(this).data('user-service-id');\n reloadContainerId(this);\n renderBackToServicePurchase(userServiceId);\n });\n}", "title": "" }, { "docid": "60eead8f4259835a576fe935a1e95aae", "score": "0.57012624", "text": "function goToSelectProductToRevise(){\n\t\t\tnewRequestFactory.selectedRequestQuote = $scope.quoteDetail;\n\n\t\t\tif(newRequestFactory.selectedRequestQuote.products.length > 1){\n\t\t\t\t$state.go('selectProductToRevise',{'RequestRevisionSK':$stateParams.RequestRevisionSK});\t\n\t\t\t} else {\n\t\t\t\t// if there is only one product then just skip the select products screen\n\t\t\t\tnewRequestFactory.selectedReviseProduct = newRequestFactory.selectedRequestQuote.products[0];\n\t\t\t\t$state.go('selectItemtoRevise',{'RequestRevisionSK':$stateParams.RequestRevisionSK});\n\t\t\t}\t\t\t\n\t\t}", "title": "" }, { "docid": "7b69c555e3158a16a16434725b0ee95d", "score": "0.5696795", "text": "ReturnToShopping() {\n $(\".added-to-shopping-cart-full-popup\").css(\"display\", \"none\");\n }", "title": "" }, { "docid": "ad1f1d4bdcf837ec1679d61e7e69a73f", "score": "0.5680942", "text": "function btnBackClick() {\r\n $(\"#pokemonDetail\").hide();\r\n $(\"#btnBack\").hide();\r\n $(\"#singleHeading\").hide();\r\n $(\"#listHeading\").show();\r\n $(\"#pokemons\").show();\r\n $(\"#btnPrev\").show();\r\n $(\"#btnNext\").show();\r\n}", "title": "" }, { "docid": "e2977fbe788cf23cefa600b6965d5088", "score": "0.5667805", "text": "function pageone() {\n\n\t\tpage1button.className = \"pressed\";\n\t\tpage2button.className = \"normal\";\n\t\tfor (var i = 0; i < products.length; ++i) {\n\t\tproducts[i].style.display = 'none';\n\t}\n\t\tfor (var i = 0, limit=8; i < limit; ++i) {\n\t\tproducts[i].style.display = 'block';\n\t}\n\t}", "title": "" }, { "docid": "16d66e33098508b56a899dd84e7c1443", "score": "0.5667211", "text": "function selectProductEvent(event,productType,product){\n let productButton = event.currentTarget;\n let productButtonsContainer = productButton.parentElement;\n productButtonsContainer.querySelectorAll('button').forEach(button=>button.classList.remove('product-selected'));\n productButton.classList.add('product-selected');\n itemActual[productType] = product;\n // activate or disactivate the add-to-cart-button\n let disableAddToCartButton = !currentProductTypes.every(element => element in itemActual);\n document.querySelector('#add-to-cart-button').disabled = disableAddToCartButton;\n}", "title": "" }, { "docid": "030a36782e3b007a2289878086b0d1b9", "score": "0.5649948", "text": "function goBack() {\n\tshowElements('main-card-group');\n\tshowElements('imageB');\n\tshowElements('attending');\n}", "title": "" }, { "docid": "82606af219f1c3f9abe71a7646662280", "score": "0.564107", "text": "previous() {\n helpers.locateElementAndClickOnIt(this.selectors.buttons.previous);\n this._prices = null;\n }", "title": "" }, { "docid": "fa37df7de7b9fcf7f290adba7b47291c", "score": "0.5631655", "text": "function ProductOverview({\r\n productList,\r\n productCategory,\r\n setCategoryAsShirts,\r\n setCategoryAsMugs,\r\n updateCart,\r\n}) {\r\n return (\r\n <div>\r\n <ProductsTitle>Products</ProductsTitle>\r\n <Tab>\r\n <button\r\n className={\r\n productCategory === PRODUCT_CATEGORIES.MUG ? \"active\" : null\r\n }\r\n onClick={setCategoryAsMugs}\r\n >\r\n mug\r\n </button>\r\n <button\r\n className={\r\n productCategory === PRODUCT_CATEGORIES.SHIRT ? \"active\" : null\r\n }\r\n onClick={setCategoryAsShirts}\r\n >\r\n shirt\r\n </button>\r\n </Tab>\r\n <Card>\r\n <ProductList itemList={productList} updateCart={updateCart} />\r\n </Card>\r\n </div>\r\n );\r\n}", "title": "" }, { "docid": "513a0b67d11189cb260b28de79729718", "score": "0.5621693", "text": "clickBackButton() {\n if (this.backButton.isExisting()) {\n this.backButton.click();\n }\n\n }", "title": "" }, { "docid": "7efab0b53799d956773c488ea7dd41c3", "score": "0.55990076", "text": "function backToHome(){\n let allProducts = [];\n for(let i=0;i<products.length;i++){\n allProducts.push(products[i]._id)\n }\n document.getElementById('titleHolder').innerHTML = ''\n displayProducts.beginDisplay(allProducts);\n}", "title": "" }, { "docid": "2b2c07d95b4f1983039ee800843f1eb1", "score": "0.5583479", "text": "function orderList_switchOrderList() {\n\n var productButton = document.getElementById('more-orderList-selectView-buttonProduct');\n var couponButton = document.getElementById('more-orderList-selectView-buttonCoupon')\n var productList = document.getElementById('more-productList');\n var couponList = document.getElementById('more-couponList');\n\n // default settings to set productButton is clicked\n productButton.style.backgroundColor = '#4DC03D';\n productButton.style.color = 'white';\n // show productList already done in its css property\n\n // when productList button is clicked\n productButton.addEventListener('click', function() {\n // restore the unselected button's properties\n couponButton.style.backgroundColor = 'white';\n couponButton.style.color = 'black';\n // change button's background-color and text color\n this.style.backgroundColor = '#4DC03D';\n this.style.color = 'white';\n // hide couponList\n couponList.style.display = 'none';\n // show productList\n productList.style.display = 'block';\n });\n\n // when couponList button is clicked\n couponButton.addEventListener('click', function() {\n // restore the unselected button's properties\n productButton.style.backgroundColor = 'white';\n productButton.style.color = 'black';\n // change button's background-color and text color\n this.style.backgroundColor = '#4DC03D';\n this.style.color = 'white';\n // show couponList\n productList.style.display = 'none';\n // hide productList\n couponList.style.display = 'block';\n });\n}", "title": "" }, { "docid": "084d1b6ab972dc4885eea58164d92cb8", "score": "0.55800754", "text": "function onClickPrevious() {\n if (currentPage >= 0) {\n currentPage--\n }\n document.getElementById('current-page').value = currentPage + 1\n document.getElementById('current-page').innerText = currentPage + 1\n if (currentPage === 0) {\n document.getElementById('previous-page').classList.add('uk-invisible')\n }\n document.getElementById('next-page').classList.remove('uk-invisible')\n fetchTMEventList(keywords)\n}", "title": "" }, { "docid": "cd30927ec0c9e57d3ac6604c803c9cf6", "score": "0.5561199", "text": "function buyBtnClicked() {\n $('html').addClass('disabled')\n dispatch(editGoToBasket(true))\n }", "title": "" }, { "docid": "f1efd75912acb6888f3a5de7679e99f6", "score": "0.5558067", "text": "function initBuyButtons() {\r\n var buyBtns = document.querySelectorAll(\"div.buy\");\r\n for (var i = 0; i < buyBtns.length; i++) {\r\n var currBtn = buyBtns[i];\r\n currBtn.onclick = buyProduct;\r\n }\r\n}", "title": "" }, { "docid": "23f721bc3db44813bf159fe4d97d5659", "score": "0.5556", "text": "function topButtons(dispatch, model) {\n if (model.show_form) {\n return '';\n }\n return [ button({ \n className: 'pa2 br1 mv2 mh2 bg-green bn white pointer',\n onclick: () => dispatch(newItemMsg)\n }, \n [\n i({className: 'fa fa-plus ph1'}),\n 'Add Product'\n ]),\n button({ \n className: 'pa2 br1 mv2 mh2 bg-green bn white pointer',\n onclick: () => dispatch(newOtherCostMsg)\n }, \n [\n i({className: 'fa fa-plus ph1'}),\n 'Add Other Costs'\n ])\n ,div({className: 'fr'}, [\n button({ \n className: 'pa2 br1 mv2 mh2 bg-green bn white pointer',\n onclick: () => dispatch(savePurchaseOrderMsg())\n }, \n [\n i({className: 'fa fa-save ph1'}),\n ''\n ]),\n button({ \n className: 'pa2 br1 mv2 mh2 bg-green bn white pointer',\n onclick: () => dispatch(closePurchaseOrderMsg())\n }, \n [\n i({className: 'fa fa-close ph1'}),\n ''\n ]),\n button({ \n className: 'pa2 br1 mv2 mh2 bg-green bn white pointer',\n onclick: () => dispatch(printPreviewMsg)\n }, \n [\n i({className: 'fa fa-print ph1'}),\n ''\n ]),\n ])\n ];\n\n}", "title": "" }, { "docid": "d8fbfbde1be3497172a87acf202afd68", "score": "0.55334705", "text": "function modifyBackButtons() {\n\t\t// Back buttons jQuery object\n\t\tvar $backBtns = $('a[data-rel=back]');\n\n\t\t// Add HTML\n\t\t$backBtns.append('<span class=\"ui-icon ui-icon-arrow-l ui-icon-shadow\"></span>');\n\t}", "title": "" }, { "docid": "6beea11cc082cac5670c01544596f635", "score": "0.55140036", "text": "navigatetoViewPage(e, item_id ) {\n window.location = \"/viewProducts\";\n }", "title": "" }, { "docid": "556352ac7ce8f3cfaf4e557375f09245", "score": "0.55030614", "text": "function gotoOrders() {\n ShoppingCart.clearAll();\n updateShoppingCart();\n $state.go('myOrders', null, {reload: true});\n }", "title": "" }, { "docid": "5f19f3b83122fdf8c7a3bb885f94bb5f", "score": "0.54988754", "text": "function goToProductPage(){\n\n\n product_clicked = this.parentElement.nextElementSibling.textContent;\n console.log(product_clicked)\n\n localStorage.setItem(\"product_clicked\",product_clicked.toLowerCase());\n\n location.assign(\"./product.html\")\n \n }", "title": "" }, { "docid": "54b53402e0a8cc4038295addb2c067b4", "score": "0.5496251", "text": "function toControlProductsState(btn, state) {\n var products = document.querySelectorAll('.js-product-item');\n Array.prototype.forEach.call(products, function (item) {\n var btnDeleteItem = item.querySelector('.js-remove-item');\n var productQuantity = item.querySelector('.js-value');\n\n productQuantity.readOnly = state;\n item.classList.toggle(IS_DELETED, state);\n btnDeleteItem.classList.toggle(IS_ACTIVE, state);\n btnDeleteItem.textContent = state ? 'Вернуть' : 'Удалить';\n });\n btn.textContent = state ? 'Вернуть все' : 'Удалить все';\n btn.classList.toggle(IS_ACTIVE, state);\n }", "title": "" }, { "docid": "54b53402e0a8cc4038295addb2c067b4", "score": "0.5496251", "text": "function toControlProductsState(btn, state) {\n var products = document.querySelectorAll('.js-product-item');\n Array.prototype.forEach.call(products, function (item) {\n var btnDeleteItem = item.querySelector('.js-remove-item');\n var productQuantity = item.querySelector('.js-value');\n\n productQuantity.readOnly = state;\n item.classList.toggle(IS_DELETED, state);\n btnDeleteItem.classList.toggle(IS_ACTIVE, state);\n btnDeleteItem.textContent = state ? 'Вернуть' : 'Удалить';\n });\n btn.textContent = state ? 'Вернуть все' : 'Удалить все';\n btn.classList.toggle(IS_ACTIVE, state);\n }", "title": "" }, { "docid": "3c06be979c566315d950918ed258175b", "score": "0.5461076", "text": "function loadEvents() {\n\n likeItem();\n moveToBasket();\n updatefavouriteCounter();\n updateDesiredCounter();\n updateDesiredProd();\n desableToLike();\n\n let productImages = Array.from(document.getElementsByClassName(\"product-img\"));\n productImages.forEach(img => changeImgOnHover(img));\n\n let buttons = Array.from(document.getElementsByClassName(\"product-img\"));\n buttons.forEach(function (currentBtn) {\n currentBtn.addEventListener('click', function (ev) {\n localStorage.setItem('productId', JSON.stringify(ev.target.previousElementSibling.value));\n location.hash = '#overview';\n })\n });\n }", "title": "" }, { "docid": "a08a5963bd3813c7e98320cf94c98093", "score": "0.54602194", "text": "function View() {\n\n\t/**\n\t * Returns the button for all products\n\t * \n\t * @returns {HTMLElement} the button element\n\t * \n\t * @public\n\t */\n\tthis.getHeaderStatusAll = function () {\n\t\tconst $headerText = document.querySelector(\".header-text\");\n\t\treturn $headerText\n\n\t};\n\n\t/**\n\t * Returns the button for products with OK status\n\t * \n\t * @returns {HTMLElement} the button element\n\t * \n\t * @public\n\t */\n\tthis.getHeaderOk = function () {\n\t\tconst $headerOk = document.querySelector(\".header-ok\");\n\t\treturn $headerOk\n\t};\n\n\t/**\n\t * Returns the button for products with STORAGE status\n\t * \n\t * @returns {HTMLElement} the button element\n\t * \n\t * @public\n\t */\n\tthis.getHeaderStorage = function () {\n\t\tconst $headerStorage = document.querySelector(\".header-storage\");\n\t\treturn $headerStorage\n\t};\n\n\t/**\n\t * Returns the button for products with OUT_of_STOCK status.\n\t * \n\t * @returns {HTMLElement} the button element.\n\t * \n\t * @public\n\t */\n\tthis.getHeaderOut = function () {\n\t\tconst $headerOut = document.querySelector(\".header-out\");\n\t\treturn $headerOut\n\t};\n\n /**\n\t * Returns the button for search stores.\n\t * \n\t * @returns {HTMLElement} the button element.\n\t * \n\t * @public\n\t */\n this.getBtnSearchStores = function () {\n const $btnSearchStores = document.querySelector(\".icon-search-stores\");\t\n return $btnSearchStores\n };\n\n /**\n\t * Returns the button for search products.\n\t * \n\t * @returns {HTMLElement} the button element.\n\t * \n\t * @public\n\t */\n this.getBtnSearchProducts = function () {\n const $btnSearchProducts = document.querySelector(\".icon-search-products\");\n return $btnSearchProducts\n };\n\n /**\n\t * Returns the button for refresh products.\n\t * \n\t * @returns {HTMLElement} the button element\n\t * \n\t * @public\n\t */\n this.getBtnRefreshProducts = function () {\n const $btnRefreshProducts = document.querySelector(\".icon-refresh-products\");\n return $btnRefreshProducts\n };\n\n /**\n\t * Returns the button for delete input value (stores).\n\t * \n\t * @returns {HTMLElement} the button element\n\t * \n\t * @public\n\t */\n this.getBtnCrossStores = function () {\n const $btnCrossStores = document.querySelector(\".icon-cross-stores\");\n return $btnCrossStores\n };\n\n /**\n\t * Returns the button for refresh products.\n\t * \n\t * @returns {HTMLElement} the button element\n\t * \n\t * @public\n\t */\n this.getBtnRefreshStores = function () {\n const $btnRefreshStores = document.querySelector(\".icon-refresh-stores\");\n return $btnRefreshStores\n };\n\n /**\n\t * Returns the button for delete input value (products).\n\t * \n\t * @returns {HTMLElement} the button element\n\t * \n\t * @public\n\t */\n this.getBtnCrossProducts = function () {\n const $btnCrossProducts = document.querySelector(\".icon-cross-products\");\n return $btnCrossProducts\n };\n\n\t/**\n\t * The first section header with info about active store.\n\t * \n\t * @constant\n\t */\n\tconst $firstSectionHeader = document.querySelector(\".first-header-section\");\n\n\t/**\n\t * The second section header with filter of products buttons by status.\n\t * \n\t * @constant\n\t */\n\tconst $secondSectionHeader = document.querySelector(\".second-header-section\");\n\n\t/**\n\t * Title of table with search panel.\n\t * \n\t * @constant\n\t */\n\tconst $tableTitle = document.querySelector(\".table-title\");\n\n\t/**\n\t * Method to get wrapper for for table body.\n\t * \n\t * @returns {HTMLDivElement} wrapper for table body.\n\t * \n\t * @public\n\t */\n this.getTableWrap = function () {\n\t const $tableWrap = document.querySelector(\".table-wrapper\");\n return $tableWrap\n }\n\n\t/**\n\t * Title of section.\n\t * \n\t * @constant\n\t */\n\tconst $sectionTitle = document.querySelector(\".js-header-title\");\n\n\t\n /**\n\t * Div with amount products\n\t * \n\t * @constant\n\t */\n const $storeAmount = document.querySelector(\".store-amount\");\n\n /**\n * Div with amount products with OK status\n * \n * @constant\n */\n const $statusOk = document.querySelector(\".status-ok\");\n\n /**\n * Div with amount products with STORAGE status\n * \n * @constant\n */\n const $statusStorage = document.querySelector(\".status-storage\");\n\n /**\n * Div with amount products with OUT_OF_STOCK status\n * \n * @constant\n */\n const $statusOut = document.querySelector(\".status-out\");\n\t\n\n\t/**\n\t * Method to get wrapper for all store-items\n\t * \n\t * @returns {HTMLDivElement} wrapper for all store-items\n\t * \n\t * @public\n\t */\n\tthis.getAllArticles = function () {\n\t\tconst $articles = document.querySelector(\".js-articles\");\n\t\treturn $articles\n\t};\n\n\t/**\n\t * Method to get input for search stores.\n\t * \n\t * @returns {HTMLInputElement} with input for search stores.\n\t */\n\t this.getSearchInputStore = function () {\n\t\tconst $storesSearchInput = document.querySelector(\".stores-search-input\");\n\t\treturn $storesSearchInput\n\t};\n\n\t/**\n\t * Method to get input for search products.\n\t * \n\t * @returns {HTMLInputElement} with input for search products.\n\t */\n\t this.getProductSearchInput = function () {\n\t\tconst $productsSearchInput = document.querySelector(\".products-search-input\");\n\t\treturn $productsSearchInput\n\t}\n\n\t/**\n\t * Returns modal window for creating a store.\n\t * \n\t * @returns {HTMLDivElement} the modal window with form.\n\t */\n\tthis.getModalCreateStore = function () {\n\t\tconst $modalCreateStore = document.querySelector(\".modal-wrapper-create-store\");\n\t\treturn $modalCreateStore\n\t}\n\n\t/**\n\t * Returns modal window for creating a product.\n\t * \n\t * @returns {HTMLDivElement} the modal window with form.\n\t */\n\tthis.getModalCreateProduct = function () {\n\t\tconst $modalCreateProduct = document.querySelector(\".modal-wrapper-create-product\");\n\t\treturn $modalCreateProduct\n\t}\n\n\t /**\n\t * Returns modal window to confirm product removal.\n\t * \n\t * @returns {HTMLDivElement} the modal window to confirm product removal with two buttons: ok and cancel.\n\t */\n\tthis.getConfirmDeleteProduct = function () {\n\t\tconst $confirmDeleteProduct = document.querySelector(\".modal-wrapper-confirm-delete-product\");\n\t\treturn $confirmDeleteProduct\n\t};\n \n\t /**\n\t * Returns modal window to confirm store removal.\n\t * \n\t * @returns {HTMLDivElement} the modal window to confirm store removal with two buttons: ok and cancel.\n\t */\n\tthis.getConfirmDeleteStore = function () {\n\t \tconst $confirmDeleteStore = document.querySelector(\".modal-wrapper-confirm-delete-store\");\n\t\t return $confirmDeleteStore\n\t};\n \n\t /**\n\t * Returns notification with message.\n\t * \n\t * @returns {HTMLDivElement} with notification about creating or removing product.\n\t */\n\tthis.getPopup = function () {\n\t \tconst $popup = document.querySelector(\".popup\");\n\t\treturn $popup\n\t};\n\n\t/**\n\t * Common method for adding a class \"active\"\n\t * \n\t * @param {HTMLElement} elem \n\t */\n\tthis.addActiveClass = function (elem) {\n\t\telem.classList.add(\"active\")\n\t};\n\n\t/**\n\t * Common method for removing a class \"active\"\n\t * \n\t * @param {HTMLElement} elem \n\t */\n\tthis.removeActiveClass = function (elem) {\n\t\telem.classList.remove(\"active\")\n\t};\n\n\t/**\n\t * Fill the data into aside with all stores.\n\t *\n\t * @param {Object[]} dataOfStores the stores data array.\n\t *\n\t */\n\tthis.renderStores = function (dataOfStores) {\n\n \tthis.getAllArticles().innerHTML = \"\";\n\n\t\tfor (let el of dataOfStores) {\n\t\t\tthis.getAllArticles().innerHTML += `<article class=\"article store-item\" id=${el.id} about=${el.id}>\n\t\t\t\t<div class=\"article-wrap\">\n\t\t\t\t\t<div class=\"article-content-main\">\n\t\t\t\t\t<p class=\"shop-name long-text\">${el.Name}</p>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<p>${el.FloorArea}</p>\n\t\t\t\t\t\t<p class=\"sq-m\">sq.m</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<p class=\"shop-address\">${el.Address}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</article>`\n\t\t}\n\t};\n\n\t/**\n\t * Show section, when no active store.\n\t *\n\t */\n\tthis.showSectionWithoutProducts = function () {\n\n\t\t$sectionTitle.innerHTML = \"Store is not selected\";\n \tthis.getTableWrap().innerHTML = `<div class=\"table-without-products\">\n\t\t\t<i class=\"fas fa-store-alt\"></i>\n\t\t\t<p class=\"title\">The store is not selected</p>\n\t\t\t<p class=\"text-grey\">Please select the store to proceed</p>\n \t</div>`;\n\t\t$firstSectionHeader.classList.remove(\"active\");\n $secondSectionHeader.classList.remove(\"active\");\n $tableTitle.classList.remove(\"active\")\n\t};\n\n\t/**\n\t * Fill the data into table of products.\n\t *\n\t * @param {Object[]} dataOfProducts the products data array.\n\t *\n\t * @public\n\t */\n\tthis.renderProductTable = function (dataOfProducts) {\n\n\t\t$sectionTitle.classList.remove(\"center\");\n\t\t$tableTitle.classList.add(\"active\");\n\t\t$sectionTitle.innerHTML = \"Stores Details\"\n\t\tthis.getTableWrap().innerHTML = `<table class=\"table\">\n\t\t\t<thead class=\"thead\">\n\t\t\t\t<tr>\n\t\t\t\t\t<th class=\"th table-nav-name\"><i class=\"fas fa-sort\"></i>Name</th>\n\t\t\t\t\t<th class=\"th table-nav-price table-product-price\"><i class=\"fas fa-sort\"></i>Price</th>\n\t\t\t\t\t<th class=\"th table-nav-specs\"><i class=\"fas fa-sort\"></i>Specs</th>\n\t\t\t\t\t<th class=\"th table-nav-supplierinfo\"><i class=\"fas fa-sort\"></i>SupplierInfo</th>\n\t\t\t\t\t<th class=\"th table-nav-country country-none\"><i class=\"fas fa-sort\"></i>Country of origin</th>\n\t\t\t\t\t<th class=\"th table-nav-company company-none\"><i class=\"fas fa-sort\"></i>Prod. company</th>\n\t\t\t\t\t<th class=\"th table-nav-rating rating-none\"><i class=\"fas fa-sort\"></i>Rating</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody class=\"tbody\"></tbody>\n\t\t</table>`\n\n\t\tconst rating1 = `\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>`\n\n\t\tconst rating2 = `\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>`\n\n\t\tconst rating3 = `\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>`\n\n\t\tconst rating4 = `\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"far fa-star\"></i>`\n\n\t\tconst rating5 = `\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>\n\t\t<i class=\"fas fa-star\"></i>`\n\n\t\tconst $tbody = document.querySelector(\".tbody\")\n\n\t\tfor (let el of dataOfProducts) {\n\t\t\t$tbody.innerHTML += `<tr id=${el.id}>\n\t\t\t\t<td>\n\t\t\t\t\t<p class=\"table-produsct-name long-text\">${el.Name}</p>\n\t\t\t\t\t<p>${el.id}</p>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"table-product-price\" nowrap>\n\t\t\t\t\t<p><span>${el.Price}</span> USD</p>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"long-text\">\n\t\t\t\t\t<p title=\"${el.Specs}\">${el.Specs}</p>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"long-text\">\n\t\t\t\t\t<p title=\"${el.SupplierInfo}\">${el.SupplierInfo}</p>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"long-text contry-none\">\n\t\t\t\t\t<p>${el.MadeIn}</p>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"long-text company-none\">\n\t\t\t\t\t<p>${el.ProductionCompanyName}</p>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"rating-none\" nowrap>\n\t\t\t\t\t<div class=\"rating\">\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t${el.Rating === 1 ? rating1 :\n\t\t\t\t\t\t\t\tel.Rating === 2 ? rating2 :\n\t\t\t\t\t\t\t\tel.Rating === 3 ? rating3 :\n\t\t\t\t\t\t\t\tel.Rating === 4 ? rating4 :\n\t\t\t\t\t\t\t\tel.Rating === 5 ? rating5 : null}\n\t\t\t\t\t\t\t</div>\n <div class=\"for-id-product\" about=${el.id} nowrap>\n\t\t\t\t\t\t\t\t<i class=\"far fa-times-circle delete-product\"></i>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t</tr>`\n\t\t}\n\t};\n\n\t/**\n\t * Show section with data about store.\n\t *\n\t * @param {Object} activeStore active store.\n\t *\n\t * @public\n\t */\n\tthis.renderHeaderWithInfoAboutStore = function (activeStore) {\n\n\t\t$firstSectionHeader.classList.add(\"active\")\n\t\t$firstSectionHeader.innerHTML = `<div class=\"header-content\">\n\t\t<div class=\"header-content-col\">\n\t\t\t<div class=\"header-cont-string\">\n\t\t\t\t<p class=\"header-cont-col-bold\">Email: </p>\n\t\t\t\t<p>${activeStore.Email}</p>\n\t\t\t</div>\n\t\t\t<div class=\"header-cont-string\">\n\t\t\t\t<p class=\"header-cont-col-bold\">Phone Number: </p>\n\t\t\t\t<p>${activeStore.PhoneNumber}</p>\n\t\t\t</div>\n\t\t\t<div class=\"header-cont-string\">\n\t\t\t\t<p class=\"header-cont-col-bold\">Address: </p>\n\t\t\t\t<p>${activeStore.Address}</p>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"header-content-col\">\n\t\t\t<div class=\"header-cont-string\">\n\t\t\t\t<p class=\"header-cont-col-bold\">Established Date:</p>\n\t\t\t\t<p>${activeStore.Established.slice(5, 7) === '01' ? 'Jan' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '02' ? 'Feb' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '03' ? 'Mar' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '04' ? 'Apr' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '05' ? 'Mai' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '06' ? 'Jnn' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '07' ? 'Jnl' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '08' ? 'Aug' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '09' ? 'Sep' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '10' ? 'Oct' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '11' ? 'Nov' :\n\t\t\t\tactiveStore.Established.slice(5, 7) === '12' ? 'Dec' : null}\n\t\t\t\t${activeStore.Established.slice(8, 10)}, ${activeStore.Established.slice(0, 4)} </p>\n\t\t\t</div>\n\t\t\t<div class=\"header-cont-string\">\n\t\t\t\t<p class=\"header-cont-col-bold\">Floor Area:</p>\n\t\t\t\t<p>${activeStore.FloorArea}</p>\n\t\t\t</div>\n\t\t</div>\n\t</div>`\n\t};\n\n\t/**\n\t * Show section with filter of products by status.\n\t *\n\t * @param {Object[]} dataOfProducts data of products for active store.\n\t *\n\t * @public\n\t */\n\tthis.renderHeaderWithStatusOfProducts = function (dataOfProducts) {\n\n\t\tlet statusOk = 0;\n\t\tlet statusStorage = 0;\n\t\tlet statusOut = 0;\n\n\t\tfor (let el of dataOfProducts) {\n\t\t\tif (el.Status === \"OUT_OF_STOCK\") {\n\t\t\t\tstatusOut += 1\n\t\t\t} else if (el.Status === \"OK\") {\n\t\t\t\tstatusOk += 1\n\t\t\t} else if (el.Status === \"STORAGE\") {\n\t\t\t\tstatusStorage += 1\n\t\t\t} else {\n\t\t\t\treturn null\n\t\t\t}\n\t\t}\n\t\t$secondSectionHeader.classList.add(\"active\");\n\t\t$storeAmount.innerHTML = `${dataOfProducts.length}`;\n\t\t$statusOk.innerHTML = `${statusOk}`;\n\t\t$statusStorage.innerHTML = `${statusStorage}`;\n\t\t$statusOut.innerHTML = `${statusOut}`;\n\t\tthis.clearClassBtnByStatus();\n\t\tthis.getHeaderStatusAll().classList.add(\"active\");\n\t};\n\n\t/**\n\t * Remove active filter buttons by status .\n\t *\n\t * @public\n\t */\n\tthis.clearClassBtnByStatus = function () {\n\n\t\tthis.getHeaderStatusAll().classList.remove(\"active\");\n\t\tthis.getHeaderOk().classList.remove(\"active\");\n\t\tthis.getHeaderStorage().classList.remove(\"active\");\n\t\tthis.getHeaderOut().classList.remove(\"active\");\n\t\tthis.getProductSearchInput().value = \"\";\n\t};\n\n\t/**\n\t * Remove input.value in forms, error classes, hide modal window.\n\t *\n\t * @param {HTMLFormElement} form with create store or product.\n\t *\n\t * @public\n\t */\n\tthis.clearForm = function (form) {\n\n\t\tconst $inputs = form.getElementsByTagName(\"input\");\n\t\tfor (let $input of $inputs) {\n\t\t\t$input.classList.remove(\"error\");\n\t\t\t$input.value = '';\n\t\t}\n\t\tdocument.getElementById(\"phone-message\").innerHTML = \"\";\n\t\tdocument.getElementById(\"email-message\").innerHTML = \"\";\n\t};\n\n\t/**\n\t * Clear search form after click \"cross\"\n\t * \n\t * @param {HTMLInputElement} input of search form (Stores or Products).\n\t * @param {HTMLElement} btnCross of search form (Stores or Products).\n\t * @param {HTMLElement} btnRefresh of search form (Stores or Products).\n\t */\n\tthis.clearSearchInput = function (input, btnCross, btnRefresh) {\n\t\tinput.value = \"\";\n\t\tbtnCross.classList.add(\"non-active\");\n\t\tbtnRefresh.classList.remove(\"non-active\");\n\t};\n\n /**\n * Common method to show preloader.\n * \n * @param {HTMLElement} elem \n */\n\tthis.showPreloader = function (elem) {\n\t\telem.innerHTML = `\n\t\t<div class=\"preloader\">\n <img src=\"./assets/images/preloader.gif\" alt=\"\">\n </div>`\n\t};\n\n /**\n * Method for collecting data from a form to create a product.\n * \n * @returns obj with values from form.\n */\n this.formCreateProductValues = function () {\n\n let name = this.getModalCreateProduct().querySelector('[name=\"Name\"]');\n let price = this.getModalCreateProduct().querySelector('[name=\"Price\"]');\n let specs = this.getModalCreateProduct().querySelector('[name=\"Specs\"]');\n let rating = this.getModalCreateProduct().querySelector('[name=\"Rating\"]');\n let supplierInfo = this.getModalCreateProduct().querySelector('[name=\"SupplierInfo\"]');\n let madeIn = this.getModalCreateProduct().querySelector('[name=\"MadeIn\"]');\n let productionCompanyName = this.getModalCreateProduct().querySelector('[name=\"ProductionCompanyName\"]');\n let status = this.getModalCreateProduct().querySelector('[name=\"Status\"]');\n\n\t\tlet obj = {\n Name: name.value,\n Price: price.value,\n Photo: name.value,\n Specs: specs.value,\n Rating: rating.value,\n SupplierInfo: supplierInfo.value,\n MadeIn: madeIn.value,\n ProductionCompanyName: productionCompanyName.value,\n Status: status.value,\n };\n return obj\n };\n\n /**\n * Method for collecting data from a form to create a store.\n * \n * @returns obj with values from form.\n */\n this.formCreateStoreValues = function () {\n\n let name = this.getModalCreateStore().querySelector('[name=\"Name\"]');\n\t\t\tlet email = this.getModalCreateStore().querySelector('[name=\"Email\"]');\n\t\t\tlet phoneNumber = this.getModalCreateStore().querySelector('[name=\"PhoneNumber\"]');\n\t\t\tlet address = this.getModalCreateStore().querySelector('[name=\"Address\"]');\n\t\t\tlet established = this.getModalCreateStore().querySelector('[name=\"Established\"]');\n\t\t\tlet floorArea = this.getModalCreateStore().querySelector('[name=\"FloorArea\"]');\n\t\t\n\t\t\tlet obj = {\n\t\t\t\tName: name.value,\n\t\t\t\tEmail: email.value,\n\t\t\t\tPhoneNumber: phoneNumber.value,\n\t\t\t\tAddress: address.value,\n\t\t\t\tEstablished: established.value,\n\t\t\t\tFloorArea: floorArea.value,\n\t\t\t\tid: established.value\n }\n return obj\n } \n\t\t\n}", "title": "" }, { "docid": "62d012bb1aa691c784f4b0c4e3e86ef3", "score": "0.54477507", "text": "function getBackButtonURL(productPrice) {\n const candles = \"Price: $3.50 each\";\n const soaps = \"Price:<small> $1/mini soap | $3.50/bag of 4 mini’s | $5/bar</small>\";\n const bathBombs = \"Price: $4.00/bomb\";\n if(productPrice === candles) {\n backButton.innerHTML += \"Candles\";\n return \"candles\";\n } else if (productPrice === soaps) {\n backButton.innerHTML += \"Soaps\";\n return \"soaps\";\n } else if (productPrice === bathBombs) {\n backButton.innerHTML += \"Bath Bombs\";\n return \"bath-bombs\";\n }\n}", "title": "" }, { "docid": "0f6b1bc2c21b18c51a49306514b74837", "score": "0.5404954", "text": "function initIndexPageFields(){\r\n $(\"#linkBtn_OurPlatform\").click(function () {\r\n window.location.href = \"product.html\";\r\n });\r\n $(\"#linkBtn_SeeWorks\").click(function () {\r\n window.location.href = \"index.html\";\r\n });\r\n $(\"#linkBtn_AllCourse\").click(function () {\r\n window.location.href = \"index.html\";\r\n });\r\n}", "title": "" }, { "docid": "fb353e5d45c47da74fcbc599c07f7201", "score": "0.54033464", "text": "_registerOnBack() {\n this._btnBack = document.getElementById('tceditorback');\n this._btnBack.onclick = (event) => {\n window.location.href = ServiceEditor.getPreviousRoute();\n };\n }", "title": "" }, { "docid": "ab97ef83b55b396b6f7560547dd6e690", "score": "0.53962046", "text": "function showOptions() {\n op1Button.show();\n op2Button.show();\n op3Button.show();\n op4Button.show();\n}", "title": "" }, { "docid": "4f76a2ce2adfddd59236d39acb75a592", "score": "0.5388774", "text": "function msf_btn_back() {\r\n msf_getFsTag[msf_form_nr].className = \"msf_hide\";\r\n msf_form_nr = msf_form_nr - 1;\r\n msf_getFsTag[msf_form_nr].className = \"msf_showhide\";\r\n}", "title": "" }, { "docid": "ee7680c30abc606bcd0d4909c0e52853", "score": "0.5377348", "text": "function buy_product() {\n\t$(document).ready(function () {\n\t\t$(\".buy-btn\").each(function () {\n\t\t\t$(this).click(function () {\n\t\t\t\tvar product_id = $(this).attr(\"product-id\");\n\t\t\t\twindow.location = ROOT_URL+\"/eshop/buy_now/\" + btoa(product_id);\n\t\t\t});\n\t\t});\n\t});\n}", "title": "" }, { "docid": "e5beed69149497ae43af037fb85bf8c4", "score": "0.53651285", "text": "function gotoOrders()\n {\n $state.go('app.e-commerce.orders');\n }", "title": "" }, { "docid": "903418e7810d2452949c41c2e3b07ff0", "score": "0.53307056", "text": "render() {\r\n const columns = [\r\n {\r\n title: 'Product Number',\r\n dataIndex: 'productId',\r\n key: 'productId',\r\n },\r\n {\r\n title: 'Product Name',\r\n dataIndex: 'product',\r\n key: 'product',\r\n },\r\n {\r\n title: 'Price',\r\n dataIndex: 'price',\r\n key: 'price',\r\n },\r\n {\r\n title: 'Description',\r\n dataIndex: 'description',\r\n key: 'description',\r\n },\r\n {\r\n title: 'Action',\r\n key: 'action',\r\n render: (text, record) =>\r\n this.state.products.length >= 1 ? (\r\n <Button onClick={ () => this.usePrevious( record.productId ) }>Select</Button>\r\n ) : null,\r\n },\r\n ];\r\n return (\r\n <div className=\"product-container\">\r\n <h2 className=\"page-title\"> Add a Product </h2>\r\n <Modal\r\n title=\"Previous Products\"\r\n centered\r\n width='60%'\r\n destroyOnClose={true}\r\n visible={ this.state.visable }\r\n onOk={ () => this.setVisable( false ) }\r\n onCancel={ () => this.setVisable( false ) }>\r\n \r\n <div className=\"table\">\r\n <Table \r\n dataSource={this.state.products} \r\n columns={columns} \r\n rowKey={(record) => record.productId}\r\n bordered\r\n pagination={false}\r\n scroll={{ y: 500 }}/>\r\n </div>\r\n </Modal>\r\n <Button \r\n style={{ borderColor:\"#597ef7\"}}\r\n onClick={ () => this.setVisable( true ) }>Use Previous Product</Button>\r\n <Form>\r\n <FormItem label=\"Product\">\r\n <Input \r\n name=\"product\"\r\n size=\"large\"\r\n type=\"text\" \r\n autocomplete=\"off\"\r\n placeholder=\"product name\"\r\n value={this.state.product.value}\r\n onChange={(event) => this.handleInputChange(event) } maxLength=\"20\"/>\r\n </FormItem>\r\n <FormItem label=\"Product description\">\r\n <Input \r\n name=\"description\"\r\n size=\"large\"\r\n type=\"text\" \r\n autocomplete=\"off\"\r\n placeholder=\"description\"\r\n value={this.state.description.value}\r\n onChange={(event) => this.handleInputChange(event) } maxLength=\"255\"/>\r\n </FormItem>\r\n <FormItem label=\"Price\">\r\n <Input \r\n name=\"price\"\r\n size=\"large\"\r\n type=\"Integer\" \r\n autocomplete=\"off\"\r\n placeholder=\"0.00\"\r\n value={this.state.price.value}\r\n onChange={(event) => this.handleInputChange(event) } maxLength=\"5\"/>\r\n </FormItem>\r\n \r\n <Row gutter={[185, 8]} type=\"flex\">\r\n <Col xs={{ span:20, offset:0}}\r\n lg={{span:6, offset:0}}>\r\n <input \r\n type=\"file\" \r\n onChange={ this.fileChangedHandler }></input>\r\n </Col>\r\n <Col xs={{ span:15, offset:1}}\r\n lg={{span:6, offset:6}}>\r\n <Button onClick={ this.handleUpload }>Upload</Button>\r\n </Col>\r\n <Col xs={{ span:20, offset:0}}\r\n lg={{span:6, offset:0}}>\r\n <Button\r\n type=\"danger\" ghost\r\n htmlType=\"button\"\r\n size=\"large\"\r\n className=\"back-button\"\r\n onClick={ this.handleBackClick(\"/campaigns\")}> Cancel </Button>\r\n </Col> \r\n <Col xs={{ span:15, offset:1}}\r\n lg={{span:6, offset:5}}>\r\n <Button \r\n htmlType=\"submit\" \r\n style={{ borderColor:\"#597ef7\"}}\r\n size=\"large\"\r\n disabled={ !this.state.uploadImage}\r\n onClick = { this.handleSubmit}> Add Product</Button>\r\n </Col>\r\n </Row>\r\n </Form>\r\n </div>\r\n );\r\n }", "title": "" }, { "docid": "a193815ce9e727481c7df7d0f2f9e821", "score": "0.53227055", "text": "function paintPrevButtons() {\n var localStgLists = JSON.parse(localStorage.getItem(\"spotify-prev-lists\"));\n for (var i = 2; i >= 0; i--) {\n var myBtn = document.querySelector(\"#btn\" + i);\n myBtn.textContent = localStgLists[i].genre;\n myBtn.value = localStgLists[i].genre;\n }\n}", "title": "" }, { "docid": "848727bf48fe73f57ef300d8aaa49680", "score": "0.5296006", "text": "function openPauseMenu() {\r\n\tpausing = true;\r\n\tresumeButton.active = true;\r\n\tshopButton.active = true;\r\n}", "title": "" }, { "docid": "7757ba713b7b8bcceba7a4c42ddebce9", "score": "0.5291988", "text": "clickCartIcon(){\n genericActions.click(headerPage.cartIcon);\n }", "title": "" }, { "docid": "9c2ca0529861b2428c8c0dba986bd8a3", "score": "0.52909595", "text": "function backToStepTwoFromThree() {\n\t\tdocument.querySelector('.header-area').innerHTML = templates.header(\n\t\t\t'Setup',\n\t\t\t'long-arrow-left back-to-step-one',\n\t\t\t'go-back-btn'\n\t\t);\n\t\tdocument.querySelector(\n\t\t\t'.main-content'\n\t\t).innerHTML = renderDeviceListAndSelect();\n\t\tdocument.querySelector('.footer-area').style.display = 'none';\n\t\tconst clientID = document.querySelector('.client-id');\n\t\tclientID.value = getLocalStorage('clientID');\n\t}", "title": "" }, { "docid": "8eb14b863ac6e1cd645064ace53d9333", "score": "0.5286159", "text": "function previousCard() {\n\t$('#gallery a')[elementIndex-1].click();\n}", "title": "" }, { "docid": "55509456a752eb8a0fa35fb146325308", "score": "0.5271477", "text": "function previousPageBtn() {\n currentComicNumber = Number(currentComicNumber) - Number(comicPerPage);\n updateComicsPage();\n}", "title": "" }, { "docid": "9ed70ca92f46002281c4b267555e39b3", "score": "0.5269556", "text": "function buyAllBtn() {\r\n let $btnBuyContainer = document.querySelector('#widgetBuy');\r\n let btnBuy = `\r\n <input type=\"submit\" class=\"widget__cart--delete\" id=\"deleteAll\" value=\"Borrar todo\">\r\n <input type=\"submit\" class=\"widget__cart--buyAll\" id=\"buyAll\" value=\"Comprar todo\">\r\n `;\r\n let productInCart = JSON.parse(localStorage.getItem('cart'));\r\n $btnBuyContainer.innerHTML = btnBuy;\r\n if (productInCart === null) {\r\n return ($btnBuyContainer.innerHTML = '');\r\n }\r\n $('#buyAll').click(() => {\r\n window.location.href = 'cartdetail.html';\r\n });\r\n $('#deleteAll').click(() => {\r\n localStorage.clear();\r\n window.location.reload();\r\n });\r\n}", "title": "" }, { "docid": "6361f8ea271c4ebf845842bdbb5dc1c2", "score": "0.5264832", "text": "function goBack() {\n new SelectionService().select('');\n window.location.href = '/';\n}", "title": "" }, { "docid": "a9a83c14c49c8ae516608d4ce0602a41", "score": "0.5262906", "text": "function OnBtnBack_Click( e )\r\n{\r\n Back() ;\r\n}", "title": "" }, { "docid": "dd16ec3c8ca3a2e48fb3fe017cc2d50c", "score": "0.525914", "text": "function initEcommerceNavbar() {\n $(\".is-cart .cart-button\").on(\"click\", function () {\n $(this).closest(\".is-cart\").find(\".shopping-cart\").addClass(\"is-active\");\n setTimeout(function () {\n $(\".is-cart .navbar-cart-loader\").removeClass(\"is-active\");\n }, 800);\n });\n\n $(\".is-wishlist .wishlist-button\").on(\"click\", function () {\n $(this)\n .closest(\".is-wishlist\")\n .find(\".shopping-wishlist\")\n .addClass(\"is-active\");\n setTimeout(function () {\n $(\".is-wishlist .navbar-cart-loader\").removeClass(\"is-active\");\n }, 800);\n });\n\n $(document).click(function (e) {\n var target = e.target;\n if (\n !$(target).is(\".is-cart .cart-button\") &&\n !$(target).parents().is(\".is-cart\")\n ) {\n $(\".shopping-cart\").removeClass(\"is-active\");\n setTimeout(function () {\n $(\".is-cart .navbar-cart-loader\").addClass(\"is-active\");\n }, 300);\n }\n });\n\n $(document).click(function (e) {\n var target = e.target;\n if (\n !$(target).is(\".is-wishlist .wishlist-button\") &&\n !$(target).parents().is(\".is-wishlist\")\n ) {\n $(\".shopping-wishlist\").removeClass(\"is-active\");\n setTimeout(function () {\n $(\".is-wishlist .navbar-cart-loader\").addClass(\"is-active\");\n }, 300);\n }\n });\n}", "title": "" }, { "docid": "df357aef6749ea4c4c8efdf4ab541d11", "score": "0.52358335", "text": "function counteractPrevNextButtons() {\n var prevNext = document.querySelectorAll(\".prev-next a\");\n var i;\n if (prevNext.length > 0) {\n i = prevNext.length - 1;\n for (; i >= 0; --i) {\n prevNext[i].setAttribute(\"data-href\", prevNext[i].href);\n prevNext[i].href = \"\";\n prevNext[i].onclick = function(e) {\n this.href = this.getAttribute(\"data-href\");\n this.click();\n };\n }\n }\n }", "title": "" }, { "docid": "80a87e668172f549977bd1ebfeca005a", "score": "0.5222316", "text": "function category_tag_buttons(){\n if(window.location.href.toString().split(\"?\")[1] == \"section=category\"){\n $('#category').css({ \"background-color\" : \"#f4f4f4\", \"border-left\" : \"2px solid #454545\" });\n $('#tag').css({ \"background-color\" : \"#fff\", \"border-left\" : \"2px solid #dedede\" });\n $('#catEtag_search').attr(\"placeholder\", \"Category\");\n }\n if(window.location.href.toString().split(\"?\")[1] == \"section=tag\"){\n $('#tag').css({ \"background-color\" : \"#f4f4f4\", \"border-left\" : \"2px solid #454545\" });\n $('#category').css({ \"background-color\" : \"#fff\", \"border-left\" : \"2px solid #dedede\" });\n $('#catEtag_search').attr(\"placeholder\", \"Tag\");\n }\n}", "title": "" }, { "docid": "1ffacff27ad206731336650f83471b46", "score": "0.52213097", "text": "function showBack(event) {\n\tdocument.getElementById(\"Selections1\").value = selectionType; // Sets the users selection in the Selections1 popup menu to the value stored in selectionType.\n\tdocument.getElementById(\"Generate1\").value = generateType; // Sets the users selection in the Generate1 popup menu to the value stored in generateType.\n\tdocument.getElementById(\"Color1\").value = colorType; // Sets the users selection in the Color1 popup menu to the value stored in colorType.\n\tdocument.getElementById(\"Update1\").value = updateCheck; // Sets the users selection in the Update1 popup menu to the value stored in updateCheck.\n document.getElementById(\"QuoteTotal\").innerText = Quotes.length + \" quotes\"; // Shows the total number of quotes in the QuoteTotal text.\n var front = document.getElementById(\"front\"); // The following code transitions the widget from front to back.\r var back = document.getElementById(\"back\");\r if (window.widget) {\r widget.prepareForTransition(\"ToBack\");\r }\r front.style.display = \"none\";\r back.style.display = \"block\";\r if (window.widget) {\r setTimeout('widget.performTransition();', 0);\r } // End of widget transition code.\n}", "title": "" }, { "docid": "44d14ca071de6e34fd71646ea6371714", "score": "0.52196366", "text": "function burgerMenuSerials(e) {\n e.preventDefault();\n apiPopular.type = 'tv';\n clearListItemFilm();\n apiPopular.fetch().then(result => {\n itemGallery = result;\n insertMarkup(result);\n })\n}", "title": "" }, { "docid": "6bd60eb61536f4d02c007239c409bc2b", "score": "0.5219185", "text": "function buttons() {\n //Lägga varor i varukorg\n const addToCartBtn = document.querySelectorAll(\".addToCart\");\n addToCartBtn.forEach((e) => {\n e.addEventListener(\"click\", addToCart);\n });\n \n //ökning\n const increBtn = document.querySelectorAll(\".cartIncrement\");\n increBtn.forEach((e) => {\n e.addEventListener(\"click\", changeQuantity);\n });\n //minskning\n const decreBtn = document.querySelectorAll(\".cartDecrement\");\n decreBtn.forEach((e) => {\n e.addEventListener(\"click\", changeQuantity);\n });\n //ta bort varor från korgen\n const deleteBtn = document.querySelectorAll(\".itemDelete\");\n deleteBtn.forEach((e) => {\n e.addEventListener(\"click\", deleteItem);\n });\n }", "title": "" }, { "docid": "d9634deaf203d7d2e83463e572f0c27f", "score": "0.52181005", "text": "function changeButtonAndQuantityOnInsert(x) {\n $(x).find(\".hideShowButton\").popover('show');\n hidePopover(\".hideShowButton\");\n $(x).find(\".hideShowButton\").text(\"Item is in Cart\").prop('disabled', true);\n // Hide quantity\n $(x).find(\".startquantity\").addClass(\"hide\");\n }", "title": "" }, { "docid": "fa36e1f2862627b9b25384e40adebea1", "score": "0.5210373", "text": "function showProducts() {\n if (jQuery.isEmptyObject(select) === false && jQuery.isEmptyObject(selectStore) === false) {\n $(\".customers-store-container\").css(\"display\", \"none\");\n $(\".products-container\").css(\"display\", \"block\");\n cartAvailable();\n }\n }", "title": "" }, { "docid": "e65ca9a3adb7d7da7540fca41a93acad", "score": "0.5206995", "text": "function selectTabStores() {\n $('#tabs').find('li').removeClass('selected');\n $('div.tab').hide();\n\n $('#btnTabStores').addClass('selected');\n $('#tabStores').show();\n\n if ($('div.store').length == 0 &&\n $('#storesLoader').is(':hidden')) {\n updateBanners();\n }\n}", "title": "" }, { "docid": "47564e86a2d4e4e3fa93bdbb4aaa0ea3", "score": "0.5205138", "text": "function openProd(){\n $('.toproduct').click(function(){\n location.replace(app_root+'/productos/'+$(this).attr(\"id\"));\n });\n}", "title": "" }, { "docid": "59a89fd1d3a95f124a40e1cbe57fa302", "score": "0.5203035", "text": "clickBackButton(){\n this.backButton.waitForExist();\n this.backButton.click();\n }", "title": "" }, { "docid": "223e82de1db05d4f4d51135c733f4cac", "score": "0.5195424", "text": "function BackButtonClickHandler()\n{\n switch(CurrentRole.toLowerCase())\n {\n case \"contractor\":\n SlideToPage(\"account.html\");\n break;\n case \"worker\":\n SlideToPage(\"account.html\");\n break;\n }\n}", "title": "" }, { "docid": "322d78d082507f1ae8e5d75a2078541f", "score": "0.5194721", "text": "function selectNextButton() {\n if (onMainMenu) {\n select.play()\n if (currentButton == \"none\" || currentButton == \"credits\" || currentButton == \"back\") {\n currentButton = \"play\";\n document.getElementById(\"play-button\").classList.add('hover');\n document.getElementById(\"credits-button\").classList.remove('hover');\n // document.getElementById(\"back-button\").classList.remove('hover');\n } else if (currentButton == \"play\") {\n currentButton = \"credits\";\n document.getElementById(\"credits-button\").classList.add('hover');\n document.getElementById(\"play-button\").classList.remove('hover');\n // document.getElementById(\"back-button\").classList.remove('hover');\n }\n }\n // else {\n // currentButton = \"back\";\n // document.getElementById(\"back-button\").classList.add('hover');\n // }\n}", "title": "" }, { "docid": "f1eb52c3fdec2b2e4b10a86cb63574ff", "score": "0.5192078", "text": "function chooseButton() {\n if (currentButton == \"play\") {\n play();\n } else if (currentButton == \"credits\") {\n credits();\n }\n // else if (currentButton == \"back\") {\n // back();\n // currentButton = \"credits\";\n // }\n}", "title": "" }, { "docid": "5856b9323f86be6f18998c00760bae0b", "score": "0.51893306", "text": "function addClickEventToButtons(){\n let buttons = document.querySelectorAll('.buyProduct');\n\n for (let i = 0; i < buttons.length; i++){\n buttons[i].addEventListener('click', () =>{\n let productID = buttons[i].value;\n\n addToBasket(productID);\n });\n }\n}", "title": "" }, { "docid": "9549060197099d7119db31c7ecfa2d2a", "score": "0.51844835", "text": "get backButton() {return browser.element(\"//android.view.ViewGroup/android.view.ViewGroup/android.widget.Button\");}", "title": "" }, { "docid": "88cf01ff4f7df8cef2347385f2a2a8a2", "score": "0.517703", "text": "function backToList(){\n if($(\"#resLink\").hasClass(\"btn btn-primary\")){ // If we want to go back to search list.\n showNearbyPlaces(placeList.curr);\n }else{\n showFavList();\n }\n}", "title": "" }, { "docid": "8957965728c3ad3bfaa6f4e0fcda2707", "score": "0.5175458", "text": "function updatePrevAndNextButtonStates() {\n // Disable the previous button if we are on the first page. Disable the Next button if we are on the last page currently loaded\n GetjQueryReference(\"cmdListPageUp\").prop(\"disabled\", (g_iPageDisplayed === 0));\n GetjQueryReference(\"cmdListPageDown\").prop(\"disabled\", (g_iPageDisplayed === (g_iPagesLoaded - 1))); // g_iPagesLoaded is one-based\n}", "title": "" }, { "docid": "e4ad0a70c34fb5667600977464249c26", "score": "0.5173875", "text": "_onPreviousClick(event) {\n // we stop propagation in case the wizard views are nested\n event.stopPropagation();\n\n this.previous();\n\n const stepList = this.stepLists.first();\n const step = stepList.items.getAll()[this._getSelectedIndex()];\n this._trackEvent('click', 'coral-wizardview-previous', event, step);\n }", "title": "" }, { "docid": "6c6e69d69706b3959180b1f59240e4c2", "score": "0.51738346", "text": "function goBackToList(){\n goBackTicketingPage ();\n}", "title": "" }, { "docid": "ce107f3a615e78a72d033e7b0a0315a0", "score": "0.5159449", "text": "function prebutton() {\n exp.go();\n }", "title": "" }, { "docid": "49c2bdb2eedc771822402f0be70cb024", "score": "0.51512855", "text": "async continueToCard() {\n await this.page.waitForSelector(PRODUCT_PAGE.MODAL_POPUP);\n await this.page.click(PRODUCT_PAGE.GO_TO_ORDER_BTN);\n }", "title": "" }, { "docid": "b3f8c9a081fedfae93f69d70c70e8b94", "score": "0.5144071", "text": "function activadorEventosProductos()\n{\n //*****************************************************\n //** VARIABLES PRINCIPALES DE LA SECCION PRODUCTOS **\n //*****************************************************\n var verProducto, volverProducto;\n // ASIGNACION DE EVENTOS A LAS VARIABLES DECLARADAS\n\n verProducto=$(\".VerProducto\");\n verProducto.click(VerProducto);\n volverProducto=$(\"#VolverProducto\");\n volverProducto.click(seccionListadoProductos);\n\n}", "title": "" }, { "docid": "6bbc59de7a8ec090601bac2bbf6b2d8a", "score": "0.5144062", "text": "function toControlProductState(btn, state) {\n var product = btn.closest('.js-product-item');\n var productQuantity = product.querySelector('.js-value');\n\n productQuantity.readOnly = state;\n product.classList.toggle(IS_DELETED, state);\n btn.textContent = state ? 'Вернуть' : 'Удалить';\n btn.classList.toggle(IS_ACTIVE, state);\n }", "title": "" }, { "docid": "6bbc59de7a8ec090601bac2bbf6b2d8a", "score": "0.5144062", "text": "function toControlProductState(btn, state) {\n var product = btn.closest('.js-product-item');\n var productQuantity = product.querySelector('.js-value');\n\n productQuantity.readOnly = state;\n product.classList.toggle(IS_DELETED, state);\n btn.textContent = state ? 'Вернуть' : 'Удалить';\n btn.classList.toggle(IS_ACTIVE, state);\n }", "title": "" }, { "docid": "ff25fcd1d9545bb1b4084c8453196ed1", "score": "0.5137053", "text": "function prev() {\n if (index - 4 >= 0) {\n if (index - 4 < posts.length - 4) {\n activateButton($(\"#btn-next\"));\n }\n index -= 4;\n if (index - 4 < 0) {\n greyButton($(\"#btn-prev\"));\n }\n renderPosts();\n }\n}", "title": "" }, { "docid": "767306958d996cacc1ac16ba882c7433", "score": "0.51338255", "text": "function show() {\r\n\t$('#btn-cancel').show();\r\n\t$('#btn-choose').show();\r\n}", "title": "" }, { "docid": "5d21bf7bc8f9645af0b537ad36c3d67e", "score": "0.51330155", "text": "bindChooseProduct(goToProductPage) {\n this.listGroup.addEventListener('click', event => {\n const itemNumber = Array.from(event.target.parentNode.children).indexOf(event.target);\n goToProductPage(itemNumber)\n })\n }", "title": "" }, { "docid": "b1dd7431ca576ef8253b07f710aa9baa", "score": "0.5132553", "text": "get backButton() {return browser.element(\"//android.widget.Button/android.view.ViewGroup/android.widget.ImageView\");}", "title": "" }, { "docid": "b1dd7431ca576ef8253b07f710aa9baa", "score": "0.5132553", "text": "get backButton() {return browser.element(\"//android.widget.Button/android.view.ViewGroup/android.widget.ImageView\");}", "title": "" }, { "docid": "a686bd01be68a1f9ba3f45ba9c2d952b", "score": "0.5129921", "text": "function butonclick(){\n\tcartIsOpen == false ? openCart() : closeCart();\n}", "title": "" }, { "docid": "33a4c6d8dadb619f37270cfc5919d541", "score": "0.51282966", "text": "function others_callback_menu(convo) {\n convo.ask({\n \"attachment\": {\n \"type\": \"template\",\n \"payload\": {\n \"template_type\": \"button\",\n \"text\": \"You can select the following to go back !!!!!!!!!\",\n \"buttons\": [{\n \"type\": \"postback\",\n \"title\": \"Go Back\",\n \"payload\": \"others again\"\n }, {\n \"type\": \"postback\",\n \"title\": \"Main Menu\",\n \"payload\": \"again_payload\"\n }]\n }\n }\n });\n}", "title": "" }, { "docid": "61d320ecdc8b822813b7d868cc40439a", "score": "0.5121246", "text": "onBackButtonClick_() {\n this.userActed('os-trial-back');\n }", "title": "" }, { "docid": "b84503466d156b026b98225fc3e2da53", "score": "0.5119282", "text": "onTosBackButtonPressed_() {\n this.backButtonDisabled_ = true;\n this.retryButtonDisabled_ = true;\n this.acceptButtonDisabled_ = true;\n this.userActed('back');\n }", "title": "" }, { "docid": "e7aeb4c716f42624615e329014ac1467", "score": "0.51173145", "text": "goToPreviousItem() {\n let index = this.getState().current.item;\n this.dispatch(actions.goToItem(index - 1));\n }", "title": "" }, { "docid": "758c05e88743231e83287efc71733943", "score": "0.51158684", "text": "function _showPreviousStep() {\n RightMenu.showRightMenu(Pages.addFsMenuSearchResultStep, null);\n }", "title": "" }, { "docid": "dae20cfa4956f4d0858229c449629328", "score": "0.5114108", "text": "function goBack(event) {\n\tlet clickTag = event.target;\n\t// if user clicked the button\n\tif (clickTag.classList.contains(\"back\")) {\n\t\t//hide the single recipe\n\t\trecipeSelectedEl.classList.add(\"is-hidden\");\n\t\t//unhide the previous list\n\t\trecipeListEl.classList.remove(\"is-hidden\");\n\t\t// Will clear the current recipe and delete the back button\n\t\trecipeSelectedEl.innerHTML = \"\";\n\t}\n}", "title": "" }, { "docid": "b76a31cc6a2d34b8106b1c59d1e239ce", "score": "0.5113247", "text": "function handleNextAndPrevButton() {\n log(\"Handle next and prev\");\n if (hasPrevVersion()) {\n log(\"Has prev version TRUE\");\n setPrevButtonEnable();\n } else {\n log(\"Has prev version FALSE\");\n setPrevButtonDisabled();\n }\n\n if (hasNextVersion()) {\n log(\"Has next version TRUE\");\n setNextButtonEnable()\n } else {\n log(\"Has next version FALSE\");\n setNextButtonDisable();\n }\n}", "title": "" }, { "docid": "1bbb396964955b3ec5401578be487122", "score": "0.5112631", "text": "function showActiveButton() {\n var category = getQueryVariable(\"tema\");\n var show = getQueryVariable(\"rodyti\");\n var search = getQueryVariable(\"s\");\n var dataShow = category != null ? category : show;\n var target = $('button[data-show =\"' + dataShow + '\"]');\n target.addClass(\"active\");\n if (category == null && show == null && search == null) {\n $('button[data-show =\"visi\"]').addClass(\"active\");\n }\n $(\"#additional-nav-opener\").addClass(\"active\");\n}", "title": "" }, { "docid": "0abf080e8e7a1a34630bf32d6afb72f8", "score": "0.5111581", "text": "function navPageButton(e) {\r\n if (e.id == \"nextBtn\") {\r\n gotoNextPage();\r\n }\r\n else if (e.id == \"prevBtn\") {\r\n gotoPrevPage();\r\n }\r\n}", "title": "" }, { "docid": "3b72990c84e1c07fa61a305c09353300", "score": "0.51109457", "text": "back() {\n this._lastAction = 'back';\n this._navigate(null, -1);\n }", "title": "" }, { "docid": "48c14731dd8e64f1883962023dafd763", "score": "0.5104297", "text": "function loadProductNavigation() {\n if (app.quickView.isActive()) {\n return;\n }\n \n var pidInput = $cache.pdpForm.find(\"input[name='pid']\").last();\n var navContainer = $(\"#product-nav-container\");\n \n // if no hash exists, or no pid exists, or nav container does not exist, return\n if (!window.location.hash.length || !pidInput.length || !navContainer.length) {\n return;\n }\n\n var pid = pidInput.val();\n var hashParams = window.location.hash.substr(1);\n if (hashParams.indexOf(\"pid=\" + pid) < 0) {\n hashParams += \"&pid=\" + pid;\n }\n \n var url = app.util.getPipeUrl('Product-Productnav') + (app.util.getPipeUrl('Product-Productnav').indexOf(\"?\") < 0 ? \"?\" : \"&\") + hashParams;\n app.ajax.load({\n url: url,\n target: navContainer,\n callback: function() {\n try {\n $(\".product-nav-target\").find(\"span.prev\").html(app.resources.PREVIOUS_ITEM);\n $(\".product-nav-target\").find(\"span.next\").html(app.resources.NEXT_ITEM);\n } catch(e) {\n //alert(e);\n }\n } \n });\n \n navContainer.appendTo(\".product-nav-target\");\n }", "title": "" }, { "docid": "34a14c5f853807a29580ad855ec133ce", "score": "0.51029396", "text": "function previousTrack(){\n\t\tvar previousTrackButton = $(mPreviousTrackButtonSelector).get(0);\n\t\tsimulateClick(previousTrackButton);\n\t}", "title": "" }, { "docid": "cc33301730b0633d72d077fc5c60b11d", "score": "0.508728", "text": "function prevPage() {\n\tvar token = $('#prev-button').data('token');\n\tvar q = $('#prev-button').data('query');\n\t// above does not exist in HTML; is written by getButtons() below\n\tsearch(token, q);\n}", "title": "" }, { "docid": "12b28c0e71b04e2e5900463cf5bfab98", "score": "0.5085528", "text": "setupButtons() {\n const buttons = this.template.querySelectorAll(BUTTON_SELECTOR);\n\n if (buttons.length > 0) {\n this.setButtonTabindex(buttons, 0);\n }\n }", "title": "" }, { "docid": "54a843e64e7f28855a42bceb87739448", "score": "0.50817055", "text": "function nav_bar(this_product_key, products_data) {\n // This makes a navigation bar to other product pages\n for (this_products_key in products_data) {\n if (this_products_key == this_product_key) continue;\n document.write(`<a href='./display_products.html?this_products_key=\n ${this_products_key}'>${this_products_key}<a>&nbsp&nbsp&nbsp;`);\n //creaating a bunch of hyperlinks \n }\n}", "title": "" }, { "docid": "31e07eecc48025a2617093deefefedde", "score": "0.5080732", "text": "handlePreviousDisable() {\n if (this.state.page === 0) {\n document.getElementById(\"previousBtn\").className = \"btn_list-lg-disabled\";\n }\n else {\n document.getElementById(\"previousBtn\").className = \"btn_list-lg\";\n }\n }", "title": "" } ]
b407f442a840efbe7c3aa797e6981dbe
Function to change 'display' value of the modal, using under control of other related functions
[ { "docid": "265d10d4598c98236cf6444d3c4614cb", "score": "0.0", "text": "function openModal(modalId) {\n var modal = document.querySelector(\"#\"+modalId);\n modal.style.display = \"block\";\n}", "title": "" } ]
[ { "docid": "12125fe3eb1764c9c8dd21c6fa7a010f", "score": "0.74502355", "text": "function trigModal(){\n document.getElementById(\"settingsModal\").style.display = \"block\";\n}", "title": "" }, { "docid": "06bd5753fd0f42a2eae11db9e36e7fa9", "score": "0.7325415", "text": "function hh() {\r\n modal.style.display = \"block\";\r\n}", "title": "" }, { "docid": "900d71c107b769bc50f3bb590898b324", "score": "0.7280424", "text": "function showModal() {\n getModal.style.display='block';\n}", "title": "" }, { "docid": "2944a55585b1a8383e342faf63e5212c", "score": "0.7279678", "text": "openModal() {\r\n modal.style.display = \"block\";\r\n}", "title": "" }, { "docid": "1dee68cd86591caece656f87fb367fbc", "score": "0.71882695", "text": "function modal1() {\r\n modal.style.display = \"block\";\r\n }", "title": "" }, { "docid": "409c49d255fb65a239b2abd98b45facb", "score": "0.71712226", "text": "function modalshow(x) {\n if (x === 1) {\n modal.style.display = \"block\";\n } else if (x === 0) {\n modal.style.display = \"none\";\n\n }\n}", "title": "" }, { "docid": "0c5f22a9e1e400590549a9f5ef530395", "score": "0.71037745", "text": "function displayEditModal() {\n viewEdit === \"hidden\" ? setViewEdit(\"visible\") : setViewEdit(\"hidden\");\n }", "title": "" }, { "docid": "5ebea09e288310062728efe0b0b91664", "score": "0.7079144", "text": "function openModal(){\n // console.log(123); a test To make sure that this is working\n modal.style.display = 'block';\n}", "title": "" }, { "docid": "7baadcca0ff5fb051446aea17bc397d7", "score": "0.7055593", "text": "function openModal() {\n modal.style.display ='block';\n}", "title": "" }, { "docid": "cf0e702cb750173c6c135d1368b60a06", "score": "0.705288", "text": "showModal() {\n document.getElementById(\"modal\").style.display = \"block\";\n }", "title": "" }, { "docid": "cdd9248545bc7e502e10c99cd103fcdc", "score": "0.7041278", "text": "function attShowModal() {\n setShowModal(!showModal);\n }", "title": "" }, { "docid": "cdd9248545bc7e502e10c99cd103fcdc", "score": "0.7041278", "text": "function attShowModal() {\n setShowModal(!showModal);\n }", "title": "" }, { "docid": "791e234f8010282be2cce5d863ee1176", "score": "0.7035992", "text": "function showModal() {\n modal.style.visibility = 'visible';\n}", "title": "" }, { "docid": "5e38ef80be7fe621721594d2a75b3a6e", "score": "0.70352596", "text": "function budgetopenModal(){\n budgetmodal.style.display='block';\n}", "title": "" }, { "docid": "4621b36966cc9148dc8c96098764c85b", "score": "0.7029965", "text": "function EditInfo() {\n document.getElementById(\"infoModal\").style.display = \"block\";\n}", "title": "" }, { "docid": "c4bd5da8107a8c8c23d4023a3bf0e685", "score": "0.6997594", "text": "function abrir() {\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "735155c3fe957735d51745fdf7191fbe", "score": "0.6986271", "text": "function openModal() {\n return modalElement.style.display = \"block\";\n }", "title": "" }, { "docid": "fd99ec49cf902863e4975661b4f1688c", "score": "0.6959246", "text": "function openModal() {\r\n modal.style.display = \"block\";\r\n}", "title": "" }, { "docid": "336cfdb44e09b0810987175951956541", "score": "0.6959139", "text": "showModal(user) {\n this.modalContainer.style.display = \"inherit\";\n this.updateModalInfo(user);\n }", "title": "" }, { "docid": "91c8373657b8c2ed8ad4e6df170a96b7", "score": "0.6930976", "text": "function modal(modalID) {\n var modal = document.getElementById(modalID);\n if (modal.style.display == '') {\n modal.style.display = 'block';\n } else {\n modal.style.display = '';\n }\n}", "title": "" }, { "docid": "87509be90e0b837d59e78459b66861dd", "score": "0.69287544", "text": "function openModal() {\n modal.style.display = 'block';\n}", "title": "" }, { "docid": "670916792dd26773e069da4015ba7d79", "score": "0.6925497", "text": "function openModal() {\n modal.style.display = \"block\"\n}", "title": "" }, { "docid": "121edf2a397622d4e4c81a85134aec6b", "score": "0.6922601", "text": "function openModal() {\n modal.style.display = \"block\";\n }", "title": "" }, { "docid": "aa1ccf75017df00e7451db8112866309", "score": "0.6922119", "text": "function modalChange(){\n let modChange = document.getElementById('rules-modal');\n if(modChange.style.display === \"none\"){\n modChange.removeAttribute('style', 'display:none');\n } else {\n modChange.setAttribute('style' ,'display:none');\n }\n}", "title": "" }, { "docid": "02e3c601881f76a24041490a051e111d", "score": "0.6921715", "text": "function openSmIntModal() {\n document.getElementById(\"smIntModal\").style.display = \"block\";\n}", "title": "" }, { "docid": "abc9fe309fd340d6624661416588dfe7", "score": "0.69176555", "text": "function openModal() {\r\n modal.style.display = 'block';\r\n}", "title": "" }, { "docid": "346e06fa7081ce9e01fd47c3cf5ab739", "score": "0.69125307", "text": "function openModal() { \n modal.style.display = \"block\"; \n}", "title": "" }, { "docid": "a184611892b1569512ebbd132161db6a", "score": "0.6909858", "text": "function openModal(){\r\n modal.style.display = 'block';\r\n}", "title": "" }, { "docid": "5b0b5fcc31c1dc29f4ddb2cce2e0ebeb", "score": "0.6907215", "text": "function openModal() {\n MODAL.style.display = 'block';\n}", "title": "" }, { "docid": "c5c16bafdb78ec005788e166f18bf93f", "score": "0.6899468", "text": "function buyopenModal(){\n buymodal.style.display='block';\n}", "title": "" }, { "docid": "cbd99966e347d1ddbff3958c2b1482e2", "score": "0.68986833", "text": "function openmodal(){\r\n modal.style.display='block';\r\n}", "title": "" }, { "docid": "f501aa6f963e754b30c2eb7585355d04", "score": "0.6896147", "text": "function openModal1() {\n document.getElementById(\"pModal\").style.display = \"block\";\n}", "title": "" }, { "docid": "6955e5cff1339c3067b8c4c5f2dd35e2", "score": "0.68906504", "text": "function openModal(){\n modal.style.display = 'block'\n}", "title": "" }, { "docid": "7eb39c74a82ead71457b5102d027eb3f", "score": "0.68843275", "text": "function openModal() {\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "7eb39c74a82ead71457b5102d027eb3f", "score": "0.68843275", "text": "function openModal() {\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "2a72f292fefd44c86119abf61d4e478d", "score": "0.6882736", "text": "function openModal() {\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "2a72f292fefd44c86119abf61d4e478d", "score": "0.6882736", "text": "function openModal() {\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "2a72f292fefd44c86119abf61d4e478d", "score": "0.6882736", "text": "function openModal() {\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "32f4cbfce63e52e2d159377c1fd67bab", "score": "0.68753827", "text": "function openModal(){\n modal.style.display='block';\n}", "title": "" }, { "docid": "d6047dced46675ba5995604377dfe04e", "score": "0.6873867", "text": "function HDopenModal(){\r\n\tHDmodal.style.display = 'block';\r\n}", "title": "" }, { "docid": "b773d9e70b349be45937cac6e0b8307a", "score": "0.68711823", "text": "function showModal() {\n document.getElementById('modalId').style.display = 'block';\n}", "title": "" }, { "docid": "dfac5f95b0ef385a40a2bf0bb64c5359", "score": "0.68648154", "text": "function openModal(){\n\n modal.style.display = 'block';\n\n}", "title": "" }, { "docid": "1a76568dfd6ae78e72f67da9306ffcb2", "score": "0.68612343", "text": "function openModal(){\n modal.style.display='block';\n}", "title": "" }, { "docid": "feb051d8291db9e39c6b21fb3dd5e1b2", "score": "0.68578947", "text": "function openModal() {\r\n modal.style.display = 'block';\r\n }", "title": "" }, { "docid": "c3bfeeadf41e7fec55109c899a278594", "score": "0.685707", "text": "function displayModal(text) {\n modal = document.getElementById('myModal')\n modal.style.display = \"block\";\n $(\"#modalText\").text(text);\n }", "title": "" }, { "docid": "6d74090f04a2cad18f892c0fcb2c50ac", "score": "0.684802", "text": "function openModal(){\n modal.style.display = 'block';\n}", "title": "" }, { "docid": "31a02ac45669ccc902be23dea703b682", "score": "0.6843998", "text": "function openModal() {\n modal.style.display = 'block';\n}", "title": "" }, { "docid": "31a02ac45669ccc902be23dea703b682", "score": "0.6843998", "text": "function openModal() {\n modal.style.display = 'block';\n}", "title": "" }, { "docid": "0ade137aef9e58cfa4ef05252dbbf5ee", "score": "0.6840124", "text": "function openModal(){\n modal.style.display = 'block';\n}", "title": "" }, { "docid": "0ade137aef9e58cfa4ef05252dbbf5ee", "score": "0.6840124", "text": "function openModal(){\n modal.style.display = 'block';\n}", "title": "" }, { "docid": "10b3fe3a24ad015767a653cc9aa23b7d", "score": "0.6830587", "text": "function loadModal() {\n modal.style.display = \"block\"\n}", "title": "" }, { "docid": "851d6f36fea904bcb599abf43ed10054", "score": "0.6825024", "text": "function loadModal() {\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "0db3962eca178bd9b51ed24269cbe509", "score": "0.6817097", "text": "function openModal() {\n modal.style.display = \"block\";\n }", "title": "" }, { "docid": "ad0c2d0fd9f3f4f6ee14e9581284a21f", "score": "0.68122476", "text": "function openModal(){\n modal.style.display = \"block\";\n }", "title": "" }, { "docid": "a91b57ec3955443fe17daed425d95701", "score": "0.6805511", "text": "function modal_display(event) {\n find_movie_id(event.srcElement.id)\n modal.style.display = \"block\";\n}", "title": "" }, { "docid": "02939fd766f19b5d9df4faa478c952bc", "score": "0.6794114", "text": "function showMessage() {\n modal.style.display = \"block\";\n }", "title": "" }, { "docid": "b29eb3bc6641bed9b900027c05b136ec", "score": "0.6787019", "text": "function clktag() {\n document.getElementById('modaltag').style.display = \"block\";\n }", "title": "" }, { "docid": "4ea3417137e32a80ab79fe8ff2e8230f", "score": "0.67757726", "text": "function openModal() {\n\tmodal.style.display='block';\n}", "title": "" }, { "docid": "58a8df05ca4e8059279212173f3af6af", "score": "0.6774686", "text": "function MTopenModal(){\r\n\tMTmodal.style.display = 'block';\r\n}", "title": "" }, { "docid": "7495213b09c4263692d6ba85f4a737c0", "score": "0.6765475", "text": "function openModal(){\r\n\tmodal.style.display = 'block';\r\n}", "title": "" }, { "docid": "7495213b09c4263692d6ba85f4a737c0", "score": "0.6765475", "text": "function openModal(){\r\n\tmodal.style.display = 'block';\r\n}", "title": "" }, { "docid": "e824a2aa7c45aea7209f3892849c8dec", "score": "0.676466", "text": "function openModal(){\n mymodal.style.display = 'block';\n}", "title": "" }, { "docid": "d4bc725cf1d5d3e49031bbedd7410d7b", "score": "0.6763525", "text": "function showDisplay() {\r\n\r\n \"use strict\";\r\n\r\n nameChooser.style.display = \"none\";\r\n nameConfirmer.style.display = \"none\";\r\n matchDisplay.style.display = \"initial\";\r\n}", "title": "" }, { "docid": "0693e3a846c4bb95f14ecd0f909beb6a", "score": "0.67570424", "text": "function openModal() {\n modal.style.display = \"block\";\n }", "title": "" }, { "docid": "e39733c1655f196a1a13446f29a9905f", "score": "0.67503726", "text": "function openModal14() {\n document.getElementById('myModal14').style.display = \"block\";\n}", "title": "" }, { "docid": "fe17abecebd4af675069797f1da4d592", "score": "0.6748562", "text": "showModal() {\n this.modal.style.display = 'block';\n }", "title": "" }, { "docid": "b483f43e29a65ecf54e071605ed704bd", "score": "0.67389625", "text": "function modal_show(id) {\r\n var overlayNode = document.getElementById(id);\r\n overlayNode.style.display = 'table';\r\n setTimeout(function() {\r\n overlayNode.className = overlayNode.className.replace(/ ?invisible ?/, ' ');\r\n }, 50);\r\n}", "title": "" }, { "docid": "1007f97bf0cc508ce9acfe08ae112522", "score": "0.6735528", "text": "function changeModal(bool) {\n setShowModal(bool);\n }", "title": "" }, { "docid": "091c597d00ce6d5e90815fe1acf5be8c", "score": "0.67305326", "text": "function displayResetModal() {\n var display = (arguments.length === 0 || arguments[0] === true);\n var $modal = $('#modal-danger-reset-template');\n\n displayModal($modal, display);\n}", "title": "" }, { "docid": "6846c5731f1ed638238a96de1afc5dc0", "score": "0.67106557", "text": "function clkomega() {\n document.getElementById('modalomega').style.display = \"block\";\n }", "title": "" }, { "docid": "b097e9bc79f6eb67a50e07509652e7b2", "score": "0.67094684", "text": "function openModal13() {\n document.getElementById('myModal13').style.display = \"block\";\n}", "title": "" }, { "docid": "f77fb2b481d852882da3255eae911362", "score": "0.6706595", "text": "function EditPicture() {\n document.getElementById(\"pictureModal\").style.display = \"block\";\n}", "title": "" }, { "docid": "85127cc22f10aa986f4494980efe2e8d", "score": "0.66931295", "text": "function openModal() {\n\tmodal.style.display= 'block';\n}", "title": "" }, { "docid": "f2886e239ca9d65cb90d4c17fd9eeda3", "score": "0.66916263", "text": "function openModal11() {\n document.getElementById('myModal11').style.display = \"block\";\n}", "title": "" }, { "docid": "0436de29ef3537b2118f547f6a68fee1", "score": "0.6690096", "text": "function openModal() {\n modal.style.display = 'block';\n }", "title": "" }, { "docid": "7dde9d7b41a34d34d700d1698611a876", "score": "0.6682562", "text": "function TMopenModal(){\r\n\tTMmodal.style.display = 'block';\r\n}", "title": "" }, { "docid": "6fe217e1ffd14b7ee59f173575805abc", "score": "0.6681456", "text": "function clkjaeger() {\n document.getElementById('modaljaeger').style.display = \"block\";\n }", "title": "" }, { "docid": "4f4c9b6e2da61376c888cd16291e55a2", "score": "0.6674977", "text": "function openModal(){\n\tmodal.style.display = 'block';\n}", "title": "" }, { "docid": "77c237b2ce8d845ff8407b214c5cd0d8", "score": "0.66719866", "text": "function openModal2() {\n document.getElementById(\"fpModal\").style.display = \"block\";\n}", "title": "" }, { "docid": "6ca9c2b3899c9a69a426466235a61d81", "score": "0.66673076", "text": "function ChangeDisplayValue(element, value){\n element.style.display = value;\n}", "title": "" }, { "docid": "8945b9163855d124bd7bf61da30ee261", "score": "0.66641736", "text": "function showModal() {\n const timeLapse = (getTimestamp() - timeStart) / 1000;\n const starsStimation = (3 * (stimateRating() / 100)).toFixed(1);\n resultsSlctr.innerText = `With ${moves} moves and ${starsStimation} stars in ${timeLapse.toFixed(1)}s!`;\n modalSlctr.style.display = \"block\";\n }", "title": "" }, { "docid": "4b1e0b9c8d2f561bcde8d11667a24d6f", "score": "0.66594243", "text": "function handleShow() {\n setShowModal(true);\n }", "title": "" }, { "docid": "1f4874fbcaef0e385bc364cc1bd9ebf4", "score": "0.66570663", "text": "function fnOpenModal(){\n\t$(\"#modal\").css(\"display\", \"flex\");\n}", "title": "" }, { "docid": "887d8f2276c8a311375d3cc96ccc05de", "score": "0.6656734", "text": "function showModal(){\n getById('modalWindow').className = \"visible\";\n}", "title": "" }, { "docid": "1ebe08ebad597920fd0a44132b6d994c", "score": "0.665356", "text": "function clkgucci() {\n document.getElementById('modalgucci').style.display = \"block\";\n }", "title": "" }, { "docid": "cc8a1f8ff010bacec330fcea1614cea7", "score": "0.66500014", "text": "function openOptionsModal(btnOption) {\n modalOptions.style.display = \"block\";\n}", "title": "" }, { "docid": "d2a43347cdd8501eb63f4966c1c913d0", "score": "0.6649598", "text": "function openModal(which) {\n document.getElementById(\"myModal\" + which).style.display = \"block\";\n }", "title": "" }, { "docid": "1fd271adebd76447f81c09da144cf8ee", "score": "0.66461533", "text": "function displayInsertName(){\n var channelName = document.getElementById(\"channelModal\");\n channelName.style.display = \"block\";\n}", "title": "" }, { "docid": "f9827ec0f8fef1e17f31968ae68353dd", "score": "0.6644865", "text": "show() {\n if (this.isVisible_) {\n return;\n }\n\n this.modalManager_.showModal(this.modalId_);\n this.isVisible_ = true;\n }", "title": "" }, { "docid": "72684c9de7c18e3484307682b0076ca1", "score": "0.6644679", "text": "function LGopenModal(){\r\n\tLGmodal.style.display = 'block';\r\n}", "title": "" }, { "docid": "4b271c50a6764dfcecb62f2bc6880975", "score": "0.6640534", "text": "function openModal() {\r\n document.getElementById(\"myModal\").style.display = \"block\";\r\n }", "title": "" }, { "docid": "f9cb8dca18be7ac1caf6ebbadeaf3bd7", "score": "0.6638944", "text": "function showModal(itemId) {\n document.getElementById(itemId).style.display=\"block\";\n}", "title": "" }, { "docid": "9b0027fc16bc2558845aff7fa672a42e", "score": "0.66388273", "text": "function showModal() {\n document.querySelector('.dialog-overlay').style.display = 'block';\n}", "title": "" }, { "docid": "64c93c9facfb1bf19ea98a56430ce5bc", "score": "0.6638649", "text": "function cl(){\n modalF.style.display = \"none\";\n modalP.style.display = \"none\";\n modalE.style.display = \"none\";\n\n}", "title": "" }, { "docid": "30959725f6dffcd27769374738090bf0", "score": "0.66296214", "text": "static show() {\n let element = document.querySelector('#modal-full');\n UIkit.modal(element).show();\n }", "title": "" }, { "docid": "348060c549b7f2f86bd38359dedd112d", "score": "0.66235006", "text": "function opentokyoModal() {\n\ttokyoModal.style.display= 'block';\n}", "title": "" }, { "docid": "9a31021419f755de7174825bfdef8fa2", "score": "0.6616265", "text": "function openModal() {\n document.getElementById(\"myModal\").style.display = \"block\";\n}", "title": "" }, { "docid": "4a0de2ca95e72c93b9df14afacf387f9", "score": "0.661297", "text": "function openModal7() {\n document.getElementById('myModal7').style.display = \"block\";\n}", "title": "" }, { "docid": "882d03e90522e1af180571d2ce3eed86", "score": "0.6609738", "text": "function showInformationModal() {\n /*New style of getting to change the 'hidden' attribute*/\n RemoveHiddenAccess[0].style['display'] = 'block';\n RemoveHiddenAccess[1].style['display'] = 'block';\n \n /*Call hide when close or cancel are clicked*/\n ModalCloseButton[0].addEventListener('click',hideInformationModal);\n ModalCancelButton[0].addEventListener('click',hideInformationModal);\n}", "title": "" }, { "docid": "b4ee990664435d62a4040bc5ffae925a", "score": "0.6604105", "text": "function openModal3() {\n modal3.style.display = \"block\";\n }", "title": "" }, { "docid": "5311e86daf44554f0287a7521f2091df", "score": "0.6599691", "text": "function openModal() {\n document.getElementById('myModal').style.display = \"block\";\n}", "title": "" } ]
6941b06df231866f5bb852166bca0e79
When a different account is selcted Also handle new account creation
[ { "docid": "85e3a59aa9432e56db24a8648042a5ff", "score": "0.6835202", "text": "handleAccountSelect(option) {\n this.deselectSelectedItem();\n if (option === 'create-new') {\n if (this.state.backendAddress !== null) {\n // Create new account\n var newName = prompt(\"New account name\");\n // Remove whitespace from beginning and end of input\n if (newName !== null) {\n newName = newName.trim();\n if (newName !== null && newName !== \"\") {\n // Create account then switch to that new account - if a duplicate name is entered, enter that account\n createAccount(newName, this.state.backendAddress, function() {\n // Update list of users\n listUsers(this.state.backendAddress, (users) => {\n this.setState({'users': users});\n this.accountSelectorRef.current.value = newName;\n // Get new user's content - usually empty unless duplicate name used\n getUserContent(newName, this.state.backendAddress, function(content){\n this.setState(\n {\n 'username': newName,\n 'content': this.formatContent(content)\n }\n );\n }.bind(this));\n })\n }.bind(this));\n }\n }\n }\n } else if (option === '') {\n // None selected\n this.setState({\n 'username': null,\n 'content': []\n });\n } else {\n // Default - switch to an existing user\n var username = option;\n getUserContent(username, this.state.backendAddress, function(content){\n this.setState(\n {\n 'username': username,\n 'content': this.formatContent(content)\n }\n );\n }.bind(this));\n }\n }", "title": "" } ]
[ { "docid": "deb4a1a0724bab040801b4d11cb12081", "score": "0.69331306", "text": "function changeAccount()\n {\n var account = $$('App.Accounts.List').getSelectedItem();\n\n if (account.getType() === 'plus') {\n Service.PageManager.switchPage(new Page.AddAccountGithub());\n } else {\n Service.PageManager.switchPage(new Page.AccountDetailsRepositories(account));\n }\n }", "title": "" }, { "docid": "018428442dfe72b2f49fbe275ac6bc1d", "score": "0.65300846", "text": "handleAccountChange(event) {\n this.accId = event.detail.value[0];\n console.log(\"Selected account Id: \" + this.accId);\n }", "title": "" }, { "docid": "63c50a400eb653e8c01211135bb8ac86", "score": "0.644349", "text": "setActiveAccount(state, activeAccount){\r\n state.activeAccount = activeAccount\r\n }", "title": "" }, { "docid": "e1a1c88e03b01aefa5ef4cf92bc825a6", "score": "0.62945694", "text": "function newAccount(){\r\n client.getAccounts({}, function(err, accounts) {\r\n if(accounts.length<=0){client.createAccount({'name': 'New Wallet'}, function(err, acct) {\r\n console.log(acct.name + ': ' + acct.balance.amount + ' ' + acct.balance.currency);\r\n});}\r\n\r\n });\r\n}", "title": "" }, { "docid": "10f93da5a953d0b299145350cf31e992", "score": "0.62781096", "text": "function doCreateAcctBtnClicked() {\n\tif ($.acct_password.value !== $.acct_password_confirmation.value) {\n\t\talert(\"Please re-enter information\");\n\t\treturn;\n\t}\n\n\tvar params = {\n\t\tfirst_name : $.acct_fname.value,\n\t\tlast_name : $.acct_lname.value,\n\t\tusername : $.acct_email.value,\n\t\temail : $.acct_email.value,\n\t\tpassword : $.acct_password.value,\n\t\tpassword_confirmation : $.acct_password_confirmation.value,\n\t};\n\n\t//we create an account model\n\tvar user = Alloy.createModel('User');\n\n\t//pass the params and also call the utility method\n\tuser.createAccount(params, userActionResponseHandler);\n}", "title": "" }, { "docid": "d1c70b276c3fab77068f4159002774a5", "score": "0.6229522", "text": "createAccount(){\n\t\tAppDispatcher.dispatch({\n\t\t\ttype: constants.CREATED_ACCOUNT,\n\t\t\tammount: 0\n\t\t});\n\t}", "title": "" }, { "docid": "d5a47f36212f0368d19291c7ff11bd97", "score": "0.6217891", "text": "processSelectedAccountsForCreation(event){ \n let table = this.template.querySelector('lightning-datatable');\n let rows = table.getSelectedRows();\n let stringifedRows = JSON.stringify(rows);\n this.selectedAccountRecords = [...JSON.parse(stringifedRows)];\n this.selectedAccountRecords.forEach(rec => this.createAccounts(rec));\n }", "title": "" }, { "docid": "d694b9bab620648111356251ee09fcc3", "score": "0.61210525", "text": "function createAccountMenu() {\n\tconsole.log(view.separateLine);\n\t// Ask for user's name, no validation\n\tuserInteract.question(view.customerName, (nameInput) => {\n\t\t// Ask for initial deposit amount\n\t\tuserInteract.question(view.initDeposit, (moneyInput) => {\n\t\t\t// Check that initial deposit is a valid number\n\t\t\tif(validateNumberInput(moneyInput)) {\n\t\t\t\t// Ask for account PIN\n\t\t\t\tuserInteract.question(view.enterPIN, (pinInput) => {\n\t\t\t\t\t// Check that given PIN matches criteria\n\t\t\t\t\tif (verifyPIN(pinInput)) {\n\t\t\t\t\t\t// Ask to verify PIN\n\t\t\t\t\t\tuserInteract.question(view.verifyPIN, (pinInputVerify) => {\n\t\t\t\t\t\t\t// Check that first and second PINs match\n\t\t\t\t\t\t\tif (pinInput == pinInputVerify) {\n\t\t\t\t\t\t\t\t// Create account\n\t\t\t\t\t\t\t\tvar currentAccount = createAccount(nameInput, pinInput, parseFloat(moneyInput));\n\t\t\t\t\t\t\t\tconsole.log(view.accountSuccess);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Display error for mismatched PIN inputs\n\t\t\t\t\t\t\t\tconsole.log(view.errorNotMatchingPIN);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Return to initial menu\n\t\t\t\t\t\t\tinitialMenu();\n\t\t\t\t\t\t})\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Display error for invalid PIN and return to initial menu\n\t\t\t\t\t\tconsole.log(view.errorInvalidPIN);\n\t\t\t\t\t\tinitialMenu();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\t// Display error for invalid number and return to initial menu\n\t\t\t\tconsole.log(view.errorNumber);\n\t\t\t\tinitialMenu();\n\t\t\t}\n\t\t})\n })\n}", "title": "" }, { "docid": "a5d75a5fa968c33630256a42247f896e", "score": "0.61059195", "text": "clickCreateNewAccountSelectOption() {\n\t\treturn this.createNewAccountSelectOption.click();\n\t}", "title": "" }, { "docid": "a56ab2283a03caebd9c3947f4236b873", "score": "0.60569715", "text": "function handleAccountsChanged(accounts) {\n let connectButton = document.getElementById('connectButton');\n if (accounts.length === 0) {\n // MetaMask is locked or the user has not connected any accounts\n //window.location.reload();\n console.log('Please connect to MetaMask.');\n connectButton.style.display = \"block\";\n message('Please connect to MetaMask.', \"is-warning\");\n } else if (accounts[0] !== currentAccount) {\n currentAccount = accounts[0].toLowerCase();\n console.log('currentAccount', currentAccount);\n connectButton.style.display = \"none\";\n message('Current Account: ' + currentAccount, \"is-success\");\n // Do any other work!\n }\n //window.location.reload();\n}", "title": "" }, { "docid": "8ba6ee1c283855d92da53af2fb85c558", "score": "0.60451365", "text": "function createNewAccount()\r\n{\r\n // check that the confirmation checkbox is checked\r\n if (!$('#confirmsave')\r\n .is(':checked'))\r\n {\r\n Materialize.toast('Please confirm that you have saved the secret key!', 5000, 'red');\r\n return false;\r\n }\r\n\r\n // check if \"link email\" checkbox is checked\r\n if ($('#linkemail')\r\n .is(':checked'))\r\n {\r\n $.get(\"https://xlmwallet.co/api/federation\",\r\n {\r\n q: email + \":\" + fresh_public_key + \":\" + emailsecret,\r\n type: \"linkEmail\"\r\n })\r\n .done(function(data)\r\n {\r\n Materialize.toast(data.detail, 5000, 'green');\r\n })\r\n .fail(function(err)\r\n {\r\n Materialize.toast('Error: ' + err.responseJSON.detail, 5000, 'red');\r\n });\r\n }\r\n\r\n showLoadingWindow(true);\r\n\r\n // finally merge account\r\n createAccount(fresh_public_key)\r\n .then(function()\r\n {\r\n $('.claim')\r\n .attr('disabled', '')\r\n .removeClass('blue')\r\n .addClass('green')\r\n .html('CLAIMED!');\r\n $('#newAccountModal .buttons')\r\n .append('<br/><a href=\"my\" class=\"btn btn-large btn-green z-depth-3 margin-U\">TO THE WALLET</a>');\r\n\r\n });\r\n}", "title": "" }, { "docid": "02184f1b04eb1c325c21a5a6a27113e2", "score": "0.6005735", "text": "function isUserCreatedAccount() {\n\t$('#sign-in').submit(function(){\n\t\tcreateUser();\n\t\tisUserConnected();\n\t\treturn false;\n\t});\n}", "title": "" }, { "docid": "a412f8fcf2d5622033a2e13d1231420b", "score": "0.5999706", "text": "function onGetAccount(account) {\n if (!account.sub || !account.picture || !account.name) return;\n\n const data = {\n sub_line_id: account.sub,\n img: account.picture,\n name: account.name,\n email: account.email,\n };\n Login(data);\n }", "title": "" }, { "docid": "9f1649dc44063e11740f8e812bd60f2d", "score": "0.5885518", "text": "function append_new_account(sp, user_account_name, trigger) {\n let i = $('.accselect').length;\n let append = '<div id=\"accselect'+i+'\" class=\"accselect\" data-spname=\"' + sp + '\" data-accountname=\"'+user_account_name+'\" onclick=\"changeacc(this)\"><span class=\"nav-group-item\" ><span class=\"icon icon-mail\"></span>'+user_account_name+'</span></div>';\n $('nav#left-nav').append(append);\n trigger && $('div#accselect'+i).trigger(\"click\");\n}", "title": "" }, { "docid": "240584161532943b0f1af75c918bdfd9", "score": "0.58816534", "text": "function haveAccount (){\n \n prompt(\"Have account?\",Yes, No){\n //do you have an account?\n if Yes /*True?*/ AcctHolder()\n //create new account\n } else No /*false??*/newUser(){\n\n };\n }", "title": "" }, { "docid": "7f723dffed0c6c282e0275a490ced1c7", "score": "0.58463234", "text": "function handleChangeHasAccount(event) {\n // event.preventDefault();\n setHasAccount(event.target.checked);\n }", "title": "" }, { "docid": "1e3d0c5d3dde7b028f82d0c257111a15", "score": "0.5845259", "text": "submitAddAccount(accountName) {\n\t\t//create new and unique (hopefully) id for the account\n\t\tconst min = 2;\n\t\tconst max = 500;\n\t\tconst id = Math.trunc(Math.random() * (+max - +min) + +min);\n\t\t\n\t\t//add account to DB\n\t\tDatabaseUtil.addAccountToDatabase(accountName, id.toString(10));\n\t\tconsole.log(id);\n\t\t//close the modal\n\t\tthis.setState({\n\t\t\tshowAccountModal: false,\n\t\t});\n\t}", "title": "" }, { "docid": "5005b32cbf231f9e494d3fef9b16efbf", "score": "0.5832463", "text": "function getSelectedAccount() {\n let account = $(\"#txorigin\").find(\"option:selected\").val()\n return account\n}", "title": "" }, { "docid": "0a5af50c57e82c2184da7f0d594f1845", "score": "0.581761", "text": "function ec_create_recordtype_dialog(qItem) {\n var dialog = $('#ec_dialog_recordtype');\n $('#lookupRecordTypesContainer').html('');\n \n $('#lookupRecordTypesContainer').html(can.view('ec_tpl_lookupRecordTypes', { recordTypes: ec_recordTypes.Account }));\n \n \t$('#acctCreateBtn').attr('disabled','true');\n //createNewAccount\n $('#acctNameInput').keyup(function() {\n if($('#acctNameInput').val().length > 0){\n $('#acctCreateBtn').removeAttr('disabled');\n $('#acctCreateBtn').removeClass('disabled');\n }\n else{\n \n $('#acctCreateBtn').addClass('disabled');\n $('#acctCreateBtn').attr('disabled','true');\n\n }\n\t});\n\n \n if (typeof ec_recordTypesDefault['Account'] != 'undefined') {\n $('#lookupRecordTypes').val(ec_recordTypesDefault['Account']);\n }\n dialog.find('.btn-continue-recordtype').off('click');\n dialog.find('.btn-continue-recordtype')\n // bind the click action to it to perform the search\n .click(function (e) {\n $('#recordTypeSearch').hide();\n $('#acctNameInput').val('');\n $('#acctNameInputArea').show();\n \n //recordTypeId = $('#lookupRecordTypes').val();\n //dialog.modal('hide');\n //createNewAccount(qItem, recordTypeId);\n });\n dialog.find('.btn-continue-acctCreate').off('click');\n dialog.find('.btn-continue-acctCreate')\n // bind the click action to it to create account\n .click(function (e) {\n recordTypeId = $('#lookupRecordTypes').val();\n $('#recordTypeSearch').hide();\n $('#acctNameInputArea').show();\n dialog.modal('hide');\n\t\tvar nAcctId = auto_createNewAccount(qItem, recordTypeId, $('#acctNameInput').val());\n if(nAcctId[0].id != null && nAcctId[0].id != ''){\n \tqItem.find('.ec_lookup_field[name=\"AccountId\"]').val($('#acctNameInput').val());\n \tqItem.find('.ec_lookup_field_val[name=\"AccountId\"]').val(nAcctId[0].id);\n \n }\n //dialog.modal('show');\n //createNewAccount(qItem, recordTypeId);\n });\n \n // open dialog or go straight to new account\n if (typeof ec_recordTypesDefault['Account'] == 'undefined') {\n //createNewAccount(qItem, '');\n dialog.modal('show');\n recordTypeId='';\n $('#recordTypeSearch').hide();\n $('#acctNameInput').val('');\n $('#acctNameInputArea').show();\n }\n else {\n dialog.modal('show');\n $('#recordTypeSearch').show();\n $('#acctNameInputArea').hide();\n }\n}", "title": "" }, { "docid": "5af8c01fc67b8e6642674ba23c60e52d", "score": "0.5784914", "text": "async updateSelectedAccount() {\n const updateAccount = await this.state.web3.eth.getAccounts();\n this.setState({ account: updateAccount[0] });\n }", "title": "" }, { "docid": "a48963fc1a39c2dbbc08867af192f88d", "score": "0.5779298", "text": "function createAccount() {\r\n\t//Get entered data\r\n\tlet enteredUser = document.getElementById(\"signup_user\").value;\r\n\tlet enteredPass = document.getElementById(\"signup_password\").value;\r\n\t\r\n\t//Loop through all users and check if this user exists or not?\r\n\tlet existing = false;\r\n\tfor (var i=0; i < allAccounts.length; i++) {\r\n\t\tif (enteredUser == allAccounts[i].user) {\r\n\t\t\talert(\"SORRY! THIS USER ALREADY EXIST!\");\t\t\t\r\n\t\t\texisting = true;\r\n\t\t\tbreak;//quit\r\n\t\t} \r\n\t}\r\n\t//Until the en, no existing user\r\n\tif (existing == false) {\r\n\t\t//Add a new user by appending it to the array\r\n\t\tallAccounts.push({user: enteredUser, pass: enteredPass});\t\r\n\t\talert(\"CONGRATS! YOUR ACCOUNT IS CREATED\");\t\t\r\n\t}\t\r\n\tdocument.getElementById(\"signup_user\").value='';\r\n\tdocument.getElementById(\"signup_password\").value='';\r\n}", "title": "" }, { "docid": "249278ce06855f5b734531bb3e760ef9", "score": "0.57788056", "text": "onProceedButtonPressed() {\n const oldThis = this;\n if (this.state.creatingNewAccount) {\n UserManager.getInstance().createUser(this.state.emailField, \n this.state.emailField.split('@')[0], this.state.passwordField)\n \n .then(_ => {\n // At this point, UserManager has guaranteed successful account creation\n oldThis.attemptLogin();\n })\n .catch(error => {\n alert(\"Your email is already being used, please use another.\");\n });\n \n } else {\n this.attemptLogin();\n }\n }", "title": "" }, { "docid": "6ed8da119e5c552b99654406017976fb", "score": "0.57727194", "text": "function createAccount()\n{\n\t$.ajax({\n\t\ttype: 'POST',\t\n\t\turl: 'ajax/createAccount.php',\n\t\tdata: {\n\t\t\temail: $(\"#newEmail\").val(),\n\t\t\tdisplayName: $(\"#newDisplayName\").val(),\n\t\t\tpassword: $(\"#newPassword\").val(),\n\t\t},\n\t\tsuccess: function(data) {\n\n\t\t\tif(data.substring(0,5) == \"Error\")\n\t\t\t{\n\t\t\t\tmyAlert(data);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t$(\"#accountEditor\").dialog(\"close\");\n\t\t\tgetAllAccounts();\n\t\t},\n\t\terror: function() {\n\t\t\tmyAlert(\"There was an error creating the account. Please refresh the page and try again\");\n\t\t},\n\t});\n}", "title": "" }, { "docid": "d56773c5a90ab5767168f3f62d6c7da3", "score": "0.5751674", "text": "function handleAccountsChanged(accounts, cb = false) {\n console.log('handled accounts');\n //console.log(cb);\n if (accounts.length === 0) {\n // MetaMask is locked or the user has not connected any accounts\n showToast(`Please connect to MetaMask!`, \"alert\");\n } else {\n\n if(currentAccount != accounts[0]) {\n currentAccount = accounts[0];\n showToast(`${accounts[0]} is now the active address`);\n\n if(currentpage === \"wallet\" && contractsInitialized) {\n loadWallet();\n return;\n }\n }\n\n\n // Do any other work!\n\n if(cb) {\n cb();\n }\n }\n}", "title": "" }, { "docid": "d8dcf6dd2de51dba7e6f7f5042edce22", "score": "0.5738202", "text": "createAccount(accountName, currentBalance) {\n let newAccount = new Account(accountName, currentBalance);\n // this.allAccounts.push(newAccount);\n this.allAccounts = [...this.allAccounts, newAccount];\n }", "title": "" }, { "docid": "01bca2abfd26f989815c2249b0c171ce", "score": "0.5729464", "text": "function handleSelectTransType(e) {\n\t\t\tremoveEventListenerToCombobox(handleSelectTransType, handleCloseTransTypeCbx);\n\t\t\tif(e.selectedValue2 == \"T19\"){\n\t\t\t\tgTrans.idtxn = e.selectedValue2;\n\t\t\t\tdocument.getElementById(\"id-trans-local\").value = e.selectedValue1;\n\t\t\t}\n\t\t\tif(e.selectedValue2 == \"T21\"){\n navCachedPages['transfer/account/transfer-account-create-scr'] = null;\n navArrayScr.pop();\n clearCachedPageToView('transfer/account/transfer-account-create-scr', true, 'html');\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "b3edb31c4f08c1b3d7572ae9e34b0326", "score": "0.57126236", "text": "function createAccount() {\n\n var passwordCheck = false;\n // get info filled out from Create Account\n var firstName = document.getElementById(\"firstName\").value;\n var lastName = document.getElementById(\"lastName\").value;\n var selector = document.getElementById(\"selector\");\n var question = selector.options[selector.selectedIndex].value;\n var answer = document.getElementById(\"answer\").value;\n var email1 = document.getElementById(\"email\").value;\n var password1 = document.getElementById(\"password1\").value;\n var password2 = document.getElementById(\"password2\").value;\n var weight = document.getElementById(\"weight\").value;\n var age = document.getElementById(\"age\").value;\n var conditions = document.getElementById(\"conditions\").value;\n\n if (firstName == \"\")\n {\n alert(\"Please enter your first name.\");\n return false;\n }\n if (lastName == \"\")\n {\n alert(\"Please enter your last name.\");\n return false;\n }\n if (question == \"\")\n {\n alert(\"Please select a security quesiton.\");\n return false;\n }\n if (answer == \"\")\n {\n alert(\"Please choose an answer to your security question.\");\n return false;\n }\n \n if (email1 == \"\") {\n alert(\"Please enter a valid email.\");\n return false;\n }\n if (password1 == \"\")\n {\n alert(\"Please choose a password.\");\n return false;\n }\n if (age == \"\")\n {\n alert(\"Please choose a age.\");\n return false;\n }\n if (weight == \"\")\n {\n alert(\"Please choose a weight.\");\n return false;\n }\n\n // Check if passwords match\n if (password1 != password2)\n {\n //passwordCheck = true;\n alert(\"Passwords do not match.\");\n return false;\n }\n passwordCheck = true;\n \n \n if (passwordCheck == true) {\n var uid = email1.substr(0, email1.indexOf('@'));\n var ref = new Firebase(\"https://group10app.firebaseio.com\");\n var account = new User(firstName,lastName,age,question,answer,email1,password1,weight,conditions);\n ref.child(\"users\").child(uid).set(account);\n ref.child('currentUser').set(uid);\n ref.on(\"value\", function(snapshot) {\n var data = snapshot.val();\n var id = data.currentUser;\n if(id === uid){\n window.location = \"PatientMenu.html\";\n }\n });\n }\n}", "title": "" }, { "docid": "66bb93d8b9b676f03781a16c2370c7c7", "score": "0.569328", "text": "showAddAccount_() {\n this.switchToScreen_(\n navigator.onLine ? Screens.ONLINE_FLOW : Screens.OFFLINE);\n }", "title": "" }, { "docid": "7a8cca4c43313e010bfc1b0f94223f06", "score": "0.5686874", "text": "async updateAccount(){\n const accounts = await web3.eth.getAccounts();\n const account = accounts[0];\n this.currentAccount = account;\n }", "title": "" }, { "docid": "7682496dbc96f9a52d29d8f8f72608a8", "score": "0.5669623", "text": "handleCreateAccClick() {\r\n this.setState({\r\n showCreateAccount: true\r\n });\r\n }", "title": "" }, { "docid": "9baa4d178d0fbd4a538ea64da50fa605", "score": "0.56659865", "text": "function changeSepaAccountType(event, accType)\n{\n var currentAccType = event.target.id;\n $('.' + currentAccType).hide();\n $('.' + accType).show();\n if (accType == 'novalnet_sepa_new_acc') {\n\t\t$('#novalnet_sepa_disclosure_confirm').css('display', 'block');\n $('#novalnet_sepa_new_details').val(1);\n } else {\n $('#novalnet_sepa_new_details').val(0);\n $('#novalnet_sepa_disclosure_confirm').css('display', 'none');\n\t}\n}", "title": "" }, { "docid": "83594902f2b4eda72e9c014b05d68e8b", "score": "0.5660269", "text": "function activateAccount() {\n\n REQUESTS.activateAcct(Q_STRING, () => { showSuccess() }, err => {\n\n if (err.status === 410) {\n showFailed(...EXPIRED);\n } else if (err.status === 403) {\n showSuccess(); // show success because 403 means user is already activated\n } else {\n showFailed(...INVALID);\n }\n\n });\n}", "title": "" }, { "docid": "ca40d58032067fe2b73ab07fc5100f43", "score": "0.56352335", "text": "function profileClick(accountID) {\n $(\"#profile-new\").click(function (event) {\n window.location.href = \"/gwa/pages/profile.html?accountID=\" + accountID;\n })\n }", "title": "" }, { "docid": "4d774fed274b6f721a8de4e0727cea5a", "score": "0.56149334", "text": "function createAccount (account) {\r\n\taccounts.push(account);\r\n\treturn account;\r\n}", "title": "" }, { "docid": "8fcb4555e75f5d25d9196276b02a1805", "score": "0.5600643", "text": "function customerArrived(){\n\t\tconsole.log('Welcome to ATM: ' + location)\n\n\t\trl.question('Enter your account number or type \"new\" to create a new account: ', (response) => {\n\t\t\t//Creates a new account\n\t\t\tif(response === 'new'){\n\t\t\t\tcreateAccount(this);\n\t\t\t} \n\t\t\telse if(response===''){\n\t\t\t\tthis.anotherTransaction();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst accountFound = findAccount(response);\n\t\t\t\tif(accountFound){\n\t\t\t\t\tthis.verifyPIN(accountFound);\n\t\t\t\t} else {\n\t\t\t\t\tconsole.log('Account \"' + response + '\" not found');\n\t\t\t\t\tthis.anotherTransaction();\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t})\n\t}", "title": "" }, { "docid": "5793a81a65fe8a2a371b05d121f1d7de", "score": "0.55988216", "text": "function saveAccount(account)\n {\n var type = localStorage.getItem(\"acc_type\");\n var onSuccess = function()\n {\n alert(\"Account updated\");\n console.log(\"Account updated\");\n LoadProfilePage(type);\n };\n var onFailure = function()\n {\n console.log(\"Account save error\");\n };\n if (type == \"I\")\n {\n makePostRequest(\"/api/editaccount/instructor/\" + account.id,account,onSuccess,onFailure);\n } else\n {\n makePostRequest(\"/api/editaccount/student/\" + account.id,account,onSuccess,onFailure);\n } \n }", "title": "" }, { "docid": "8dae232f8e5d21502480677192434040", "score": "0.5592408", "text": "function makeNewWalletForm() {\n common.hideDiv(document.getElementById('statusDiv'));\n common.hideDiv(document.getElementById('statusContentDiv'));\n var newWalletAccountsListDiv = document.getElementById('newWalletAccountsListDiv');\n listAccounts(newWalletAcctList, newWalletLabelList, newWalletAccountsListDiv);\n // set up threshold selector and init new account addr\n var thresholdSelector = document.getElementById(\"thresholdSelector\");\n var addAccountAddrInput = document.getElementById('addAccountAddrInput');\n var addAccountLabelInput = document.getElementById('addAccountLabelInput');\n common.clearDivChildren(thresholdSelector);\n if (newWalletAcctList.length == 0) {\n\tvar option = document.createElement(\"option\");\n\toption.text = 'Select Threshold';\n\toption.value = '0';\n\tthresholdSelector.appendChild(option);\n\t//no accounts defined, so set default acct to currently active metamask acct\n\taddAccountAddrInput.value = common.web3.eth.accounts[0];\n\taddAccountLabelInput.value = 'My Account';\n } else {\n\tfor (var i = 1; i <= newWalletAcctList.length; ++i) {\n\t var option = document.createElement(\"option\");\n\t option.text = 'Threshold ' + i.toString(10);\n\t option.value = i.toString(10);\n\t thresholdSelector.appendChild(option);\n\t}\n\t//after first account, ensure no artifacts of default acct in input field\n\taddAccountAddrInput.value = '';\n\taddAccountLabelInput.value = '';\n }\n // we can be called multiple times. so ensure we don't add multiple handlers\n var addAccountButton = document.getElementById('addAccountButton');\n addAccountButton.removeEventListener('click', newWalletAddAccountHandler);\n addAccountButton.addEventListener('click', newWalletAddAccountHandler);\n //\n var deployNewWalletButton = document.getElementById('deployNewWalletButton');\n deployNewWalletButton.disabled = (newWalletAcctList.length > 0) ? false : true;\n if (!deployNewWalletButton.disabled) {\n\tdeployNewWalletButton.removeEventListener('click', newWalletDeployHandler);\n\tdeployNewWalletButton.addEventListener('click', newWalletDeployHandler);\n }\n}", "title": "" }, { "docid": "492ea355b380f2a5d4b74a61753300e0", "score": "0.5580556", "text": "function createAccount(account){\n\taccounts.push(account);\n\treturn account;\n}", "title": "" }, { "docid": "0c12e61911f945432482a01dca77b421", "score": "0.5578908", "text": "function on_create_sap_account() {\r\n scrolltotop();\r\n var redirect = encodeURIComponent(_registration_url);\r\n var httpBridge = get_bridge_or_warning_url(_http_bridge_url);\r\n var sep = get_separator(httpBridge);\r\n var url = httpBridge + sep + 'action=registrationLayer&refresh=false&redirect=' + redirect + '&dialog=' + _registration_dialog;\r\n window.location.href = url;\r\n}", "title": "" }, { "docid": "e3f2f4862accde243254ce6038210193", "score": "0.55763674", "text": "createUpdateAccount(account) {\n this.$uibModal.open({\n template: require('../modals/createUpdateAccount.html'),\n controller: AccountModalCtrl,\n controllerAs: '$ctrl',\n windowClass: 'site-modal',\n backdrop: 'static',\n resolve: {\n account: () => account ? angular.copy(account) : {},\n enterprise: () => this.accountInfo.id\n }\n }).result.then(user => {\n if(!account) {\n this.accounts.push(user);\n } else {\n this.accounts[_.findIndex(this.accounts, {id: user.id})] = user;\n }\n }, _.noop);\n }", "title": "" }, { "docid": "39caa91ee9762738b7fd44365156acd0", "score": "0.5572463", "text": "function accountCreate() {\n\t\n\t// Selection choice for php to handle\n\tvar selected = \"accountCreate\";\n\n\t// Pulling user information from the site\n\tvar username = document.getElementById('Username').value;\n\tvar password = document.getElementById('Password').value;\n\tvar email = document.getElementById('Email').value;\n\tvar confirmPass = document.getElementById('ConfirmPass').value;\n\n\t// Simple password checking to make sure passwords are equal\n\tif (password != confirmPass) {\n\t\tdocument.getElementById('output').innerHTML = \"Passwords do not match!\";\n\t}\n\n\telse {\n\t\t// New request to send user information for account creation\n\t\tvar createAccountRequest = new XMLHttpRequest();\n\t\tcreateAccountRequest.onreadystatechange = function() {\n\t\t\tif (this.readyState == 4 && this.status == 200){\n\t\t\t\tdocument.getElementById('output').innerHTML = this.responseText;\n\t\t\t}\n\t\t};\n\n\t\t// Sending request for account creation\n\t\tcreateAccountRequest.open(\"GET\", \"../PHP/user.php?selected=\"+selected+\"&username=\"+username+\"&password=\"+password+\"&confirmPass=\"+confirmPass+\"&email=\"+email, true);\n\t\tcreateAccountRequest.send();\n\n\t\t// Interval function to check for successful account\n\t\tsetInterval(function() {\n\n\t\t// If it succeeds then redirect to login\n\t\tif (createAccountRequest.responseText === \"Account Created! Redirecting you to login! If not redirected automatically, <a href = login.html>click here</a>\") {\n\t\t\tsetTimeout(function() {\n\t\t\t\twindow.location.assign(\"Login.html\");\n\t\t\t}, 2000);\n\n\t\t}\n\t\t}, 50);\n\t}\n}", "title": "" }, { "docid": "c4e2bc1d045bb87ef2de2ac83ca52d99", "score": "0.5570377", "text": "function doCreateAccount(){\n var username = YAHOO.lang.trim(YAHOO.util.Dom.get('new_username').value);\n var password = YAHOO.lang.trim(YAHOO.util.Dom.get('new_password').value);\n var confirmPassword = YAHOO.lang.trim(YAHOO.util.Dom.get('confirm_password').value);\n \n //Validation checks\n var usernameCheck = validateUsername(username);\n var passwordCheck = validatePassword(password);\n if (usernameCheck !== '') {\n YAHOO.util.Dom.get('newAccountMessage').innerHTML = usernameCheck;\n return false;\n }\n else \n if (usernameExists(username) === true) {\n YAHOO.util.Dom.get('newAccountMessage').innerHTML = \"Username already in use! Please try another.\";\n return false;\n }\n else \n if (passwordCheck !== '') {\n YAHOO.util.Dom.get('newAccountMessage').innerHTML = passwordCheck;\n return false;\n }\n else \n if (password !== confirmPassword) {\n YAHOO.util.Dom.get('newAccountMessage').innerHTML = \"Passwords do not match! Please try again.\";\n return false;\n }\n \n var newUserResult = addNewUser(username, password);\n if (newUserResult) {\n\t\t//Cleanup the fields so they are not present on signout/create during the initial session\n\t\tYAHOO.util.Dom.get('new_username').value = '';\n\t\tYAHOO.util.Dom.get('new_password').value = '';\n\t\tYAHOO.util.Dom.get('confirm_password').value = '';\n\t\t\n\t YAHOO.util.Dom.get('loginMessage').innerHTML = 'Account created successfully! Please login.';\n\t\tYAHOO.util.Dom.setStyle('registration-form', 'display', 'none');\n\t\tYAHOO.util.Dom.setStyle('login-form', 'display', 'block');\n }\n else {\n alert('Unable to create new user. Please try again!');\n return false;\n }\n}", "title": "" }, { "docid": "339f3772c6da3fa13bc36f18fb38363f", "score": "0.5566715", "text": "onToggleCreateNewAccount() {\n this.setState({ creatingNewAccount: !this.state.creatingNewAccount });\n }", "title": "" }, { "docid": "0b6914c7840e91f0fbee04097f25badb", "score": "0.5553526", "text": "function CreateAccountFunction(e) {\n // what will run when you create an account...\n e.preventDefault();\n const email = e.currentTarget.createEmail.value; // .createEmail is the name of the input, SEE CreateAccountForm htmlFor='createEmail'\n const password = e.currentTarget.createPassword.value; // SEE CreateAccountForm name='createPassword'\n // password variable will take data from the input that I set 'createPassword' with name='createPassword'\n\n firebase\n .auth()\n .createUserWithEmailAndPassword(email, password)\n .then(function (response) {\n setLoggedIn(true);\n })\n .catch(function (error) {\n console.warn(\"ACCOUNT CREATION FAILED\", error);\n });\n }", "title": "" }, { "docid": "e4782fa2ffa7174e19f92fe64f8a0e36", "score": "0.5539466", "text": "get createAccountURL() {return 'http://automationpractice.com/index.php?controller=authentication&back=my-account#account-creation'}", "title": "" }, { "docid": "19a743b8a78cce83f500a449308b4b97", "score": "0.5537069", "text": "function newAccount () {\n let pin = parseInt(document.getElementById(\"newPinput\").value);\n let account = {\n \"pin\": pin,\n \"balance\": 0\n };\n for(let i=0; i < bankAccounts.length; i++){\n if( bankAccounts[i].pin === pin ){\n document.getElementById(\"balance\").innerHTML = bankAccounts[i].balance;\n\n alert(\"use different pin!\");\n return;\n } \n } \n bankAccounts.push(account);\n alert('Account Created');\n displayMenu (); }", "title": "" }, { "docid": "21aca6deff3bf52cc0a99546dc8191db", "score": "0.5536355", "text": "function workOnAccount(callback) {\n var accountOperation = '';\n if ( editAccObj.get('accId') == -1 ) {\n accountOperation = 'createAccount';\n } else {\n accountOperation = 'updateAccount';\n };\n\n var accObj = {\n accountGroupId: parseInt(editAccObj.get('groupField')),\n username:editAccObj.get('usernameField'),\n firstName:editAccObj.get('firstnameField'),\n email:editAccObj.get('emailField'),\n task: accountOperation,\n is_active: (editAccObj.get('accActivField'))?1:0,\n language_iso_code:editAccObj.get('languageField'),\n lastName:editAccObj.get('lastnameField'),\n quota:editAccObj.get('quotaField'),\n budget:editAccObj.get('budgetField'),\n accountId:editAccObj.get('accId')\n };\n\n if ( editAccObj.get('passwordField') != '' ) {\n accObj.password = editAccObj.get('passwordField');\n };\n\n $.ajax({\n type: \"POST\",\n url: urlGenJSON('workOnAccount') ,\n cache: false,\n data: accObj,\n success: function (data) {\n var answerData = data + '';\n if ( answerData.search(\"ERR_USER_UNIQUE\") == '-1' ) {\n var curAccId = data.ID;\n editAccObj.set('accId', parseInt(curAccId) );\n\n getAccountList();\n shortPopupCallFunct('dialog-popup','saved-popup-tmp');\n } else {\n shortPopupCallFunct('dialog-popup','username-popup-tmp');\n };\n\n editAccObj.set('isVisible',false);\n toggleBtnStatus( $('#delete-account-button , #save-account-button') ,false);\n\n if (callback && typeof(callback) === \"function\") {\n callback();\n }\n }\n });\n}", "title": "" }, { "docid": "1c450765a258af842d0225f0fa51ce06", "score": "0.55318254", "text": "function okSelected(e) {\n tmpDestinationAcc = \"\";\n tmpDestinationAccName = \"\";\n if (currentPage == \"transfer/domestic/transfer-inter-create-scr\") {\n handleInputPayeeAccClose();\n var destinationAcc = document.getElementById(\"trans.destaccountnointer\");\n if ((e.selectedValue != undefined) && (e.selectedValue != null) && (e.selectedValue.length > 0)) {\n destinationAcc.value = e.selectedValue;\n }\n }\n}", "title": "" }, { "docid": "76686c2b5e9445a180d65137d4027c2a", "score": "0.5527487", "text": "function handleOptionChange(selection) {\n setFieldValue(props.name, selection);\n if (accountType === \"INV\") {\n setDialogValue(selection.label);\n loadBillingAddress(selection.value);\n }\n if (myValues !== undefined) handleBake(myValues, selection, props.name);\n }", "title": "" }, { "docid": "73453f3adf4d9eea47895474ee7e69f9", "score": "0.55157965", "text": "async function handleButtonCreateAccountOnClick() {\n await axios.post(SERVER_URL_USERS, {\n user: {\n full_name: signUpData.fullName,\n email: signUpData.email,\n date_of_birth: signUpData.dateOfBirth,\n country: signUpData.country,\n city: signUpData.city,\n username: signUpData.username,\n password: signUpData.password,\n password_confirmation: signUpData.passwordConfirmation\n }\n });\n }", "title": "" }, { "docid": "76bb97072d61d98c5d105a5f80214b0c", "score": "0.55031997", "text": "async useAccount(privK) {\n try {\n let account = await this.web3.eth.accounts.privateKeyToAccount(\"0x\" + privK);\n await this.web3.eth.accounts.wallet.add(account);\n this.selectedAddress = account[\"address\"];\n await this.updateAccount()\n await this.cb.call(this, \"success\")\n } catch (ex) {\n await this.cb.call(this, \"error\", String(ex))\n }\n }", "title": "" }, { "docid": "d6794ebf9b1e279b9842c96435c82982", "score": "0.5499206", "text": "handleCreateAccSuccess() {\r\n this.setState({\r\n showSuccessAlert: true,\r\n showCreateAccount: false\r\n });\r\n }", "title": "" }, { "docid": "765b8d09b31617854e55348307da816a", "score": "0.5498411", "text": "function update() {\n if (currentAccount === account) {\n wallet.emit('didChangeCurrentAccount', account.address);\n }\n }", "title": "" }, { "docid": "f158f5a576627498a00f5340090c7ff6", "score": "0.54969174", "text": "addAccount(accountId) {\n this.accounts.push(accountId);\n }", "title": "" }, { "docid": "ee886a3319562695302805ce47c3c42a", "score": "0.54922783", "text": "function markAccountActive(account) {\n method = eth.contract.methods.editAccount(account.id, account.userAddress, JSON.stringify(account.metadata), util.BYTES_ZERO);\n return eth.doSend(method, 1, 2);\n}", "title": "" }, { "docid": "45f1c7850f76682385408891a7524877", "score": "0.54905754", "text": "function createAccountHandler(){\n var newBankAcount = bankAccountInfo();\n accountInfoList.push({accountName: newBankAcount.accountName, depositAmount: newBankAcount.depositAmount});\n \n var txtArea = document.getElementById('txtarea');\n var data = \"\";\n accountInfoList.forEach(function(element){\n data += \"Account name: \"+element.accountName +\" Balance: \"+element.depositAmount+\"\\n\";\n });\n txtArea.innerHTML = data;\n }", "title": "" }, { "docid": "431507bb117af7493ac1faaf59e36272", "score": "0.54767144", "text": "function createAccount (account) {\n\taccounts.push(account);\n\treturn account;\n}", "title": "" }, { "docid": "376567bb47d81f29a4a3bae3162a51e8", "score": "0.5470098", "text": "function finishCreate() {\n var addButton, addAccountWidget;\n/* disable the add panel for now\n // Add tab button for add account\n addButton = new TabButton({\n target: 'addAccount',\n title: 'Add Account',\n name: '+'\n }, tabFragment);\n\n // Add the AddAccount UI to the DOM/tab list.\n addAccountWidget = new AddAccount({\n id: 'addAccount', owaservices: owaservices\n }, fragment);\n*/\n // add the tabs and tab contents now\n tabsDom.append(tabFragment);\n tabContentDom.append(fragment);\n\n // Get a handle on the DOM elements used for tab selection.\n tabButtonsDom = $('.widgets-TabButton');\n servicePanelsDom = $('.servicePanel');\n\n mediator.checkBase64Preview(activity.data);\n\n //If no matching accounts match the last selection clear it.\n if (lastSelectionMatch < 0 && lastSelection) {\n delete localStorage[\"last-app-selected\"];\n lastSelectionMatch = 0;\n }\n\n // which domain was last active?\n // TODO in new tabs world.\n //$(\"#accounts\").accordion({ active: lastSelectionMatch });\n tabButtonsDom.eq(lastSelectionMatch).click();\n\n //Inform extension the content size has changed, but use a delay,\n //to allow any reflow/adjustments.\n setTimeout(function () {\n mediator.sizeToContent();\n }, 100);\n }", "title": "" }, { "docid": "e7b69f99bacebc3e83ea7296dd6407ed", "score": "0.5467694", "text": "function createNewAccount(request, response){\n\tvar name = request.body.name;\n\tvar username = request.body.username;\n\tvar password = request.body.password;\n\tvar confirmPassword = request.body.confirmPassword;\n\tvar errorObj = {};\n\tgetStudentInfo(name, function(student){\n\t\tif (student.rows.length == 0){\n\t\t\terrorObj.errorMessage = \"User \" + name + \" is not in the database. Please contact a creator of this page, if there is a mistake.\"\n\t\t\terrorObj.nameError = true;\n\t\t\tresponse.render('newAccount.html', errorObj);\n\t\t}\n\t\telse if (password != confirmPassword){\n\t\t\terrorObj.errorMessage = \"The passwords do not match.\";\n\t\t\terrorObj.passwordError = true;\n\t\t\tresponse.render('newAccount.html', errorObj);\n\t\t}\n\t\telse if (name == \"\" || username == \"\" || password == \"\"|| confirmPassword == \"\"){\n\t\t\terrorObj.errorMessage = \"Please fill out all required fields.\";\n\t\t\terrorObj.emptyError = true;\n\t\t\tresponse.render('newAccount.html', errorObj);\n\t\t}\n\t\telse{\n\t\t\tconn.query(\"UPDATE student_info SET username = ?, password = ? WHERE name = ?\", [username, password, name], function(err, data){ if (err) throw err; });\n\t\t\tresponse.redirect('/');\n\t\t}\n\t});\n}", "title": "" }, { "docid": "184796d3a9820611ec5f4b7874794feb", "score": "0.5466575", "text": "static CREATE_ACCOUNT () { return new GoalCodes('create-account', 'To create an account with a service') }", "title": "" }, { "docid": "08e8cd9b683b67bbda75a3bc409d8195", "score": "0.54659843", "text": "openCreateAccountDrawer () {\n this.openSelectedDrawer(DRAWER_IDS.CREATE_ACCOUNT);\n }", "title": "" }, { "docid": "601f44a8d734c95c8a4054846c5a9b0b", "score": "0.5464877", "text": "handledropSelectedItem(accountInfo) {\n this.dragRecordId = accountInfo;\n }", "title": "" }, { "docid": "684f39de1e9424921c8fe838cbc00ab2", "score": "0.54498124", "text": "login() {\n const {email, password} = this.state;\n // get if user detail exist\n user_login({email: email, password: password}).then(response => {\n let {confirmation} = response; // new or success\n if (confirmation === 'new') {\n // alert option to create\n this.create_option();\n }\n if (confirmation === 'success') {\n // alert option to create\n let account = response.data;\n account.is_login = true;\n set_account(response.data).then(obj => {\n if (obj) {\n push('Start');\n }\n });\n }\n });\n }", "title": "" }, { "docid": "310e0c536daf61e9c9a0ad3e2a15947a", "score": "0.54490566", "text": "function accountStateCallback(response) {\n isSuccess = manageResponseStatus(response)\n //TODO: display success message or reselect the first value:\n if (isSuccess == true) {\n user = response.data.user\n lastSlt = document.querySelector(\"select[data-user='\" + user.id + \"']\")\n lastSlt.disabled = true\n }\n if (isSuccess == false) {\n if (response.data.hasOwnProperty(\"user\")) {\n user = response.data.user\n lastSlt = document.querySelector(\"select[data-user='\" + user.id + \"']\")\n lastSlt.value = user.state\n }\n }\n\n}", "title": "" }, { "docid": "8f010767a49b6e88b89cd90db895ca2a", "score": "0.54366064", "text": "setAccountType(e) {\n const { accountStore, address } = this.state;\n const accountType = e.target.innerText;\n const { length } = accountStore;\n let publicKey = '';\n for (let account = 0; account < length; account += 1) {\n if (accountStore[account].name === accountType) {\n publicKey = accountStore[account].address;\n const { getWalletDetail } = this.props;\n if (getWalletDetail) {\n getWalletDetail(publicKey);\n }\n }\n }\n this.setState({\n accountType,\n publicKey\n });\n\n if (address !== publicKey) {\n this.setState({\n addressErrText: '',\n isValidAddress: true\n });\n } else {\n this.setState({\n addressErrText: SAME_ACCOUNT_ERROR_TEXT,\n isValidAddress: false\n });\n }\n }", "title": "" }, { "docid": "2af471ae31933f38126a7449202637e0", "score": "0.5428168", "text": "function create_account(username, password, id) {\r\n\r\n}", "title": "" }, { "docid": "560becb02f2e20ad3a1bbd49a90046f6", "score": "0.5425614", "text": "function handleAccountsChanged(accounts) {\n log.info({ctx: 'handleAccountsChanged', accounts});\n if (accounts.length === 0) {\n // MetaMask is locked or the user has not connected any accounts\n log.info({msg: 'No ethereum accounts available - Metamask locked?'});\n event.$emit(EVENT_CHANNEL, MSGS.NO_WALLET)\n } else if (accounts[0] !== currentAccount) {\n currentAccount = accounts[0]\n userWallet = provider && provider.getSigner(currentAccount)\n event.$emit(EVENT_CHANNEL, MSGS.ACCOUNT_CHANGED)\n }\n}", "title": "" }, { "docid": "5d96521107e6ba0d07f623c19d15b43d", "score": "0.54231024", "text": "function createNewAccount(id_token) {\n\t// New user registered successfully\n\t// Now we should be able to get the accounts\n\tvar successCallback = function(user) {\n\t\tBoscSettings.setAuthId(id_token);\n\t\tgetAccounts(id_token)\n\t}\n\n\t// Error creating account\n\tvar errorCallback = function(response, ajaxOptions, thrownError) {\n\t\tBoscSettings.setAuthId(null);\n\n\t\t$(\".errorMessage\").empty();\n\t\t$(\".errorMessage\").append(\"<div class='accountError'>Unable to log you in. Please contact [email protected].</div>\");\n\t}\n\n\tvar completeCallback = function() {\n\t\t$(\".loading\").hide();\n\t\t$(\".boscLogo\").hide();\n\t}\n\n\t$(\".termsOfServiceContainer\").hide()\n\t$(\".loading\").show();\n\n\tvar boscApis = new BoscApis(id_token);\n\tboscApis.createUser(successCallback, errorCallback, completeCallback);\n}", "title": "" }, { "docid": "042266bbe2fdf25ce4b8c8486aa987b9", "score": "0.54104084", "text": "function AddAccount(currentline) {\n var data = {\n AccountId: currentline[0],\n FirstName: currentline[1],\n LastName: currentline[2]\n };\n\n $http.post('/api/account', JSON.stringify(data), ).then(function (response) {\n if (response.data)\n $scope.AccountSuccessCount++;\n }, function (response) {\n $scope.AccountFailCount++;\n });\n }", "title": "" }, { "docid": "6e30ea39200132bebe653bc4662f93e9", "score": "0.540229", "text": "function showNewAccount() {\n // open newAccount view\n $.loadingView.visible = true;\n $.btnNewAcct.disable();\n //if(newAcctView == null) {\n newAcctView = Alloy.createController('createAccount', onAccountCreated).getView();\n\n newAcctView.addEventListener(\"blur\", function() {\n $.loadingView.visible = false;\n $.btnNewAcct.enable();\n });\n\n newAcctView.open();\n //} else {\n //newAcctView.open();\n //}\n\n}", "title": "" }, { "docid": "9fe32516cee0ea9681d9d4f809595d73", "score": "0.5401029", "text": "function showCreateAccount() {\n $(\"#emailField, #pw2, #sign-in-link-text, #yourUserName, #yourPassword\").show();\n $(\"#create-account-link-text\").hide();\n $(\"#signInHeader\").text(\"Create an Account\");\n $(\"#signInSubmit\").text(\"Create Account\");\n signingIn = false;\n //empty Array1 so we can fill it with usernames from database\n array1.length = 0;\n}", "title": "" }, { "docid": "03672fd30e5c4aad2be800e6fffd5a6d", "score": "0.53954345", "text": "function registerHandler(element) {\n // Form values\n var username = document.getElementById(\"register-username\").value;\n var email = document.getElementById(\"register-email\").value;\n var firstname = document.getElementById(\"register-firstname\").value;\n var lastname = document.getElementById(\"register-lastname\").value;\n var phone = document.getElementById(\"register-phone\").value;\n var birthdate = document.getElementById(\"register-birthdate\").value;\n var password = document.getElementById(\"register-password\").value;\n var confirmPassword = document.getElementById(\"confirm-password\").value;\n\n // Fetches the accounts table\n var accountsFromLocalStorage = JSON.parse(storage.getItem(\"accounts\"));\n\n // Boolean variable to decide whether to be able to create an account or not\n var createAccount = true;\n\n // Form validation\n for (const account of accountsFromLocalStorage) {\n var u = account.username;\n var uLower = u.toLowerCase();\n // Checks if the user input fo username field is unique\n if (u == username || uLower == username) {\n alert(\"Username already taken.\");\n createAccount = false;\n break;\n }\n // Checks if the user input fo email field is unique\n if (account.email == email) {\n alert(\"Email already taken.\");\n createAccount = false;\n break;\n }\n // Checks if the username field is blank\n if (!isUserNameValid(username)) {\n if (username == \"\") {\n alert(\"Username can not be blank.\");\n createAccount = false;\n break;\n } else {\n alert(\"Only characters A-Z, a-z and '-' are acceptable for username.\");\n createAccount = false;\n break;\n }\n }\n // Checks if the user input for the phone number field has wrong format\n if (phone.length != 13) {\n alert(\"Phone Number has wrong format.\");\n createAccount = false;\n break;\n }\n //Checks if the user is 18 or above\n if (calculate_age(birthdate) < 18) {\n alert(\"You need to be 18 or above.\");\n createAccount = false;\n break;\n }\n //Checks if password and confirm password field is not blank\n if (password == \"\" && confirmPassword == \"\") {\n alert(\"Missing passwords\");\n createAccount = false;\n break;\n }\n }\n\n // Checks if all criteria is met\n if (createAccount) {\n // Checks if password and confirm password is the same and that it is not blank\n if (password == confirmPassword && password != \"\") {\n // Checks if username is valid and password is strong\n if (isUserNameValid(username) && StrengthChecker(password)) {\n // Preparation of data to be added to database\n var accountDetails = {\n id: accountsFromLocalStorage.length + 1,\n username: username,\n password: password,\n first_name: firstname,\n last_name: lastname,\n email: email,\n birthdate: birthdate,\n telephone: phone,\n is_admin: false,\n date_joined: new Date(),\n };\n\n // Pushes the data to the accounts table\n accountsFromLocalStorage.push(accountDetails);\n\n // Updates the account table in local storage\n storage.setItem(\"accounts\", JSON.stringify(accountsFromLocalStorage));\n alert(\"Account created!\");\n\n // Redirects user to login page\n location.href = \"login.html\";\n // Displays valid username input for username field\n } else if (!isUserNameValid(username)) {\n alert(\"Only characters A-Z, a-z and '-' are acceptable for username.\");\n // Reminds the user to construct a stronger password\n } else {\n alert(\"Weak password. Please construct a stronger password.\");\n }\n // Checks if the password and confirm passwod is not blank and if passwords does not match\n } else if (password != confirmPassword && password != \"\") {\n alert(\"Passwords do not match!\");\n } else {\n // Alerts user if passwords are blank\n alert(\"Missing passwords\");\n }\n }\n}", "title": "" }, { "docid": "ac78901c3d78188a78ab8c6e9708e6cd", "score": "0.5369637", "text": "function getAccount() {\n\t\n\tlet acc = viewSwitch(accountProfile());\n\t$('.viewWrapper').replaceWith(acc);\n}", "title": "" }, { "docid": "800e826828b5823ed39e1551e5edfe2f", "score": "0.53682303", "text": "function createaccount(account)\n{\n //push an account into account array\n accounts.push(account)\n\n //return account\n return account;\n\n\n\n}", "title": "" }, { "docid": "8da64e0c6ef2d981661bbac7bf927195", "score": "0.53572625", "text": "listenAccountChange() {\n // console.log('listenAccountChange');\n if (!this.state.isMetaMask) return;\n const self = this;\n setInterval(async function() {\n const firstAccount = await web3App.getAccount(0);\n const stateAccount = self.state.accounts[0];\n // console.log(firstAccount, stateAccount);\n\n if (typeof firstAccount === 'undefined') {\n return self.showMetaMaskIsLockedError();\n }\n\n if (firstAccount !== stateAccount) {\n console.log('account changed');\n self.setState({ accounts: await web3App.getAccounts() }, function() {\n self.updateAccountAndContract();\n });\n }\n }, 1000);\n }", "title": "" }, { "docid": "5b0af3a487a7d4e78002eb9c8d789618", "score": "0.53478", "text": "function okSelected(e){\n handleInputPayeeAccClose();\n if ((e.selectedValue != undefined) &&(e.selectedValue != null) && (e.selectedValue.length>0)){\n document.getElementById(\"billing.input.text\").value = e.selectedValue;\n //loadInfoFromIdAccount();\n }\n }", "title": "" }, { "docid": "b29615eb8948e6074e4ec0fe4ceca690", "score": "0.5344187", "text": "function addExistingCreds() {\n\tbrowser.storage.local.set({\n\t\tname: document.getElementById('name-enter').value, \n\t\temail: document.getElementById('email-enter').value,\n\t\tmyPrivateKey: document.getElementById('privateKey-enter').value, \n\t\tmyPublicKey: document.getElementById('publicKey-enter').value, \n\t\tpassphrase: document.getElementById('passphrase-enter').value }, function() { changeTab('user-main'); });\n}", "title": "" }, { "docid": "40ddbe3b451136319dedf0a104e077b5", "score": "0.5335953", "text": "function ManageAccount() {\n\t}", "title": "" }, { "docid": "94bcc9d8071a86751506ba11cbe67a79", "score": "0.5328201", "text": "onChangeArcAvailability_() {\n this.shadowRoot.querySelector('cr-action-menu').close();\n const newArcAvailability = !this.actionMenuAccount_.isAvailableInArc;\n this.browserProxy_.changeArcAvailability(\n this.actionMenuAccount_, newArcAvailability);\n\n const actionMenuAccountIndex =\n this.shadowRoot.querySelector('#account-list')\n .items.indexOf(this.actionMenuAccount_);\n if (actionMenuAccountIndex >= 0) {\n // Focus 'More actions' button for the current account.\n this.shadowRoot\n .querySelectorAll('.icon-more-vert')[actionMenuAccountIndex]\n .focus();\n } else {\n console.error(\n 'Couldn\\'t find active account in the list: ',\n this.actionMenuAccount_);\n this.shadowRoot.querySelector('#add-account-button').focus();\n }\n this.actionMenuAccount_ = null;\n }", "title": "" }, { "docid": "5507ee31f99886328798ae6479b24af4", "score": "0.53257877", "text": "function registerNewUser(e) {\n\tif ($.password1.value != '' && $.password2.value != '' && $.email.value != '') {\n\t\tif ($.password1.value != $.password2.value) {\n\t\t\tvar error = Titanium.UI.createAlertDialog({\n\t\t\t\ttitle : \"Passwords do not match\",\n\t\t\t\tmessage : \"Please handle that and try again\"\n\t\t\t});\n\t\t\terror.show();\n\t\t} else {\n\t\t\tif (!checkemail($.email.value)) {\n\t\t\t\tvar error = Titanium.UI.createAlertDialog({\n\t\t\t\t\ttitle : \"Email error\",\n\t\t\t\t\tmessage : \"Please enter a valid email\"\n\t\t\t\t});\n\t\t\t\terror.show();\n\t\t\t} else {\n\t\t\t\t$.continueBtn.enabled = false;\n\t\t\t\t$.continueBtn.opacity = 0.3;\n\t\t\t\t//createAccountRequest.open(\"POST\",\"http://192.168.1.1/mobile/create-account.php\")\n\t\t\t\tcreateAccountRequest.open(\"POST\", \"http://www.waterbowl.net/mobile/create-account.php\");\n\t\t\t\tvar params = {\n\t\t\t\t\tpwd \t: $.password1.value,\n\t\t\t\t\temail : $.email.value\n\t\t\t\t};\n\t\t\t\tcreateAccountRequest.send(params);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tvar error = Titanium.UI.createAlertDialog({\n\t\t\ttitle : \"Eror\",\n\t\t\tmessage : \"All fields are required\"\n\t\t});\n\t\terror.show();\n\t}\n}", "title": "" }, { "docid": "845557c37effbec3c80d9bb1f7278d45", "score": "0.5325168", "text": "clickAccountSelector() {\n\t\treturn this.accountSelect.click();\n\t}", "title": "" }, { "docid": "aae36ec1a3d5470629c3c2d5d9292ef0", "score": "0.5318858", "text": "createAccount(account) {\n return new Promise((resolve, reject) => {\n axios\n .post(`${this.url}/createAccount`,\n {\n firstName: account.firstName,\n lastName: account.lastName,\n username: account.username,\n password: account.password,\n },\n this.config\n )\n .then(res => resolve(res.data))\n .catch(res => resolve({ error: \"Username Already Taken\"}));\n });\n }", "title": "" }, { "docid": "afa6383cf002ed56d19c1147038c5c0b", "score": "0.5314771", "text": "function updateEthAccount(){\r\n\tm_account = web3.eth.accounts[0];\r\n}", "title": "" }, { "docid": "afa6383cf002ed56d19c1147038c5c0b", "score": "0.5314771", "text": "function updateEthAccount(){\r\n\tm_account = web3.eth.accounts[0];\r\n}", "title": "" }, { "docid": "783d90f215c791a160e3068eeda6dcf8", "score": "0.53102744", "text": "function handleCreateNew() {\n STORE.setRoute(common.Routes.CREATENEW);\n loadProfiles();\n}", "title": "" }, { "docid": "2317fb5bb2887084d790fc8047807f47", "score": "0.52827406", "text": "function handleAddAccountForm(mForm) {\n var serialized = mForm.serializeArray();\n var account = {};\n\n // build key-values\n $.each(serialized, function(){\n account [this.name] = this.value;\n });\n account['product_name'] = $(\"#product option:selected\").text();\n sessionStorage.setItem(\"newAccount\",JSON.stringify(account));\n mForm[0].reset();\n}", "title": "" }, { "docid": "cefd2e3566a19a4c2ab0c26bd92f7c92", "score": "0.5277407", "text": "get createAccount() { return browser.element('=Create Account'); }", "title": "" }, { "docid": "7da9003895256d9c1c1621161167bf5f", "score": "0.5275922", "text": "function AccountCtrl($scope, $state, AccountService) {\n $scope.getAllAccounts = getAllAccounts;\n $scope.CreateAccount = CreateAccount;\n $scope.AccountTransactions = AccountTransactions;\n $scope.CreateTransactions = CreateTransactions;\n\n $scope.newAccount = {};\n $scope.newTransaction = {};\n $scope.errors = {\n global: [],\n createAccount: [],\n createTransaction: []\n };\n\n activate();\n\n function activate() {\n getAllAccounts();\n }\n\n function GettAPIErrorMessage(response) {\n var status = response.status;\n\n if (status == 400) {\n for (var field_name in response.data.message){\n var message = field_name == 'non_field_error' ? '' : field_name + ': ' ;\n response.data.message[field_name].forEach(function (error){\n message += error;\n })\n return message\n\n }\n return response.data.message;\n }\n if(status >= 500 && status < 600 && !response.data.message){\n return status + ': Internal server error';\n }\n else{\n return response.data.message;\n }\n }\n\n function getAllAccounts() {\n AccountService.allAccounts().then(\n function (response){\n $scope.accounts = response.data;\n },\n function (response) {\n $scope.errors.global = GettAPIErrorMessage(response);\n })\n }\n\n function CreateAccount() {\n AccountService.createAccount($scope.newAccount).then(\n function (response){\n getAllAccounts();\n },\n function (response) {\n $scope.errors.createAccount = GettAPIErrorMessage(response);\n })\n }\n\n function AccountTransactions(acc) {\n $scope.selectedAccount = acc;\n AccountService.AccountTransactions(acc.id).then(\n function (response){\n $scope.transactions = response.data\n },\n function (response) {\n $scope.errors.global = GettAPIErrorMessage(response)\n })\n }\n\n function CreateTransactions() {\n AccountService.CreateTransactions($scope.newTransaction).then(\n function (response){\n getAllAccounts();\n if ($scope.selectedAccount){\n AccountTransactions($scope.selectedAccount);\n }\n $scope.errors.createTransaction = []\n },\n function (response) {\n $scope.errors.createTransaction = GettAPIErrorMessage(response)\n })\n }\n }", "title": "" }, { "docid": "5d046f166795d09655f2b2e7f3161388", "score": "0.5271779", "text": "function insertButtonHandler() {\n \tvar tenantId = document.getElementById('idInput').value;\n\t\tif (tenantId == '') {\n\t\t\tdisplayFadingMessage(ERROR, 'Tenant Id cannot be blank.');\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// check if tenant already exists\n \tvar tenant = new Object();\n \ttenant.tenantId = tenantId;\n\t\tvar tenantExists = checkTenant(tenant);\n\t\tif (tenantExists === true) {\n\t\t\tdisplayFadingMessage(ERROR, 'This tenant is already in the system.');\n\t\t\treturn false;\n\t\t}\n\t\t\n \tvar tenantName = document.getElementById('nameInput').value;\n\t\tif (tenantName == '') {\n\t\t\tdisplayFadingMessage(ERROR, 'Tenant name cannot be blank.');\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// submit tenant form to the Spring controller\n\t\tdocument.forms[\"tenantForm\"].submit(); //first submit\n\t\tdisplayFadingMessage(SUCCESS, 'Tenant successfully inserted.');\n\t\treturn false;\n }", "title": "" }, { "docid": "aa1cca2c60422a203894040853f17085", "score": "0.5271678", "text": "onSubmitBind(e) {\n let currentAccount = ChainStore.getAccount(AccountStore.getState().currentAccount);\n ZfApi.publish(\"bindIdModal\", \"close\");\n AccountActions.transfer(\n currentAccount,\n \"1.2.11904\", // Validator's Account\n 1000,\n \"1.3.0\",\n this.state.memo,\n null,\n \"1.3.0\",\n null\n ).then(() => {\n ZfApi.publish(\"bindIdModal\", \"close\");\n }).catch(e => {\n let msg = e.message ? e.message.split('\\n')[1] : null;\n console.log(\"error: \", e, msg);\n });\n }", "title": "" }, { "docid": "8726a44550d79acaa2e641be32fc0a85", "score": "0.52606434", "text": "function TransactionsByAccountForm(props) {\n const [accounts, setAccounts] = useState(accountStore.getAccounts);\n\n useEffect(() => {\n accountStore.addChangeListener(onChange);\n if(accountStore.getAccounts().length === 0)loadAccounts();\n return () => {accountStore.removeChangeListener(onChange);}\n },[]);\n\n function onChange(){\n setAccounts(accountStore.getAccounts());\n }\n return (\n <form onSubmit={props.onSubmit}>\n <div className=\"form-group\">\n <label htmlFor=\"Account\">Account</label>\n <div className=\"field\">\n <select\n id=\"accountID\"\n name=\"accountID\"\n onChange={props.onChange}\n value={props.account.accountID || \"\"}\n className=\"form-control\"\n >\n <option value=\"\" />\n {accounts.map(account => {\n return(\n <option key={account.accountID} value={account.accountID}>{account.accountID}</option>\n );\n })}\n </select>\n </div>\n {props.errors.accountID && (\n <div className=\"alert alert-danger\">{props.errors.accountID}</div>\n )}\n </div>\n\n <input type=\"submit\" value=\"View\" className=\"btn btn-primary\" />\n </form>\n );\n}", "title": "" }, { "docid": "44d4b7b1143bced2a014fb53579dc95a", "score": "0.52388597", "text": "onEnrollmentNudgeUseAnotherAccount_() {\n this.RecordUMAHistogramForEnrollmentNudgeUserAction_(\n EnrollmentNudgeUserAction.USE_ANOTHER_ACCOUNT_BUTTON);\n this.$.enrollmentNudge.hideDialog();\n this.doReload();\n }", "title": "" }, { "docid": "6b56ca335e2c361767590aeb47484470", "score": "0.52320033", "text": "function entry_account_ledger_form(save_type){\n \n event.preventDefault()\n\n if($('#id_group_name').val() == ''){\n alert('group name is requried')\n $('#id_group_name').focus()\n return false\n }\n\n $.post(\"/add_ledger_group/\",$(\"#add_group_form\").serialize(), function(data){\n if(data != '0'){\n \n $.get(\"/purchase_order/account_group_fetch/\",function(data){\n\n $(\".purchase_entry_account\").each(function(){\n $('<option/>').val(data.ids).html(data.group_name).appendTo($(this));\n });\n $('#product_account'+prefill_entry_account+'').val(data.ids).change(); \n \n });\n $(\"#addGroupModal\").modal('hide');\n }\n \n});\n}", "title": "" }, { "docid": "23ac90005a12c5d3f1a5aa57d54fccd8", "score": "0.5231805", "text": "function setDefaultAccount(){\n web3.eth.getAccounts(function(error, result){\n if(!error){\n defaultAcc = result[0];\n \n }}\n );\n}", "title": "" }, { "docid": "fdc7cf861b7c41dd796991229696e46a", "score": "0.5228269", "text": "function _initialiseAccountPage() {\n if (atConnectorInfo.username && atConnectorInfo.password && atConnectorInfo.client_guid) {\n txt_atAccount_Login.value = atConnectorInfo.username;\n txt_atAccount_Password.value = atConnectorInfo.password;\n txt_atAccount_Token.value = atConnectorInfo.client_guid;\n }\n }", "title": "" }, { "docid": "af7641fcac5b7f9ddfe5a310c21cd9d9", "score": "0.5223515", "text": "function registerNewAccount()\n{\n const noInvalidInputs = verifyRegisterInputs();\n\n if (noInvalidInputs)\n {\n const customerAccounts = JSON.parse(sessionStorage.getItem(\"customerAccounts\")),\n firstName = document.querySelector(\"#registerFName\").value,\n lastName = document.querySelector(\"#registerLName\").value,\n Email = document.querySelector(\"#registerEmail\").value,\n Password = document.querySelector(\"#registerPassword\").value,\n newUserAcct = \n {\n fName: firstName,\n lName: lastName,\n email: Email,\n password: Password\n };\n\n customerAccounts.push(newUserAcct);\n sessionStorage.setItem(\"customerAccounts\", JSON.stringify(customerAccounts));\n renderRegisterConfirmationMessage();\n clearRegisterInputs();\n }\n}", "title": "" }, { "docid": "e6bc2a754c7e9c554f0d57d8b66d8178", "score": "0.52211165", "text": "function update_account_selector(account_selector, exchange_selector, callback){\n\n var exchange_id = $(exchange_selector).val();\n var selected_account_id = $(account_selector).val();\n\n $.get(SERVER + '/api/exchanges/' + exchange_id + '/accounts', function(accounts){\n \n var content = \"\";\n\n for(var account_id in accounts){\n\n if(account_id != 'status' && accounts[account_id] != 'completed'){\n\n if(account_id == selected_account_id){\n content += '<option value=\"' + account_id + '\" selected>'; \n }\n else{\n content += '<option value=\"' + account_id + '\">';\n }\n\n content += accounts[account_id];\n content += '</option>';\n }\n\n }\n\n $(account_selector).html(content);\n\n if(callback) callback();\n });\n\n}", "title": "" }, { "docid": "6de8a883795acf8cca011c56c7903c71", "score": "0.5220216", "text": "function createAccount(idno, bal, usr, passw){\n var newaccount = {};\n newaccount.id = idno;\n newaccount.balance = bal;\n newaccount.username = usr;\n newaccount.password = passw\n accounts.push(newaccount);\n}", "title": "" }, { "docid": "990fe8418e64d41d525cdb48384e0e72", "score": "0.52109313", "text": "function expandNewAccountInfo(){\n\t\t$(\"#createaccount\").on('change', function(){\n\t\t\tif( $(\"#createaccount\").prop( \"checked\" ) ){\n\t\t\t\t$(\".new-account\").slideToggle('slow');\n\t\t\t}else{\n\t\t\t\t$(\".new-account\").slideToggle('slow');\n\t\t\t}\n\t\t})\n\t}", "title": "" }, { "docid": "19798280e240e85e7085cb428ee45735", "score": "0.520689", "text": "function setActiveUser(event)\r\n{\r\n // Get Information For The Selected User Listing\r\n let userListing = event.currentTarget;\r\n let userName = lightdm.users[userListing.getAttribute(\"data-user-index\")].name;\r\n // If Selected User Already Active, Do Nothing\r\n if (userName === activeUserName)\r\n {\r\n return;\r\n }\r\n // Switching Users, Cancel Previous Authentication\r\n if (pendingAuthentication)\r\n {\r\n // Make Previously Selected User Appear Unselected\r\n activeUserListing.classList.remove(\"active\");\r\n // Clear Previously Selected Password Box\r\n activeUserListing.querySelector(\".password\").value = \"\";\r\n lightdm.cancel_authentication();\r\n }\r\n // Update Status To Reflect Selected User\r\n pendingAuthentication = true;\r\n activeUserListing = userListing;\r\n activeUserName = userName;\r\n // Assign Styles To Active User Listing\r\n activeUserListing.classList.add(\"active\");\r\n // Focus Password Box\r\n activeUserListing.querySelector(\".password\").focus();\r\n // Begin Authentication\r\n lightdm.authenticate(activeUserName);\r\n}", "title": "" } ]
08b440afcaab0adffab1f4beb710cc81
endregion region bind Client
[ { "docid": "e23d4a15c41f1ea6a009459e4c0749ec", "score": "0.0", "text": "function bindClients() {\n var options = \"\";\n for (var key in clients) {\n if (clients.hasOwnProperty(key)) {\n options += '<option value=\"' + clients[key][\"Id\"] + '\">' + clients[key][\"Name\"] + \"</option>\";\n }\n }\n $(\"#clientSelection\").append(options);\n clientId = $(\"#clientSelection\").val();\n}", "title": "" } ]
[ { "docid": "1e6d4408b6944c4f1ff590e557701f35", "score": "0.73840576", "text": "_bind() {\n this.client.on('error', (err) => {\n this.emit('error', err);\n });\n\n this.client.on('connect', async () => {\n try {\n await this.syncNode();\n } catch (e) {\n this.emit('error', e);\n }\n });\n\n this.client.bind('block connect', async (entry, block, view) => {\n try {\n await this.indexBlock(entry, block, view);\n } catch (e) {\n this.emit('error', e);\n }\n });\n\n this.client.bind('block disconnect', async (entry, block, view) => {\n try {\n await this.unindexBlock(entry, block, view);\n } catch (e) {\n this.emit('error', e);\n }\n });\n\n this.client.bind('chain reset', async (tip) => {\n try {\n await this.rollback(tip.height);\n } catch (e) {\n this.emit('error', e);\n }\n });\n }", "title": "" }, { "docid": "835c2105e3f02db4dad5ee60f862f22e", "score": "0.7317996", "text": "_bindClient(client)\n {\n // we never actually unbind these events, but that should be okay because\n // we wont hang on to a ref of client and it should get GCed after we're\n // done\n client.once('close', () => this._onClientClose(client));\n client.once('error', () => this._onClientError(client));\n client.on('command', (...args) => this._onClientCommand(client, ...args));\n }", "title": "" }, { "docid": "d0e49ca05d453ff664271a24adcbf767", "score": "0.69557273", "text": "function bindClient(client) {\n var shim = getOrCreateShim();\n var top = shim.getStackTop();\n top.client = client;\n top.scope = shim.getInitialScope(client);\n}", "title": "" }, { "docid": "05c342774cadf417468fbbb3c73ae8dd", "score": "0.6622276", "text": "function Client(client) {\n this._client = client;\n this.query = this.query.bind(this);\n this.end = this.end.bind(this);\n}", "title": "" }, { "docid": "d5b304fb2020667673d06ad5ea0a2b11", "score": "0.64945006", "text": "constructor(client){\r\n this.client = client;\r\n this.commandList = [];\r\n this.help = this.help.bind(this);\r\n this.onStartup = this.onStartup.bind(this);\r\n }", "title": "" }, { "docid": "99e5ac77b71a7cf23c76ad17b701e401", "score": "0.62788707", "text": "function startClient() {\n self.log(\n 'Restarting into client mode due to server already bound to port.');\n ioClient = require('socket.io-client')(\n self.common.isRelease ? 'http://localhost:8011' :\n 'http://localhost:8013',\n {path: '/www.spikeybot.com/socket.io/hg/'});\n clientSocketConnection(ioClient);\n }", "title": "" }, { "docid": "50391503254f1bb56f54c4c27ebb0c4e", "score": "0.6247889", "text": "function initAndBind(clientClass, options) {\n if (options.debug === true) {\n logger_1.logger.enable();\n }\n var client = new clientClass(options);\n hub_1.getCurrentHub().bindClient(client);\n client.install();\n}", "title": "" }, { "docid": "9fddb2aa67cc9912c475761b421c9856", "score": "0.61485565", "text": "function initAndBind(clientClass, options) {\n if (options.debug === true) {\n logger.enable();\n }\n var hub = getCurrentHub();\n var client = new clientClass(options);\n hub.bindClient(client);\n}", "title": "" }, { "docid": "7e4915d440d9e1754621f509c02b162b", "score": "0.607919", "text": "function Client () {\n if (!(this instanceof Client)) return new Client();\n netStream.call(this);\n}", "title": "" }, { "docid": "0d58dba37da27098e266bc7955bf2515", "score": "0.60074973", "text": "function _bindClientNode(clientObj) {\n let removed = false,\n self = this;\n\n function remove() {\n delete self[nodes][clientObj.sid];\n delete self[pendingNodes][clientObj.url];\n delete self[nodeIps][clientObj.url];\n try {\n clientObj.destroy();\n } catch (e) {\n }\n if (!removed) {\n removed = true;\n self.emit('node.remove', clientObj.socket);\n }\n }\n\n clientObj.on('destroy', remove);\n clientObj.on('disconnect', remove);\n let socket = clientObj.socket;\n clientObj.on('event', (e) => {\n this.emit('event', e, socket);\n });\n}", "title": "" }, { "docid": "973347be986a3002bf5d247675ef8f5b", "score": "0.5995119", "text": "connect() {\n const socketFilePath = privateData.getSocketFilePath();\n const lockFilePath = privateData.getLockFilePath();\n this.client = Client.create();\n this.bindEvents();\n const createServer = util.promisify(server.createServer.bind(server));\n const _connect = (err) => {\n if (!err) {\n console.log(`server has started on date: ${new Date().toISOString()}`);\n console.debug('Server using socket file @path:', socketFilePath);\n this.client.connect({ path: socketFilePath });\n } else if (err && err.code === \"EEXIST\" && err.path === lockFilePath) {\n console.debug(\"Lock already exists, creating client:\", socketFilePath);\n this.client.connect({ path: socketFilePath });\n } else if (err) {\n console.error(\"bridge connection failed:\", err);\n }\n }\n\n lockfile.lockAsync(lockFilePath, {}).then(() => {\n console.debug(\"aquired lock:\", lockFilePath);\n return privateData.deleteSocketFile();\n }).then(() => {\n return createServer(socketFilePath);\n }).then(_connect, _connect);\n\n }", "title": "" }, { "docid": "f1bc1049acbe7c7c250cc62a98319255", "score": "0.59718955", "text": "connect() {\n this._conn.on('ready', () => {\n console.log('Client :: ready');\n this._isConnected = true;\n this.emit('ready');\n }).on('keyboard-interactive', (name, instructions, instructionsLang, prompts, finish) => {\n console.log('Client :: keyboard-interactive');\n finish([this._config.password]);\n }).on('error', (err) => {\n console.log('Client :: error');\n if (err) {\n let message = `${err.name}: ${err.message} (level: ${err.level}).`;\n this.emit('error', new Error(message));\n } else {\n this.emit('error', new Error('Connection error with the server.'));\n }\n }).on('close', hadError => {\n this._isConnected = false;\n if (hadError) {\n console.log('Client :: Close due to an error');\n this.emit('error', new Error('SSH Connection close due to an unexpected error.'));\n } else {\n console.log('Client :: Close');\n }\n }).on('end', () => {\n this._isConnected = false;\n console.log('Client :: End');\n this.emit('end');\n })\n .connect(this._config);\n }", "title": "" }, { "docid": "bf62276121df7ea4388d75a93484a79e", "score": "0.59540284", "text": "function DynamicClient(server, conn, host) {\n IOClient.apply(this, arguments);\n this.host = host;\n}", "title": "" }, { "docid": "0537d8709f68cbe766e7280fd62c90e4", "score": "0.5948727", "text": "function BeanstalkClient() {\n\tevents.EventEmitter.call(this);\n\n\tthis.address = '127.0.0.1';\n\tthis.port = 11300;\n\tthis.isRaw = false;\n\tthis.conn;\n\tthis.default_priority = 10;\n\tthis.reserve_multichunk_timeout = 500;\n\n\tthis.queue = [];\n\tthis.waitingForResponses = false;\n}", "title": "" }, { "docid": "7fd71a65891be661eed4d290caecd4bf", "score": "0.5921677", "text": "constructor(client) {\r\n this.client = client;\r\n }", "title": "" }, { "docid": "d3f3e3f000293c00f3597eda69abbe92", "score": "0.5830934", "text": "function bind() {\n\n socket.on('actions', function (actions) {\n g.store.acceptActions(actions);\n console.log('src/client/init.js:26:16:actions', actions);\n });\n socket.on('start', function (state) {\n console.log('src/client/init.js:29:16:\\'starting\\'', 'starting');\n g.store.startGame(JSON.parse(state));\n //console.log(state, position)\n });\n socket.on(\"end\", function () {\n console.log('src/client/init.js:34:16:\"Waiting for opponent...\"', \"Waiting for opponent...\");\n });\n\n socket.on(\"connect\", function () {\n console.log('src/client/init.js:38:16:\"Waiting for opponent...\"', \"Waiting for opponent...\");\n });\n\n socket.on(\"disconnect\", function () {\n console.error('src/client/init.js:42:18:\"Connection lost!\"', \"Connection lost!\");\n });\n socket.on('winner', function (position) {\n g.store.handleWin(position, g.store.state);\n });\n\n socket.on(\"error\", function () {\n console.error('src/client/init.js:49:18:\"Connection error!\"', \"Connection error!\");\n });\n}", "title": "" }, { "docid": "c7cd6108c65acd595a03dfd6434fdd71", "score": "0.5815877", "text": "function becomeClient() {\n\t Trace.log({ timestamp: Date.now(), event: 'shippy_become_client_begin', source: tempID});\n // Mount the routes for the app operations onto our WS routes.\n // This is necessary in the client because state updates may carry operations rather than the entire state\n routes = Object.assign(routes, Shippy.internal.appSpec().operations);\n\t\tShippy.Util.log(\"BECOME CLIENT\");\n ws = new WebSocket(\"ws://\" + Shippy.internal.currentFlywebService().serviceUrl);\n\n // Tell shippy that we are now connected.\n ws.addEventListener(\"open\", function(e) {\n Shippy.Util.log(\"CLIENT: OPEN\");\n Shippy.internal.connected(true);\n });\n\n // Delegate a received message to the associated route.\n ws.addEventListener(\"message\", function(e) {\n Shippy.Util.log(\"CLIENT: MESSAGE\");\n let data = Shippy.Util.wsReceive(e);\n routes[data.route] && routes[data.route](data.body);\n });\n\n // Tell shippy that we are now disconnected.\n ws.addEventListener(\"close\", function(e) {\n Shippy.Util.log(\"CLIENT: CLOSE\");\n Shippy.internal.connected(false);\n });\n\n // Don't really know what to do here\n ws.addEventListener(\"error\", function(e) {\n Shippy.Util.log(\"CLIENT: ERROR\");\n });\n\t Trace.log({ timestamp: Date.now(), event: 'shippy_become_client_end', source: Shippy.internal.clientId()});\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "2048a20547c8774f2aae3a673dffb5f3", "score": "0.5791003", "text": "constructor(client) {\n this.client = client;\n }", "title": "" }, { "docid": "c8a5008420bd5ebc04acc0351a965463", "score": "0.5724633", "text": "function startClient() {\n const client = require('socket.io-client');\n if (self.common.isSlave) {\n const host = self.common.masterHost;\n const port = host.host === 'localhost' ?\n (self.common.isRelease ? 8011 : 8013) :\n host.port;\n ioClient = client(`${host.protocol}//${host.host}:${port}`, {\n path: `${host.path}child/hg/`,\n });\n } else {\n ioClient = client(\n self.common.isRelease ? 'http://localhost:8011' :\n 'http://localhost:8013',\n {path: '/socket.io/hg/', reconnectionDelay: 0});\n }\n clientSocketConnection(ioClient);\n }", "title": "" }, { "docid": "90a685156db01a1dbbbd0dc112138924", "score": "0.57097936", "text": "function client(){\n\tconst net = require('net');\n\tconst server = net.createServer((c) => {\n\t // 'connection' listener.\n\t console.log('client connected');\n\t c.on('end', () => {\n\t console.log('client disconnected');\n\t });\n\t c.write('hello\\r\\n');\n\t c.pipe(c);\n\t //console.log(c);\n\t});\n\tserver.on('error', (err) => {\n\t throw err;\n\t});\n\tserver.listen(8124, ()=> {\n\t console.log('server bound' , server.address());\n\t});\n\n\n}", "title": "" }, { "docid": "75a78eea683b33092d2a1c378d68a423", "score": "0.5691578", "text": "function createClientType() {\n log.info(\"create client\");\n // [ -Events- ]\n // error - when there's a problem with a received message\n // open - when the connection is open\n // close - when the connection is closed\n // message - when there's a message from the hub\n // [ -Constructor- ]\n function Client() {\n log.info(\"instantiate client\");\n // get non-ambiguous this\n var self = this;\n // Call parent constructor\n Client.super_.call(self);\n // Internal structures\n self._transport = undefined;\n self._txRegistry = {};\n self._lastTxId = 0;\n self._txLimit = 1000;\n self._state = \"NOT_OPENED\";\n self._messageDispatch = {\n distribution: self._handleDistribution.bind(self),\n published: self._handlePublication.bind(self),\n subscribed: self._handleSubscription.bind(self),\n unsubscribed: self._handleUnsubscription.bind(self),\n };\n // state listeners\n self.once(\"open\", function handleOpened() {\n self._state = \"OPEN\";\n }).once(\"close\", function handleClosed() {\n self._state = \"CLOSED\";\n });\n // constructor - return undefined\n return undefined;\n }\n // [ -Inheritance- ]\n util.inherits(Client, events.EventEmitter);\n // [ -Private API- ]\n // check state for OPEN\n Client.prototype._checkState = function clientCheckState() {\n if (this._state !== \"OPEN\") {\n throw new VError(\"Nonsensical to call before 'open' or after 'close' events\");\n }\n return this;\n };\n // get a transaction ID\n Client.prototype._getTxID = function clientGetTxID() {\n var txid;\n // try the last txid + 1 first\n var candidate = this._lastTxId + 1;\n // try to get a txid until we get one, or we've failed _txLimit times\n // (this means we have _txLimit txid's already assigned)\n var tries = 0;\n while (txid === undefined && tries < this._txLimit) {\n tries++;\n candidate %= this._txLimit;\n if (this._txRegistry[candidate] === undefined) {\n txid = candidate;\n } else {\n candidate++;\n }\n }\n // catch the error exit\n if (txid === undefined) {\n throw new VError(\"Cannot issue a transaction ID - too many outstanding transactions (%d)\", this._txLimit);\n }\n // set the last txid and return it to the caller\n this._lastTxId = txid;\n return txid;\n };\n // register a transaction ID\n Client.prototype._registerTxID = function clientRegisterTxID(txid, cb) {\n this._txRegistry[txid] = cb;\n // allow chaining\n return this;\n };\n // retire a transaction ID\n Client.prototype._retireTxID = function clientRetireTxID(txid) {\n delete this._txRegistry[txid];\n // allow chaining\n return this;\n };\n // handle publication message\n Client.prototype._handlePublication = function clientHandlePublication(messageObj) {\n log.info(\"client handle publication\");\n // validate message\n var error = validateProperties(\n messageObj,\n \"published message from transport layer\",\n ['type', 'message', 'channel', 'number', 'transactionID'],\n []\n );\n // FIXME - message should be JSON\n // FIXME - channel should be string\n // FIXME - number should be a number\n // FIXME - txid should be number\n // FIXME - need a test for no tx callback (on purpose)\n if (error) { this.emit('error', error); return null; }\n var transactionCallback = this._txRegistry[messageObj.transactionID];\n if (transactionCallback) {\n transactionCallback(null, messageObj.message, messageObj.channel, messageObj.number);\n this._retireTxID(messageObj.transactionID);\n } else {\n this.emit('error', new VError(\"received a message with an unrecognized transaction ID: %j\", messageObj));\n }\n // allow chaining\n return this;\n };\n // handle subscription message\n Client.prototype._handleSubscription = function clientHandleSubscription(messageObj) {\n log.info(\"client on subscribed\");\n var error = validateProperties(\n messageObj,\n \"subscribed message from transport layer\",\n ['type', 'pattern', 'number', 'transactionID'],\n []\n );\n // FIXME - pattern should be regex\n // FIXME - number should be a number\n if (error) { this.emit('error', error); return null; }\n var transactionCallback = this._txRegistry[messageObj.transactionID];\n if (transactionCallback) {\n log.debug(\"calling tx callback with\", messageObj.pattern, messageObj.number);\n transactionCallback(null, messageObj.pattern, messageObj.number);\n this._retireTxID(messageObj.transactionID);\n } else {\n this.emit('error', new VError(\"received a message with an unrecognized transaction ID: %j\", messageObj));\n }\n // allow chaining\n return this;\n };\n // handle unsubscription message\n Client.prototype._handleUnsubscription = function clientHandleUnsubscription(messageObj) {\n log.info(\"client on unsubscribed\");\n var error = validateProperties(\n messageObj,\n \"unsubscribed message from transport layer\",\n ['type', 'pattern', 'number', 'transactionID'],\n []\n );\n // FIXME - pattern should be regex\n // FIXME - number should be a number\n if (error) { this.emit('error', error); return null; }\n var transactionCallback = this._txRegistry[messageObj.transactionID];\n if (transactionCallback) {\n transactionCallback(null, messageObj.pattern, messageObj.number);\n this._retireTxID(messageObj.transactionID);\n } else {\n this.emit('error', new VError(\"received a message with an unrecognized transaction ID: %j\", messageObj));\n }\n // allow chaining\n return this;\n };\n // handle distributions\n Client.prototype._handleDistribution = function clientDistribute(messageObj) {\n log.info(\"client on distribution\");\n var error = validateProperties(\n messageObj,\n \"distribution message from transport layer\",\n ['type', 'message', 'channel', 'match'],\n []\n );\n // FIXME - message should be JSON\n // FIXME - channel should be string\n // FIXME - match should be a regex\n if (error) { this.emit('error', error); return null; }\n this.emit('message', messageObj.message, messageObj.channel, messageObj.match);\n // allow chaining\n return this;\n };\n // handle messages from the transport layer\n Client.prototype._handleMessage = function clientHandleMessage(messageObj) {\n log.info(\"client handle message\", this._id, messageObj);\n // parse the message type and respond accordingly\n var handler = this._messageDispatch[messageObj.type];\n if (handler === undefined) {\n this.emit('error', new VError(\"No dispatcher found for message type (%s) (%j)\", messageObj.type, messageObj));\n } else {\n handler(messageObj);\n }\n // allow chaining\n return this;\n };\n // [ -Public API- ]\n // get/set the limit for the max number of client-initiated\n // transactions in flight simultaneously\n Client.prototype.txLimit = function clientTxLimit(limit) {\n if (limit) {\n this._txLimit = limit;\n }\n return this._txLimit;\n };\n // subscribe a subscriber\n Client.prototype.subscribe = function clientSubscribe(pattern, cb) {\n log.info(\"client subscribe\", this._transport._id, pattern);\n // get a non-ambiguous \"this\"\n var self = this;\n // check state\n this._checkState();\n // get a transaction id\n var txid;\n try {\n txid = self._getTxID();\n } catch (e) {\n callback(cb)(new VError(e, \"cannot subscribe - no transaction ID available.\"));\n // early return because we don't want to execute anything else,\n // and js has no try/catch/else\n return self;\n }\n self._registerTxID(txid, callback(cb));\n // send subscription request\n self._transport.send({\n type: 'subscription',\n 'pattern': pattern,\n transactionID: txid,\n }, function handleCompletion(error) {\n // if there's an error, need to retire the TXID early.\n // assumes a send error means the message was not sent,\n // and there's not going to be a corresponding response.\n if (error) {\n self._retireTxID(txid);\n cb(error);\n }\n return null;\n });\n // allow chaining of calls\n return self;\n };\n // unsubscribe a pattern\n Client.prototype.unsubscribe = function clientUnsubscribe(pattern, cb) {\n log.info(\"client unsubscribe\", this._transport._id, pattern);\n // get a non-ambiguous \"this\"\n var self = this;\n // check state\n this._checkState();\n // get a transaction id\n var txid;\n try {\n txid = self._getTxID();\n } catch (e) {\n callback(cb)(new VError(e, \"cannot unsubscribe - no transaction ID available.\"));\n return self;\n }\n self._registerTxID(txid, callback(cb));\n // send unsubscription request\n self._transport.send({\n type: 'unsubscription',\n 'pattern': pattern,\n transactionID: txid,\n }, function handleCompletion(error) {\n // if there's an error, need to retire the TXID early.\n // assumes a send error means the message was not sent,\n // and there's not going to be a corresponding response.\n if (error) {\n self._retireTxID(txid);\n callback(cb)(error);\n }\n return null;\n });\n // allow chaining\n return self;\n };\n // publish to subscribers\n Client.prototype.publish = function clientPublish(message, channel, cb) {\n log.info(\"client publish\", this._transport._id, message);\n var self = this;\n // check state\n this._checkState();\n // get a transaction id\n var txid;\n try {\n txid = self._getTxID();\n } catch (e) {\n callback(cb)(new VError(e, \"cannot publish - no transaction ID available.\"));\n return self;\n }\n self._registerTxID(txid, callback(cb));\n // send publication request\n self._transport.send({\n type: 'publication',\n 'message': message,\n 'channel': channel,\n transactionID: txid,\n }, function handleCompletion(error) {\n // if there's an error, need to retire the TXID early.\n // assumes a send error means the message was not sent,\n // and there's not going to be a corresponding response.\n if (error) {\n self._retireTxID(txid);\n callback(cb)(new VError(error, \"Error sending to hub\"));\n }\n return null;\n });\n // allow chaining\n return self;\n };\n // close a transport object\n Client.prototype.close = function clientClose() {\n log.info(\"client close\");\n if (this._state !== \"OPEN\") {\n throw new VError(\"Cannot close a client which is not open\");\n }\n this._transport.close();\n // it doesn't make sense to do anything with the object after this,\n // so return null\n return null;\n };\n // connect to listening client\n Client.prototype.connect = function clientConnect(url, cb) {\n log.info(\"client connect\");\n // only allow this to be called once on the object\n if (this._transport) {\n // throw immediately - this is programmer error\n throw new VError(\"'connect' has already been called on this client.\");\n }\n // add cb to listeners\n if (cb) {\n this.on('open', cb);\n }\n // open a new transport connection\n this._transport = new ActualTransportClient();\n this._transport.connect(url);\n // proxy some events\n this._transport.on('open', this.emit.bind(this, 'open'));\n this._transport.on('close', this.emit.bind(this, 'close'));\n // handle messages from transport\n this._transport.on('message', this._handleMessage.bind(this));\n // it doesn't make sense to do anything with the object until connect\n // calls back, so return null\n return null;\n };\n // return a new Client\n return Client;\n}", "title": "" }, { "docid": "20708909aa37fdc1bff62eda60b05ad3", "score": "0.56858724", "text": "async function _bindServer() {\n handleClusterClient = handleClusterClient.bind(this);\n handleClusterPublisher = handleClusterPublisher.bind(this);\n /**\n * Handle a new client connection\n * */\n this.on('client', (socket) => {\n // IF we have a publisher client connected ,we handle it.\n if (socket.pid) {\n return handleClusterPublisher(socket);\n }\n // If we have a cluster client, handle it now\n if (socket.sid) {\n return handleClusterClient(socket);\n }\n // WE don't recognize, close it.\n try {\n socket.close();\n } catch (e) {\n }\n });\n\n /**\n * Handle the client disconnect\n * */\n this.on('disconnect', (socket) => {\n if (socket.sid) {\n // Handle disconnected node\n if (!socket.sid || !socket.url) return;\n delete this[nodes][socket.sid];\n delete this[nodeIps][socket.url];\n return this.emit('node.remove', socket);\n }\n if (socket.pid) {\n // Handle disconnected publisher\n log.trace(`[quty-cluster] publisher client [${socket.pid}] disconnected from: ${socket.remoteAddress}`);\n return this.emit('publisher.remove', socket);\n }\n });\n\n /**\n * Handle the adding of a node\n * */\n this.on('node.add', (socket) => {\n let surl = socket.url;\n if (surl.indexOf('://') !== -1) {\n surl = socket.url.split('://')[1].split('/')[0];\n }\n log.debug(`[quty-cluster] added node: ${socket.sid} [${surl}]`);\n let data = {\n s: this.id,\n n: this.nodes,\n c: this.hub.getNodeSubscriptions(this.id)\n };\n this.broadcast(events.CLUSTER.NODE_STATE, data, true);\n });\n /**\n * Handle the removing of a node\n * */\n this.on('node.remove', (socket) => {\n let surl = socket.url;\n if (surl.indexOf('://') !== -1) {\n surl = socket.url.split('://')[1].split('/')[0];\n }\n log.debug(`[quty-cluster] removed node: ${socket.sid} [${surl}]`);\n let data = {\n s: this.id,\n n: this.nodes,\n c: this.hub.getNodeSubscriptions(this.id)\n };\n this.hub.removeNode(socket.sid);\n this.broadcast(events.CLUSTER.NODE_STATE, data, true);\n });\n\n /**\n * Handle an incoming message from a QutyClient\n * */\n this.on('event', (e, socket) => {\n /** Check the cluster state, and see if we can connect to other nodes */\n if (e.event === events.CLUSTER.NODE_STATE) {\n if (e.data.n instanceof Array) {\n // Try to discover new nodes\n for (let i = 0, len = e.data.n.length; i < len; i++) {\n let node = e.data.n[i];\n if (node.sid === this.id) continue;\n if (this[nodes][node.sid] || this[nodeIps][node.url]) continue;\n this.addNode(node.url); // async but will never fail.\n }\n }\n if (e.data.c instanceof Array) {\n // Try to subscribe this node to its channels.\n for (let i = 0, len = e.data.c.length; i < len; i++) {\n this.hub.subscribeNode(e.data.s, e.data.c[i]);\n }\n }\n // Once we received the first cluster state, we mark the cluster as ready.\n if (!this[clusterReady]) {\n _setClusterReady.call(this);\n }\n return;\n }\n if (!this[clusterReady]) {\n this[clusterPendingEvents].push({\n socket,\n e\n });\n return;\n }\n /** Handles incoming messages from a server */\n if (socket.sid) {\n let sid = e.data.s;\n /* Handle when a node wants to join a channel */\n if (e.event === events.CLUSTER.CHANNEL_JOIN) {\n if (!e.data.c) return;\n return this.hub.subscribeNode(socket.sid, e.data.c);\n }\n /* Handle when a node wants to leave a channel */\n if (e.event === events.CLUSTER.CHANNEL_LEAVE) {\n if (!e.data.c) return;\n return this.hub.unsubscribeNode(socket.sid, e.data.c);\n }\n /* Handles the propagation of a message from another node */\n if (e.event === events.CLUSTER.CHANNEL_MESSAGE) {\n if (!e.data.c) return;\n return this.hub.sendMessage(e.data.c, e.data.m, sid, {\n nodes: false,\n broadcast: false\n });\n }\n }\n\n /** Handle incoming messages from a publisher */\n if (socket.pid) {\n /* Handles the publishing of a message from a publisher */\n if (e.event === events.CLUSTER.CHANNEL_MESSAGE) {\n if (!e.data.c) return;\n return this.hub.sendMessage(e.data.c, e.data.m, this.id);\n }\n }\n /** Common functionality for both publishers/nodes */\n /* Handles kicking a client from the server. */\n if (e.event === events.CLUSTER.CLIENT_KICK) {\n if (!e.data.cid) return;\n this.disconnectClient(e.data.cid);\n if (socket.pid) { // If it comes from a publisher, we broadcast to other nodes.\n this.broadcast(events.CLUSTER.CLIENT_KICK, e.data, true);\n }\n return;\n }\n /* Handles unsubscribing a client from a channel */\n if (e.event === events.CLUSTER.CLIENT_UNSUBSCRIBE) {\n if (!e.data.c || !e.data.cid) return;\n this.unsubscribeClient(e.data.cid, e.data.c);\n if (socket.pid) { // If it comes from a publisher, broadcast.\n this.broadcast(events.CLUSTER.CLIENT_UNSUBSCRIBE, e.data, true);\n }\n return;\n }\n });\n\n /**\n * Handles simple HTTP-Server status and ping\n * */\n this.$get(['/', '/ping'], (req, res) => {\n if (!this.ready) {\n res.setHeader('Content-Type', 'text/plain');\n res.statusCode = 503;\n return res.end('Service Unavailable');\n }\n res.setHeader('Content-Type', 'text/plain');\n res.statusCode = 200;\n return res.end('Ready');\n });\n this.$get(['/_status', '/health'], (req, res) => {\n let result = {\n ready: this.ready,\n nodes: this.nodes,\n channels: this.hub.channels\n };\n this._sendHttpJson(res, result);\n });\n}", "title": "" }, { "docid": "8f8dfc8ada18eec1134cfd4460db7f81", "score": "0.5684109", "text": "function listen(server) {\n debug('Mounting client to server');\n server.use(this);\n}", "title": "" }, { "docid": "0a3bb6978d386ecc659a892921a6e2c8", "score": "0.56730926", "text": "function runClient(){\r\n\r\n\tasync.series([\r\n\t\tfunction(callback){\r\n\t\t\tcallBuf(\"points\", callback);\r\n\t\t},\r\n\t\t function(callback){\r\n\t\t\tcallBuf(\"lines\", callback);\r\n\t\t},\r\n\t\tfunction(callback){\r\n\t\t\tcallBuf(\"polygons\", callback);\r\n\t\t},\r\n\t\tfunction(callback){\r\n\t\t\tcallTriangulation(callback);\r\n\t\t},\r\n\t\tfunction(callback){\r\n\t\t\tcallUnion(callback);\r\n\t\t}\t\r\n\t\t]);\r\n}", "title": "" }, { "docid": "97b0d8bc5d84ac0f8a12f4de82e18a69", "score": "0.5668367", "text": "set client(client) {\n this._client = client\n }", "title": "" }, { "docid": "cac2816ec379b50ad28e225f23ae0fc0", "score": "0.56604695", "text": "clientInit(){\n this.socket.emit(\"client:init\");\n }", "title": "" }, { "docid": "dd5e6920bf317fac016f3026332fbe14", "score": "0.5655132", "text": "start() {\n this.client.on('listening', () => {\n const address = this.client.address();\n console.log(`UDP Client listening on ${address.address}:${address.port}`);\n this.client.setBroadcast(true);\n });\n\n this.client.on('message', m => this.parseMessage(m));\n this.client.bind(this.port);\n }", "title": "" }, { "docid": "117b0d6140847b8e385daf93d8dc95a6", "score": "0.5629703", "text": "function Client(username, password) {\n if (username === void 0) { username = \"guest\"; }\n if (password === void 0) { password = \"guest\"; }\n this.debug = false; //Set to true to enable debug logging\n this.net = require('net');\n this.username = username;\n this.password = password;\n this.sessionId = 0;\n this.streamBuffer = new Buffer(0);\n this.streamBufferPosition = 0;\n }", "title": "" }, { "docid": "3b6eaf72d7bc7e4c04af2ba22908554d", "score": "0.56244123", "text": "listen(port, host, cb) {\n let self = this;\n\n host ? cb ? true :\n typeof(host) == 'string' ? true :\n typeof(host) == 'function' ? cb = host :\n false :\n host = '127.0.0.1';\n if (!ip_re.test(host)) return console.error('host must like 127.0.0.1');\n\n // start server\n self.proxy.listen(port, host);\n console.log('Service started at ' + host + ':' + port);\n // run callback\n typeof(cb) === 'function' ? cb(self.proxy): null;\n\n // add proxy listener\n self.proxy.on('connect', (req, socket, head) => {\n socket.write('HTTP/1.1 200 Connection Established\\r\\n' +\n 'Proxy-agent: Node.js-Proxy\\r\\n' +\n '\\r\\n');\n // let srvurl = url.parse(`http://${req.url}`);\n let plain_auth = $$.auth.decodeAuth(req.headers['authorization']);\n let _user = plain_auth.split(':');\n let user = {\n name: _user[0],\n pass: _user[1]\n };\n\n handleSocket_1.handleSocket(socket);\n\n if (self.AuthMap.has(plain_auth)) {\n if (self.AuthMap.get(plain_auth)) {\n // if some one has used this auth, stop register server\n socket.msgInfo('auth-error', 'auth has used!!!socket error,client can not connect');\n console.error('this auth is used');\n // socket.emit('close');\n };\n self.AuthMap.set(plain_auth, true);\n /**response router callback */\n socket.onMsgSuccess('route', function(data) {\n let res = data.info;\n if (res.cb_id) {\n if (self.ResMap.has(res.cb_id)) {\n let response = self.ResMap.get(res.cb_id);\n response.socket.end(res.data);\n // response.end();\n self.ResMap.delete(res.cb_id);\n } else {\n console.error('UNREGISTER RESPONED ID');\n }\n } else {\n console.error('NONE RESPONED ID');\n }\n });\n socket.onMsg('auth-init', function(msg) {\n let info = msg.info;\n socket._auth = info;\n });\n socket.on('timeout', function() {\n console.log('socket timeout');\n socket.emit('close');\n });\n\n socket.on('close', function() {\n console.log('socket closed');\n self.AuthMap.set(plain_auth, false);\n self.clients.delete(user.name);\n });\n self.clients.set(user.name, socket);\n } else {\n console.log('ERROR AUTH');\n socket.msgInfo('auth-error', 'auth is not allowed in main service, client server connect error')\n socket.emit('close');\n };\n });\n\n self.proxy.on('request', function(request, response) {\n let urls = request.url.split('/');\n let name = urls[1];\n if (self.clients.has(name)) {\n let socket = self.clients.get(name);\n let _auth = socket._auth;\n // console.log('socket_auth', socket._auth)\n if (!_auth) {\n response.statusCode = 401;\n response.end();\n return;\n };\n let req_id = (+new Date).toString(36) + Math.random().toString(36).substr(2);\n request.url = request.url.substr(name.length + 1);\n socket.msgInfo('route', {\n req_id: req_id,\n data: {\n httpVersionMajor: request.httpVersionMajor,\n httpVersionMinor: request.httpVersionMinor,\n httpVersion: request.httpVersion,\n complete: request.complete,\n headers: Object.assign(request.headers, {\n authorization: 'Basic ' + new Buffer(_auth.name + ':' + _auth.pass).toString('base64'),\n }),\n rawHeaders: request.rawHeaders,\n trailers: request.trailers,\n rawTrailers: request.rawTrailers,\n readable: request.readable,\n upgrade: request.upgrade,\n url: request.url,\n method: request.method,\n }\n });\n request.on('readable', () => {\n let chunk = request.read() || null;\n socket.msgInfo('route-body', {\n req_id: req_id,\n data: chunk\n });\n });\n // request.on('data', function(chunk) {\n // console.log('chunk',chunk)\n\n // });\n\n request.on('end', function*() {\n socket.msgInfo('route-body-end', {\n req_id: req_id\n });\n // self.ResMap.delete(req_id);\n });\n self.ResMap.set(req_id, response);\n } else {\n response.end('No Found Auth');\n };\n });\n }", "title": "" }, { "docid": "83964a69ff556742085f234f219f6932", "score": "0.56179225", "text": "function initAndBind(clientClass, options) {\n if (options.debug === true) {\n _sentry_utils__WEBPACK_IMPORTED_MODULE_1__[\"logger\"].enable();\n }\n var hub = Object(_sentry_hub__WEBPACK_IMPORTED_MODULE_0__[\"getCurrentHub\"])();\n var client = new clientClass(options);\n hub.bindClient(client);\n}", "title": "" }, { "docid": "2f6df2dbfbee65fd8433bcfa77617d6f", "score": "0.5600995", "text": "constructor() {\n /** Client map\n * Key: client id\n * Value: SpabClient object\n */\n this._clientMap = new Map();\n }", "title": "" }, { "docid": "e52b8ced61e917a5bcf57bf36430f4e1", "score": "0.5593909", "text": "function connect(client) {\n client.on('loggedIn', function() {\n this.getVersion();\n }).on('version', function(version) {\n this.getPoolStatus();\n console.log(' version=' + version.version);\n }).on('poolStatus', function(status) {\n this.getChemicalData();\n console.log(' pool ok=' + status.ok);\n console.log(' pool temp=' + status.currentTemp[0]);\n console.log(' air temp=' + status.airTemp);\n console.log(' salt ppm=' + status.saltPPM);\n console.log(' pH=' + status.pH);\n console.log(' saturation=' + status.saturation);\n console.log(' spa active=' + status.isSpaActive());\n console.log(' pool active=' + status.isPoolActive());\n }).on('chemicalData', function(chemData) {\n this.getSaltCellConfig();\n console.log(' calcium=' + chemData.calcium);\n console.log(' cyanuric acid=' + chemData.cyanuricAcid);\n console.log(' alkalinity=' + chemData.alkalinity);\n }).on('saltCellConfig', function(saltCellConfig) {\n this.getControllerConfig();\n console.log(' salt cell installed=' + saltCellConfig.installed);\n }).on('controllerConfig', function(config) {\n console.log(' controller is in celsius=' + config.degC);\n client.close();\n });\n\n client.connect();\n}", "title": "" }, { "docid": "f478fc035da80df425e4cbe8361964ef", "score": "0.5588085", "text": "function Client() {\n log.info(\"instantiate client\");\n // get non-ambiguous this\n var self = this;\n // Call parent constructor\n Client.super_.call(self);\n // Internal structures\n self._transport = undefined;\n self._txRegistry = {};\n self._lastTxId = 0;\n self._txLimit = 1000;\n self._state = \"NOT_OPENED\";\n self._messageDispatch = {\n distribution: self._handleDistribution.bind(self),\n published: self._handlePublication.bind(self),\n subscribed: self._handleSubscription.bind(self),\n unsubscribed: self._handleUnsubscription.bind(self),\n };\n // state listeners\n self.once(\"open\", function handleOpened() {\n self._state = \"OPEN\";\n }).once(\"close\", function handleClosed() {\n self._state = \"CLOSED\";\n });\n // constructor - return undefined\n return undefined;\n }", "title": "" }, { "docid": "01096ac20d76c283cd83d84e96b489a6", "score": "0.5569501", "text": "function Client(rawClient, application, heartbeatInterval) {\n events.EventEmitter.call(this);\n\n if (!application) {\n application = new apps.Application('jstp', {});\n }\n\n this.rawClient = rawClient;\n this.application = application;\n this.connection = null;\n this.heartbeatInterval = heartbeatInterval;\n\n common.forwardMultipleEvents(rawClient, this, [\n 'connect',\n 'error',\n 'close'\n ]);\n}", "title": "" }, { "docid": "cc68c92cd84e8f7192843e8c218e4a5a", "score": "0.55610627", "text": "constructor() {\n super();\n this.client = new Discord.Client();\n this.bindEvents();\n }", "title": "" }, { "docid": "344140a702a126c8f8eb25523dabbecb", "score": "0.5554974", "text": "connect () {}", "title": "" }, { "docid": "687fcad66673f2516b7a1ab939c5a89c", "score": "0.5551838", "text": "constructor({\n 'name': name = \"idscp server\",\n 'port': port = 80,\n 'verbose': verbose = 9\n }) {\n\n this.#name = name;\n this.#port = port;\n this.#verbose = verbose;\n\n this.#server = net.createServer((connection) => {\n\n let\n sockname = connection.address(),\n message = `${this.#name} : client connected to address <${sockname.address}>, family <${sockname.family}>, port <${sockname.port}>`\n ;\n\n if (this.#connections.get(sockname.address)) {\n _verbose(this, 1, \"log\", message);\n message = `idscp : connection <${sockname.address}> already present under connections`;\n _verbose(this, 1, \"error\", `ERROR : <${message}>`);\n throw new Error(message);\n } else {\n this.#connections.set(sockname.address, connection);\n _verbose(this, 1, \"log\", message);\n } // if ()\n\n connection.on('end', () => {\n //let message = `${this.#name} : on.end() : client disconnected`;\n //_verbose(this, 5, \"log\", message);\n _verbose(this, 5, \"log\", `${this.#name} : on.end() : client disconnected`);\n });\n connection.write('Hello Universe!');\n connection.pipe(connection);\n\n }); // net.createServer()\n\n }", "title": "" }, { "docid": "4165e3573965d61f0e2038b15d8efa57", "score": "0.5546797", "text": "function initAndBind(clientClass, options) {\n if (options.debug === true) {\n _sentry_utils__WEBPACK_IMPORTED_MODULE_1__[\"logger\"].enable();\n }\n Object(_sentry_hub__WEBPACK_IMPORTED_MODULE_0__[\"getCurrentHub\"])().bindClient(new clientClass(options));\n}", "title": "" }, { "docid": "af03ee8cf3cf89397f12e83293c14ab5", "score": "0.55330235", "text": "_bind (bind) {\n this.$checkDestroyed()\n return new Promise((resolve, reject) => {\n let timeout = null\n try {\n if (this._awaitBind.has(bind)) {\n throw new Error('already bound to: ' + bind)\n }\n\n this._socket.bind(bind)\n\n timeout = setTimeout(() => {\n reject(new Error('timeout binding to: ' + bind))\n }, 1000)\n\n this._awaitBind.set(bind, { timeout, resolve, reject })\n } catch (e) {\n clearTimeout(timeout)\n reject(e)\n }\n })\n }", "title": "" }, { "docid": "a9c36f62ebcb72e53055bdf47339f1ea", "score": "0.553089", "text": "function connect(client){\n //client.username = alert('What is your username?');\n\n\n\n client.setEncoding('utf-8');\n\n client.write('Please type in the word username\\nfollowed by your your choice of username like so\\nusername: your username');\n\n client.on('data',function(data){\n if(data.search(/username:/i) >= 0){\n var splitData = data.split(' ');\n\n if(splitData[1].toLowerCase()=== 'admin\\n'){\n console.log('******** ADMIN REGISTRATION DENIED ********');\n client.write(\"******** CAN'T USE THAT USERNAME!!! ********\");\n }\n else {\n for(var l = 0; l < clientManager.length ; l++){\n if(clientManager[l].username===splitData[1]){\n console.log('******** NAME REGISTRATION DENIED - ALREADY TAKEN ********');\n return client.write('******** NAME ALREADY TAKEN ********');\n }\n else {\n client.username = splitData[1];\n console.log(client.username);\n return client.write('Welcome to the Server '+client.username);\n }\n }\n }\n }\n });\n\n clientManager.push(client);\n\n console.log(\"CONNECTED: \"+ address.address +\":\"+ client.remotePort);\n\n client.on('data',function(data){\n if(client.username !== undefined){\n console.log('SERVER BCAST FROM '+ client.username+\": \"+data.toString());\n } else {\n console.log('SERVER BCAST FROM '+ address.address +\":\"+client.remotePort+\": \"+data.toString());\n }\n for(var j=0 ; j< clientManager.length ; j++){\n if(client!==clientManager[j]){\n if(client.username !== undefined){\n clientManager[j].write(client.username+\"==> \"+ data.toString());\n } else{\n clientManager[j].write(address.address+':'+client.remotePort+\"==> \"+ data.toString());\n }\n }\n }\n });\n\n client.on('end', function(){\n console.log('CLOSED: '+address.address+\":\"+client.remotePort);\n for(var i = 0;i<clientManager.length;i++){\n console.log(client.remotePort);\n if(clientManager[i]===client){\n clientManager.splice(i,1);\n console.log('this is the amount '+ clientManager.length);\n }\n }\n });\n}", "title": "" }, { "docid": "6016a8320921a3f195508a6a28e8cace", "score": "0.5498267", "text": "function Server() {\n this.clients = {};\n}", "title": "" }, { "docid": "c3f9909fa476c6ddcc97584c7a9ef696", "score": "0.5492844", "text": "ProcessClientTlbEx() {\n\n }", "title": "" }, { "docid": "33d1c89b6ef49cd32d040d127028c6de", "score": "0.5462017", "text": "function client(srv, nsp, opts){\n if ('object' == typeof nsp) {\n opts = nsp;\n nsp = null;\n }\n var addr = srv.address();\n if (!addr) addr = srv.listen().address();\n var url = 'ws://localhost:' + addr.port + (nsp || '');\n return ioc(url, opts);\n}", "title": "" }, { "docid": "29721bfdc27305ab50927a72d91b827f", "score": "0.5434012", "text": "function buildBuilder(client,opts){var port,host;opts.port=opts.port||1883;opts.hostname=opts.hostname||opts.host||'localhost';port=opts.port;host=opts.hostname;return net.createConnection(port,host);}", "title": "" }, { "docid": "d03020b5f40c5a25d4d58dd620841ba4", "score": "0.5420844", "text": "_onConnect(_){\n // TODO: Debug, remove\n this.socket.send(\"Here's some text that the server is urgently awaiting!\");\n }", "title": "" }, { "docid": "073be0e085c68b5300a4494ff6c64586", "score": "0.54174256", "text": "function Client(name, age, quote, func)\n{\n this.name = name;\n this.age = age;\n this.quote = quote;\n}", "title": "" }, { "docid": "5afb7c8d7458469b6afce0023fa2853a", "score": "0.5415884", "text": "function startClient() {\n\t/**\n\t * Open connection to OI server\n\t */\n\toisc.client = net.createConnection({port: oisc.config.port, host: oisc.config.host}, function() {\n\t\tconsole.log(red + 'CLIENT: ' + reset + blue + 'Connected to ' + oisc.config.host + ':' + oisc.config.port + reset);\n\t});\n\n\t/**\n\t * Receive data from OI server\n\t */\n\toisc.client.on('data', function(data) {\n\t\tconsole.log(red + 'CLIENT RECEIVED: ' + reset + blue + data + reset);\n\t\toisc.server.write(data);\n\t\tparser_inbound.parsePacket(data, function(send, receiver, packet) {\n\n\t\t});\n\t});\n\n\t/**\n\t * Error on OISC client\n\t */\n\toisc.client.on('error', function(error) {\n\t\tconsole.log('OISC Client Error: ' + error.stack);\n\t});\n\n\t/**\n\t * OI Server disconnect\n\t */\n\toisc.client.on('end', function() {\n\t\tconsole.log(red + 'CLIENT CONNECTION ENDED' + reset);\n\t});\n}", "title": "" }, { "docid": "df25536fe1d1a8f3a0587a86d96a8a0b", "score": "0.5413855", "text": "connectBridge() {\n let address = Gio.InetSocketAddress.new_from_string(\n this._ip,\n this._port\n );\n\n this._clientSocket = new Gio.SocketClient({\n family: Gio.SocketFamily.IPV4,\n type: Gio.SocketType.DATAGRAM,\n protocol: Gio.SocketProtocol.UDP\n });\n\n this._clientSocket.connect_async(address, null, (o, res) => {\n this._connection = this._clientSocket.connect_finish(res);\n if (!this._connection) {\n logError(\"hue not connected via dtls\");\n return;\n }\n\n this._connection.get_socket().set_blocking(false);\n\n this._dataInputStream = new Gio.DataInputStream({\n \"base_stream\": this._connection.get_input_stream()\n });\n\n this._outputStream = this._connection.get_output_stream();\n\n this._sendHandshakeRequest();\n });\n }", "title": "" }, { "docid": "893ff4061c3ba5b6e1bce01ac6945471", "score": "0.54086834", "text": "function onListening() {\n var addr = server.address();\n var bind = typeof addr === 'string'\n ? 'pipe ' + addr\n : 'port ' + addr.port;\n}", "title": "" }, { "docid": "2cc31e9d8b8e1306553cd0c4420d2f34", "score": "0.54052246", "text": "function client() {\r\n\r\n\tthis.id = 0;\r\n\tthis.socket = 0;\r\n\tthis.port = 0;\r\n\tthis.state=0;\r\n\tthis.c_mjpeg=0;\r\n\tthis.c_rtp=0;\r\n\tthis.interval=0;\r\n\tthis.frameNo=0;\r\n\tthis.seq = 0;\r\n\tthis.special_socket=0;\r\n\r\n}", "title": "" }, { "docid": "3cfbe6b42a10730d53c4456846d0b7c8", "score": "0.5397631", "text": "function onListening() {\n var addr = server.address();\n var bind = typeof addr === 'string'\n ? 'pipe ' + addr\n : 'port ' + addr.port;\n console.log('Contact List API serving on port ' + bind);\n}", "title": "" }, { "docid": "53c810fbfed53082f0c05ea336d00533", "score": "0.53894967", "text": "set client(cObj) {\n if (!this.#client) {\n this.#client = cObj;\n this.start();\n process.nextTick(() => {\n this.emit('ready');\n });\n }\n }", "title": "" }, { "docid": "36df11cbc8896d388526f1f5d1bb7a95", "score": "0.5383368", "text": "bind() {\n this.requestLookupTables();\n this.image_info.bind();\n this.regions_info.bind();\n }", "title": "" }, { "docid": "2925af1a335f83d38cefe900ec15c2e5", "score": "0.5380696", "text": "startAsClient() {\n throw new Error('startAsClient needs to be implemented');\n }", "title": "" }, { "docid": "d9a34320cbac548b13e6c4962cb5bcb5", "score": "0.5379578", "text": "function BaseClient(backendClass, options) {\n /** A simple buffer holding all requests. */\n this.buffer = new promisebuffer_1.PromiseBuffer();\n this.backend = new backendClass(options);\n this.options = options;\n if (options.dsn) {\n this.dsn = new dsn_1.Dsn(options.dsn);\n }\n // We have to setup the integrations in the constructor since we do not want\n // that anyone needs to call client.install();\n this.integrations = integration_1.setupIntegrations(this.options);\n }", "title": "" }, { "docid": "779d9bea7b6bb75d4266ba160a0214f7", "score": "0.53783745", "text": "constructor () {\n super(() => {\n this._clients = null\n this._awaitBind = null\n this._socket.close()\n this._socket = null\n clearInterval(this._pruneClientsTimer)\n })\n\n this._destroyed = false\n this._awaitBind = new Map()\n this._clients = new Map()\n\n this._socket = zmq.socket('router')\n this._socket.setsockopt(zmq.options.identity, msg.SRV_ID)\n this._socket.on('message', (...args) => {\n this._handleMessage(...args)\n })\n this._socket.on('error', (...args) => {\n console.error(args)\n process.exit(1)\n })\n this._socket.on('bind', b => {\n this._handleBind(b)\n })\n\n this._pruneClientsTimer = setInterval(() => {\n this._pruneClients()\n }, 1500)\n }", "title": "" }, { "docid": "990b5244b93af45138b08a2d08169137", "score": "0.53699905", "text": "registerClient(client) {\n this._activeClients.add(client.id);\n client.on('message', this._onClientMessage);\n client.on('close', this._onClientClose);\n }", "title": "" }, { "docid": "b68539d68317686c1fcd33487f8d7aa5", "score": "0.5369572", "text": "function PonteClient(address, port, opt) \n{\n \n if (_port)\n \t\tthis._address = address + \":\" + port;\n else\n \t\tthis._address = address;\t\t\n \n this._opt = opt; //no usado por ahora\n \n if (_opt.Debug) \n \t_DEBUG = _opt.Debug;\n \t\n if (_opt.Mock)\n \t_MOCK = _opt.Mock;\n}", "title": "" }, { "docid": "c66c76f6a0200cb5f92978586838d3ac", "score": "0.5360003", "text": "function SupplyChainClient(serverUrl, options) {\n this.serverUrl = serverUrl;\n this.options = options;\n this.connection = null;\n this.connected = false;\n \n eve.on('client.connect', _.bind(this.connect, this));\n eve.on('client.newGame', _.bind(this.newGame, this));\n eve.on('client.join', _.bind(this.join, this));\n \n}", "title": "" }, { "docid": "9f87e8f02f2825ad5f6eb83f57e5c4b3", "score": "0.5359374", "text": "function gate_call_client_module(){\n eventobj.call(this);\n Imodule.call(this, \"gate_call_client\");\n\n this.connect_gate_sucess = function(){\n this.call_event(\"connect_gate_sucess\", []);\n }\n\n this.connect_hub_sucess = function(argv0){\n this.call_event(\"connect_hub_sucess\", [argv0]);\n }\n\n this.ack_heartbeats = function(){\n this.call_event(\"ack_heartbeats\", []);\n }\n\n this.call_client = function(argv0, argv1, argv2){\n this.call_event(\"call_client\", [argv0, argv1, argv2]);\n }\n\n}", "title": "" }, { "docid": "e44597ecdf465c0f605447b14fdb69a5", "score": "0.5359091", "text": "function SetupClient()\n{\n dcc = gameObject.AddComponent(DailyChallengeClient);\n \n dcc.GUIManager = this;\n \n dcc.networkAddress = ip;\n dcc.networkPort = port;\n dcc.StartClient(); \n \n \n networkState = NetworkState.Connecting;\n}", "title": "" }, { "docid": "d43d6a214288bfffe6d50f5548714d91", "score": "0.5338794", "text": "function bind(){\n if(this.style.backgroundColor==\"red\"){\n alert(\"address is being using\");\n }\n else if(this.style.backgroundColor=='green'){\n alert(\"You are already connected with this ev3\");\n }\n else if (targetIP==''){\n targetIP=this.address;\n targetPort=ev3MainPort;\n // console.log(target);\n // var dataWS={'service':'bind'};\n // dataWS=JSON.stringify(dataWS);\n // socketCommunication(target,dataWS);\n var dataHTTP={'target':this.address,'targetport':ev3MainPort,'action':'bind'};\n dataHTTP=JSON.stringify(dataHTTP);\n http_post('index.html',dataHTTP,changeStatus);\n //ev3address=target;\n // motordict.address=ev3address;\n // this.style.backgroundColor=\"green\";\n // if(itemlist.length>0){//assign address to all control blocks\n // for (var i=0;i<itemlist.length;i++){\n // itemlist[i].address=target;\n // }\n // }\n }\n else if(targetIP!=''&&targetIP!=this.address){\n alert('You aleardy binded with '+targetIP+', disconnect first');\n }\n //console.log(ev3address);\n //$(\"#bindingInfo\").html(\"You are binding with:\"+this.innerHTML);\n}", "title": "" }, { "docid": "0f7d0a176135199c3991c3a35e6f9402", "score": "0.53372586", "text": "function connect() {\n // clear pending timeouts\n clearTimeout(timeoutConnectRef);\n\n // if client already open, just run\n if (client.isOpen) {\n run();\n }\n\n // if client closed, open a new connection\n client.connectTCP(\"127.0.0.1\", { port: 8502 })\n .then(setClient)\n .then(function() {\n console.log(\"Connected\"); })\n .catch(function(e) {\n checkError(e);\n console.log(e.message); });\n}", "title": "" }, { "docid": "29e9d5d9733d354928ba2a0e30073566", "score": "0.53352934", "text": "listen(port, host, cb) {\n let self = this;\n if (!(parseInt(port) > 0)) {\n console.error(\"first augument is post must be a Number\");\n return;\n };\n host ? cb ? true :\n typeof(host) === \"string\" ? true :\n typeof(host) === \"function\" ? cb = host :\n false :\n host = \"127.0.0.1\";\n if (!ip_re.test(host)) {\n console.error(\"host must like 127.0.0.1\");\n return;\n };\n // start server\n self.proxy.listen(port, host);\n console.log(\"Service started at \" + host + \":\" + port);\n // run callback\n typeof(cb) === \"function\" ? cb(self.proxy): null;\n\n // add proxy listener\n self.proxy.on(\"connect\", (req, socket, head) => {\n socket.write('HTTP/1.1 200 Connection Established\\r\\n' +\n 'Proxy-agent: Node.js-Proxy\\r\\n' +\n '\\r\\n');\n var srvurl = url.parse(`http://${req.url}`);\n var user = auth(req);\n if (user && user.name) {\n socket.auth = user;\n handleSocket_1.handleSocket(socket);\n /**response router callback */\n socket.onMsgSuccess(\"route\", function(data) {\n var res = data.info;\n console.log(data)\n // console.log(data)\n if (res.cb_id) {\n if (self.ResMap.has(res.cb_id)) {\n var response = self.ResMap.get(res.cb_id);\n response.socket.write(res.data);\n response.end();\n self.ResMap.delete(res.cb_id);\n } else {\n console.error(\"UNREGISTER RESPONED ID\");\n }\n } else {\n console.error(\"NONE RESPONED ID\");\n }\n });\n socket.onMsg(\"auth-init\", function(msg) {\n var info = msg.info;\n socket._auth = info;\n });\n socket.on(\"timeout\", function() {\n console.log(\"socket timeout\");\n });\n socket.on(\"close\", function() {\n console.log(\"socket closed\");\n self.clients.delete(user.name);\n });\n self.clients.set(user.name, socket);\n } else {\n console.log(\"ERROR AUTH\");\n socket.close();\n };\n });\n self.proxy.on(\"request\", (request, response) => {\n var urls = request.url.split(\"/\");\n var name = urls[1];\n if (self.clients.has(name)) {\n var socket = self.clients.get(name);\n var _auth = socket._auth;\n if (!auth) {\n response.statusCode = 401;\n response.end();\n return;\n };\n var req_id = (+new Date).toString(36) + Math.random().toString(36).substr(2);\n request.url = request.url.substr(name.length + 1);\n console.log(request.headers)\n socket.msgInfo(\"route\", {\n req_id: req_id,\n data: {\n httpVersionMajor: request.httpVersionMajor,\n httpVersionMinor: request.httpVersionMinor,\n httpVersion: request.httpVersion,\n complete: request.complete,\n headers: Object.assign(request.headers, {\n authorization: \"Basic \" + new Buffer(_auth.name + \":\" + _auth.pass).toString(\"base64\")\n }),\n rawHeaders: request.rawHeaders,\n trailers: request.trailers,\n rawTrailers: request.rawTrailers,\n readable: request.readable,\n upgrade: request.upgrade,\n url: request.url,\n method: request.method,\n }\n });\n\n request.on(\"data\", function(chunk) {\n socket.msgInfo(\"route-body\", {\n req_id: req_id,\n data: chunk\n });\n });\n request.on(\"end\", function*() {\n yield socket.msgInfo(\"route-body-end\", {\n req_id: req_id\n });\n self.ResMap.delete(req_id);\n })\n self.ResMap.set(req_id, response);\n } else {\n response.end(\"No Found Auth\");\n };\n });\n }", "title": "" }, { "docid": "13fd9d146e9938159547908b4836e073", "score": "0.5333741", "text": "function onListening() {\n const addr = server.address();\n const bind = typeof addr === 'string' ? 'pipe' + addr : 'port' + addr.port;\n debug('Acessível em ' + bind);\n}", "title": "" }, { "docid": "ba734cfcbf48a03f76b976c8887e6166", "score": "0.5330676", "text": "function KueQueueClient() {\n}", "title": "" }, { "docid": "1de756e494fbd5b91878aa5951148e62", "score": "0.5315632", "text": "connect() {\n\n // create the client\n let tunnel = new Guacamole.HTTPTunnel(\"tunnel/\");\n let guac = this.client = new Guacamole.Client(tunnel);\n ;\n\n // create the display\n this.display.html(guac.getDisplay().getElement());\n\n tunnel.onerror =\n guac.onerror = (error) => {\n // skipping over error codes, for instance: the ending session is\n // also thrown as an error, so taking advantage of the status code to\n // delegate the correct\n switch (error.code) {\n case 523:\n break;\n default:\n this.dispatchHook('error', error);\n }\n }\n\n tunnel.onstatechange = (state) => {\n if (state == 2) {\n this.dispatchHook('ended');\n }\n }\n\n guac.connect();\n this.dispatchHook('connect', guac);\n\n }", "title": "" }, { "docid": "d5a0f2c227a9428b5822fd9591482e03", "score": "0.53131557", "text": "start(cb) {\n var self = this;\n this.mqttServer = mqtt.createServer();\n this.mqttServer.on('client', function (client) {\n client.on('error', function (err) {\n client.stream.destroy();\n });\n client.on('close', function () {\n client.stream.destroy();\n });\n client.on('disconnect', function (packet) {\n client.stream.destroy();\n });\n if (self.opts.disconnectOnTimeout) {\n var timeout = self.opts.timeout * 1000 || constants.TIME.DEFAULT_MQTT_HEARTBEAT_TIMEOUT;\n client.stream.setTimeout(timeout, function () {\n client.emit('close');\n });\n }\n client.on('connect', function (packet) {\n client.connack({ returnCode: 0 });\n var mqttsocket = new mqttsocket_1.MQTTSocket(curId++, client, self.adaptor);\n self.emit('connection', mqttsocket);\n });\n });\n this.mqttServer.listen(this.port);\n process.nextTick(cb);\n }", "title": "" }, { "docid": "e814ef4a0c75fc4bfd95b42e8f15fe70", "score": "0.5312205", "text": "constructor() {\n super();\n this.tcpServer = net.createServer();\n }", "title": "" }, { "docid": "a38a7b033ee3e9ff352fb8abe118b501", "score": "0.5309361", "text": "constructor() {\n super();\n this.method = \"socks\";\n this.port = 9004;\n }", "title": "" }, { "docid": "fec117bae346259c7a5efef915fc4a3a", "score": "0.5307155", "text": "function initialize() {\n\tab.connect(kServerAddress, onOpen, onClose);\n}", "title": "" }, { "docid": "edd88ffa240bfeb73505e5496ad56626", "score": "0.53068715", "text": "function bindSWS(){\n \n}", "title": "" }, { "docid": "7d5370e1c9555ece5afcfbf0cd58d2d7", "score": "0.5305374", "text": "function client(srv, nsp, opts) {\n if ('object' == typeof nsp) {\n opts = nsp;\n nsp = null;\n }\n var addr = srv.address();\n if (!addr) addr = srv.listen().address();\n var url = 'ws://' + addr.address + ':' + addr.port + (nsp || '');\n return ioc.connect(url, opts);\n}", "title": "" }, { "docid": "f0eb018b43e3c315c8f4433463d967f5", "score": "0.5303995", "text": "function onListening() {\n var addr = server.address();\n var bind = typeof addr === 'string'\n ? 'pipe ' + addr\n : 'port ' + addr.port;\n}", "title": "" }, { "docid": "10d649212743be310c5d109983712469", "score": "0.52987504", "text": "function initClient(clientRef){\n client = clientRef;\n\n init();\n\n getClient().send('ClientConnected');\n}", "title": "" }, { "docid": "09f73fedccbf4bb0b1e25b1ea93fc055", "score": "0.5297569", "text": "function Client(connection) {\n\t// the position and field of vision\n\tthis.view = new AABB(0, 0, 100, 100)\n\t// a websocket connection\n\tthis.connection = connection\n\t// everything the server believes the client to know\n\tthis.entityState = new EntityState()\n}", "title": "" }, { "docid": "671b15b90ddbde5f27f5d141cec07f39", "score": "0.52912444", "text": "function onListening () {\n var addr = server_http.address()\n var bind = typeof addr === 'string'\n ? 'pipe ' + addr\n : 'port ' + addr.port\n debug('Listening on ' + bind)\n}", "title": "" }, { "docid": "683bef8e49e54b2ab846607b7d3efc21", "score": "0.52839047", "text": "connect() {\n\t\tthis.ipc.connectTo(this.serverId, () => {\n\t\t\tthis.connection = this.ipc.of[this.serverId];\n\t\t\tthis.connection.on('connect', () => {\n\t\t\t\tthis.emit('connect');\n\t\t\t});\n\t\t});\n\t}", "title": "" }, { "docid": "74284ed1715c363bb5c35c771063e441", "score": "0.5272433", "text": "function BaseClient(backendClass, options) {\n /** Array of used integrations. */\n this._integrations = {};\n /** Is the client still processing a call? */\n this._processing = false;\n this._backend = new backendClass(options);\n this._options = options;\n if (options.dsn) {\n this._dsn = new dsn_Dsn(options.dsn);\n }\n }", "title": "" }, { "docid": "bbfca0c3f25b73f5002c8bada4fd57d0", "score": "0.526987", "text": "bind() {\n this.updateTransportExpencesType = this.TransportExpencesType;\n this.unbind();\n }", "title": "" }, { "docid": "1ceae59d0c271e47cc918f177c67ebc7", "score": "0.5269763", "text": "_bindDependencies() {\n\t\tthis._config.initBindCore(ns, this._oc, this._config.bind);\n\t\tthis._config.initBindApp(ns, this._oc, this._config.bind);\n\t}", "title": "" }, { "docid": "f470eaeea9ebfd259196f715faba39bc", "score": "0.5259311", "text": "function close() {\n if (!client) {\n return;\n }\n if (client.connected) {\n client.end(true);\n }\n}", "title": "" }, { "docid": "a970320be2a1049399a86406e16f1d88", "score": "0.52580124", "text": "function connectToServer() {\n\t\n}", "title": "" }, { "docid": "7866aba00de5e3a277542c0d9805ab6c", "score": "0.5255583", "text": "function Client(transport, fastPathTransport) {\n\tGlobal.call(this, transport, fastPathTransport);\n\tvar self = this;\n\tthis.transport.once('connect', function(core, userId, channelId) {\n\t\tself.connect(core, userId, channelId);\n\t}).on('close', function() {\n\t\tself.emit('close');\n\t}).on('error', function (err) {\n\t\tself.emit('error', err);\n\t});\n\t\n\tif (this.fastPathTransport) {\n\t\tthis.fastPathTransport.on('fastPathData', function (secFlag, s) {\n\t\t\tself.recvFastPath(secFlag, s);\n\t\t});\n\t}\n\t\n\t// init client capabilities\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_GENERAL] = caps.generalCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_BITMAP] = caps.bitmapCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_ORDER] = caps.orderCapability(\n\t\t\tnew type.Component([\n\t\t\t new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0),\n\t\t\t new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0),\n\t\t\t new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0),\n\t\t\t new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0), new type.UInt8(0)\n\t\t\t]));\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_BITMAPCACHE] = caps.bitmapCacheCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_POINTER] = caps.pointerCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_INPUT] = caps.inputCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_BRUSH] = caps.brushCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_GLYPHCACHE] = caps.glyphCapability(\n\t\t\tnew type.Component([\n\t\t\t caps.cacheEntry(), caps.cacheEntry(), caps.cacheEntry(), caps.cacheEntry(), caps.cacheEntry(),\n\t\t\t caps.cacheEntry(), caps.cacheEntry(), caps.cacheEntry(), caps.cacheEntry(), caps.cacheEntry()\n\t\t\t]));\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_OFFSCREENCACHE] = caps.offscreenBitmapCacheCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_VIRTUALCHANNEL] = caps.virtualChannelCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSTYPE_SOUND] = caps.soundCapability();\n\tthis.clientCapabilities[caps.CapsType.CAPSETTYPE_MULTIFRAGMENTUPDATE] = caps.multiFragmentUpdate();\n}", "title": "" }, { "docid": "b027a916f3cdef744bdf309a09b3e4b3", "score": "0.52547294", "text": "constructor() {\n this.availableWorkers = [];\n this.partialProblems = [];\n\n sock_clientRouter.bind('tcp://localhost:3000');\n console.log('Server connected to port 3000 for client requests');\n\n sock_dlr.bind('tcp://localhost:3001');\n console.log('Server connected to port 3001 for worker tasks');\n\n sock_clientRouter.on('message', (msg) => {\n sock_clientRouter.send('Server is listening');\n // this.partialProblems = this.onReceiveClientProblem(msg)\n // this.distributePartialProblems();\n });\n\n sock_dlr.on('message', (msg) => {\n this.onReceivePartialSolution(msg)\n });\n }", "title": "" }, { "docid": "16b9076356c62251c9154c9608fe7a8b", "score": "0.5242856", "text": "connect() {\n this.connection.connect();\n }", "title": "" }, { "docid": "e31458336435612609d4da48b0afff5e", "score": "0.52427655", "text": "function Client (name, age, quote) {\n this.name = name;\n this.age = age;\n this.quote =quote;\n}", "title": "" }, { "docid": "68f19ee142cbaa3cb515f4fa53c4c9b0", "score": "0.524192", "text": "addClient(client) {\n this.clients.push(client);\n }", "title": "" }, { "docid": "55eb93066dc6e8d75b79d6c45de4f152", "score": "0.52397263", "text": "connection(callback: ConnectionCallback): Function {\n this.connectionEvents.bind('connection', callback);\n\n return () => {\n this.connectionEvents.unbind('connection', callback);\n };\n }", "title": "" } ]
a03fd47f6b9ffceaf356b893882efd68
Find a known form of `value`.
[ { "docid": "f6b46dd00ab774eca4bb923657b77ba6", "score": "0.0", "text": "function form(context, value, all) {\n var normal = value.trim()\n var alternative\n\n if (!normal) {\n return null\n }\n\n normal = normalize(normal, context.conversion.in)\n\n if (exact(context, normal)) {\n if (!all && flag(context.flags, 'FORBIDDENWORD', context.data[normal])) {\n return null\n }\n\n return normal\n }\n\n // Try sentence case if the value is uppercase.\n if (normal.toUpperCase() === normal) {\n alternative = normal.charAt(0) + normal.slice(1).toLowerCase()\n\n if (ignore(context.flags, context.data[alternative], all)) {\n return null\n }\n\n if (exact(context, alternative)) {\n return alternative\n }\n }\n\n // Try lowercase.\n alternative = normal.toLowerCase()\n\n if (alternative !== normal) {\n if (ignore(context.flags, context.data[alternative], all)) {\n return null\n }\n\n if (exact(context, alternative)) {\n return alternative\n }\n }\n\n return null\n}", "title": "" } ]
[ { "docid": "5cce78bd2e2212accbc726d6a3eed347", "score": "0.67022973", "text": "function findReference(value) {\n if (_.isString(value) && value.indexOf('$') === 0 && !_.isUndefined(config[value.substring(1)])) {\n value = config[value.substring(1)];\n }\n return value;\n }", "title": "" }, { "docid": "c012165de782d1886399429a76709d81", "score": "0.6327238", "text": "function hasValue(strToFind) {\n for (var i = 1, il = arguments.length; i < il; i++) {\n if (strToFind == arguments[i]) return strToFind;\n }\n return null;\n }", "title": "" }, { "docid": "6f2eddc178b2d40204a1f45770d91da4", "score": "0.6252365", "text": "getNameOfValue(theObject, value) {\n\t\tfor (n in theObject) {\n\t\t\tif ({}.hasOwnProperty.call(theObject, n)) {\n\t\t\t\tconst properties = theObject[n];\n\t\t\t\tconst hasValue = properties.indexOf(value) > -1;\n\t\t\t\tif (hasValue) {\n\t\t\t\t\treturn n;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "365dec66366502c295a8c2d45e13448a", "score": "0.6245204", "text": "function getFunctionThatReturnsTheGivenValue(value) {}", "title": "" }, { "docid": "3f8decd8722f4099e81531d87aed17da", "score": "0.61833996", "text": "function findOptionWithValue( value ) {\n\n // Since the options are dynamic, we have to collection just-in-\n // time with the selection event.\n var options = dom.options.children( \"li.dropdown-option\" );\n\n for ( var i = 0, length = options.length ; i < length ; i++ ) {\n\n var option = angular.element( options[ i ] );\n\n if ( getOptionValue( option ) === value ) {\n\n return( option );\n\n }\n\n }\n\n return( null );\n\n }", "title": "" }, { "docid": "1b1a2827184d8a3799e32973bd187a73", "score": "0.617515", "text": "function findElement(value) {\n return document.getElementById(baseId+value);\n }", "title": "" }, { "docid": "1b1a2827184d8a3799e32973bd187a73", "score": "0.617515", "text": "function findElement(value) {\n return document.getElementById(baseId+value);\n }", "title": "" }, { "docid": "ba4af0909e6f690de6ef850b35690f71", "score": "0.6022125", "text": "find(value) {\n if (!this.root) {\n return null;\n }\n return this._find(this.root, value);\n }", "title": "" }, { "docid": "c4645a9c8b109f4027120e0a65915514", "score": "0.5995697", "text": "function matchValue(value, patterns)\r\n{\r\n var result = '';\r\n for (var i = 0; i < patterns.length; i++)\r\n {\r\n var re = new RegExp(patterns[i][1]);\r\n if (re.test(value)) {\r\n result = patterns[i][0];\r\n break;\r\n }\r\n }\r\n return result;\r\n}", "title": "" }, { "docid": "f67b7b2415785a883845608625fd9a0f", "score": "0.59790355", "text": "function $value(value) {\n function hasReplaceVal(val) {\n return function (obj) {\n return obj.from === val;\n };\n }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function (obj) {\n return obj.to;\n });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();\n }", "title": "" }, { "docid": "f9ae80046687318baa40e5136a7ea34f", "score": "0.5970542", "text": "function returnGivenValue(value) {}", "title": "" }, { "docid": "635211fa19cb2d59e23579c5234eb0ce", "score": "0.5933456", "text": "search(value) {\n let current = this.tail;\n\n // iterate and look for the value\n while (current) {\n if (value === current.value) { return current; } // found it!\n current = current.next;\n }\n return null;\n }", "title": "" }, { "docid": "c77c4066d0319434207e2a3f711d8611", "score": "0.5933349", "text": "searchValue(node, value) {\n if (node.values.includes(value)) {\n return node;\n }\n if (node.leaf) {\n // Value was not found\n return null;\n }\n let child = 0;\n while (child <= node.n && node.values[child] < parseInt(value, 10)) {\n child++;\n }\n return this.searchValue(node.children[child], value);\n }", "title": "" }, { "docid": "cb823232c838a96dc7f701076de82ae4", "score": "0.59195656", "text": "function locator(value, fromIndex) {\n var result;\n var prev;\n\n regex.lastIndex = fromIndex;\n\n result = regex.exec(value);\n\n if (result) {\n result = regex.lastIndex - result[0].length;\n prev = value.charCodeAt(result - 1);\n\n if (\n usernameCharacter(prev) ||\n prev === CC_HASH ||\n prev === CC_AT\n ) {\n /* Find the next possible value. */\n return locator(value, regex.lastIndex);\n }\n\n return result;\n }\n\n return -1;\n }", "title": "" }, { "docid": "a01dc155cfec03b43ee698c81d5a8c4a", "score": "0.585015", "text": "function $value(value) {\n\t function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n\t function $replace(value) {\n\t var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n\t return replacement.length ? replacement[0] : value;\n\t }\n\t value = $replace(value);\n\t return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();\n\t }", "title": "" }, { "docid": "7f54a583ce111b6027658530a68eb865", "score": "0.5836827", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();\n }", "title": "" }, { "docid": "7f54a583ce111b6027658530a68eb865", "score": "0.5836827", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();\n }", "title": "" }, { "docid": "7f54a583ce111b6027658530a68eb865", "score": "0.5836827", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();\n }", "title": "" }, { "docid": "f51829326568eaede7107a3cf4b2f181", "score": "0.58297604", "text": "function search(arr, value) {\n\tfor (let i =0; i<arr.length; i++) {\n\t\tif (arr[i].name === value) {\n\t\t\treturn arr[i];\n\t\t}\n\t}\n\treturn null;\n}", "title": "" }, { "docid": "8ad3c9fb6b5fbbe8e09a94e0c59e8ebd", "score": "0.5779916", "text": "function get_id_from_option_value( value ) {\n var pattern = new RegExp( '^[0-9]+/([0-9]+)$' );\n var matches = pattern.exec( value );\n return matches.length > 1 ? matches[1] : NULL;\n}", "title": "" }, { "docid": "07388273d3af0d71caee1152523e7264", "score": "0.57682705", "text": "function $value(value) {\n\t function hasReplaceVal(val) {\n\t return function (obj) {\n\t return obj.from === val;\n\t };\n\t }\n\t function $replace(value) {\n\t var replacement = map(filter(self.replace, hasReplaceVal(value)), function (obj) {\n\t return obj.to;\n\t });\n\t return replacement.length ? replacement[0] : value;\n\t }\n\t value = $replace(value);\n\t return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n\t }", "title": "" }, { "docid": "e9c402ac37340f08d5d98da42a0dcbf7", "score": "0.57634896", "text": "function findMatchingOption(el, value) {\n if (el) {\n for (var i = 0, l = el.options.length; i < l; i++) {\n var option = el.options[i];\n if (option && DOM.getAttribute(option, \"value\") === value) {\n return option;\n }\n }\n }\n return null;\n }", "title": "" }, { "docid": "dcbbe57c4cbd26d0ec0ce8e6ca532c8c", "score": "0.5748267", "text": "function getValue(value){\n return value;\n}", "title": "" }, { "docid": "3ee8b143b50e67b1965e42a70d21762b", "score": "0.57451177", "text": "function findNode(value, node) {\n if (value === node.value)\n return node;\n for (const child of node.children) {\n const node = findNode(value, child);\n if (node)\n return node;\n }\n return null;\n}", "title": "" }, { "docid": "3ee8b143b50e67b1965e42a70d21762b", "score": "0.57451177", "text": "function findNode(value, node) {\n if (value === node.value)\n return node;\n for (const child of node.children) {\n const node = findNode(value, child);\n if (node)\n return node;\n }\n return null;\n}", "title": "" }, { "docid": "3ee8b143b50e67b1965e42a70d21762b", "score": "0.57451177", "text": "function findNode(value, node) {\n if (value === node.value)\n return node;\n for (const child of node.children) {\n const node = findNode(value, child);\n if (node)\n return node;\n }\n return null;\n}", "title": "" }, { "docid": "3ee8b143b50e67b1965e42a70d21762b", "score": "0.57451177", "text": "function findNode(value, node) {\n if (value === node.value)\n return node;\n for (const child of node.children) {\n const node = findNode(value, child);\n if (node)\n return node;\n }\n return null;\n}", "title": "" }, { "docid": "e3358227177fd05db39ee8d87e4925b2", "score": "0.57411635", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "afcababe8195ab7d5f88888f2fa2132d", "score": "0.5697294", "text": "function lookup( path ) {\n\t\t\tvar i, re,\n\t\t\t\tdata = properties[ path.join( \"/\" ) ];\n\n\t\t\tfor ( i in data ) {\n\t\t\t\tre = new RegExp( \"^\" + data[ i ] );\n\t\t\t\tif ( re.test( value ) ) {\n\t\t\t\t\ttoken.value = i;\n\t\t\t\t\treturn tokenRe = new RegExp( data[ i ] );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}", "title": "" }, { "docid": "afb51d9d37bd83ba5567dcc6b6471ba8", "score": "0.569649", "text": "function $value(value) {\n\t function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n\t function $replace(value) {\n\t var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n\t return replacement.length ? replacement[0] : value;\n\t }\n\t value = $replace(value);\n\t return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n\t }", "title": "" }, { "docid": "afb51d9d37bd83ba5567dcc6b6471ba8", "score": "0.569649", "text": "function $value(value) {\n\t function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n\t function $replace(value) {\n\t var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n\t return replacement.length ? replacement[0] : value;\n\t }\n\t value = $replace(value);\n\t return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n\t }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "021702f0a9d17147d83c17ffbbe9e083", "score": "0.5686962", "text": "function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }", "title": "" }, { "docid": "8e8b8159d170f31bdec5a5f66c10c2a5", "score": "0.5684975", "text": "function getValue(value) {\n\n if (value == \"exclusion\" || value == \"exclusions\") {\n value = \"EXCLUSION\";\n }\n else if (value == \"inclusion\" || value == \"inclusions\" || value == \"garanties\") {\n value = \"INCLUSION\";\n }\n else if (value == \"option\" || value == \"options\" || value == \"garanties supplémentaires\") {\n value = \"OPTION\";\n }\n else if (value == \"plafond\" || value == \"plafonds\") {\n value = \"PLAFOND\";\n }\n else if (value == \"formule\" || value == \"formules\") {\n value = \"FORMULE\";\n }\n else if (value == \"formule Eco\" || value == \"Eco\") {\n value = \"ECO\";\n }\n else if (value == \"formule Confort\" || value == \"Confort\") {\n value = \"CONFORT\";\n }\n else if (value == \"formule Excellence\" || value == \"Excellence\") {\n value = \"EXCELLENCE\";\n }\n return value;\n}", "title": "" }, { "docid": "3e79bf3a6fe3604fdf2f48a2a9069352", "score": "0.5676371", "text": "function findKey (obj, value) {\n for (let key of Object.keys(obj)) {\n if (obj[key].V.get()[0] === value) {\n return key;\n }\n }\n\n return null;\n}", "title": "" }, { "docid": "41607ccefe1591f266a5f8ff193365a8", "score": "0.56388813", "text": "function find(value) {\n if(!value) return;\n var found;\n if(!options.groupKey && scope.items){\n found = scope.items.filter(function (item){\n return item.value === value;\n })[0];\n } else {\n angular.forEach(scope.items, function (group) {\n if(!found) {\n found = group.items.filter(function(item) {\n return item.value === value;\n })[0];\n }\n });\n\n }\n return found;\n }", "title": "" }, { "docid": "0110943956e5cf2caf76c2ce85960558", "score": "0.553927", "text": "function getKeyByValue(object, value) {\n for (var key in object){\n if (object[key].includes(value)) {\n\n return(key)\n }\n // return Object.keys(object).find(key => object[key].value === value);\n }\n }", "title": "" }, { "docid": "9385d8431623c3fb815f321ecec4c1f4", "score": "0.5537722", "text": "find(value, parent = this.root) {\n // loop through every letter in the value\n for (let i = 0; i < value.length; i++){\n //\n parent = parent.children.find(child => child.value[i] === value[i]);\n\n if (!parent){\n return null;\n }\n }\n return parent;\n }", "title": "" }, { "docid": "098dc135c09f2e2570c37cdca110c1b1", "score": "0.55313855", "text": "_iterativeFindValue( key, cb )\n\t{\n\t\tlet callback = cb || function() {};\n\n\t\t//\t...\n\t\tthis._iterativeFind( key, 'VALUE', function( err, type, result )\n\t\t{\n\t\t\tif ( type === 'VALUE' )\n\t\t\t{\n\t\t\t\tcallback( null, result );\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcallback\n\t\t\t\t(\n\t\t\t\t\t{\n\t\t\t\t\t\t'code': 'NOTFOUND',\n\t\t\t\t\t\t'key': key\n\t\t\t\t\t},\n\t\t\t\t\tnull\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "cd529aec5dac28634fb3403d018a26f3", "score": "0.552081", "text": "getIndexFromValue(value) {\n if (value === null || this.state.options === undefined || this.state.options === null) return null;\n\n return this.state.options.findIndex((option) => {\n return option.props.value === value;\n });\n }", "title": "" }, { "docid": "5c86e6992702d7b3c029fc3a39192bdd", "score": "0.55093634", "text": "search(value) {\n let currentNode = this.head;\n while (currentNode) {\n if (currentNode.value === value) {\n return currentNode;\n }\n currentNode = currentNode.next;\n }\n return null;\n }", "title": "" }, { "docid": "4f5e90c980fd4d82dc07499173f65f22", "score": "0.54621905", "text": "function getValueNonLocation(positionProfile, series)\r\n{\r\n var match = \"\";\r\n var things = series[\"dataRow\"][0][\"data\"][\"generic.SeriesKey\"][\"generic.Value\"];\r\n\r\n for (i = 0; i < things.length; i++)\r\n {\r\n if(things[i][\"@concept\"] == firstColumn[positionProfile])\r\n {\r\n match = (things[i][\"@value\"]);\r\n break;\r\n }\r\n }\r\n return match;\r\n}", "title": "" }, { "docid": "f65ea7e23d30eda5e17f6c3b62cf5a5f", "score": "0.54615283", "text": "findValueByIdentifier(identifier, values) {\n for (let value of values) {\n if (value instanceof mdls.IdentifiableValue && value.possibleIdentifiers.some(pid => pid.equals(identifier))) {\n // If the identifier isn't the value's direct identifier or effective identifier, it's\n // probably from an includes type. Check for that case.\n if (!identifier.equals(value.identifier) && !identifier.equals(value.effectiveIdentifier)) {\n for (const itc of value.constraintsFilter.includesType.constraints) {\n if (itc.path.length == 0 && itc.isA.equals(identifier)) {\n // It did resolve from an includes type, so return a value referencing the includes type instead!\n // Remove any of the direct type-ish constraints and card constraints since we're setting type & card\n const constraintsToCopy = value.constraints.filter(c => {\n return c.path.length === 0\n && !(c instanceof mdls.IncludesTypeConstraint)\n && !(c instanceof mdls.TypeConstraint)\n && !(c instanceof mdls.CardConstraint);\n });\n value = new mdls.IdentifiableValue(itc.isA).withCard(itc.card).withConstraints(constraintsToCopy);\n // Apply special marker used only in FHIR Exporter. There is probably a more elegant way, but the\n // alternative right now seems to require a ton of code\n value._derivedFromIncludesTypeConstraint = true;\n break;\n }\n }\n }\n return value;\n } else if (value instanceof mdls.ChoiceValue) {\n // First check to see if there is a type constraint to make this a single value type\n const typeConstrained = value.constraintsFilter.own.type.constraints.some(c => c.isA.equals(identifier));\n\n let opt = this.findValueByIdentifier(identifier, value.options);\n if (typeof opt !== 'undefined') {\n // We need to modify cardinality to:\n // (a) use the choice's cardinality, because choice options are now ALWAYS 1..1\n // (b) set min to 0 if there are multiple options (since it will have 0 instances if not selected)\n opt = opt.clone().withCard(value.effectiveCard.clone());\n if (value.options.length > 1 && !typeConstrained) {\n opt.card.min = 0;\n }\n return this.mergeConstraintsToChild(value.constraints, opt);\n }\n }\n }\n }", "title": "" }, { "docid": "abd4d3124bd0b876c5173bf66d957db5", "score": "0.54504794", "text": "function getKey(value){\n if(value){\n let key = value.toString();\n value.trim().toLowerCase();\n return value;\n }\n return undefined;\n }", "title": "" }, { "docid": "9004418403cc1a736c132b9afe249a13", "score": "0.54440266", "text": "function getKeyByValue(object, value) { // helper function to get keys from object\n\tfor(var key in object) {\n\t\tif (object[key] == value) {\n\t\t\treturn key;\n\t\t}\n\t}\n\n\treturn null;\n}", "title": "" }, { "docid": "95cc375234c3b0175e2ab333c111fc31", "score": "0.54166305", "text": "getReferenceStringForValue(val) {\n return Object.entries(this.data).find(([k, v]) => v === val)[0] // note that === is pointer comparison\n }", "title": "" }, { "docid": "437e89e9c9da9bc3f55b20ab4c4ea346", "score": "0.5378077", "text": "function find( value, array ){\n let found = false\n for ( let x=0; x<array.length; x++ ) {\n if (array[x] === value) found = true\n }\n return found\n}", "title": "" }, { "docid": "09cacd234b26cc675d012def3576b897", "score": "0.5367674", "text": "find(value, node = this.root) {\n if (node === null) return null;\n if (node.value === value) return node;\n if (value < node.value) return this.find(value, node.left);\n if (value > node.value) return this.find(value, node.right);\n }", "title": "" }, { "docid": "504607bdc7c3643608132d311c239b4a", "score": "0.5358811", "text": "function thingTypeLookup(value) {\n let thingType = '';\n\n switch (value) {\n case 0x00:\n thingType = 'thing';\n break;\n case 0x01:\n thingType = 'onOffSwitch';\n break;\n case 0x02:\n thingType = 'multilevelSwitch';\n break;\n case 0x03:\n thingType = 'binarySensor';\n break;\n case 0x04:\n thingType = 'multilevelSensor';\n break;\n case 0x05:\n thingType = 'smartPlug';\n break;\n case 0x06:\n thingType = 'onOffLight';\n break;\n case 0x07:\n thingType = 'dimmableLight';\n break;\n case 0x08:\n thingType = 'onOffColorLight';\n break;\n case 0x09:\n thingType = 'dimmableColorLight';\n break;\n default:\n thingType = 'unknown';\n break;\n }\n return thingType;\n}", "title": "" }, { "docid": "bfb3691f57d58ff38ef710ae950f2dcd", "score": "0.5355094", "text": "value(value) {\n if (this.isMultiValue(value)) {\n return value; // if multi value the returns the full array\n }\n if (value) return value.value; // if single value then returns the id/value\n\n return undefined; // otherwise return undefined\n }", "title": "" }, { "docid": "88e088d198f98c737b716151f3873cea", "score": "0.53440523", "text": "function $value(id)\n{\n\tvar el = $id(id);\n\tif(el != null)\n\t{\n\t\treturn el.value;\n\t}\n\telse\n\t{\n\t\tlogs(\"$value : \" + id + \" : doesn't exist\",false,'WARNING');\n\t}\n}", "title": "" }, { "docid": "0433ab89a608ca50f4f4d934a5ec6bc8", "score": "0.5331262", "text": "function findNode(value, node) {\n var e_1, _a;\n if (value === node.value)\n return node;\n try {\n for (var _b = __values(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {\n var child = _c.value;\n var node_1 = findNode(value, child);\n if (node_1)\n return node_1;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return null;\n}", "title": "" }, { "docid": "daaaac0ab78f51a9a3c3b62bab13f7a7", "score": "0.53257805", "text": "findMessageByValue(value){\n for (let msg of this.messages.values()) {\n if (msg === value) return msg;\n }\n }", "title": "" }, { "docid": "eb479154efb49eec00be4ea10263f408", "score": "0.53201604", "text": "findValueByPath(path, def, valueOnly=false, parentConstraints=[]) {\n if (path.length == 0) {\n return;\n }\n\n const fieldsToSearch = [];\n if (typeof def.value !== 'undefined') {\n fieldsToSearch.push(this.mergeConstraintsToChild(parentConstraints, def.value, true));\n }\n if (!valueOnly) {\n fieldsToSearch.push(...(def.fields.map(f => this.mergeConstraintsToChild(parentConstraints, f, false))));\n }\n // Find the value at the root of the path\n let value = this.findValueByIdentifier(path[0], fieldsToSearch);\n\n // Some special case logic for _Concept (implicit field)\n if (typeof value === 'undefined' && path[0].isConceptKeyWord) {\n if (path.length == 1) {\n // This is the end of the path, so just give them a 1..1 CodeableConcept\n const conceptValue = new mdls.IdentifiableValue(CONCEPT_ID).withMinMax(1, 1);\n if (def.concepts.length == 1) {\n // Add code constraint\n conceptValue.addConstraint(new mdls.CodeConstraint(def.concepts[0]));\n } else if (def.concepts.length > 1) {\n // Update the card to be n to many and add includesCode constraints\n conceptValue.card = new mdls.Cardinality(def.concepts.length);\n for (const c of def.concepts) {\n conceptValue.addConstraint(new mdls.IncludesCodeConstraint(c));\n }\n }\n return conceptValue;\n } else {\n //13061, `Mapping ${pathName1} sub-fields is currently not supported.' , 'Unknown' , 'errorNumber'\n logger.error({pathName1 : path[0].name }, '13061');\n }\n }\n\n // If we didn't find the value, it could be one of those cases where we replaced the original identifier with\n // an includesType identifier, so we should check the constraints to look for a match on the includesType.\n if (typeof value === 'undefined' && parentConstraints.length > 0) {\n const cf = new mdls.ConstraintsFilter(parentConstraints);\n for (const itc of cf.includesType.constraints) {\n if (itc.path.length == 1 && itc.isA.equals(path[0])) {\n\n value = this.findValueByIdentifier(itc.path[0], fieldsToSearch);\n if (typeof value !== 'undefined') {\n value = new mdls.IdentifiableValue(itc.isA).withCard(itc.card).withConstraints(value.constraints);\n // Apply special marker used only in FHIR Exporter. There is probably a more elegant way, but the\n // alternative right now seems to require a ton of code\n value._derivedFromIncludesTypeConstraint = true;\n }\n }\n }\n }\n\n if (typeof value !== 'undefined') {\n //value = this.mergeConstraintsToChild(parentConstraints, value, isValueField);\n } else {\n return; // invalid path\n }\n\n if (path.length == 1) {\n return value; // this was the tail of the path\n }\n\n // We're not at the end of the path, so we must dig deeper\n def = this._specs.dataElements.findByIdentifier(common.choiceFriendlyEffectiveIdentifier(value));\n if (typeof def === 'undefined') {\n return; // invalid path\n }\n\n // First see if we can continue the path by traversing the value\n if (typeof def.value !== 'undefined') {\n const subValue = this.findValueByPath(path.slice(1), def, true, value.constraints);\n if (typeof subValue !== 'undefined') {\n return this.mergeConstraintsToChild(value.constraints, subValue, true);\n }\n }\n\n // Still haven't found it, so traverse the rest\n const subValue = this.findValueByPath(path.slice(1), def, false, value.constraints);\n if (typeof subValue !== 'undefined') {\n return subValue;\n }\n }", "title": "" }, { "docid": "ad928600720bc16434ee8434e05421e9", "score": "0.53078014", "text": "function matchValue(r, v) {\n var failureResult = null;\n\n var vs = [v];\n var stack = [[]];\n\n while (!is_emptyMatcher(r)) {\n\tif (r instanceof $WildcardSequence) {\n\t if (stack.length === 0) return failureResult;\n\t vs = stack.pop();\n\t r = r.matcher;\n\t continue;\n\t}\n\n\tif (r instanceof $Success) {\n\t if (vs.length === 0 && stack.length === 0) return r.value;\n\t return failureResult;\n\t}\n\n\tif (vs.length === 0) {\n\t if (stack.length === 0) return failureResult;\n\t vs = stack.pop();\n\t r = r.get(EOA);\n\t continue;\n\t}\n\n\tvar v = vs.shift();\n\n\tif (typeof v === 'string' && v.substring(0, 2) === '__') {\n\t die(\"Cannot match special string starting with __\");\n\t}\n\n\tif (Array.isArray(v)) {\n\t if (SOA in r.entries) {\n\t\tr = r.get(SOA);\n\t\tstack.push(vs);\n\t\tvs = shallowCopyArray(v);\n\t } else {\n\t\tr = r.get(__);\n\t }\n\t} else {\n\t var key;\n\t try {\n\t\tkey = JSON.stringify(v);\n\t } catch (exn) {\n\t\t// For example, v might be cyclic, as in DOM events.\n\t\tkey = null;\n\t }\n\t if (key in r.entries) {\n\t\tr = r.get(key);\n\t } else {\n\t\tr = r.get(__);\n\t }\n\t}\n }\n\n return failureResult;\n}", "title": "" }, { "docid": "e5198241086b3339e63207e53212734a", "score": "0.53049684", "text": "function getKeyByValue(object, value) {\n\t return Object.keys(object).find(key => object[key] === value);\n\t}", "title": "" }, { "docid": "f1557ceb3e5b6feaf22ad2911f134df9", "score": "0.53003883", "text": "function getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value);\n }", "title": "" }, { "docid": "f70c954bfcfa9e0f9fd105bb02c9727e", "score": "0.52968955", "text": "function findValue(array, name) {\n for (var i = 0; i<array.length; i++) {\n if(array[i][0] === name) return array[i][1];\n }\n return -1;\n}", "title": "" }, { "docid": "2d044485cbc3de5be32b09212098f960", "score": "0.5283555", "text": "find(value) {\n let current = this.root;\n while (current) {\n if (value === current.value) return current;\n else if (value < current.value) current = current.left;\n else current = current.right;\n }\n }", "title": "" }, { "docid": "2a1edbe02871ceb9a616e268f05d5c48", "score": "0.52770543", "text": "function is(value) {\r\n var candidate = value;\r\n return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));\r\n }", "title": "" }, { "docid": "e21dbd5924b4bccb3519f715825d4712", "score": "0.5273776", "text": "function findValue(arr, val) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i].value === val) {\n return i;\n }\n }\n return false;\n }", "title": "" }, { "docid": "a7167a1ffe7d5f1d044a2cadcb912171", "score": "0.5268366", "text": "function getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value);\n }", "title": "" }, { "docid": "258df031dd034829ecdbd8825f7e74f6", "score": "0.52668285", "text": "function is(value) {\n var candidate = value;\n return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));\n }", "title": "" }, { "docid": "258df031dd034829ecdbd8825f7e74f6", "score": "0.52668285", "text": "function is(value) {\n var candidate = value;\n return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));\n }", "title": "" }, { "docid": "50f4b1d040bb5c220bf4ab9c3163f310", "score": "0.5251124", "text": "function validate(value) {\n\n\t\tvar search_type = 0;\n\n \t\tif (validate_email(value)) {\n \t\t\tsearch_type = \"email\";\n \t\t} else if (validate_mongoid(value)) {\n \t\t\tsearch_type = \"id\";\n \t\t}\n\n\t\treturn [search_type != 0, search_type, value];\n \t}", "title": "" }, { "docid": "94041a97d154f482f84d060b957e3994", "score": "0.5247405", "text": "function getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value);\n }", "title": "" }, { "docid": "33fb6bb025ec5d08ac50efd11e0f4260", "score": "0.52414125", "text": "lookup(value){\n // if the tree is empty\n if(!this.root) return false\n let curr = this.root\n while(curr){\n if(value===curr.value) return curr\n else if(value<curr.value) curr = curr.left\n else curr = curr.right\n }\n // when value is not found\n return false\n }", "title": "" }, { "docid": "f041f05cf173f7e7e735afe6cabc0e92", "score": "0.5229415", "text": "find(value) {\n let counter = 0;\n let currentNode = this.head;\n while (currentNode.value !== value && currentNode) {\n //while curr value is not equal to target value and curr node exists\n currentNode = currentNode.next;\n counter++;\n }\n return counter >= 0 ? counter : -1;\n }", "title": "" }, { "docid": "6f170b343ebdad4d5bfa4968984c3e43", "score": "0.52217096", "text": "findMessageByValue(val) {\n\t\tfor (let [ key, value ] of this.messages.entries()) {\n\t\t\tif (value === val) return val;\n\t\t}\n\t}", "title": "" }, { "docid": "d98541a4d31b5f6bcda359443a03a8e3", "score": "0.5207153", "text": "getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value);\n }", "title": "" }, { "docid": "d8e479327cc91a1de406283c57a903d5", "score": "0.52033633", "text": "function findNode(value, node) {\n if (value === node.value) return node;\n\n var _iterator12 = _createForOfIteratorHelper(node.children),\n _step12;\n\n try {\n for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {\n var child = _step12.value;\n\n var _node = findNode(value, child);\n\n if (_node) return _node;\n }\n } catch (err) {\n _iterator12.e(err);\n } finally {\n _iterator12.f();\n }\n\n return null;\n } // Return the path to the node with the given value using DFS", "title": "" }, { "docid": "2e1dc3ffbab6cf1ce11dcbc001f4c0f7", "score": "0.51941293", "text": "function read (value) {\n if (value instanceof RegExp) {\n var chars = source.slice(index)\n var match = chars.match(value)\n if (match) {\n index += match[0].length\n return match[0]\n }\n } else {\n if (source.indexOf(value, index) === index) {\n index += value.length\n return value\n }\n }\n }", "title": "" }, { "docid": "2e1dc3ffbab6cf1ce11dcbc001f4c0f7", "score": "0.51941293", "text": "function read (value) {\n if (value instanceof RegExp) {\n var chars = source.slice(index)\n var match = chars.match(value)\n if (match) {\n index += match[0].length\n return match[0]\n }\n } else {\n if (source.indexOf(value, index) === index) {\n index += value.length\n return value\n }\n }\n }", "title": "" }, { "docid": "2e1dc3ffbab6cf1ce11dcbc001f4c0f7", "score": "0.51941293", "text": "function read (value) {\n if (value instanceof RegExp) {\n var chars = source.slice(index)\n var match = chars.match(value)\n if (match) {\n index += match[0].length\n return match[0]\n }\n } else {\n if (source.indexOf(value, index) === index) {\n index += value.length\n return value\n }\n }\n }", "title": "" }, { "docid": "2e1dc3ffbab6cf1ce11dcbc001f4c0f7", "score": "0.51941293", "text": "function read (value) {\n if (value instanceof RegExp) {\n var chars = source.slice(index)\n var match = chars.match(value)\n if (match) {\n index += match[0].length\n return match[0]\n }\n } else {\n if (source.indexOf(value, index) === index) {\n index += value.length\n return value\n }\n }\n }", "title": "" }, { "docid": "2e1dc3ffbab6cf1ce11dcbc001f4c0f7", "score": "0.51941293", "text": "function read (value) {\n if (value instanceof RegExp) {\n var chars = source.slice(index)\n var match = chars.match(value)\n if (match) {\n index += match[0].length\n return match[0]\n }\n } else {\n if (source.indexOf(value, index) === index) {\n index += value.length\n return value\n }\n }\n }", "title": "" }, { "docid": "e85c60383f85a95373ebd66b2ddce3cd", "score": "0.51932293", "text": "function findNode(value, node) {\n var e_1, _a;\n if (value === node.value)\n return node;\n try {\n for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__values\"])(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {\n var child = _c.value;\n var node_1 = findNode(value, child);\n if (node_1)\n return node_1;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return null;\n}", "title": "" }, { "docid": "e85c60383f85a95373ebd66b2ddce3cd", "score": "0.51932293", "text": "function findNode(value, node) {\n var e_1, _a;\n if (value === node.value)\n return node;\n try {\n for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__values\"])(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {\n var child = _c.value;\n var node_1 = findNode(value, child);\n if (node_1)\n return node_1;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return null;\n}", "title": "" }, { "docid": "e85c60383f85a95373ebd66b2ddce3cd", "score": "0.51932293", "text": "function findNode(value, node) {\n var e_1, _a;\n if (value === node.value)\n return node;\n try {\n for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__[\"__values\"])(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {\n var child = _c.value;\n var node_1 = findNode(value, child);\n if (node_1)\n return node_1;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return null;\n}", "title": "" }, { "docid": "e4c937f8a51461d2f913f90e570a26e9", "score": "0.51828784", "text": "function getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value)\n}", "title": "" }, { "docid": "9a5e8ca66b8073493dd0fa33ddbc86af", "score": "0.5173151", "text": "function resolvePathValue(path) {\n const { value, confident, deopt } = path.evaluate();\n if (confident) return value;\n throw deopt.buildCodeFrameError('Could not evaluate value');\n}", "title": "" }, { "docid": "045e3b23397a033acab9f0623dda5619", "score": "0.51665944", "text": "function find (node, value) {\n if (!value || node === null) {\n return false;\n } else {\n let current = node;\n let parent = node;\n\n while (true) {\n if (parent.value === value) {\n return true;\n }\n\n if (value < parent.value) {\n current = parent.leftNode;\n if (current === null) {\n return false;\n } else {\n parent = current;\n }\n } else {\n current = parent.rightNode;\n if (current === null) {\n return false;\n } else {\n parent = current;\n }\n }\n }\n }\n\n }", "title": "" }, { "docid": "6646ae6d37cc41f4059106097b5e4f65", "score": "0.51562655", "text": "function phoneticLookup(val) {\n var result = \"\";\n\n var lookup = {\n alpha: \"Adams\",\n bravo: \"Boston\",\n charlie: \"Chicago\",\n delta: \"Denver\",\n echo: \"Easy\",\n foxtrot: \"Frank\"\n };\n result = lookup[val];\n return result;\n}", "title": "" }, { "docid": "283ea9e1bbab9447769f99fc2e911cc8", "score": "0.5155694", "text": "function getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value);\n}", "title": "" }, { "docid": "e5ac9c19fc0c9629734e8e33eb1d27eb", "score": "0.5153591", "text": "function findBook(key, value) {\n console.log(`${key} : ${value}`);\n var i, len = value.length;\n \n for (i = 0; i < len; i++) {\n if (value[i] && value[i].hasOwnProperty(key)) {\n return value[i][key];\n }\n }\n \n return -1;\n }", "title": "" }, { "docid": "57235d181ca2dd15e8259d3c7b8879a7", "score": "0.51511276", "text": "function _getValueIDByObjectName(objectName, value) {\n if (_autocompleteData && _autocompleteData[\"Values\"]) {\n var acData = _autocompleteData[\"Values\"];\n for (var acKey in acData) {\n if (acKey === 'length' || !acData.hasOwnProperty(acKey)) continue;\n if (acData[acKey][\"Name\"] == objectName || acData[acKey][\"RelatedEntityName\"] == objectName) {\n return acData[acKey][\"InvertedValues\"][value];\n }\n }\n }\n\n return null;\n }", "title": "" }, { "docid": "cf35335ebbfee874befe2bbb781ae8d1", "score": "0.5145497", "text": "function getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value);\n}", "title": "" }, { "docid": "cf35335ebbfee874befe2bbb781ae8d1", "score": "0.5145497", "text": "function getKeyByValue(object, value) {\n return Object.keys(object).find(key => object[key] === value);\n}", "title": "" }, { "docid": "488323e29d552642033291303bcf758a", "score": "0.51416624", "text": "function phoneticLookup(val) {\n var result = \"\";\n var lookup = {\n alpha: \"Adams\",\n bravo: \"Boston\",\n charlie: \"Chicago\",\n delta: \"Denver\",\n echo: \"Easy\",\n foxtrot: \"Frank\"\n };\n result = lookup[val];\n return result;\n}", "title": "" } ]
fe77496304396341997a64958707c732
Expend Contact list Function start / Function extend content for mission
[ { "docid": "9c548dfea24ad10dc1adeb5653151f9f", "score": "0.5194228", "text": "function fn_extndcontformission(scheduleid) {\n var dataparam = \"oper=loadmissionextendcontent&scheduleid=\"+scheduleid+\"&missionid=\"+$('#misionid').val()+\"&licenseid=\"+$('#licenseid').val();\n $.ajax({\n\t\ttype: 'post',\n\t\turl: \"class/newclass/class-newclass-classajax.php\",\n\t\tdata: dataparam,\n\t\tbeforeSend: function(){\t\t\t\n\t\t},\n\t\tsuccess:function(data) {\n\n\t\t\t$('#missionextendcontent').html(data);\n }\n\t\t\n\t});\t\n }", "title": "" } ]
[ { "docid": "4bf48d05cbd751601e951330fd4520b8", "score": "0.61222214", "text": "function contacts(app) {\n var department = app.getArgument('hr_contact_info');\n var comm = app.getArgument('info_type');\n if (department == \"general\") {\n app.ask(\"General inquires can be emailed to [email protected].\");\n }\n else if (department == \"HR & Payroll\") {\n if (comm == \"phone\") {\n app.ask(\"The phone number for the \" + department + ' department is (808) 956-3100.');\n }\n else if (comm == \"email\") {\n app.ask(\"The email address for the \" + department + \" department is [email protected].\");\n }\n else if (comm == \"mailing\") {\n app.ask(\"The mailing address for the \" + department + ` department is:\\n1601 East-West Road Burns Hall 4th Floor, Makai Wing\\nHonolulu, HI 96848.`);\n }\n }\n else if (department == \"Disbursing/Procurement\") {\n if (comm == \"phone\") {\n app.ask(\"The phone number for the \" + department + ' department is (808) 956-3608.');\n }\n else if (comm == \"email\") {\n app.ask(\"I'm sorry, but the \" + department + \" department doesn't have an email address.\");\n }\n else if (comm == \"mailing\") {\n app.ask(\"The mailing address for the \" + department + \" department is:\\n1601 East-West Road Burns Hall, Room 4020\\nHonolulu, HI 96848.\");\n }\n }\n else if (department == \"Accounting & Project Admin\") {\n if (comm == \"phone\") {\n app.ask(\"The phone number for the \" + department + \" department is (808) 988-8300.\");\n }\n else if (comm == \"email\") {\n app.ask(\"I'm sorry, but the \" + department + \" department doesn't have an email address.\");\n }\n else if (comm == \"mailing\") {\n app.ask(\"The mailing address for the \" + department + \" department is:\\n2800 Woodlawn Drive, Suite 200\\nHonolulu, HI 96822.\")\n }\n }\n else if (department == \"Executive Director\") {\n if (comm == \"phone\") {\n app.ask(\"The phone number for the \" + department + \" department is (808) 988-8311\");\n }\n else if (comm == \"email\") {\n app.ask(\"I'm sorry, but the \" + department + \" department doesn't have an email address.\");\n }\n else if (comm == \"mailing\") {\n app.ask(\"The mailing address for the \" + department + \" department is:\\n2800 Woodlawn Drive, Suite 200\\nHonolulu, HI 96822.\");\n }\n }\n else if (department == \"Corporate Services\") {\n if (comm == \"phone\") {\n app.ask(\"The phone number for the \" + department + \" department is (808) 988-8314.\");\n }\n else if (comm == \"email\") {\n app.ask(\"I'm sorry, but the \" + department + \" department doesn't have an email address.\");\n }\n else if (comm == \"mailing\") {\n app.ask(\"The mailing address for the \" + department + \" department is:\\n2800 Woodlawn Drive, Suite 200\\nHonolulu, HI 96822.\");\n }\n }\n }", "title": "" }, { "docid": "78b61869ade56fca46fc21c8f820f8c3", "score": "0.5928911", "text": "function contactPageWrapper(){\n generateRandMessage();\n displayOpportunities();\n}", "title": "" }, { "docid": "10a8c2068750a99c70c0a3254c9ff91a", "score": "0.57723457", "text": "function refreshContactList() {\r\n\t\r\n\tvar contactListLoader = new net.ContentLoader('process/list_contact.php', getContactList, showError, 'POST', '', 'application/xml');\r\n\t\r\n\t\r\n}", "title": "" }, { "docid": "d22ca4c3e9dae54673b25057727b1e82", "score": "0.57668686", "text": "function mostrasLista() {\n\tclear(agendados);\n\tif(listaContactos.length == 0){\n\t\trender(ej2)\n\t};\n\trender(listaContactos);\n}", "title": "" }, { "docid": "087898af8c265de34312a1a3d4a9684f", "score": "0.56084937", "text": "function preLoadContactList() {\r\n\t\r\n\tvar contactPreLoader = new net.ContentLoader('process/list_contact.php', loadContactList, showError, 'POST', '', 'application/xml');\r\n\t\r\n\t\r\n}", "title": "" }, { "docid": "58dd816480e6cfb083f4f1706487e608", "score": "0.55827147", "text": "function contactAddingToPages(){\n\t\t\n\t\t//console.info('You are here');\n\t\t\n\t\tvar contact\t=\tdocument.getElementById(\"contact\");\n\t\t\n\t\tif(\tcontact){\n\t\t\t\t\t\t\t\t\n\t\t\tcontact.innerHTML\t=\t\n\t\t\t\n\t\t\t\t'<div class=\"container-fluid\">\\\n\t\t\t\t\t<div class=\"row p-t-1\">\\\n\t\t\t\t\t\t<div class=\"col-lg-2 col-md-2 col-sm-0 col-xs-0\"></div>\\\n\t\t\t\t\t\t<div class=\"col-lg-3 col-md-3 col-sm-12 col-xs-12\">\\\n\t\t\t\t\t\t\t<div class=\"container-fluid\">\\\n\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center\">\\\n\t\t\t\t\t\t\t\t\t\t<h3 class=\"section-heading\">Contacts:</h3>\\\n\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t<div class=\"row p-t-2\">\\\n\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 text-left\">\\\n\t\t\t\t\t\t\t\t\t\t<p class=\"m-t-0-em m-b-0-em p-t-0p5-em p-b-0p5-em verticalAlignParent\">\\\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-phone fa-2x sr-contact\" data-toggle=\"tooltip\" title=\"Phone\" data-placement=\"top\"></i>&nbsp;\\\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-phone-square fa-2x sr-contact\" data-toggle=\"tooltip\" title=\"Viber\" data-placement=\"top\"></i>&nbsp;\\\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-telegram fa-2x sr-contact\" data-toggle=\"tooltip\" title=\"Telegram\" data-placement=\"top\"></i>&nbsp;\\\n\t\t\t\t\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;<span class=\"verticalAlignChild\">\\\n\t\t\t\t\t\t\t\t\t\t\t+1 650 7410014<br />\\\n\t\t\t\t\t\t\t\t\t\t\t</span></p>\\\n\t\t\t\t\t\t\t\t\t\t<p class=\"m-t-0-em m-b-0-em p-t-0p5-em p-b-0p5-em verticalAlignParent\">\\\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-skype fa-2x sr-contact\" data-toggle=\"tooltip\" title=\"Skype\" data-placement=\"top\"></i>\\\n\t\t\t\t\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;<span class=\"verticalAlignChild\">rootstem</span></p>\\\n\t\t\t\t\t\t\t\t\t\t<p class=\"m-t-0-em m-b-0-em p-t-0p5-em p-b-0p5-em verticalAlignParent\">\\\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-envelope-o fa-2x sr-contact\" data-toggle=\"tooltip\" title=\"Email\" data-placement=\"top\"></i>\\\n\t\t\t\t\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;<span class=\"verticalAlignChild\">[email protected]</span>\\\n\t\t\t\t\t\t\t\t\t\t\t<!-- <img class=\"h-m-1p5\" src=\"http://arbir.ru/images/icons/at_sign_14102501.jpg\"\\\n\t\t\t\t\t\t\t\t\t\t\t> --></p>\\\n\t\t\t\t\t\t\t\t\t\t<div class=\"m-t-0-em m-b-0-em p-t-0p5-em p-b-0p5-em verticalAlignParent\">\\\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-whatsapp fa-2x sr-contact\" data-toggle=\"tooltip\" title=\"WhatsApp\" data-placement=\"top\"></i>&nbsp;\\\n\t\t\t\t\t\t\t\t\t\t\t&nbsp;&nbsp;&nbsp;<span class=\"verticalAlignChild\">+7 9126619279\\\n\t\t\t\t\t\t\t\t\t\t\t<!-- <s>+7 912 6619279</s> --></span>\\\n\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 text-left\">\\\n\t\t\t\t\t\t\t\t\t\t<img src=\"http://r1.userto.com/img/_VVS3415-crop.png\" \\\n\t\t\t\t\t\t\t\t\t\tclass=\"img-responsive img-thumbnail h-m-15\" ' + ' >\\\n\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t<div class=\"col-lg-5 col-md-5 col-sm-12 col-xs-12\">\\\n\t\t\t\t\t\t\t<div class=\"container-fluid\">\\\n\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center\">\\\n\t\t\t\t\t\t\t\t\t\t<h4 class=\"section-heading\">You have a question?</h4>\\\n\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center\">\\\n\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center\">\\\n\t\t\t\t\t\t\t\t\t\t<h3>do not hesitate to send a message:</h3>\\\n\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 text-left\">\\\n\t\t\t\t\t\t\t\t\t\t<div class=\"container-fluid\">\\\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- feedback url 0 form 0 elem 0 -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- input for name -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id=\"\" class=\"form-group userto-form-0-elem-0\"></div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- feedback url 0 form 0 elem 1 -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- Via -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id=\"\" class=\"form-group userto-form-0-elem-1 d-i-b w-30\"></div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- feedback url 0 form 0 elem 2 -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- Login-number -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id=\"\" class=\"form-group userto-form-0-elem-2 d-i-b w-65\"></div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- feedback url 0 form 0 elem 3 -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- textarea for message -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id=\"\" class=\"form-group userto-form-0-elem-3\"></div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"row\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"col-lg-8 col-md-8 col-sm-8 col-xs-12\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"col-md-offset-1\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- feedback url 0 form 0 elem 4 -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- button Send -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"form-group userto-form-0-elem-4 d-i-b\"></div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- feedback url 0 form 0 elem 5 -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<!-- button Reset -->\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"form-group userto-form-0-elem-5 d-i-b p-l-1-em\"></div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"col-lg-4 col-md-4 col-sm-4 col-xs-12\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"col-md-offset-1\">\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t* required\\\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t</div>\\\n\t\t\t\t\t\t<div class=\"col-lg-2 col-md-2 col-sm-2 col-xs-2 text-center\"></div>\\\n\t\t\t\t\t</div>\\\n\t\t\t\t</div>';\t\t\t\t\n\t\t\t\t//console.info(' contact.innerHTML:',contact.innerHTML);\n\t\t}\n\n\t\t\n\t\treturn;\n\t}", "title": "" }, { "docid": "1f36b6a70ffe7e0b2d4e77cd47306d70", "score": "0.5556243", "text": "function setContactPageContent()\n\t{\n\t\t// content variables\n\t\tvar title = \"Contact Me.\"\n\t\tvar subtitle_greet = \"<h2 id=\\\"subtitle_greet\\\">Prospective Employers and Fellow Developers</h2>\";\n\t\tvar greeting = \"<p id=\\\"greeting\\\">\" + \n\t\t\"If you are a prospective employer you may contact me by email or on LinkedIn by clicking the icons below. \" +\n\t\t\"Alternatively, if you are a fellow developer looking for a team members on an open-source project feel free to reach out to me via Github.\" +\n\t\t\"</p>\";\n\t\t\n\t\tvar linkedin_url = \"https://linkedin.com/in/theresa-nemeth-485861141\";\n\t\tvar linkedin_icon = \"<a class=\\\"fa fa-linkedin-square fa-3x\\\" aria-hidden=\\\"true\\\" href=\\\"\" + linkedin_url + \"\\\"></a>\";\t\n\t\t\n\t\tvar github_url = \"https://github.com/theresafiesta\";\n\t\tvar github_icon = \"<a class=\\\"fa fa-github fa-3x\\\" aria-hidden=\\\"true\\\" href=\\\"\" + github_url + \"\\\"></a>\";\t\n\t\t\n\t\tvar email_addr = \"[email protected]\";\n\t\tvar email_icon = \"<i class=\\\"fa fa-envelope-open fa-3x\\\" aria-hidden=\\\"true\\\" data-clipboard-target=\\\"\" + email_addr+ \"\\\"></i>\";\t\t\n\t\t\n\t\tvar icons = \"<p id=\\\"icons\\\">\" + email_icon + tab + linkedin_icon + tab + github_icon + \"</p>\";\n\t\t// consider codewars, stackexchange, stackoverflow\n\t\n\t\t// clean up the page elements\n\t\t$(pageTitle).empty();\n\t\t$(section_top).empty();\n\t\t$(section_middle).empty();\n\t\t$(section_bottom).empty();\n\t\t\n\t\t// set the title\n\t\t$(pageTitle).append(title);\n\t\t\n\t\t// contact me text\n\t\t$(section_top).append(subtitle_greet);\n\t\t$(\"#subtitle_greet\").css('text-align','center');\n\t\t$(section_top).append(greeting);\n\t\t$(\"#greeting\").css('text-align','center');\n\t\t\n\t\t// add linkedin, github, email icons\n\t\t$(section_top).append(icons);\n\t\t$(\"#icons\").css('text-align','center');\n\t\t\n\t\t// set the last visited page\n\t\tlastPage = link_contact;\n\t\t\n\t} // end function", "title": "" }, { "docid": "27a8c4dcf47f34758a6503936efc6314", "score": "0.5513156", "text": "function chooseSendContacts(addr_form_id) {\n document.getElementById('send-contact-list').style.display = 'block';\n // contactsDB.open(function () {\n contactsDB.fetchContacts(function(contacts) {\n\n var contactList = document.getElementById('send-contacts');\n contactList.innerHTML = '';\n\n for (var i = 0; i < contacts.length; i++) {\n // Read the contacts backwards (most recent first).\n var contact = contacts[(contacts.length - 1 - i)];\n\n var li = document.createElement('li');\n li.id = 'send-contact-' + contact.timestamp;\n\n var contactName = document.createElement('span');\n contactName.className = 'send-contact-name';\n contactName.innerHTML = contact.name;\n contactName.setAttribute(\"data-id\", contact.xmr_address);\n li.appendChild(contactName);\n\n contactList.appendChild(li);\n\n // Setup an event listener for the checkbox.\n li.addEventListener('click', function(e) {\n var addr = String(e.target.getAttribute('data-id'));\n document.getElementById(addr_form_id).value = addr;\n document.getElementById('send-contact-list').style.display = 'none';\n });\n }\n\n });\n // });\n}", "title": "" }, { "docid": "fd3a40bb0ee4bdc517360e9274f5e413", "score": "0.5467071", "text": "function listContacts(){\ngetContacts().forEach (contact =>{\n let contactComponent = createContact(contact.name,contact.phone, contact.address);\nfunction writetotheDOM(contactComponent)\n});\n}", "title": "" }, { "docid": "8114c39fdbf2ed4403ff737764d53c1d", "score": "0.5464892", "text": "function hireToContactOpener() {\n $(\".hireButton\").click(function () {\n clearTimeout(idTimeOut);\n $(\".mainContent\").hide();\n $(\".navigationBar ul li\").removeClass(\"navigationBarUlLiSelected\");\n $(\".contactArea\").show();\n $(\".contactManipulate\").addClass(\"navigationBarUlLiSelected\");\n })\n }", "title": "" }, { "docid": "ba73f0617d3ed5f4281b27fee5002e78", "score": "0.54512405", "text": "reqContactList(phoneList) {\n\t\tlet payload = {\n\t\t\tphoneList: JSON.stringify(phoneList)\n\t\t}, self = this;\n\t\tHttpHelp.post(\n\t\t\tCONFIG.ADDRESSapi.checkListAdded.url,\n\t\t\t(code, msg, json) => self.filterContactList(code, msg, json), // success\n\t\t\t(code, msg) => { this.setState({getLocal: true,errText: msg}) }, // error\n\t\t\tpayload\n\t\t);\n\t}", "title": "" }, { "docid": "0ba138db0c00e02e8379a6bb58c0e6f0", "score": "0.54476535", "text": "function listInfo() {\n $(\"#complaint\").empty();\n //append attributes to compaint section\n var commentDisplay = $(\"<p>\").text(\"Problem: \" + complaintComment);\n var dueDateDisplay = $(\"<p>\").text(\"Due Date: \" + complaintDueDate);\n \n $(\"#complaint\").append(commentDisplay).append(dueDateDisplay);\n }", "title": "" }, { "docid": "07ebde879e8e8d5548cbf844aa1d71f6", "score": "0.54450065", "text": "function orgAddActionFromMail(){\n\torgAddStuffFromMailDialogue(\"a\");\n}", "title": "" }, { "docid": "8b0573270c2bebfbb4dce032240a4bb6", "score": "0.54349816", "text": "function addMissionToList(mission){\n /**\n * Function to add each mission id to the list given in the this object.\n */\n var $listItem = $(\"<a/>\", {\n href : \"#\",\n html : mission.name,\n });\n $listItem.addClass(\"list-group-item\");\n this.append($listItem);\n}", "title": "" }, { "docid": "e5b1e4f2d4430d6bea7f386a9c641d73", "score": "0.54055053", "text": "@wire(getAccountContacts, { csId: '$caseId' })\n contactListData(value) {\n this.contactData = value;\n const { data, error } = value;\n if (data) {\n for(i=0; i<data.length; i++) {\n this.items = [...this.items ,{value: data[i].Id , label: data[i].Name + ' ( '+data[i].Email+' )' } ]; \n } \n this.listOptions =this.items;\n \n this.error = undefined;\n this.loading = false;\n }\n else if (error) {\n this.items = undefined;\n this.error = error;\n this.loading = false;\n }\n }", "title": "" }, { "docid": "26b1d81ad7b8e5e1a64648fbd90d1ead", "score": "0.53963685", "text": "'sendToMailingList'() {\n mg.send({\n from: listAddress,\n to: listAddress,\n subject: \"Testing out our mailing list!\",\n text: \"This is where we pass our message to users. If we want to send HTML, we rename this field HTML, or, add it as a separate property (to send text as a backup).\"\n }, function( error, body ) {\n });\n }", "title": "" }, { "docid": "c3567de462c65990fceccc3062c5adb8", "score": "0.5373992", "text": "function setsExecutivesInforLB(tagContactTextImage, tagContactTextName, tagContactEmail, tagContactPhone, tagContactSectionNames, strContactName, strContactID, strContactEmail, strContactPhone, strContactTextImage, arrContactSectionNames) \n{\n\t//checks if there is a tagContactTextImage, tagContactTextName, tagContactEmail, tagContactPhone, tagContactSectionNames if so then add values to them\n\tif(tagContactTextImage != null && tagContactTextName != null && tagContactEmail != null && tagContactPhone != null && tagContactSectionNames != null)\n\t{\n\t\t//sets the basic properties to the contact us lightbox\n\t\t\n\t\t//sets the contact image\n\t\ttagContactTextImage.href = strContactID;\n\t\ttagContactTextImage.innerHTML = \"<img src='\" + strContactTextImage + \"' alt='\" + strContactName + \"' />\";\n\t\t\n\t\t//sets the contact name\n\t\ttagContactTextName.href = strContactID;\n\t\ttagContactTextName.innerHTML = strContactName;\n\t\t\n\t\t//sets the contact email\n\t\ttagContactEmail.href = \"mailto:\" + strContactEmail;\n\t\ttagContactEmail.innerHTML = strContactEmail;\n\t\t\n\t\t//sets the contact phone number\n\t\ttagContactPhone.innerHTML = strContactPhone;\n\n\t\t//checks if there is any items to display this seciton\n\t\tif(arrContactSectionNames != null && arrContactSectionNames.length > 0)\n\t\t{\n\t\t\t//sets the section to display the Schools this uses in in\n\t\t\ttagContactSectionNames.innerHTML = \"<div class='divETTExecutivesLabels customLeft'>\" + \n\t\t\t\t\t\"<label>Family of Schools:</label>\" + \n\t\t\t\t\"</div>\" + \n\t\t\t\t\"<div class='ContactUsForumFamilyofSchools customLeft'>\";\n\t\t\t\n\t\t\t//goes around adding the contact's schools they are part of\n\t\t\tfor (var intIndex = 0;intIndex < arrContactSectionNames.length;intIndex++)\n\t\t\t{\n\t\t\t\ttagContactSectionNames.innerHTML += arrContactSectionNames[intIndex] + \" ,\";\n\t\t\t}//end of for loop\n\t\t\t\n\t\t\t//ends the section to display the Schools this uses in in\t\n\t\t\ttagContactSectionNames.innerHTML = tagContactSectionNames.innerHTML.substring(0,tagContactSectionNames.innerHTML.length - 1) + \n\t\t\t\t\"</div>\" + \n\t\t\t\t\"<div class='customFooter'></div>\";\n\t\t}//end of if\n\t}//end of if\n}//end of setsExecutivesInforLB()", "title": "" }, { "docid": "48dfeb0d4862fcc0b09cd1e0b7be92f9", "score": "0.5365892", "text": "modifyContactandCompanyData() {\n\n \n }", "title": "" }, { "docid": "e75fb7689e8aab6bc7804f8a0a325ee8", "score": "0.5363904", "text": "function listContacts() {\n getContacts().forEach(contact => {\n writeToDom(createContact(contact.name, contact.phone, contact.address));\n })\n}", "title": "" }, { "docid": "09bebbd3399034c7aa30401311e3cfa6", "score": "0.5362069", "text": "function createExtrasList(exit, missionCode) {\n\tif(document.getElementById(\"compslider\").value == 0) {\n\t\tdocument.getElementById(\"submenu_comp\").disabled = true;\n\t\tdocument.getElementById(\"subsubmenu_comp\").disabled = true;\n\t\tdocument.getElementById(\"input_complicationt\").value = \"\";\n\t\treturn [];\n\t}\n\telse {\n\t\tdocument.getElementById(\"submenu_comp\").disabled = false;\n\t\tdocument.getElementById(\"subsubmenu_comp\").disabled = false;\n\t\tdocument.getElementById(\"input_complicationt\").value = \"\\n\\nComplications:\";\n\t}\n\t\t\n\tvar extras = [];\n\tvar modeIndex = document.getElementById(\"modeselect\");\n\tvar mode = modeIndex.options[modeIndex.selectedIndex].value;\n\tvar disguiseIndex = document.getElementById(\"disguise\");\n\tvar disguise = disguiseIndex.options[disguiseIndex.selectedIndex].value;\n\t\n\tif (Math.random() < 0.50)\n\t\textras.push(\"No Recordings|Do not get recorded by a security camera. If you are recorded, you must destroy the evidence.\");\n\n\tif (Math.random() < 0.50 && document.getElementById(\"firearm\").checked == 0)\n\t\textras.push(\"No Agency Pickup|When planning this mission, refrain from using a hidden stash or agency pickup.\");\n\n\tif (Math.random() < 0.40)\n\t\textras.push(\"No Bodies Found|No dead or unconscious bodies may be found. This does not include victims of accidents or poisoning.\");\n\n\tif (Math.random() < 0.30 && disguise == \"OFF\" && !disguiseExits.includes(exit) ) {\n\t\tif (Math.random() < 0.50)\n\t\t\textras.push(\"No Disguise Changes|Do not change from your starting disguise at any time during the mission.\");\n\t\telse\n\t\t\textras.push(\"One Disguise Change|You are allowed one disguise change while playing the mission.\");\n\t};\n\n\tif (Math.random() < 0.25 && document.getElementById(\"rating\").checked == 0)\n\t\textras.push(\"Rowdy Guns|Any ballistic weapon used must be non-silenced.\");\n\n\tif (Math.random() < 0.25 && document.getElementById(\"rating\").checked == 0)\n\t\textras.push(\"No Civilian Casualties|Avoid collateral damage by only eliminating your targets.\");\n\n\tif (Math.random() < 0.20 && document.getElementById(\"rating\").checked == 0)\n\t\textras.push(\"Do Not Get Spotted|Avoid anyone seeing you performing any illegal action.\");\n\n\tif (Math.random() < 0.30 && !koExits.includes(exit) && document.getElementById(\"exobj\").checked == 0)\n\t\textras.push(\"No Pacifications|Do not pacify or subdue anyone in any way. This includes using items via melee/throwing, sedating, or tranquilizing.\");\n\n\tif (Math.random() < 0.25)\n\t\textras.push(\"No Agility|Do not vault, hang, scale, or climb down.\");\n\n\tif (Math.random() < 0.20)\n\t\textras.push(\"Headshots Only|Any shots fired at NPCs must be headshots.\");\n\n\tif (Math.random() < 0.20 && mode == \"MAIN\" && document.getElementById(\"difficulty\").selectedIndex == 0 && !noSave.includes(missionCode) )\n\t\textras.push(\"One Save Only|You are allowed to save your mission progress only once.\");\n\t\n\tif (Math.random() < 0.30)\n\t\textras.push(\"Perfect Shooter|Do not use firearms as distractions or to destroy objects. All shots must hit an NPC, even if they subsequently pass through the NPC and hit a wall.\");\n\t\n\t\n\t\n\tif(extras.length == 0) //failsafe\n\t\textras.push(\"No Recordings|Do not get recorded by a security camera. If you are recorded, you must destroy the evidence.\");\n\t\n\treturn extras.slice(0,document.getElementById(\"compslider\").value); //max is value of slider\n}", "title": "" }, { "docid": "4873e18fa5931700fc587203794d5de0", "score": "0.5313044", "text": "function add_as_contact(){\r\n\t\t\t\r\n\t\t\tvar added_by_userType = req.query.added_by_usertype;\r\n\r\n\t\t\tif(added_by_userType){//if provided\r\n\t \t\t\tadded_by_user_type = added_by_userType.replace(added_by_userType[0], added_by_userType[0].toUpperCase());//capitalize first letter\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tkeystone.list('seller distributor').model.findOne()\r\n\t\t\t.where({idnumber : req.query.added_by_id, usertype :added_by_user_type})\r\n\t\t\t.exec(function(err, response){\r\n\r\n\t\t\t\tif(err){\r\n\t\t\t\t\tconsole.log('error when finding/adding new user as contact to user id : '+req.query.added_by_id+' ,user type : '+req.query.added_by_usertype);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(response == null || response == undefined || response == ''){//user not found//add user\r\n\t\t\t\t\tconsole.log('error no data when finding/adding new user as contact to user id : '+req.query.added_by_id+' ,user type : '+req.query.added_by_usertype);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tvar user_added_by = {'name':req.query.name.toLowerCase()+' '+req.query.surname.toLowerCase(),'type_of_user':user_type,'id_no':req.query.id};//create contact data\r\n\t\t\t\t\r\n\t\t\t\tvar added_customers_partners_array = response.added_customers_partners;//get old contact list\r\n\t\t\t\t\r\n\t\t\t\tadded_customers_partners_array.push(JSON.stringify(user_added_by));\r\n\t\t\t\t\r\n\t\t\t\tresponse.added_customers_partners = added_customers_partners_array;//append new contact to existing list\r\n\t\t\t\t\r\n\t\t\t\tresponse.save(function(error, results){//save new contact changes to profile\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(error){\r\n\t\t\t\t\t\tconsole.log('error saving new user as contact to user id : '+req.query.added_by_id+' ,user type : '+req.query.added_by_usertype);\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(results == null || results == undefined || results == ''){//user not found//add user\r\n\t\t\t\t\t\tconsole.log('error saving new user as contact to user id : '+req.query.added_by_id+' ,user type : '+req.query.added_by_usertype);\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t});\r\n\t\t\t\t\r\n\t\t\treturn;\r\n\r\n\t\t\t});\r\n\r\n\r\n\t\t}", "title": "" }, { "docid": "102489d9325bd344a8bdd1ebd3642e1f", "score": "0.5302193", "text": "function stampcontact() {\r\n try {\r\n if (Xrm.Page.getAttribute(\"whb_contact\").getValue() != null && Xrm.Page.getAttribute(\"whb_contact\").getValue()[0] != null) {\r\n\r\n\r\n var childcaseflag = Xrm.Page.getAttribute(\"whb_childcaseflag\").getValue();\r\n var contactid = Xrm.Page.getAttribute(\"whb_contact\").getValue()[0].id;\r\n var contactname = Xrm.Page.getAttribute(\"whb_contact\").getValue()[0].name;\r\n if (childcaseflag == 1) {\r\n contactid = contactid.slice(1, -1).toUpperCase();\r\n Xrm.Page.getAttribute(\"customerid\").setValue([{ id: contactid, name: contactname, entityType: \"contact\" }]);\r\n }\r\n else {\r\n Xrm.Page.getAttribute(\"customerid\").setValue([{ id: contactid, name: contactname, entityType: \"contact\" }]);\r\n }\r\n\r\n }\r\n\r\n } catch (err) { ErrorHandling(\"Case\", \"whb_onchange.js\", \"stampcontact\", err); }\r\n}", "title": "" }, { "docid": "ce9a875b998d5fb5f8326e88c61d8152", "score": "0.5302118", "text": "buildContact(lecturerObj)\n\t{\n\t\tlet cv = lecturerObj.cvfile;\n\t\tlet email = lecturerObj.email;\n\t\tlet phone = lecturerObj.phone;\n\t\tlet linkedin = lecturerObj.linkedin_link;\n\t\tlet google = lecturerObj.google_scholar_link;\n\t\tlet facebook = lecturerObj.facebook_link;\n\n\t\tlet contacts = document.getElementById(\"contacts\");\n\t\tlet mobileContacts = document.getElementById(\"contacts-mobile\");\n\n\t\tif(cv != \"\"){\n\t\t\tlet elem = document.createElement(\"A\");\n\t\t\telem.href = cv;\n\t\t\telem.id = \"cv\";\n\t\t elem.innerHTML = Icons.cv() + '<span style=\"margin-left: 5px;\">Download CV</span>';\n\t\t contacts.appendChild(elem);\n\n\t\t let elem_mob = document.createElement(\"A\");\n\t\t elem_mob.href = cv;\n\t\t elem_mob.innerHTML = Icons.cv();\n\t\t elem_mob.classList.add(\"social-icon\");\n\t\t mobileContacts.appendChild(elem_mob);\n\t\t}\n\n\t\tif(email != \"\"){\n\t\t let elem = document.createElement(\"P\");\n\t\t elem.innerHTML = Icons.mail() + \" \" + email;\n\t\t contacts.appendChild(elem);\n\n\t\t let elem_mob = document.createElement(\"A\");\n\t\t elem_mob.innerHTML = Icons.mail_mobile();\n\t\t elem_mob.href = \"mailto:\" + email;\n\t\t elem_mob.classList.add(\"social-icon\");\n\t\t mobileContacts.appendChild(elem_mob);\n\t\t}\n\n\t\tif(phone != \"\"){\n\t\t let elem = document.createElement(\"P\");\n\t\t elem.innerHTML = Icons.phone() + \" \" + phone;\n\t\t contacts.appendChild(elem);\n\n\t\t let elem_mob = document.createElement(\"A\");\n\t\t elem_mob.innerHTML = Icons.phone();\n\t\t elem_mob.href = \"tel:\" + phone;\n\t\t elem_mob.classList.add(\"social-icon\");\n\t\t mobileContacts.appendChild(elem_mob);\n\t\t \n\t\t}\n\n\t\tif(linkedin != \"\"){\n\t\t let linkedinIcon = document.createElement(\"A\");\n\t\t linkedinIcon.innerHTML = Icons.linkedin();\n\t\t linkedinIcon.classList.add(\"social-icon\");\n\t\t linkedinIcon.href = linkedin;\n\t\t contacts.appendChild(linkedinIcon);\n\t\t mobileContacts.appendChild(linkedinIcon);\n\t\t}\n\n\t\tif(google != \"\"){\n\t\t let googleIcon = document.createElement(\"A\");\n\t\t googleIcon.innerHTML = Icons.google();\n\t\t googleIcon.classList.add(\"social-icon\");\n\t\t googleIcon.href = google;\n\t\t contacts.appendChild(googleIcon);\n\t\t mobileContacts.appendChild(googleIcon);\n\t\t}\n\n\t\tif(facebook != \"\"){\n\t\t\tlet fbIcon = document.createElement(\"A\");\n\t\t\tfbIcon.innerHTML = Icons.about_facebook();\n\t\t\tfbIcon.classList.add(\"social-icon\");\n\t\t\tfbIcon.href = facebook;\n\t\t\tcontacts.appendChild(fbIcon);\n\t\t\tmobileContacts.appendChild(fbIcon);\n\t\t}\n\t}", "title": "" }, { "docid": "14313c8a817d6ef4e078481b2fac1c4a", "score": "0.5295767", "text": "function Start()\n{\n highlightActiveLink();\n addHeading2HoverTextInBio();\n addParagraphsInBio();\n addTextsInProject();\n addTextsToContact();\n addTextsToFooter();\n}", "title": "" }, { "docid": "bf26f49e32bd569d69db1942460a8b90", "score": "0.5291868", "text": "function questListSection(title, icon, useActiveList)\n{\t\n\tvar heading = $.CreatePanel(\"Label\", $(\"#quest-con\"), \"\");\n\theading.AddClass(\"quest-section\");\n\theading.text = title;\n\t\n\tfor(var i in quests){\n\t\tif(\t(useActiveList && quests[i].curStage > 0 && quests[i].curStage < 1000) ||\n\t\t\t(!useActiveList && quests[i].curStage >= 1000))\n\t\t{\n\t\t\tvar label = $.CreatePanel(\"Label\", $(\"#quest-con\"), \"\");\n\t\t\tlabel.AddClass(\"quest\");\n\t\t\tlabel.text = icon + \" \" + quests[i].title;\n\t\t\tlabel.SetPanelEvent(\"onactivate\", \"updateQuestInfo('\"+i+\"')\");\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d5705b283de1bbe9c9f5b82d4933cc04", "score": "0.5288501", "text": "function getContactList() {\r\n\r\n\tcontactXML = this.req.responseXML.documentElement;\r\n\tsetContactList();\r\n\t\r\n}", "title": "" }, { "docid": "6ab91667c8b5233a395ffe955410c5bc", "score": "0.5286519", "text": "function printInListView(contacts){\n contacts.map((contact, i)=>{\n //Tile\n\n var tile = document.createElement('div')\n tile.className=\"list\";\n tile.id=i;\n console.log(tile.id)\n //Left\n let leftContainer= document.createElement('div');\n leftContainer.className='left-container'\n //Right\n let rightContainer= document.createElement('div');\n rightContainer.className='right-container'\n //Name\n let name = document.createElement('h6')\n name.textContent = `${contact.FirstName} ${contact.LastName}`\n name.className=\"contactname\"\n //Mobile\n let mobile = document.createElement('h6')\n mobile.textContent = `${contact.Mobile}`\n mobile.className=\"mobile\"\n //Email\n let email = document.createElement('h6')\n email.textContent = `${contact.Email}`\n email.className=\"email\"\n //adding to left\n leftContainer.append(name,mobile,email)\n //container for contact via call email etc\n let connectWrap= document.createElement('div')\n connectWrap.className=\"connect-wrap\"\n //view contact \n let viewContact = document.createElement('div')\n viewContact.className=\"view-contact\"\n viewContact.innerHTML='<i class=\"fa fa-eye\" aria-hidden=\"true\"></i>'\n //send email button\n let emailContact = document.createElement('div')\n emailContact.className='email-contact'\n emailContact.innerHTML='<i class=\"fa fa-envelope\" aria-hidden=\"true\"></i>'\n //Call button\n let callContact = document.createElement('div')\n callContact.className=\"call-contact\"\n callContact.innerHTML='<i class=\"fa fa-phone\" aria-hidden=\"true\"></i>'\n connectWrap.append(viewContact,emailContact,callContact)\n //Modifying contact\n let mod = document.createElement('div')\n mod.className='mod'\n //edit\n let editContact=document.createElement('div')\n editContact.className='edit-contact'\n editContact.innerHTML='Edit'\n //delete\n let deleteContact= document.createElement('div')\n deleteContact.className=\"delete-contact\"\n deleteContact.innerHTML='<i class=\"fa fa-trash\" aria-hidden=\"true\"></i>'\n //adding to mod\n mod.append(editContact,deleteContact)\n //Add to Right container\n rightContainer.append(mod,connectWrap)\n tile.append(leftContainer,rightContainer)\n document.querySelector('.tiles').append(tile);\n\n\n //delete listener\n document.querySelector('.list-view').classList.add('selected')\n })\n}", "title": "" }, { "docid": "53ad108a906fa256c5cde7581aa184b4", "score": "0.5269882", "text": "function UpdateContactList(){\n\t\tconsole.log('update contact');\n\t\tuser.get('contact').map().once((data,id)=>{\n\t\t\t//console.log(data);\n\t\t\tif(!data.name)//check for name to exist\n\t\t\t\treturn;\n\t\t\tvar option = $('#' + id).get(0) || $('<option>').attr('id', id).appendTo('#contacts');//check if option id exist else create.\n\t\t\tif(data){\n\t\t\t\tif(data == 'null'){\n\t\t\t\t\t$(option).hide();//hide element\n\t\t\t\t}\n\t\t\t\t$(option).text(data.name);//set text\n\t\t\t} else {\n\t\t\t\t$(option).hide();//hide element\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "9c60d828e14de996cc5b7b517aef4fc3", "score": "0.52531123", "text": "@api\n addContactToList(strContactName) {\n console.log('Child Component:' + strContactName);\n //this.lstContacts.push(strContactName);\n this.lstContacts = [...this.lstContacts, strContactName];\n }", "title": "" }, { "docid": "16d6fa06fcbb8dae861d62b7e8f0636c", "score": "0.5238545", "text": "function addMessageToContactList(){\n\tlet newConvo = document.createElement(\"div\");\n\tnewConvo.setAttribute(\"class\", \"addRemoveContact\");\n\n\tlet addButton = document.createElement(\"img\");\n\taddButton.setAttribute(\"id\", 'contact_addButton');\n\taddButton.setAttribute(\"src\", 'images/button_add.png');\n\n\tlet removeButton = document.createElement(\"img\");\n\tremoveButton.setAttribute(\"id\", 'contact_removeButton');\n\tremoveButton.setAttribute(\"src\", 'images/button_remove.png');\n\t\n\tnewConvo.appendChild(addButton);\n\tnewConvo.appendChild(removeButton);\n\n\tlet container = document.getElementById(\"zone_contacts\");\n\tcontainer.appendChild(newConvo);\n\n\t//Pour gérer le fait d'ouvrir une conversation\n\taddButton.onclick = function (e) {\n\t\tlet contactToAdd = window.prompt(\"Entrez le courriel du contact que vous voulez ajouter\",\"\");\n\t\taddContact(contactToAdd);\n\t}\n\n\t//Pour gérer le fait d'ouvrir une conversation\n\tremoveButton.onclick = function (e) {\n\t\tlet contactToRemove = window.prompt(\"Entrez le courriel du contact que vous voulez supprimer\",\"\");\n\t\tremoveContact(contactToRemove);\n\t}\n}", "title": "" }, { "docid": "8e8fae615cf5e1506b3260c762abcc00", "score": "0.52366745", "text": "function sendPermitReadyToIssueNotification()\r\n{\r\n// Provide the ACA URL\r\nvar acaURL = \"acasupp3.accela.com/agency\"\r\n// Provide the Agency Reply Email\r\nvar agencyReplyEmail = \"[email protected]\"\r\n//Provide the contact types to send this notification\r\nvar contactTypesArray = new Array(\"Applicant\",\"Property Owner\");\r\n// Provide the Notification Template to use\r\nvar notificationTemplate = \"AA_MESSAGE_PERMIT_READY_TO_ISSUE\";\r\n// Get an array of Contact Objects using Master Scripts 3.0\r\nvar contactObjArray = getContactObjs(capId,contactTypesArray);\r\n// Provide the professional types to send this notification\r\nvar profTypesArray = new Array(\"Engineer\",\"Architect\");\r\n// Get an array of Professional Objects\r\nvar profObjArray = getLicenseProfessional(capId);\r\n\r\n//licenseProfObject(licProfScriptModel.getLicenseNbr(), profTypesArray);\r\n\r\nfor (iCon in contactObjArray) {\r\n\tvar tContactObj = contactObjArray[iCon];\r\n\tlogDebug(\"Contact Name: \" + tContactObj.people.getFirstName() + \" \" + tContactObj.people.getLastName());\r\n\tif(!matches(tContactObj.people.getEmail(),null,undefined,\"\")) {\r\n\t\tlogDebug(\"Contact Email: \" + tContactObj.people.getEmail());\r\n\t\tvar eParams = aa.util.newHashtable();\r\n\t\taddParameter(eParams, \"$$recordTypeAlias$$\", cap.getCapType().getAlias());\r\n\t\tgetRecordParams4Notification(eParams);\r\n\t\tgetACARecordParam4Notification(eParams,acaURL);\r\n\t\ttContactObj.getEmailTemplateParams(eParams);\r\n\t\tgetPrimaryAddressLineParam4Notification(eParams);\r\n\t\t// getWorkflowParams4Notification(eParams); \r\n\t\tgetContactParams4Notification(eParams,contactTypesArray);\r\n\t\tsendNotification(agencyReplyEmail,tContactObj.people.getEmail(),\"\",notificationTemplate,eParams,null);\r\n\t}\r\n\t\r\n}\r\nfor (iProf in profObjArray) {\r\n\tvar tProfObj = profObjArray[iProf];\r\n\t//logDebug(\"LP Name: \" + tProfObj.people.getFirstName() + \" \" + tProfObj.people.getLastName());\r\n\tvar vProfObj = new licenseProfObject(tProfObj.getLicenseNbr());\r\n\tlogDebug(\"LP Email: \" + vProfObj.refLicModel.getEMailAddress());\r\n\tif(!matches(vProfObj.refLicModel.getEMailAddress(),null,undefined,\"\")) {\r\n\t\tlogDebug(\"LP Email: \" + vProfObj.refLicModel.getEMailAddress());\r\n\t\tvar eParams = aa.util.newHashtable();\r\n\t\taddParameter(eParams, \"$$recordTypeAlias$$\", cap.getCapType().getAlias());\r\n\t\tgetRecordParams4Notification(eParams);\r\n\t\tgetACARecordParam4Notification(eParams,acaURL);\r\n\t\tvProfObj.getEmailTemplateParams(eParams);\r\n\t\tgetPrimaryAddressLineParam4Notification(eParams);\r\n\t\t// getWorkflowParams4Notification(eParams); \r\n\t\t// getContactParams4Notification(eParams,contactTypesArray);\r\n\t\tsendNotification(agencyReplyEmail,vProfObj.refLicModel.getEMailAddress(),\"\",notificationTemplate,eParams,null);\r\n\t} \r\n}\r\n}", "title": "" }, { "docid": "4f355f9f841053a8d0788b2c8e2e8ecf", "score": "0.52260417", "text": "function showContactList() {\n for (let x = 0; x < contactList.length; x++) {\n document.getElementById('links').innerHTML+=`<img src=\"${contactList[x].imglink}\" id=\"contactimg\"></div>`;\n if (contactList[x].name==='call' || contactList[x].name==='email')\n document.getElementById('links').innerHTML+=`<span id=\"contactlink\">${contactList[x].link}</span>`;\n else document.getElementById('links').innerHTML+=`<a id=\"contactlink\" href=${contactList[x].link}>${contactList[x].link}</a>`;\n document.getElementById('links').innerHTML+=`<img src=\"public/images/editButton.png\" height=\"30\" width=\"30\" style=\"cursor: pointer; float: right;\" onclick='showContactForm(\"${contactList[x].id}\");'>`;\n }\n}", "title": "" }, { "docid": "b33acea5e9b4718f0eef96a133d86bcf", "score": "0.5223445", "text": "function setContactList() {\n\t\t contactService.getContactList().then(function (contactData) {\n\t\t\t $scope.contactList = contactData.ContactList;\n\t\t });\n\t }", "title": "" }, { "docid": "7e6be1d0759ad9901c514df798a0e16e", "score": "0.52233076", "text": "dayAtAGlance() {\n\n // Add a section to the day-at-a-glance body for this module if there isn't one already.\n if (!$$(\"dayAtAGlanceScreen_Tasks\")) {\n $$(\"dayAtAGlanceBody\").addView({\n view : \"fieldset\", label : \"Tasks\",\n body : { id : \"dayAtAGlanceScreen_Tasks\", rows : [ ] }\n });\n $$(\"dayAtAGlanceBody\").addView({ height : 20 });\n }\n\n // Populate the day-at-a-glance screen.\n const template = webix.template(\"#subject#\");\n let dataItems = wxPIM.getModuleData(\"Tasks\");\n dataItems = wxPIM.objectAsArray(dataItems);\n wxPIM.sortArray(dataItems, \"value\", \"A\");\n const currentDate = new Date().setHours(0, 0, 0, 0);\n const rows = [ ];\n for (let i = 0; i < dataItems.length; i++) {\n const item = dataItems[i];\n const itemDate = new Date(item.dueDate).setHours(0, 0, 0, 0);\n if (itemDate == currentDate) {\n if (item.status == 1) {\n item.status = \"Ongoing\";\n } else {\n item.status = \"Completed\";\n }\n item.dueDate = webix.i18n.timeFormatStr(new Date(item.dueDate));\n rows.push({ borderless : true, template : template(item), height : 30 });\n }\n }\n webix.ui(rows, $$(\"dayAtAGlanceScreen_Tasks\"));\n\n }", "title": "" }, { "docid": "fcf06cfe446f2e3a787c209459ad63b7", "score": "0.52171165", "text": "function contactPage(){\n $(\"#contentText\").show().addClass(\"showFeed\");\n $(\".navMenu\").hide();\n $(\"#headerTxt\").html(\"<span onclick=\\\"homeScreen()\\\" style=\\\"float:left; margin-left:5px;\\\">&lt;</span>Contact Me\");\n $(\"<p class=\\\"plainP\\\">This email will be sent to [email protected]</p>\").appendTo(\"#contentText\");\n $(\"<form name=\\\"emailForm\\\"><textarea class=\\\"textBox\\\" name=\\\"msgText\\\" ></textarea><div class=\\\"navBtn\\\" onclick=\\\"submitMail(emailForm.msgText.value)\\\"><h4>Send Mail</h4></div></form>\").appendTo(\"#contentText\");\n}", "title": "" }, { "docid": "dcf0d855d2720397a1354e6b5f8e71a9", "score": "0.5212383", "text": "function emailPC() {\n var emailNotification = new GlideRecord(\"sys_email\");\n emailNotification.initialize();\n emailNotification.type = 'send-ready';\n emailNotification.recipients = primaryContactEmail;\n emailNotification.subject = userName + \"'s access to ServiceNow has been granted\";\n var bodyStr =\n\n '<p>'\n + 'Per your request ' + ritmNum + ', ServiceNow access for ' + userName + ' has been modified.<br><br>'\n + userName + ' has been added to the following group(s):<br>';\n\n for (var i = 0; i < groupsToAddNames.length; i++) {\n bodyStr += groupsToAddNames[i] + '<br>';\n }\n bodyStr += '<br>';\n\n bodyStr +=\n 'If you have any issues, please contact IT Express at 530-754-HELP (4357).<br><br>'\n + 'Thank you,<br>'\n + 'IT Service Management' +\n '</p>';\n\n emailNotification.body = bodyStr;\n emailNotification.insert();\n gs.log(\"INBOUND ACTION--\\nemail sent to pc\\n\" + primaryContactEmail);\n}", "title": "" }, { "docid": "16145204d63d465b56f5e3e823b3b33e", "score": "0.51949614", "text": "function addContact() {\r\n\r\n\tvar divContactButtons = document.getElementById(\"contact_buttons\");\r\n\tvar divContactForm = document.getElementById(\"new_contact\");\r\n\tvar divContactProcess = document.getElementById(\"contact_process\");\r\n\t\r\n\t// reset error messages\r\n\tvar divContactEmailError = document.getElementById(\"contact_email_error\");\r\n\tdivContactEmailError.style.display = \"none\";\r\n\r\n\tvar divContactNameError = document.getElementById(\"contact_name_error\");\r\n\tdivContactNameError.style.display = \"none\";\r\n\t\r\n\t\t\r\n\tvar inputs = divContactForm.getElementsByTagName(\"input\");\r\n\t\r\n\tvar validation_result = conValidate(inputs)\r\n\t\r\n\tif(validation_result == true) {\r\n\t\t\r\n\t\tdivContactButtons.style.display = \"none\";\r\n\t\tdivContactProcess.style.display = \"block\";\r\n\t\r\n\t\t\r\n\t\tvar query_string = \"contact_name=\" + inputs[0].value +\r\n\t\t\t\t\t\t\t\"&contact_email=\" + inputs[1].value +\r\n\t\t\t\t\t\t\t\"&contact_address1=\" + inputs[2].value +\r\n\t\t\t\t\t\t\t\"&contact_address2=\" + inputs[3].value +\r\n\t\t\t\t\t\t\t\"&contact_city=\" + inputs[4].value +\r\n\t\t\t\t\t\t\t\"&contact_state=\" + inputs[5].value +\r\n\t\t\t\t\t\t\t\"&contact_zip=\" + inputs[6].value +\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\"&contact_phone=\" + inputs[7].value +\r\n\t\t\t\t\t\t\t\"&contact_fax=\" + inputs[8].value +\r\n\t\t\t\t\t\t\t\"&contact_cell=\" + inputs[9].value;\r\n\t\t\t\t\r\n\t\tvar loader = new net.ContentLoader('process/add_contact.php', processContactResponse, showError, 'POST', query_string);\r\n\t\r\n\t\r\n\t}\r\n\t\r\n}", "title": "" }, { "docid": "5ac54e587ace1d24ff443db80c9a269e", "score": "0.51912045", "text": "function emergencyContactEdit(si_id, secid, contname, rel, mobno, officeno, homeno, status){\n\t\t\n\t\t$(\"#emergcont_list\").html(\"<div align=\\\"center\\\" width=\\\"100%\\\"><img align=\\\"center\\\" src=\\\"images/loader.gif\\\"/></div>\");\n\t\t$.ajax({\n\t\t\ttype : \"POST\",\n\t\t\turl : \"studentaction_emergcontact_edit.action\",\t\t\t\t\n\t\t\tdata : \"si_id=\" + si_id + \"&sec_id=\" + secid + \"&contact_name=\" + contname + \"&relationship=\" + rel + \"&mob_no=\" + mobno + \"&office_phone_no=\" + officeno + \"&home_phone_no=\" + homeno + \"&sec_status=\" + status,\n\t\t\tsuccess : function(response) {\n\t\t\t\t$('#emergcont_list').html(response);\n\t\t\t},\n\t\t\terror : function(e) {\n\t\t\t\talert('Error: ' + e);\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "c302a90156d259ebecaeadc1a4b63d37", "score": "0.51896036", "text": "function addContact(contactList, fName, lName) {\r\n contactList.push({\r\n lName: lName,\r\n fName: fName,\r\n })\r\n}", "title": "" }, { "docid": "bd70936f139d38c20d636ef5db5e8ba1", "score": "0.5185271", "text": "function displayContacts() {\n // modify the generic contact template to use icon fonts\n var HTMLmyGeneric = '<li class=\"flex-item\"><a class=\"white-text %iconfont%\" href=\"#\"><span class=\"orange-text\">%data%</span></a></li>';\n\n // iterate through each contacts object\n for (var contactKey in bio.contacts) {\n if (bio.contacts.hasOwnProperty(contactKey)) {\n // set the iconfont class and variables\n var iconClass, data, ref;\n\n switch (contactKey) {\n case 'mobile':\n iconClass = 'fa-phone';\n data = bio.contacts[contactKey];\n ref = ' ';\n break;\n case 'email':\n iconClass = 'fa-envelope-o';\n data = bio.contacts[contactKey];\n ref = ' ';\n break;\n case 'twitter':\n iconClass = 'fa-twitter';\n data = 'Twitter';\n ref = bio.contacts[contactKey];\n break;\n case 'github':\n iconClass = 'fa-github';\n data = 'GitHub';\n ref = bio.contacts[contactKey];\n break;\n case 'location':\n iconClass = 'fa-globe';\n data = bio.contacts[contactKey];\n ref = ' ';\n break;\n case 'linkedin':\n iconClass = 'fa-linkedin';\n data = 'LinkedIn';\n ref = bio.contacts[contactKey];\n break;\n case 'wordpress':\n iconClass = 'fa-wordpress';\n data = 'Wordpress';\n ref = bio.contacts[contactKey];\n break;\n default:\n iconClass = '';\n data = bio.contacts[contactKey];\n ref = ' ';\n }\n\n // format and display each contact\n var formattedContact = HTMLmyGeneric.replace('%iconfont%', iconClass).replace('#', ref).replace('%data%', data);\n $('#topContacts').append(formattedContact);\n }\n }\n}", "title": "" }, { "docid": "105d47d240b9e393275e60571ffa4696", "score": "0.5179551", "text": "function ZWCollaboration() {\n}", "title": "" }, { "docid": "ccbb97d2f054567ac4ff7c748087c480", "score": "0.51786685", "text": "function contactFunction() {\n if (\n homeElement.style.display === 'block' ||\n aboutElement.style.display === 'block'\n ) {\n showMenueDivs(false, false, true);\n }\n}", "title": "" }, { "docid": "89ade5bed7439dfd020c988a46511317", "score": "0.51764446", "text": "function compose() { \t\n\t\n\t$('.slimScrollDiv').hide();\n\t$('.slimScrollDiv').has('#message-compose').show();\n\n\t//disable left sidebar if in compose page\n\twindow.snapper.disable();\n\t\n\t//flag page as COMPOSE\n\t$('.current-page').attr('id', 'compose');\n\t\n\t//navbars\n\t//hide delete message icon\n\t$('#delete-message').hide();\n\t//show send button icon\n\t$('#process-send').show();\n\t//hide compose button icon\n\t$('#compose-message').hide();\n\t//back button show\n\t$('#back-top').show();\n\t//hide sidebar icon\t\n\t$('#sidebar-top').hide();\n\n\t//unset compose fields\n\t$('form.ui-filterable').\n\t\tchildren().\n\t\tchildren().\n\t\tfirst().\n\t\tval('');\n\n\t//unset message priority\t\n\t$('#compose-important option').\n\t\tremoveAttr('selected').\n\t\tfilter('[value=0]').\n\t\tattr('selected', true);\n\n\t//to Normal as defailt\t\n $('#compose-important-button span').html('Normal') \n\n\t$('.loading-messages').hide();\n\t$('.message-elem').hide();\n\t$('#message-compose').show();\n\n\t$('.to-holder').html('');\n\t$('.to-holder-shrink').html('');\n\t$('.to-holder-shrink').hide();\n\t$('#compose-subject').val('');\n\t$('#compose-content').val('');\n\t$('#compose-content').html('');\n\t$('#compose-contact').val('');\n\t$('#compose-contact').prev().html('');\n\t$('.warning-holder').html('');\n\t$('#compose-contact-list').html('');\n\n\t//populate the contact listing auto search\n\tfor(i in window.contactList) {\n\t\t//append, append, append\n\t\t$('#compose-contact-list').append(CONTACT_LIST.\n\t\t\treplace('[ID]', i).\n\t\t\treplace('[NAME]', window.contactList[i].name));\n\t\t\n\t}\n\t\n\t$('#compose-content').val('').trigger('autosize.resize');\n\t\n\t//on typing in To field\n\t$('.contact-pick').click(function() {\n\t\tvar id \t\t= $(this).attr('id');\n\t\tvar name \t= $(this).html();\n\t\tvar hasID \t= false;\n\n\t\t//empty out the warning error\n\t\t$('.warning-holder').html('');\n\n\t\t//prevent dual TO name in listing\n\t\t$('.to-holder div').each(function() {\n\t\t\tvar ids = $(this).attr('id');\n\n\t\t\tif(ids == id) {\n\t\t\t\thasID = true;\n\t\t\t}\n\t\t});\n\n\t\t//now unset \n\t\t$('input#compose-contact-list').val('');\n\t\t$('ul#compose-contact-list li').each(function() {\n\t\t\t$(this).addClass('ui-screen-hidden');\n\t\t});\n\n\t\t$('form.ui-filterable').children().children().first().val('');\n\t\t$('form.ui-filterable').children().children().first().focus();\n\n\t\t//prevent adding the same contacts\n\t\tif(!hasID) {\n\t\t\t$('.to-holder').append(TO_COMPOSE.\n\t \t\treplace('[ID]', id).\n\t \t\treplace('[NAME]', name)\n\t \t);\n\t\t}\n\n\t\treturn false;\n\t});\n}", "title": "" }, { "docid": "84ca4db78da4c447631013c279f9842b", "score": "0.5156879", "text": "function loadContactList() {\r\n\r\n\tcontactXML = this.req.responseXML.documentElement;\r\n\t\r\n}", "title": "" }, { "docid": "d4aa74dc0fa51510886f2604c26dbd38", "score": "0.51301056", "text": "function launchCampaign(){\n\n console.log(\"LAUNCH CAMPAIGN!\");\n\n clearPlayerInventory();\n\n //player starts with a single soul\n player.addSoul();\n\n //Start with nothing but a single set of old bones\n player.giveItem(1, 0);//myBones.push(1);\n\n //Start the Player with 10 malachite\n player.malachite = 10;\n\n player.campaignProgress = [1,1];\n\n campaign.list[player.campaignProgress[0]](player.campaignProgress[1]);\n\n\n}//end launchCampaign()", "title": "" }, { "docid": "6b50ad1422d0d3bbab202de9acfc0d21", "score": "0.5127207", "text": "function showContent (index){\n\t\t$(\".content-list\").each(function() {\n if($(this).hasClass(\"content-list-active\")){\n\t\t\t\t$(this).removeClass(\"content-list-active\").slideUp(600, function(){\n\t\t\t\t\t$(\".content-list\").eq(index).addClass(\"content-list-active\").slideDown(600);\n\t\t\t\t\t\n\t\t\t\t\tvar hasClassContact = $(\".content-list\").eq(index).hasClass(\"content-contact\");\n\t\t\t\t\tif(hasClassContact){\n\t\t\t\t\t\t$(this).trigger(\"map-trigger\", [hasClassContact]);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// Set the animation flag to false after the content has changed\n\t\t\t\t\tanimationFlag = false;\n\t\t\t\t});\n\t\t\t}\n });\n\t}", "title": "" }, { "docid": "8355da8164fc80a92edbdfce70883f19", "score": "0.5113222", "text": "function Twilio_Send_elementsExtraJS() {\n // screen (Twilio_Send) extra code\n\n /* mobilelist_121 */\n\n listView = $(\"#Twilio_Send_mobilelist_121\");\n theme = listView.attr(\"data-theme\");\n if (typeof theme !== 'undefined') {\n var themeClass = \"ui-btn-up-\" + theme;\n listItem = $(\"#Twilio_Send_mobilelist_121 .ui-li-static\");\n $.each(listItem, function(index, value) {\n $(this).addClass(themeClass);\n });\n }\n\n /* mobilelistitem_122 */\n\n /* mobilelist_20 */\n\n listView = $(\"#Twilio_Send_mobilelist_20\");\n theme = listView.attr(\"data-theme\");\n if (typeof theme !== 'undefined') {\n var themeClass = \"ui-btn-up-\" + theme;\n listItem = $(\"#Twilio_Send_mobilelist_20 .ui-li-static\");\n $.each(listItem, function(index, value) {\n $(this).addClass(themeClass);\n });\n }\n\n /* mobilelistitem_21 */\n\n /* mobilelistitem_27 */\n\n /* home_page */\n\n }", "title": "" }, { "docid": "fda0eac0bd22069819cb806ef4c7895c", "score": "0.510951", "text": "function addContact($container) {\r\n // Dans le contenu de l'attribut « data-prototype », on remplace :\r\n // - le texte \"__name__label__\" qu'il contient par le label du champ\r\n // - le texte \"__name__\" qu'il contient par le numéro du champ\r\n var $prototype = $($container.attr('data-prototype').replace(/__name__label__/g, nameInput + (index+1))\r\n .replace(/__name__/g, index));\r\n\r\n // On ajoute au prototype un lien pour pouvoir supprimer la catégorie\r\n addDeleteLink($prototype);\r\n\r\n // On ajoute le prototype modifié à la fin de la balise <div>\r\n $container.append($prototype);\r\n\r\n // Enfin, on incrémente le compteur pour que le prochain ajout se fasse avec un autre numéro\r\n index++;\r\n }", "title": "" }, { "docid": "22f4f330f84600ffb40878ce92f8dcf3", "score": "0.5109367", "text": "function renderMissions(){\n\tconsole.log(\"rendering missions\");\n\t$(\"#missions-list\").html(\"\");\n\tvar username = Parse.User.current().get(\"username\");\n\tvar MissionObject = Parse.Object.extend(\"Mission\");\n\tvar ObjectiveObject = Parse.Object.extend(\"Objective\");\n\tvar query = new Parse.Query(MissionObject);\n\tquery.equalTo(\"user\", username);\n\tquery.equalTo(\"completed\", false);\n\tquery.equalTo(\"failed\", false);\n\tquery.find().then(function(results){\n\t\tvar promise = Parse.Promise.as();\n\t\tif(results.length == 0){\n \t\t $(\"#missions-list\").html(\"<li class='default-list'><em>No missions to display.\"\n \t\t \t+ \"<br/>Click <strong>'New Mission'</strong> to create a new mission.</em></li>\");\n \t}\n \tconsole.log(results);\n \tresults.sort(function(x, y){\n\t\t return x.get(\"deadline\") - y.get(\"deadline\") ;\n\t\t});\n\t\tresults.forEach(function(result){\n\t\t\tvar mission = result.toJSON();\n\t\t\tvar oquery = new Parse.Query(ObjectiveObject);\n\t\t\toquery.equalTo(\"missionId\", mission.objectId);\n\t\t\toquery.equalTo(\"completed\", false);\n\t\t\toquery.equalTo(\"failed\", false);\n\t\t\toquery.find({\n\t\t\t\tsuccess:function(findings){\n\t\t\t\t\tfindings.sort(function(x, y){\n\t\t\t\t\t return x.index - y.index;\n\t\t\t\t\t});\n\t\t\t\t\tif(!findings[0]) { //Means have finished all objectives associated with mission\n\t\t\t\t\t\t//alert(\"Error: Empty mission found! \\n You may need to create a new account.\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(findings[0]);\n\t\t\t\t\tvar data = findings[0];\n\t\t\t\t\tvar subtaskHtml = \"\";\n\t\t for(var s = 0; s < data.get(\"subtasks\").length; s++){\n\t\t \t\tsubtaskHtml += \"<li><input id='\" + data.id + \"_\" + data.get(\"subtasks\")[s].id + \"' type='checkbox' class='subtask_check'\" + ((data.get(\"subtasks\")[s].completed)? \"checked\" : \"\") + \"/>\"\n\t\t \t\t\t\t\t+ \"<label for='\"+ data.id + \"_\" + data.get(\"subtasks\")[s].id + \"'>\" + data.get(\"subtasks\")[s].title + \"</label></li>\";\n\t\t \t}\n\t\t \tvar date = dateString(new Date(mission.deadline.iso), true);\n\t\t console.log(\"#edit_\"+ data.id);\n\t\t\t\t\tvar htmlBuilder = \"<div class='mission_background'>\"\n\t\t\t\t\t\t\t+ \"<li class='mission_box container current_mission' id='\" + mission.objectId +\"'>\"\n\t\t\t\t\t\t\t+ \t\"<div class='pull-right btn-group mdropdown'>\"\n \t\t\t\t\t\t\t+\t\"<a class='btn dropdown-toggle mission_dropdown' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>\"\n \t\t\t\t\t\t+ \t\t\"<span class='glyphicon glyphicon-chevron-down'></span></a>\"\n \t\t\t\t\t\t+ \t\t\"<ul class='dropdown-menu mission_options'>\"\n \t\t\t\t\t\t\t+ \t\t\t\"<li><a class='edit_mission' id='edit_\" + data.id + \"'>Edit</a></li>\"\n\t\t\t\t\t\t\t+ \t\t\t\"<li><a class='cancel_mission' id='cancel_\" + data.id + \"'>Delete</a></li>\"\n \t\t\t\t\t\t+\t\t\"</ul>\"\n\t\t\t\t\t\t\t+\t\"</div>\"\n\t\t\t\t\t\t\t+\t\"<div class='runner-progress'>\"\n\t\t\t\t\t\t\t+\t\t\"<br/><div class='progress_background'><div class='pBar_r'>&nbsp;</div>\"\n\t\t\t\t\t\t\t+\t\t\t\"<div id='distance_\" + mission.objectId + \"' class='distance'></div>\"\n\t \t\t\t+ \t\t\"<img src='\" + \"/images/deadlion_leap.png\" +\"' class='progress_img lion_img' id='lion_\" + mission.objectId + \"'/>\"\t\n\t \t\t\t+\t\t\"<img src='/images/\" + mission.runner + \"_panic_static.png' class='progress_img runner_img pull-right' id='runner_\" + mission.objectId + \"'/>\"\n \t\t\t\t+\t\"</div>\"\n \t\t\t\t+\t\"<h4 class='mission_dates'><img src='/images/icon_timed.png' class='time_img'/>&nbsp;Due: \" + dateString(data.get(\"deadline\"), true) + \"</h4>\"\n\t\t\t\t\t\t\t+ \t\"<h3 class='subtaskToggle' id='mission_\" + mission.objectId + \"'>\" + mission.title + \"&nbsp;\"\n\t \t\t\t+\t\t\"<span class='collapse_indicator collapsed glyphicon glyphicon-chevron-up'></span>\"\n\t \t\t\t+\t\"</h3>\"\n\t \t\t\t+\t\"<div class='tasklist' id='\" + data.id + \"'>\"\n\t \t\t\t+\t\t((mission.dates) ? \"<h4 class='mission_dates'>Every \" + mission.dates + \"<br/>Until: \" + dateString(new Date(mission.deadline.iso), false) + \"</h4>\" : \"\")\n\t \t\t\t+\t\t\"<ul class='list-unstyled subtasks-list'>\" + subtaskHtml + \"</ul>\"\n\t \t\t\t+\t\"</div>\"\n\t \t\t\t+\t\"<a class='btn pull-right complete_mission btn-custom' id='complete_\" + data.id + \"'>Incomplete</a>\"\n\t \t\t\t+ \"</li>\"\n\t \t\t\t+ \"</div>\";\n \t\t$(\"#missions-list\").append(htmlBuilder);\n\n \t\t$(\"#mission_\"+ mission.objectId).click(toggleSubtaskList);\n \t\tconsole.log($(\"#edit_\"+ data.id));\n \t\t$(\"#edit_\"+ data.id).click(editMission);\n\n \t\t$(\"#\" + data.id).data(\"parseObject\", findings[0]);\n \t\t$(\"#\" + mission.objectId).data(\"mission\", result);\n \t\tvar target = new Date(mission.deadline.iso);\n\t\t \t\t$(\"#lion_\" + mission.objectId).css(\"margin-left\", Math.min(80, (1- ((target - new Date()) / (target - new Date(data.get(\"createdAt\"))))) * 80) + \"%\");\n\t\t \t\t$(\"#distance_\" + mission.objectId).css(\"width\", Math.min(100, (1- ((target - new Date()) / (target - new Date(data.get(\"createdAt\"))))) * 100) + \"%\");\n\n \t\tcheckForCompleted(data);\n \t\n \t\t$(\"#cancel_\" + data.id).click(cancelMission);\n\t\t\t\t\t$(\"#\" + data.id + \" .subtask_check\").change(checkSubtask);\n\n \t\treturn promise;\n\t\t }\n\t\t }).then(function(){\n\t\t\tcalculateDistances();\n\t\t});\n\t\t});\n\t});\n}", "title": "" }, { "docid": "f284877248d277fcd6927d7094a17824", "score": "0.5107034", "text": "function fn_rotloadexpextendcontent1(scheduleid,licenseid,type)\n{\n\t\t\n\tif((type==\"mod\" && $('#excflag').val()==1) || type==\"exc\")\n\t{\n\tvar list4 = [];\t //module id\n\t\n\t$(\"div[id^=list4_]\").each(function()\n\t{\n\t\t\tlist4.push($(this).attr('id').replace('list4_',''));\n\t});\n\t\t\n\tif(list4=='' && type==\"exc\"){\n\t\talert(\"Please select any one Expedition\");\n\t\treturn false;\n\t}\n\tvar dataparam = \"oper=loadexpextendcontent1&list4=\"+list4+\"&scheduleid=\"+scheduleid+\"&licenseid=\"+licenseid;\t\t\t\n\t\n\t$.ajax({\n\t\ttype: 'post',\n\t\turl: \"class/newclass/class-newclass-expedition-ajax.php\",\n\t\tdata: dataparam,\n\t\tbeforeSend: function(){\t\t\t\n\t\t},\n\t\tsuccess:function(data) {\n\t\t\t$('#expextendcontent').html(data);\n\t\t}\n\t\t\n\t});\t\n\t}\n}", "title": "" }, { "docid": "136d495a1e20d89b621dad5a1a96156a", "score": "0.50983", "text": "function composeWith(data, type) {\n\t\n\t$('.slimScrollDiv').hide();\n\t$('.slimScrollDiv').has('#message-compose').show();\n\n\t//disable left sidebar if in compose page\n\twindow.snapper.disable();\n\t\n\t//flag page as compose\n\t$('.current-page').attr('id', 'compose');\n\n\t//navbar unset\n\t//hide delete message icon\n\t$('#delete-message').hide();\n\t//show send message icon\n\t$('#process-send').show();\n\t//hide compose message icon\n\t$('#compose-message').hide();\n\t$('.loading-messages').hide();\n\t$('.message-elem').hide();\n\t$('#message-compose').show();\n\t$('.to-holder').html('');\n\t$('.to-holder-shrink').html('');\n\t$('.to-holder-shrink').hide();\n\t$('#compose-contact').val('');\n\t$('#compose-contact').prev().html('');\n\t$('.warning-holder').html('');\n\t$('#compose-contact-list').html('');\n\t$('#compose-content').html('');\n\t$('#compose-content').val('');\n\t$('#compose-content').empty();\n\tvar contactList = window.contactList;\n\t\n\t//FOR OUTBOX\n\tif(type == 'Outbox') {\n\t\tvar res = data['b:Recipients']['b:Recipient'];\n\t\t//MESSAGE CONTENT\n\t\t$('#compose-content').html(data['content']);\n\t\t$('#compose-content').val(data['content']);\n \t\t//MESSAGE SUBJECT\n \t\t$('#compose-subject').val(data['b:Subject']);\n \t\t\n \t\t//MESSAGE PRIORITY\n \t\tif(typeof data['b:Priority'] !== 'undefined'){\n\t\t\tif(typeof data['b:Priority']['m_Value'] !== 'undefined') {\n\t\t\t\tif(data['b:Priority']['m_Value']['_'] == 'High') {\n\t\t\t\t\t$('#compose-important option')\n\t\t\t\t .removeAttr('selected')\n\t\t\t\t .filter('[value=1]')\n\t\t\t\t .attr('selected', true)\n\t\t\t\t $('#compose-important-button span').html('High') \n\t\t\t\t} else {\n\t\t\t\t\t$('#compose-important option')\n\t\t\t\t .removeAttr('selected')\n\t\t\t\t .filter('[value=0]')\n\t\t\t\t .attr('selected', true)\n\t\t\t\t $('#compose-important-button span').html('Normal') \n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t//FOR DRAFT\t\n\t} else {\n\t\t\n\t\tvar res = data['b:Label']['b:Recipients']['b:Recipient'];\n\t\t\n\t\t//MESSAGE CONTENT\n\t\t$('#compose-content').html(data['b:Content']);\n\t\t$('#compose-content').val(data['b:Content']);\n \t\t//MESSAGE SUBJECT\n \t\t$('#compose-subject').val(data['b:Label']['b:Subject']);\n \t\t\n \t\t//MESSAGE PRIORITY\n\t\tif(typeof data['b:Label']['b:Priority'] !== 'undefined'){\n\t\t\tif(typeof data['b:Label']['b:Priority']['m_Value'] !== 'undefined') {\n\t\t\t\tif(data['b:Label']['b:Priority']['m_Value']['_'] == 'High') {\n\t\t\t\t\t$('#compose-important option')\n\t\t\t\t .removeAttr('selected')\n\t\t\t\t .filter('[value=1]')\n\t\t\t\t .attr('selected', true)\n\t\t\t\t $('#compose-important-button span').html('High') \n\t\t\t\t} else {\n\t\t\t\t\t$('#compose-important option')\n\t\t\t\t .removeAttr('selected')\n\t\t\t\t .filter('[value=0]')\n\t\t\t\t .attr('selected', true)\n\t\t\t\t $('#compose-important-button span').html('Normal') \n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t}\n\t\n\tif(typeof res !== 'undefined') {\n\t\t//MESSAGE TO LISTING\n\t\t//if multiple contact list\n\t\tif(typeof res[0] !== 'undefined') {\n\t\t\t//find name\n\t\t\tfor(i in res) {\n\t\t\t\tfor(x in contactList) {\n\t\t\t\t\t\n\t\t\t\t\tif(res[i]['b:m_Receiver']['c:PortalAccess']['c:LoginId'] == contactList[x].data['b:PortalAccess']['b:LoginId']) {\n\t\t\t\t\t\t\n\t\t\t\t \tif(i < 2) {\n\t\t\t\t\t\t\t$('.to-holder').append(TO_COMPOSE.\n\t\t\t\t\t \t\treplace('[ID]', x).\n\t\t\t\t\t \t\treplace('[NAME]', window.contactList[x].name)\n\t\t\t\t\t \t);\t\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t$('.to-holder-shrink').append(TO_COMPOSE.\n\t\t\t\t\t \t\treplace('[ID]', x).\n\t\t\t\t\t \t\treplace('[NAME]', window.contactList[x].name)\n\t\t\t\t\t \t);\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$('.to-holder').append(\n\t\t\t\t'<div id=\"toggle-shrink\" style=\"float: left;margin-right: 7px;\" class=\"alert alert-info\" ><strong>more ...</strong></div>'\n\t\t\t);\n\t\t\t$('#toggle-shrink').click(function() {\n\t\t\t\t$('.to-holder-shrink').toggle();\n\t\t\t\tconsole.log('click')\n\t\t\t});\n\n\t\t} else {\n\t\t\tfor(x in contactList) {\n\t\t\t\t\n\t\t\t\tif(res['b:m_Receiver']['c:PortalAccess']['c:LoginId'] == contactList[x].data['b:PortalAccess']['b:LoginId']) {\n\t\t\t\t\t$('.to-holder').append(TO_COMPOSE.\n\t\t\t \t\treplace('[ID]', x).\n\t\t\t \t\treplace('[NAME]', contactList[x].name)\n\t\t\t \t);\n\t\t\t\t}\t\n\t\t\t}\n\t\t}\n\t}\n\t//populate autocomplete with contact listing\n\tfor(i in contactList) {\n\t\t\n\t\t$('#compose-contact-list').append(CONTACT_LIST.\n\t\t\treplace('[ID]', i).\n\t\t\treplace('[NAME]', contactList[i].name));\n\t}\n\n\t$('.ui-filterable input').focus();\n\t\n\t$('.ui-filterable input').click(function(e){ \n\t \t$(this).focus(); \n\t});\n\n $('.ui-filterable input').click(function(e) {\n $('.ui-filterable input').trigger('click');\n })\n\n\n\t$('.contact-pick').click(function() {\n\t\tvar id \t\t= $(this).attr('id');\n\t\tvar name \t= $(this).html();\n\t\tvar hasID \t= false;\n\n\t\t//unset warning\n\t\t$('.warning-holder').html('');\n\t\t\n\t\t$('.to-holder div').each(function() {\n\t\t\tvar ids = $(this).attr('id');\n\t\t\tif(ids == id) {\n\t\t\t\thasID = true;\n\t\t\t}\n\t\t});\n\n\t\t//unset now\n\t\t$('input#compose-contact-list').val('');\n\t\t$('ul#compose-contact-list li').each(function() {\n\t\t\t$(this).addClass('ui-screen-hidden');\n\t\t});\n\n\t\t//prevent double TO name in listing\n\t\tif(!hasID) {\n\t\t\t$('.to-holder').append(TO_COMPOSE.\n\t \t\treplace('[ID]', id).\n\t \t\treplace('[NAME]', name)\n\t \t);\n\t\t}\n\n\t\t//refresh page\n\t\t/*setTimeout(function(){window.composePage.refresh();\n\t\tconsole.log('xxx');}, 1000)*/\n\t});\n\n\t//now get the GUID\n\tvar guid = data['b:Label']['b:MessageGUID'];\n\t//and put it sa hidden input \n\t$('#detail-guid').val(guid);\n\t\n\tSoftKeyboard.show();\n\n\t//on click send button\n\tprocessSend(guid);\n}", "title": "" }, { "docid": "1742598ed699a702be1c7abac1690907", "score": "0.5097798", "text": "function MailingTo(id,statut,commentaire,mail_to, mail_cc, option){\n \n //if(values===undefined || typeof values!='object') throw 'no values for MailingTo';\n var html = HtmlService.createTemplateFromFile('template_email');\n var objet ='';\n var zoneAction ='';\n var url = ''\n var libelleBtn = ''\n var marge = '';\n var tblParamByStatus = '';\n var ctypedde='';\n var mail_sstraitance='';\n\n try {\n // Recuperation de la liste des statuts d'une demande d'achat\n var state=GetRowParams(COLUMN_STATE);\n \n switch(statut){\n case state.initialise : // Alimentation des donnees du template email\n html.id = globalDAData.id;\n html.bdc = \"\";\n html.fournisseur = globalDAData.fournisseur;\n html.statut = statut;\n html.demandeur = globalDAData.emetteur;\n html.typedemande = globalDAData.typedemande;\n html.nature = globalDAData.nature;\n html.contactfournisseur = globalDAData.contactfournisseur;\n html.buimputation = globalDAData.buimputation;\n html.codeprojet = globalDAData.codeprojet;\n html.nomprojet = globalDAData.nomprojet;\n html.quantite = globalDAData.quantite;\n html.prixunitairetjmachat = globalDAData.prixtjmachat;\n html.prixunitairetjmvendu = globalDAData.prixtjmvendu;\n marge = globalDAData.marge;\n if (marge != '') {\n html.marge = Utilities.formatString(\"%.2f\", marge);\n } else {\n html.marge = '';\n }\n html.collaborateur = globalDAData.collaborateur;\n html.datedebutlivraison = globalDAData.datedebutlivraison;\n html.datefinlivraison = globalDAData.datefinlivraison;\n html.adresselivraison = globalDAData.adresselivraison;\n html.conditionreglement = globalDAData.conditionreglement;\n html.urldevis = globalDAData.urlDevis;\n html.lblbdcsigne = \"\";\n html.urlbdcsigne = \"\";\n html.acteurcourant = globalDAData.managerBU;\n tblParamByStatus = getParamPageByStatus(state.initialise);\n url = (option)?getProcessAchatUrl()+'?page='+tblParamByStatus.status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je traite la demande d\\'achat';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n break;\n case state.invalideeNiv0 : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de la zone d'action de l'email\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n zoneAction += '<div style=\"text-decoration:none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;padding: 15px;margin-bottom: 20px;border: 1px solid transparent;border-radius: 4px;color: #a94442;background-color: #f2dede;border-color: #ebccd1;margin-right: 15px;margin-left: 15px;\"><b>&#9432;</b>&nbsp;Demande refusée par '+html.acteurcourant;\n zoneAction += ' <p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Motif du refus : '+commentaire.nl2br()+'</p>';\n zoneAction += '</div>';\n break;\n case state.valideeNiv0 : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de l'url de l'action et de la zone d'action de l'email\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.valideeNiv0).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je traite la demande d\\'achat';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n break;\n case state.invalideeNiv1 : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de la zone d'action de l'email\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n zoneAction += '<div style=\"text-decoration:none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;padding: 15px;margin-bottom: 20px;border: 1px solid transparent;border-radius: 4px;color: #a94442;background-color: #f2dede;border-color: #ebccd1;margin-right: 15px;margin-left: 15px;\"><b>&#9432;</b>&nbsp;Demande refusée par '+html.acteurcourant;\n zoneAction += ' <p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Motif du refus : '+commentaire.nl2br()+'</p>';\n zoneAction += '</div>';\n break;\n case state.valideeNiv1 : // Alimentation des donnees du template email\n copyData2Form(html, statut, GetManagerBU(BU_ENTREPRISE_PARIS));\n // Definition de l'url de l'action et de la zone d'action de l'email\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.valideeNiv1).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je traite la demande d\\'achat';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n break;\n case state.invalideeNiv2 : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de la zone d'action de l'email\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n zoneAction += '<div style=\"text-decoration:none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;padding: 15px;margin-bottom: 20px;border: 1px solid transparent;border-radius: 4px;color: #a94442;background-color: #f2dede;border-color: #ebccd1;margin-right: 15px;margin-left: 15px;\"><b>&#9432;</b>&nbsp;Demande refusée par '+html.acteurcourant;\n zoneAction += ' <p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Motif du refus : '+commentaire.nl2br()+'</p>';\n zoneAction += '</div>';\n break;\n case state.valideeNiv2 : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de l'url d'action et de la zone d'action de l'email\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.valideeNiv2).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je traite la demande d\\'achat et je génère le bon de commande';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n break;\n case state.bdcGenere : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Defintion de l'url d'action et de la zone d'action de l'email\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.bdcGenere).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je reporte la décision de la direction financière';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n zoneAction += '<div style=\"text-decoration:none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;padding: 15px;margin-bottom: 20px;border: 1px solid transparent;border-radius: 4px;color: #468847;background-color: #dff0d8;border-color: #d6e9c6;margin-right: 15px;margin-left: 15px;\"><b>&#8618;</b>&nbsp;Impression du bon de commande provisoire n°<a href=\"'+globalDAData.urlBDCpdf+'\">'+globalDAData.bdc+'</a>';\n zoneAction += '</div>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n break;\n case state.invalideeNiv3 : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de la zone d'action de l'email\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n zoneAction += '<div style=\"text-decoration:none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;padding: 15px;margin-bottom: 20px;border: 1px solid transparent;border-radius: 4px;color: #a94442;background-color: #f2dede;border-color: #ebccd1;margin-right: 15px;margin-left: 15px;\"><b>&#9432;</b>&nbsp;Demande refusée par '+html.acteurcourant;\n zoneAction += ' <p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Motif du refus : '+commentaire.nl2br()+'</p>';\n zoneAction += '</div>';\n break;\n case state.valideeNiv3 : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Si type de demande = Interne Alors SendBDC sinon EditAPP \n ctypedde = getInfoDA(id).codetypedemande\n // Evolution #2\n \n /*if ((ctypedde != null) && (ctypedde != 'INT')) {\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.valideeNiv3).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je saisis le bon de commande dans APP';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n } else {\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.appMisAJour).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je transmets le bon de commande au fournisseur';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n }*/\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.valideeNiv3).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je valide la diffusion du bon de commande au fournisseur';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n // Evolution #2\n break;\n // Evolution #2\n case state.valideeDiffusion : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Si type de demande = Interne Alors SendBDC sinon EditAPP \n ctypedde = getInfoDA(id).codetypedemande\n if ((ctypedde != null) && (ctypedde != 'INT')) {\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.valideeNivDiffusion).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je saisis le bon de commande dans APP';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n } else {\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.appMisAJour).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je transmets le bon de commande au fournisseur';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n }\n break;\n case state.invalideeDiffusion : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de la zone d'action de l'email\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n zoneAction += '<div style=\"text-decoration:none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;padding: 15px;margin-bottom: 20px;border: 1px solid transparent;border-radius: 4px;color: #a94442;background-color: #f2dede;border-color: #ebccd1;margin-right: 15px;margin-left: 15px;\"><b>&#9432;</b>&nbsp;Demande refusée par '+html.acteurcourant;\n zoneAction += ' <p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Motif du refus : '+commentaire.nl2br()+'</p>';\n zoneAction += '</div>';\n break;\n // Evolution #2\n case state.appMisAJour :// Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // Definition de l'url d'action et de la zone d'action de l'email\n url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.appMisAJour).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je transmets le bon de commande au fournisseur';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n break;\n case state.bdcTransmis : // Alimentation des donnees du template email\n copyData2Form(html, statut, Session.getActiveUser().getEmail());\n // $TODO : V1\n /*url = (option)?getProcessAchatUrl()+'?page='+getParamPageByStatus(state.bdcTransmis).status+'&ref='+id:'#';\n url = encodeURI(url);\n libelleBtn = 'Je receptionne la facture du fournisseur';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' <a href=\"'+url+'\" class=\"btn btn-outline btn-md\" style=\"text-decoration: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;background-color: transparent;color: #336699;display: inline-block;padding: 6px 12px;margin-bottom: 0;font-size: 14px;font-weight: normal;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;border-color: #563d7c;\">'+libelleBtn+'</a>';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n */\n libelleBtn = '';\n url='#';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">Commentaire attaché à la demande : '+commentaire.nl2br()+'</p>';\n zoneAction += '<p style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;orphans: 3;widows: 3;margin: 0 0 10px;\">';\n zoneAction += ' <div class=\"text-center\" style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;text-align: center;color: #505050;font-family: Arial;font-size: 14px;line-height: 150%;\">';\n zoneAction += ' </div>';\n zoneAction += '</p>';\n zoneAction += '<br style=\"-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;\">';\n break;\n case state.factureBpfReceptionnes : // Alimentation des donnees du template email\n // $TODO : V1\n break;\n default : break;\n }\n // Si la DA est de type sous-traitance alors ajout de la liste de diffusion sous-traitance dans l'envoi de l'email\n if (isSousTraitance(globalDAData.codetypedemande) == true) {\n mail_sstraitance = GetEMAIL_SOUSTRAITANCE();\n }\n html.form_action='%%body_mail%%';\n // S.VIOT 01/10 Suppression du logo SQLi Entreprise : pb de performance\n var sqliLogoUrl = \"http://www.sqli-enterprise.com/files/2014/05/logo_sqli_entreprise_340x156_bg_transp1.png\";\n var sqliLogoBlob = UrlFetchApp\n .fetch(sqliLogoUrl)\n .getBlob()\n .setName(\"sqliLogoBlob\");\n objet = SUBJECT.replace('%%id%%',id)\n .replace('%%fournisseur%%',globalDAData.fournisseur)\n .replace('%%buimputation%%',globalDAData.buimputation)\n .replace('%%statut%%',statut);\n var advancedArgs = {\n to: mail_to,\n cc: EMAIL_CC +','+mail_cc+','+mail_sstraitance,\n subject: objet,\n htmlBody: html.evaluate().getContent().replace('%%body_mail%%',zoneAction),\n inlineImages:{\n sqliLogo: sqliLogoBlob\n },\n };\n Log_Info(\"MailingTo\", Utilities.formatString(\"advancedArgs=%s\",Utilities.jsonStringify(advancedArgs)));\n if(option) MailApp.sendEmail(advancedArgs);\n return advancedArgs;\n } catch(e){\n e = (typeof e === 'string') ? new Error(e) : e;\n Log_Severe(\"MailingTo\", Utilities.formatString(\"%s %s (line %s, file '%s'). Stack: '%s' . While processing %s.\",e.name||'',e.message||'',e.lineNumber||'',e.fileName||'', e.stack||'', e.processMessage||''));\n throw e;\n }\n}", "title": "" }, { "docid": "80ebaf324013d86dd61469a1b926a5f5", "score": "0.50956047", "text": "function manageContacts() {\n if (!name && !email && !phoneNumber) {\n Alert.alert('Something went wrong', 'Please fill the all fields');\n return;\n }\n const myPhonenumber = [{label: 'phone', number: phoneNumber}];\n\n const myEmail = [{label: 'email', email: email}];\n\n // do add and existing contact based on existingData\n if (existingData === undefined) {\n const contactInfo = {\n givenName: name,\n emailAddresses: myEmail,\n phoneNumbers: myPhonenumber,\n };\n // addContact api\n Contacts.addContact(contactInfo)\n .then(() => navigation.navigate('MyContacts'))\n .catch(error => console.log(error));\n } else {\n const contactInfo = {\n recordID: existingData.recordID,\n givenName: name,\n emailAddresses: myEmail,\n phoneNumbers: myPhonenumber,\n };\n\n // editExistingContact api\n Contacts.editExistingContact(contactInfo)\n .then(() => navigation.navigate('MyContacts'))\n .catch(error => console.log(error));\n }\n }", "title": "" }, { "docid": "f909c3d4883ed78df7e1adafc1fdcb48", "score": "0.5082891", "text": "contact(appUUID, contactParameters) {\n for (var contactParametersKey in contactParameters) {\n console.log(appUUID +\n \":contact:\" +\n contactParametersKey + \"=\" + contactParameters[contactParametersKey]\n );\n }\n if (!contactParameters.fromEmail) {\n contactParameters.fromEmail = ilendbooks.private.generic.FROM_EMAIL;\n }\n\n // if (ilendbooks.public.contactPreference.EMAIL === contactParameters.contactPreference) {\n\n var emailResult = Email.send({\n to: contactParameters.email,\n from: contactParameters.fromEmail,\n subject: contactParameters.emailSubject,\n text: contactParameters.emailBody,\n });\n\n console.log(appUUID + \":contact:email sent.\" + emailResult);\n\n contactParameters.contactResult = emailResult;\n contactParameters.status = ilendbooks.public.status.SUCCESS;\n for (var contactResultKey in contactParameters.contactResult) {\n console.log(appUUID +\n \":contact:contactResult (email):\" +\n contactResultKey + \"=\" + contactParameters.contactResult[contactResultKey]);\n }\n\n if (ilendbooks.public.contactPreference.PHONE === contactParameters.contactPreference) {\n var smsParameters = {\n to: contactParameters.phoneNumber,\n message: contactParameters.smsMessage\n }\n var smsResult = Meteor.call('sendSMS', appUUID, smsParameters);\n contactParameters.contactResult = smsResult;\n contactParameters.contactStatus = smsResult.status;\n contactParameters.status = ilendbooks.public.status.SUCCESS;\n }\n // } else {\n // console.log(appUUID + \":contact: Fatal, no good, no contact preference...\");\n // contactParameters.status = ilendbooks.public.status.FAILED;\n // contactParameters.contactResult = \"No contact preference for this user \" + contactParameters.borrowerUserId;\n // }\n Meteor.call(\"insertCorrespondence\", appUUID, contactParameters.toUserId, contactParameters.ilendbooksId, contactParameters);\n console.log(appUUID + \":contact:emailed successfully \");\n }", "title": "" }, { "docid": "f484b7773f05e7f4d8c27755a393756d", "score": "0.50729674", "text": "function displayContact(tel, website) {\n\t$(\"#cinemaInformation #contact\").empty();\n\t$(\"#cinemaInformation #contact\").append(\"<p><b>Phone number:</b></p><p>\"+tel+\"</p>\");\n\t$(\"#cinemaInformation #contact\").append('<p><b>Website:</b></p><p><a href=\"#\">'+website+\"</a></p>\");\n}", "title": "" }, { "docid": "484b824ac9936f6d825c865d585a6d02", "score": "0.5055943", "text": "function contactsSelect(){\n\n $(document).on('click', '.contacts-info-select-list-text', function(){\n\n $(this).toggleClass('active');\n\n $('.contacts-info-select-list-wrap').stop().slideToggle(300);\n\n });\n\n $(document).on('click','.contacts-info-select-list-wrap li', function(){\n\n var town = $(this).attr('data-town');\n\n var townText = $(this).text();\n\n $('.contacts-info-select-list-text').removeClass('active').text(townText);\n\n $('.contacts-info-select-list-wrap').slideUp(300);\n\n $('.contacts-info-adress-tab-item').removeClass('active');\n\n $('.contacts-info-adress-tab-item[data-town='+town+']').addClass('active');\n\n });\n\n $('.contacts-info-select-list-wrap li').eq(0).click();\n\n }", "title": "" }, { "docid": "c2e8e50e42682e3ae4056c5be3d23f7c", "score": "0.5055363", "text": "function createMission() {\r\n var text = \"QGC WPL 110\\n\";\r\n // HOME POINT\r\n var lon = HomePoint_List.get(currentStatusDisplay)[0];\r\n var lat = HomePoint_List.get(currentStatusDisplay)[1];\r\n\ttext += \"0\\t1\\t0\\t16\\t0\\t0\\t0\\t0\\t\"+lat+\"\\t\"+lon+\"\\t2\\t1\\n\";\r\n\t\r\n\tvar MissionListSelectedVehicle = Mission_List.get(Number(currentStatusDisplay));\r\n\t\r\n\tvar index = 1;\r\n\tfor(var i=0; i<MissionListSelectedVehicle.length; i++){\r\n\t\tdata = MissionListSelectedVehicle[i];\r\n\t\tif(data.TYPE == \"POINT\"){\r\n\t\t\tvar lon = WayPoint_List.get(Number(data.ID))[0];\r\n\t\t\tvar lat = WayPoint_List.get(Number(data.ID))[1];\r\n\t\t\ttext += index + \"\\t0\\t3\\t\"+data.COMMAND+\"\\t0.00000000\\t0.00000000\\t0.00000000\\t0.00000000\\t\" + lat + \"\\t\" + lon + \"\\t\"+data.ALT+\"\\t1\\n\";\r\n\t\t\tindex++;\r\n\t\t}\r\n\t}\r\n lon = HomePoint_List.get(currentStatusDisplay)[0];\r\n lat = HomePoint_List.get(currentStatusDisplay)[1];\r\n\ttext += index + \"\\t0\\t3\\t20\\t0.00000000\\t0.00000000\\t0.00000000\\t0.00000000\\t\" + lat + \"\\t\" + lon + \"\\t10\\t1\\n\";\r\n return text;\r\n}", "title": "" }, { "docid": "e757e88d9ade62bd69a408fad8b4d2d4", "score": "0.50523376", "text": "function openContent(evt, contactID) \n{\n\t\tvar $tabcontent = $('.tabcontent');\n\t\tvar $edit = $('.edit');\n\t\t$edit.show();\n\t\tvar $givenName, $surname;\n\t\t$tabcontent.empty(); \n\t\n\t\t//initially its empty we can keep default by using document.(\"#content\").setdefault();\n\t\t\n\t\t/*when left navigation name and surname is clicked it display name and surname to right side*/\n\t\t$.ajax({\n\t\ttype: 'GET',\n\t\tcache:'false',\n\t\turl: '/contacts/'+contactID,\n\t\tcache: 'false',\n\t\tsuccess: function(tabcontent){\n\t\t\t$.each(tabcontent,function(i,link) \n\t\t\t\t{\n\t\t\t\t$tabcontent.append('<input type=\"image\" onClick=\"edit('+contactID+');\" src=\"images/edit-record.png\" height=\"30px\" width=\"30px\" style=\"margin-top: 20px \">');\n\t\t\t \n\t\t\t\t$tabcontent.append('<table class=\"displayname\" align=\"center\" style=\"margin-right: 60px;\"><tr><td>Name </td><td>'+tabcontent.givenName+'</td></tr><tr><td> Surname </td><td>'+tabcontent.surname+'</td></tr></table>').insertAfter(\"img class=''\");\n\t\t\t });\n\t\t}\n\n\t\t});\n\t\t\n\t\t//to display phone number of particular contactid\n\t\t$.ajax({\n\t\ttype: 'GET',\n\t\t//cache:'false',\n\t\turl: '/contacts/'+contactID+'/phones',\n\t\tcache: 'false',\n\t\t\tdataType:'json',\n\t\t\n\t\tsuccess: function(phonenumber){\n\t\t\t\n\t\t$.each(phonenumber,function(i,contacts) {\t\t\t \n\t\t\t\t $tabcontent.append('<table class=\"displayphone\" align=\"center\" style=\"margin-top: 0px; margin-right: 60px;\"><tr><td>'+contacts.phoneType+'</td><td> '+contacts.phoneNumber+'</td></tr></table>');\n\t\t\t\t\t\n\t\t});\n\t\t\n\t\t}\n\n\t\t});\n\t\t\n\t/*get particular contact address*/\n\t\t$.ajax({\n\t\ttype: 'GET',\n\t\t//cache:'false',\n\t\turl: '/contacts/'+contactID+'/addresses',\n\t\tcache: 'false',\n\t\tdataType:'json',\n\t\t\n\t\tsuccess: function(address){\n\t\t\t\n\t\t$.each(address,function(i,addresses)\n\t\t{\t\t\t \n\t\t\t$tabcontent.append('<table class=\"displayaddress\" align=\"center\" style=\"margin-top: 0px; margin-right: 60px;\"><tr><td>'+addresses.addressType+' </td><td> '+addresses.street+'</td></tr></table>');\n\t\t\t \n\t\t\t$tabcontent.append('<table class=\"displayaddress\" align=\"center\" style=\"margin-top: 0px; margin-right: 60px;\"><tr><td>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</td><td> '+addresses.city+' '+addresses.state+' '+addresses.postalCode+'</td></tr></table>');\n\t\t\t\t\t\n\t\t});\n\t\t\n\t\t}\n\n\t\t});\n\t\t\n}", "title": "" }, { "docid": "ae2bdb525ddd85fbce91401ed601f84c", "score": "0.5050119", "text": "function customer_questionList() {\n document.getElementById('more-listItem-toQuestionList').addEventListener('click', function() {\n // debugging\n // alert('guideTo_wrapper_questionList');\n\n // hide all other wrappers\n wrappers = document.getElementsByClassName('wrapper-more');\n for (var i = 0; i < wrappers.length; i++) {\n wrappers[i].style.display = 'none';\n }\n // show wrapper-questionList\n document.getElementById('wrapper-questionList').style.display = 'block';\n\n // reset listItemSettings\n listItemSettings();\n });\n}", "title": "" }, { "docid": "23fa6252c8aa29d64bd036e8d9de8bfc", "score": "0.50499326", "text": "function aspire_helpCommand(commandname, subject, body, ci\n , completesubjectline\n , completeBody)\n{\nvar qhelp = \"<pre><code>\";\nqhelp = qhelp + \"\\ncode\\ncode1\\nimages\\nimage\\nlink\\nquestion\\ngquestion\\naquestion\\nwhoareyou\\ndict\\nplist\\nolist\\nhelp\";\nqhelp = qhelp + \"</code></pre>\";\n\nvar baseurl=\"/akc/display?url=DisplayNoteIMPURL&reportId=3905&downerUserId=satya\";\n//body exists\nvar newbody = '<p><a href=\"' + baseurl + '\">Click her to see full help</a></p>';\nnewbody = newbody + qhelp;\nci.newSubject=subject;\nci.newAppendText = newbody;\n}", "title": "" }, { "docid": "4a423100f9a738240d638b7d9d1c14be", "score": "0.5046207", "text": "function updateQuestList()\n{\t\n\t$.Msg(quests);\n\t$(\"#quest-con\").RemoveAndDeleteChildren();\n\tquestListSection(\"Active\", String.fromCharCode(9671), true);\n\tquestListSection(\"Completed\", String.fromCharCode(9670), false);\n}", "title": "" }, { "docid": "634b6019713863750bd3042e899e08e1", "score": "0.5038797", "text": "function addC(tipo) {\n\tvar d = document.getElementById(\"fortextarea\"+tipo);\n var d1 = document.getElementById(\"button\"+tipo);\n var textarea = document.createElement(\"textarea\");\n\n textarea.setAttribute(\"rows\", \"3\");\n textarea.setAttribute(\"cols\", \"65\");\n textarea.setAttribute(\"name\", tipo);\n textarea.setAttribute(\"id\", \"textarea\" + tipo);\n textarea.setAttribute(\"disabled\",\"true\");\n textarea.setAttribute(\"class\",\"textareacontacts\");\n\n var contacts = document.createElement(\"a\");\n var text = document.createTextNode(\"'.get_string('participants', 'block_email_list').'...\");\n\n \tcontacts.appendChild(text);\n contacts.setAttribute(\"target\", \"participants\");\n contacts.setAttribute(\"title\", \"'.get_string('participants', 'block_email_list').'\");\n contacts.setAttribute(\"href\", \"'. $CFG->wwwroot .'/blocks/email_list/email/participants.php?'. $url .'\");\n contacts.setAttribute(\"onclick\", \"return openpopup(\\'/blocks/email_list/email/participants.php?'.$url.'\\', \\'participants\\', \\'menubar=0,location=0,scrollbars=0,resizable,width=750,height=520\\', 0)\");\n\n d.appendChild(textarea);\n d1.appendChild(contacts);\n\n var b = document.createElement(\"b\");\n \tvar txt;\n\n \tif ( tipo == \"cc\") {\n\t\ttxt = \"'. get_string('cc', 'block_email_list').'\" ;\n \t} else {\n \t\ttxt = \"' .get_string('bcc', 'block_email_list') . '\";\n \t}\n\n\tvar node=document.createTextNode(txt+\": \");\n\tb.appendChild(node);\n \tdocument.getElementById(\"td\"+tipo).appendChild(b);\n\n\tvar rm = document.getElementById(\"url\"+tipo);\n\tdocument.getElementById(\"url\").removeChild(rm);\n\n\tvar rm1 = document.getElementById(\"urltxt\");\n\n\tif ( rm1 ) {\n\t\tdocument.getElementById(\"url\").removeChild(rm1);\n\t}\n}", "title": "" }, { "docid": "dc8f4807ca2ac84f38a55cee544a39c2", "score": "0.5035728", "text": "function switchToList(){\n postal.publish({\n channel:'planetInterface',\n topic:'switchToList',\n data: null\n });\n }", "title": "" }, { "docid": "a2b1952bf5d7639848d82cb37ea57af6", "score": "0.5031657", "text": "function ShowContactDetailDlg(xml) {\r\n\tg_ContactID = $(xml).find(\"ID\").text();\r\n\tvar sName = $(xml).find(\"name\").text();\r\n\t\r\n\t$(\"#CD-NAME-LABEL\")\r\n\t\t\t.html(\r\n\t\t\t\t\tsLContactLabelName + '<input id=\"CD-NAME-VAL\" type=\"text\" value=\"' + sName\r\n\t\t\t\t\t\t\t+ '\"/>');\r\n\t$(\"#CD-PHONE-LABEL\")\r\n\t\t\t.html(\r\n\t\t\t\t\tsLContactLabelPhone\r\n\t\t\t\t\t\t\t+ '<a href=\"#\" class=\"aHasBk sprite sprite-add-item\" onclick=\"OnAddContactItem(\\'phone\\');\"></a>');\r\n\t$(\"#CD-EMAIL-LABEL\")\r\n\t\t\t.html(\r\n\t\t\t\t\tsLContactLabelEmail\r\n\t\t\t\t\t\t\t+ '<a href=\"#\" class=\"aHasBk sprite sprite-add-item\" onclick=\"OnAddContactItem(\\'email\\');\"></a>');\r\n\t$(\"#CD-ADDR-LABEL\").html(sLContactLabelAddr);\r\n\r\n\t$(\"#CD-PHONE-LIST\").html(\"\");\r\n\t$(\"#CD-EMAIL-LIST\").html(\"\");\r\n\t$(\"#CD-ADDR-LIST\").html(\"\");\r\n\t\r\n\tif (g_iCDOpType != CD_OP_TYPE_ADD){\r\n\t\t$(\"#CD-INSERT-CONTACT-BTN\").text(sLUpdateContact);\r\n\t}\r\n\telse {\r\n\t\t$(\"#CD-INSERT-CONTACT-BTN\").text(sLAddContact);\r\n\t}\r\n\t\r\n\tvar id = 0;\r\n\t\r\n\t$(xml).find(\"phone\").each(function(i) {\r\n\t\t\t\t\t\tvar phoneTxt = $(this).text();\r\n\t\t\t\t\t\tif (phoneTxt == null){\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tvar phoneItem = phoneTxt.split(\":\");\r\n\t\t\t\t\t\tvar phoneType = phoneItem[0];\r\n\t\t\t\t\t\tvar phoneNo = phoneItem[1];\r\n\t\t\t\t\r\n\t\t\t\t\t\tid = OnAddContactItem('phone');\r\n\t\t\t\t\t\t$('#' + id).find('.p-CD-PHONE-TYPE').val(phoneType);\r\n\t\t\t\t\t\t$('#' + id).find('.p-CD-PHONE-NO').val(phoneNo);\r\n\t\t\t\t\t});\r\n\tif (id == 0){\r\n\t\tOnAddContactItem('phone');\r\n\t}\t\r\n\t\r\n\t$(xml).find(\"email\").each(\r\n\t\t\t\t\tfunction(i) {\r\n\t\t\t\t\t\tvar etxt = $(this).text();\r\n\t\t\t\t\t\tif (etxt == null){\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tvar emailItem = etxt.split(\":\");\r\n\t\t\t\t\t\tvar emailType = emailItem[0];\r\n\t\t\t\t\t\tvar email = emailItem[1];\r\n\t\t\t\t\t\r\n\t\t\t\t\t\tid = OnAddContactItem('email');\r\n\t\t\t\t\t\t$('#' + id).find('.p-CD-EMAIL-TYPE').val(emailType);\r\n\t\t\t\t\t\t$('#' + id).find('.p-CD-EMAIL-VAL').val(email);\r\n\t\t\t\t\t});\r\n\r\n\tOnAddContactItem('addr');\r\n\t$(xml).find(\"addr\").each(\r\n\t\t\tfunction(i) {\r\n\t\t\t\tvar addrtxt = $(this).text();\r\n\t\t\t\tif (addrtxt == null){\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tvar addrItem = addrtxt.split(\":\");\r\n\t\t\t\tvar addrType = addrItem[0];\r\n\t\t\t\tvar addr = addrItem[1];\r\n\t\t\t\t\r\n\t\t\t\t$(\"#CD-\" + addrType).val(addr);\r\n\t\t\t});\r\n\r\n\t$.colorbox( {\r\n\t\tinline : true,\r\n\t\thref : '#CONTACT-DETAIL-DIV'\r\n\t});\r\n}", "title": "" }, { "docid": "37ea6ba28cbad891dc8c652dea2f1c51", "score": "0.50282824", "text": "function _showContactsList() {\n vm.showList = true;\n }", "title": "" }, { "docid": "4639993be9e86e173c1a82e6eb117dd8", "score": "0.50256056", "text": "function getContactListHTML (id) {\n\tvar html = \"\";\n\thtml += '<h2 class=\"contact-list-name\">' + contacts.contact_info[id].name + '</h2>'\n\thtml += '<li class=\"ui-li-has-thumb ui-first-child\">'\n\thtml += '<h3>' + contacts.contact_info[id].relation + '</h3>' // maybe take this out if needbe, or add a condition/make it optional\n\thtml += '<a class=\"bigiconfont\" href=\"#zoomcontact' + id + '\">'\n\thtml += '<img src=' + contacts.contact_info[id].photo_file_path + ' />'\n\thtml += '<div class=\"meep\">View</div>'\n\thtml += '</a></li>'\n\t//$(\"#contact_list\").append(html);\n\treturn html;\n}", "title": "" }, { "docid": "2e033f0c8362630adb21bd44e929688a", "score": "0.5024711", "text": "function startContactLoad() {\n return {\n type: CONTACT_LOAD_REQUEST,\n isFetchingContact: true,\n };\n}", "title": "" }, { "docid": "e4654b0caf4d907f3191ea326ea93cca", "score": "0.5018402", "text": "function render(contacts) {}", "title": "" }, { "docid": "cf77ba9b999186f2f7879da8eff78c91", "score": "0.5014428", "text": "function addMappingToTheWaitingList() {\t\n\ttry{\n\t\t//arguments for Add button\n\t\tvar chAcc = nlapiGetFieldValue('custrecord_trigger_cn_account_number');\n\t\tvar chAccName = nlapiGetFieldText('custpage_chinaaccountname');//CHINA ACCOUNT NAME\n\t\tvar nsAcc = nlapiGetFieldValue('custrecord_trigger_netsuite_account');\n\t\tvar nsAccID = nlapiGetFieldValue('custrecord_trigger_ns_account_id');\n\t\tvar sbsdry = nlapiGetFieldValue('custrecord_trigger_ns_subsidiary');\n\t\tvar sbsdryName = nlapiGetFieldText('custrecord_trigger_ns_subsidiary');// SBSDRY NAME\n\t\tvar isO2MMapping = nlapiGetFieldValue('custrecord_trigger_one_to_many');\t\t\n\t\tvar dptmnt = nlapiGetFieldValue('custrecord_trigger_ns_department');\n\t\tvar dptmntName = nlapiGetFieldText('custrecord_trigger_ns_department');//DEPARTMENT NAME\n\t\tvar lctn = nlapiGetFieldValue('custrecord_trigger_ns_location');\n\t\tvar lctnName = nlapiGetFieldText('custrecord_trigger_ns_location');//LOCATION name\n\t\tvar cls = nlapiGetFieldValue('custrecord_trigger_ns_class');\t\n\t\tvar clsName = nlapiGetFieldText('custrecord_trigger_ns_class');//CLASS name\n\t\t\n\t\tvar isInputValid = isValidMapping(sbsdry, isO2MMapping, dptmnt, lctn, cls);\n\t\tif (isInputValid.status == 'error'){\n\t\t\tthrow isInputValid.details;\n\t\t}\n\t\tif(isInputValid){\n\t\t\tnlapiSelectNewLineItem('custpage_sublist_cncoa_mapping');\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_is_mapping_selected', 'T', false, true);\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_china_acc_name', chAccName, false, true);\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_ns_acc', nsAcc, false, true);\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_sbsdry_name', sbsdryName, false, true);\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_mapping2many', isO2MMapping, false, true);\n\t\t\t\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_china_acc', chAcc, false, true);\t\t\t\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_ns_acc_id', nsAccID, false, true);\n\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_sbsdry', sbsdry, false, true);\n\t\t\t\n\t\t\tif(isO2MMapping == 'T'){ //populate classification values only for 12Many mapping chosen\n\t\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_deptmnt_name', dptmntName, false, true);\n\t\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_deptmnt', dptmnt, false, true);\n\t\t\t\t\n\t\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_lctn_name', lctnName, false, true);\n\t\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_lctn', lctn, false, true);\n\t\t\t\t\n\t\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_cls_name', clsName, false, true);\n\t\t\t\tnlapiSetCurrentLineItemValue('custpage_sublist_cncoa_mapping', 'custpage_cls', cls, false, true);\n\t\t\t}\n\t\t\tnlapiCommitLineItem('custpage_sublist_cncoa_mapping');\n\t\t}\n\t}catch(ex){\n\t\tnlapiLogExecution('DEBUG','addMappingToTheWaitingList',ex);\n\t\tcommon.sendErrorEmail('[email protected]', 'FinLocalization', 'TN_CS_CN_COA_MappingForm', 'addMappingToTheWaitingList', ex.message);\n\t}\n}", "title": "" }, { "docid": "81c19a7262ff6f24f85d69892fbeadb0", "score": "0.50135595", "text": "function sendList() {\n var msg;\n\n msg = {};\n msg.links =[];\n msg.collection = g.list;\n\n msg.links.push(m.addControl);\n\n if(msg.collection.length>0) {\n msg.links.push(m.listControl);\n msg.links.push(m.searchControl);\n }\n\n res.writeHead(200, 'OK', m.appJson);\n res.end(JSON.stringify(msg,null,2));\n }", "title": "" }, { "docid": "3273dc96e546bb1871be904c5753ec82", "score": "0.5013198", "text": "function Dispositivo_Listo(){\n\t\tComienza();\n\t}", "title": "" }, { "docid": "3aad78906c073c57202c4d92a51078ce", "score": "0.5003571", "text": "function displayContact(idx) {\n\t\tvar item = this.getItem(idx);\n\t\tvar contactId = item.id;\n\t\tcontactView.set(\"href\", \"data/contact.php?contact_id=\"+contactId);\n\n\t\tmnuEditContact.set(\"disabled\", false);\n\t\tmnuMoveContact.set(\"disabled\", false);\n\t\tmnuDeleteContact.set(\"disabled\", false);\n\t\tctxMnuEditContact.set(\"disabled\", false);\n\t\tctxMnuMoveContact.set(\"disabled\", false);\n\t\tctxMnuDeleteContact.set(\"disabled\", false);\n\t}", "title": "" }, { "docid": "1c17d13aaaa6d7c90b52772d3ae958db", "score": "0.50033504", "text": "function ContactsSync_elementsExtraJS() {\n // screen (ContactsSync) extra code\n\n /* device_contact_sync_status */\n\n $(\"#ContactsSync_device_contact_sync_status\").parent().find(\".ui-flipswitch-on\").attr(\"tabindex\", \"6\");\n\n }", "title": "" }, { "docid": "b018d9aa9101144b68bff91c25da1c68", "score": "0.5001802", "text": "function addToMylist() {\r\n\talert('This action shouldn\\'t be possible.\\nPlease inform an anidb moderator what you have done to get this message.');\r\n\treturn true;\r\n}", "title": "" }, { "docid": "bc9ca7ed07010176ed4587107c067952", "score": "0.49992087", "text": "function MailingListForOverlayVisit(frm) {\n\n if (frm.length == 0) return;\n\n function validateEmail(email) {\n\n var filter = /^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$/;\n if (!filter.test(email)) {\n\n return false;\n }\n return true;\n }\n // alert(\"test overlay\");\n frm.submit = doSubmit;\n\n function onAjaxLoaded(data) {\n\n data = $.parseJSON(data);\n data = data || {};\n if (data.status != 0) { // failed\n msg.html('<span class=\"failed\">We failed to submit. Please <a>try again</a> later.<span>')\n msg.find(\"a\").click(function () {\n idle.css(\"display\", \"block\");\n if (agr) agr.css(\"display\", \"block\");\n msg.css(\"display\", \"none\");\n });\n }\n else { // success\n msg.html(\"Thank you for your subscription.\");\n }\n }\n\n var field = $(\"#subscribe_field1\");\n var check = $(\"#subscribe_check1\");\n\n var defaultText = field.data(\"default\");\n var idle = frm.children(\".idle\");\n var msg = frm.children(\".message\");\n var agr = frm.children(\".agree\");\n\n\n function doSubmit() {\n if (check.length) {\n if (!check[0].checked) {\n msg.css(\"display\", \"block\");\n msg.html(\"<br>You have to agree to the terms and conditions.\");\n return false;\n }\n }\n var val = field.val();\n if (validateEmail(val)) {\n field.removeClass(\"error\");\n $.ajax({ url: $API.SUBSCRIBE, type: \"POST\", data: { \"service\": \"subscribe\", \"email\": val }, success: onAjaxLoaded }); //.done(onAjaxLoaded);\n idle.css(\"display\", \"none\");\n if (agr) agr.css(\"display\", \"none\");\n msg.css(\"display\", \"block\");\n msg.html(\"Subscribing...\");\n return false;\n }\n else {\n field.addClass(\"error\");\n field.focusin(function () {\n field.removeClass(\"error\");\n field.unbind(\"focusin\");\n });\n return false;\n }\n }\n\n function handleKeyPress(e) {\n var key = e.keyCode || e.which;\n\n if (key == 13) {\n\n doSubmit();\n return false;\n }\n return true;\n }\n field.keypress(handleKeyPress);\n frm.find(\".submit\").click(doSubmit);\n}", "title": "" }, { "docid": "bbe0cf633d01777ce2d6593eb0ffabc9", "score": "0.4996344", "text": "function startContactAllLoad() {\n return {\n type: CONTACT_ALL_LOAD_REQUEST,\n isFetchingAllContact: true,\n };\n}", "title": "" }, { "docid": "981f002add96e80713288141444222c3", "score": "0.49927202", "text": "function createRelatedAccountList(data){\n \n let el = document.createElement('div');\n el.innerHTML = relatedLists('mail_outline', 'Show Accounts', customerAccounts(data));\n mainCard.querySelector('.main-card-content').appendChild(el);\n //Initialise collapse effect\n M.Collapsible.init(document.querySelectorAll('.collapsible'));\n}", "title": "" }, { "docid": "4438dc67fd9b476bc91fa642c4ff3d42", "score": "0.49891645", "text": "function partyAction(){ \n\tif(self.mode==\"add\"){\n\t\taddParty()\n\t} else if (self.mode==\"modify\"){\n\t\tmodifyParty()\n\t}\n}", "title": "" }, { "docid": "c712ef4ca5b6b9229538645ae6f1ee28", "score": "0.4988203", "text": "enterList(ctx) {\n\t}", "title": "" }, { "docid": "6824db518eaba83e4fec196872284edc", "score": "0.49858752", "text": "function chargementPageCI(dataObjFcis, dataObjLnk){\n\tconsole.log(\"chargement!!!!\")\n\t//stop chargement animation\n\tspinner.stop(spinner_div);\n\n\t//vidage des tableaux\n\t$(\"#table_db tbody\").html('')\n\t$(\"#table_vm tbody\").html('');\n\t$(\"#table_contact tbody\").html('');\n\n\tvar tableContact = $(\"#table_contact tbody:last\");\n\t//triTabBy('role_name', contact);\n\n\t//affichage des contacts\n\tif(contact!=null){\n\t\t//newtab = contact indexé par des int\n\t\tvar newTab= reIndexage(contact);\n\n\t\ttriBy('role_name', newTab);\n\t\t//parcours de tout les contact + contactDétails\n\t\t$.each(newTab, function(ind, val){\n\t\t\t$.each(contactDetails, function(i, v){\n\t\t\t\t//si les id de contact se correspondent\n\t\t\t\tif((v['key']==val['fields']['contact_id']) && (val['fields']['role_name']!= 'Key User Portail')){\n\n\t\t\t\t\t//creation d'une ligne + ajout au tableau\n\t\t\t\t\tvar tr = document.createElement('tr');\n\t\t\t\t\ttableContact.append(tr);\n\n\t\t\t\t\t//creation d'un lien\n\t\t\t\t\tvar a = document.createElement('a');\n\t\t\t\t\t//a.href=iTopContactUrl+val['fields']['contact_id'];\n a.href=\"../appli_gestion_collabo-recherche/afficheInfo.html?collab=\"+val['fields']['contact_id_friendlyname'];\n\t\t\t\t\ta.innerHTML = val['fields']['contact_id_friendlyname'];\n\t\t\t\t\ta.target=\"_blank\"\n\n\t\t\t\t\t//création d'une céllule + ajout a la ligne + ajout du lien a la cellule\n\t\t\t\t\tvar tdName = document.createElement('td');\n\t\t\t\t\ttr.append(tdName);\n\t\t\t\t\ttdName.append(a);\n\n\t\t\t\t\t//création d'une cellule + ajout après la cellule précédente\n\t\t\t\t\tvar tdFonction = document.createElement('td');\n\t\t\t\t\ttdFonction.innerHTML = val['fields']['role_name'];\n\t\t\t\t\ttdName.after(tdFonction);\n\n\t\t\t\t\t//création d'une cellule + ajout après la cellule précédente\n\t\t\t\t\tvar tdMail = document.createElement('td');\n\t\t\t\t\ttdMail.innerHTML = v['fields']['email'];\n\t\t\t\t\ttdFonction.after(tdMail);\n\n\t\t\t\t\t//création d'une cellule + ajout après la cellule précédente\n\t\t\t\t\tvar tdTel = document.createElement('td');\n\t\t\t\t\ttdTel.innerHTML = v['fields']['phone'];\n\t\t\t\t\ttdMail.after(tdTel);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}else{\n\t\tvar tr = document.createElement('tr');\n\t\ttableContact.append(tr);\n\n\t\t//création d'une céllule + ajout a la ligne\n\t\tvar td = document.createElement('td');\n\t\ttd.innerHTML = \"Il n'y a aucun contact\";\n\t\ttr.append(td);\n\t}\n\n\t//si il y a des CIs\n\tif(dataObjFcis!=null){\n\n\t\t//création de listes utilitaires\n\t\tvar lst_table_db, lst_table_vm;\n\n\t\t//utile pour remplissage des table db et vm\n\t\tlst_table_db = new Array;\n\t\tlst_table_vm = new Array;\n\n\n\t\t// liste assoc nom db -> id_db\n\t\tlst_db_id = new Object;\n\n\t\t// liste assoc nom vm -> id_vm\n\t\tlst_vm_id = new Object;\n\n\t\t$.each(dataObjFcis, function(index, value){\n\t\t\t//remplissage des tableau associatif [idIC]= value\n\t\t\t//cest une db\n\t\t\tif(value['class']==\"DatabaseCluster\"){\n\t\t\t\tvar name = value['fields']['friendlyname'];\n\t\t\t\tlst_db_id[name]=new Object;\n\t\t\t\tlst_db_id[name]=value['key'];\n\t\t\t}\n\t\t\t//cets une vm\n\t\t\telse if(value['class']==\"VirtualMachine\"){\n\t\t\t\tvar name = value['fields']['friendlyname'];\n\t\t\t\tlst_vm_id[name]=new Object;\n\t\t\t\tlst_vm_id[name]=value['key'];\n\t\t\t}\n\n\t\t});\n\n\t\t//remplissage des listes lst_table_db et lst_table_vm\n\t\t//db\n\n\t\tconsole.log(dataObjFcis);\n\t\tconsole.log(dbs);\n\t\tconsole.log(dataObjLnk);\n\t\t//HLSF6V60 HLSF6V60\n\n\t\tvar length=0;\n\t\t$.each(dataObjFcis, function(index, value){\n\t\t\t$.each(dbs, function(inde, valu){\n\n\t\t\t\t//si cest une db et si y a un databaseshema\n\t\t\t\t// if(value['class']==\"DatabaseCluster\" && value['fields']['databaseschemas_list'][0]!=null){\n\t\t\t\t\t// if((value['fields']['databaseschemas_list'][0]['databaseschema_id'] == valu['key']) && value['fields']['status']!='obsolete'){\n\t\t\t\tif(value['class']==\"DatabaseCluster\" && value['fields']['databaseschemas_list']!=null){\n\t\t\t\t\tif((value['fields']['databaseschemas_list'][0]['databaseschema_id'] == valu['key']) && value['fields']['status']!='obsolete'){\n\t\t\t\t\t\t//si il y a des choses dans le tableau\n\t\t\t\t\t\tif(length>=3){\n\t\t\t\t\t\t\t//si la ligne nexiste pas déjà\n\t\t\t\t\t\t\tif(lst_table_db[length-1]!=valu['fields']['db_environment_server_name_friendlyname'] || lst_table_db[length-2]!=value['fields']['friendlyname'] ){\n\t\t\t\t\t\t\t\tconsole.log('ligne inexistante');\n\t\t\t\t\t\t\t\t//remplissage des commentaires\n\t\t\t\t\t\t\t\t$.each(dataObjLnk, function(ind, val){\n\t\t\t\t\t\t\t\t\tif(val['fields']['ci_id'] == value['key']){\n\t\t\t\t\t\t\t\t\t\tlst_table_db.push(val['fields']['utility']);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlst_table_db.push(value['fields']['friendlyname']);\n\t\t\t\t\t\t\t\tlst_table_db.push(valu['fields']['db_environment_server_name_friendlyname']);\n\t\t\t\t\t\t\t\tlength=length+3;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t//remplissage des commentaires\n\t\t\t\t\t\t\t$.each(dataObjLnk, function(ind, val){\n\t\t\t\t\t\t\t\tif(val['fields']['ci_id'] == value['key']){\n\t\t\t\t\t\t\t\t\tlst_table_db.push(val['fields']['utility']);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tlst_table_db.push(value['fields']['friendlyname']);\n\t\t\t\t\t\t\tlst_table_db.push(valu['fields']['db_environment_server_name_friendlyname']);\n\t\t\t\t\t\t\tlength=length+3;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t//pas de dbs\n\t\t\t\t//else if((value['class']==\"DatabaseCluster\" && value['fields']['databaseschemas_list'][0]==null)){\n\t\t\t\t\t//if((value['fields']['friendlyname'] == valu['fields']['name']) && value['fields']['status']!='obsolete'){\n\t\t\t\telse if(value['class']==\"DatabaseCluster\" && value['fields']['databaseschemas_list']==null){\n\t\t\t\t\tif((value['fields']['friendlyname'] == valu['fields']['name']) && value['fields']['status']!='obsolete'){\n\t\t\t\t\t\t//si il y a des choses dans le tableau\n\t\t\t\t\t\tif(length>=3){\n\t\t\t\t\t\t\t//si la ligne nexiste pas déjà\n\t\t\t\t\t\t\tif(lst_table_db[length-1]!=valu['fields']['db_environment_server_name_friendlyname'] || lst_table_db[length-2]!=value['fields']['friendlyname'] ){\n\t\t\t\t\t\t\t\tconsole.log('ligne inexistante');\n\t\t\t\t\t\t\t\t//remplissage des commentaires\n\t\t\t\t\t\t\t\t$.each(dataObjLnk, function(ind, val){\n\t\t\t\t\t\t\t\t\tif(val['fields']['ci_id'] == value['key']){\n\t\t\t\t\t\t\t\t\t\tlst_table_db.push(val['fields']['utility']);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlst_table_db.push(value['fields']['friendlyname']);\n\t\t\t\t\t\t\t\tlst_table_db.push(valu['fields']['db_environment_server_name_friendlyname']);\n\t\t\t\t\t\t\t\tlength=length+3;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t//remplissage des commentaires\n\t\t\t\t\t\t\t$.each(dataObjLnk, function(ind, val){\n\t\t\t\t\t\t\t\tif(val['fields']['ci_id'] == value['key']){\n\t\t\t\t\t\t\t\t\tlst_table_db.push(val['fields']['utility']);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tlst_table_db.push(value['fields']['friendlyname']);\n\t\t\t\t\t\t\tlst_table_db.push(valu['fields']['db_environment_server_name_friendlyname']);\n\t\t\t\t\t\t\tlength=length+3;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\tif(lst_table_db.length == 0){\n\t\t\tlst_table_db=[\"Il n'y a pas de base de données\",'',''];\n\t\t}\n\n\t\t//vm\n\t\t$.each(vm, function(index, value){\n\t\t\t$.each(dataObjLnk, function(ind, val){\n\t\t\t\tif(val['fields']['ci_id'] == value['key']){\n\t\t\t\t\t//si la vm nest pas obsolete\n\t\t\t\t\tif(value['fields']['status']!='obsolete'){\n\t\t\t\t\t\t//remplissage de nouvelle valeur dans la lst_table_vm avec vm\n\t\t\t\t\t\tlst_table_vm.push(val['fields']['utility']);\n\t\t\t\t\t\tlst_table_vm.push(value['fields']['name']);\n\t\t\t\t\t\tlst_table_vm.push(value['fields']['mgmt_ip']);\n\t\t\t\t\t\tlst_table_vm.push(value['fields']['osfamily_name']);\n\t\t\t\t\t\tlst_table_vm.push(value['fields']['osversion_name']);\n\t\t\t\t\t\tlst_table_vm.push(value['fields']['url']);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\tif(lst_table_vm.length==0){\n\t\t\t lst_table_vm=[\"Il n'y a aucune machines virtuelles\",'','', '', '', ''];\n\t\t}\n\n\n\n\t\t//remplissage des tableaux\n\t\tif(dataObjLnk!=null){\n\t\t\t//db\n\t\t\tconsole.log(\"db remplissage tableau!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\");\n\t\t\tconsole.log(lst_table_db);\n\n\t\t\t//on avance de 3 enn 3 psk il y a 3 cellules\n\t\t\tfor(var i=0; i < lst_table_db.length; i=i+3){\n\t\t\t\tvar idDB= null;\n\t\t\t\t//boucle sur la liste db id pour recup l'id\n\t\t\t\t$.each(lst_db_id, function(index, value){\n\t\t\t\t\t//si index correspond a name\n\t\t\t\t\tif(lst_table_db[i+1] == index){\n\t\t\t\t\t\tidDB = value;\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t//création de lien DB\n\t\t\t\tif(idDB!= null){\n\n\t\t\t\t\tconsole.log(\"idBD!=null\");\n\t\t\t\t\t//si le parametre ci n'est pas null on affiche seulement le ci concerné\n\t\t\t\t\t/*if($('#ciName').val()!=''){\n\t\t\t\t\t\tif(lst_table_db[i+1] == $('#ciName').val().toUpperCase()){\n\t\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_db[i] +'</td><td><a href=\"'+ iTopCIUrl+ idDB +'\" target=\"_blank\">'+ lst_table_db[i+1] +'</a></td><td>'+ lst_table_db[i+2] +'</td></tr>';\n\t\t\t\t\t\t\t$(\"#table_db tbody:last\").append(str);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{*/\n\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_db[i] +'<button type=\"button\" class=\"btn btn-primary btn-sm pencil\" data-toggle=\"modal\" data-target=\"#exampleModal\"><i class=\"fa fa-pencil\"></i></button></td><td><a href=\"'+ iTopCIUrl+ idDB +'\" target=\"_blank\">'+ lst_table_db[i+1] +'</a></td><td>'+ lst_table_db[i+2] +'</td></tr>';\n\t\t\t\t\t\t$(\"#table_db tbody:last\").append(str);\n\t\t\t\t//\t}\n\n\t\t\t\t}else{\n\t\t\t\t\t/*if($('#ciName').val()!=''){\n\t\t\t\t\t\tif(lst_table_db[i+1] == $('#ciName').val().toUpperCase()){\n\t\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_db[i] +'</td><td>'+ lst_table_db[i+1] +'</td><td>'+ lst_table_db[i+2] +'</td></tr>';\n\t\t\t\t\t\t\t$(\"#table_db tbody:last\").append(str);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{*/\n\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_db[i] +'</td><td>'+ lst_table_db[i+1] +'</td><td>'+ lst_table_db[i+2] +'</td></tr>';\n\t\t\t\t\t\t$(\"#table_db tbody:last\").append(str);\n\t\t\t\t\t//}\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t\t//vm\n\t\t\tfor(var i=0; i < lst_table_vm.length; i=i+6){\n\t\t\t\tvar idVM= null;\n\t\t\t\t//boucle sur la liste vm id pour recup l'id\n\t\t\t\t$.each(lst_vm_id, function(index, value){\n\t\t\t\t\t//si index correspond a name\n\t\t\t\t\tif(lst_table_vm[i+1] == index){\n\t\t\t\t\t\tidVM = value;\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t//creation de lien VM\n\t\t\t\tif(idVM != null){\n\t\t\t\t\t//si le parametre ci n'est pas null on affiche seulement le ci concerné\n\t\t\t\t/*\tif($('#ciName').val()!=''){\n\t\t\t\t\t\tif(lst_table_vm[i+1] == $('#ciName').val().toUpperCase()){\n\t\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_vm[i] +'</td><td><a href=\"'+ iTopCIUrl+ idVM +'\" target=\"_blank\">'+ lst_table_vm[i+1] +'</a></td><td>'+ lst_table_vm[i+2] +'</td> <td>'+ lst_table_vm[i+3] +'</td><td>'+ lst_table_vm[i+4] +'</td><td><a href=\"'+ lst_table_vm[i+5] +'\" target=\"_blank\">'+ lst_table_vm[i+5] +'</a></td></tr>';\n\t\t\t\t\t\t\t$(\"#table_vm tbody:last\").append(str);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{*/\n\t\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_vm[i] +'<button type=\"button\" class=\"btn btn-primary btn-sm pencil\" data-toggle=\"modal\" data-target=\"#exampleModal\"><i class=\"fa fa-pencil\"></i></button></td><td><a href=\"'+ iTopCIUrl+ idVM +'\" target=\"_blank\">'+ lst_table_vm[i+1] +'</a></td><td>'+ lst_table_vm[i+2] +'</td><td>'+ lst_table_vm[i+3] +'</td><td>'+ lst_table_vm[i+4] +'</td><td><a href=\"'+ lst_table_vm[i+5] +'\" target=\"_blank\">'+ lst_table_vm[i+5] +'</a></td></tr>';\n\t\t\t\t\t\t\t$(\"#table_vm tbody:last\").append(str);\n\t\t\t\t\t//}\n\t\t\t\t}else{\n\t\t\t\t\t/*if($('#ciName').val()!=''){\n\t\t\t\t\t\tif(lst_table_vm[i+1] == $('#ciName').val().toUpperCase()){\n\t\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_vm[i] +'</td><td>'+ lst_table_vm[i+1] +'</td><td>'+ lst_table_vm[i+2] +'</td><td>'+ lst_table_vm[i+3] +'</td><td>'+ lst_table_vm[i+4] +'</td><td><a href=\"'+ lst_table_vm[i+5] +'\" target=\"_blank\">'+ lst_table_vm[i+5] +'</a></td></tr>';\n\t\t\t\t\t\t\t$(\"#table_vm tbody:last\").append(str);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{*/\n\t\t\t\t\t\tvar str='<tr><td>'+ lst_table_vm[i] +'</td><td>'+ lst_table_vm[i+1] +'</td><td>'+ lst_table_vm[i+2] +'</td><td>'+ lst_table_vm[i+3] +'</td><td>'+ lst_table_vm[i+4] +'</td><td><a href=\"'+ lst_table_vm[i+5] +'\" target=\"_blank\">'+ lst_table_vm[i+5] +'</a></td></tr>';\n\t\t\t\t\t\t$(\"#table_vm tbody:last\").append(str);\n\t\t\t\t\t//}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\n\t}\n\t//sil n'y a pas de CIs\n\telse{\n\n\t\t//deuxieme chargement si premier passage pour etre sur psk desfois ça marche pas lol\n\t\tif(passage==2){\n\t\t\tloadPageAfficheCI();\n\t\t}else{\n\t\t\tvar str='<tr><td COLSPAN=3>Il n\\'y a aucune base de données</td></tr>';\n\t\t\t$(\"#table_db tbody:last\").append(str);\n\t\t\tvar strv='<tr><td COLSPAN=3>Il n\\'y a aucune machine virtuelle</td></tr>';\n\t\t\t$(\"#table_vm tbody:last\").append(strv);\n\t\t}\n\t}\n $(\".pencil\").click(function(){\n var ci = $(this).parent().next(\"td\").text();\n var utilisationExistante = $(this).parent().text();\n $(\"#inputModif\").val(utilisationExistante);\n console.log(\"utilisation existante : \"+utilisationExistante);\n ciModif=ci;\n dbOrVm = $(this).parent().parent().parent().parent().attr('id');\n console.log(\"DB OR VM : \"+dbOrVm);\n $(\"#exampleModalLabel\").text(\"Modifier CI \"+ci);\n });\n\n}", "title": "" }, { "docid": "d0dda7e109188f77d74c5d0bdb3de404", "score": "0.49843162", "text": "function sendingGetAndGiveNewSpareToAHiderAHelperF(DCSOToAsk, conIdFromGroup){\n var key = UUID.generate(); \n window.permissionKeysSent.insert({\"key\": key,\n \"connectionId\": DCSOToAsk.connectionId,\n \"action\": \"addNewSpare\",\n \"conIdFromGroup\": conIdFromGroup});\n \n DCSOToAsk.dataChannel.send(JSON.stringify({id: 'GetAndGiveNewUnusedSpareHider', key: key, }));\n return;\n }", "title": "" }, { "docid": "6aa8d8d9ad6ae054db1cf4ca094b6619", "score": "0.49779794", "text": "function updateContactList(transaction, results) {\n //initialise the listitems variable\n var listitems = \"\";\n //get the contact list holder ul\n var listholder = document.getElementById(\"contacts\");\n\n //clear contact list ul\n listholder.innerHTML = \"\";\n\n var i;\n //Iterate through the results\n for (i = 0; i < results.rows.length; i++) {\n //Get the current row\n var row = results.rows.item(i);\n\n listholder.innerHTML += \"<li class='ui-btn ui-icon-user ui-btn-icon-left' id='\"+row.id + \"'><a href='#details' >\"+row.name+\"</a></li>\";\n\n /* GET Userlist page. */\n router.get('/userlist', function(req, res) {\n var db = req.db;\n var collection = db.get('usercollection');\n collection.find({},{},function(e,docs){\n res.render('userlist', {\n \"userlist\" : docs\n });\n });\n });\n \n $(\"#\"+row.id).on(\"tap\",function(){\n fillContact(row.id);\n }); \n \n $(function(){\n $( \"#\"+row.id ).bind( \"taphold\", tapholdHandler );\n \n function tapholdHandler( event ){\n deleteContact(row.id);\n }\n});\n }\n}", "title": "" }, { "docid": "fe8616ccc3799e7681df5dadcafa2a22", "score": "0.49777624", "text": "function contacts_listener() {\n let contactField = document.getElementById('SelectedContact').value;\n let cl = document.getElementById('contactList');\n while (cl.hasChildNodes()) {\n cl.removeChild(cl.firstChild);\n }\n if (contactField.length > 2) {\n\n //populating the contacts list\n contacts.forEach((c) => {\n if (c.includes(contactField)) {\n var contact = document.createElement(\"a\");\n contact.innerText = c;\n contact.setAttribute('href', '#');\n contact.setAttribute('onclick', `document.getElementById(\\'SelectedContact\\').value = \\'${c}\\';`);\n document.getElementById('contactList').appendChild(contact);\n\n }\n\n });\n }\n\n\n}", "title": "" }, { "docid": "870b7f7d4632216614db6e2f4a31d939", "score": "0.49756587", "text": "function addModtools() {\n var numberRX = /-?\\d+/,\n reportsThreshold = TBUtils.getSetting('QueueTools', 'reports-threshold', 1),\n listingOrder = TBUtils.getSetting('QueueTools', 'reports-order', 'age'),\n sortAscending = (TBUtils.getSetting('QueueTools', 'reports-ascending', 'false') == 'true'), //the fuck is going on here?\n viewingspam = !! location.pathname.match(/\\/about\\/(spam|trials)/),\n viewingreports = !! location.pathname.match(/\\/about\\/reports/),\n allSelected = false;\n \n if (viewingspam && listingOrder == 'reports')\n listingOrder = 'age';\n\n // Get rid of promoted links & thing rankings\n $('#siteTable_promoted,#siteTable_organic,.rank').remove();\n\n //remove stuff we cant moderate.\n $('.thing .report-button').parents('.thing').remove();\n $('.modtools-on').parent().remove();\n\n // Make visible any collapsed things (stuff below /prefs/ threshold)\n $('.entry .collapsed:visible a.expand:contains(\"[+]\")').click();\n\n // Add checkboxes, tabs, menu, etc\n $('#siteTable').before('\\\n <div class=\"menuarea modtools\" style=\"padding: 5px 0;margin: 5px 0;\"> \\\n <input style=\"margin:5px;float:left\" title=\"Select all/none\" type=\"checkbox\" id=\"select-all\" title=\"select all/none\"/> \\\n <span>\\\n <a href=\"javascript:;\" class=\"pretty-button invert inoffensive\" accesskey=\"I\" title=\"invert selection\">&lt;/&gt;</a> \\\n <!--a href=\"javascript:;\" class=\"pretty-button open-expandos inoffensive\" title=\"toggle all expando boxes\">[+]</a--> \\\n <div onmouseover=\"hover_open_menu(this)\" onclick=\"open_menu(this)\" class=\"dropdown lightdrop \"> \\\n <a href=\"javascript:;\" class=\"pretty-button inoffensive select\"> [select...]</a> \\\n </div>\\\n <div class=\"drop-choices lightdrop select-options\"> \\\n ' + (viewingreports ? '' : '<a class=\"choice inoffensive\" href=\"javascript:;\" type=\"banned\">shadow-banned</a>\\\n <a class=\"choice inoffensive\" href=\"javascript:;\" type=\"filtered\">spam-filtered</a>\\\n ' + (viewingspam ? '' : '<a class=\"choice inoffensive\" href=\"javascript:;\" type=\"reported\">has-reports</a>')) + '\\\n <a class=\"choice dashed\" href=\"javascript:;\" type=\"spammed\">[ spammed ]</a> \\\n <a class=\"choice\" href=\"javascript:;\" type=\"removed\">[ removed ]</a> \\\n <a class=\"choice\" href=\"javascript:;\" type=\"approved\">[ approved ]</a>\\\n ' + (TBUtils.post_site && false ? '<a class=\"choice\" href=\"javascript:;\" type=\"flaired\">[ flaired ]</a>' : '') + '\\\n <a class=\"choice\" href=\"javascript:;\" type=\"actioned\">[ actioned ]</a>\\\n <a class=\"choice dashed\" href=\"javascript:;\" type=\"domain\">domain...</a> \\\n <a class=\"choice\" href=\"javascript:;\" type=\"user\">user...</a> \\\n <a class=\"choice\" href=\"javascript:;\" type=\"title\">title...</a> \\\n <a class=\"choice dashed\" href=\"javascript:;\" type=\"comments\">all comments</a> \\\n <a class=\"choice\" href=\"javascript:;\" type=\"links\">all submissions</a> \\\n <a class=\"choice dashed\" href=\"javascript:;\" type=\"self\">self posts</a> \\\n <a class=\"choice\" href=\"javascript:;\" type=\"flair\">posts with flair</a> \\\n </div>\\\n &nbsp; \\\n <a href=\"javascript:;\" class=\"pretty-button inoffensive unhide-selected\" accesskey=\"U\">unhide&nbsp;all</a> \\\n <a href=\"javascript:;\" class=\"pretty-button inoffensive hide-selected\" accesskey=\"H\">hide&nbsp;selected</a> \\\n <a href=\"javascript:;\" class=\"pretty-button action negative\" accesskey=\"S\" type=\"negative\" tabindex=\"3\">spam&nbsp;selected</a> \\\n <a href=\"javascript:;\" class=\"pretty-button action neutral\" accesskey=\"R\" type=\"neutral\" tabindex=\"4\">remove&nbsp;selected</a> \\\n <a href=\"javascript:;\" class=\"pretty-button action positive\" accesskey=\"A\" type=\"positive\" tabindex=\"5\">approve&nbsp;selected</a> \\\n ' + (TBUtils.post_site && false ? '<a href=\"javascript:;\" class=\"pretty-button flair-selected inoffensive\" accesskey=\"F\" tabindex=\"6\">flair&nbsp;selected</a>' : '') + ' \\\n </span> \\\n <span class=\"dropdown-title lightdrop\" style=\"float:right\"> sort: \\\n <div onmouseover=\"hover_open_menu(this)\" onclick=\"open_menu(this)\" class=\"dropdown lightdrop \"> \\\n <span class=\"selected sortorder\">' + listingOrder + '</span> \\\n </div> \\\n <div class=\"drop-choices lightdrop sortorder-options\"> \\\n <a class=\"choice\" href=\"javascript:;\">age</a> \\\n ' + (viewingspam ? '' : '<a class=\"choice\" href=\"javascript:;\">reports</a>') + ' \\\n <a class=\"choice\" href=\"javascript:;\">score</a> \\\n </div> \\\n </span> \\\n </div>');\n\n //Check if the tab menu exists and create it if it doesn't\n var tabmenu = $('#header-bottom-left .tabmenu')\n if(tabmenu.length == 0)\n tabmenu = $('#header-bottom-left').append('<ul class=\"tabmenu\"></ul>')\n $('.tabmenu').append(viewingspam ? '' : '<li><a><label for=\"modtab-threshold\">threshold: </label><input id=\"modtab-threshold\" value=\"' + reportsThreshold + '\" style=\"width:10px;height:14px;border:none;background-color:#EFF7FF\"/></a></li>');\n \n $('.thing.link, .thing.comment').prepend('<input type=\"checkbox\" tabindex=\"1\" style=\"margin:5px;float:left;\" />');\n $('.buttons .pretty-button').attr('tabindex', '2');\n\n //add class to processed threads.\n $('.thing').addClass('mte-processed');\n\n // Add context & history stuff\n $('body').append('<div class=\"pretty-button inline-content\" style=\"z-index:9999;display:none;position:absolute;line-height:12px;min-width:100px\"/>');\n $('#siteTable .comment .flat-list.buttons:has( a:contains(\"parent\"))').each(function () {\n $(this).prepend('<li><a class=\"context\" href=\"' + $(this).find('.first .bylink').attr('href') + '?context=2\">context</a></li>');\n });\n\n //// Button actions ////\n // Select thing when clicked\n var noAction = ['A', 'INPUT', 'TEXTAREA', 'BUTTON'];\n $('body').on('click', '.thing .entry', function (e) {\n if (noAction.indexOf(e.target.nodeName) + 1) return;\n $(this).parent('.thing').find('input[type=checkbox]:first').click();\n });\n\n // Change sort order\n $('.sortorder-options a').click(function () {\n var order = $(this).text(),\n toggleAsc = (order == $('.sortorder').text());\n\n if (toggleAsc) sortAscending = !sortAscending;\n\n TBUtils.setSetting('QueueTools', 'reports-ascending', sortAscending);\n TBUtils.setSetting('QueueTools', 'reports-order', order);\n\n $('.sortorder').text(order);\n sortThings(order, sortAscending);\n });\n\n // Invert all the things.\n $('.invert').click(function () {\n $('.thing:visible input[type=checkbox]').click();\n });\n\n // Select / deselect all the things\n $('#select-all').click(function () {\n $('.thing:visible input[type=checkbox]').attr('checked', allSelected = this.checked);\n });\n $('body').on('click', '.thing input[type=checkbox]', function () {\n $('#select-all').attr('checked', allSelected = !$('.thing:visible input[type=checkbox]').not(':checked').length);\n });\n\n // Select/deselect certain things\n $('.select-options a').click(function () {\n var things = $('.thing:visible'),\n selector;\n\n switch (this.type) {\n case 'banned':\n selector = '.banned-user';\n break;\n case 'filtered':\n selector = '.spam:not(.banned-user)';\n break;\n case 'reported':\n selector = ':has(.reported-stamp)';\n break;\n case 'spammed':\n selector = '.spammed,:has(.pretty-button.negative.pressed),:has(.remove-button:contains(spammed))';\n break;\n case 'removed':\n selector = '.removed,:has(.pretty-button.neutral.pressed),:has(.remove-button:contains(removed))';\n break;\n case 'approved':\n selector = '.approved,:has(.approval-checkmark,.pretty-button.positive.pressed),:has(.approve-button:contains(approved))';\n break;\n case 'flaired':\n selector = '.flaired';\n break;\n case 'actioned':\n selector = '.flaired,.approved,.removed,.spammed,:has(.approval-checkmark,.pretty-button.pressed),\\\n :has(.remove-button:contains(spammed)),:has(.remove-button:contains(removed)),:has(.approve-button:contains(approved))';\n break;\n case 'domain':\n selector = ':has(.domain:contains(' + prompt('domain contains:', '').toLowerCase() + '))';\n break;\n case 'user':\n selector = ':has(.author:contains(' + prompt('username contains:\\n(case sensitive)', '') + '))';\n break;\n case 'title':\n selector = ':has(a.title:contains(' + prompt('title contains:\\n(case sensitive)', '') + '))';\n break;\n case 'comments':\n selector = '.comment';\n break;\n case 'links':\n selector = '.link';\n break;\n case 'self':\n selector = '.self';\n break;\n case 'flair':\n selector = ':has(.linkflair)';\n break;\n }\n things.filter(selector).find('input[type=checkbox]').attr('checked', true);\n });\n $('.hide-selected').click(function () {\n $('.thing:visible:has(input:checked)').hide();\n $('.thing input[type=checkbox]').attr('checked', false);\n });\n $('.unhide-selected').click(function () {\n $('.thing').show();\n });\n\n // Mass spam/remove/approve\n $('.pretty-button.action').click(function () {\n var spam = (this.type == 'negative'),\n type = (this.type == 'positive' ? 'approve' : 'remove');\n\n // Apply action\n $('.thing:visible>input:checked').parent().each(function () {\n $.post('/api/' + type, {\n uh: TBUtils.modhash,\n spam: spam,\n id: $(this).attr('data-fullname') //getThingInfo seems like overkill.\n });\n }).css('opacity', '1').removeClass('flaired spammed removed approved').addClass((spam ? 'spamme' : type) + 'd');\n });\n\n // menuarea pretty-button feedback.\n $('.menuarea.modtools .pretty-button').click(function () {\n $(this).clearQueue().addClass('pressed').delay(200).queue(function () {\n $(this).removeClass('pressed');\n });\n });\n\n var ignoreOnApproveset;\n // Uncheck anything we've taken an action, if it's checked.\n $('body').on('click', '.pretty-button', function (e) {\n var thing = $(this).closest('.thing');\n $(thing).find('input[type=checkbox]').attr('checked', false);\n if (hideActionedItems) {\n $(thing).hide();\n } else if (ignoreOnApproveset) {\n ignoreOnApproveset = false;\n } else if ($(this).hasClass('negative')) {\n $(thing).removeClass('removed');\n $(thing).removeClass('approved');\n $(thing).addClass('spammed');\n } else if ($(this).hasClass('neutral')) {\n $(thing).removeClass('spammed');\n $(thing).removeClass('approved');\n $(thing).addClass('removed');\n } else if ($(this).hasClass('positive')) {\n $(thing).removeClass('removed');\n $(thing).removeClass('spammed');\n $(thing).addClass('approved');\n }\n });\n\n // Open reason dropdown when we remove something as ham.\n $('body').on('click', '.big-mod-buttons > span > .pretty-button.positive', function () {\n if (!ignoreOnApprove) return;\n var thing = $(this).closest('.thing');\n $(thing).removeClass('removed');\n $(thing).removeClass('spammed');\n $(thing).addClass('approved');\n ignoreOnApproveset = true;\n\n if ($(thing).find('.reported-stamp').length) {\n var ignore = $(thing).find('a:contains(\"ignore reports\")')\n if (ignore) ignore[0].click();\n }\n });\n\n // Set reports threshold (hide reports with less than X reports)\n $('#modtab-threshold').keypress(function (e) {\n e.preventDefault();\n\n var threshold = +String.fromCharCode(e.which);\n if (isNaN(threshold)) return;\n\n $(this).val(threshold);\n TBUtils.setSetting('QueueTools', 'reports-threshold', threshold);\n setThreshold($('.thing'));\n });\n\n function setThreshold(things) {\n var threshold = TBUtils.getSetting('QueueTools', 'reports-threshold', 1);\n things.show().find('.reported-stamp').text(function (_, str) {\n if (str.match(/\\d+/) < threshold)\n $(this).closest('.thing').hide();\n });\n }\n setThreshold($('.thing'));\n\n\n function replaceSubLinks() {\n $this = $(this).find('a.subreddit');\n var href = $this.attr('href') + QUEUE_URL;\n $this.attr('href', href);\n }\n if (linkToQueues && QUEUE_URL) {\n $('.thing').each(replaceSubLinks);\n }\n\n // NER support. TODO: why doesn't this work?\n window.addEventListener(\"TBNewThings\", function () {\n $.log(\"proc new things\");\n var things = $(\".thing\").not(\".mte-processed\");\n processNewThings(things);\n });\n\n /* Disabled for 2.1 final release. Causes huge issue because reddit does a postback to get the expando content.\n // Toggle all expando boxes\n var expandosOpen = false;\n $('.open-expandos').on('click', function () {\n\n \n if (!expandosOpen) {\n $('.open-expandos').text('[-]');\n $('.expando-button.collapsed').each(function (index) {\n var button = this;\n setTimeout(function () { $(button).click(); }, index * 1000);\n });\n expandosOpen = true;\n } else {\n $('.open-expandos').text('[+]');\n $('.expando-button.expanded').each(function () {\n $(this).click();\n });\n expandosOpen = false;\n }\n \n });\n */\n\n // Open inline context\n $('.inline-content').click(function (e) {\n e.stopPropagation();\n });\n $('body').on('click', 'a.context', function (e) {\n $('html').one('click', function () {\n $('.inline-content').hide();\n });\n $('.inline-content').show().offset($(this).offset()).text('loading...').load(this.href + '&limit=5 .sitetable.nestedlisting');\n return false;\n });\n\n // Add history button to all users. \n function addUserHistoryLink() {\n var userhistory = '<a href=\"javascript:;\" class=\"user-history-button\" title=\"view user history\" target=\"_blank\">H</a>';\n\n $(this).append('[' + userhistory + ']');\n }\n $('.thing .entry .userattrs').each(addUserHistoryLink);\n\n // Add ban button to all users. \n function addUserBanLink() {\n if (!$(this).hasClass('ban-button')) {\n\n // Add the class so we don't add buttons twice.\n $(this).addClass('ban-button');\n\n // Add button.\n $(this).append('[<a href=\"javascript:void(0)\" class=\"user-ban-button\">B</a>]');\n }\n }\n $('.thing .entry .userattrs').each(addUserBanLink);\n\n //Process new things loaded by RES or flowwit.\n function processNewThings(things) {\n $.log(\"proc new things 2\");\n //add class to processed threads.\n $(things).addClass('mte-processed');\n\n $(things).prepend('<input type=\"checkbox\" tabindex=\"2\" style=\"margin:5px;float:left;\"' + (allSelected ? ' checked' : '') + ' />').find('.collapsed:visible a.expand:contains(\"[+]\")').click().end().find('.userattrs').each(addUserHistoryLink).end().find('.userattrs').each(addUserBanLink).filter('.comment').find('.flat-list.buttons:has( a:contains(\"parent\"))').each(function () {\n $(this).prepend('<li><a class=\"context\" href=\"' + $(this).find('.first .bylink').attr('href') + '?context=2\">context</a></li>');\n });\n if (expandosOpen)\n $(things).find('.expando-button.collapsed').click();\n if (!viewingspam)\n setThreshold(things);\n }\n\n // Remove rate limit for expandos,removing,approving\n var rate_limit = window.rate_limit;\n window.rate_limit = function (action) {\n if (action == 'expando' || action == 'remove' || action == 'approve') return !1;\n return rate_limit(action);\n };\n\n //User history button pressed\n var gettingUserdata = false;\n $('body').on('click', '.user-history-button', function () {\n $('html').one('click', function () {\n $('.inline-content').hide();\n gettingUserdata = false;\n });\n gettingUserdata = true;\n\n var author = TBUtils.getThingInfo($(this).closest('.entry')).user,\n commentbody = '',\n contentBox = $('.inline-content').show().offset($(this).offset()).html('<div class=\"user-history\"><a href=\"/user/' + author + '\" target=\"_blank\">' + author + '</a> <span class=\"karma\" /> <a class=\"rts-report\" href=\"javascript:;\" data-commentbody=\"\">Report Spammer</a><div><br /><b>Submission history:</b></div><div class=\"table domain-table\"><table><thead><tr><th>domain submitted from</th><th>count</th><th>ups</th><th>downs</th><th>score</th><th>%</th></tr></thead><tbody><tr><td colspan=\"6\" class=\"error\">loading...</td></tr></tbody></table></div><div class=\"table subreddit-table\"><table><thead><tr><th>subreddit submitted to</th><th>count</th><th>ups</th><th>downs</th><th>score</th><th>%</th></tr></thead><tbody><tr><td colspan=\"6\" class=\"error\">loading...</td></tr></tbody></table></div></div>'),\n\n domains = {},\n domainslist = [],\n domaintable = contentBox.find('.domain-table tbody'),\n subreddits = {},\n subredditlist = [],\n subreddittable = contentBox.find('.subreddit-table tbody');\n\n $('.rts-report').attr('data-author', author);\n\n // Show user's karma\n $.get('/user/' + author + '/about.json').success(function (d) {\n contentBox.find('.karma').text('(' + d.data.link_karma + ' | ' + d.data.comment_karma + ')');\n });\n\n // Get user's domain & subreddit submission history\n (function populateHistory(after) {\n $.get('/user/' + author + '/submitted.json?limit=100&after=' + (after || '')).error(function () {\n contentBox.find('.error').html('unable to load userdata</br>shadowbanned?');\n }).success(function (d) {\n\n if (!gettingUserdata) return;\n if (!d.data.children.length) return contentBox.find('.error').html('no submissions');\n\n var after = d.data.after,\n commentbody = 'Recent Submission history for ' + author + ':\\n\\ndomain submitted from|count|ups|downs|score|%\\n:-|-:|-:|-:|-:|-:';\n\n for (i in d.data.children) {\n var data = d.data.children[i].data;\n\n if (!domains[data.domain]) {\n domains[data.domain] = {\n ups: 0,\n downs: 0,\n score: 0,\n count: 0\n };\n domainslist.push(data.domain);\n }\n\n domains[data.domain].ups += data.ups;\n domains[data.domain].downs += data.downs;\n domains[data.domain].score += data.score;\n domains[data.domain].count++;\n\n if (!subreddits[data.subreddit]) {\n subreddits[data.subreddit] = {\n ups: 0,\n downs: 0,\n score: 0,\n count: 0\n };\n subredditlist.push(data.subreddit);\n }\n subreddits[data.subreddit].ups += data.ups;\n subreddits[data.subreddit].downs += data.downs;\n subreddits[data.subreddit].score += data.score;\n subreddits[data.subreddit].count++;\n }\n\n domainslist.sort(function (a, b) {\n return domains[b].count - domains[a].count;\n });\n domaintable.empty();\n\n for (i in domainslist) {\n var dom = domainslist[i],\n n = domains[dom].count,\n u = domains[dom].ups,\n d = domains[dom].downs,\n s = domains[dom].score,\n url = '/search?q=%28and+site%3A%27' + dom + '%27+author%3A%27' + author + '%27+is_self%3A0+%29&restrict_sr=off&sort=new',\n match = dom.match(/^self.(\\w+)$/);\n\n if (match) url = '/r/' + match[1] + '/search?q=%28and+author%3A%27' + author + '%27+is_self%3A1+%29&restrict_sr=on&sort=new';\n domaintable.append('<tr><td><a target=\"_blank\" href=\"' + url + '\" title=\"view links ' + author + ' recently submitted from \\'' + dom + '\\'\">' + dom + '</a></td><td>' + n + '</td><td>' + u + '</td><td>' + d + '</td><td>' + s + '</td><td>' + Math.round(u / (u + d) * 100) + '%</td></tr>');\n\n if (i < 20) commentbody += '\\n[' + dom + '](' + url + ')|' + n + '|' + u + '|' + d + '|' + s + '|' + Math.round(u / (u + d) * 100) + '%';\n }\n if (i >= 20) commentbody += '\\n\\n_^...and ^' + (domainslist.length - 20) + ' ^more_';\n\n commentbody += '\\n\\nsubreddit submitted to|count|ups|downs|score|%\\n:-|-:|-:|-:|-:|-:';\n\n subredditlist.sort(function (a, b) {\n return subreddits[b].count - subreddits[a].count;\n });\n subreddittable.empty();\n for (i in subredditlist) {\n var sr = subredditlist[i],\n n = subreddits[sr].count,\n u = subreddits[sr].ups,\n d = subreddits[sr].downs,\n s = subreddits[sr].score,\n url = '/r/' + sr + '/search?q=author%3A%27' + author + '%27&restrict_sr=on&sort=new';\n\n subreddittable.append('<tr><td><a target=\"_blank\" href=\"' + url + '\" title=\"view links ' + author + ' recently submitted to /r/' + sr + '/\">' + sr + '</a></td><td>' + n + '</td><td>' + u + '</td><td>' + d + '</td><td>' + s + '</td><td>' + Math.round(u / (u + d) * 100) + '%</td></tr>');\n\n if (i < 20) commentbody += '\\n[' + sr + '](' + url + ')|' + n + '|' + u + '|' + d + '|' + s + '|' + Math.round(u / (u + d) * 100) + '%';\n }\n if (i >= 20) commentbody += '\\n\\n_^...and ^' + (subredditlist.length - 20) + ' ^more_';\n\n $('.rts-report').attr('data-commentbody', commentbody);\n\n if (after) populateHistory(after);\n else gettingUserdata = false;\n });\n })();\n return false;\n });\n\n // User ban button pressed. \n function postbanlog(subreddit, author, reason) {\n var data = {\n subreddit: subreddit,\n author: author,\n title: 'banned',\n logsub: '',\n bantitle: '',\n logreason: '',\n url: 'http://www.reddit.com/user/' + author\n };\n\n if (notEnabled.indexOf(data.subreddit) != -1)\n return;\n\n // Get removal reasons.\n getRemovalReasons(data.subreddit, function (resp) {\n if (!resp || resp.reasons.length < 1) {\n notEnabled.push(data.subreddit);\n return;\n }\n\n // Get PM subject line\n data.subject = resp.pmsubject || 'Your {kind} was removed from {subreddit}';\n\n // Add additional data that is found in the wiki JSON. \n // Any HTML needs to me unescaped, because we store it escaped in the wiki.\n data.logreason = resp.logreason || '';\n data.header = unescape(resp.header || '');\n data.footer = unescape(resp.footer || '');\n data.logsub = resp.logsub || '';\n data.logtitle = resp.logtitle || 'Removed: {kind} by /u/{author} to /r/{subreddit}';\n data.bantitle = resp.bantitle || '/u/{author} has been {title} from /r/{subreddit} for {reason}';\n data.reasons = [];\n\n // Loop through the reasons... unescaping each.\n $(resp.reasons).each(function () {\n data.reasons.push(unescape(this.text));\n });\n\n if (!data || !data.logsub) {\n return;\n }\n else if (reason == '' || reason == undefined || reason == null) {\n alert('You did not give a reason for this ban. You will need to create the log thread in /r/' + data.logsub + ' manually.');\n return;\n }\n else {\n data.logreason = reason;\n data.bantitle = data.bantitle.replace('{reason}', data.logreason);\n data.bantitle = data.bantitle.replace('{title}', data.title);\n data.bantitle = data.bantitle.replace('{author}', data.author);\n data.bantitle = data.bantitle.replace('{subreddit}', data.subreddit);\n \n TBUtils.postLink(data.url, TBUtils.removeQuotes(data.bantitle), data.logsub, function(successful) {\n var removalId = data.json.data.url;\n removalId = removalId.match(/http:\\/\\/www.reddit.com\\/r\\/.+?\\/comments\\/([^\\/]+?)\\/.*/);\n removalId = 't3_' + removalId[1];\n\n TBUtils.approveThing(removalId);\n return;\n });\n }\n });\n }\n\n $('body').on('click', '.user-ban-button', function (e) {\n var banbutton = e.target,\n info = TBUtils.getThingInfo($(this).closest('.entry')),\n currentsub = info.subreddit,\n user = info.user;\n\n // No such luck.\n if (!user || user === '[deleted]' || !currentsub) {\n $(banbutton).text('E');\n $(banbutton).css('color', 'red');\n return;\n }\n\n var reason = prompt(\"Are you sure you want to ban /u/\" + user + \" from /r/\" + currentsub + \"?\\n\\nBan reason: (optional)\", \"\"); \n if( reason != null){ \n postbanlog(currentsub, user, reason);\n TBUtils.banUser(user, currentsub, reason, function() {\n alert(user + \" has been banned from /r/\" + currentsub);\n });\n }\n });\n\n // RTS button pressed\n $('.inline-content').on('click', '.rts-report', function () {\n var rtsLink = this,\n author = rtsLink.getAttribute('data-author'),\n commentbody = rtsLink.getAttribute('data-commentbody');\n\n rtsLink.textContent = 'submitting...';\n rtsLink.className = '.rts-report-clicked';\n \n //Submit to RTS\n var link = 'http://www.reddit.com/user/' + author,\n title = 'Overview for ' + author;\n \n TBUtils.postLink(link, title, SPAM_REPORT_SUB, function (successful, submission) {\n if (!successful) {\n rtsLink.innerHTML = '<span class=\"error\" style=\"font-size:x-small\">an error occured</span>';\n }\n else {\n if (submission.json.errors.length) {\n rtsLink.innerHTML = '<span class=\"error\" style=\"font-size:x-small\">' + submission.json.errors[0][1] + '</error>';\n if (submission.json.errors[0][0] == 'ALREADY_SUB')\n rtsLink.href = 'http://www.reddit.com/r/'+SPAM_REPORT_SUB+'/search?q=http%3A%2F%2Fwww.reddit.com%2Fuser%2F' + author + '&restrict_sr=on';\n return;\n }\n\n // Post stats as a comment.\n if (!commentbody.length || !rtsComment) {\n rtsLink.textContent = 'reported';\n rtsLink.href = submission.json.data.url;\n rtsLink.className = '';\n return;\n }\n \n\n TBUtils.postComment(submission.json.data.name, commentbody, function (successful, comment) {\n if (!successful) {\n rtsLink.innerHTML = '<span class=\"error\" style=\"font-size:x-small\">an error occured</span>';\n }\n else {\n if (comment.json.errors.length)\n return rtsLink.innerHTML = '<span class=\"error\" style=\"font-size:x-small\">' + comment.json.errors[1] + '</error>';\n rtsLink.textContent = 'reported';\n rtsLink.href = submission.json.data.url;\n rtsLink.className = '';\n };\n });\n }\n });\n });\n\n // This method is evil and breaks shit if it's called too early.\n function sortThings(order, asc) {\n var $sitetable = $('#siteTable');\n var things = $('#siteTable .thing').sort(function (a, b) {\n (asc) ? (A = a, B = b) : (A = b, B = a);\n\n switch (order) {\n case 'age':\n var timeA = new Date($(A).find('time:first').attr('datetime')).getTime(),\n timeB = new Date($(B).find('time:first').attr('datetime')).getTime();\n return timeA - timeB;\n case 'score':\n var scoreA = $(A).find('.score:visible').text().match(numberRX),\n scoreB = $(B).find('.score:visible').text().match(numberRX);\n return scoreA - scoreB;\n case 'reports':\n var reportsA = $(A).find('.reported-stamp').text().match(numberRX),\n reportsB = $(B).find('.reported-stamp').text().match(numberRX);\n return reportsA - reportsB;\n }\n });\n $sitetable.find('.thing').remove();\n $sitetable.prepend(things);\n }\n sortThings(listingOrder, sortAscending);\n }", "title": "" }, { "docid": "d2c34dfd27137abdec14e694c1015ba2", "score": "0.49734235", "text": "function inviteStaffSponsorsToComment_() {\n\n log('inviteStaffSponsorsToComment_()')\n\n var docSunday = DocumentApp.getActiveDocument();\n \n if (docSunday === null) {\n docSunday = DocumentApp.openById(TEST_DOC_ID_);\n }\n\n var documentId = docSunday.getId();\n var arrnew = docSunday.getName().split(\"-\");\n var paraFirst = arrnew[0];\n var str = arrnew[0];\n var arr = str.split(\"[\");\n var arr1 = arr[1].split(\"]\");\n var documentShortDate = arr1[0].trim();\n checkName(documentShortDate);\n cleanInstancesofLiveAnnouncement_();\n \n return;\n \n // Private Functions\n // -----------------\n\n function checkName(documentShortDate) {\n \n var staffToEmail = makeStaffMailList();\n var rawCommentData = Comments_.getAllComments(documentId);\n var commentsContent = getOpenCommentsContent();\n var emailListArray = [];\n \n // Make a list of all the staff mentioned in text and comments\n \n staffToEmail.forEach(function(emailAddress) {\n \n var staffName = emailAddress[0];\n var staffEmail = emailAddress[1];\n \n if (staffEmail !== \"\" && (foundNameInText(staffName) || foundNameInComments(staffName))) { \n emailListArray.push(staffEmail);\n } \n })\n \n // Filter the list to one mention of each\n \n var emailList = \"\";\n \n getUniqueItems(emailListArray).forEach(function(nextEmail) { \n emailList += nextEmail + \",\";\n })\n \n // Send each an email \n sendDraftMailFinal(emailList, documentShortDate); \n return;\n \n // Private Functions\n // -----------------\n\n function getUniqueItems(a) {\n var seen = {};\n var newArray = a.filter(function(item) {\n return seen.hasOwnProperty(item) ? false : (seen[item] = true);\n })\n return newArray;\n }\n\n\n function foundNameInComments(staffName) {\n return commentsContent.indexOf(('' + staffName).toUpperCase()) !== -1\n }\n\n function foundNameInText(staffName) {\n \n var check = 0;\n staffName = staffName.trim();\n \n if (staffName !== \"\") {\n \n var body = docSunday.getBody();\n var textToHighlight = staffName;\n var paras = body.getParagraphs();\n var textLocation = {};\n var i;\n var result = \"\";\n \n for (i = 0; i < paras.length; ++i) {\n \n textLocation = paras[i].findText(textToHighlight);\n \n if (textLocation != null && textLocation.getStartOffset() != -1) {\n return true;\n }\n }\n }\n \n return false;\n }\n\n function sendDraftMailFinal(emailList, documentShortDate) {\n \n if (emailList === '') {\n log('No emails sent')\n return;\n }\n \n var sundayAnnouncementsDraftDocumentUrl = DocumentApp.openById(documentId).getUrl();\n var subject = Utilities.formatString(\"Please Review: [ %s ] Sunday Announcements draft\", documentShortDate);\n var body = Utilities.formatString(\"Dear Event Sponsor: <br><br> \\\n Please review the document linked below regarding promotion for your upcoming event.<br><br>\\\n You are invited to suggest changes to your event's promotion by typing directly in the document by Friday EOD. <br><br>\\\n Thank you!<br><br>--<br>\\\n <a href='%s'>[ %s ] Sunday Announcement draft</a>\", \n sundayAnnouncementsDraftDocumentUrl,\n documentShortDate\n );\n emailList = emailList.replace(/\\,$/, ''); //should build the list without the trailing comma in the first place\n \n MailApp.sendEmail({\n to: emailList,\n subject: subject,\n htmlBody: body\n });\n \n log('Emails sent to ' + emailList)\n \n } // sendDraftMailFinal()\n\n /**\n * Get comments content if it passes the various criteria described, mainly\n * only since the script was last run\n */\n\n function getOpenCommentsContent() {\n \n var commentsContent = \"\";\n var lastTimeScriptRun = Comments_.getLastTimeScriptRun(documentId)\n \n if (lastTimeScriptRun === null) {\n return ''\n }\n\n for (var i = 0; i < rawCommentData.items.length; i++) {\n \n var nextComment = rawCommentData.items[i] \n var modifiedDate = new Date(nextComment.modifiedDate)\n \n // Since v1.8 \"invite request\" is no longer stored, but the check to ignore it is kept here \n // for backward compatibility\n \n if (nextComment.content.indexOf(config.lastTimeInviteRunText) === -1 && \n nextComment.content.indexOf(config.lastTimeRotateRunText) === -1 &&\n nextComment.status === \"open\" && \n !nextComment.deleted && \n modifiedDate > lastTimeScriptRun) {\n \n // This is not the \"script last run\" AND it is open AND it hasn't been \n // deleted AND it was created since the script was last run\n commentsContent += \" \" + (nextComment.content)\n }\n }\n \n return ('' + commentsContent).toUpperCase();\n \n } // inviteStaffSponsorsToComment_.checkName.getOpenCommentsContent()\n \n } // inviteStaffSponsorsToComment_.checkName()\n \n} // inviteStaffSponsorsToComment_()", "title": "" }, { "docid": "6e5f94da6f74774364451261acceec91", "score": "0.49719077", "text": "function showContact(visibleContact){\r\n for(contact of contactsDisplay){\r\n\t\tturnOffDisplay(contact);\r\n }\r\n\t\r\n visibleContact.style.display = \"block\";\t\r\n}", "title": "" }, { "docid": "785880dd92caeeb58f0b421f4dd715af", "score": "0.49707466", "text": "function processContactLink() {\n $('content').innerHTML = getContactMarkup();\n $('head-contact').src = '../img/heidi/header-contact-a.gif';\n $('head-portfolio').src = '../img/heidi/header-portfolio.gif';\n //Currently, \"Resume\" \"active\" image is never used.\n adjustNavigationState('contactHeidi.html');\n Element.hide('nav');\n}", "title": "" }, { "docid": "1129fbbca9540a3d3bf370ca52579e5b", "score": "0.49679598", "text": "constructor({subject, recipients}, content){\n super();\n\n //lec 135\n this.sgApi = sendgrid(keys.sendGridKey);\n //who this email appears to be sent from\n //people using emaily service to send our survey\n this.from_email = new helper.Email('[email protected]');\n this.subject = subject;\n this.body = new helper.Content('text/html',content);\n this.recipients = this.formatAddresses(recipients);\n\n this.addContent(this.body);\n this.addClickTracking();\n this.addRecipients();\n\n }", "title": "" }, { "docid": "e3376b3c68a39c350c3d52222761f4f8", "score": "0.49619776", "text": "function onClickContactList(event) {\n // on annule le comportement par défaut du clic sur le lien\n event.preventDefault();\n\n // Il y a deux propriété très importantes sur event qui permettent de récupérer\n // ce qui à déclenché l'évènement\n // event.currentTarget ==> this\n // event.target ==> l'enfant qui à déclenché l'évênement\n\n // on identifie la cible qui à été cliqué\n var link = event.target;\n\n // on récupère la valeur de l'attribut data-index\n var contactIndex = $(link).data('index');\n\n // récupération des infos du contact séléctioné\n var contact = getContactInfos(contactIndex);\n\n var contactDOM = $('#contact-infos');\n\n contactDOM.children('h2').text(contact.gender + \" \" + contact.lastname + \" \" + contact.firstname);\n contactDOM.children('p').text(contact.phone);\n contactDOM.children('a').data('index', contactIndex);\n\n contactDOM.fadeIn();\n}", "title": "" }, { "docid": "d45c53e6d7249ce9bdef11d0e571cb2e", "score": "0.49612594", "text": "function addActiveAddress() {\n radioAddress = document.getElementsByName(\"address-radio\");\n let summaryContact = document.querySelector(\"#dynamic-contact\");\n for (var i = 0, length = radioAddress.length; i < length; i++) {\n if (radioAddress[i].checked) {\n addressDiv = radioAddress[i].parentElement;\n let name = addressDiv.querySelectorAll(\"li\")[0].textContent;\n let address = addressDiv.querySelectorAll(\"li\")[1].textContent;\n addedContact = `\n <li><b id='user-name'>${name}</b></li>\n <li id='user-address'>${address}</li>\n `;\n let newElement = document.createElement(\"li\");\n newElement.innerHTML = addedContact;\n summaryContact.appendChild(newElement);\n }\n }\n }", "title": "" }, { "docid": "83b6f5a753f694826c26503f55186f2e", "score": "0.49590138", "text": "async function listenforsend(tabid, details) { //15\r\n\r\n //console.log(\"Details: \"+JSON.stringify(details))\r\n\r\n// Check recipients of a message\r\n // console.log(\"To: \"+ details['to'] )\r\n // console.log(\"CC: \"+ details['cc'] )\r\n // console.log(\"BCC: \"+ details['bcc'] )\r\n ExpandButton(tabid);// To expand addresses\r\n// Build an array of To and CC recipients and remove exact duplicates\r\n if (domainExclude == undefined) {domainExclude = \"\"}\r\n if (versionHeader == undefined) {versionHeader = \"\"}\r\n console.log(\"Domain to exclude is:\" + typeof domainExclude + \", \" + domainExclude);\r\n if (versionHeader != \"\") {\r\n console.log(\"Version setting is \" + typeof versionHeader + \" is \" + versionHeader);\r\n }\r\n var accounts = await browser.accounts.list();\r\n for (const account of accounts) {\r\n for (const identity of account.identities) {\r\n if (identity.id == details['identityId']) {\r\n Sender = identity.email;\r\n }\r\n }\r\n }\r\n console.log(\"Sender is \" + Sender);\r\n if (Sender.indexOf(domainExclude) > 0 && versionHeader !=\"\") {\r\n await browser.myapi.SetVersionHeader(versionHeader)\r\n }\r\n console.log(details);\r\n var reciplist = details['to'].concat(details['cc'])\r\n reciplist = reciplist.concat(details['bcc'])\r\n console.log(\"Recipient list :\" + reciplist);\r\n var nonweeded = [];\r\n reciplist.forEach(element => {\r\n var dup = false;\r\n for (let i = 0; i < nonweeded.length; i++) {\r\n if (element == nonweeded[i]) {\r\n dup = true;\r\n break;\r\n };\r\n };\r\n if ( !dup ) { nonweeded.push(element) };\r\n });\r\n // console.log( \"Weeded: \" + nonbccweeded );\r\n\r\n// Separate email addresses and lists (or posssible lists)\r\n\r\n// This regex defines any string with one @ followed by a string containing 1 or more dots and no spaces as an email address\r\n// Anything else might be a list\r\n// TODO Check how TB defines an email address\r\n var re = /[^@]*@[^@\\. ]*\\.[^@ ]*$/;\r\n\r\n var validaddresses = [];\r\n var possiblelists = [];\r\n\r\n nonweeded.forEach(element => {\r\n var isaddress = re.test(element) ;\r\n if (isaddress) {\r\n validaddresses.push(element);\r\n } else {\r\n possiblelists.push(element);\r\n }\r\n });\r\n\r\n //console.log(\"Valid email addresses: \" + validaddresses);\r\n //console.log(\"Possible lists: \" + possiblelists);\r\n\r\n// Match possible lists with mailing lists and count their contacts\r\n var contactcount;\r\n let listcontactspromise = new Promise((resolve) => { //8\r\n var listcontactsarray = [];\r\n if ( possiblelists.length == 0) { //7.5\r\n resolve(listcontactsarray);\r\n } else {\r\n browser.addressBooks.list(true)\r\n .then(function(books) { //7\r\n contactcount = 0 ;\r\n books.forEach(book => { //6\r\n if (book.mailingLists) { //5\r\n // console.log(\"Mailing list node: \" + JSON.stringify(book));\r\n book.mailingLists.forEach(list => { //4\r\n // console.log(\"Mailing list name: \" + list.name);\r\n// Check each possible list for match on name\r\n possiblelists.forEach(posslist => { //3\r\n// List recipients are of the form \"name <name>\" - extract the name\r\n var possname = posslist.replace(/ <.*>$/,\"\");\r\n// // console.log(\"Possible list name: \" + possname );\r\n// // console.log(\"This list name: \" + list.name);\r\n// // console.log(\"This list contacts: \" + JSON.stringify(list.contacts) );\r\n\r\n if (possname == list.name) { //2\r\n// Matches a list\r\n // console.log(\"Matched list: \" + possname + \" Contacts: \" + list.contacts.length);\r\n // confirmedlists.push(possname);\r\n\r\n// Collect the contacts from the list for later weeding of duplicates\r\n// // console.log(\"Mailing list node: \" + JSON.stringify(list));\r\n list.contacts.forEach(contact => { //1\r\n if (contact.properties.DisplayName == contact.properties.PrimaryEmail) {\r\n listcontactsarray.push(contact.properties.PrimaryEmail);\r\n } else {\r\n listcontactsarray.push(contact.properties.DisplayName + \"<\" + contact.properties.PrimaryEmail + \">\");\r\n }\r\n // console.log(\"Added contact: \" + contact.properties.PrimaryEmail );\r\n }) //1\r\n }; //2\r\n }); //3\r\n }); //4\r\n }; //5\r\n resolve(listcontactsarray);\r\n }); //6\r\n }); //7\r\n }; //7.5\r\n }); //8\r\n\r\n// Wait for all that\r\n let listcontacts = await listcontactspromise ;\r\n\r\n// Weed out duplicates within the list contacts.\r\n// Note: Could count all the contacts in one go.\r\n// But might report counts separately in future.\r\n var dup\r\n console.log(\"List contacts: \" + listcontacts );\r\n var listcontactsweeded = [] ;\r\n listcontacts.forEach(element => {\r\n dup = false;\r\n// Check within listcontacts\r\n for (let i = 0; i < listcontactsweeded.length; i++) {\r\n if (element == listcontactsweeded[i]) {\r\n dup = true;\r\n break;\r\n };\r\n };\r\n// Check within validaddresses - just email address part so remove name\r\n for (let i = 0; i < validaddresses.length; i++) {\r\n var emailpart = validaddresses[i].replace(/^.*</, \"\") ;\r\n emailpart = emailpart.replace(/>.*$/, \"\") ;\r\n //console.log(\"Email part: \" + emailpart ) ;\r\n if (element == emailpart) {\r\n dup = true;\r\n break;\r\n };\r\n };\r\n if ( !dup ) { listcontactsweeded.push(element) };\r\n });\r\n //console.log( \"Weeded list contacts: \" + listcontactsweeded );\r\n var Breakdomain = \"\";\r\n var controlledRecipients = [];// List of all addresses in the safe area\r\n var Recipients = [];// List of all the other addresses\r\n // Check the email addresses for validaddresses\r\n //Title[row] = Titles.slice(0,Titles.indexOf(\"|\"));\r\n var TotalAddresses = validaddresses.concat(listcontactsweeded);\r\n for (let i = 0;i < TotalAddresses.length;i++) {\r\n var AddressDomain = TotalAddresses[i].slice(TotalAddresses[i].indexOf(\"@\") + 1);\r\n if (AddressDomain.indexOf(\">\") > -1) {\r\n AddressDomain = AddressDomain.slice(0,AddressDomain.indexOf(\">\"));\r\n }\r\n console.log(TotalAddresses[i] + \" \" + domainExclude.indexOf(\" \") + \" \" + domainExclude.indexOf(AddressDomain));\r\n console.log(\"Domain of \" + TotalAddresses[i] + \" is: \" + AddressDomain + \", Domain to contain is:\" + domainExclude);//gmail.com>\r\n if ((domainExclude[1] == \"@\" && \"@\" + AddressDomain == domainExclude) ||\r\n (domainExclude.indexOf(\" \") > -1 && domainExclude.indexOf(AddressDomain) > -1)||\r\n (TotalAddresses[i].indexOf(domainExclude) > -1))\r\n {\r\n controlledRecipients.push(TotalAddresses[i]);\r\n } else {\r\n Recipients.push(TotalAddresses[i]);\r\n }\r\n }\r\n // Check if any addresses break the barrier\r\n SenderDomain = Sender.slice(Sender.indexOf(\"@\") + 1)\r\n if (SenderDomain.indexOf(\">\") > -1) {\r\n SenderDomain = SenderDomain.slice(0,SenderDomain.indexOf(\">\"));\r\n }\r\n console.log(\"Sender, Domain and place in DomainExclude:\" + Sender + \" \" + SenderDomain + \" \" + domainExclude.indexOf(SenderDomain));\r\n if ((domainExclude[1] == \"@\" && \"@\" + SenderDomain == domainExclude) ||\r\n (domainExclude.indexOf(\" \") > -1 && domainExclude.indexOf(SenderDomain) > -1)||\r\n (Sender.indexOf(domainExclude) > -1)) {\r\n if (Recipients.length > 0) {\r\n Breakdomain = Recipients;\r\n }\r\n } else {\r\n if (controlledRecipients.length > 0) {\r\n Breakdomain = controlledRecipients;\r\n }\r\n }\r\nconsole.log(\"controlledRecipients : \" + controlledRecipients);\r\nconsole.log(\"Recipients :\" + Recipients);\r\nconsole.log(\"Breakdomain \" + Breakdomain);\r\nif (Breakdomain.length > 0) {\r\n// Breaks the domain barrier exceeded. Open a dialogue popup\r\n//*\r\n extensionName = browser.i18n.getMessage(\"title\");\r\n var createData={allowScriptsToClose: true,\r\n titlePreface : extensionName,\r\n width : 500,\r\n height : 300 + Breakdomain.length * 10,\r\n type : \"popup\",\r\n url : \"dialogue.html?\" + Breakdomain\r\n };\r\n\r\n var wid=null;\r\n browser.windows.create(createData).then((win)=>{\r\n wid=win.id;\r\n });\r\n\r\n// Wait for response from popup\r\n let response = new Promise((resolve) => {\r\n async function gotmessage(msg) {\r\n // console.log(msg);\r\n browser.windows.remove(wid);\r\n browser.runtime.onMessage.removeListener(gotmessage);\r\n resolve(msg);\r\n }\r\n\r\n browser.runtime.onMessage.addListener(gotmessage);\r\n\r\n });\r\n var msgobj = await response ;\r\n console.log(\"Response of the window is:\" + msgobj);\r\n // console.log(\"Response: \"+mess) ;\r\n// Action according to response\r\n\r\n var returnobj = new Object()\r\n returnobj['details'] = DetailsToSend ;\r\n if (msgobj.msg == \"send_cancel\") {\r\n returnobj['cancel'] = true;\r\n } else {\r\n returnobj['cancel'] = false;\r\n }\r\n //console.log( returnobj);\r\n return returnobj ;\r\n\r\n } else {\r\n// No Breakdomain - continue with send\r\n var returnobj = new Object();\r\n returnobj['details'] = DetailsToSend ;\r\n//TESTING - Change to true to stop sending\r\n returnobj['cancel'] = false ;\r\n return returnobj ;\r\n }\r\n }", "title": "" }, { "docid": "1a54c5cc8c15335d2a62360a94591484", "score": "0.49569353", "text": "function handelListMaking(data) {\n // console.log(data);\n if (data !== undefined) {\n const lists = data;\n const main = document.querySelector('main');\n\n main.innerHTML = `<div class=\"boards board-flex\">\n <div class=\"list-container board-flex height-100\">\n </div>\n <div>\n <button type=\"button\" class=\"btn add-list-btn-primary btn-primary margin-right\" onclick=\"handelListMaking()\">\n add new list..\n </button>\n </div>\n </div>`;\n\n lists.forEach((list) => {\n createList(list)\n });\n }\n\n else {\n createList();\n }\n\n function createList(list) {\n\n function handelListName(obj) {\n\n if (obj !== undefined) {\n listName.innerHTML = obj.title;\n\n }\n else {\n listName.innerHTML = \"brand new list\";\n }\n }\n\n function handelCards(obj) {\n\n if (obj !== undefined) {\n let tasks = obj.tasks;\n\n for (task of tasks) {\n\n //create card wraper and appand to dad ul\n const cardWraper = createElement('li', ['assignment'], listUl);\n cardWraper.tabIndex = '0';\n cardWraper.setAttribute('data-id', `${task.id}`);\n\n\n //create edit btn and appand to dad ul\n const editBtn = createElement('button', ['card-edit-btn', 'btn', 'btn-info', 'btn-xs'], cardWraper);\n editBtn.textContent = 'Edit card';\n editBtn.addEventListener(\"click\", toggleModal);\n\n //create interactive task description\n const cardDiscription = createElement('p', ['card-description', 'p-no-margins'], cardWraper);\n\n cardDiscription.textContent = task.text;\n\n //loop the member\n\n membersMaker(task.members, cardWraper);\n\n }\n }\n }\n\n function handelListId(obj) {\n\n if (obj !== undefined) {\n newList.setAttribute('data-id', list.id);\n }\n else {\n newList.setAttribute('data-id', uuid());\n }\n }\n\n /*create the list*/ /**********************$%$%*************************/\n\n const listsContainer = document.querySelector('main > div > div');\n\n const newList = createElement('section', ['panel panel-default'], listsContainer);\n\n const listHead = createElement('div', ['panel-heading, task-name-wraper'], newList);\n\n const listName = createElement('h3', ['panel-title'], listHead);\n\n handelListId(list);\n handelListName(list);\n listName.tabIndex = '0';\n\n listName.addEventListener(\"click\", changeListName);\n listName.addEventListener('keydown', changeListName);\n\n const titelInPut = createElement('input', ['list-name-input'], listHead);\n\n titelInPut.setAttribute(\"value\", `${listName.innerHTML}`);\n titelInPut.style.display = \"none\";\n\n titelInPut.addEventListener(\"blur\", saveListName);\n titelInPut.addEventListener('keydown', saveListName);\n\n //create the editBtn container\n const editBtnContainer = createElement('div', ['btn-group'], listHead);\n\n editBtnContainer.innerHTML = `\n <button type=\"button\" class=\"delete-btn btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n <span class=\"smaller-glyphicon glyphicon glyphicon-triangle-bottom\"></span>\n </button>\n <ul class=\"ul-drop-down dropdown-menu\">\n <li><a href=\"#\"><span class=\"padding-right glyphicon glyphicon-trash\n \"></span>Delete</a></li>\n </ul>\n`;\n //target btn and add events\n const editBtn = editBtnContainer.querySelector('button');\n const deleteLi = editBtnContainer.querySelector('li');\n\n addEventListeners([editBtn], ['click', 'blur', 'keydown'], handelDropDown);\n addEventListeners([deleteLi], ['mousedown'], deleteList);\n\n //create the list content add it to dad and give class\n const overFlowMask = createElement('div', ['over-flow-mask'], newList);\n\n //create the list ul\n const listUl = createElement('ul', ['flex-box'], overFlowMask);\n handelCards(list);\n //create the list footer add it to dad and give class\n const listFooter = createElement('div', ['panel-footer', 'list-footer'], newList);\n listFooter.tabIndex = '0';\n\n //create the add card btn in footer and give class and onclick\n const addCardBtn = createElement('span', ['panel-footer-btn'], listFooter);\n\n addCardBtn.innerHTML = `\n<span class=\"padding-right glyphicon glyphicon-plus\"></span>Add New Card`;\n listFooter.addEventListener(\"click\", addNewCard);\n\n if (list === undefined) {\n addNewListToAppData(newList, listName);\n }\n }\n}", "title": "" }, { "docid": "3b0ff672c326cd5c3113e57e69014baa", "score": "0.49568236", "text": "function fn_rotloadexpextendcontent(scheduleid,licenseid,type)\n{\n console.log(\"fn_rotloadexpextendcontent\");\n var list4 = [];\t //module id\n\n $(\"div[id^=list4_]\").each(function()\n {\n list4.push($(this).attr('id').replace('list4_',''));\n });\n console.log(list4);\n setTimeout(function(){\n\tif((type==\"mod\" && $('#excflag').val()==1) || type==\"exc\")\n\t{\n\tvar list4 = [];\t //module id\n\t\n\t$(\"div[id^=list4_]\").each(function()\n\t{\n\t\t\tlist4.push($(this).attr('id').replace('list4_',''));\n\t});\n console.log(list4);\n\tif(list4=='' && type==\"exc\"){\n\t\talert(\"Please select any one Expedition\");\n\t\treturn false;\n\t}\n\tvar dataparam = \"oper=loadextendcontent&list4=\"+list4+\"&scheduleid=\"+scheduleid+\"&licenseid=\"+licenseid;\t\n\t\n\t$.ajax({\n\t\ttype: 'post',\n\t\turl: \"class/newclass/class-newclass-expedition-ajax.php\",\n\t\tdata: dataparam,\n\t\tbeforeSend: function(){\t\t\t\n\t\t},\n\t\tsuccess:function(data) {\n\t\t\tconsole.log(data);\n\t\t\t$('#expextendcontent').html(data);\n\t\t}\n\t\t\n\t});\t\n\t}\n }, 1000);\n}", "title": "" }, { "docid": "18b93b84b6e01908f95723a079b2030a", "score": "0.4956629", "text": "[printContact](contact){\n let contacti = $(`<div class=\"mt-1 form-check d-inline-block\">\n <!--Contacts-->\n <span id=\"Contact_${contact.id}\">\n <small class=\"text-muted allContacts\">\n <input class=\"form-check-input form-control-sm\" \n id=\"ContactAll_${contact.id}\" type=\"checkbox\" value=\"\">\n ${contact.contactAddress}\n </input>\n </small></span></div>`);\n $(`.contact-list`).append(contacti);\n }", "title": "" }, { "docid": "27440544dc26c586a21cf4c1e7a23a58", "score": "0.4952528", "text": "function showContact(elem, editMode) {\n // Get the contact\n var address = elem.data(\"address\");\n var contact = getContact(address); \n if (contact === null){\n // Should never happen\n alert(\"Could not find contact \"+address);\n return;\n }\n\n // Select the item\n $(\".js-item.active\").removeClass(\"active\");\n elem.addClass(\"active\");\n\n // Show the detail\n viewState.contact = contact;\n if (contact.address == sessionStorage[\"emailAddress\"]) {\n showSelfDetails(contact);\n } else if(editMode) {\n showContactEditDetails();\n } else {\n showContactDetails();\n }\n}", "title": "" }, { "docid": "78db87ed71075c9c4e7599c84cf4a708", "score": "0.49514097", "text": "function appendCPnotes(selection){\t\t\t\t\t\n\t\t\t\t//$(\"#CPnotesList\").empty();\n\t\t\t\tswitch(selection){\n\t\t\t\t\tcase \"Fire\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"natural\">Natural</li><li class=\"prescribed\">Prescribed</li><li class=\"sitePrepFire\">Site-prep fire</li><li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#fire\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forFire\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forFire\").attr(\"disabled\", false);\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Harvest\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"clearcut\">Clearcut</li><li class=\"thinning\">Thinning</li><li class=\"sitePrepFire\">Site-prep fire</li><li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#harvest\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forHarvest\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forHarvest\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t// case \"Decline\":\n\t\t\t\t\t// \t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t// \t$(\"#decline\").addClass(\"selected\");\n\t\t\t\t\t// \t$(\".forDecline\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t// \t$(\".forDecline\").attr(\"disabled\", false);\n\t\t\t\t\t// \tbreak;\n\t\t\t\t\tcase \"Acute Decline\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#acuteDecline\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forAcuteDecline\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forAcuteDecline\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Condition Decline\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#conditionDecline\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forConditionDecline\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forConditionDecline\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Wind\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#wind\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forWind\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forWind\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Hydrology\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"flooding\">Flooding</li><li class=\"reserviorLakeFlux\">Reservoir/Lake flux</li><li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#hydro\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forHydro\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forHydro\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Debris\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\n\t\t\t\t\t\t$(\"#debris\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forDebris\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forDebris\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Growth/Recovery\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#growth\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forGrowth\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forGrowth\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Stable\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t$(\"#stable\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forStable\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forStable\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Mechanical\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"wetlandDrainage\">Wetland drainage</li><li class=\"airphotoOnly\">Airphoto only</li>');\n\t\t\t\t\t\t$(\"#mechanical\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forMechanical\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forMecahnical\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Other\":\n\t\t\t\t\t\t//$(\"#CPnotesList\").append('<li class=\"airphotoOnly\">Airphoto only</li>');\n\t\t\t\t\t\t$(\"#otherCP\").addClass(\"selected\");\n\t\t\t\t\t\t$(\".forOther\").closest(\"li\").removeClass(\"disabled\");\n\t\t\t\t\t\t$(\".forOther\").attr(\"disabled\", false);\n\t\t\t\t\t\tbreak;\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "328e8d558df4928be053d5801ba879e1", "score": "0.494682", "text": "addMore(contoLName) {\n this.submitUser.get(contoLName).push(this.createContact());\n // (<FormArray>this.submitUser.get('contacts')).push(this.createContact());\n // this.contactList.push(this.createContact());\n }", "title": "" }, { "docid": "328e8d558df4928be053d5801ba879e1", "score": "0.494682", "text": "addMore(contoLName) {\n this.submitUser.get(contoLName).push(this.createContact());\n // (<FormArray>this.submitUser.get('contacts')).push(this.createContact());\n // this.contactList.push(this.createContact());\n }", "title": "" }, { "docid": "c4fe5d2b141055627d1bf86a40d16051", "score": "0.49449995", "text": "function SectionDeliverabilityOverview(){}", "title": "" }, { "docid": "d1a58261f1f94749b49b9afd7c82f059", "score": "0.4939777", "text": "function makeContact(selectedAccount) {\n\n $mdBottomSheet.show({\n controllerAs : \"vm\",\n templateUrl : './src/accounts/view/contactSheet.html',\n controller : [ '$mdBottomSheet', ContactSheetController],\n parent : angular.element(document.getElementById('content'))\n }).then(function(clickedItem) {\n $log.debug( clickedItem.address + ' clicked!');\n });\n\n /**\n * Account ContactSheet controller\n */\n function ContactSheetController( $mdBottomSheet) {\n this.account = selectedAccount;\n this.send={fromAddress: selectedAccount.address, secondSignature:selectedAccount.secondSignature}\n this.items = [\n { name: 'Send Lisk', icon: 'send'},\n { name: 'Delete', icon: 'delete'}\n ];\n this.answer=function(answer){\n $mdDialog.hide(answer);\n }\n this.contactAccount = function(action) {\n\n $mdBottomSheet.hide(action);\n if(action.name==\"Delete\"){\n var confirm = $mdDialog.confirm()\n .title('Delete Account '+ this.account.address)\n .textContent('Are you sure? There is no way back.')\n .ok('Delete permanently this account')\n .cancel('Cancel');\n $mdDialog.show(confirm).then(function() {\n accountService.deleteAccount(selectedAccount).then(function(account){\n self.accounts = accountService.loadAllAccounts();\n if(self.accounts.length>0) selectAccount(self.accounts[0]);\n $mdToast.show(\n $mdToast.simple()\n .textContent('Account deleted!')\n .hideDelay(3000)\n );\n });\n });\n }\n\n if(action.name==\"Send Lisk\"){\n $mdDialog.show({\n controllerAs : \"vm\",\n controller : [ '$mdBottomSheet', ContactSheetController],\n parent : angular.element(document.getElementById('content')),\n templateUrl : './src/accounts/view/sendLisk.html',\n clickOutsideToClose: true\n }).then(function(vm) {\n if(vm){\n accountService.sendLisk(vm.send.toAddress, parseInt(vm.send.amount*100000000), vm.send.passphrase, vm.send.secondpassphrase).then(\n function(transaction){\n $mdToast.show(\n $mdToast.simple()\n .textContent('Transaction '+transaction.id+' sent!')\n .hideDelay(5000)\n );\n },\n function(reason) {\n $mdToast.show(\n $mdToast.simple()\n .textContent('Error: '+reason)\n .hideDelay(5000)\n );\n }\n );\n }\n }, function() {\n\n });\n\n\n }\n\n };\n }\n }", "title": "" } ]
f721932046d4564a4341c32abbcf4a63
Wait for the window to finish loading before running the callback
[ { "docid": "80f1dfac51f2379bf25903773ba33e14", "score": "0.600618", "text": "function runOnLoad(window) {\n // Listen for one load event before checking the window type\n window.addEventListener(\"load\", function runOnce(event) {\n window.removeEventListener(\"load\", runOnce, false);\n myExtension.init(window);\n //window.removeEventListener(\"load\", runOnce, false);\n watcher(window);\n }, false);\n }", "title": "" } ]
[ { "docid": "0cc599d4b3814de6906852c2e8c77adc", "score": "0.6999439", "text": "windowLoaded() {\n console.info('On complete fired');\n if (this.oncomplete)\n eval(this.oncomplete);\n }", "title": "" }, { "docid": "c5ab549de0fd301befc1b187b4fa84e3", "score": "0.68924797", "text": "onload() {\n // do something to the UI when this fires to signify that it's done\n console.log('done loading');\n }", "title": "" }, { "docid": "d18dc9bad8c249e98d629cf2030aae07", "score": "0.66158193", "text": "function whenUIReady(chromeWin, callback) {\n let domWindow = chromeWin\n .QueryInterface(Ci.nsIInterfaceRequestor)\n .getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);\n\n domWindow.addEventListener(\"load\", function onLoad() {\n domWindow.removeEventListener(\"load\", onLoad, false);\n callback(domWindow);\n }, false);\n}", "title": "" }, { "docid": "2d75c8626c5b90be06f672098f38645e", "score": "0.6528131", "text": "function wait_for_window_close() {\n WindowWatcher.waitForWindowClose();\n}", "title": "" }, { "docid": "a3d28e1d5f1a663d59fa5e2ae0a9d9bb", "score": "0.63970655", "text": "function ready() {\n\t vdom_debug('attachWindow-ready', gob);\n\t createENV(gob);\n\t gob.location = \"about:blank\";\n\t if (cb)\n\t\tcb(gob);\n\t}", "title": "" }, { "docid": "c201c5873a70fc4da285f8df54919f36", "score": "0.63853693", "text": "loading() {\n window.loadingInvoked = true;\n }", "title": "" }, { "docid": "bcf614f445395f577c64a28f601bb3f9", "score": "0.6374565", "text": "confirmWaitersLoaded() {\n if (this.tabs.getActiveTab(\"input\") >= 0 &&\n this.tabs.getActiveTab(\"output\") >= 0) {\n log.debug(\"Waiters loaded\");\n this.app.waitersLoaded = true;\n this.app.loaded();\n } else {\n // Not loaded yet, try again soon\n setTimeout(this.confirmWaitersLoaded.bind(this), 10);\n }\n }", "title": "" }, { "docid": "b21595c6882f1871cd8156a6fd27720f", "score": "0.6340634", "text": "function load() {\n if (!loaded) {\n loaded = true;\n\n callback();\n }\n }", "title": "" }, { "docid": "92a3d82da9d1ffe71866c79d2e5a914d", "score": "0.6335243", "text": "function setWindowLoaded() {\n _windowLoaded = true;\n window_default.a.removeEventListener('load', setWindowLoaded);\n}", "title": "" }, { "docid": "abbba106cb381863854a98665631ef7a", "score": "0.6314579", "text": "function setWindowLoaded() {\n _windowLoaded = true;\n window.removeEventListener('load', setWindowLoaded);\n }", "title": "" }, { "docid": "d31b7ec797cd0bfb977c7ac273ebb51d", "score": "0.62913275", "text": "function qodefOnWindowLoad() {\n\n }", "title": "" }, { "docid": "d33f14fd9721ba6de7ff22d05e4d1db7", "score": "0.6285683", "text": "function windowLoaded() {\n api.search.general(getParams(window.location.href).q, 0).then((response) => {\n dom.renderSearch(response);\n });\n // Listen for screen orientation changes\n // The orientation object is provided by Cordova\n screen.orientation.addEventListener('change', function() {\n dom.setOrientation();\n })\n document.getElementById('searchbox').addEventListener('search', function() {\n let searchterm = document.getElementById('searchbox').value;\n window.location.replace('search.html?q=' + searchterm);\n });\n}", "title": "" }, { "docid": "98d60e6dee59c7525727fd3cc6f05adb", "score": "0.62090546", "text": "function loadComplete(callback){\n loadProgress(100);\n var loadingDiv = $('#loading'),\n device = control.currentDevice;\n // menu = $('#menu_button'); \n loadingDiv.fadeOut(1000);\n //menu.fadeIn(1000);\n if (callback && typeof(callback) === \"function\") {\n callback();\n }\n\n console.timeEnd(\"initialize js chain until ready\");\n\n }", "title": "" }, { "docid": "fb3e1b252f7e939693907386aaaaf7b2", "score": "0.6196101", "text": "function qodeOnWindowLoad() {\n qodeInitElementorWorkflow();\n }", "title": "" }, { "docid": "36b115b31eb48a91a59e222bf4776dfb", "score": "0.6150622", "text": "function setWindowLoaded() {\n _windowLoaded = true;\n window.removeEventListener('load', setWindowLoaded);\n}", "title": "" }, { "docid": "b35feb135f7da20b7b3aaddec649c101", "score": "0.61132765", "text": "function edgtOnWindowLoad() {\n\n }", "title": "" }, { "docid": "871eea6dee1cad481af6bea051347ec9", "score": "0.6102975", "text": "function _windowonload() {\n uuready.window = _true;\n _DOMContentLoaded();\n uureadyfire(\"window\");\n}", "title": "" }, { "docid": "0ff9717ebe5d1f5c3347214183e7f816", "score": "0.6102623", "text": "function loadEnd() {\r\n console.log('loadEnd');\r\n assignWaitPropertyToElement()\r\n }", "title": "" }, { "docid": "b9355828d10d95992c4f1ee6e0d87588", "score": "0.6099413", "text": "function loadIntoWindow(aWindow) {\n if (aWindow && aWindow.gBrowser) {\n // Add a listener to the tabbrowser\n aWindow.gBrowser.addEventListener(\"DOMContentLoaded\",\n onDOMContentLoaded, false);\n }\n}", "title": "" }, { "docid": "b4d5de9ac671cfd7a6bca39742b9420e", "score": "0.60618186", "text": "doneLoading() {\n\t\tconst result = this.isLoading();\n\n\t\tif (result === 1) {\n\t\t\tif (typeof this.loadedCallback !== 'undefined' && this.loadedCallback !== 0 && this.loadedCallback !== null) {\n\t\t\t\tthis.loadedCallback();\n\t\t\t}\n\t\t}\n\t}", "title": "" }, { "docid": "360b0cffcec5bba7a68b6a73292de966", "score": "0.6055513", "text": "function waitForDocumentReady() {\n return new Promise(resolve => {\n if (document.readyState === 'complete') {\n resolve();\n }\n\n window.addEventListener('load', () => {\n resolve();\n }, {once: true});\n });\n}", "title": "" }, { "docid": "934a6da1df3947b1468c180a5d5d41e4", "score": "0.6042449", "text": "function edgtfOnWindowLoad() {\n }", "title": "" }, { "docid": "b7b00c057c9bb5aa834bb629441cec76", "score": "0.60103005", "text": "function init() {\n loadComplete();\n}", "title": "" }, { "docid": "ed0348bef5ad16f66889995bae419876", "score": "0.600613", "text": "doneLoading() { return this.page.waitForFunction( 'document.querySelector(\".mt-loading\") == null' ); }", "title": "" }, { "docid": "89fc81183bafb2558df4e9f29b44e97f", "score": "0.60059375", "text": "function Ready() {\r\n\r\n // Reset busy indicator\r\n normal();\r\n\r\n if (translationProgressTimer != null) {\r\n // Stop the translation progress check timer.\r\n window.clearInterval(translationProgressTimer);\r\n translationProgressTimer = null;\r\n }\r\n\r\n // Load the document in viewer\r\n LoadViewerDocument();\r\n}", "title": "" }, { "docid": "03c4a5939bbefd62f16c31e221719a98", "score": "0.5964214", "text": "function qodeOnWindowLoad() {\n qodeInitElementorCardsGallery();\n }", "title": "" }, { "docid": "2f6cf1cb0c603bc8b363c1ce1a2d5dcf", "score": "0.5957107", "text": "function onWindowLoad() {\n if (self.isWebView()) {\n // the window and scripts are fully loaded, and a cordova/phonegap\n // object exists then let's listen for the deviceready\n document.addEventListener(\"deviceready\", onPlatformReady, false);\n } else {\n // the window and scripts are fully loaded, but the window object doesn't have the\n // cordova/phonegap object, so its just a browser, not a webview wrapped w/ cordova\n onPlatformReady();\n }\n if (windowLoadListenderAttached) {\n window.removeEventListener(\"load\", onWindowLoad, false);\n }\n }", "title": "" }, { "docid": "2aacf4e38bcedbbc90efb9481dd965e3", "score": "0.5946866", "text": "doneLoading() {\n\t\t\tclearTimeout(this.timeout);\n\t\t\tthis.loaded = true;\n\t\t\tif (this.callback !== 0) {\n\t\t\tthis.callback();\n\t\t\t}\n\t}", "title": "" }, { "docid": "46e50ab74be0e227e8549ed40456e4fe", "score": "0.5940539", "text": "function completed() {\n // readyState === \"complete\" is good enough for us to call the dom ready in oldIE\n if ( document.addEventListener || event.type === \"load\" || document.readyState === \"complete\" ) {\n isReady = true;\n detach();\n\n callback();\n }\n }", "title": "" }, { "docid": "85eda2d7d2523ddf46979fe64e230df7", "score": "0.59357303", "text": "_waitForPage (window, generateFunction, waitTime) {\n const waitForJSEvent = this.args.waitForJSEvent\n if (waitForJSEvent) {\n const ipc = electron.ipcMain\n const eventName = _.size(waitForJSEvent) > 0 ? waitForJSEvent : 'view-ready'\n console.log(`Waiting for '${eventName}' event in the browser to continue rendering...`)\n const cmd = `var ipc = require('electron').ipcRenderer\n var body = document.body\n body.addEventListener('${eventName}', () => ipc.send('READY_TO_RENDER'))`\n ipc.once('READY_TO_RENDER', generateFunction)\n window.webContents.executeJavaScript(cmd)\n } else {\n setTimeout(generateFunction, waitTime)\n }\n }", "title": "" }, { "docid": "2d57103646991c6e6a51cc0a2481b40f", "score": "0.5931826", "text": "function waitTillAsyncApiLoaded(callback) {\n if (!Object.prototype.hasOwnProperty.call(window, 'mixpanel') || (window.mixpanel['__loaded'] === undefined)) {\n setTimeout(function () {\n waitTillAsyncApiLoaded(callback);\n }, 500);\n }\n\n callback();\n }", "title": "" }, { "docid": "54b2309e9fa4b89d2bff0fc10cc77e8f", "score": "0.59292215", "text": "function loading() {\n loader.style.display = \"initial\";\n firstSetMeasureCall = true;\n\n // Check if the callback is invoked before that a button is pressed (fast connection)\n if(fired)\n main();\n }", "title": "" }, { "docid": "7b4b5c2e70d87aaa3a004d6fa4dae4fb", "score": "0.5924307", "text": "function waitForScriptsLoad() \r\n {\r\n var scriptWindow = (typeof unsafeWindow == \"undefined\" ? window : unsafeWindow);\r\n \r\n if(typeof scriptWindow.jQuery == 'undefined' || typeof scriptWindow.overlib == 'undefined') \r\n //if (scriptWindow.jQuery == null || scriptWindow.overlib == null)\r\n window.setTimeout(waitForScriptsLoad,100); \r\n else \r\n {\r\n $ = scriptWindow.jQuery; \r\n\r\n //Inject the DIV for overlib\r\n $(\"body\").prepend('<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000\"></div>');\r\n\r\n //Call the main function depending on the page we are in\r\n if (inMyWantsPage)\r\n myWantsMain();\r\n }\r\n }", "title": "" }, { "docid": "8c79ec56baf83001a842f3e6a3cc5620", "score": "0.5887888", "text": "function windowLoadEvent() {\n //remove listener, no longer needed\n win.removeEventListener(\"load\", windowLoadEvent, false);\n //Run function whenever browser resizes\n window.onresize = respondCanvas;\n //listen to fullscreen changes\n doc.addEventListener(\"fullscreenchange\", fullScreenHandler);\n doc.addEventListener(\"webkitfullscreenchange\", fullScreenHandler);\n doc.addEventListener(\"mozfullscreenchange\", fullScreenHandler);\n doc.addEventListener(\"MSFullscreenChange\", fullScreenHandler);\n //check for updates appcache\n // win.applicationCache.addEventListener(\"updateready\", appCacheEvent, false);\n //load images\n gameGfx.init();\n}", "title": "" }, { "docid": "98ef90ef795c48c60bd2bae88b88be39", "score": "0.58846295", "text": "onReady(f) {\n window.onload = f;\n }", "title": "" }, { "docid": "6c4146e7f8a7f9b115ea356586161c97", "score": "0.5880973", "text": "function onLoad(callback) {\n callback();\n}", "title": "" }, { "docid": "6c4146e7f8a7f9b115ea356586161c97", "score": "0.5880973", "text": "function onLoad(callback) {\n callback();\n}", "title": "" }, { "docid": "0f0224008f8a1d64df628af57174af49", "score": "0.5878677", "text": "_loadUI() {\n var win = $(\"#window\")[0];\n\n if (this.context.isLoading.getValue()) {\n win.classList.add(\"passive-load\");\n }\n else {\n win.classList.remove(\"passive-load\");\n }\n }", "title": "" }, { "docid": "5f87a42822fc625b89fdcc610305cb15", "score": "0.58736515", "text": "function qodeOnWindowLoad() {\r\n qodeInitElementorContentMenu();\r\n }", "title": "" }, { "docid": "9d27119415477cccf550e3122b162d72", "score": "0.587252", "text": "function onloadsOn() {\n window.onload = onloadsGo;\n}", "title": "" }, { "docid": "5b6d649f191ceb8d7e285677efe71988", "score": "0.5869235", "text": "function scriptsDone () {\n \n let DOMContentLoadedEvent = document.createEvent('Event');\n DOMContentLoadedEvent.initEvent('DOMContentLoaded', true, true);\n document.dispatchEvent(DOMContentLoadedEvent);\n\n // based on an array of callback functions specified by the user\n callBacks.forEach(cb => {\n cb;\n })\n \n //console.log(\"scripts done\", document)\n }", "title": "" }, { "docid": "58767c34cc5e5cf645a10a9f7921026b", "score": "0.58674586", "text": "function qsWindowLoaded()\r\n{\r\n var appcontent = document.getElementById(\"appcontent\");\r\n if(appcontent) {\r\n appcontent.addEventListener(\"DOMContentLoaded\", qsDomContentLoaded, true);\r\n }\r\n}", "title": "" }, { "docid": "ce59530457a05850ebdf0e4736dc80c2", "score": "0.5857902", "text": "async function loadPageOnAppReady(){\n // check to see if onsen is ready and if all app loading has been completed\n if(!ons.isReady() || utopiasoftware[utopiasoftware_app_namespace].model.isAppReady === false){\n setTimeout(loadPageOnAppReady, 500); // call this function again after half a second\n return;\n }\n\n // listen for the back button event\n $('#login-navigator').get(0).topPage.onDeviceBackButton = function(){\n ons.notification.confirm('Do you want to close the app?', {title: 'Exit',\n buttonLabels: ['No', 'Yes'], modifier: 'utopiasoftware-alert-dialog'}) // Ask for confirmation\n .then(function(index) {\n if (index === 1) { // OK button\n navigator.app.exitApp(); // Close the app\n }\n });\n };\n\n // hide the loader\n $('#loader-modal').get(0).hide();\n }", "title": "" }, { "docid": "e3058727b384c22dade18956ea723693", "score": "0.5852156", "text": "function onLoad(callback) {\r\n callback();\r\n}", "title": "" }, { "docid": "cb5a77deeee907b297b08f5ec021baa3", "score": "0.58349216", "text": "onLoad() {\n if (this._load) {\n this._load.raise();\n }\n }", "title": "" }, { "docid": "4e6efb4509fbac6cc6593c2c16bb550f", "score": "0.5822163", "text": "function finishload() {\n $.unblockUI();\n }", "title": "" }, { "docid": "d7bf0855a997500ee3319e6602b4759b", "score": "0.58183193", "text": "function ready(element, options) {\r\n appBarInit();\r\n liveInit();\r\n var enterPage = WinJS.UI.Animation.enterPage(rootGrid, { top: \"100px\", left: \"100px\" });\r\n enterPage.done();\r\n myprofile = ECGData.profile.items;\r\n UIInit();\r\n }", "title": "" }, { "docid": "57b1798fab9ab5e3c14d6f670097baa0", "score": "0.58180976", "text": "function whenMapIsReady(cb) { //when external vars have loaded\n var waiting = setInterval(function() { //run every 1sec until we have loaded the page (dont hate me Sam)\n if (map.loaded)\n {\n console.log(\"map is ready\");\n clearInterval(waiting); //stop timer\n cb(); //call back\n }\n}, 200);\n}", "title": "" }, { "docid": "57b1798fab9ab5e3c14d6f670097baa0", "score": "0.58180976", "text": "function whenMapIsReady(cb) { //when external vars have loaded\n var waiting = setInterval(function() { //run every 1sec until we have loaded the page (dont hate me Sam)\n if (map.loaded)\n {\n console.log(\"map is ready\");\n clearInterval(waiting); //stop timer\n cb(); //call back\n }\n}, 200);\n}", "title": "" }, { "docid": "5c2ed079ca83de02dd78af7b5902b088", "score": "0.58139527", "text": "function onLoad() {\n tab.removeListener(safaridriver.message.Alert.TYPE, onAlert);\n if (response.isPending()) {\n goog.log.info(safaridriver.extension.commands.LOG_,\n 'Page load finished; returning');\n tab.removeListener(safaridriver.message.Alert.TYPE, onAlert);\n response.fulfill();\n }\n }", "title": "" }, { "docid": "2b945da3d1c7c278ed0f1c8aa844b16e", "score": "0.5813836", "text": "function isWindowLoaded(/*HtmlWindow*/ win) {\n return !getWebProgress(win).isLoadingDocument;\n}", "title": "" }, { "docid": "aea1ccd6bda390965b54fba0c08d3ae9", "score": "0.5813482", "text": "function receiveMsg(){\n if(document.readyState === \"complete\" || document.readyState === \"interactive\") {\n // setTimeout(loadMsg, 200);\n loadMsg();\n } else {\n console.log('ReadyState not complete');\n }\n}", "title": "" }, { "docid": "848593c1dc49bde1caa63d2f84e9da87", "score": "0.5813269", "text": "function windowOnBlur() {\n\tif(!loadingComplete) return;\n\tsetPaused(true, PauseCause.LostFocus);\n}", "title": "" }, { "docid": "abd9e216696d9c81029b810dbdbf2834", "score": "0.5807252", "text": "function ready(callback){\n if (document.readyState === \"complete\"){\n callback();\n } else {\n document.addEventListener('DOMContentLoaded', function (){\n\tcallback();\n });\n }\n }", "title": "" }, { "docid": "a3573dcee1705db9025f67e4a48ab0df", "score": "0.5793568", "text": "_loadInitializationData(callback) {\n chrome.runtime.sendMessage({\n type: MessageTypes.LoadInitializationData\n }, callback);\n }", "title": "" }, { "docid": "84759c1f40a333c052ed43d23ec6edb5", "score": "0.5789531", "text": "static async onEndLoading() {\n switch (Platform.MODE_TEST) {\n case Platform.MODE_TEST_BATTLE_TROOP:\n await Manager.Stack.pushBattleTest();\n break;\n case Platform.MODE_TEST_SHOW_TEXT_PREVIEW:\n await Manager.Stack.pushShowTextPreview();\n break;\n default:\n Manager.Stack.pushTitleScreen();\n break;\n }\n Main.loaded = true;\n Manager.Stack.requestPaintHUD = true;\n }", "title": "" }, { "docid": "566029bc01a29e575df0e75eebe9a6c9", "score": "0.57699186", "text": "function wait_for_compose_window(aController) {\n if (aController === undefined) {\n aController = mc;\n }\n\n let replyWindow = windowHelper.wait_for_new_window(\"msgcompose\");\n\n let editor = replyWindow.window.document.querySelector(\"editor\");\n\n if (editor.docShell.busyFlags != Ci.nsIDocShell.BUSY_FLAGS_NONE) {\n let editorObserver = {\n editorLoaded: false,\n\n observe: function eO_observe(aSubject, aTopic, aData) {\n if (aTopic == \"obs_documentCreated\") {\n this.editorLoaded = true;\n }\n },\n };\n\n editor.commandManager.addCommandObserver(\n editorObserver,\n \"obs_documentCreated\"\n );\n\n utils.waitFor(\n () => editorObserver.editorLoaded,\n \"Timeout waiting for compose window editor to load\",\n 10000,\n 100\n );\n\n // Let the event queue clear.\n aController.sleep(0);\n\n editor.commandManager.removeCommandObserver(\n editorObserver,\n \"obs_documentCreated\"\n );\n }\n\n // Although the above is reasonable, testing has shown that the some elements\n // need to have a little longer to try and load the initial data.\n // As I can't see a simpler way at the moment, we'll just have to make it a\n // sleep :-(\n\n aController.sleep(1000);\n\n return replyWindow;\n}", "title": "" }, { "docid": "759bea21ae5d8ecf80f4530e69e15997", "score": "0.5769176", "text": "function Done(){\n\tconsole.log(\"page done!\");\n\t\n\t//load google charting package\n\t\n\tgoogle.load(\"visualization\", \"1\", {packages:[\"corechart\"], \"callback\":gVizloaded});\n}", "title": "" }, { "docid": "bb082a9807fb5d478213d23e393606b5", "score": "0.57659227", "text": "function init_cb(canvas_elem, success) {\n\n if (!success) {\n console.log(\"b4w init failure\");\n return;\n }\n\n load();\n}", "title": "" }, { "docid": "a301606f4a93c08a859090634b980328", "score": "0.57627785", "text": "function FaceBoxLoadComplete()\n{\n Show_FaceBox();\n CallBack_FaceBox();\n\n //ẩn div loading\n HideLoading();\n}", "title": "" }, { "docid": "0e09a52d2584cdb61f27508d05ad7f51", "score": "0.5760846", "text": "function qodeOnWindowLoad() {\n qodeInitElementorInfoCardWithIcon();\n }", "title": "" }, { "docid": "14caa99fbf35dda543bedceaf6ab0b3e", "score": "0.57603675", "text": "function mainComplete() {\n const loading = document.getElementById('loading');\n\n loading.style.opacity = 0;\n\n setTimeout(() => {\n loading.style.display = 'none';\n }, 1000);\n\n console.log(\"We're all loaded up!\");\n\n MyGame.menu.initialize();\n }", "title": "" }, { "docid": "dd6f6670904e8ea56875cf47f0097f11", "score": "0.5757435", "text": "function bitstorm_WinOnLoad()\n{\n window.removeEventListener('load', bitstorm_WinOnLoad);\n Bitstorm.emit('window:ready', Bitstorm);\n}", "title": "" }, { "docid": "5b6421e37591ed9f195cab4b16724b7a", "score": "0.5752027", "text": "function showloadDialog() {\n waittingDialog = $.ligerDialog.waitting(\"正在处理,请稍后...\");\n}", "title": "" }, { "docid": "4a8d0e53ace90ee7af071d9ccd93f7ed", "score": "0.57494354", "text": "function loadagain() {\n\tport.postMessage({\n\t tabId: browser.devtools.inspectedWindow.tabId,\n\t type: \"qm-div-load\"\n\t});\n }", "title": "" }, { "docid": "55734f0a062d1629424e25de31bacb9e", "score": "0.57449806", "text": "function loaded(){\n console.log(\"success\");\n header();\n display();\n}", "title": "" }, { "docid": "c8e5ce6138ee26a69222b053302554ad", "score": "0.5735201", "text": "onPageLoaded() {\n this.dispatchEvent(\n new CustomEvent('loaded', {bubbles: true, composed: true}));\n this.loading = false;\n this.$['next-button'].focus();\n if (!this.hidden && !this.screenShown_) {\n this.browserProxy_.screenShown(RELATED_INFO_SCREEN_ID);\n this.screenShown_ = true;\n }\n }", "title": "" }, { "docid": "0f7c2175e2db23628bff88176aee3f31", "score": "0.57282203", "text": "view_complete() {\n window.setTimeout(() => {\n hideSceneLoadingIndicator();\n }, 250);\n }", "title": "" }, { "docid": "b75d63942940678987260c3407f69a4e", "score": "0.57271796", "text": "function mkdfOnWindowLoad() {\n }", "title": "" }, { "docid": "70ae3b66a56d12807a746e8b0d8d7f1b", "score": "0.5722421", "text": "function whenUrlIsReady(cb) { //when external vars have loaded\n var waiting = setInterval(function() { //run every 1sec until we have loaded the page (dont hate me Sam)\n if (typeof urls != \"undefined\" & urls.Base != \"undefined\") {\n if (urls.Base !== null)\n {\n console.log(\"urls is ready\");\n clearInterval(waiting); //stop timer\n cb(); //call back\n }\n }\n}, 200);\n}", "title": "" }, { "docid": "7cb2ba37648d74fe86a0cac5e4057005", "score": "0.5718951", "text": "function loaded()\n\t\t{\n\t\t\tct++;\n\t\t\tif (settings.progressFunction !== null)\n\t\t\t{\n\t\t\t\tsettings.progressFunction(ct, loadCount);\n\t\t\t}\n\t\t\tif (ct >= loadCount)\n\t\t\t{\n\t\t\t\tconsole.log(\"done!\");\t\t\t\t\n\t\t\t\tneedToPresent = false;\n\t\t\t\t\n\t\t\t\tif (settings.onComplete === null)\n\t\t\t\t{\n\t\t\t\t\t// bring the loaded stuff & hide the loading class\n\t\t\t\t\twindow.setTimeout(function()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (settings.loadingClass !== '')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$(\".\" + settings.loadingClass).fadeOut(200, function(){$(\".\" + settings.loadedClass).fadeIn(200);});\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$(\".\" + settings.loadedClass).fadeIn(200);\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},300);\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tsettings.onComplete();\t\n\t\t\t\t}\n\t\t\t}\n\t\t}", "title": "" }, { "docid": "b4e63dd960c00361eeba41ecfac5e229", "score": "0.57186323", "text": "function load() {\n return new Promise(function(resolve) {\n window.onload = resolve; // promise resolves on load event\n });\n}", "title": "" }, { "docid": "685745ebe3bc68e05909513db56d227f", "score": "0.57052934", "text": "function gameLanguageViewLoaded()\n\t{\n\t\tpushScreenCallback();\n\t}", "title": "" }, { "docid": "ecadd1344168f672f3c416d0b494b703", "score": "0.5702552", "text": "function onLoadOnce(err, window) {\n if (onLoadCalled) return;\n onLoadCalled = true;\n if (onLoad) onLoad(err, window);\n }", "title": "" }, { "docid": "a00150be93d44275400ae9ccc7004f48", "score": "0.57019705", "text": "function waitForTabs() {\n chrome.windows.getAll({\"populate\": true}, function(windows) {\n var ready = true;\n for (var i in windows) {\n for (var j in windows[i].tabs) {\n if (windows[i].tabs[j].status != \"complete\") {\n ready = false;\n break;\n }\n }\n if (!ready)\n break;\n }\n if (ready)\n callback();\n else\n setTimeout(waitForTabs, 30);\n });\n }", "title": "" }, { "docid": "25815c98eb319257f3f22ca5ebd10597", "score": "0.5691055", "text": "function onHtmlLoaded(){\n \n //if nobody is logged stop script execution\n if(loggedUser.isLogged === false){\n return;\n }\n \n //atatch click event to cancel button on any window\n $(\".cancel-button\").on('click',closeWindow);\n \n //add top menu\n addTopMenu();\n \n //add command buttons\n addCommandButtons();\n \n //get user data from the server\n user.getUserData(user.loggedUserId).done(function(response){\n \n //check server response\n if(response.success === true){\n \n user = new User(response[0]);\n fillUserData(); //display user data\n \n }else{\n popUp(\"error\",response.message); //show error message\n }\n }); //get user data completed\n \n}//END onHtmlLoaded function", "title": "" }, { "docid": "f9cfd37246263ed8931e40cdeb73022c", "score": "0.56870764", "text": "function loadProjectorWindow()\n{\n if(myNewWindow == undefined || myNewWindow == null) {\n myNewWindow = initProjectorWindow();\n myNewWindow.onbeforeunload = function(){ myNewWindow = null; }\n myNewWindow.document.body.style.backgroundColor=\"black\";\n\n var csslink = document.createElement(\"link\");\n csslink.href = hostWithPort + \"/assets/vidwinstyles.css\";\n csslink.type = \"text/css\";\n csslink.rel = \"stylesheet\";\n\n var lyric_block_container = myNewWindow.document.createElement(\"div\");\n lyric_block_container.setAttribute(\"id\",\"proj_content_container\");\n\n var lyric_block = myNewWindow.document.createElement(\"div\");\n lyric_block.setAttribute(\"id\",\"proj_content_block\");\n lyric_block.innerHTML = currentSlide != undefined ? currentSlide : '' ;\n\n lyric_block_container.appendChild(lyric_block);\n\n var vidContainer = myNewWindow.document.createElement(\"div\");\n vidContainer.setAttribute(\"id\",\"vidContainer\");\n\n $(myNewWindow.document).ready(setTimeout(function() {\n myNewWindow.document.getElementsByTagName(\"head\")[0].appendChild(csslink);\n myNewWindow.document.body.appendChild(vidContainer);\n myNewWindow.document.body.appendChild(lyric_block_container);\n lyricElement = myNewWindow.document.getElementById(\"proj_content_block\");\n }, 1000) );\n }\n}", "title": "" }, { "docid": "c5eb85893d0d835cb3825296ad8cb501", "score": "0.56850743", "text": "function ContentLoaded(win, fn) {\n\n var done = false, top = true,\n init = function(e) {\n if (e.type == \"readystatechange\" && doc.readyState != \"complete\") return;\n (e.type == \"load\" ? win : doc).detachEvent(\"on\" + e.type, init, false);\n if (!done && (done = true)) fn.call(win, e.type || e);\n },\n poll = function() {\n try { root.doScroll(\"left\"); } catch(e) { setTimeout(poll, 50); return; }\n init('poll');\n };\n\n if (doc.readyState == \"complete\") fn.call(win, EMPTY_STRING);\n else {\n if (doc.createEventObject && root.doScroll) {\n try { top = !win.frameElement; } catch(e) { }\n if (top) poll();\n }\n addEvent(doc,\"readystatechange\", init);\n addEvent(win,\"load\", init);\n }\n }", "title": "" }, { "docid": "0560560d0e71fa39a95f1d81b07ebed4", "score": "0.5680254", "text": "dashboard_page_loaded() {\n Action.waitForJSReadystate();\n Action.setFrMainFrame(); // Sets frMain frame as the base frame\n \tif (this.athenaTextNotification.isVisible()) this.athenaTextNotificationClose.click();\n \tAction.waitForPageToLoad(this.devInfo, \"Dashboard - Non Clinician Page\");\n }", "title": "" }, { "docid": "e0297d6371909718f9cd9a34f1f70db2", "score": "0.5678981", "text": "initTabReady() {\n if (!this.tabReadyInitialized) {\n windowTracker.addListener(\"progress\", this);\n\n this.tabReadyInitialized = true;\n }\n }", "title": "" }, { "docid": "3a587f73dbcb1798a6971bfb5adf74fb", "score": "0.5677738", "text": "function setWindowLoaded() {\n _windowLoaded = true;\n global_window__WEBPACK_IMPORTED_MODULE_0___default.a.removeEventListener('load', setWindowLoaded);\n}", "title": "" }, { "docid": "3a587f73dbcb1798a6971bfb5adf74fb", "score": "0.5677738", "text": "function setWindowLoaded() {\n _windowLoaded = true;\n global_window__WEBPACK_IMPORTED_MODULE_0___default.a.removeEventListener('load', setWindowLoaded);\n}", "title": "" }, { "docid": "d989b05967b5110573f96649fc51a0bb", "score": "0.56747895", "text": "function init(){ //function window.onload as init\n\talert(\"done\")\n}", "title": "" }, { "docid": "8f3122815614538bb2f4ac31a0316885", "score": "0.56681293", "text": "function waitElementReady(element, callback) {\n var id;\n\n function tryOrNextFrame() {\n if (Object(rc_util_es_Dom_isVisible__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(element)) {\n callback();\n } else {\n id = Object(rc_util_es_raf__WEBPACK_IMPORTED_MODULE_2__[\"default\"])(function () {\n tryOrNextFrame();\n });\n }\n }\n\n tryOrNextFrame();\n return function () {\n rc_util_es_raf__WEBPACK_IMPORTED_MODULE_2__[\"default\"].cancel(id);\n };\n}", "title": "" }, { "docid": "a59c692d501bae59b14c12840d3cfe07", "score": "0.56673497", "text": "function waitForFinDesktop(readyCallback) {\n var callback = function (ready) {\n if (ready === true) {\n readyCallback();\n } else {\n client.pause(1000).then(function () {\n waitForFinDesktop(readyCallback);\n });\n }\n };\n checkFinGetVersion(callback);\n }", "title": "" }, { "docid": "e71bd221a23a9bb8351ae25e1613dba1", "score": "0.56546134", "text": "function eventWindowLoaded() {\n canvasApp();\n} // eventWindowLoaded()", "title": "" }, { "docid": "51df7840fd55db7156a8db4f1fc8e8e7", "score": "0.56527746", "text": "function handleComplete() {\r\n\ttoggleLoader(false);\r\n\tinitMain();\r\n}", "title": "" }, { "docid": "ba85df4d5f17586d468ff3d754ecd627", "score": "0.5650839", "text": "_onload(callback = _interface.noOp) {\n callback();\n if (this.autostart) this.start();\n }", "title": "" }, { "docid": "e5fdc500fe284add7dd5c3f3a05b160e", "score": "0.56504273", "text": "function mkdfOnWindowLoad() {\n\n }", "title": "" }, { "docid": "e5fdc500fe284add7dd5c3f3a05b160e", "score": "0.56504273", "text": "function mkdfOnWindowLoad() {\n\n }", "title": "" }, { "docid": "e5fdc500fe284add7dd5c3f3a05b160e", "score": "0.56504273", "text": "function mkdfOnWindowLoad() {\n\n }", "title": "" }, { "docid": "9d3012f265750d2bbb7a44586fbe0329", "score": "0.56502193", "text": "function callBack(url, idImgWait) {\n\n\tif (url == \"undefined\")\n\t\turl = \"about:blank\";\n\tif (idImgWait == 'undefinded') {\n\t\tthis.idImgWaitToShow = null;\n\t} else {\n\t\tthis.idImgWaitToShow = idImgWait;\n\t}\n\n\t// Mostra o Wait Load - SE HOUVER\n\tshowWaitCallback(true);\n\t// CHAMADA DO CALLBACK NO I-FRAME\n\twindow.document.getElementById('iframe_cb').src = url;\n\n}", "title": "" }, { "docid": "a1ca969d259c1b6c76e47a81bedcae4e", "score": "0.5646703", "text": "function checkDocumentLoaded(cb) {\n if (document.querySelector(\".client_channels_list_container\")) {\n cb();\n } else {\n setTimeout(() => checkDocumentLoaded(cb), 10);\n }\n }", "title": "" }, { "docid": "c0a21c99dc389670478d295423b54e47", "score": "0.56446254", "text": "function proceed() {\n if (scriptsAsync.length) {\n // Load asynchronous scripts\n head.js.apply(null, scriptsAsync);\n }\n\n start();\n }", "title": "" }, { "docid": "e33c94a8182a29b16d4f485ec4a7fc90", "score": "0.5642958", "text": "function onLoadComplete(){\n ready = true;\n \n}", "title": "" }, { "docid": "2d8e3563a4af3efef0775a729a388ec0", "score": "0.56401885", "text": "async function pageLoaded() {\n loadLoginData();\n prepareHandles();\n addEventListeners();\n}", "title": "" }, { "docid": "feeb32f10404f68a7276d2198f302032", "score": "0.56363106", "text": "function whenTeamsAreReady(cb) { //when external vars have loaded\n var waiting = setInterval(function() { //run every 1sec until we have loaded the page (dont hate me Sam)\n if (typeof masterViewModel != \"undefined\" & masterViewModel.teamsViewModel.teamsLoaded.peek() == true) {\n console.log(\"teams are ready\");\n clearInterval(waiting); //stop timer\n cb(); //call back\n }\n }, 200);\n}", "title": "" }, { "docid": "feeb32f10404f68a7276d2198f302032", "score": "0.56363106", "text": "function whenTeamsAreReady(cb) { //when external vars have loaded\n var waiting = setInterval(function() { //run every 1sec until we have loaded the page (dont hate me Sam)\n if (typeof masterViewModel != \"undefined\" & masterViewModel.teamsViewModel.teamsLoaded.peek() == true) {\n console.log(\"teams are ready\");\n clearInterval(waiting); //stop timer\n cb(); //call back\n }\n }, 200);\n}", "title": "" }, { "docid": "731deff50dde9784b25c98c33713cce9", "score": "0.56343615", "text": "function onSuccess() {\n if (!waitForLoad && response.isPending()) {\n goog.log.info(safaridriver.extension.commands.LOG_,\n 'Not expecting a new page load; returning');\n response.fulfill();\n }\n tab.on(safaridriver.message.Alert.TYPE, onAlert);\n }", "title": "" }, { "docid": "e038d8a6795999050660267f25e1a857", "score": "0.5623354", "text": "function waitElementReady(element, callback) {\n var id;\n\n function tryOrNextFrame() {\n if ((0,rc_util_es_Dom_isVisible__WEBPACK_IMPORTED_MODULE_3__.default)(element)) {\n callback();\n } else {\n id = (0,rc_util_es_raf__WEBPACK_IMPORTED_MODULE_2__.default)(function () {\n tryOrNextFrame();\n });\n }\n }\n\n tryOrNextFrame();\n return function () {\n rc_util_es_raf__WEBPACK_IMPORTED_MODULE_2__.default.cancel(id);\n };\n}", "title": "" } ]
96c0a0a1f6f69766ca394af97b049826
initApp handles setting up UI event listeners and registering Firebase auth listeners: firebase.auth().onAuthStateChanged: This listener is called when the user is signed in or out, and that is where we update the UI.
[ { "docid": "4ffc7d01bcf1c58d8267aa4f889ebafa", "score": "0.6629171", "text": "function initApp() {\n // Listening for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function(user) {\n if (user) {\n // User clicks the sign in button\n // [START_EXCLUDE]\n document.getElementById('sign-in-status').textContent = 'Connecting...';\n\n // [START node server connection test]\n function ifServerOnline(ifOnline, ifOffline) {\n let img = document.body.appendChild(document.createElement(\"img\"));\n img.onload = function() {\n ifOnline && ifOnline.constructor == Function && ifOnline();\n };\n img.onerror = function() {\n ifOffline && ifOffline.constructor == Function && ifOffline();\n };\n img.src = \"http://flip3.engr.oregonstate.edu:7994/favicon-1.ico\"; \n }\n \n // Connected to OSU node server and user signed in\n ifServerOnline(function() {\n // Create query string for GET request\n let currentUser = {uid: user.providerData[0].uid};\n currentUser = new URLSearchParams(currentUser).toString();\n\n // URL with query string\n let url = \"http://flip3.engr.oregonstate.edu:7994/?\" + currentUser;\n\n // Clear out user and sign-out before changing URL\n user = null;\n toggleSignIn();\n\n // Change URL to user backend node server\n window.location.href = url;\n // [END_EXCLUDE]\n },\n // Not connected to OSU node server\n function () {\n alert(\"You must sign in to the OSU vpn to continue\");\n document.getElementById('sign-in-status').textContent = 'Signed out';\n });\n } else {\n // User is signed out.\n // [START_EXCLUDE]\n document.getElementById('sign-in-status').textContent = 'Signed out';\n document.getElementById('sign-in').textContent = 'Sign in';\n // [END_EXCLUDE]\n }\n // [START_EXCLUDE silent]\n document.getElementById('sign-in').disabled = false;\n // [END_EXCLUDE]\n });\n // [END authstatelistener]\n document.getElementById('sign-in').addEventListener('click', toggleSignIn, false);\n document.getElementById('sign-up').addEventListener('click', handleSignUp, false);\n document.getElementById('password-reset').addEventListener('click', sendPasswordReset, false);\n}", "title": "" } ]
[ { "docid": "3237fa94836940ebf3c3d603ae8bd1de", "score": "0.8166016", "text": "function initApp() {\n\t// Listening for auth state changes.\n\t// [START authstatelistener]\n\tconsole.log(\"initApp\");\n\n\tfirebase.auth().onAuthStateChanged(function(user) {\n\t\tif (user) {\n\t\t\t// User is signed in.\n\t\t\tvar displayName = user.displayName;\n\t\t\tvar email = user.email;\n\t\t\tvar emailVerified = user.emailVerified;\n\t\t\tvar photoURL = user.photoURL;\n\t\t\tvar isAnonymous = user.isAnonymous;\n\t\t\tvar uid = user.uid;\n\t\t\tvar providerData = user.providerData;\n\n\t\t\tdocument.getElementById('sign-in-container').style.display = 'none';\n\t\t\tdocument.getElementById('signed-in-container').style.display = 'block';\n\t\t\tdocument.getElementById('user-details-container').style.display = 'block';\n\t\t\tdocument.getElementById('loading').style.display = 'none';\n\t\t\tdocument.getElementById('account-details').style.display = 'block';\n\n\t\t\tdocument.getElementById('current-user').textContent = email;\n\n\t\t\tgetData();\n\n\t\t\t\n\n\t\t} else {\n\t\t\t// User is signed out.\n\n\t\t\tdocument.getElementById('sign-in-container').style.display = 'block';\n\t\t\tdocument.getElementById('signed-in-container').style.display = 'none';\n\t\t\tdocument.getElementById('user-details-container').style.display = 'none';\n\t\t\tdocument.getElementById('loading').style.display = 'block';\n\t\t\tdocument.getElementById('account-details').style.display = 'none';\n\n\t\t\tremoveData();\n\n\t\t\t\n\t\t}\n\t});\n\t// [END authstatelistener]\n\n\tdocument.getElementById('sign-out').addEventListener('click', toggleSignIn, false);\n\tdocument.getElementById('save-data').addEventListener('click', saveData, false);\n\tdocument.getElementById('cancel').addEventListener('click', resetData, false);\n\n\tdocument.getElementById('sign-in').addEventListener('click', toggleSignIn, false);\n\tdocument.getElementById('password-reset1').addEventListener('click', sendPasswordReset, false);\n\tdocument.getElementById('password-reset2').addEventListener('click', sendPasswordReset, false);\n\t\n}", "title": "" }, { "docid": "e9612b80395d5e283ed5022035a731c8", "score": "0.8028267", "text": "function initApp() {\n //When the sign-up button is clicked an event listener is activated causing the handleSignUp function to be activated.\n document.getElementById('sign-up').addEventListener('click', handleSignUp, false);\n //The following checks if the user is already signed in\n firebase.auth().onAuthStateChanged(function(user) {\n if(user){ \n //If so the home.html is opened\n window.location='Home';\n }\n });\n }", "title": "" }, { "docid": "3437f1f1042eef7859f20dc2638a7b6f", "score": "0.7988067", "text": "function initApp() {\n firebase.auth().onAuthStateChanged(function(user) {\n document.getElementById('verify-email').disabled = true;\n if (user) {\n var displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var uid = user.uid;\n \n document.getElementById('sign-in').textContent = 'Sign out';\n document.getElementById('name-display').textContent = 'Name: ' + displayName;\n document.getElementById('name-display').style = 'display:block;margin-bottom:0';\n document.getElementById('email-display').textContent = 'Email: ' + email;\n document.getElementById('email-display').style = 'display:block;margin-top:0';\n if (!emailVerified) {\n document.getElementById('verify-email').disabled = false;\n }\n } else {\n document.getElementById('sign-in').textContent = 'Sign in';\n }\n document.getElementById('sign-in').disabled = false;\n });\n\n document.getElementById('sign-in').addEventListener('click', toggleSignIn, false);\n document.getElementById('verify-email').addEventListener('click', sendEmailVerification, false);\n document.getElementById('password-reset').addEventListener('click', sendPasswordReset, false);\n}", "title": "" }, { "docid": "16d3d736f1ff6cf952ff23f6584c538b", "score": "0.78505933", "text": "function initApp() {\n // Listen for auth state changes.\n firebase.auth().onAuthStateChanged(function(user) {\n console.log('User state change detected from the Background script of the Chrome Extension:', user);\n });\n}", "title": "" }, { "docid": "52131ab84b75cd564ee888e581307a8b", "score": "0.7843117", "text": "function initApp() {\n // Listening for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function (user) { \n if (user) {\n // User is signed in.\n document.getElementById('SignIn').textContent = 'Sign out';\n \n } else {\n // User is signed out.\n // [START_EXCLUDE]\n //document.getElementById('SignInStatus').textContent = 'Signed out';\n document.getElementById('SignIn').textContent = 'Sign in';\n //document.getElementById('AccDetails').textContent = 'null';\n // [END_EXCLUDE]\n }\n // [START_EXCLUDE silent]\n document.getElementById('SignIn').disabled = false;\n // [END_EXCLUDE]\n });\n // [END authstatelistener]\n\n document.getElementById('SignIn').addEventListener('click', toggleSignIn, false);\n document.getElementById('PasswordReset').addEventListener('click', sendPasswordReset, false);\n}", "title": "" }, { "docid": "c97c2533ca66fd243bd3e5f0acc05183", "score": "0.75295407", "text": "function initApp3() {\n firebase.auth().onAuthStateChanged(function(user) {\n\n if (user) {\n\n var displayName = user.displayName;\n var email = user.email;\n var photoURL = user.photoURL;\n var uid = user.uid;\n\n userUId = user.uid;\n userEmail = user.email;\n showMap(userUId);\n\n }else {\n location.href = \"index.html\";\n }\n });\n document.getElementById('quickstart-sign-out').addEventListener('click', toggleSignIn, false);\n}", "title": "" }, { "docid": "3a3c74a3dfeacd4112e904e489c052da", "score": "0.7469417", "text": "function initFirebaseAuth() {\n firebase.auth().onAuthStateChanged(authStateObserver);\n}", "title": "" }, { "docid": "b15b3458c0b101c1013bf8735de638c7", "score": "0.74054724", "text": "function initFirebaseAuth() {\n // Listen to auth state changes.\n firebase.auth().onAuthStateChanged(authStateObserver);\n}", "title": "" }, { "docid": "4030d93ac5da262a8d191a25966e28b4", "score": "0.7251623", "text": "function initApp() {\n // Listening for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function(user) {\n // [START_EXCLUDE silent]\n document.getElementById('quickstart-verify-email').disabled = true;\n // [END_EXCLUDE]\n if (user) {\n // User is signed in.\n var displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n // [START_EXCLUDE]\n document.getElementById('quickstart-sign-in-status').textContent = 'Signed in';\n document.getElementById('quickstart-sign-in').textContent = 'Sign out';\n document.getElementById('quickstart-account-details').textContent = JSON.stringify(user, null, ' ');\n if (!emailVerified) {\n document.getElementById('quickstart-verify-email').disabled = false;\n }\n // [END_EXCLUDE]\n } else {\n // User is signed out.\n // [START_EXCLUDE]\n document.getElementById('quickstart-sign-in-status').textContent = 'Signed out';\n document.getElementById('quickstart-sign-in').textContent = 'Sign in';\n document.getElementById('quickstart-account-details').textContent = 'null';\n // [END_EXCLUDE]\n }\n // [START_EXCLUDE silent]\n document.getElementById('quickstart-sign-in').disabled = false;\n // [END_EXCLUDE]\n });\n // [END authstatelistener]\n\n document.getElementById('quickstart-sign-in').addEventListener('click', toggleSignIn, false);\n document.getElementById('quickstart-sign-up').addEventListener('click', handleSignUp, false);\n document.getElementById('quickstart-verify-email').addEventListener('click', sendEmailVerification, false);\n document.getElementById('quickstart-password-reset').addEventListener('click', sendPasswordReset, false);\n document.getElementById('submit').addEventListener('click',create,false);\n document.getElementById('read').addEventListener('click',read,false);\n document.getElementById('delete').addEventListener('click',remove,false);\n document.getElementById('update').addEventListener('click',update,false);\n document.getElementById('save').addEventListener('click',save,false);\n document.getElementById('selectTag').addEventListener('click',selectTagName,false);\n var header=document.getElementById('header')\n var dbref = firebase.database().ref().child('header')\n dbref.on('value',snap => header.innerText=snap.val());\n}", "title": "" }, { "docid": "def1adda9ff73840be1b93ed0fe4d871", "score": "0.7235625", "text": "function initApp2() {\n firebase.auth().onAuthStateChanged(function(user) {\n if (user) {\n var displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n //document.getElementById('quickstart-sign-in').textContent = 'Sign out';\n\n console.log(displayName);\n console.log(email);\n console.log(emailVerified);\n console.log(photoURL);\n console.log(isAnonymous);\n console.log(uid);\n console.log(providerData);\n\n userUId = user.uid;\n userEmail = user.email;\n checkExistingUser();\n // addAccount();\n // checkUsernameSignIn();\n // location.href = \"index.html\";\n }else {\n //document.getElementById('quickstart-sign-in').textContent = 'Sign in';\n location.href = \"index.html\";\n };\n //document.getElementById('quickstart-sign-in').disabled = false;\n });\n document.getElementById('quickstart-sign-out').addEventListener('click', toggleSignIn, false);\n // document.getElementById('quickstart-sign-out').addEventListener('click', toggleSignIn, false);\n // document.getElementById('quickstart-sign-up').addEventListener('click', handleSignUp, false);\n}", "title": "" }, { "docid": "d1bdf55cbbe4577567d75dcda72346fc", "score": "0.7127147", "text": "function initApp() {\n console.log(\"initializing background\");\n // Listen for auth state changes.\n firebase.auth().onAuthStateChanged(function(authData) {\n console.log('User state change detected from the Background script of the Chrome Extension:', authData);\n user = authData;\n });\n chrome.browserAction.onClicked.addListener(function(tab) {\n if (!user) {\n startAuth();\n return;\n }\n pushNewThread({\n title: tab.title,\n url: tab.url\n })\n });\n}", "title": "" }, { "docid": "29c186e390c57b586975dc6db29ec94a", "score": "0.7107928", "text": "function initializeApp() {\n initializeFirebase();\n initializeFramework7();\n}", "title": "" }, { "docid": "fbe6b998d062c9c2e8e56d3c7c7d6137", "score": "0.7074017", "text": "function initApp() {\n // Listening for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function(user) {\n // [START_EXCLUDE silent]\n // [END_EXCLUDE]\n if (user) {\n var displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n // [START_EXCLUDE silent]\n \n var userId = firebase.auth().currentUser.uid;\n const dbRefObject=firebase.database().ref().child('users');\n const us=dbRefObject.child(userId);\n const nam=us.child('name');\n nam.on('value', snapshot => {\n console.log(snapshot.val());\n document.getElementById('nombre').textContent =snapshot.val();\n //document.getElementById('citass').textContent = JSON.stringify(snapshot.val(), null, ' ');\n });\n const cit=us.child('citas');\n \n cit.on('value', snapshot => {\n //console.log(snapshot.val());\n //document.getElementById('citass').textContent = JSON.stringify(snapshot.val(), null, ' ');\n\t\t datos=snapshot.val();\n calendariodeamor(datos);\n //console.log(datos);\n });\n //document.getElementById('citass').textContent = const;\n if (!emailVerified) {\n }\n // [END_EXCLUDE]\n } else {\n // User is signed out.\n // [START_EXCLUDE silent]\n // [END_EXCLUDE]\n }\n // [START_EXCLUDE silent]\n // [END_EXCLUDE]\n });\n // [END authstatelistener]\n\n }", "title": "" }, { "docid": "02d55b25458b66f445d392684815fd0d", "score": "0.70170367", "text": "function initApp() {\n firebase.auth().onAuthStateChanged(function(user) {\n if (user) {\n var displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n document.getElementById('quickstart-sign-in').textContent = 'Sign out';\n\n console.log(displayName);\n console.log(email);\n console.log(emailVerified);\n console.log(photoURL);\n console.log(isAnonymous);\n console.log(uid);\n console.log(providerData);\n\n location.href = \"search.html\";\n }else {\n document.getElementById('quickstart-sign-in').textContent = 'Sign in';\n console.log(\"signed out\");\n };\n //document.getElementById('quickstart-sign-in').disabled = false;\n });\n document.getElementById('quickstart-sign-in').addEventListener('click', toggleSignIn, false);\n document.getElementById('quickstart-sign-up').addEventListener('click', handleSignUp, false);\n}", "title": "" }, { "docid": "9d080d8a944312ba6ecc58909195d60f", "score": "0.69952804", "text": "function initializeApp() {\n displayIsInClientInfo();\n registerButtonHandlers();\n\n // check if the user is logged in/out, and disable inappropriate button\n if (liff.isLoggedIn()) {\n document.getElementById('liffLogoutButton').disabled = false;\n } else {\n document.getElementById('liffLogoutButton').disabled = true;\n }\n }", "title": "" }, { "docid": "93222617a76a05456edb4cfc371bcfec", "score": "0.69444805", "text": "function init() {\n if (!initialized) {\n firebase.initializeApp(CONFIG);\n initialized = true;\n }\n}", "title": "" }, { "docid": "794e0b5c0ccbaef482d47a070b9311b2", "score": "0.68597937", "text": "function initApp() {\n // Listening for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function (user) {\n // [START_EXCLUDE silent]\n //document.getElementById('quickstart-verify-email').disabled = true;\n // [END_EXCLUDE]\n if (user) {\n //User is signed in.\n var uid = user.uid;\n /**\n * 1. We want to get the type of admin and display accordingly.\n * 2. First, we initialize the Firebase Realtime Database.\n * 3. Next, we retrieve the value from the database.\n * 4. const type will get the value type.\n * 5. Once we get the type, we will check them by lists of type of admin.\n * 6. Type = {'Owner' , 'Customer', 'Packages', 'Live Chat', 'Transaction', 'Profit Report'};\n * 7. After that, we only display nav top bar according to the type of admin.\n */\n var database = firebase.database();\n database.ref('/admin/' + uid + '/').on('value', function (snapshot) {\n //Get the value of type and store in var type.\n const type = snapshot.val().type;\n\n //Checking the type\n if (type === \"Owner\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkAdmin').hidden = false;\n document.getElementById('navLinkCustomer').hidden = false;\n document.getElementById('navLinkPackages').hidden = false;\n document.getElementById('navLinkTransaction').hidden = false;\n document.getElementById('navLinkProfitReport').hidden = false;\n } else if (type === \"Customer\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkCustomer').hidden = false;\n } else if (type === \"Packages\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkPackages').hidden = false;\n } else if (type === \"Profit Report\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkProfitReport').hidden = false;\n } else if (type === \"Transaction\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkTransaction').hidden = false;\n }\n });\n } else {\n // User is signed out.\n // // [START_EXCLUDE]\n // document.getElementById('quickstart-sign-in-status').textContent = 'Signed out';\n // document.getElementById('quickstart-sign-in').textContent = 'Sign in';\n // document.getElementById('quickstart-account-details').textContent = 'null';\n // // [END_EXCLUDE]\n }\n });\n document.getElementById('navLinkSignOut').addEventListener('click', btnSignOutOnClick, false);\n}", "title": "" }, { "docid": "794e0b5c0ccbaef482d47a070b9311b2", "score": "0.68597937", "text": "function initApp() {\n // Listening for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function (user) {\n // [START_EXCLUDE silent]\n //document.getElementById('quickstart-verify-email').disabled = true;\n // [END_EXCLUDE]\n if (user) {\n //User is signed in.\n var uid = user.uid;\n /**\n * 1. We want to get the type of admin and display accordingly.\n * 2. First, we initialize the Firebase Realtime Database.\n * 3. Next, we retrieve the value from the database.\n * 4. const type will get the value type.\n * 5. Once we get the type, we will check them by lists of type of admin.\n * 6. Type = {'Owner' , 'Customer', 'Packages', 'Live Chat', 'Transaction', 'Profit Report'};\n * 7. After that, we only display nav top bar according to the type of admin.\n */\n var database = firebase.database();\n database.ref('/admin/' + uid + '/').on('value', function (snapshot) {\n //Get the value of type and store in var type.\n const type = snapshot.val().type;\n\n //Checking the type\n if (type === \"Owner\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkAdmin').hidden = false;\n document.getElementById('navLinkCustomer').hidden = false;\n document.getElementById('navLinkPackages').hidden = false;\n document.getElementById('navLinkTransaction').hidden = false;\n document.getElementById('navLinkProfitReport').hidden = false;\n } else if (type === \"Customer\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkCustomer').hidden = false;\n } else if (type === \"Packages\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkPackages').hidden = false;\n } else if (type === \"Profit Report\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkProfitReport').hidden = false;\n } else if (type === \"Transaction\") {\n document.getElementById('navLinkSignOut').hidden = false;\n document.getElementById('navLinkTransaction').hidden = false;\n }\n });\n } else {\n // User is signed out.\n // // [START_EXCLUDE]\n // document.getElementById('quickstart-sign-in-status').textContent = 'Signed out';\n // document.getElementById('quickstart-sign-in').textContent = 'Sign in';\n // document.getElementById('quickstart-account-details').textContent = 'null';\n // // [END_EXCLUDE]\n }\n });\n document.getElementById('navLinkSignOut').addEventListener('click', btnSignOutOnClick, false);\n}", "title": "" }, { "docid": "7505f103c7e05afed2e42e88bb591e82", "score": "0.6839046", "text": "init() {\r\n firebase.auth().onAuthStateChanged(brugere => {\r\n if (brugere) {\r\n this.userAuthenticated();\r\n } else {\r\n this.userNotAuthenticated();\r\n }\r\n });\r\n }", "title": "" }, { "docid": "a504e322a43ae1a82500fe748c907f33", "score": "0.6828149", "text": "function initApp() {\n // Result from Redirect auth flow.\n // [START getidptoken]\n firebase.auth().getRedirectResult().then(function(result) {\n if (result.credential) {\n // This gives you a Google Access Token. You can use it to access the Google API.\n var token = result.credential.accessToken;\n\n console.log('OAuth token: ' + token);\n } else {\n console.log('No OAuth token');;\n // [END_EXCLUDE]\n }\n // The signed-in user info.\n var user = result.user;\n }).catch(function(error) {\n // Handle Errors here.\n var errorCode = error.code;\n var errorMessage = error.message;\n // The email of the user's account used.\n var email = error.email;\n // The firebase.auth.AuthCredential type that was used.\n var credential = error.credential;\n if (errorCode === 'auth/account-exists-with-different-credential') {\n alert('You have already signed up with a different auth provider for that email.');\n // If you are using multiple auth providers on your app you should handle linking\n // the user's accounts here.\n } else {\n console.error(error);\n }\n });\n // [END getidptoken]\n // Listening for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function(user) {\n if (user) { // ******************* User is signed in.\n googleDisplayName = user.displayName,\n googleLogin = user.login, \n googleEmail = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n\n [].forEach.call(statuses, function(status) {\n status.textContent = 'Signed in';\n });\n\n\n [].forEach.call(signInOuts, function(signInOut) {\n signInOut.textContent = 'Sign out';\n });\n \n // Turn on the proper page\n if(googleEmail === '[email protected]') { // TEST WITH MY OWN GMAIL ACCOUNT (kbooth1000)\n activateHomePage();\n } else //if(googleEmail === '[email protected]') {\n { \n activateOnboardingPage();\n }\n } else { // ******************* User is signed out.\n [].forEach.call(statuses, function(status) {\n status.textContent = 'Signed out';\n });\n\n [].forEach.call(signInOuts, function(signInOut) {\n signInOut.textContent = 'Sign in with Google';\n });\n\n [].forEach.call(signInOuts, function(signInOut) {\n signInOut.disabled = false;\n });\n };\n // [END authstatelistener]\n [].forEach.call(signInOuts, function(signInOut) { // watches the signin/out button one each page\n signInOut.addEventListener('click', toggleSignIn, false);\n });\n document.getElementById('skip-setup').addEventListener('click', function(){ activateHomePage() ;console.log('Activate Home Page---------------'); });//\n\n document.getElementById(\"github-namefield\").addEventListener(\"keyup\", function(event) {\n event.preventDefault();\n if (event.keyCode === 13) {\n document.getElementById(\"github-namefield-submit\").click();\n }\n });\n document.getElementById('github-namefield-form').addEventListener('submit', function(event) {\n event.preventDefault();\n console.log('SUBMITTED');\n \n gitHubUserID = document.getElementById('github-namefield').value;\n console.log('gitHubUserID: ' + gitHubUserID);\n \n var request = new XMLHttpRequest();\n request.onload = accessGitHub;\n console.log('Github: https://api.github.com/users/'+gitHubUserID+'/repos');\n \n request.open('get', 'https://api.github.com/users/'+gitHubUserID+'/repos', true);\n request.onerror = function(){\n console.log('The given gitHubUserID ('+gitHubUserID+') is not valid.');\n }\n request.send(); });\n });\n}", "title": "" }, { "docid": "8451a937889a96d234fcd172ea0f72b7", "score": "0.68253934", "text": "function initApp() {\n // Listening for auth state changes.\n // [START authstatelistener]\n auth.onAuthStateChanged(function(user) {\n \n if (user) {\n // User is signed in.\n\n $('#logoutButton').prop(\"disabled\",false);\n //event listener on basket\n eventBasket(db.ref('Clients/' + remChara(user.email)));\n \n /*if (!emailVerified) {\n //document.getElementById('quickstart-verify-email').disabled = false;\n }*/\n\n } else {\n // User is signed out.\n $('#logoutButton').prop(\"disabled\",true);\n //clear the basket \n $('.modal-body').html(`\n <article class =\"ArticleTitre\">\n <div class = \"row\">\n <div class=\"col-sm-3 text-center\">Article name</div>\n <div class=\"col-sm-3 text-center\">Quantity</div> \n <div class=\"col-sm-3 text-center\">Add</div>\n <div class=\"col-sm-3 text-center\">Delete</div>\n </div>\n </article>`);\n \n }\n });\n }", "title": "" }, { "docid": "debc8ceb8c775ccb55ed44473ed87334", "score": "0.68036884", "text": "init(){\n // verify if there no have other app on firebase initialized\n // change from !this._initialized to !window.initializedFirebase, use Global\n if(!window._initializedFirebase){\n firebase.initializeApp(this._config);\n // ativa snapshot pra ficar constantemente de olho\n firebase.firestore().settings({\n timestampsInSnapshots:true\n });\n window.initializedFirebase = true;\n }\n }", "title": "" }, { "docid": "30ae08035df0b7c1c7db826229fc8d19", "score": "0.67472714", "text": "function init(config){\n \n this.config = config;\n this.onLogin = config.onLogin;\n this.onLogout = config.onLogout;\n\n this.connection = firebase.initializeApp(config);\n firebase.auth().onAuthStateChanged(updateAuthState, onError);\n }", "title": "" }, { "docid": "52a62be6e698feaf96d5aadc8ed58571", "score": "0.6658733", "text": "function initApp(){\n firebase.auth().onAuthStateChanged(function(user){\n \n if(user){\n var displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n \n /**\n * [if Check email verified or not.] \n * @param {[Boolean]} emailVerified [Status of email verified ] \n */\n if(emailVerified){\n window.location.href = \"index.html\";\n }\n \n //console.log(emailVerified);\n\n }\n });\n \n}", "title": "" }, { "docid": "836ec8f3900af2915729e90ecaecadf7", "score": "0.66582876", "text": "function initLoginUI() {\n var uiConfig = {\n signInSuccessUrl: '/',\n signInOptions: [_modules_firebase__WEBPACK_IMPORTED_MODULE_0__[\"firebase\"].auth.GoogleAuthProvider.PROVIDER_ID]\n };\n var ui = new firebaseui.auth.AuthUI(_modules_firebase__WEBPACK_IMPORTED_MODULE_0__[\"auth\"]);\n ui.start('#firebaseui-auth-container', uiConfig);\n}", "title": "" }, { "docid": "20b37f945402ea9466b3ae47ac7c0da3", "score": "0.65818524", "text": "function initFireBase() {\n \n\n firebase.auth().onAuthStateChanged((user) => {\n if (user) {\n displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n\n console.log(\"user \", displayName, email, uid);\n // $(\"#nav nav .linkWrap #logBtnChange\").html(`<a class=\"logInBtn\" href=\"#\" id=\"logOut\">Log out</a>`);\n $(\"#nav nav .linkWrap\").html(`<a id=\"home\" href=\"#\">Home</a>\n <a id=\"browse\" href=\"#\">Browse</a>\n <a id=\"create\" href=\"#\">Create Recipe</a>\n <a id=\"recipe\" href=\"#\">Your Recipes</a>\n <div id=\"logBtnChange\" class=\"logBtnDiv\">\n <a class=\"logInBtn\" href=\"#\" id=\"logOut\">Log Out</a>\n </div>`);\n _db = firebase.firestore();\n } else {\n console.log(\"No user\");\n $(\"#nav nav .linkWrap\").html(`<a id=\"home\" href=\"#\">Home</a>\n <a id=\"browse\" href=\"#\">Browse</a>\n <a id=\"login\" href=\"#\">Create Recipe</a>\n <div id=\"logBtnChange\" class=\"logBtnDiv\">\n <a class=\"logInBtn\" href=\"#\" id=\"login\">Log In</a>\n </div>`);\n }\n });\n }", "title": "" }, { "docid": "634d4a11cd0ffb1bd6740772698f3eb7", "score": "0.65338236", "text": "function initializeAuthorization() {\n firebase.auth().onAuthStateChanged(function (user) {\n //exclude silent\n document.getElementById('verify-email').disabled = true;\n if (user) {\n // User is signed in.\n userEmail = user.email;\n userID = user.uid;\n userEmailVerified = user.emailVerified;\n userSignedIn = true;\n displayApplicationOrAuthentication();\n console.log(userID + \" is signed in\");\n document.getElementById('sign-in').textContent = 'Sign out';\n if (!userEmailVerified) {\n document.getElementById('verify-email').disabled = false;\n }\n firebase.database().ref('users/' + userID).set({\n email: userEmail,\n signedIn: true\n });\n } else {\n // User is signed out.\n userSignedIn = false;\n console.log(userID + \" is signed out\");\n displayApplicationOrAuthentication();\n document.getElementById('sign-in').textContent = 'Sign in';\n }\n document.getElementById('sign-in').disabled = false;\n });\n $(document.body).on(\"click\", \"#sign-in\", function () {\n toggleSignIn();\n });\n $(document.body).on(\"click\", \"#sign-up\", function () {\n handleSignUp();\n });\n $(document.body).on(\"click\", \"#verify-email\", function () {\n sendEmailVerification();\n });\n $(document.body).on(\"click\", \"#password-reset\", function () {\n sendPasswordReset();\n });\n }", "title": "" }, { "docid": "372dda0c92daeed1b5c13946f8219788", "score": "0.6475101", "text": "function firebaseInit() {\n if (!firebase.apps.length) {\n firebase.initializeApp(config);\n }\n}", "title": "" }, { "docid": "d0fdf98535aac91f6c5a08b3a34e492a", "score": "0.6469316", "text": "function initializeApp() {\n // Setup application before DOM loads\n $.ajaxSetup({\n cache: false\n });\n\n Router.initializeWithPushState();\n\n initializeControllers();\n\n // Run DOM dependent logic - Models and Views initialization\n $(document).ready(function () {\n var docView,\n sessionModel,\n pageStateModel;\n\n sessionModel = SessionModel.retrieve();\n pageStateModel = PageStateModel.retrieve();\n \n docView = Doc.construct(\n sessionModel,\n pageStateModel);\n\n // initialize pushState in the DOM\n docView.initializePushStateDOM();\n\n initializeNewUser();\n });\n}", "title": "" }, { "docid": "e85d22ef0e997e710d9e1d1035f36fb7", "score": "0.64474064", "text": "function appInit() {\n mobileNav();\n colorSelector();\n initialRender();\n eventBindings();\n\t}", "title": "" }, { "docid": "1d91a1262606f52d2dd3317508283f7b", "score": "0.64434874", "text": "componentDidMount() {\n\t\tfirebase.initializeApp(this.#firebaseConfig);\n\t\tfirebase.auth().languageCode = 'en';\n\t\tfirebase.auth().onAuthStateChanged(this.handleAuthStateChange);\n\t}", "title": "" }, { "docid": "9f6fd0ab1fe455e6263b73a1fe62bebb", "score": "0.63829947", "text": "function initApp() {\n\tauthCode = null;\n\tchildWindow = null;\n\n\t// setup our Facebook credentials, and callback URL to monitor\n\ttwitterOptions = {\n\t\tconsumerKey: '*',\n\t\tconsumerSecret: '*',\n\t\tcallbackUrl: '*'\n\t};\n\ttwitterOAuth = OAuth(twitterOptions);\n\n\t// (bbUI) push the start.html page\n\tbb.pushScreen('start.html', 'start');\n}", "title": "" }, { "docid": "744415b1c21bbdd57e72a8ec47a131ce", "score": "0.6351433", "text": "function initFirebase() {\n\t// Initialize firebase connection config and start\n\tvar config = {\n\t\tapiKey: \"AIzaSyCGtNp8KH9l9ZAQvYOJ8lNG1sbbzXbfJuk\",\n\t\tauthDomain: \"triibe-user-app.firebaseapp.com\",\n\t\tdatabaseURL: \"https://triibe-user-app.firebaseio.com\",\n\t\tstorageBucket: \"triibe-user-app.appspot.com\",\n\t\tmessagingSenderId: \"139425671337\"\n\t};\n\tfirebase.initializeApp(config);\n}", "title": "" }, { "docid": "e70ec2b3603622d565e1b4995552ebed", "score": "0.6303043", "text": "function initApp(apiUrl) {\n // first remove all of the contents in the root\n const root = document.getElementById('root');\n while (root.firstChild) {\n root.removeChild(root.firstChild);\n }\n\n // add contents to the root\n navBar();\n mainPage();\n createLoginMod();\n createSigninMod();\n //console.log(apiUrl);\n // log in listeners\n document.getElementById('login-button').addEventListener('click', showLogin);\n document.getElementById('cancel-login').addEventListener('click', closeLogin);\n document.getElementById('close-login').addEventListener('click', closeLogin);\n document.getElementById('login-form').addEventListener('submit', (event) => {\n event.preventDefault();\n checkLogin(apiUrl);\n });\n\n // sign up listeners\n document.getElementById('signup-button').addEventListener('click', showSignup);\n document.getElementById('cancel-signup').addEventListener('click', closeSignup);\n document.getElementById('close-signup').addEventListener('click', closeSignup);\n document.getElementById('signup-form').addEventListener('submit', (event) => {\n event.preventDefault();\n checkSignup(apiUrl);\n });\n \n}", "title": "" }, { "docid": "00dc58b6bff1cf84c7ccfb9b2adfddaa", "score": "0.62939847", "text": "function init() {\n controller.core(\"authClicked\").subscribe(toggleAuth);\n }", "title": "" }, { "docid": "c48d7218ac432af55177d638f6b95612", "score": "0.62921685", "text": "function start() {\n firebase.auth().onAuthStateChanged(function (user) {\n if (user) {\n console.log(\"User is signed in, loading Home Page\");\n createPage();\n } else {\n console.log(\"No user signed in, loading login page\");\n document.location.href = \"index.html\"\n }\n })\n}", "title": "" }, { "docid": "b3c42f14f7fc2456c64895ecaf7f8b0c", "score": "0.6287345", "text": "function initApp() {\n // Listen for auth state changes.\n // [START authstatelistener]\n firebase.auth().onAuthStateChanged(function (user) {\n if (user) {\n // User is signed in.\n var displayName = user.displayName;\n uid = user.uid;\n // [START_EXCLUDE]\n document.getElementById(\"quickstart-button\").textContent = \"Sign out\";\n document.getElementById(\"quickstart-sign-in-status\").textContent =\n \"Signed in\";\n document.getElementById(\n \"quickstart-account-Name\"\n ).textContent = JSON.stringify(displayName, null, \" \");\n document.getElementById(\"new-job-form\").hidden = false;\n document.getElementById(\"submit-job-button\").addEventListener(\n \"click\",\n () => {\n const company = document.getElementById(\"company-name-field\").value;\n const jobTitle = document.getElementById(\"job-title-field\").value;\n const status = document.getElementById(\"job-status-field\").value;\n if(company && jobTitle){\n const newJob = { company, jobTitle, status };\n chrome.runtime.sendMessage({ command: \"post\", newJob });\n document.getElementById(\"company-name-field\").value = \"\"\n document.getElementById(\"job-title-field\").value = \"\"\n document.getElementById(\"job-status-field\").value = \"\"\n } else {\n alert(\"please fill out all fields\")\n }\n },\n false\n );\n // [END_EXCLUDE]\n } else {\n // Let's try to get a Google auth token programmatically.\n // [START_EXCLUDE]\n document.getElementById(\"quickstart-button\").textContent =\n \"Sign-in with Google\";\n document.getElementById(\"quickstart-sign-in-status\").textContent =\n \"Signed out\";\n document.getElementById(\"quickstart-account-Name\").textContent = \"null\";\n document.getElementById(\"quickstart-account-ID\").textContent = \"null\";\n document.getElementById(\"new-job-form\").hidden = true;\n\n // [END_EXCLUDE]\n }\n document.getElementById(\"quickstart-button\").disabled = false;\n });\n // [END authstatelistener]\n\n document\n .getElementById(\"quickstart-button\")\n .addEventListener(\"click\", startSignIn, false);\n}", "title": "" }, { "docid": "63ef9c191c417f3494e0ac3b33301c9e", "score": "0.6269243", "text": "function initApp() {\n console.log(\"Result from Redirect auth flow.\");\n console.log(\"[START getidptoken]\");\n firebase.auth().getRedirectResult().then(function(result) {\n if (result.credential) {\n console.log(\"This gives you a Google Access Token. You can use it to access the Google API.\");\n var token = result.credential.accessToken;\n console.log(\"[START_EXCLUDE]\");\n vm.token = token;\n console.log(\"[START_SETCREDENTIALS]\");\n AuthenticationService.SetCredentials(\"google\", result.user.email, token);\n console.log(\"[END_SETCREDENTIALS]\");\n console.log(\"[START_RELOAD]\");\n $location.path('/');\n console.log(\"[END_RELOAD]\");\n } else {\n \tvm.token = 'null';\n console.log(\"[END_EXCLUDE]\");\n }\n console.log(\"The signed-in user info.\");\n vm.user = result.user;\n }).catch(function(error) {\n console.log(\"Handle Errors here.\");\n var errorCode = error.code;\n var errorMessage = error.message;\n console.log(\"The email of the user's account used.\");\n var email = error.email;\n console.log(\"The firebase.auth.AuthCredential type that was used.\");\n var credential = error.credential;\n console.log(\"[START_EXCLUDE]\");\n if (errorCode === 'auth/account-exists-with-different-credential') {\n alert('You have already signed up with a different auth provider for that email.');\n console.log(\"If you are using multiple auth providers on your app you should handle linking\");\n console.log(\"the user's accounts here.\");\n } else {\n console.error(error);\n }\n console.log(\"[END_EXCLUDE]\");\n });\n console.log(\"[END getidptoken]\");\n console.log(\"Listening for auth state changes.\");\n console.log(\"[START authstatelistener]\");\n firebase.auth().onAuthStateChanged(function(user) {\n if (user) {\n \tconsole.log(\"[START_SETCREDENTIALS]\");\n AuthenticationService.SetCredentials(\"google\", user.email, vm.token);\n console.log(\"[END_SETCREDENTIALS]\");\n console.log(\"[START_RELOAD]\");\n $location.path('/');\n console.log(\"[END_RELOAD]\");\n } else {\n vm.dataLoading = false;\n }\n });\n }", "title": "" }, { "docid": "bd899a5ed4357ed43b7a02686d8d8dd5", "score": "0.625341", "text": "authListener() {\n\t\tfirebase.auth().onAuthStateChanged((user) => {\n\t\t\tif(user){\n\t\t\t\tif(user.emailVerified){\n\t\t\t\t\tthis.user = firebase.auth().currentUser;\n\t\t\t\t\tUserDB.createDBForNewUser(this.user);\n\t\t\t\t\t//check if user has database otherwice create a start up DB\n\t\t\t\t\t// use userDB.createDBForNewUsers(firebase.auth().currentUser.uid);\n\t\t\t\t\t//or observer from DB looking at this (look at other examples)\n\t\t\t\t\tthis.notifyObservers();\n\t\t\t\t}else{\n\t\t\t\t\talert(\"Please verify your email\");\n\t\t\t\t\tuser.sendEmailVerification();\n\t\t\t\t\tfirebase.auth().signOut();\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tthis.notifyObservers();\n\t\t\t}\t\t\t\t\t\t\t\t\t\n\t\t});\n\t}", "title": "" }, { "docid": "de6f2e330bcde7f6d6b2768f6e3f4d55", "score": "0.6249069", "text": "function init() {\n\tauthStatusListener();\n}", "title": "" }, { "docid": "9cb9fb7f7b2f74986396f7f55fe61a36", "score": "0.6158763", "text": "componentWillMount() {\nfirebase.initializeApp({\n apiKey: \"AIzaSyD2hoV-qiSSRRCHooI8CCD67dNxyz2TCkM\",\n authDomain: \"fir-loginapp-ef7ed.firebaseapp.com\",\n databaseURL: \"https://fir-loginapp-ef7ed.firebaseio.com\",\n projectId: \"fir-loginapp-ef7ed\",\n storageBucket: \"fir-loginapp-ef7ed.appspot.com\",\n messagingSenderId: \"416958996610\",\n appId: \"1:416958996610:web:da2abe52c22a9960\"\n});\n\n//Handle the Application when it's logged in or logged out\nfirebase.auth().onAuthStateChanged(user => {\nif (user) {\nthis.setState({ loggedIn: true });\n} else {\nthis.setState({ loggedIn: false });\n}\n});\n}", "title": "" }, { "docid": "ab1c88e6d7c865630aa71b6a6f96b108", "score": "0.6149915", "text": "function init(){\n\n // Disable Touch Scrolling\n document.addEventListener('touchmove', function(e){\n\n var swipe_target = e.target;\n\n while(swipe_target !== document.body){\n \n swipe_target = swipe_target.parentNode;\n }\n\n e.preventDefault();\n });\n\n // Load Starting Pages\n resetActiveScreens();\n \n // Set Screen Heights\n setFullscreenHeight();\n\n // Prepare for Window Size Changes\n setResizeResponses();\n setResizeListener();\n\n // Prepare for Network Changes\n setNetworkChangeResponses();\n setNetworkListeners();\n\n // Set Appcache Listeners\n setAppcacheListeners();\n\n // Create Network Transaction Offline Storage Area\n createDeviceStorage();\n\n // Set Current Network State\n if( networkState() === \"up\"){ \n\n _publish(\"network-up\", null, 'app-init');\n }\n\n else { \n\n _publish(\"network-down\", null, 'app-init'); \n }\n\n // Prepare Screen Setup Listeners\n screenSetupHandlers();\n\n // Setup Google Analytics\n configureGoogleAnalytics();\n\n // Activate the Requested Screen\n gotoScreen( activeScreenIndex );\n }", "title": "" }, { "docid": "b7eeb77e3ff413c37deb2d0fafa56120", "score": "0.6120868", "text": "function initApp() {\n\t// Listen for window resize events\n\twindow.addEventListener('resize', resize)\n\twindow.addEventListener('keydown', handleKeyDown)\n\twindow.addEventListener('keyup', handleKeyUp)\n\tresize()\n}", "title": "" }, { "docid": "4dba9426b7d87d7f0ed6813b08a9cc30", "score": "0.610644", "text": "function initiateApp(){\n\tuserEmail = getCookie(\"userEmail\");\n\tif(userEmail){\n\t\tconsole.log('You are logged in!');\n\t\tloadUserObjectAndSetUp();\n\t}else{\n\t\tconsole.log('NOT logged in.');\n\t\t$(\"#pre-login\").show();\n\t\t\n\t\t//If the user is logged out and soundPreference is on, play introMusic\n\t\tif(getCookie(\"soundPreference\") == \"on\"){\n\t\t\tconsole.log('YES');\n\t\t\tsoundIsOn = true;\n\t\t\tsound(\"introMusic\");\n\t\t}\n\t\t\n\t}\n\t//Check in on the soundPreference cookie\n\tif(getCookie(\"soundPreference\") == \"on\"){\n\t\tsoundIsOn = true;\n\t\t$(\"#speakerIcon\")[0].src = \"images/speakerIcon-on.png\";\n\t\t$(\"#homePageSpeakerIcon\")[0].src = \"images/speakerIcon-on-white.png\";\n\t}\n}", "title": "" }, { "docid": "60f8af58904b349c1d2ab00fd4548cbd", "score": "0.6103179", "text": "setAuthStateListener(listener) {\n firebase.auth().onAuthStateChanged(listener);\n }", "title": "" }, { "docid": "838fd8a7ed6ecc00569e5a6ce139715d", "score": "0.6098348", "text": "function onInit() {\r\n _getlastLoggedInUser();\r\n _registerModals();\r\n $scope.selectOrg = onSelectOrg;\r\n $rootScope.resources = {};\r\n $scope.loginData = {};\r\n $scope.loggedOut = false;\r\n $scope.initialLogin = \"\";\r\n $scope.subSequentLogin = \"\";\r\n $scope.emailAddress = \"\";\r\n\r\n $scope.doLogin = onDoLogin;\r\n $scope.logout = onSelectOrgViewCanceled;\r\n\r\n $scope.$on('$destroy', onDestroy);\r\n $rootScope.$on('logout', onLogout);\r\n }", "title": "" }, { "docid": "73a2452e0da8aaf578a93f662c42834b", "score": "0.60956615", "text": "function onInit() {\r\n if (!$rootScope.user) {\r\n $state.transitionTo('login');\r\n return;\r\n }\r\n\r\n _registerModals();\r\n /**\r\n * Event Handlers and Functions attached to $scope to be used in View\r\n */\r\n $scope.$on('$destroy', onDestroy);\r\n cleanUserIdleHandler = $rootScope.$on('UserIdle', onUserIdle);\r\n $scope.autoLogoutClose = onAutoLogoutClose;\r\n\r\n $scope.next = onNext;\r\n $scope.previous = onPrevious;\r\n $scope.startApp = onStartApp;\r\n $scope.leftButtonClick = onLeftButtonClick;\r\n $scope.rightButtonClick = onRightButtonClick;\r\n $scope.slideIndex = 0;\r\n $scope.$watch(\"slideIndex\", onSlideIndexChanged);\r\n $scope.logout = onLogout;\r\n $ionicSlideBoxDelegate.slide(0, 1);\r\n // //Note: Do not change this instance to SecuredPopups. \r\n // //It requires to be ionicPopup as it needs to be closed in code\r\n // confirmSkip = $ionicPopup.confirm({\r\n // title: 'Message',\r\n // template: $rootScope.Messages.INTRO_SCREEN_INFO_MESSAGE,\r\n // cancelText: 'Skip',\r\n // okText: 'View'\r\n // });\r\n\r\n // confirmSkip.then(function(result) {\r\n // if (!result) {\r\n // $state.go('app.quickAction');\r\n // }\r\n // confirmSkip = null;\r\n // });\r\n }", "title": "" }, { "docid": "97aea109ed277555223f99332cfe1409", "score": "0.6080681", "text": "INIT_APP(state) {\n firebase.auth().onAuthStateChanged(user => {\n var onUpdateUserUID;\n if (user) {\n state.singin = true;\n\n console.log(firebase.auth().currentUser);\n console.info('Bae đã đăng nhập ^^!');\n //UID and Eamil, login \n state.user.uid = user.uid;\n state.user.email = user.email;\n\n console.log(\"State uid của bae là : \" + state.user.uid);\n\n //Init once\n var UserUID = userRef.child(user.uid);\n UserUID.update({ login: true });\n UserUID.once(\"value\", snapshot => {\n let data = snapshot.val();\n console.log('once Update!');\n data.level === undefined && UserUID.update({ level: 0 });\n });\n\n //Set snapshot data --> store state! \n //Check when value change listener!\n onUpdateUserUID = UserUID.on(\"value\", snapshot => {\n console.log('on Update!');\n console.log(snapshot.val());\n var data = snapshot.val();\n state.user.level = data.level;\n state.user.login = data.login;\n }, (error) => {\n f7.alert('Đã có lỗi khi tải dữ liệu! Kiểm tra kết nối mạng của bạn!');\n console.info(\"Error: \" + error.code);\n });\n } else {\n if (state.singin) {\n userRef.child(state.user.uid).update({ login: false });\n console.info('Đã đăng xuất, tạm biệt bae >.<!');\n }\n console.info('Bae chưa đăng nhập, đăng nhập để đến với em đi nào bea ^^!');\n //Cance listener value change !\n state.singin && userRef.child(state.user.uid).off('value', onUpdateUserUID);\n //Reset\n state.input.password = '';\n state.user.email = '';\n state.user.level = 'Đang tải...';\n state.singin = false;\n\n }\n\n });\n }", "title": "" }, { "docid": "35c760a4c370bf5ab2b713d6f75a8410", "score": "0.607787", "text": "function onAuthStateChanged(result) {\n setUser(result)\n if (initializing) setInitializing(false)\n }", "title": "" }, { "docid": "35c760a4c370bf5ab2b713d6f75a8410", "score": "0.607787", "text": "function onAuthStateChanged(result) {\n setUser(result)\n if (initializing) setInitializing(false)\n }", "title": "" }, { "docid": "6af0cc6f982a56555cffaec8d30ee9de", "score": "0.6061414", "text": "function oninitialized() {\n\t // focus once ready\n\t this.once(this.options.mode + ' ready', bind(this.focusInput, this));\n\t\n\t // resolve view\n\t if ('signin' === this.options.mode) {\n\t // if user in AD ip range\n\t if (this.$ssoData && this.$ssoData.connection) {\n\t return this._kerberosPanel(this.options, callback);\n\t }\n\t\n\t // if user logged in show logged in experience\n\t if (this.options._shouldShowLastLogin()) {\n\t return this._loggedinPanel(this.options, callback);\n\t }\n\t\n\t // otherwise, just show signin\n\t this._signinPanel();\n\t }\n\t\n\t if ('signup' === this.options.mode) {\n\t this._signupPanel();\n\t }\n\t\n\t if ('reset' === this.options.mode) {\n\t this._resetPanel(this.options, callback);\n\t }\n\t\n\t }", "title": "" }, { "docid": "437e44b081c17b04d26476e48ae65e19", "score": "0.6060867", "text": "connectedCallback() {\n super.connectedCallback();\n const auth = this.shadowRoot.querySelector(\"firebase-auth\");\n auth.addEventListener(\"user-changed\", e => this.__initClaims(e));\n }", "title": "" }, { "docid": "4dc16846f1a24503b76b9d4aa9c38f43", "score": "0.6057259", "text": "function init() {\n var firebaseConfig = {\n apiKey: \"AIzaSyC0-0VEr_p7XxTE9u5nJtdUJ75fkWA5L6Q\",\n authDomain: \"onlinejudgeanalyzer.firebaseapp.com\",\n projectId: \"onlinejudgeanalyzer\",\n storageBucket: \"onlinejudgeanalyzer.appspot.com\",\n messagingSenderId: \"202774544058\",\n appId: \"1:202774544058:web:a43e02287ac1986be08c83\",\n measurementId: \"G-KMG62JHYHR\"\n };\n // Initialize Firebase\n firebase.initializeApp(firebaseConfig);\n firebase.analytics();\n //alert(\"done\");\n }", "title": "" }, { "docid": "457c52427935c6c73dc20cd79994ce29", "score": "0.6045182", "text": "function fbInit() {\n FB.getLoginStatus(fbStatusChangedHandler);\n FB.Event.subscribe('auth.authResponseChange', fbStatusChangedHandler);\n }", "title": "" }, { "docid": "0890741fc0858de8e31ead7a873d1efc", "score": "0.6042634", "text": "function initApp() {\r\n\r\n}", "title": "" }, { "docid": "9dd67060e9ede480f2aba30fe6b4afde", "score": "0.60361236", "text": "onAuthStateChanged(callback) {\n firebase.auth().onAuthStateChanged(callback);\n }", "title": "" }, { "docid": "76ecbe671811e48f50eebb37814ff1b8", "score": "0.60262495", "text": "function onAuthStateChanged(user) {\n // We ignore token refresh events.\n if (user && currentUID === user.uid) {\r\n return;\r\n }\n\n cleanupUi();\n if (user) {\r\n currentUID = user.uid;\n splashPage.style.display = 'none';\n writeUserData(user.uid, user.displayName, user.email, user.photoURL);\n startDatabaseQueries();\r\n startDatabaseQueriesArticle();\r\n startDatabaseQueriesQuestion();\r\n\r\n } else {\n // Set currentUID to null.\n currentUID = null;\n // Display the splash page where you can sign-in.\n splashPage.style.display = '';\r\n }\r\n}", "title": "" }, { "docid": "d977544fd28bfe659ee8140ac38edfdd", "score": "0.60259783", "text": "function initializeApp() {\n displayLiffData();\n displayIsInClientInfo();\n registerButtonHandlers();\n\n}", "title": "" }, { "docid": "2112f81f39552bb3dd0ab2fb6ed5b358", "score": "0.6015233", "text": "function onAuthStateChanged(result) {\n setUser(result)\n if (initializing) setInitializing(false)\n }", "title": "" }, { "docid": "41e689c19e51db2b04708fa5f0901720", "score": "0.60095704", "text": "function initApp() {\n\n // Sets up OpenLayers map.\n buildMap();\n\n // Sets up discover table.\n $(document).ready(function(){\n buildDiscoverTable();\n });\n\n // Sets up layer table.\n $(document).ready(function(){\n buildWorkspaceTable();\n $('.workspace-loading-container').hide();\n if ($('#resource_id').text() !== 'None') {\n $('.workspace-loading-container').show();\n loadHydroShareData($('#resource_id').text());\n };\n });\n\n // Sets initial nav tab.\n if ($('#resource_id').text() !== 'None' || $('#aggregation_id').text() !== 'None') {\n toggleNavTabs('workspace');\n } else {\n toggleNavTabs('discover');\n };\n toggleNavigation();\n }", "title": "" }, { "docid": "0c3cec9151a1bb65f0d9198ab606e1ab", "score": "0.59982455", "text": "function onAuthStateChanged(user) {\n setUser(user);\n if (initializing) setInitializing(false);\n }", "title": "" }, { "docid": "0c3cec9151a1bb65f0d9198ab606e1ab", "score": "0.59982455", "text": "function onAuthStateChanged(user) {\n setUser(user);\n if (initializing) setInitializing(false);\n }", "title": "" }, { "docid": "01a22f0a55739a13f4568213888c4211", "score": "0.5974174", "text": "static initFirebaseSession() {\n if (firebase.apps.length === 0) {\n const firebaseConfig = {\n apiKey: \"AIzaSyBXD35ShAvf1SrwVSKGrgsl-Odibwrq1G0\",\n authDomain: \"tic-tac-toe-owens.firebaseapp.com\",\n projectId: \"tic-tac-toe-owens\",\n storageBucket: \"tic-tac-toe-owens.appspot.com\",\n messagingSenderId: \"89134231715\",\n appId: \"1:89134231715:web:50b6e7d9333dd1542d8f16\",\n databaseURL: \"https://tic-tac-toe-owens-default-rtdb.firebaseio.com/\"\n };\n \n firebase.initializeApp(firebaseConfig);\n }\n }", "title": "" }, { "docid": "cd232bb213d23cedbe50b3486c6b5e56", "score": "0.5970895", "text": "function init() {\n Auth.$onAuth(createUserIfNew);\n TeamInfo.getTeamInfo().then(function (teamInfo) {\n authCtrl.teamInfo = teamInfo;\n });\n }", "title": "" }, { "docid": "366d140f1487a83cd826440b15cfe91f", "score": "0.5956798", "text": "function onReady() {\n // on document ready\n $('.signin-btn').click(authenticateUser);\n $('.loginSubmitButton').click(authenticateUser);\n init();\n getTermsOfUse();\n getOtherLoginMechanisms();\n toggleRegistrationLink();\n }", "title": "" }, { "docid": "14e99321d888ee5e870487bb720c6f30", "score": "0.5943753", "text": "function initApp() {\n\tconsole.log('app init');\n\tbb.pushScreen('main.html', 'main');\n}", "title": "" }, { "docid": "5d6e9549ba2e8d7c3384335079f16ef0", "score": "0.5907257", "text": "function authStateMonitor() {\n // Firebase triggers listener when the user signs in or out\n firebase.auth().onAuthStateChanged(function(user) {\n // [START_EXCLUDE silent]\n //At reload, when there is not any user in Firebase yet\n $(\"#verifyEmail\").prop(\"disabled\", true);\n $(\"#logIn\").prop(\"disabled\", false);\n // [END_EXCLUDE]\n\n if (user) { //When user is signed in.\n $(\".loginTitle\").text(\"Welcome Back!\");\n $(\".loginFooter\").hide();\n $(\".usernameInput\").hide();\n $(\".passwordInput\").hide();\n $(\"#logIn\").text(\"Logout\");\n\n //Create button direct user to library after login\n var toLibraryBtn = $(\"<button>\").addClass(\"btn btn-info toLibrary\").text(\"Let's Play!\");\n $(\"#playBtn\").append(toLibraryBtn);\n\n $(document).on(\"click\", \".toLibrary\", function(){\n window.location =\"library.html\";\n })\n \n var displayName = user.displayName;\n var email = user.email;\n var emailVerified = user.emailVerified;\n var photoURL = user.photoURL;\n var isAnonymous = user.isAnonymous;\n var uid = user.uid;\n var providerData = user.providerData;\n \n\n //then add user info to database\n \n\n //Display for monitoring purpose\n $(\"#sign-in-status\").text(\"Signed In\");\n var currentUserInfo = JSON.stringify(user, null, ' ');//when sending data to server, data has to be a string\n $(\"#account-details\").text(currentUserInfo);\n \n //Change login button to logout (toogle)\n \n \n if (!emailVerified) { //If user is signed in but has not been verified thru email\n $(\"#verifyEmail\").prop(\"disabled\", false);\n }\n \n }else{ //When user is signed out.\n // [START_EXCLUDE]\n $(\"#logIn\").text(\"Login\");\n $(\".loginTitle\").text(\"Login\");\n $(\"#userInput\").show();\n $(\".loginFooter\").show();\n $(\"#playBtn\").empty();\n $(\".welcomeBack\").hide();\n $(\"#sign-in-status\").text(\"Signed out\");\n $(\"#account-details\").text(\"null\");\n //change back to login\n // [END_EXCLUDE]\n }\n });\n }", "title": "" }, { "docid": "f179dd99c5480ca9712079969cde1c98", "score": "0.5905271", "text": "function initAuth(callback)\n\t{\n\t\tApp.auth = new FirebaseSimpleLogin(new Firebase(App.config.firebaseUrl), function(error, user) \n\t\t{\n\t\t\tif (error) \n\t\t\t{\n\t\t\t\t// an error occurred while attempting login\n\t\t\t\tconsole.log(error)\n\n\t\t\t\t// an error occurred while attempting login\n\t\t\t\tswitch(error.code) \n\t\t\t\t{\n\t\t\t\t\tcase 'INVALID_EMAIL':\n\t\t\t\t\tcase 'INVALID_PASSWORD':\n\t\t\t\t\tdefault:\n\t\t\t\t}\n\n\t\t\t\t// TODO\n\t\t\t\t/*\n\n\t\t\t\t\tAUTHENTICATION_DISABLED\t The specified authentication type is not enabled for this Firebase.\n\t\t\t\t\tEMAIL_TAKEN\tThe specified email address is already in use.\n\t\t\t\t\tINVALID_EMAIL\tThe specified email address is incorrect.\n\t\t\t\t\tINVALID_FIREBASE\tInvalid Firebase specified.\n\t\t\t\t\tINVALID_ORIGIN\t Unauthorized request origin, please check application configuration.\n\t\t\t\t\tINVALID_PASSWORD\tThe specified password is incorrect.\n\t\t\t\t\tINVALID_USER\tThe specified user does not exist.\n\t\t\t\t\tUNKNOWN_ERROR\tAn unknown error occurred. Please contact [email protected].\n\t\t\t\t\tUSER_DENIED\tUser denied authentication request.\n\n\t\t\t\t*/\n\n\t\t\t} \n\t\t\telse if (user) \n\t\t\t{\n\t\t\t\t// user authenticated with Firebase\n\t\t\t\t// console.log(user)\n\t\t\t\tif (callback) callback(null, user)\n\t\t\t} \n\t\t\telse \n\t\t\t{\n\t\t\t\t// user is logged out\n\t\t\t\tif (callback) callback(null, null)\n\t\t\t}\n\n\t\t\t// TODO thirdPartyUserData\n\t\t})\n\t}", "title": "" }, { "docid": "ade190a8f67612ed60cc522ccef37f03", "score": "0.59039193", "text": "function AppInit( ) {\n\theaderSetup( );\t\t\t// Setting up header information\n\tdevNoteControlSetup( );\t// DOCUMENTATION CONTROLS\n\n\tinitPanelControl( );\t// PANEL CONTROLS\n\tinitPooStoreContorl( );\t// POO STORE\n\tinitSettingControl( );\t// SETTING\n\tinitGameControls( );\t// MAIN GAME AREA\n\tinitSessionState( );\t// Session State\n\tinitMobileMenu( );\n\n\tenterGame( );\n}", "title": "" }, { "docid": "d4aac95d5a7b5977a7683a8b84c22ba8", "score": "0.5900673", "text": "function authInit() {\n\t /* */\n\t // console.log(\"initializing auth\");\n\t //authService.getauth();\n\t }", "title": "" }, { "docid": "60705ef66449c13595cc4aebd06bee54", "score": "0.5890168", "text": "function startApp() {\n gapi.load('auth2', function() {\n gapi.client.load('plus', 'v1').then(function() {\n gapi.signin2.render('signin-button', {\n scope: 'https://www.googleapis.com/auth/plus.login',\n fetch_basic_profile: false\n });\n gapi.auth2.init({\n fetch_basic_profile: false,\n scope: 'https://www.googleapis.com/auth/plus.login'\n }).then(\n function() {\n console.log('init');\n auth2 = gapi.auth2.getAuthInstance();\n auth2.isSignedIn.listen(updateSignIn);\n auth2.then(updateSignIn());\n });\n });\n });\n }", "title": "" }, { "docid": "370ed2fd07230b995bfaa91c8aaac19e", "score": "0.58885384", "text": "function initApp ()\n {\n\t// Do various initialization steps\n\t\n\tno_update = 1;\n\t\n\tinitDisplayClasses();\n\tgetDBUserNames();\n\t\n\tif ( getElementValue(\"vf1\") != \"-1\" )\n\t showHideSection('f1', 'show');\n\t\n\tvar sections = { vf2: 'f2', vf3: 'f3', vf4: 'f4', vf5: 'f5', vf6: 'f6', vo1: 'o1', vo2: 'o2' };\n\tvar s;\n\t\n\tfor ( s in sections )\n\t{\n\t if ( getElementValue(s) == \"1\" )\n\t\tshowHideSection(sections[s], 'show');\n}\n\t\n\t// Make sure we have a proper URL to use for data service requests.\n\t\n\tvar origin_match;\n\n\tshort_data_url = data_url;\n\t\n\tif ( data_url.match( /^\\// ) && window.location.origin )\n\t full_data_url = window.location.origin + data_url;\n\telse\n\t full_data_url = data_url;\n\t\n\t// If the form is being reloaded and already has values entered into it, take some steps\n\t// to make sure it is properly set up.\n\t\n\ttry\n\t{\n\t var record_type = $('input[name=\"record_type\"]:checked').val();\n\t setRecordType(record_type);\n\t \n\t var form_mode = $('input[name=\"form_mode\"]:checked').val();\n\t setFormMode(form_mode);\n\t \n\t var output_format = $('input[name=\"output_format\"]:checked').val();\n\t setFormat(output_format);\n\n\t var private_url = $('input[name=\"private_url\"]:checked').val();\n\t console.log(\"private_url = \" + private_url);\n\t setPrivate(private_url);\n\t}\n\t\n\tcatch (err) { };\n\t\n\tno_update = 0;\n\t\n\t// Initiate two API calls to fetch necessary data. Each has a callback to handle the data\n\t// that comes back, and a failure callback too.\n\t\n\t$.getJSON(data_url + 'config.json?show=all&limit=all')\n\t .done(callbackConfig1)\n\t .fail(badInit);\n\t$.getJSON(data_url + 'intervals/list.json?all_records&limit=all')\n\t .done(callbackConfig2)\n\t .fail(badInit);\n }", "title": "" }, { "docid": "79b83d3b0e0c64c02e5240e1ac8cdc49", "score": "0.5887542", "text": "componentWillMount() {\n\t\tfirebase.initializeApp({\n\t\t\tapiKey: 'AIzaSyChfDueWis5PTHqXHMybwdvfQi3LkgqzUE',\n\t\t\tauthDomain: 'auth-ba9d3.firebaseapp.com',\n\t\t\tdatabaseURL: 'https://auth-ba9d3.firebaseio.com',\n\t\t\tstorageBucket: 'auth-ba9d3.appspot.com',\n\t\t\tmessagingSenderId: '491144405866'\n\t\t});\n\n\t// User logged in or not?\n\t\tfirebase.auth().onAuthStateChanged((user) => {\n\t\t\tif (user) {\n\t\t\t\tthis.setState({ loggedIn: true });\t\n\t\t\t} else {\n\t\t\t\tthis.setState({ loggedIn: false });\n\t\t\t}\n\t\t});\n }", "title": "" }, { "docid": "e086f9449f50e3c33c5c43e5f4a0dc6b", "score": "0.58742195", "text": "function onAuthStateChanged(result) {\n setUser(result)\n if (initializing) setInitializing(false)\n }", "title": "" }, { "docid": "ea7462f8a95d4eb1d7706c657eaf6fb3", "score": "0.5841431", "text": "setupLogin() {\n this.firebaseLogin.start('#firebaseui-auth-container', {\n callbacks: {\n signInSuccessWithAuthResult: (authResult, redirectUrl) => {\n this.performerAuthInfo = authResult.user;\n this.loginUI.hidden = true;\n this.database = firebase.database();\n this.checkIfNewPerformer();\n return false;\n },\n uiShown: function() {\n // What to do when the widget is rendered.\n },\n },\n signInFlow: 'popup',\n signInOptions: [\n firebase.auth.EmailAuthProvider.PROVIDER_ID,\n firebase.auth.GoogleAuthProvider.PROVIDER_ID,\n firebase.auth.FacebookAuthProvider.PROVIDER_ID,\n firebase.auth.TwitterAuthProvider.PROVIDER_ID,\n firebase.auth.GithubAuthProvider.PROVIDER_ID,\n firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID,\n ],\n // Terms of service url.\n tosUrl: '<your-tos-url>',\n // Privacy policy url.\n privacyPolicyUrl: '<your-privacy-policy-url>',\n });\n }", "title": "" }, { "docid": "66e3cd384f06321a2ea2e4c46aa5b370", "score": "0.58337885", "text": "function onAuthStateChanged(user) {\n // We ignore token refresh events.\n if (user && currentUID === user.uid) {\n return;\n }\n\n cleanupUi();\n if (user) {\n currentUID = user.uid;\n splashPage.style.display = 'none';\n writeUserData(user.uid, user.displayName, user.email, user.photoURL);\n startDatabaseQueries();\n } else {\n // Set currentUID to null.\n currentUID = null;\n // Display the splash page where you can sign-in.\n splashPage.style.display = '';\n }\n}", "title": "" }, { "docid": "15e7aaf45c2314d1a891f65a389956a7", "score": "0.5830082", "text": "async function loadPageOnAppReady() {\n // check to see if onsen is ready and if all app loading has been completed\n if (!ons.isReady() || utopiasoftware[utopiasoftware_app_namespace].model.isAppReady === false) {\n setTimeout(loadPageOnAppReady, 500); // call this function again after half a second\n return;\n }\n\n // listen for the back button event\n $('#app-main-navigator').get(0).topPage.onDeviceBackButton =\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.backButtonClicked;\n\n // listen for when the login-carousel has changed/slide used to change screen from login to signup etc\n $thisPage.on(\"postchange\", \"#login-carousel\",\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.changeScreenCarouselPostChange);\n\n // listen for when the login-carousel has changed/slide used to hide the tooltips for the previous displayed screen\n $thisPage.on(\"postchange\", \"#login-carousel\",\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.hideTooltipsCarouselPostChange);\n\n // initialise the login form validation\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.loginFormValidator =\n $('#login-page #login-form').parsley();\n\n // initialise the signup form validation\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.signupFormValidator =\n $('#login-page #signup-form').parsley();\n\n // initialise the forgot password form validation\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.forgotPasswordFormValidator =\n $('#login-page #forgot-password-form').parsley();\n\n // listen for log in form field validation failure event\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.loginFormValidator.on('field:error', function(fieldInstance) {\n // get the element that triggered the field validation error and use it to display tooltip\n // display tooltip\n let tooltip = $('#login-page #login-form').get(0).\n ej2_instances[fieldInstance.$element.get(0)._utopiasoftware_validator_index];\n tooltip.content = fieldInstance.getErrorsMessages()[0];\n tooltip.dataBind();\n tooltip.open(fieldInstance.$element.get(0));\n });\n\n // listen for log in form field validation success event\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.loginFormValidator.on('field:success', function(fieldInstance) {\n // hide tooltip from element\n let tooltip = $('#login-page #login-form').get(0).\n ej2_instances[fieldInstance.$element.get(0)._utopiasoftware_validator_index];\n tooltip.close();\n });\n\n // listen for log in form validation success\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.loginFormValidator.on('form:success',\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.loginFormValidated);\n\n // listen for signup form field validation failure event\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.signupFormValidator.on('field:error', function(fieldInstance) {\n // get the element that triggered the field validation error and use it to display tooltip\n // display tooltip\n let tooltip = $('#login-page #signup-form').get(0).\n ej2_instances[fieldInstance.$element.get(0)._utopiasoftware_validator_index];\n tooltip.content = fieldInstance.getErrorsMessages()[0];\n tooltip.dataBind();\n tooltip.open(fieldInstance.$element.get(0));\n });\n\n // listen for sign up form field validation success event\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.signupFormValidator.on('field:success', function(fieldInstance) {\n // hide tooltip from element\n let tooltip = $('#login-page #signup-form').get(0).\n ej2_instances[fieldInstance.$element.get(0)._utopiasoftware_validator_index];\n tooltip.close();\n });\n\n // listen for signup form validation success\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.signupFormValidator.on('form:success',\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.signupFormValidated);\n\n // listen for forgot password form field validation failure event\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.forgotPasswordFormValidator.on('field:error', function(fieldInstance) {\n // get the element that triggered the field validation error and use it to display tooltip\n // display tooltip\n let tooltip = $('#login-page #forgot-password-form').get(0).\n ej2_instances[fieldInstance.$element.get(0)._utopiasoftware_validator_index];\n tooltip.content = fieldInstance.getErrorsMessages()[0];\n tooltip.dataBind();\n tooltip.open(fieldInstance.$element.get(0));\n });\n\n // listen for forgot password form field validation success event\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.forgotPasswordFormValidator.on('field:success', function(fieldInstance) {\n // hide tooltip from element\n let tooltip = $('#login-page #forgot-password-form').get(0).\n ej2_instances[fieldInstance.$element.get(0)._utopiasoftware_validator_index];\n tooltip.close();\n });\n\n // listen for forgot password form validation success\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.forgotPasswordFormValidator.on('form:success',\n utopiasoftware[utopiasoftware_app_namespace].controller.loginPageViewModel.forgotPasswordFormValidated);\n\n\n // listen for scroll event on the page to adjust the tooltips when page scrolls\n $('#login-page .login-page-form-container').on(\"scroll\", function(){\n\n // place function execution in the event queue to be executed ASAP\n window.setTimeout(function(){\n\n switch ($('#login-page #login-carousel').get(0).getActiveIndex()) { // get the active carousel item\n case 0: // first carousel item is active, so adjust the input elements on the login form\n $(\"#login-page #login-form ons-input\").each(function(index, element){\n document.getElementById('login-form').ej2_instances[index].refresh(element);\n });\n break;\n\n case 1: // second carousel item is active, so adjust the input elements on the login form\n $(\"#login-page #signup-form ons-input\").each(function(index, element){\n document.getElementById('signup-form').ej2_instances[index].refresh(element);\n });\n break;\n\n case 2: // third carousel item is active, so adjust the input elements on the login form\n $(\"#login-page #forgot-password-form ons-input\").each(function(index, element){\n document.getElementById('forgot-password-form').ej2_instances[index].refresh(element);\n });\n\n break;\n }\n }, 0);\n });\n\n try{\n // create the tooltip objects for the signin form\n $('#login-form ons-input', $thisPage).each(function(index, element){\n element._utopiasoftware_validator_index = index;\n // create the tool tips for every element being validated, but attach it to the html form object\n new ej.popups.Tooltip({\n cssClass: 'utopiasoftware-ej2-validation-tooltip',\n position: 'TopCenter',\n opensOn: 'Custom'\n }).appendTo($('#login-page #login-form').get(0));\n });\n\n // create the tooltip objects for the signup form\n $('#signup-form ons-input', $thisPage).each(function(index, element){\n element._utopiasoftware_validator_index = index;\n // create the tool tips for every element being validated, but attach it to the html form object\n new ej.popups.Tooltip({\n cssClass: 'utopiasoftware-ej2-validation-tooltip',\n position: 'TopCenter',\n opensOn: 'Custom'\n }).appendTo($('#login-page #signup-form').get(0));\n });\n\n // create the tooltip objects for the forgot password form\n $('#forgot-password-form ons-input', $thisPage).each(function(index, element){\n element._utopiasoftware_validator_index = index;\n // create the tool tips for every element being validated, but attach it to the html form object\n new ej.popups.Tooltip({\n cssClass: 'utopiasoftware-ej2-validation-tooltip',\n position: 'TopCenter',\n opensOn: 'Custom'\n }).appendTo($('#login-page #forgot-password-form').get(0));\n });\n\n // create the button for showing password visibility on the signup page\n new ej.buttons.Button({\n isToggle: true,\n cssClass: 'e-flat e-small e-round',\n iconCss: \"zmdi zmdi-eye\",\n iconPosition: \"Left\"\n }).appendTo($('#signup-password-view-button', $thisPage).get(0));\n\n }\n catch(err){}\n }", "title": "" }, { "docid": "41f7af740866b9e2b559aaf54b468949", "score": "0.5826805", "text": "function authInit() {\n console.log(\"init\");\n gapi.load('auth2', function() {\n auth2 = gapi.auth2.init({\n client_id: '62228642744-d2acfs521ah38phingjmpq6l0lui7oju.apps.googleusercontent.com',\n scope: 'profile'\n });\n\n if (auth2.isSignedIn.get()) {\n signIn(auth2);\n }\n\n // sign in handler\n $(\"#signInButton\").click(function() {\n // open sign in dialog\n auth2.signIn().then(function() {\n signIn(auth2);\n });\n });\n });\n}", "title": "" }, { "docid": "3bf7f4c8eee01404c4218bf63792d162", "score": "0.5818649", "text": "function onAuthStateChanged(user) {\n // We ignore token refresh events.\n if (user && currentUID === user.uid || !user && currentUID === null) {\n return;\n }\n currentUID = user ? user.uid : null;\n\n cleanupUi();\n if (user) {\n splashPage.style.display = 'none';\n writeUserData(user.uid, user.displayName, user.email, user.photoURL);\n startDatabaseQueries();\n } else {\n // Display the splash page where you can sign-in.\n splashPage.style.display = '';\n }\n}", "title": "" }, { "docid": "3b174995283b5d9d4740ad00684825af", "score": "0.5818492", "text": "function initUI() {\n pubsub.publish(topics.init, uiState);\n initMeta();\n initView();\n }", "title": "" }, { "docid": "461e92acec8215f1ccba8926d3c8247f", "score": "0.58092934", "text": "componentWillMount() {\n var config = {\n apiKey: \"AIzaSyATey6H0VnQTyXG197INUCDB98JjTYzUOM\",\n authDomain: \"foobee-auth.firebaseapp.com\",\n databaseURL: \"https://foobee-auth.firebaseio.com\",\n projectId: \"foobee-auth\",\n storageBucket: \"foobee-auth.appspot.com\",\n messagingSenderId: \"368695401541\"\n };\n firebase.initializeApp(config);\n }", "title": "" }, { "docid": "09e4d1b972370ee57b7feedd8afc02d3", "score": "0.5804487", "text": "function onAuthStateChanged(currentUser) {\n setUser(currentUser);\n if (initializing) {\n setInitializing(false);\n }\n }", "title": "" }, { "docid": "64bd3efc5581c01739b64561fe68ceb0", "score": "0.575928", "text": "function start() {\n loadSignIn();\n checkSignIn();\n addAuthStateListener();\n}", "title": "" }, { "docid": "f9dab51bdddc566c11ed264df1c5e1d6", "score": "0.5755055", "text": "function dashboardInit() {\n\thideHeaderLinks('sign-in', 'sign-up');\n\n\t// get sessioStorage data\n\tconst loginData = JSON.parse(sessionStorage.getItem('appUserData'));\n\n\t// get current user from querystring\n\tconst queryString = window.location.search.substring(1).split('&');\n\tvar currentUser = queryString.find( q => {\n\t\treturn q.indexOf('user') > -1;\n\t});\n\n\t// get currentUser data from querystring if a valid query parameter is given\n\tif(currentUser) {\n\t\tcurrentUser = currentUser.slice(currentUser.indexOf('=') + 1, currentUser.length);\n\t\tdocument.getElementById('title').innerHTML = `${currentUser} Dashboard!`;\n\t}\n\n\t// check whether the user is logged in\n\tif(currentUser && loginData && loginData[currentUser]) {\n\t\tlet userData = Object.assign(loginData[currentUser], {'phone': currentUser});\n\t\t// user has signed in\n\t\tgetUserInfo(userData);\n\t}\n\telse {\n\t\t// user data is not present in sessionStorage, user needs to sign-in\n\t\t// display alert to user to sign-in\n\t\tvar alertData = {\n\t\t\t'message': 'You are not signed in!',\n\t\t\t'linkText': 'Please sign-in!',\n\t\t\t'link': 'sign-in',\n\t\t\t'type': 'notify'\n\t\t};\n\t\tconst a = new Alert(alertData);\n\t\ta.appendAlertToDOM('.page-content');\n\t}\n}", "title": "" }, { "docid": "38ad7040f382fd8afc7082501de283ec", "score": "0.57463944", "text": "componentWillMount() {\n firebase.initializeApp({\n apiKey: 'AIzaSyDyNXbnfP1-V_LY1o0z1wa-ByYSpCAnZkM',\n authDomain: 'authentication-98260.firebaseapp.com',\n databaseURL: 'https://authentication-98260.firebaseio.com',\n projectId: 'authentication-98260',\n storageBucket: 'authentication-98260.appspot.com',\n messagingSenderId: '851759449751',\n });\n\n firebase.auth().onAuthStateChanged(user => {\n if (user) {\n this.setState({ loggedIn: true });\n } else {\n this.setState({ loggedIn: false });\n }\n });\n }", "title": "" }, { "docid": "bab6d3ed5a03e0b4fb80a2391e1c0ebe", "score": "0.57375735", "text": "function elfConfigure() {\n 'use strict';\n /* const config = {\n YOUR FIREBASE CONFIG API - KEY OBJECT HERE\n GO TO FIREBASE CONSOLE, FIND YOUR PROJECT,\n SELECT \"Add Firebase to your webapp\"\n COPY THE OBJECT HERE OR PUT IT IN A FILE\n CALLED configuration.js\n THAT IS IN THE SAME DIRECTORY AS THIS FILE.\n Exposing this is not a security risk, but you\n want to use your own database, not mine.\n Do not use a symbolic link to configuration.js\n Do not need to use a module.exports = config;\n Do not need to use a require('./configuration.js');\n @see /views/layout.pug\n @see /public/javascripts/.gitignore\n }; */\n\n firebase.initializeApp(firebaseConfig);\n document.getElementById('elf-sign-in').addEventListener('click', toggleSignIn, false);\n document.getElementById('elf-sign-in').disabled = false;\n}", "title": "" }, { "docid": "35202f17802d38f6f1ca11254e406542", "score": "0.57364583", "text": "function initializeAfterLoad() {\n\n\t// Get previously stored session token\n\ttry {\n\t\tapp.session.token = window.localStorage.getItem(\"sessionToken\") || undefined;\n\t\tapp.selections.user = { id: +window.localStorage.getItem(\"userId\") || undefined };\n\t\tloadUser();\n\t} catch(error) {\n\t\tconsole.error(\"Can't retrieve sessionToken and/or userId\");\n\t}\n\n\t// Initialize pages in app\n\tObject.keys(app.pages).forEach(function(pageId) {\n\n\t\t// Validate page exists in DOM as well\n\t\tvar pageElement = d3.select(\"#\" + pageId);\n\t\tif(pageElement.size() !== 1) {\n\t\t\tconsole.error(\"Internal Error. Unknown page with id \" + pageId + \" in app.\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Add element to page for easy selection of child elements\n\t\tpage = app.pages[pageId];\n\t\tpage.element = pageElement;\n\n\t\t// Add 'empty' defaults to page\n\t\tif(page.beforeShow === undefined) {\n\t\t\tpage.beforeShow = EMPTY_FUNCTION;\n\t\t}\n\t\tif(page.afterShow === undefined) {\n\t\t\tpage.afterShow = EMPTY_FUNCTION;\n\t\t}\n\t\tif(page.actions === undefined) {\n\t\t\tpage.actions = {};\n\t\t}\n\n\t\t// Bind 'this' to page actions/methods\n\t\tObject.keys(page.actions).forEach(function(actionId) {\n\n\t\t\t// Replace action with bound action\n\t\t\tvar action = page.actions[actionId];\n\t\t\tpage.actions[actionId] = action.bind(page);\n\t\t});\n\t});\n\n\t// Add event handlers for main functions\n\td3.select(\"#dial-button\").on(\"click\", app.actions.dial);\n\td3.select(\"#logout-button\").on(\"click\", app.actions.logout);\n\td3.select(\"#me-button\").on(\"click\", app.actions.me);\n\td3.select(\"#message-button\").on(\"click\", app.actions.message);\n\td3.select(\"#call-button\").on(\"click\", app.actions.call);\n\td3.select(\"#add-button\").on(\"click\", app.actions.add);\n\n\t// Add event handlers to navigation links (this is independent of location of links)\n\td3.selectAll(\"a.nav\").each(function() {\n\t\tvar linkElement = d3.select(this);\n\t\tvar href = linkElement.attr(\"href\");\n\t\tif(href && href.startsWith(\"#\")) {\n\n\t\t\t// Validate page exists in app\n\t\t\tvar pageId = href.slice(1);\t// Remove \"#\"\n\t\t\tif(!app.pages[pageId]) {\n\t\t\t\tconsole.error(\"Internal Error. Unknown pageId \" + pageId + \" in link.\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Add event handler\n\t\t\tlinkElement.on(\"click\", function() {\n\t\t\t\tshowPage(pageId);\n\t\t\t\tstopEventFully();\n\t\t\t});\n\t\t}\n\t});\n\n\t// Add event handlers to action links (this is dependent on page where link is located)\n\td3.selectAll(\".page\").each(function() {\n\n\t\t// Validate page exists in app\n\t\tvar pageElement = d3.select(this);\n\t\tvar pageId = pageElement.attr(\"id\");\n\t\tvar page = app.pages[pageId];\n\t\tif(!page) {\n\t\t\tconsole.error(\"Internal Error. Unknown pageId \" + pageId + \" in html.\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle action links within page\n\t\tpageElement.selectAll(\"a.action\").each(function() {\n\t\t\tvar linkElement = d3.select(this);\n\t\t\tvar href = linkElement.attr(\"href\");\n\t\t\tif(href && href.startsWith(\"#\")) {\n\n\t\t\t\t// Validate action exists\n\t\t\t\tvar actionId = href.slice(1);\t// Remove \"#\"\n\t\t\t\tvar action = page.actions[actionId];\n\t\t\t\tif(!action) {\n\t\t\t\t\tconsole.error(\"Internal Error. Unknown actionId \" + actionId + \" in link on page \" + pageId + \".\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Add event handler\n\t\t\t\tlinkElement.on(\"click\", function(d) {\n\t\t\t\t\taction(d);\n\t\t\t\t\tstopEventFully();\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t});\n\n\t// Add event handlers to list items\n\td3.select(\"#members li\").on(\"click\", function(d) {\n\t\tapp.selections.member = d;\n\t\tshowPage(\"member\", d);\n\t});\n\n\t// Add event handlers to notification items\n\td3.select(\"#notifications .close\").on(\"click\", function() {\n\t\tvar dataIndex = d3.select(this).attr(\"data-index\");\n\t\tif(dataIndex) {\n\t\t\tremoveNotification(+dataIndex);\n\t\t}\n\t});\n\n\t// Create templates from pages\n\td3.selectAll(\"#templates > *\").template();\n\td3.selectAll(\".page\").template();\n\n\t// Create templates for notifications\n\tapp.notificationsTemplate = d3.select(\"#notifications\").template();\n\n\t// Show home page\n\tshowPage(\"home\");\n}", "title": "" }, { "docid": "5e0a16bb15346fbbdd6045ed2b50667a", "score": "0.5725544", "text": "function initializeApp() {\n var submit_button = $('#submit_button');\n screen.orientation.lock('portrait').catch(function(){\n });\n submit_button.on('click', geocode);\n google.charts.load('current', { 'packages': ['corechart'] });\n callApi();\n $('#info-icon').on('click', infoButtonClickHandler);\n}", "title": "" }, { "docid": "655484b1d9e51a6e5268eb067fa11572", "score": "0.5719115", "text": "initApp() {\n this.todoList = JSON.parse(localStorage.getItem(\"todos\")) || [];\n document.body.appendChild(this.renderApp());\n this.getTodos();\n this.submitTodoHandler();\n this.operationHandler();\n this.removeCompletedTodos();\n this.submitTodoEditHandler();\n }", "title": "" }, { "docid": "c4468a3e744f00c5993c7416f2e55fb8", "score": "0.5713028", "text": "function authStatusListener() {\n\tfirebase.auth().onAuthStateChanged(function(user) {\n\t\tif (user) {\n\t\t\t// A user is signed in\n\t\t} else {\n\t\t\tdocument.getElementById('message-box').innerHTML = \"You're logged out.\";\n\t\t\tdocument.getElementById('log-out-form').innerHTML = '';\n //location.href = \"livnyc.html\";\n\t\t}\n\t});\n}", "title": "" }, { "docid": "127f2cb59bd437a8fc59e4cbcc76f373", "score": "0.56953907", "text": "function onAuthStateChanged(user) {\n setUser(user);\n if (initializing) setInitializing();\n }", "title": "" }, { "docid": "ab703e3383ee826655ddac0bbf3085bd", "score": "0.5694217", "text": "function initApp(apiUrl) { \n \n // making the website\n // make header\n header();\n \n // add in login functionality\n makeLoginForm();\n loginFunctionality(apiUrl);\n \n // add in sign up functionality\n makeSignUpForm();\n signUpFunctionality(apiUrl);\n \n // make the feed \n createFeedTemplate();\n makePublic();\n showPublic(apiUrl);\n \n // PAGE REMODELLING (WHEN USER LOGS IN/OUT)\n logout();\n checkUserLoggedIn(apiUrl);\n \n // allow users to search posts\n startSearch(apiUrl);\n \n // allow the description to be expanded/collapsed\n togglePost();\n \n // show upvotes and comments\n makeUpvotesWindow();\n makeCommentsWindow();\n loadVotesComments(apiUrl);\n \n // allow a logged in user to upvote or remove their upvote\n thumbsButtonFunctionality(apiUrl);\n \n // allowed a logged user to make, edit or delete a post\n postForm();\n editPostForm();\n makePost(apiUrl);\n postBtnOptions(apiUrl);\n \n // allow the user to see and edit their profile\n makeProfileWindow();\n makeFollowingWindow();\n showProfile(apiUrl);\n updateProfile(apiUrl);\n \n // applies infinite scroll of user feed\n if (localStorage.getItem('login') === 'true') {\n infiniteScroll(apiUrl);\n }\n \n // scroll to the top of the page when the page refreshes\n window.onbeforeunload = function() {\n window.scrollTo(0, 0);\n }\n \n // allow users to comment\n comment(apiUrl);\n \n // allows the user to open user pages\n makeUserPage();\n mainUserPage(apiUrl);\n}", "title": "" }, { "docid": "1d7b6b4d75f5fbdad0ea4767d564c045", "score": "0.5685105", "text": "function onInit() {\r\n _registerModals();\r\n /**\r\n * Event Handlers and Functions attached to $scope to be used in View\r\n */\r\n $scope.$on('$destroy', onDestroy);\r\n cleanUserIdleHandler = $rootScope.$on('UserIdle', onUserIdle);\r\n $scope.autoLogoutClose = onAutoLogoutClose;\r\n\r\n $rootScope.$watch('user', onStateCleared);\r\n $scope.logout = onLogout;\r\n $scope.help = onHelp;\r\n $scope.synchronize = onSynchronize;\r\n $scope.toggleResetData = onToggleResetData;\r\n }", "title": "" }, { "docid": "e920d0db668c6ccb0e462a5cbd4a8fff", "score": "0.5678341", "text": "function setupAppConfig() {\n if (!appConfig.hasInit) {\n appConfig.init();\n }\n} // this can be called multiple times (due to recreating the main app window),", "title": "" }, { "docid": "9532e0fa7c38fdc4c1dc7b59d73fe1a7", "score": "0.5678191", "text": "function checkCred() {\n firebase.auth().onAuthStateChanged(function (user) {\n if (!user) {\n window.location = \"main.html\";\n }\n });\n}", "title": "" }, { "docid": "e78b88d727cb77c0ee1d4b278087bc2a", "score": "0.5651279", "text": "async function redirectIfNotFirebaseUser()\n{\n await firebase.auth().onAuthStateChanged(async function(user)\n {\n if (user)\n await initializeAppUser();\n else\n window.location.replace(\"index.html\");\n });\n}", "title": "" }, { "docid": "2de45dfe66196863da9875fd4458b283", "score": "0.5649215", "text": "async init_app() {\r\n this.logger.info('init_app: Start initializing the main modules')\r\n\r\n //intialize db connection\r\n await this.init_db();\r\n\r\n //initialize APIs\r\n await this.init_routes();\r\n }", "title": "" }, { "docid": "8d19fb329411ec8a1f326951c569a83d", "score": "0.5645767", "text": "async function initializeApp() {\n const domView = new DomView();\n // check for logged in user, then display all user stories\n await domView.checkForLoggedUser();\n await domView.displayStories();\n\n // run all event listeners in domView instance\n domView.createEventListeners();\n }", "title": "" }, { "docid": "a8b3d4d464f04ba4acf3bb689553037e", "score": "0.5642887", "text": "function handleAuth(callback) {\n window.addEventListener('DOMContentLoaded', () => {\n\n // Initialize the FirebaseUI Widget using Firebase.\n var ui = new firebaseui.auth.AuthUI(firebase.auth());\n\n function handleSignedInUser(user) {\n\n // Display page content\n $('title').text('IHS Artists Console');\n $('#auth').css('display', 'none');\n $('#console').css('display', 'block');\n\n callback(user.uid);\n }\n\n function handleSignedOutUser() {\n\n // Display Sign In UI\n $('title').text('Sign In | IHS Artists Console');\n $('#auth').css('display', 'block');\n $('#console').css('display', 'none');\n\n ui.start('#auth-ui', {\n callbacks: {\n signInSuccessWithAuthResult: function (authResult) {\n // Save GitHub access token\n firebase.database().ref('users/' + authResult.user.uid + '/token').set(authResult.credential.accessToken);\n // Do not redirect.\n return false;\n },\n uiShown: function () {\n $('#auth-loader').css('display', 'none');\n }\n },\n signInFlow: 'redirect',\n signInOptions: [{\n provider: firebase.auth.GithubAuthProvider.PROVIDER_ID,\n scopes: ['repo']\n }]\n });\n }\n\n firebase.auth().onAuthStateChanged(function (user) {\n user ? handleSignedInUser(user) : handleSignedOutUser();\n });\n\n $('#sign-out').click(function () {\n firebase.auth().signOut();\n });\n });\n}", "title": "" }, { "docid": "a31da44d5ee06837aac13126de4a2283", "score": "0.56382555", "text": "connect(){\r\n var uiConfig = {\r\n callbacks: {\r\n signInSuccessWithAuthResult: function(authResult, redirectUrl) {\r\n // User successfully signed in.\r\n // Return type determines whether we continue the redirect automatically\r\n // or whether we leave that to developer to handle.\r\n return false;\r\n },\r\n uiShown: function() {\r\n // The widget is rendered.\r\n // Hide the loader.\r\n document.getElementById('loader').style.display = 'none';\r\n }\r\n },\r\n // Will use popup for IDP Providers sign-in flow instead of the default, redirect.\r\n signInFlow: 'popup',\r\n signInSuccessUrl: '',\r\n signInOptions: [\r\n // Leave the lines as is for the providers you want to offer your users.\r\n firebase.auth.EmailAuthProvider.PROVIDER_ID\r\n ],\r\n // Terms of service url.\r\n tosUrl: '',\r\n // Privacy policy url.\r\n privacyPolicyUrl: ''\r\n };\r\n\r\n /* Mise en place de la fonction de callback qui est activée à chaque changement d'état de connexion. */\r\n firebase.auth().onAuthStateChanged(\r\n function(authUser){\r\n if(authUser){\r\n this.user = authUser;\r\n this.ui.reset();\r\n this.onConnect(authUser);\r\n }\r\n else{\r\n this.onDisconnect();\r\n this.ui.start('#firebaseui-auth-container', uiConfig);\r\n this.user = null;\r\n }\r\n }.bind(this));\r\n }", "title": "" } ]
9a451a9796722a0432d27ed4f946e0fc
===== Clear Library and Storage function =====
[ { "docid": "6ee8d6defaf7aee66d05374d7a00d693", "score": "0.78130233", "text": "function clearLocalStorage(){\n localStorage.clear();\n myLibrary = [];\n container.innerHTML = '';\n clearValues();\n}", "title": "" } ]
[ { "docid": "31236d9912b54e129f5685d80ba3c91c", "score": "0.7988415", "text": "static clear() {\n const libraryLength = localStorage.length;\n for (let inx = libraryLength-1; inx >= 0; inx--) {\n const key = localStorage.key(inx);\n if (key != undefined && key.startsWith('http')) {\n localStorage.removeItem(key);\n delete Library.map[key];\n }\n }\n }", "title": "" }, { "docid": "656893c33f38c0d5fd365e69cdda589c", "score": "0.75038207", "text": "function clear() {\n storage.clear();\n }", "title": "" }, { "docid": "9834c1ac5147214972674e530ebb60c9", "score": "0.72189415", "text": "function _clear_cache_and_update(){\n chrome.storage.local.remove('library', unless_error(function() {\n console.log('cleared library cache');\n send_cscripts_message({\n action: 'library_updated',\n library: null\n });\n }));\n}", "title": "" }, { "docid": "d5ecd88c94fff772e783b208af511a09", "score": "0.7145012", "text": "clear() {}", "title": "" }, { "docid": "d5ecd88c94fff772e783b208af511a09", "score": "0.7145012", "text": "clear() {}", "title": "" }, { "docid": "c35f17f84e86b169086703fcd96e87db", "score": "0.7138344", "text": "clear() {\n this.storage = {};\n }", "title": "" }, { "docid": "cf4c213be2bc96243b635f42dc0550cb", "score": "0.70409924", "text": "function clearStorage() {\n var defaultPathURL = DEFAULT_CORE_PATH;\n appStorage.setItem('nDC_core_file', defaultPathURL);\n AppCore.core = defaultPathURL;\n xxLoadDefaultCore(defaultPathURL); // reload Core\n}", "title": "" }, { "docid": "6d67fe4273a056aaf83f8a09ab524618", "score": "0.7039997", "text": "function clearLocalStorage() {\n \n}", "title": "" }, { "docid": "7cd2bdc77a7968872ef6b8a925afec52", "score": "0.6983899", "text": "clear() {\n\n }", "title": "" }, { "docid": "13a7bfd59d76109ed5ea5bb5ee769ede", "score": "0.69399226", "text": "function guidoLsClear() {\n\tif(typeof(Storage) !== \"undefined\") {\n\t\tvar state = localStorage.removeItem(guidoConf.ls + \"__state\");\n\t}\n}", "title": "" }, { "docid": "29d33cb9d753f1640312d7367f430e2d", "score": "0.6939818", "text": "clear() {\n window.localStorage.clear();\n }", "title": "" }, { "docid": "b366509c2b343646c5e209fb44724750", "score": "0.69347996", "text": "clear() {\n localStorage.clear();\n }", "title": "" }, { "docid": "498f15925d1ff75867b23e6fe392a7a6", "score": "0.69038653", "text": "static async wipeLocalStore() {\n try {\n await AsyncStorage.clear() \n } catch (error) {\n console.log('Error Wiping Local Store: ', error)\n }\n }", "title": "" }, { "docid": "451daf4e3d26b91871f723ce123ddef3", "score": "0.6877439", "text": "clearAll() {\n localStorage.clear();\n }", "title": "" }, { "docid": "1ae4bbcd5829ef889bfc7c3a5edc6447", "score": "0.68760777", "text": "clear() {\n chrome.storage.sync.clear(() => {\n // alert(\"Storage cleared successfully!\")\n })\n }", "title": "" }, { "docid": "762cbd3b5ee60d5ce462e981f37d28fb", "score": "0.682423", "text": "clear() {\n // !!!! IMPLEMENT ME !!!!\n }", "title": "" }, { "docid": "7a411b66def42780c13a5b992c9e25a5", "score": "0.68228585", "text": "function clearStorage() {\n chrome.storage.sync.clear();\n}", "title": "" }, { "docid": "d272441ddef6ee340c0f8a99f9284cb5", "score": "0.68222976", "text": "function clearStorage() {\n chrome.storage.sync.get(null, function(settings) {\n $.each(settings, function(k) { chrome.storage.sync.remove(k); })\n });\n }", "title": "" }, { "docid": "12258bc28dd75aec3c5c0baea8e3e57a", "score": "0.68221676", "text": "static clearData() {\n chrome.storage.sync.clear();\n }", "title": "" }, { "docid": "2a54c75af488bc2866a9b53b80cfb2e9", "score": "0.68177307", "text": "static clearAllStore () {\n window.localStorage.clear()\n }", "title": "" }, { "docid": "6ae075ce48af7258655becf7e7d54ca1", "score": "0.68119705", "text": "clear() {\n delete this.dataStore;\n this.dataStore = [];\n this.listSize = this.pos = 0;\n }", "title": "" }, { "docid": "cf11533ad38181453c5742b914596a4e", "score": "0.6809667", "text": "static clearAll(){\n\n localStorage.clear();\n }", "title": "" }, { "docid": "ca84cf16335686414a201e032636c5b6", "score": "0.6796874", "text": "function cleanAll(){\n\tlocalStorage.clear();\n\tshowInformation();//llamo a showinformation para que use esta funcion en el boton usado para borrar datos\n}", "title": "" }, { "docid": "e1e87ad5973a2b255e11ff2d8f8a2325", "score": "0.6785785", "text": "cleanup() {\n this['file'] = null;\n if (this['files'].length > 0) this['files'] = [];\n this['status'] = -1; // uninitialized state\n }", "title": "" }, { "docid": "a50cfaa36ce5d513ac73e5dc86fdd6e4", "score": "0.67675555", "text": "function clear() {\n delete this.dataStore;\n this.dataStore = [];\n this.listSize = this.pos = 0;\n }", "title": "" }, { "docid": "7eeabd719a3eff58013c3d2171db5fad", "score": "0.6754888", "text": "static _clear() {\n this.isInit()\n\n storage.clearMap()\n }", "title": "" }, { "docid": "b5358a29ac9efc04097b4653a5bfbca6", "score": "0.6751608", "text": "function clearStorage() {\n localStorage.clear();\n}", "title": "" }, { "docid": "261de9c0dc3781da3bde83eb70419c5b", "score": "0.67303365", "text": "async function removeAll() {\n await handleError(writeFile, path, JSON.stringify({}), 'utf8')\n localstorageEvents.emit(LOCALSTORAGE_CLEAR, null)\n }", "title": "" }, { "docid": "39ba97837eb55aa82165bcf8d7477a01", "score": "0.6723861", "text": "async clear() {\n //@TODO\n }", "title": "" }, { "docid": "7386fbd08997ab6ab05e6078f3f2ee08", "score": "0.67218995", "text": "function clearStorage()\n\t\t{\n\t\tlocalStorage.removeItem('comm');\n\t\twindow.location.reload();\n\t\t}", "title": "" }, { "docid": "15d63047bf75d848cd96581c20ed271c", "score": "0.67191964", "text": "function clear ()\n {\n window.localStorage.removeItem(dataName);\n }", "title": "" }, { "docid": "1c0450fec76d106d78dfede44ed1a034", "score": "0.6704594", "text": "clear() {\n this._objects = {};\n this._objectsNeedAutosave = {};\n }", "title": "" }, { "docid": "4ae2e690598f8a87b2f68bd5f60e5db7", "score": "0.66956633", "text": "function clearStrg() {\n log('about to clear local storage');\n window.localStorage.clear(); // <-- Local storage!\n log('cleared');\n }", "title": "" }, { "docid": "1edb44b52c21b4751d6ff66dcdceb508", "score": "0.66936445", "text": "clear () {\n if (window.localStorage) {\n for (let key in window.localStorage) {\n if (key.indexOf(LOCAL_STORAGE_PREFIX) === 0) {\n window.localStorage.removeItem(LOCAL_STORAGE_PREFIX + key);\n }\n }\n }\n }", "title": "" }, { "docid": "784b7f61bd34c5fb22f270cb5735afa7", "score": "0.66912365", "text": "function clearLS() {\r\n localStorage.clear();\r\n}", "title": "" }, { "docid": "de7bbc6cbc52c028d8b33e60a07674b4", "score": "0.6685471", "text": "function clearAllFromLocStor() {\n localStorage.clear();\n}", "title": "" }, { "docid": "0007fe6201653e5c8299afd6cea9a1cd", "score": "0.6681281", "text": "function clearStorage() {\n\tif ( supportsHTML5Storage() ) {\n\t\twindow.localStorage.removeItem('poll'+window.location.pathname.toLowerCase().split('poll/').slice(-1));\n\t\twindow.localStorage.removeItem('current'+window.location.pathname.toLowerCase().split('poll/').slice(-1));\n\t} else {\n\t\t//window['polljspoll'+poll._id] = undefined;\n\t\t//window['polljscurrent'+poll._id] = undefined;\n\t}\n}", "title": "" }, { "docid": "853b79e334d724e723d5f60146b990cf", "score": "0.66772884", "text": "function clearData(){\n //localStorage.clear();\n}", "title": "" }, { "docid": "0b93bf92847e15b0f2204b148f56aea8", "score": "0.6676341", "text": "function clearStorage() {\n // clear localStorage\n for (let i = 0; i < localStorage.length; i++) {\n const lsKey = localStorage.key(i);\n if (lsKey.includes(\"converse\")) {\n localStorage.removeItem(lsKey);\n }\n }\n\n // clear sessionStorage\n for (let i = 0; i < sessionStorage.length; i++) {\n const ssKey = sessionStorage.key(i);\n if (ssKey.includes(\"converse\")) {\n sessionStorage.removeItem(ssKey);\n }\n }\n\n // clear IndexedDB\n window.indexedDB.deleteDatabase(\"converse-persistent\");\n}", "title": "" }, { "docid": "ad531cfd93704b084d6f04890557d107", "score": "0.66644406", "text": "function clearMethod() {\n\tlocalStorage.clear();\n}", "title": "" }, { "docid": "59fe92cdf9beaca763600f45072b4f15", "score": "0.6660605", "text": "async clear() {\n const db = await this.ready;\n const storeNames = [...ALLOWED_TYPES];\n const stores = await new Promise((resolve, reject) => {\n const transaction = db.transaction(storeNames, \"readwrite\");\n\n transaction.onerror = () => {\n reject(new DOMException(transaction.error.message, transaction.error.name));\n };\n\n resolve(transaction);\n });\n const clearStorePromises = storeNames.map(name => {\n return new Promise(resolve => {\n const request = stores.objectStore(name).clear();\n request.onsuccess = resolve;\n });\n });\n Promise.all(clearStorePromises);\n }", "title": "" }, { "docid": "a5e1749dc33f52e2518128ea4bb0f50f", "score": "0.66581887", "text": "function cleanup() {\n log('cleanup');\n saveData(storageKey, data);\n}", "title": "" }, { "docid": "4963277f4ffd9e0995b3c2143c659ef3", "score": "0.6654264", "text": "clear() {\n // if (confirm(\"Do you really want to delete all movies?\")) {\n try {\n this._instances = {};\n localStorage[MOVIES_STORAGE_KEY] = \"{}\";\n this.setNextId(1);\n console.info(\"All movie records cleared.\");\n } catch (e) {\n console.warn(`${e.constructor.name}: ${e.message}`);\n }\n // }\n }", "title": "" }, { "docid": "9e05f3805f191273ef1ef324fe93cfd6", "score": "0.6644436", "text": "clear() {\n this.cache_ = {};\n this.cacheSize_ = 0;\n }", "title": "" }, { "docid": "6cfd93d86adabb16d79841f1d2381beb", "score": "0.66416746", "text": "function clearCarsFromLocalStorage() {\n localStorage.clear();\n}", "title": "" }, { "docid": "0b4b7e33160ce7b49f2624fce0203cdf", "score": "0.6639448", "text": "clear() {\n this.cache_ = {};\n if (Store.isSupported_()) {\n try {\n Store.clear_(this.key_);\n } catch(err) {\n // Do nothing.\n }\n }\n }", "title": "" }, { "docid": "878d0fd0b9e0db1146712be4c4e394e3", "score": "0.6635594", "text": "clear() {\n let libraryForm = document.getElementById('libraryForm');\n libraryForm.reset();\n }", "title": "" }, { "docid": "871e50bf0223c6cb2033ea7b33d6e584", "score": "0.6629211", "text": "clear() {\n for (let i = 0; i < this.storedKeys.length; i++) {\n this.storage.removeItem(this.storedKeys[i]);\n }\n this.storedKeys = [];\n }", "title": "" }, { "docid": "adce6d6a59dd156a36b7bfd9c83804af", "score": "0.66247445", "text": "function clearStrg() {\n log('about to clear local storage');\n window.localStorage.clear();\n log('cleared');\n}", "title": "" }, { "docid": "f7573f69ff82e9be6df1ddb567b0504f", "score": "0.6613965", "text": "static clear_registry() {\n\t\tthis._extension_registry.clear();\n\t\tthis._all_extensions.length = 0;\n\n\t\tthis._mime_registry.clear();\n\t\tthis._all_mimes.length = 0;\n\n\t\tthis._all_providers.length = 0;\n\t}", "title": "" }, { "docid": "bc1469f7721a39ec61f63322a0007ec8", "score": "0.6608564", "text": "clear() {\n console.log('Clearing local storage...');\n this.localStorage.clear();\n }", "title": "" }, { "docid": "b998188787fc3721c1e40cffd60c7916", "score": "0.6599947", "text": "clearData(){\n AsyncStorage.clear();\n console.log('Data cleared. App will reset.');\n }", "title": "" }, { "docid": "88701816d018bf5b77d88f7cbc9da8a5", "score": "0.65943754", "text": "function clearToDoItemsFromStorage(){\r\n //Call the function to remove the to do items from storage\r\n clearStorage(\"ToDoItems\");\r\n}", "title": "" }, { "docid": "050eb925695b4ee25eea0bef2c9c0caf", "score": "0.65885854", "text": "function clearLocalStorage() {\n localStorage.clear();\n }", "title": "" }, { "docid": "13c9b6b1c5a1d9d0a168eedfb1d49560", "score": "0.6578945", "text": "function clearStorage() {\n JSON.parse(localStorage.removeItem(\"products\"));\n }", "title": "" }, { "docid": "714b6ac6c6f2d63b6fda3bda51d37d20", "score": "0.6575771", "text": "function clearStoreDB() {\n //Cleans data\n store.clearAll();\n}", "title": "" }, { "docid": "51f6f345a80c999cbb74ef11947a917e", "score": "0.65732104", "text": "function clear() {\n objects.clear();\n }", "title": "" }, { "docid": "cb0e0fac66dfb11b9b1b87175c26c8e7", "score": "0.6560837", "text": "clear() {\n\t\tif (this.#keyPrefix) this.keys.forEach(key => this.remove(key));\n\t\telse {\n\t\t\tthis.#backend.clear();\n\t\t\tthis.dispatchEvent(new StorageEvent(null));\n\t\t}\n\t}", "title": "" }, { "docid": "5ccc74c7070cfc12cd42d90c6ed6d2e0", "score": "0.6560497", "text": "function vaciarLocarStorage(){\n localStorage.clear();\n }", "title": "" }, { "docid": "c8b01531dc5582d6419870d2f52a879d", "score": "0.6558284", "text": "function clearUserData() {\n\tStorage.clear();\n}", "title": "" }, { "docid": "b35327e1374034f367a6f5e03ad40536", "score": "0.655626", "text": "clear() {\n let libraryForm = document.getElementById(\"libraryForm\");\n libraryForm.reset();\n }", "title": "" }, { "docid": "c1d2a6077e7d87a98da9e534072f12ce", "score": "0.6555971", "text": "function localStorageClear() {\n $('#queues').empty();\n localStorage.clear();\n closeAllVideo();\n pauseQueue();\n insertSplashSearchBar();\n}", "title": "" }, { "docid": "ea1eaab7b75a7d7c3819b66c7ffdf68a", "score": "0.6552858", "text": "function clearLocalStorage(){\n localStorage.clear();\n}", "title": "" }, { "docid": "03effc865feb9fd56cea88b7d5b021a3", "score": "0.6550754", "text": "function clearMainPage(){\n GalleryStore.clearRoot()\n clearSideLayout()\n clearTags()\n clearSubmitButton()\n}", "title": "" }, { "docid": "2d3285f3cadf7bef500a695241a9c3b4", "score": "0.6545537", "text": "function ClearAgentData(){\n print(\"Cleared Local Storage\")\n localStorage.clear();\n}", "title": "" }, { "docid": "e83039bebab5aba7cbce42c9968175be", "score": "0.65402734", "text": "function initClearStorage() {\n for (var i = 0; i < settingsVarNameDescs.length; i++) {\n var varNameDesc = settingsVarNameDescs[i];\n var varName = varNameDesc[0];\n var varPersist = varNameDesc[1];\n if (!varPersist) {\n continue;\n }\n localStorage.removeItem(_initPresistentPrefix + varName);\n }\n}", "title": "" }, { "docid": "95df4a22971be2715ff45021fc2be438", "score": "0.653652", "text": "function storageClear(){\r\n var storage = window.localStorage;\r\n storage.removeItem(\"game_recode_listdata_h5p_room\");\r\n for(let i = 0; i< storage.length; i++ ){\r\n if( storage.key(i).indexOf(`yubaAssigned💧${uid}💧`) != -1 && storage.key(i).indexOf(localStorageName) == -1 ){\r\n storage.removeItem(storage.key(i));\r\n }\r\n }\r\n }", "title": "" }, { "docid": "470ffeecb01fa7c0da10773f90281c1a", "score": "0.6533175", "text": "function clearLocalStorage() {\n localStorage.clear();\n console.log(\"Cleared Local Storage\");\n}", "title": "" }, { "docid": "3cfa479d0e4c98715f484f581a5dd69d", "score": "0.6529784", "text": "clearFilesFromLocalStorage() {\n localStorage.removeItem(this.file0);\n localStorage.removeItem(this.file1);\n localStorage.removeItem(this.file2);\n localStorage.removeItem(this.file3);\n localStorage.removeItem(this.file4);\n }", "title": "" }, { "docid": "d73c7bc1308f5a8ad7d186eccb4c3b20", "score": "0.6528461", "text": "function clear() {\n \n}", "title": "" }, { "docid": "0ad24b051db729517d1868bf010559c1", "score": "0.6527499", "text": "function clearLocalStorage(){\n localStorage.clear();\n}", "title": "" }, { "docid": "0cafb82198cda5e29826ba55ad67e705", "score": "0.6527023", "text": "function clear() {\n cache = {};\n}", "title": "" }, { "docid": "163619ebd68e54c51914ac0ae260e334", "score": "0.65253603", "text": "clear() {\n if (this._records) {\n let records = this._records;\n this._records = [];\n let record;\n\n for (let i = 0; i < records.length; i++) {\n record = records[i];\n record.unloadRecord();\n record.destroy(); // maybe within unloadRecord\n }\n }\n\n this._metadata = null;\n }", "title": "" }, { "docid": "d67bb4fabe1dcaccb920f99020d80ba9", "score": "0.6520931", "text": "function clear_all()\r\n\t\t\t\t{\r\n\t\t\t\t\tlocalStorage.clear();\r\n\t\t\t\t\tshow_content(\"new\");\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t}", "title": "" }, { "docid": "9ec63b3e1f3c0e94ca69792f49c72a49", "score": "0.651948", "text": "static async clear() {\n const waitFor = [];\n Object.keys(AbcApi._modelsManaged).forEach(key => {\n const ref = AbcApi.getModelApi(AbcApi._modelsManaged[key].model.constructor);\n if (ref.config.useIndexedDb) {\n waitFor.push(ref.dexieTable.clear());\n }\n });\n await Promise.all(waitFor).catch(e => {\n console.warn(e);\n });\n AbcApi._modelsManaged = {};\n if (AbcApi.indexedDbConnected) {\n AbcApi.disconnect();\n }\n }", "title": "" }, { "docid": "c14440607b7a39fbcea8fc27a4c5bc91", "score": "0.6519191", "text": "function clearLocalStorage() {\n localStorage.clear();\n setVarDefaults();\n blankFields();\n hideResults();\n setFields();\n}", "title": "" }, { "docid": "1c5d4f3c16e0714baeb94085fe1430cf", "score": "0.6517874", "text": "function limpiarLocalStorage () {\n\tlocalStorage.clear();\n}", "title": "" }, { "docid": "acf0c378ec8c21c18e3fddb14e309760", "score": "0.65129954", "text": "function _clearObjStore(callback) {\n var objStore = _getObjStore('offlineItems');\n var req = objStore.clear();\n req.onsuccess = function(e) { callback(objStore.getAll()); }\n req.onerror = function() { console.error(this.error); };\n }", "title": "" }, { "docid": "a35bf1da979de977c508719cdbd1c5e4", "score": "0.65109843", "text": "clear() {\n allItems = [];\n whenGoodsApearArray = [0, 0, 0];\n speed = 1;\n countOfGems = 1;\n }", "title": "" }, { "docid": "e526ac658402ec1a3535a685eebcd72d", "score": "0.6509652", "text": "function clear() {\n this.__size = 0;\n this.__store = {};\n}", "title": "" }, { "docid": "736d7896708462263aa836452438cbcf", "score": "0.6506646", "text": "function clear(){\n\t//remove element using innerHTML\n\t\n\t// ul.innerHTML = '';\n\n\t//remove element using removeChild\n\twhile(ul.firstChild){\n\t\tul.removeChild(ul.firstChild);\n\t}\n\tlocalStorage.clear();\n}", "title": "" }, { "docid": "05672c401e29a1c2278329aac3d36094", "score": "0.65058815", "text": "clear() {\n this._store = [];\n }", "title": "" }, { "docid": "e2f90396b86f7510e41a9227bf61d70f", "score": "0.6501528", "text": "function clear() {\n cache = {};\n}", "title": "" }, { "docid": "e2f90396b86f7510e41a9227bf61d70f", "score": "0.6501528", "text": "function clear() {\n cache = {};\n}", "title": "" }, { "docid": "e2f90396b86f7510e41a9227bf61d70f", "score": "0.6501528", "text": "function clear() {\n cache = {};\n}", "title": "" }, { "docid": "37c42aebf126a5c3389b18fa38366d99", "score": "0.64998287", "text": "function clearStorage() {\n localStorage.clear();\n refreshBtnText();\n}", "title": "" }, { "docid": "3072bb0aff3c0fac32cc112f6a1e13fd", "score": "0.6497284", "text": "function resetLibraryContainer() {\n document.querySelector(\".library\").innerHTML = \"\";\n}", "title": "" }, { "docid": "b3af6984cd65b941fadaccb6643136ca", "score": "0.64947826", "text": "function clearFromLocalStorage(){\r\n\r\n // clear from local storage via Clear cart\r\n\r\n localStorage.clear();\r\n}", "title": "" }, { "docid": "5eb1b0e4a7fd91bae5cbccd5d6ed7556", "score": "0.6480129", "text": "function clearAllFromLocalStorage() {\n localStorage.clear();\n}", "title": "" }, { "docid": "f6b01a3ad0c5f6ba541ebe86a3fedfc8", "score": "0.64714354", "text": "clearItems() {\n this._items = [];\n storage.remove(WF_DATA_KEY);\n }", "title": "" }, { "docid": "357fde99bf7a3877eedff8f185cc01af", "score": "0.6468593", "text": "function clean() {\n _cache = {};\n }", "title": "" }, { "docid": "e5e28fd5907457a00daf2328bfd5274d", "score": "0.646572", "text": "function cleanup() {\n if (db) db.close();\n samplecoll = null;\n db = null;\n keysToRemove = [];\n\n if (global.gc) {\n global.gc();\n }\n}", "title": "" }, { "docid": "8d01cef6aed4e755ddf5a0fa0a4af5e2", "score": "0.64636177", "text": "function resetEntries() {\n getStorage().removeItem(storageKey)\n}", "title": "" }, { "docid": "ec4fdb8b15ec7b60424fed30049e0e5b", "score": "0.6452422", "text": "function clear() {\n urls, codeType, rawUrls = null;\n processedImgs.length = 0;\n notFound.length = 0;\n imgsDone = 0;\n}", "title": "" }, { "docid": "0ccd5630309cbe7a9b2ff4d52d052bd8", "score": "0.64416087", "text": "function clear() {\n authenticationData.clear();\n\n sessionStore.remove(storageKey, 'authenticationStore');\n }", "title": "" }, { "docid": "eb615072376662af45ec9909d00502b7", "score": "0.6441462", "text": "function clearMyRecipes() {\n localStorage.removeItem(\"MR\", null);\n loadShoppingList();\n}", "title": "" }, { "docid": "669920754005786ffc8b4077ca555d2e", "score": "0.6437898", "text": "function clear() {\n tests$1 = [];\n fetch = doFetch;\n }", "title": "" }, { "docid": "c6608f58a8ddf0cd6ada03c65a5f99ed", "score": "0.64364505", "text": "clear() {\n this.__data__ = Object.create(null)\n this.size = 0\n }", "title": "" }, { "docid": "733bed13c040a33ccf5b92b01ec8345c", "score": "0.6434219", "text": "function clearStorage() {\n localStorage.removeItem('className');\n localStorage.removeItem('pagerClass');\n localStorage.removeItem('pagerId');\n localStorage.removeItem('annotations');\n localStorage.removeItem('totalPages');\n localStorage.removeItem('data');\n localStorage.removeItem('currentPage');\n localStorage.removeItem('nextUrl');\n}", "title": "" }, { "docid": "c9a7d03a9ce7f2b930cb7a157a075b3d", "score": "0.64312863", "text": "clearAll() {\n this[cacheSymbol] = [];\n this.store.remove(this.namespace);\n }", "title": "" } ]
81170069c296f211f0562bfa7cefca8d
Sends projection/modelview matrices to shader
[ { "docid": "8701ffe0b61345121804980724bfbeb7", "score": "0.65741736", "text": "function setMatrixUniforms() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);\n}", "title": "" } ]
[ { "docid": "4ee2fc29ee7ae39881181c45196e6a11", "score": "0.79027754", "text": "function uploadModelViewMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "b1aeba1ae6dae2c378fc6aa148f336e9", "score": "0.7883579", "text": "function uploadModelViewMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "b1aeba1ae6dae2c378fc6aa148f336e9", "score": "0.7883579", "text": "function uploadModelViewMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "b7512fba2d4f7d18bf530de91996adf9", "score": "0.7867933", "text": "function uploadModelViewMatrixToShader() {\r\n\tgl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "fa313efb52ef049b7ea4cfd49e752cc3", "score": "0.78454214", "text": "function setMatrixUniforms() {\n uploadModelViewMatrixToShader();\n uploadProjectionMatrixToShader();\n \n}", "title": "" }, { "docid": "98cb8d8eea2b4cca2ab513ed6f0ca1ef", "score": "0.7845094", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "98cb8d8eea2b4cca2ab513ed6f0ca1ef", "score": "0.7845094", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "a7cc9d65adccc6938d97a7b59e6eac7e", "score": "0.7806225", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "a7cc9d65adccc6938d97a7b59e6eac7e", "score": "0.7806225", "text": "function uploadModelViewMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "b193b27692c36078c0b7026b4d704816", "score": "0.77918243", "text": "function uploadModelViewMatrixToShader() {\n\tgl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "b193b27692c36078c0b7026b4d704816", "score": "0.77918243", "text": "function uploadModelViewMatrixToShader() {\n\tgl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "94f1c0380b4ff3cd3e2a774268444ae5", "score": "0.7653932", "text": "function uploadProjectionMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform,\r\n false, pMatrix);\r\n gl.uniformMatrix4fv(shaderProgram.inverseViewTransform, false, inverseViewTransform);\r\n}", "title": "" }, { "docid": "6f92bb4215fe9b6b2fa8df3f34a4650e", "score": "0.76015323", "text": "function setMatrixUniforms() {\r\n uploadModelViewMatrixToShader();\r\n uploadNormalMatrixToShader();\r\n uploadProjectionMatrixToShader();\r\n}", "title": "" }, { "docid": "6f92bb4215fe9b6b2fa8df3f34a4650e", "score": "0.76015323", "text": "function setMatrixUniforms() {\r\n uploadModelViewMatrixToShader();\r\n uploadNormalMatrixToShader();\r\n uploadProjectionMatrixToShader();\r\n}", "title": "" }, { "docid": "6f92bb4215fe9b6b2fa8df3f34a4650e", "score": "0.76015323", "text": "function setMatrixUniforms() {\r\n uploadModelViewMatrixToShader();\r\n uploadNormalMatrixToShader();\r\n uploadProjectionMatrixToShader();\r\n}", "title": "" }, { "docid": "cf61c4a19e0efe4e368f5ac7dbf90701", "score": "0.7553701", "text": "function setMatrixUniforms() {\n uploadModelViewMatrixToShader();\n uploadNormalMatrixToShader();\n uploadProjectionMatrixToShader();\n}", "title": "" }, { "docid": "cf61c4a19e0efe4e368f5ac7dbf90701", "score": "0.7553701", "text": "function setMatrixUniforms() {\n uploadModelViewMatrixToShader();\n uploadNormalMatrixToShader();\n uploadProjectionMatrixToShader();\n}", "title": "" }, { "docid": "cf61c4a19e0efe4e368f5ac7dbf90701", "score": "0.7553701", "text": "function setMatrixUniforms() {\n uploadModelViewMatrixToShader();\n uploadNormalMatrixToShader();\n uploadProjectionMatrixToShader();\n}", "title": "" }, { "docid": "cf61c4a19e0efe4e368f5ac7dbf90701", "score": "0.7553701", "text": "function setMatrixUniforms() {\n uploadModelViewMatrixToShader();\n uploadNormalMatrixToShader();\n uploadProjectionMatrixToShader();\n}", "title": "" }, { "docid": "a84d0ff10150f78d59c49f99e152478b", "score": "0.75214463", "text": "function setMatrixUniforms() {\n\tuploadModelViewMatrixToShader();\n\tuploadNormalMatrixToShader();\n\tuploadProjectionMatrixToShader();\n}", "title": "" }, { "docid": "a84d0ff10150f78d59c49f99e152478b", "score": "0.75214463", "text": "function setMatrixUniforms() {\n\tuploadModelViewMatrixToShader();\n\tuploadNormalMatrixToShader();\n\tuploadProjectionMatrixToShader();\n}", "title": "" }, { "docid": "f36ab9e68f6c287c80ed268d4c0faa60", "score": "0.74677914", "text": "function uploadProjectionMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, \r\n false, pMatrix);\r\n}", "title": "" }, { "docid": "3bffd97b56b1d0fee50bc708d11629fc", "score": "0.74601984", "text": "function uploadProjectionMatrixToShader() {\r\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);\r\n}", "title": "" }, { "docid": "9da1bf05928a64c7d55d388d81655c98", "score": "0.7429467", "text": "function drawModel(){\n\t\n\t// Ready to draw\n\n\t// Clear canvas.\n\tgl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\t\n\t// Set Shader program\n\tgl.useProgram(sProgram);\n\t\n\t// Get location for vertex positions and normals\n\tvar posLoc = gl.getAttribLocation(sProgram, \"vPos\");\n\tgl.enableVertexAttribArray(posLoc);\n\tvar normalLoc = gl.getAttribLocation(sProgram, \"vNor\");\n\tgl.enableVertexAttribArray(normalLoc);\n\t\t\n\t// Calculate and send view matrix\n\t//alert(showVec(lookAt));\n\tvar vm = mat4.lookAt(eye,center,up);\n\tvar vm3 = mat4.toMat3(vm);\n\t//var viewMLoc = gl.getUniformLocation(sProgram, \"viewM\");\n\t//gl.uniformMatrix4fv(viewMLoc, false, vm);\n\t\n\t// Calculate and send projection matrix\n\tvar near = 0.1 + diag;\n\tvar far = 5 * diag;\n\tvar oposite = Math.max(max[0] - center[0], max[1] - center[1]);\n\tvar adjacent = (1.5 * diag) - ( (max[2] - min[2]) / 2 );\n\tvar fov = 2 * ( Math.atan(oposite/adjacent) * 180.0 / Math.PI );\n\tvar pm = mat4.perspective(fov, 1.0, near, far);\n\tvar projMLoc = gl.getUniformLocation(sProgram, \"projM\");\n\tgl.uniformMatrix4fv(projMLoc, false, pm);\n\t\n\t// Send the eye\n\tvar eyeLoc = gl.getUniformLocation(sProgram, \"eye\");\n\tgl.uniform3fv(eyeLoc, eye);\n\t\n\t//var normalMatrix = mat3.create();\n\t//var modelMLoc = gl.getUniformLocation(sProgram, \"modelM\");\n\tvar normalMLoc = gl.getUniformLocation(sProgram, \"normalM\");\n\t\n\tvar vmM = mat4.create();\n\tvar vmMLoc = gl.getUniformLocation(sProgram, \"vmM\");\n\t\n\t// Send n k vectors\n\tvar nfLoc = gl.getUniformLocation(sProgram, \"nf\");\n\tvar kfLoc = gl.getUniformLocation(sProgram, \"kf\");\n\tgl.uniform1fv(nfLoc, ct_n);\n\tgl.uniform1fv(kfLoc, ct_k);\n\t\n\t// Send CIE color matching functions\n\tvar cie_colour_matchLoc = gl.getUniformLocation(sProgram, \"cie_colour_match\");\n\tgl.uniform3fv(cie_colour_matchLoc, cie_colour_match);\n\t\n\t// Send XYZ to RGB matrix\n\tvar xyzTOrgbLoc = gl.getUniformLocation(sProgram, \"xyzTOrgb\");\n\tgl.uniformMatrix3fv(xyzTOrgbLoc, false, xyzTOrgbMatrix);\n\t\n\t// Send gamma\n\tvar gammaLoc = gl.getUniformLocation(sProgram, \"gamma\");\n\tgl.uniform1fv(gammaLoc, [colorSystem.gamma]);\n\t\n\t// Activate and sends Textures\n\tenvCubeLoc = gl.getUniformLocation(sProgram, \"envCube\");\n\t//console.log(\"texCube.complete=\" + texCube.complete);\n\tgl.activeTexture(gl.TEXTURE1);\n\tgl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube);\n\tgl.uniform1i(envCubeLoc,1);\n\t\n\t// Render models\n\tfor(var ni = 0; ni < obj.nodes.length; ++ni){\n\t\tvar node = obj.nodes[ni]; // Get actual node\n\t\t\n\t\t// Send node modelmatrix\n\t\t//gl.uniformMatrix4fv(modelMLoc, false, node.modelMatrix);\n\t\t\n\t\t// Calculate and send view-model matrix\n\t\tmat4.multiply(vm,node.modelMatrix,vmM);\n\t\tgl.uniformMatrix4fv(vmMLoc, false, vmM);\n\t\t\n\t\t// Calculate and send normal matrix\n\t\tvar normalMatrix = mat4.toMat3(node.modelMatrix);\n\t\tmat3.inverse(normalMatrix,normalMatrix);\n\t\tmat3.transpose(normalMatrix);\n\t\tmat3.multiply(vm3, normalMatrix, normalMatrix);\n\t\tgl.uniformMatrix3fv(normalMLoc, false, normalMatrix);\n\t\t\n\t\t// For each mesh in node\n\t\tfor(var mi = 0; mi < node.meshIndices.length; ++mi){\n\t\t\tvar mesh_index = node.meshIndices[mi];\n\t\t\tvar mesh = obj.meshes[mesh_index]; // Get actual mesh\n\t\t\t\n\t\t\t// FIX for DijonPalais\n\t\t\tif(mesh.vertexNormals.length == 0) continue;\n\t\t\t\t\t\t\n\t\t\t// Render Mesh\n\t\t\tgl.bindBuffer(gl.ARRAY_BUFFER, buffers[mesh_index].vertex);\n\t\t\tgl.vertexAttribPointer(posLoc, 3, gl.FLOAT, false, 0, 0);\n\t\t\t\n\t\t\tgl.bindBuffer(gl.ARRAY_BUFFER, buffers[mesh_index].normal);\n\t\t\tgl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, true, 0, 0);\n\t\t\t\n\t\t\t// Actual draw\n\t\t\tvar primitives;\n\t\t\tif(buffers[mesh_index].index){\n\t\t\t\tprimitives = mesh.indices.length;\n\t\t\t\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffers[mesh_index].index);\n\t\t\t\tgl.drawElements(gl.TRIANGLES, primitives, gl.UNSIGNED_SHORT, 0);\n\t\t\t}else{\n\t\t\t\tprimitives = mesh.vertexPositions.length/3;\n\t\t\t\tgl.drawArrays(gl.TRIANGLES, 0, primitives);\n\t\t\t}\n\t\t}\n\t}\n\t\n\t// Finish rendering\n}", "title": "" }, { "docid": "c7863e19dfded053419d89dff421cc4b", "score": "0.7363115", "text": "function uploadProjectionMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, \n false, pMatrix);\n}", "title": "" }, { "docid": "5f5cd66620baf5c0d12f99a667d1c21f", "score": "0.73397505", "text": "function uploadProjectionMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform,\n false, pMatrix);\n}", "title": "" }, { "docid": "35369ed1d72f0f84477f22fb32373124", "score": "0.7336535", "text": "function uploadProjectionMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, \n false, pMatrix);\n}", "title": "" }, { "docid": "35369ed1d72f0f84477f22fb32373124", "score": "0.7336535", "text": "function uploadProjectionMatrixToShader() {\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, \n false, pMatrix);\n}", "title": "" }, { "docid": "acf37acb4f5a6529e723bcabd0c6b49f", "score": "0.73150265", "text": "function uploadProjectionMatrixToShader() {\n\tgl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);\n}", "title": "" }, { "docid": "0e3dd466a579a8c3c74c3d058298e8dc", "score": "0.7292448", "text": "function uploadProjectionMatrixToShader() {\n\tgl.uniformMatrix4fv(shaderProgram.pMatrixUniform,\n\tfalse, pMatrix);\n}", "title": "" }, { "docid": "fbbc18daab6f01acd69c0617c16cc774", "score": "0.7125274", "text": "function drawCube(modelMatrix)\n{\n\n // bind the shader\n gl.useProgram(shader);\n\n // get the index for the a_Position attribute defined in the vertex shader\n var positionIndex = gl.getAttribLocation(shader, 'a_Position');\n if (positionIndex < 0) {\n console.log('Failed to get the storage location of a_Position');\n return;\n }\n\n var colorIndex = gl.getAttribLocation(shader, 'a_Color');\n if (colorIndex < 0) {\n\t console.log('Failed to get the storage location of a_');\n\t return;\n\t }\n\n // \"enable\" the a_position attribute\n gl.enableVertexAttribArray(positionIndex);\n gl.enableVertexAttribArray(colorIndex);\n\n // bind buffers for points\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);\n gl.vertexAttribPointer(positionIndex, 3, gl.FLOAT, false, 0, 0);\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);\n gl.vertexAttribPointer(colorIndex, 4, gl.FLOAT, false, 0, 0);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n\n // set uniform in shader for projection * view * model transformation\n var transform = new Matrix4().multiply(projection).multiply(view).multiply(modelMatrix);\n var transformLoc = gl.getUniformLocation(shader, \"transform\");\n gl.uniformMatrix4fv(transformLoc, false, transform.elements);\n\n gl.drawArrays(gl.TRIANGLES, 0, 36);\n\n// // draw axes (not transformed by model transformation)\n// gl.bindBuffer(gl.ARRAY_BUFFER, axisBuffer);\n// gl.vertexAttribPointer(positionIndex, 3, gl.FLOAT, false, 0, 0);\n// gl.bindBuffer(gl.ARRAY_BUFFER, axisColorBuffer);\n// gl.vertexAttribPointer(colorIndex, 4, gl.FLOAT, false, 0, 0);\n// gl.bindBuffer(gl.ARRAY_BUFFER, null);\n//\n// // set transformation to projection * view only\n// transform = new Matrix4().multiply(projection).multiply(view);\n// gl.uniformMatrix4fv(transformLoc, false, transform.elements);\n//\n// // draw axes\n// gl.drawArrays(gl.LINES, 0, 6);\n\n // unbind shader and \"disable\" the attribute indices\n // (not really necessary when there is only one shader)\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n gl.disableVertexAttribArray(positionIndex);\n gl.disableVertexAttribArray(colorIndex);\n gl.useProgram(null);\n\n}", "title": "" }, { "docid": "710fdbeb2f80f8d4fe8071ee90ed0a52", "score": "0.71180606", "text": "function setModelViewMatrix(matrix)\r\n{\r\n gl.uniformMatrix4fv(shaderProgram.uModelViewMatrix, false, matrix);\r\n \r\n var normal_matrix = mat3.create();\r\n mat4.toInverseMat3(matrix, normal_matrix);\r\n mat3.transpose(normal_matrix);\r\n gl.uniformMatrix3fv(shaderProgram.uNormalMatrix, false, normal_matrix);\r\n}", "title": "" }, { "docid": "e4c1cef61d85c112b004f535dec5ee41", "score": "0.7079082", "text": "sendMatrices (gl, locations, modelMatrix) {\n const deg_to_rad = (deg) => deg*Math.PI/180.0;\n let V = mat4.create(); // view\n let P = mat4.create(); // projection\n let VM = mat4.create(); // model-view\n let PVM = mat4.create(); // model-view-perspective\n\n mat4.perspective(P, deg_to_rad(this.fov), this.ar,\n this.near, this.far);\n\n mat4.lookAt(V, this.position, this.lookAt, this.up);\n mat4.invert(V, V);\n\n mat4.multiply(VM, V, modelMatrix);\n mat4.multiply(PVM, P, VM);\n\n gl.uniformMatrix4fv(locations.u_MvpMatrix,\n false, PVM);\n\n this._viewMatrix = V;\n this._projectionMatrix = P;\n }", "title": "" }, { "docid": "659472d7723ff731fc64608deae21e9a", "score": "0.7057311", "text": "setMatrixUniforms() {\n this.calculateNormal();\n this.gl.uniformMatrix4fv(this.program.uModelViewMatrix, false, this.modelViewMatrix);\n this.gl.uniformMatrix4fv(this.program.uProjectionMatrix, false, this.projectionMatrix);\n this.gl.uniformMatrix4fv(this.program.uNormalMatrix, false, this.normalMatrix);\n }", "title": "" }, { "docid": "fa4c029bd6080dcc6a337677397b349f", "score": "0.70436436", "text": "bindAsView() {\n this.pipeline.bind();\n this.gl.uniformMatrix4fv(\n this.pipeline.uniformLocations['uProjectionMatrix'],\n false,\n this.projectionMatrix\n );\n this.gl.uniformMatrix4fv(\n this.pipeline.uniformLocations['uViewMatrix'],\n false,\n this.viewMatrix\n );\n }", "title": "" }, { "docid": "57484b032c43ab16e8143ed6866ece90", "score": "0.6991451", "text": "function setAllMatrices() {\n gl.uniformMatrix4fv(projectionMatrixLoc, false, flatten(projectionMatrix));\n setMV();\n\n}", "title": "" }, { "docid": "57484b032c43ab16e8143ed6866ece90", "score": "0.6991451", "text": "function setAllMatrices() {\n gl.uniformMatrix4fv(projectionMatrixLoc, false, flatten(projectionMatrix));\n setMV();\n\n}", "title": "" }, { "docid": "0d2561eec05063d0c38662a5cc2d74d8", "score": "0.69859844", "text": "function drawMesh(mesh, modelMatrix)\n{\n //vertex attributes\n gl.bindBuffer(gl.ARRAY_BUFFER, mesh.positionBuffer);\n gl.vertexAttribPointer(shaderProgram.vertexPositionHandle, POSITION_DATA_SIZE, gl.FLOAT, false, 0, 0);\n gl.enableVertexAttribArray(shaderProgram.vertexPositionHandle);\n gl.bindBuffer(gl.ARRAY_BUFFER, mesh.normalBuffer);\n gl.vertexAttribPointer(shaderProgram.vertexNormalHandle, NORMAL_DATA_SIZE, gl.FLOAT, false, 0, 0);\n gl.enableVertexAttribArray(shaderProgram.vertexNormalHandle);\n\n //calculate and set normal matrix (just based on model)\n var normalMatrix = mat3.normalFromMat4(mat3.create(), modelMatrix);\n gl.uniformMatrix3fv(shaderProgram.normalMatrixHandle, false, normalMatrix);\n\n //modelview -- calculate and pass\n var MVPmatrix = mat4.mul(mat4.create(), viewMatrix, modelMatrix);\n gl.uniformMatrix4fv(shaderProgram.MVmatrixHandle, false, MVPmatrix);\n\n //pass projection matrix\n gl.uniformMatrix4fv(shaderProgram.PmatrixHandle, false, projectionMatrix);\n\n //draw the model!\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh.indexBuffer);\n gl.drawElements(gl.TRIANGLES, mesh.indexBuffer.numItems, gl.UNSIGNED_SHORT, 0);\n\n}", "title": "" }, { "docid": "c160c40e79094dbda9640a241ce1231a", "score": "0.6968163", "text": "updateBuffer () {\n // Push the matrix to the buffer\n gl.uniformMatrix4fv(modelMatrixLoc, false, new Float32Array(this.modelMatrix));\n\n // TODO: Übergebe hier die Normalenmatrix an den Shader\n gl.uniformMatrix4fv(normalMatrixLoc, false, new Float32Array(this.normalMatrix));\n // TODO: Übergebe hier die Materialkoeffizienten des Objektes an den Shader\n gl.uniform3f(kaLoc, this.ka[0], this.ka[1], this.ka[2]);\n gl.uniform3f(ksLoc, this.ks[0], this.ks[1], this.ks[2]);\n gl.uniform3f(kdLoc, this.kd[0], this.kd[1], this.kd[2]);\n\n gl.uniform1f(withLightningLoc, this.withLightning);\n gl.uniform1f(withTextureLoc, this.withTexture);\n gl.uniform1f(withBumpmapLoc, this.withBumpmap);\n gl.uniform1f(isWaterLoc, this.isWater);\n }", "title": "" }, { "docid": "990c1219aad30841019d7fef77db9c97", "score": "0.6938784", "text": "function draw() { \r\n gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); //viewing angle static\r\n gl.clear(gl.COLOR_BUFFER_BIT);\r\n mat4.identity(mvMatrix);\r\n mat4.rotateY(mvMatrix, mvMatrix, degToRad(rotAngle)); //rotate along the Y axis\r\n mat4.rotateX(mvMatrix, mvMatrix, degToRad(rotAngle)); //rotate along the X axis\r\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexPositionBuffer);\r\n gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, \r\n vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); //draw the mesh\r\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);\r\n gl.vertexAttribPointer(shaderProgram.vertexColorAttribute, \r\n vertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0); //color the mesh\r\n \r\n setMatrixUniforms();\r\n gl.drawArrays(gl.TRIANGLES, 0, vertexPositionBuffer.numberOfItems);\r\n}", "title": "" }, { "docid": "7e4f9537c1a46b062fea5f0b0e8fc5ed", "score": "0.69333786", "text": "function display() {\n // Clear the color buffer\n gl.clear( gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT );\n \n // Set the model-view matrix to the current CameraController rotation\n quat4.toMat4( controller.currentOrientation, mvmat );\n \n // Get the normal matrix from the model-view matrix (for lighting)\n mat4.toInverseMat3( mvmat, nmat );\n mat3.transpose( nmat );\n \n // Use the created shader program\n gl.useProgram(gl_program);\n \n // Upload the projection matrix and the model-view matrix to the shader\n gl.uniformMatrix4fv(gl_program_loc.uPMatrix, false, projmat);\n gl.uniformMatrix4fv(gl_program_loc.uMVMatrix, false, mvmat);\n gl.uniformMatrix3fv(gl_program_loc.uNMatrix, false, nmat);\n gl.uniform3fv(gl_program_loc.uColor, new Float32Array([0.5, 0.5, 0.5]));\n gl.uniform1i(gl_program_loc.uLighting, lighting ? 1 : 0 );\n \n // If there is a model loaded\n if( vbo.length > 0 ) {\n // Bind vbo to be the current array buffer\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n \n // Enables a vertex attribute array for vertex positions\n gl.enableVertexAttribArray(gl_program_loc.aPosition);\n \n // Setup the pointer to the position data\n gl.vertexAttribPointer(gl_program_loc.aPosition, 3, gl.FLOAT, false, 12, 0);\n \n if( line ) {\n // Bind lineIndices to be the current index array buffer\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, lineIndices);\n \n // Finally, draw the data as lines using all of the current settings\n gl.drawElements(gl.LINES, lineIndices.length, gl.UNSIGNED_SHORT, 0);\n } else {\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, triIndices);\n gl.drawElements(gl.TRIANGLES, triIndices.length, gl.UNSIGNED_SHORT, 0);\n }\n }\n}", "title": "" }, { "docid": "5dc2691446809010e5ab4a56cc06f12a", "score": "0.6905342", "text": "function uploadProjectionMatrixToShaderPot() {\n gl.uniformMatrix4fv(potProgram.pMatrixUniform, \n false, pMatrix);\n \n}", "title": "" }, { "docid": "762722ba7b8a343c64896643b28eb949", "score": "0.689629", "text": "updateViewMatrix() {\n var matViewUniformLocation = this.gl.getUniformLocation(this.program, 'mView');\n this.gl.uniformMatrix4fv(matViewUniformLocation, this.gl.FALSE, this.viewMatrix);\n }", "title": "" }, { "docid": "c1019d3e9239b703cf12ec3be356128f", "score": "0.68827945", "text": "setMatrixUniforms()\n\t{\n\t\t\tmat4.identity(mvMatrix);\n\t\t\tmat4.translate(mvMatrix, distCENTER);\n\t\t\tmat4.multiply(mvMatrix, rotMatrix);\n\n\t\t\t// mat4.identity(this.rMatrix);\n\t\t\t// mat4.identity(this.tMatrix);\n\t\t\t// mat4.translate(this.tMatrix, [0, 0.5, 0]);\n\t\t\t// mat4.rotate(this.rMatrix, this.rotObjY, [0, 0, 1]);\n\t\t\t// mat4.rotate(this.rMatrix, this.rotObjX, [1, 0, 0]);\n\n\t\t\tgl.uniformMatrix4fv(this.shader.rMatrixUniform, false, rotMatrix);\n\t\t\tgl.uniformMatrix4fv(this.shader.mvMatrixUniform, false, mvMatrix);\n\t\t\tgl.uniformMatrix4fv(this.shader.pMatrixUniform, false, pMatrix);\n\t\t\tgl.uniformMatrix4fv(this.shader.rObjMatrixUniform, false, this.rMatrix);\n\t\t\tgl.uniformMatrix4fv(this.shader.tObjMatrixUniform, false, this.tMatrix);\n\t}", "title": "" }, { "docid": "95a2e4fca8cfc83c3b9b491cc89e0963", "score": "0.6863638", "text": "draw(gl) {\n let camera = this.engine.camera;\n let pvmMatrix = mat4.create();\n let modelMatrix = mat4.create(); // Creates a blank identity matrix\n \n // Step A: compute translation, for now z is always at 0.0\n mat4.translate(modelMatrix, modelMatrix, vec3.fromValues(this.originX, this.originY, 0.0));\n // Step B: concatenate with rotation.\n // mat4.rotateZ(matrix, matrix, this.getRotationInRad());\n // Step C: concatenate with scaling\n // mat4.scale(modelMatrix, modelMatrix, vec3.fromValues(this.width, this.height, 1.0));\n\n mat4.multiply(pvmMatrix, camera.getPVMatrix(), modelMatrix);\n\n // Activates the vertex buffer\n gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer.id);\n\n Grid.shader.activate(gl);\n // Describe the characteristic of the vertex position attribute\n gl.vertexAttribPointer(Grid.shader.getPositionLocation(),\n 3, // each element is a 3-float (x,y,z)\n gl.FLOAT, // data type is FLOAT\n false, // if the content is normalized vectors\n 0, // number of bytes to skip in between elements\n 0); // offsets to the first element\n\n gl.enableVertexAttribArray(Grid.shader.getPositionLocation());\n gl.uniformMatrix4fv(Grid.shader.getPVMTransformLocation(), false, pvmMatrix);\n gl.uniform4fv(Grid.shader.getColorLocation(), this.color);\n // Grid.shader.activate();\n\n gl.drawArrays(gl.LINES, 0, this.num_lines * 2);\n\n // Activates the vertex buffer\n gl.bindBuffer(gl.ARRAY_BUFFER, this.backgroundVertexBuffer.id);\n gl.vertexAttribPointer(Grid.shader.getPositionLocation(),\n 3, // each element is a 3-float (x,y,z)\n gl.FLOAT, // data type is FLOAT\n false, // if the content is normalized vectors\n 0, // number of bytes to skip in between elements\n 0); // offsets to the first element\n\n gl.enableVertexAttribArray(Grid.shader.getPositionLocation());\n gl.uniformMatrix4fv(Grid.shader.getPVMTransformLocation(), false, pvmMatrix);\n\n // gl.uniform4fv(Grid.shader.getColorLocation(), [0.0, 0.5, 0.0, 1.0]);\n // gl.drawArrays(gl.TRIANGLES, 0, 36);\n\n for(let i = 0; i < this.num_triangles; i += 1) {\n gl.uniform4fv(Grid.shader.getColorLocation(), this.colors[i]);\n // console.log(this.colors[i]);\n // if (i % 2 == 0) {\n // gl.uniform4fv(Grid.shader.getColorLocation(), [0.0, i / this.num_triangles, 0.0, 1.0]);\n // } else {\n // gl.uniform4fv(Grid.shader.getColorLocation(), [0.0, 0.0, i / this.num_triangles, 1.0]);\n // }\n \n gl.drawArrays(gl.TRIANGLES, i * 3, 3);\n }\n }", "title": "" }, { "docid": "be818eb446662f5d7491d6246bed8ab1", "score": "0.6847564", "text": "function draw() { \n gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); \n\n mat4.identity(mvMatrix);\n mat4.identity(pMatrix);\n \n\n var sca = clk2 * 0.005;\n vec3.set(scaleVec, sca * 0.5 +0.5, sca * 0.5 +0.5, 1);\n if ((clk2 < 600)&(clk2 > 200)){ \n mat4.scale(mvMatrix, mvMatrix, scaleVec);\n mat4.rotateZ(mvMatrix, mvMatrix, degToRad(100*sca - 100));\n }\n\n\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexPositionBuffer);\n gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, \n vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0);\n gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);\n gl.vertexAttribPointer(shaderProgram.vertexColorAttribute, \n vertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0);\n \n setMatrixUniforms();\n gl.drawArrays(gl.TRIANGLES, 0, vertexPositionBuffer.numberOfItems);\n}", "title": "" }, { "docid": "cafe723466daf99d96ce1a4417470578", "score": "0.683221", "text": "function update_model_view() {\r\n\tlet mv = mult(rotateZ(thetas[2]), mult(rotateY(thetas[1]), rotateX(thetas[0])));\r\n\tmv = mult(translate(position[0], position[1], position[2]), mv);\r\n\tmv = mult(scalem(cur_scale, cur_scale, cur_scale), mv);\r\n\tgl.uniformMatrix4fv(model_view_loc, false, flatten(mv));\r\n}", "title": "" }, { "docid": "1889952a7007d4c8b259221b06474961", "score": "0.68246734", "text": "function setMatrixUniforms( )\n{\n\n // Pass the vertex shader the projection matrix and the model-view matrix.\n\n gl.uniformMatrix4fv( shaderProgram.pMatrixUniform, false, pMatrix );\n gl.uniformMatrix4fv( shaderProgram.mvMatrixUniform, false, mvMatrix );\n\n // Pass the vertex normal matrix to the shader so it can compute the lighting calculations.\n\n var normalMatrix = mat3.create( );\n mat3.normalFromMat4( normalMatrix, mvMatrix );\n gl.uniformMatrix3fv( shaderProgram.nMatrixUniform, false, normalMatrix );\n\n}", "title": "" }, { "docid": "323e6b626fe51172e0eb269e694cabb6", "score": "0.68232316", "text": "draw()\n\t{\n\t\t//Sends the mvMatrix to the shader\n\t\tglContext.uniformMatrix4fv(prg.mvMatrixUniform, false, this.mvMatrix);\n\n\t\t//Links and sends the vertexBuffer to the shader, defining the format to send it as\n\t\tglContext.bindBuffer(glContext.ARRAY_BUFFER, this.vertexBuffer);\n\t\tglContext.vertexAttribPointer(prg.vertexPositionAttribute, 3, glContext.FLOAT, false, 0, 0);\n\n\t\t//Links and sends the colorBuffer to the shader, defining the format to send it as\n\t\tglContext.bindBuffer(glContext.ARRAY_BUFFER, this.colorBuffer);\n\t\tglContext.vertexAttribPointer(prg.colorAttribute, 4, glContext.FLOAT, false, 0, 0);\n\n\t\t//Links the indexBuffer with the shader\n\t\tglContext.bindBuffer(glContext.ELEMENT_ARRAY_BUFFER, this.indexBuffer);\n\n\t\t//Based on the render variable\n\t\tif(render)\n\t\t{\n\t\t\t//Renders the objet as a wireframe\n\t\t\tglContext.drawElements(glContext.LINES, this.indices.length, glContext.UNSIGNED_SHORT,0);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t//Renders the object as triangles\n\t\t\tglContext.drawElements(glContext.TRIANGLES, this.indices.length, glContext.UNSIGNED_SHORT,0);\n\t\t}\n\t}", "title": "" }, { "docid": "559f2d2a9c7b48cbb3a31d554e8d9bfd", "score": "0.6817077", "text": "function setupVertexShaderMatrix2(){\n var viewMatrixUniform = gl.getUniformLocation(glProgram_helicoptero, \"uVMatrix\");\n var projMatrixUniform = gl.getUniformLocation(glProgram_helicoptero, \"uPMatrix\");\n var normalMatrixUniform = gl.getUniformLocation(glProgram_helicoptero, \"uNMatrix\");\n\n mat3.fromMat4(normalMatrix,matriz_model); // normalMatrix= (inversa(traspuesta(matrizModelado)));\n\n mat3.invert(normalMatrix, normalMatrix);\n mat3.transpose(normalMatrix,normalMatrix);\n\n \n gl.uniformMatrix4fv(viewMatrixUniform, false, viewMatrix);\n gl.uniformMatrix4fv(projMatrixUniform, false, projMatrix);\n //gl.uniformMatrix4fv(normalMatrixUniform, false, normalMatrix);\n gl.uniform3f(glProgram_helicoptero.directionalColorUniform, 1.0, 1.0, 0.8);\n var lightPosition = [0.0,300.0, 10000.0]; \n gl.uniform3fv(glProgram_helicoptero.lightingDirectionUniform, lightPosition); \n}", "title": "" }, { "docid": "1622beed9e9d53ff3e2548b84ceb407a", "score": "0.68158895", "text": "function draw() {\n gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n // We'll use perspective\n mat4.perspective(pMatrix,degToRad(45),\n gl.viewportWidth / gl.viewportHeight,\n 0.1, 200.0);\n\n // We want to look down -z, so create a lookat point in that direction\n vec3.add(viewPt, eyePt, viewDir);\n // Then generate the lookat matrix and initialize the MV matrix to that view\n mat4.lookAt(mvMatrix,eyePt,viewPt,up);\n\n //push current modelview matrix to stack\n mvPush();\n\n // generate transformation\n vec3.set(transformVec, 0.0, -0.25, -2.0);\n //add transformation to modelview\n mat4.translate(mvMatrix, mvMatrix,transformVec);\n // rotate modelview around y\n mat4.rotateY(mvMatrix, mvMatrix, degToRad(viewRot));\n // rotate around x\n mat4.rotateX(mvMatrix, mvMatrix, degToRad(-75));\n // Update the matrix uniforms to hold calculations just performed\n setMatrixUniforms();\n // Send the lighting information to shaders\n setLightUniforms(lightPosition,lAmbient,lDiffuse,lSpecular);\n // send material information to shaders\n setMaterialUniforms(shininess,kAmbient,kTerrainDiffuse,kSpecular);\n // draw the terrain\n myTerrain.drawTriangles();\n // Pop modelview from stack\n mvPop();\n\n\n}", "title": "" }, { "docid": "39bfb7d21749aa2c6cecb51c378a495c", "score": "0.6808126", "text": "function renderModels() {\n // var hMatrix = mat4.create(); // handedness matrix\n var pMatrix = mat4.create(); // projection matrix\n var vMatrix = mat4.create(); // view matrix\n var mMatrix = mat4.create(); // model matrix\n var pvMatrix = mat4.create(); // hand * proj * view matrices\n var pvmMatrix = mat4.create(); // hand * proj * view * model matrices\n \n //window.requestAnimationFrame(renderModels); // set up frame render callback\n \n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); // clear frame/depth buffers\n \n // set up projection and view\n // mat4.fromScaling(hMatrix,vec3.fromValues(-1,1,1)); // create handedness matrix\n mat4.perspective(pMatrix,0.5*Math.PI,1,1,20); // create projection matrix\n mat4.lookAt(vMatrix,Eye,Center,Up); // create view matrix\n mat4.multiply(pvMatrix,pvMatrix,pMatrix); // projection\n mat4.multiply(pvMatrix,pvMatrix,vMatrix); // projection * view\n\n var currSet; // the tri set and its material properties\n for (var whichTriSet=0; whichTriSet<inputTriangles.length; whichTriSet++) {\n currSet = inputTriangles[whichTriSet];\n\n // make model transform, add to view project\n mat4.multiply(pvmMatrix,pvMatrix,mMatrix); // project * view * model\n gl.uniformMatrix4fv(mMatrixULoc, false, mMatrix); // pass in the m matrix\n gl.uniformMatrix4fv(pvmMatrixULoc, false, pvmMatrix); // pass in the hpvm matrix\n \n // reflectivity: feed to the fragment shader\n gl.uniform3fv(ambientULoc,currSet.material.ambient); // pass in the ambient reflectivity\n gl.uniform3fv(diffuseULoc,currSet.material.diffuse); // pass in the diffuse reflectivity\n gl.uniform3fv(specularULoc,currSet.material.specular); // pass in the specular reflectivity\n gl.uniform1f(shininessULoc,currSet.material.n); // pass in the specular exponent\n\n // vertex buffer: activate and feed into vertex shader\n gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffers[whichTriSet]); // activate\n gl.vertexAttribPointer(vPosAttribLoc,3,gl.FLOAT,false,0,0); // feed\n gl.bindBuffer(gl.ARRAY_BUFFER,normalBuffers[whichTriSet]); // activate\n gl.vertexAttribPointer(vNormAttribLoc,3,gl.FLOAT,false,0,0); // feed\n gl.vertexAttribPointer(tPosAttribLoc,2,gl.FLOAT,false,0,0); // feed\n \n // triangle buffer: activate and render\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,triangleBuffers[whichTriSet]); // activate\n gl.drawElements(gl.TRIANGLES,3*triSetSizes[whichTriSet],gl.UNSIGNED_SHORT,0); // render\n \n } // end for each triangle set\n\n\n} // end render model", "title": "" }, { "docid": "861bc9b59414c66e76bfa43368dcc23f", "score": "0.6804443", "text": "function setMV() {\n modelViewMatrix = mult(viewMatrix, modelMatrix);\n gl.uniformMatrix4fv(modelViewMatrixLoc, false, flatten(modelViewMatrix));\n normalMatrix = inverseTranspose(modelViewMatrix);\n gl.uniformMatrix4fv(normalMatrixLoc, false, flatten(normalMatrix));\n}", "title": "" }, { "docid": "861bc9b59414c66e76bfa43368dcc23f", "score": "0.6804443", "text": "function setMV() {\n modelViewMatrix = mult(viewMatrix, modelMatrix);\n gl.uniformMatrix4fv(modelViewMatrixLoc, false, flatten(modelViewMatrix));\n normalMatrix = inverseTranspose(modelViewMatrix);\n gl.uniformMatrix4fv(normalMatrixLoc, false, flatten(normalMatrix));\n}", "title": "" }, { "docid": "8f563780c0f7e4c13daa466567f4acc7", "score": "0.67895573", "text": "function uploadMVMatrix(){\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "2e3dae825cae0704889004079667055c", "score": "0.6782328", "text": "function setupVertexShaderMatrix(){ \n var viewMatrixUniform = gl.getUniformLocation(glProgram_terreno, \"uVMatrix\");\n var projMatrixUniform = gl.getUniformLocation(glProgram_terreno, \"uPMatrix\");\n var modMatrixUniform = gl.getUniformLocation(glProgram_terreno, \"uMMatrix\");\n\n var normalMatrix2 = mat3.create();\n mat3.fromMat4(normalMatrix2,matriz_model_terreno); // normalMatrix= (inversa(traspuesta(matrizModelado)));\n\n mat3.invert(normalMatrix2, normalMatrix2);\n mat3.transpose(normalMatrix2,normalMatrix2);\n\n //gl.uniformMatrix3fv(glProgram_terreno.nMatrixUniform, false, normalMatrix2);\n \n gl.uniformMatrix4fv(viewMatrixUniform, false, viewMatrix);\n gl.uniformMatrix4fv(projMatrixUniform, false, projMatrix);\n\n gl.uniform1f(glProgram_terreno.frameUniform, time/10.0 );\n gl.uniform3f(glProgram_terreno.ambientColorUniform, 0.0, 0.0, 0.0 );\n gl.uniform3f(glProgram_terreno.directionalColorUniform, 1.0, 1.0, 0.8);\n gl.uniform3f(glProgram_terreno.directionalColorUniform2, 0.2, 0.2, 0.2);\n gl.uniform1i(glProgram_terreno.useLightingUniform,true);\n\n var lightPosition = [0.0,0.0, -1.0]; \n var lightPosition2 = [0.0,300.0, 0.0]; \n gl.uniform3fv(glProgram_terreno.lightingDirectionUniform, lightPosition); \n gl.uniform3fv(glProgram_terreno.lightingDirectionUniform2, lightPosition2);\n \n}", "title": "" }, { "docid": "c81b0eef9432e7c08ddb5e94f9cad1ad", "score": "0.6761296", "text": "function d$2(o,r){o.include(o$7),o.vertex.include(r$b,r),o.varyings.add(\"vPositionWorldCameraRelative\",\"vec3\"),o.varyings.add(\"vPosition_view\",\"vec3\"),o.vertex.uniforms.add(\"uTransform_WorldFromModel_RS\",\"mat3\"),o.vertex.uniforms.add(\"uTransform_WorldFromModel_TH\",\"vec3\"),o.vertex.uniforms.add(\"uTransform_WorldFromModel_TL\",\"vec3\"),o.vertex.uniforms.add(\"uTransform_WorldFromView_TH\",\"vec3\"),o.vertex.uniforms.add(\"uTransform_WorldFromView_TL\",\"vec3\"),o.vertex.uniforms.add(\"uTransform_ViewFromCameraRelative_RS\",\"mat3\"),o.vertex.uniforms.add(\"uTransform_ProjFromView\",\"mat4\"),o.vertex.code.add(t$i`vec3 positionWorldCameraRelative() {\nvec3 rotatedModelPosition = uTransform_WorldFromModel_RS * positionModel();\nvec3 transform_CameraRelativeFromModel = dpAdd(\nuTransform_WorldFromModel_TL,\nuTransform_WorldFromModel_TH,\n-uTransform_WorldFromView_TL,\n-uTransform_WorldFromView_TH\n);\nreturn transform_CameraRelativeFromModel + rotatedModelPosition;\n}\nvec3 position_view() {\nreturn uTransform_ViewFromCameraRelative_RS * positionWorldCameraRelative();\n}\nvoid forwardPosition() {\nvPositionWorldCameraRelative = positionWorldCameraRelative();\nvPosition_view = position_view();\ngl_Position = uTransform_ProjFromView * vec4(vPosition_view, 1.0);\n}\nvec3 positionWorld() {\nreturn uTransform_WorldFromView_TL + vPositionWorldCameraRelative;\n}`),o.fragment.uniforms.add(\"uTransform_WorldFromView_TL\",\"vec3\"),o.fragment.code.add(t$i`vec3 positionWorld() {\nreturn uTransform_WorldFromView_TL + vPositionWorldCameraRelative;\n}`);}", "title": "" }, { "docid": "7ff05c6faca201a5390efa3dfd413296", "score": "0.6760873", "text": "world2canvas(modelMatrix, viewMatrix, projectionMatrix) {\n // https://webglfundamentals.org/webgl/lessons/webgl-text-html.html\n // We just got through computing a matrix to draw our\n // F in 3D.\n\n // compute a clip space position\n // using the matrix we computed for the F\n const clipspace = vec4.create()\n\n // duplicate in programHelper\n const modelViewMatrix = mat4.create();\n mat4.multiply(modelViewMatrix, viewMatrix, modelMatrix);\n const mvpMatrix = mat4.create();\n mat4.multiply(mvpMatrix, projectionMatrix, modelViewMatrix);\n\n vec4.transformMat4(clipspace, [0.5, 0.5, 0.5, 1], mvpMatrix);\n\n if (clipspace[3] < 0)\n return null\n // divide X and Y by W just like the GPU does.\n clipspace[0] /= clipspace[3];\n clipspace[1] /= clipspace[3];\n\n // convert from clipspace to pixels\n var pixelX = (clipspace[0] * 0.5 + 0.5) * gl.canvas.width;\n var pixelY = (clipspace[1] * -0.5 + 0.5) * gl.canvas.height;\n\n if (pixelX < 0 || pixelX > gl.canvas.width)\n return null\n if (pixelY < 0 || pixelY > gl.canvas.height)\n return null\n\n // position the div\n // div.style.left = Math.floor(pixelX) + \"px\";\n //div.style.top = Math.floor(pixelY) + \"px\";\n //textNode.nodeValue = clock.toFixed(2);\n return { x: Math.floor(pixelX), y: Math.floor(pixelY), z: clipspace[3] }\n }", "title": "" }, { "docid": "52e2518b83da012d3bfe2c09f0da5887", "score": "0.6755337", "text": "function drawScene() {\n\n\tvar pMatrix;\n\tvar mvMatrix = mat4();\n\tvar viewMatrix = mat4();\n\n\n\t// Clearing the frame-buffer and the depth-buffer\n\n\tgl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n\t// Computing the Projection Matrix\n\t//perpesctive-----------------------------\n\n\t// Viewer is at (0,0,0)\n\n\t// Ensure that the model is \"inside\" the view volume\n\t//pMatrix = ortho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );\t\t\n\n\n\n\n\tpMatrix = perspective(45, 1, 0.05, 100);\n\t// Passing the Projection Matrix to apply the current projection\n\n\tvar pUniform = gl.getUniformLocation(shaderProgram, \"uPMatrix\");\n\n\tgl.uniformMatrix4fv(pUniform, false, new Float32Array(flatten(pMatrix)));\n\n\n\n\n\t// NEW --- Passing the viewer position to the vertex shader\n\t//gl.uniform4fv( gl.getUniformLocation(shaderProgram, \"pos_Viewer\"), flatten(pos_Viewer) );\n\n\n\t// GLOBAL TRANSFORMATION FOR THE WHOLE SCENE\n\n\tviewMatrix = mult(viewMatrix, rotationXXMatrix(-pitch));\n\n\tviewMatrix = mult(viewMatrix, rotationYYMatrix(-yaw));\n\n\tviewMatrix = mult(viewMatrix, translationMatrix(tx, ty, tz));\n\tmvMatrix = mult(viewMatrix, mvMatrix);\n\n\n\n\t// NEW - Updating the position of the light sources, if required\n\n\t// FOR EACH LIGHT SOURCE\n\n\tfor (var i = 0; i < lightSources.length; i++) {\n\t\t// Animating the light source, if defined\n\n\t\tvar lightSourceMatrix = mat4();\n\n\t\tif (!lightSources[i].isOff()) {\n\n\t\t\tif (customLight) {\n\t\t\t\t\n\t\t\t\tlightSourceMatrix = mult(\n\t\t\t\t\tlightSourceMatrix,\n\t\t\t\t\trotationYYMatrix(lightSources[i].getRotAngleYY()));\n\n\t\t\t\tlightSourceMatrix = mult(\n\t\t\t\t\tlightSourceMatrix,\n\t\t\t\t\trotationXXMatrix(lightSources[i].getRotAngleXX()));\n\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//static\n\t\t\t\tif (lightSources[i].isRotXXOn()) {\n\n\t\t\t\t\tlightSourceMatrix = mult(lightSourceMatrix, rotationXXMatrix(-pitch));\n\n\t\t\t\t}\n\t\t\t\tif (lightSources[i].isRotYYOn()) {\n\n\n\t\t\t\t\tlightSourceMatrix = mult(lightSourceMatrix, rotationYYMatrix(-yaw));\n\n\n\t\t\t\t}\n\t\t\t\tlightSourceMatrix = mult(lightSourceMatrix, translationMatrix(tx, ty, tz));\n\n\n\t\t\t}\n\n\n\n\t\t}\n\n\t\t// NEW Passing the Light Souree Matrix to apply\n\n\t\tvar lsmUniform = gl.getUniformLocation(shaderProgram, \"allLights[\" + String(i) + \"].lightSourceMatrix\");\n\n\t\tgl.uniformMatrix4fv(lsmUniform, false, new Float32Array(flatten(lightSourceMatrix)));\n\t}\n\n\t// Instantianting the current model\n\n\tdrawModel(angleXX, angleYY, angleZZ,\n\t\tsx, sy, sz,\n\t\ttx, ty, tz,\n\t\tmvMatrix,\n\t\tprimitiveType);\n\n\n\n\n\n\t// NEW - Counting the frames\n\n\tcountFrames();\n\n}", "title": "" }, { "docid": "fa676c969f1d7318458c8015ba594a57", "score": "0.6740275", "text": "function uploadNormalMatrixToShader() {\r\n mat3.fromMat4(nMatrix,mvMatrix);\r\n mat3.transpose(nMatrix,nMatrix);\r\n mat3.invert(nMatrix,nMatrix);\r\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix);\r\n}", "title": "" }, { "docid": "3cc730678962dca1feb25088fe2180ba", "score": "0.6736375", "text": "updateMatrices() {\n this.projection = perspective(this.fieldOfViewY, this.aspect, this.near, this.far);\n const up = vec3(0, 1, 0);\n this.view = lookAt(this.eye, this.at, up);\n this.viewProjection = mult(this.projection, this.view);\n }", "title": "" }, { "docid": "b4c95f13fdeba454183e9ce79b3e25ea", "score": "0.6724962", "text": "function uploadNormalMatrixToShader() {\r\n mat3.fromMat4(nMatrix,mvMatrix);\r\n mat3.transpose(nMatrix,nMatrix);\r\n mat3.invert(nMatrix,nMatrix);\r\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix);\r\n}", "title": "" }, { "docid": "b4c95f13fdeba454183e9ce79b3e25ea", "score": "0.6724962", "text": "function uploadNormalMatrixToShader() {\r\n mat3.fromMat4(nMatrix,mvMatrix);\r\n mat3.transpose(nMatrix,nMatrix);\r\n mat3.invert(nMatrix,nMatrix);\r\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix);\r\n}", "title": "" }, { "docid": "630fe75e3a4fa85326f465707c9f2f47", "score": "0.6710349", "text": "function __draw() {\n\n mat4.multiply(__modelMatrix, __translationMatrix, __rotationMatrix);\n mat4.multiply(__modelMatrix, __modelMatrix, __scaleMatrix);\n\n // calculate the inverse transformation that will remove caused by transforming the 3D surface\n mat3.normalFromMat4(__normalMatrix, __modelMatrix);\n\n mat4.multiply(__PVMMatrix, _glProgram.customAttribs.viewMatrix, __modelMatrix);\n mat4.multiply(__PVMMatrix, _glProgram.customAttribs.perspectiveMatrix, __PVMMatrix);\n\n __shouldUpdateMatrices = false;\n\n _gl.uniformMatrix3fv(_glProgram.customAttribs.u_NormalMatrixRef, false, __normalMatrix);\n _gl.uniformMatrix4fv(_glProgram.customAttribs.u_PVMMatrixRef, false, __PVMMatrix);\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, __quadVertexPositionBuffer);\n _gl.vertexAttribPointer(_glProgram.customAttribs.a_PositionRef, __quadVertexPositionBuffer.itemSize, _gl.FLOAT, false, 0, 0);\n _gl.enableVertexAttribArray(_glProgram.customAttribs.a_PositionRef);\n\n _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, __quadVertexIndexBuffer);\n\n _gl.bindBuffer(_gl.ARRAY_BUFFER, __quadVertexNormalBuffer);\n _gl.vertexAttribPointer(_glProgram.customAttribs.a_VertexNormalRef, __quadVertexNormalBuffer.itemSize, _gl.FLOAT, false, 0, 0);\n _gl.enableVertexAttribArray(_glProgram.customAttribs.a_VertexNormalRef);\n\n _gl.uniform4f(_glProgram.customAttribs.u_FragColourRef, __colour.r, __colour.g, __colour.b, __colour.a);\n\n _gl.drawElements(_gl.TRIANGLES, __quadVertexIndexBuffer.numItems, _gl.UNSIGNED_SHORT, 0);\n\n }", "title": "" }, { "docid": "1ab3cd42ee6763974edd5c3cc5d0e27d", "score": "0.6706597", "text": "function uploadNormalMatrixToShader() {\n\tnMatrix = mvMatrix\n\tmat4.transpose(nMatrix,nMatrix);\n\tmat4.invert(nMatrix,nMatrix);\n\tgl.uniformMatrix4fv(shaderProgram.nMatrixUniform, false, nMatrix);\n}", "title": "" }, { "docid": "92925e23ac18bc444ee1e1657f8d838c", "score": "0.6697823", "text": "draw() {\n \n //gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, this.vBuffer );\n let vPosition = gl.getAttribLocation( program, \"vPosition\" );\n gl.vertexAttribPointer( vPosition, 4, gl.FLOAT, false, 0, 0 );\n gl.enableVertexAttribArray( vPosition );\n\n gl.bindBuffer(gl.ARRAY_BUFFER, this.cBuffer ); \n let vColor = gl.getAttribLocation( program, \"vColor\" );\n gl.vertexAttribPointer( vColor, 4, gl.FLOAT, false, 0, 0 );\n gl.enableVertexAttribArray( vColor );\n\n let location = gl.getUniformLocation(program, \"mat\");\n gl.uniformMatrix4fv(location, false, flatten(this.mat));\n \n\n gl.drawArrays(this.drawMode, 0 , this.numVertices);\n\n }", "title": "" }, { "docid": "a470c5faa028949c45ae194a537d8e15", "score": "0.669077", "text": "setProjectionMatrix() {\n\n if( this.projType === \"perspective\") {\n const aspect = this.width / this.height;\n mat4.perspective(this.projMatrix, glMatrix.toRadian(45.0), aspect, 0.1, 1000.0);\n }\n\n if( this.projType === \"orthographic\"){\n mat4.ortho(this.projMatrix, -(this.width/this.height), (this.width/this.height), -1,1,0.5,1000.0);\n }\n }", "title": "" }, { "docid": "f0943499ecc35f58e1c0b23376efb491", "score": "0.66885936", "text": "function setMatrixUniforms() {\r\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "f8e61a8df972b0589ebfdd8e6ce0b40d", "score": "0.6671891", "text": "function updateMVP() {\n\n\tviewMatrix_value = SC.getViewMatrix(); // obtain the new view matrix from camera\n\tmvMatrix_value = mat4.create(); // Reset to identity matrix\n\tmvpMatrix_value = mat4.create();\n\tnormalMatrix_value = mat3.create();\n\n\t// Obtain the ModelView Matrix\n\tmat4.multiply(mvMatrix_value, modelMatrix_value, mvMatrix_value);\n\tmat4.multiply(mvMatrix_value, viewMatrix_value, mvMatrix_value);\n\n\t// Based on MV, obtain MVP\n\tmat4.multiply(mvpMatrix_value, mvMatrix_value, mvpMatrix_value);\n\tmat4.multiply(mvpMatrix_value, projMatrix_value, mvpMatrix_value);\n\n\t// Based on MV, obtain Normal Matrix\n\tmat3.fromMat4(normalMatrix_value, mvMatrix_value);\n\tmat3.invert(normalMatrix_value, normalMatrix_value);\n\tmat3.transpose(normalMatrix_value, normalMatrix_value);\n\n\t// Update the graphics card with the latest values\n\tgl.useProgram(shader_program);\n\tgl.uniformMatrix4fv(viewMatrix_location, gl.FALSE, viewMatrix_value);\n\tgl.uniformMatrix4fv(mvMatrix_location, gl.FALSE, mvMatrix_value);\n\tgl.uniformMatrix4fv(mvpMatrix_location, gl.FALSE, mvpMatrix_value);\n\tgl.uniformMatrix3fv(normalMatrix_location, false, normalMatrix_value);\n\tgl.useProgram(null);\n}", "title": "" }, { "docid": "61540607a32d881359d8370b9d559e0e", "score": "0.6643985", "text": "function draw() {\n gl.viewport(0, 0, c_width, c_height);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n transforms.updatePerspective();\n\n try{\n for (var i = 0; i < Scene.objects.length; i++){\n\n var object = Scene.objects[i];\n\n if (object.hidden == true) continue;\n\n transforms.calculateModelView();\n transforms.push();\n transforms.setMatrixUniforms();\n transforms.pop();\n\n //Setting uniforms\n gl.uniform4fv(Program.uMaterialDiffuse, object.diffuse);\n gl.uniform4fv(Program.uMaterialAmbient, object.ambient);\n gl.uniform1i(Program.uWireframe,object.wireframe);\n\n\n //Setting attributes\n gl.enableVertexAttribArray(Program.aVertexPosition);\n gl.disableVertexAttribArray(Program.aVertexNormal);\n gl.disableVertexAttribArray(Program.aVertexColor);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, object.vbo);\n gl.vertexAttribPointer(Program.aVertexPosition, 3, gl.FLOAT, false, 0, 0);\n gl.enableVertexAttribArray(Program.aVertexPosition);\n\n gl.uniform1i(Program.uUseVertexColor, useVertexColors);\n\n if (object.scalars != null && useVertexColors){\n gl.enableVertexAttribArray(Program.aVertexColor);\n gl.bindBuffer(gl.ARRAY_BUFFER, object.cbo);\n gl.vertexAttribPointer(Program.aVertexColor, 4, gl.FLOAT, false, 0, 0);\n\n }\n\n\n if(!object.wireframe){\n gl.bindBuffer(gl.ARRAY_BUFFER, object.nbo);\n gl.vertexAttribPointer(Program.aVertexNormal, 3, gl.FLOAT, false, 0, 0);\n gl.enableVertexAttribArray(Program.aVertexNormal);\n }\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, object.ibo);\n\n if (object.wireframe){\n gl.drawElements(gl.LINES, object.indices.length, gl.UNSIGNED_SHORT,0);\n }\n else{\n gl.drawElements(gl.TRIANGLES, object.indices.length, gl.UNSIGNED_SHORT,0);\n }\n\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n\n }\n }\n catch(err){\n alert(err);\n console.error(err.description);\n }\n}", "title": "" }, { "docid": "ae64ece7f4669ed3f3ad8fc4074ddee9", "score": "0.6641792", "text": "renderModels(obj)\n {\n obj.rotateobj(obj.Up,1,0);\n obj.rotateobj(obj.Up,1,1);\n\n function makeModelTransform(currModel)\n {\n var zAxis = vec3.create(), sumRotation = mat4.create(), temp = mat4.create(), negCenter = vec3.create();\n\n vec3.normalize(zAxis,vec3.cross(zAxis,currModel.xAxis,currModel.yAxis)); // get the new model z axis\n mat4.set(sumRotation, // get the composite rotation\n currModel.xAxis[0], currModel.yAxis[0], zAxis[0], 0,\n currModel.xAxis[1], currModel.yAxis[1], zAxis[1], 0,\n currModel.xAxis[2], currModel.yAxis[2], zAxis[2], 0,\n 0, 0, 0, 1);\n vec3.negate(negCenter,currModel.center);\n mat4.multiply(sumRotation,sumRotation,mat4.fromTranslation(temp,negCenter)); // rotate * -translate\n mat4.multiply(sumRotation,mat4.fromTranslation(temp,currModel.center),sumRotation); // translate * rotate * -translate\n mat4.fromTranslation(mMatrix,currModel.translation); // translate in model matrix\n mat4.multiply(mMatrix,mMatrix,sumRotation); // rotate in model matrix\n } // end make model transform\n\n var hMatrix = mat4.create(); // handedness matrix\n var pMatrix = mat4.create(); // projection matrix\n var vMatrix = mat4.create(); // view matrix\n var mMatrix = mat4.create(); // model matrix\n var hpvMatrix = mat4.create(); // hand * proj * view matrices\n var hpvmMatrix = mat4.create(); // hand * proj * view * model matrices\n const HIGHLIGHTMATERIAL =\n {ambient:[0.5,0.5,0], diffuse:[0.5,0.5,0], specular:[0,0,0], n:1, alpha:1, texture:false}; // hlht mat\n\n window.requestAnimationFrame(function()\n {\n obj.renderModels(obj);\n }\n ); // set up frame render callback\n\n obj.gl.clear(obj.gl.DEPTH_BUFFER_BIT); // clear frame/depth buffers\n\n // set up handedness, projection and view\n mat4.fromScaling(hMatrix,vec3.fromValues(-1,1,1)); // create handedness matrix\n //mat4.perspective(pMatrix,0.45*Math.PI,1,0.1,10); // create projection matrix\n mat4.ortho(pMatrix,1,-1,-1,1,0.0,10);\n mat4.lookAt(vMatrix,obj.Eye,obj.Center,obj.Up); // create view matrix\n mat4.multiply(hpvMatrix,hMatrix,pMatrix); // handedness * projection\n mat4.multiply(hpvMatrix,hpvMatrix,vMatrix); // handedness * projection * view\n\n // render each triangle set\n var currSet, setMaterial; // the tri set and its material properties\n for (var whichTriSet=0; whichTriSet<obj.numTriangleSets; whichTriSet++)\n {\n currSet = obj.inputTriangles[whichTriSet];\n // make model transform, add to view project\n makeModelTransform(currSet);\n mat4.multiply(hpvmMatrix,hpvMatrix,mMatrix); // handedness * project * view * model\n obj.gl.uniformMatrix4fv(obj.mMatrixULoc, false, mMatrix); // pass in the m matrix\n obj.gl.uniformMatrix4fv(obj.pvmMatrixULoc, false, hpvmMatrix); // pass in the hpvm matrix\n\n // reflectivity: feed to the fragment shader\n if (obj.inputTriangles[whichTriSet].on)\n setMaterial = HIGHLIGHTMATERIAL; // highlight material\n else\n setMaterial = currSet.material; // normal material\n obj.gl.uniform3fv(obj.ambientULoc,setMaterial.ambient); // pass in the ambient reflectivity\n obj.gl.uniform3fv(obj.diffuseULoc,setMaterial.diffuse); // pass in the diffuse reflectivity\n obj.gl.uniform3fv(obj.specularULoc,setMaterial.specular); // pass in the specular reflectivity\n obj.gl.uniform1f(obj.shininessULoc,setMaterial.n); // pass in the specular exponent\n obj.gl.uniform1i(obj.usingTextureULoc,(currSet.material.texture != false)); // whether the set uses texture\n obj.gl.activeTexture(obj.gl.TEXTURE0); // bind to active texture 0 (the first)\n obj.gl.bindTexture(obj.gl.TEXTURE_2D, obj.textures[whichTriSet]); // bind the set's texture\n obj.gl.uniform1i(obj.textureULoc, 0); // pass in the texture and active texture 0\n\n // position, normal and uv buffers: activate and feed into vertex shader\n obj.gl.bindBuffer(obj.gl.ARRAY_BUFFER,obj.vertexBuffers[whichTriSet]); // activate position\n obj.gl.vertexAttribPointer(obj.vPosAttribLoc,3,obj.gl.FLOAT,false,0,0); // feed\n obj.gl.bindBuffer(obj.gl.ARRAY_BUFFER,obj.normalBuffers[whichTriSet]); // activate normal\n obj.gl.vertexAttribPointer(obj.vNormAttribLoc,3,obj.gl.FLOAT,false,0,0); // feed\n obj.gl.bindBuffer(obj.gl.ARRAY_BUFFER,obj.uvBuffers[whichTriSet]); // activate uv\n obj.gl.vertexAttribPointer(obj.vUVAttribLoc,2,obj.gl.FLOAT,false,0,0); // feed\n\n // triangle buffer: activate and render\n obj.gl.bindBuffer(obj.gl.ELEMENT_ARRAY_BUFFER,obj.triangleBuffers[whichTriSet]); // activate\n obj.gl.drawElements(obj.gl.TRIANGLES,3*obj.triSetSizes[whichTriSet],obj.gl.UNSIGNED_SHORT,0); // render\n\n } // end for each triangle set\n\n // render each sphere\n var sphere, currentMaterial, instanceTransform = mat4.create(); // the current sphere and material\n obj.gl.bindBuffer(obj.gl.ARRAY_BUFFER,obj.vertexBuffers[obj.vertexBuffers.length-1]); // activate vertex buffer\n obj.gl.vertexAttribPointer(obj.vPosAttribLoc,3,obj.gl.FLOAT,false,0,0); // feed vertex buffer to shader\n obj.gl.bindBuffer(obj.gl.ARRAY_BUFFER,obj.normalBuffers[obj.normalBuffers.length-1]); // activate normal buffer\n obj.gl.vertexAttribPointer(obj.vNormAttribLoc,3,obj.gl.FLOAT,false,0,0); // feed normal buffer to shader\n obj.gl.bindBuffer(obj.gl.ARRAY_BUFFER,obj.uvBuffers[obj.uvBuffers.length-1]); // activate uv\n obj.gl.vertexAttribPointer(obj.vUVAttribLoc,2,obj.gl.FLOAT,false,0,0); // feed\n obj.gl.bindBuffer(obj.gl.ELEMENT_ARRAY_BUFFER,obj.triangleBuffers[obj.triangleBuffers.length-1]); // activate tri buffer\n\n for (var whichSphere=0; whichSphere<obj.numSpheres; whichSphere++)\n {\n sphere = obj.inputSpheres[whichSphere];\n\n // define model transform, premult with pvmMatrix, feed to shader\n makeModelTransform(sphere);\n mat4.fromTranslation(instanceTransform,vec3.fromValues(sphere.x,sphere.y,sphere.z)); // recenter sphere\n mat4.scale(mMatrix,mMatrix,vec3.fromValues(sphere.r,sphere.r,sphere.r)); // change size\n mat4.multiply(mMatrix,instanceTransform,mMatrix); // apply recenter sphere\n hpvmMatrix = mat4.multiply(hpvmMatrix,hpvMatrix,mMatrix); // premultiply with hpv matrix\n obj.gl.uniformMatrix4fv(obj.mMatrixULoc, false, mMatrix); // pass in model matrix\n obj.gl.uniformMatrix4fv(obj.pvmMatrixULoc, false, hpvmMatrix); // pass in handed project view model matrix\n\n // reflectivity: feed to the fragment shader\n if (sphere.on)\n currentMaterial = HIGHLIGHTMATERIAL;\n else\n currentMaterial = sphere;\n obj.gl.uniform3fv(obj.ambientULoc,currentMaterial.ambient); // pass in the ambient reflectivity\n obj.gl.uniform3fv(obj.diffuseULoc,currentMaterial.diffuse); // pass in the diffuse reflectivity\n obj.gl.uniform3fv(obj.specularULoc,currentMaterial.specular); // pass in the specular reflectivity\n obj.gl.uniform1f(obj.shininessULoc,currentMaterial.n); // pass in the specular exponent\n obj.gl.uniform1i(obj.usingTextureULoc,(sphere.texture != false)); // whether the sphere uses texture\n obj.gl.activeTexture(obj.gl.TEXTURE0); // bind to active texture 0 (the first)\n obj.gl.bindTexture(obj.gl.TEXTURE_2D, obj.textures[obj.numTriangleSets+whichSphere]); // bind the set's texture\n obj.gl.uniform1i(obj.textureULoc, 0); // pass in the texture and active texture 0\n\n obj.gl.drawElements(obj.gl.TRIANGLES,obj.triSetSizes[obj.triSetSizes.length-1],obj.gl.UNSIGNED_SHORT,0); // render\n }\n }", "title": "" }, { "docid": "9215fdb3a4a3e9d3d66e965cebab10b3", "score": "0.66409147", "text": "function uploadNormalMatrixToShader() {\n mat3.fromMat4(nMatrix,mvMatrix);\n mat3.transpose(nMatrix,nMatrix);\n mat3.invert(nMatrix,nMatrix);\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix);\n}", "title": "" }, { "docid": "ee65ea205ba3ffce9da158ad9d2decaa", "score": "0.6634936", "text": "function setMatrixUniforms() {\n\tgl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);\n\tgl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "dcb4cbb5b87a1aacdeeee149337770b1", "score": "0.66328573", "text": "render() {\n // Clear the geometry onscreen\n this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);\n\n for (var i = 0; i < this.scene.geometries.length; i++) {\n var geometry = this.scene.geometries[i];\n\n // Switch to shader attached to geometry\n this.gl.useProgram(geometry.shader.program);\n this.gl.program = geometry.shader.program;\n\n geometry.shader.setUniform(\"u_ViewMatrix\", this.camera.viewMatrix.elements);\n geometry.shader.setUniform(\"u_ProjectionMatrix\", this.camera.projectionMatrix.elements);\n //geometry.shader.setUniform(\"u_ModelMatrix\", this.camera.modelMatrix.elements);\n\n if(geometry.image != null) {\n if(!(geometry.image.src in this.textures)) {\n // Create a texture object and store id using its path as key\n this.textures[geometry.image.src] = this.gl.createTexture();\n this.loadTexture(this.textures[geometry.image.src], geometry.image);\n }\n else {\n // Enable texture unit0\n this.gl.activeTexture(this.gl.TEXTURE0);\n // Bind the texture object to the target\n this.gl.bindTexture(this.gl.TEXTURE_2D, this.textures[geometry.image.src]);\n }\n }\n\n // Callback function in the case user wants to change the\n // geometry before the draw call\n geometry.render();\n\n // Set attribute buffer with the geometry data\n this.sendVertexDataToGLSL(geometry.data, geometry.dataCounts, geometry.shader);\n\n // Passes the indices of a geometry to the index buffer a\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, geometry.indices, this.gl.STATIC_DRAW);\n\n // Draw geometries using current buffer data\n this.gl.drawElements(this.gl.TRIANGLES, geometry.indices.length, this.gl.UNSIGNED_SHORT, 0);\n }\n }", "title": "" }, { "docid": "6bbdf2026d96b358e017a7bde8ad9a5e", "score": "0.66274434", "text": "function uploadNormalMatrixToShader() {\n mat3.fromMat4(nMatrix, mvMatrix);\n mat3.transpose(nMatrix, nMatrix);\n mat3.invert(nMatrix, nMatrix);\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix);\n}", "title": "" }, { "docid": "a30e506558198f50c94530daebd4cabd", "score": "0.6619455", "text": "function setUpProjectionMat() {\n let projectionMat = mat3.create();\n mat3.fromScaling(projectionMat, [2.0 / gl.drawingBufferWidth, 2.0 / gl.drawingBufferHeight]);\n gl.uniformMatrix3fv(context.uProjectionMatId, false, projectionMat);\n}", "title": "" }, { "docid": "1b2a286057febaea11de562f665d6664", "score": "0.66193134", "text": "function render() {\n if (animationQueue.length != 0 && !isAnimating) {\n animate(animationQueue.shift());\n isAnimating = true;\n }\n\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n \n eye = vec3(cameraRadius*Math.sin(PHI)*Math.sin(THETA),\n cameraRadius*Math.cos(PHI),\n cameraRadius*Math.sin(PHI)*Math.cos(THETA));\n \n PROJMATRIX = perspective(fovy, aspect, near, far);\n \n MVMATRIX = lookAt(eye, at, up);\n var x, y, z;\n for (x = -1; x <= 1; x++) {\n for (y = -1; y <= 1; y++) {\n for (z = -1; z <= 1; z++) {\n if (x !=0 || y !=0 || z!=0) {\n var tempMVMATRIX = MVMATRIX;\n \n MVMATRIX = mult(MVMATRIX,getRotationMatrix(x,y,z));\n MVMATRIX = mult(MVMATRIX,translate(vec3(x*spacing,y*spacing,z*spacing)));\n reColor(x,y,z);\n \n cBuffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, cBuffer);\n gl.bufferData(gl.ARRAY_BUFFER, flatten(vertexColors), gl.STATIC_DRAW);\n \n vColor = gl.getAttribLocation( program, \"vColor\" );\n gl.vertexAttribPointer(vColor, 4, gl.FLOAT, false, 0 , 0);\n gl.enableVertexAttribArray(vColor);\n \n gl.uniformMatrix4fv(_projectionMatrix, false, flatten(PROJMATRIX));\n gl.uniformMatrix4fv(_modelViewMatrix, false, flatten(MVMATRIX));\n gl.drawElements(gl.TRIANGLES, numOfVertices, gl.UNSIGNED_BYTE, 0);\n \n MVMATRIX = tempMVMATRIX;\n } \n }\n }\n }\n requestAnimFrame(render);\n}", "title": "" }, { "docid": "fe823af15f0edc096c5494475ac5efb7", "score": "0.6612459", "text": "update_GPU( context, gpu_addresses, graphics_state, model_transform, material ) // Define how to synchronize our JavaScript's variables to the GPU's:\n { const [ P, C, M ] = [ graphics_state.projection_transform, graphics_state.camera_inverse, model_transform ],\n PCM = P.times( C ).times( M );\n context.uniformMatrix4fv( gpu_addresses.projection_camera_model_transform, false, Mat.flatten_2D_to_1D( PCM.transposed() ) );\n }", "title": "" }, { "docid": "3146d62b809ec17e4fff9fe4dd7e09cb", "score": "0.6609454", "text": "function updateModelViewMatrix() {\r\n let mv = glMatrix.mat4.fromRotationTranslationScale(glMatrix.mat4.create(),\r\n glMatrix.quat.fromEuler(glMatrix.quat.create(), ...rotation), position, scale);\r\n gl.uniformMatrix4fv(gl.program.uModelViewMatrix, false, mv);\r\n}", "title": "" }, { "docid": "142cb0f370b5ccdb179679a9e15a86a0", "score": "0.6606935", "text": "function updateModelView(modelView) {\n gl.uniformMatrix4fv(locations.modelView, false, flatten(modelView));\n gl.uniformMatrix4fv(locations.normalLocation, false, flatten(modelView));\n}", "title": "" }, { "docid": "fe86b38de354a0c9f636210c1bc0ad8b", "score": "0.6603074", "text": "function drawModel_Merc()\n{\n viewMatrix_Scene3 = mat4.create();\n\n \n \n\t//gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);\n\tgl.useProgram(MercedesProgramObject_Merc);\n\t//lighting details\n\t\n// if(gParts_Table)\n// console.log(gParts_Table.length);\n\n\n\tvar modelMatrix = mat4.create();\n \n \n viewScene3[0] = Math.sin(MercRotY) + MercTransX_Eye\n viewScene3[1] = -1.0 + (MercTransY_Eye * 6)\n viewScene3[2] = Math.cos(MercRotY) + MercTransZ_Eye\n //Initially values [0.0, -1.5, 1.0], [0.0, -1.5, 0.0]\n mat4.lookAt(viewMatrix_Scene3, viewScene3, [MercTransX_Eye, -1.0 + MercTransY_Eye, MercTransZ_Eye], [0.0, 1.0, 0.0]);\n //var angleInRadian = degreeToRadian(gAngle);\n mat4.translate(modelMatrix, modelMatrix, [MercTransX, MercTransY, MercTransZ]);\n\n // mat4.rotateY(modelMatrix, modelMatrix, deg2rad(180));\n mat4.scale(modelMatrix, modelMatrix, [MercScale, MercScale, MercScale]);\n\n GRPushToStack_logo(modelMatrix);\n\t//var angleInRadian = degreeToRadian(gAngle);\n\t// mat4.translate(modelMatrix, modelMatrix, [0.0,transY_Merc,-100.0]);\n // mat4.scale(modelMatrix, modelMatrix, [0.2,0.2,0.2]);\n//\tmat4.rotateY(modelMatrix,modelMatrix,degreeToRadian(gAngleTriangle_modelLoading));\n\t\n\t//gAngleTriangle_modelLoading += 0.005;\n\t//mat4.rotateY(modelMatrix,modelMatrix,degreeToRadian(gAngleTriangle));\n\t//mat4.multiply(modelViewMatrix, modelViewMatrix, modelMatrix);\n\tgl.uniformMatrix4fv(modelUniform_modelLoading_Merc,false,modelMatrix);\n\tgl.uniformMatrix4fv(viewUniform_modelLoading_Merc,false,viewMatrix_Scene3);\n\tgl.uniformMatrix4fv(projectionUniform_modelLoading_Merc,false,perspectiveMatrix);\n gl.uniform3fv(cameraPosUniform_Merc,[0.0,0.0,0.0]);\n\n var lightPos = [100.0,100.0,100.0];\n \n gl.uniform3fv(u_lightDirectionUniform_Merc,vec3.normalize(lightPos,[100.0,100.0,100.0]));\n\n\n\n\t\n\t// if(gParts_Table)\n\t// {\n\t\t\n\n\t// \tfor(var i = 0; i < gParts_Table.length;i++)\n\t// \t{\n\n\t// \t\tif(gbLighting_modelLoading){\n\t// \t\t\tgl.uniform1i(LKeyPressed_modelLoading, 1);\n\t// \t\t\tgl.uniform3fv(LAUniform_modelLoading, light_ambient_modelLoading);\n\t// \t\t\tgl.uniform3fv(LDUniform_modelLoading, light_diffuse_modelLoading);\n\t// \t\t\tgl.uniform3fv(LSUniform_modelLoading, light_specular_modelLoading);\n\t\t\t\t\n\t// \t\t\tgl.uniform4fv(LightPositionUniform_modelLoading, light_position_modelLoading);\n\t\t\t\t\n\t// \t\t\t//set material properties\n\t// \t\t\tgl.uniform3fv(KAUniform_modelLoading, gParts_Table[i].material.ambient);\n\t// \t\t\tgl.uniform3fv(KDUniform_modelLoading, gParts_Table[i].material.diffuse);\n\t// \t\t\tgl.uniform3fv(KSUniform_modelLoading, gParts_Table[i].material.specular);\n\t// \t\t\tgl.uniform1f(MaterialShininessUniform_modelLoading,gParts_Table[i].material.shininess);\n\t\t\t\t\n\t// \t\t\t}\n\t// \t\t\telse\n\t// \t\t\t{\n\t// \t\t\t\t\tgl.uniform1i(LKeyPressed_modelLoading, 0);\n\t// \t\t\t}\n\t// \t\tgl.bindTexture(gl.TEXTURE_2D, gParts_Table[i].material.diffuseMap);\n\n\t// \t\t\tgl.bindVertexArray(vao_mercedes_modelLoading[i]);\n\t\t\n\t// \t\t\tgl.drawArrays(gl.TRIANGLES,0,numElements_Teapot[i]);\n\t// \t}\n \n\t// }\n\n\n if(gParts_Teapot_Merc)\n\t{\n\t\t\n\n\t\tfor(var i = 0; i < gParts_Teapot_Merc.length;i++)\n\t\t{\n\n\t\t\tif(gbLighting_modelLoading_Merc){\n\t\t\t\tgl.uniform1i(LKeyPressed_modelLoading_Merc, 1);\n\t\t\t\t// gl.uniform3fv(LAUniform_modelLoading, light_ambient_modelLoading);\n\t\t\t\t// gl.uniform3fv(LDUniform_modelLoading, light_diffuse_modelLoading);\n\t\t\t\t// gl.uniform3fv(LSUniform_modelLoading, light_specular_modelLoading);\n\t\t\t\t\n\t\t\t\t// gl.uniform4fv(LightPositionUniform_modelLoading, light_position_modelLoading);\n\t\t\t\t\n\t\t\t\t//set material properties\n\t\t\t\tgl.uniform3fv(ambientUniform_Merc, gParts_Teapot_Merc[i].material.ambient);\n\t\t//\t\tgl.uniform3fv(diffuseMapUniform, gParts_Teapot[i].material.diffuseMap);\n\t\t\t\tgl.uniform3fv(diffuseUniform_Merc, gParts_Teapot_Merc[i].material.diffuse);\n gl.uniform3fv(specularUniform_Merc, gParts_Teapot_Merc[i].material.specular);\n\t\t\t\tgl.uniform1f(shininessUniform_Merc,gParts_Teapot_Merc[i].material.shininess);\n\t\t\t\tgl.uniform1f(opacityUniform_Merc,gParts_Teapot_Merc[i].material.opacity);\n\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\tgl.uniform1i(LKeyPressed_modelLoading_Merc, 0);\n\t\t\t\t}\n\t\t\tgl.bindTexture(gl.TEXTURE_2D, gParts_Teapot_Merc[i].material.diffuseMap);\n\n\t\t\t\tgl.bindVertexArray(vao_teapot_Merc[i]);\n\t\t\n\t\t\t\tgl.drawArrays(gl.TRIANGLES,0,numElements_table[i]);\n\t\t}\n \n\t}\n\t\n\t\n\tgl.useProgram(null);\n\n //logo\n GRDisplayLogo();\n\n\n\t// requestAnimationFrame(drawModel_Merc,canvas);\n\t console.log(i);\n\t\n\t// if( gAngleTriangle_modelLoading_Merc >= 360.0)\n\t// \t\tgAngleTriangle_modelLoading_Merc = 0.0;\n\t// \telse\n\t// \t\tgAngleTriangle_modelLoading_Merc = gAngleTriangle_modelLoading_Merc + 1.0;\n\t\n\t// if( gAngleSquare_modelLoading_Merc >= 360.0)\n\t// \t\tgAngleSquare_modelLoading_Merc = 0.0;\n\t// \telse\n\t// \t\tgAngleSquare_modelLoading_Merc = gAngleSquare_modelLoading_Merc + 1.0;\n}", "title": "" }, { "docid": "82a1cc3192d646421f2fae18aed37eb3", "score": "0.65997607", "text": "function uploadNormalMatrixToShader() {\n mat3.fromMat4(nMatrix,mvMatrix);\n mat3.transpose(nMatrix,nMatrix);\n mat3.invert(nMatrix,nMatrix);\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix);\n}", "title": "" }, { "docid": "25ca6e36415f5db01100443af8040dd3", "score": "0.65949535", "text": "function setMatrixUniforms() {\n gl.useProgram(shaderProgram)\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix)\n mat3.fromMat4(nMatrix,mvMatrix)\n mat3.transpose(nMatrix,nMatrix)\n mat3.invert(nMatrix,nMatrix)\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix)\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix)\n gl.uniform1f(shaderProgram.ReflectToggle, Toggle)\n gl.uniformMatrix4fv(shaderProgram.normals,false, rot)\n}", "title": "" }, { "docid": "b118ab920e7f8b4e6c4e279ce25a8486", "score": "0.6586862", "text": "function setMatrixUniforms() {\n uploadMVMatrix();\n uploadPMatrix();\n uploadNMatrix();\n}", "title": "" }, { "docid": "5510c018d4a8d95179a8ad475be47586", "score": "0.6577373", "text": "function draw() { \n // vectors for model manipulation\n var transformVec = vec3.create();\n var stepVec = vec3.create();\n \n gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n // We'll use perspective \n mat4.perspective(pMatrix,degToRad(45), gl.viewportWidth / gl.viewportHeight, 0.1, 200.0);\n\n // We want to look down -z, so create a lookat point in that direction \n vec3.add(viewPt, eyePt, viewDir);\n // Then generate the lookat matrix and initialize the MV matrix to that view\n mat4.lookAt(mvMatrix,eyePt,viewPt,up); \n \n // Draw Terrain\n mvPushMatrix();\n vec3.set(transformVec,0.0,-0.25,-3.0);\n \n // Create stepVec as a vector to move the flight simulator forward\n vec3.normalize(stepVec, viewDir);\n vec3.scale(stepVec, stepVec, -transAmt);\n transAmt += 0.001;\n \n // Set up model and move flight simulator forward by translating model in opposite\n // direction of view direction\n mat4.translate(mvMatrix, mvMatrix, transformVec);\n mat4.translate(mvMatrix, mvMatrix, stepVec); // move forward\n mat4.rotateX(mvMatrix, mvMatrix, degToRad(-75));\n mat4.rotateZ(mvMatrix, mvMatrix, degToRad(25)); \n setMatrixUniforms();\n \n // Manipulate lighting informtion, draw the terrain and restore old model view matrix\n uploadLightsToShader([0,1,1],[0.0,0.0,0.3],[1.0,0.5,0.0],[1.0,1.0,0.0]);\n drawTerrain();\n mvPopMatrix();\n}", "title": "" }, { "docid": "95cbaf0e6afed4f63fbeacda48ec6447", "score": "0.6561397", "text": "update(viewMatrix, projectionMatrix) {\n _math_Matrix44__WEBPACK_IMPORTED_MODULE_0__[\"default\"].multiplyTo(projectionMatrix, viewMatrix, this.__vp);\n this.zNear.x = this.__vp.m20 + this.__vp.m30;\n this.zNear.y = this.__vp.m21 + this.__vp.m31;\n this.zNear.z = this.__vp.m22 + this.__vp.m32;\n this.zNear.w = this.__vp.m23 + this.__vp.m33;\n this.zNear.normalize3();\n this.zFar.x = -this.__vp.m20 + this.__vp.m30;\n this.zFar.y = -this.__vp.m21 + this.__vp.m31;\n this.zFar.z = -this.__vp.m22 + this.__vp.m32;\n this.zFar.w = -this.__vp.m23 + this.__vp.m33;\n this.zFar.normalize3();\n this.bottom.x = this.__vp.m10 + this.__vp.m30;\n this.bottom.y = this.__vp.m11 + this.__vp.m31;\n this.bottom.z = this.__vp.m12 + this.__vp.m32;\n this.bottom.w = this.__vp.m13 + this.__vp.m33;\n this.bottom.normalize3();\n this.top.x = -this.__vp.m10 + this.__vp.m30;\n this.top.y = -this.__vp.m11 + this.__vp.m31;\n this.top.z = -this.__vp.m12 + this.__vp.m32;\n this.top.w = -this.__vp.m13 + this.__vp.m33;\n this.top.normalize3();\n this.left.x = this.__vp.m00 + this.__vp.m30;\n this.left.y = this.__vp.m01 + this.__vp.m31;\n this.left.z = this.__vp.m02 + this.__vp.m32;\n this.left.w = this.__vp.m03 + this.__vp.m33;\n this.left.normalize3();\n this.right.x = -this.__vp.m00 + this.__vp.m30;\n this.right.y = -this.__vp.m01 + this.__vp.m31;\n this.right.z = -this.__vp.m02 + this.__vp.m32;\n this.right.w = -this.__vp.m03 + this.__vp.m33;\n this.right.normalize3();\n }", "title": "" }, { "docid": "1ef49ad6e877dbd3d9fb7cad37aaae80", "score": "0.6559538", "text": "function render() {\n\n\t// Tell OpenGL state machine which program should be active.\n\tgl.useProgram(shader_program);\n\t// Since we are going to use drawElements, we need to have the index buffer\n\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, modelEBO);\n\n\t// Get the latest values of the matrices and uniforms\n\tmat4.fromYRotation(worldMatrix_value, glMatrix.toRadian(angle));\n\tfragColor_value = vec3.fromValues(modelColor.r, modelColor.g, modelColor.b);\n\tgl.uniform3fv(fragColor_location, fragColor_value);\n\n\tgl.uniformMatrix4fv(worldMatrix_location, gl.FALSE, worldMatrix_value);\n\tgl.uniformMatrix4fv(viewMatrix_location, gl.FALSE, viewMatrix_value);\n\tgl.uniformMatrix4fv(projMatrix_location, gl.FALSE, projMatrix_value);\n\n\t// clear everything that was on the screen\n\tgl.clearColor(0.18, 0.18, 0.18, 1.0); // Background Color (R, G, B, Alpha)\n\tgl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n\tgl.drawElements(gl.TRIANGLES, indices_length, gl.UNSIGNED_SHORT, 0);\n\n\t// Best practices: clean-up.\n\tgl.useProgram(null); \n\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n}", "title": "" }, { "docid": "bb747dd3cbf7f23ec291760be222bd07", "score": "0.6555233", "text": "draw() {\n // TODO\n let vPosition = gl.getAttribLocation( program, \"vPosition\");\n gl.bindBuffer(gl.ARRAY_BUFFER, this.vBuffer);\n gl.vertexAttribPointer(vPosition, 4, gl.FLOAT, false, 0, 0);\n gl.enableVertexAttribArray(vPosition);\n\n let vColor = gl.getAttribLocation( program, \"vColor\" );\n gl.bindBuffer(gl.ARRAY_BUFFER, this.cBuffer);\n \tgl.vertexAttribPointer( vColor, 4, gl.FLOAT, false, 0, 0 );\n \tgl.enableVertexAttribArray( vColor );\n\n \n\n let location = gl.getUniformLocation(program, \"mat\");\n gl.uniformMatrix4fv(location, false, flatten(this.mat));\n gl.drawArrays( gl.TRIANGLES, 0, this.numVertices);\n\n\n }", "title": "" }, { "docid": "5135f51cfcfd189bdc6a5781b07deafb", "score": "0.655231", "text": "function uploadNormalMatrixToShader() {\n glMatrix.mat3.fromMat4(nMatrix,mvMatrix);\n glMatrix.mat3.transpose(nMatrix,nMatrix);\n glMatrix.mat3.invert(nMatrix,nMatrix);\n gl.uniformMatrix3fv(shaderProgram.nMatrixUniform, false, nMatrix);\n}", "title": "" }, { "docid": "7eff9ea7dd302585e74413e88f768296", "score": "0.65416425", "text": "function setMatrixUniforms() {\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n}", "title": "" }, { "docid": "e097df423f0862b1604acdf9e833fe86", "score": "0.6535822", "text": "function createModel(modelData, xtraTranslate) {\n var model = {};\n model.coordsBuffer = gl.createBuffer();\n model.normalBuffer = gl.createBuffer();\n model.indexBuffer = gl.createBuffer();\n model.count = modelData.indices.length;\n if (xtraTranslate)\n model.xtraTranslate = xtraTranslate;\n else\n model.xtraTranslate = null;\n gl.bindBuffer(gl.ARRAY_BUFFER, model.coordsBuffer);\n gl.bufferData(gl.ARRAY_BUFFER, modelData.vertexPositions, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ARRAY_BUFFER, model.normalBuffer);\n gl.bufferData(gl.ARRAY_BUFFER, modelData.vertexNormals, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, model.indexBuffer);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, modelData.indices, gl.STATIC_DRAW);\n model.render = function() { \n gl.bindBuffer(gl.ARRAY_BUFFER, this.coordsBuffer);\n gl.vertexAttribPointer(a_coords_loc, 3, gl.FLOAT, false, 0, 0);\n gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer);\n gl.vertexAttribPointer(a_normal_loc, 3, gl.FLOAT, false, 0, 0);\n gl.uniform4fv(u_material.diffuseColor, currentColor);\n if (this.xtraTranslate) {\n pushMatrix();\n mat4.translate(modelview,modelview,this.xtraTranslate);\n }\n gl.uniformMatrix4fv(u_modelview, false, modelview );\n mat3.normalFromMat4(normalMatrix, modelview);\n gl.uniformMatrix3fv(u_normalMatrix, false, normalMatrix);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);\n gl.drawElements(gl.TRIANGLES, this.count, gl.UNSIGNED_SHORT, 0);\n if (this.xtraTranslate) {\n popMatrix();\n }\n }\n return model;\n}", "title": "" }, { "docid": "e00e95bd021528449bcca854558d2f23", "score": "0.65351653", "text": "function setMatrixUniforms() {\r\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\r\n}", "title": "" }, { "docid": "130ae8a97a2f71a2f8943a428b018b50", "score": "0.65264004", "text": "updateBuffer() {\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.vbo)\n\n\t\tthis.setNormalMatrix(this.makeNormalMatrix())\n\n\t\tgl.uniformMatrix4fv(state.loc.matrices.model, false, new Float32Array(this.modelMatrix))\n\t\tgl.uniformMatrix4fv(state.loc.matrices.normal, false, new Float32Array(this.normalMatrix))\n\n\t\tgl.uniform4fv(state.loc.light.ambientColor, this.colors.ambientColor)\n\t\tgl.uniform4fv(state.loc.light.diffuseColor, this.colors.diffuseColor)\n\t\tgl.uniform4fv(state.loc.light.specularColor, this.colors.specularColor)\n\t\tgl.uniform1f(state.loc.light.specularExponent, this.colors.specularExponent)\n\t}", "title": "" }, { "docid": "6ae7a32e12d36ea6841e048219e5bb41", "score": "0.65255815", "text": "function setMatrixUniforms() {\n gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);\n gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);\n }", "title": "" }, { "docid": "dec6fcf032a340336727f2f23260c41a", "score": "0.6518299", "text": "function renderModels() {\n \n // construct the model transform matrix, based on model state\n function makeModelTransform(whichTriSet) {\n var zAxis = vec3.create(), sumRotation = mat4.create(), temp = mat4.create(), negCtr = vec3.create();\n\n // move the model to the origin\n mat4.fromTranslation(mMatrix,vec3.negate(negCtr,centerArray[whichTriSet])); \n \n // rotate the model to current interactive orientation\n vec3.normalize(zAxis,vec3.cross(zAxis,xAxisArray[whichTriSet],yAxisArray[whichTriSet])); // get the new model z axis\n mat4.set(sumRotation, // get the composite rotation\n xAxisArray[whichTriSet][0], yAxisArray[whichTriSet][0], zAxis[0], 0,\n xAxisArray[whichTriSet][1], yAxisArray[whichTriSet][1], zAxis[1], 0,\n xAxisArray[whichTriSet][2], yAxisArray[whichTriSet][2], zAxis[2], 0,\n 0, 0, 0, 1);\n mat4.multiply(mMatrix,sumRotation,mMatrix); // R(ax) * S(1.2) * T(-ctr)\n \n // translate back to model center\n mat4.multiply(mMatrix,mat4.fromTranslation(temp,centerArray[whichTriSet]),mMatrix); // T(ctr) * R(ax) * S(1.2) * T(-ctr)\n\n // translate model to current interactive orientation\n mat4.multiply(mMatrix,mat4.fromTranslation(temp,transArray[whichTriSet]),mMatrix); // T(pos)*T(ctr)*R(ax)*S(1.2)*T(-ctr)\n \n } // end make model transform\n \n // var hMatrix = mat4.create(); // handedness matrix\n var pMatrix = mat4.create(); // projection matrix\n var vMatrix = mat4.create(); // view matrix\n var mMatrix = mat4.create(); // model matrix\n var pvMatrix = mat4.create(); // hand * proj * view matrices\n var pvmMatrix = mat4.create(); // hand * proj * view * model matrices\n \n window.requestAnimationFrame(renderModels); // set up frame render callback\n \n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); // clear frame/depth buffers\n \n // set up projection and view\n // mat4.fromScaling(hMatrix,vec3.fromValues(-1,1,1)); // create handedness matrix\n mat4.perspective(pMatrix,0.5*Math.PI,1,0.1,10); // create projection matrix\n mat4.lookAt(vMatrix,Eye,Center,Up); // create view matrix\n mat4.multiply(pvMatrix,pvMatrix,pMatrix); // projection\n mat4.multiply(pvMatrix,pvMatrix,vMatrix); // projection * view\n\n // render each triangle set in the grid\n for (var whichTriSet=0; whichTriSet<numTriangleSets; whichTriSet++) {\n \n // make model transform, add to view project\n // makeModelTransform(whichTriSet);\n mat4.multiply(pvmMatrix,pvMatrix,mMatrix); // project * view * model\n gl.uniformMatrix4fv(mMatrixULoc, false, mMatrix); // pass in the m matrix\n gl.uniformMatrix4fv(pvmMatrixULoc, false, pvmMatrix); // pass in the hpvm matrix\n \n // reflectivity: feed to the fragment shader\n gl.uniform3fv(diffuseULoc,colorArray[whichTriSet]); // pass in the diffuse reflectivity\n gl.uniform1f(transpULoc, 1.0);\n gl.uniform1f(xTransULoc, 0.0);\n gl.uniform1f(yTransULoc, 0.0);\n gl.uniform1f(zTransULoc, 0.0);\n \n // vertex buffer: activate and feed into vertex shader\n gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffers[whichTriSet]); // activate\n gl.vertexAttribPointer(vPosAttribLoc,3,gl.FLOAT,false,0,0); // feed\n\n // triangle buffer: activate and render\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,triangleBuffers[whichTriSet]); // activate\n gl.drawElements(gl.TRIANGLES,3*triSetSizes[whichTriSet],gl.UNSIGNED_SHORT,0); // render\n \n } // end for each triangle set\n\n mat4.multiply(pvmMatrix,pvMatrix,mMatrix); // project * view * model\n gl.uniformMatrix4fv(mMatrixULoc, false, mMatrix); // pass in the m matrix\n gl.uniformMatrix4fv(pvmMatrixULoc, false, pvmMatrix); // pass in the hpvm matrix\n\n // Tell WebGL how to pull out the positions from the position\n\n renderPeicesA();\n renderPeicesB();\n renderPeicesC();\n renderPeicesD();\n renderPeicesE();\n\n\n if (ultimateDone == false) {\n console.log(ultimateDone);\n \n round++;\n\n if (round%25 == 0) {\n update();\n }\n\n }\n \n \n \n}", "title": "" }, { "docid": "d8ec164c6687114349c6e9b74a47b04a", "score": "0.65169615", "text": "_initMatrices() {\n // create our matrices, they will be set after\n const matrix = new Mat4();\n this._matrices = {\n world: {\n // world matrix (global transformation)\n matrix: matrix,\n },\n modelView: {\n // model view matrix (world matrix multiplied by camera view matrix)\n name: \"uMVMatrix\",\n matrix: matrix,\n location: this.gl.getUniformLocation(this._program.program, \"uMVMatrix\"),\n },\n projection: {\n // camera projection matrix\n name: \"uPMatrix\",\n matrix: matrix,\n location: this.gl.getUniformLocation(this._program.program, \"uPMatrix\"),\n },\n modelViewProjection: {\n // model view projection matrix (model view matrix multiplied by projection)\n matrix: matrix,\n }\n };\n }", "title": "" }, { "docid": "19d7f308bc31f2976ea4e14f6352942c", "score": "0.65150183", "text": "function updateProjectionMatrix() {\r\n let aspect = gl.canvas.width / gl.canvas.height;\r\n let p = mat4.perspective(mat4.create(), Math.PI / 4, aspect, 0.1, 10);\r\n gl.uniformMatrix4fv(gl.program.uProjectionMatrix, false, p);\r\n}", "title": "" }, { "docid": "ba1a4d6ce11f755277ae04a47957b25e", "score": "0.6508408", "text": "_setMVMatrix() {\n if(this._updateMVMatrix) {\n // compose our world transformation matrix from custom origin\n this._matrices.world.matrix = this._matrices.world.matrix.composeFromOrigin(this._translation, this.quaternion, this.scale, this._boundingRect.world.transformOrigin);\n\n // we need to scale our planes, from a square to a right sized rectangle\n // we're doing this after our transformation matrix because this scale transformation always have the same origin\n this._matrices.world.matrix.scale({\n x: this._boundingRect.world.width,\n y: this._boundingRect.world.height,\n z: 1\n });\n\n\n // our model view matrix is our world matrix multiplied with our camera view matrix\n // in our case we're just subtracting the camera Z position to our world matrix\n this._matrices.modelView.matrix.copy(this._matrices.world.matrix);\n this._matrices.modelView.matrix.elements[14] -= this.camera.position.z;\n\n // our modelViewProjection matrix, useful for bounding box calculations and frustum culling\n // this is the result of our projection matrix multiplied by our modelView matrix\n this._matrices.modelViewProjection.matrix = this._matrices.projection.matrix.multiply(this._matrices.modelView.matrix);\n\n // check if we should draw the plane but only if everything has been initialized\n if(!this.alwaysDraw) {\n this._shouldDrawCheck();\n }\n\n // update our matrix uniform\n this.renderer.useProgram(this._program);\n this.gl.uniformMatrix4fv(this._matrices.modelView.location, false, this._matrices.modelView.matrix.elements);\n }\n\n // reset our flag\n this._updateMVMatrix = false;\n }", "title": "" }, { "docid": "9f247806c0cd5f43192ed0b37ed3e609", "score": "0.6497334", "text": "function setCubeMatrixUniforms(){\n gl.useProgram(SkyboxProgram)\n gl.uniformMatrix4fv(SkyboxProgram.cubeProjection, false, cubeP)\n gl.uniformMatrix4fv(SkyboxProgram.ModelVIew, false, Modelviewmatrix)\n gl.uniform1i( SkyboxProgram.skybox, 0)\n}", "title": "" } ]
f9d7f9723b255009eb6d997de6918951
wrapper function for providing a more flexible interface without getting yelled at by flow
[ { "docid": "7e7f40d4f182f47321ccfb699bbb8789", "score": "0.0", "text": "function createElement (\n context,\n tag,\n data,\n children,\n normalizationType,\n alwaysNormalize\n) {\n if (Array.isArray(data) || isPrimitive(data)) {\n normalizationType = children;\n children = data;\n data = undefined;\n }\n if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }\n return _createElement(context, tag, data, children, normalizationType)\n}", "title": "" } ]
[ { "docid": "95b70191bc05bb0097b59d3cc45bc98c", "score": "0.6185405", "text": "function Wrapper() {}", "title": "" }, { "docid": "1226bccfb9553b375fc0362f444496bc", "score": "0.60045", "text": "function PipeDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "ac651a088fd31058b096696c90ea2fe2", "score": "0.5736741", "text": "function PipeDecorator() {} // WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "ac651a088fd31058b096696c90ea2fe2", "score": "0.5736741", "text": "function PipeDecorator() {} // WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "9cfe1467b03bf139c57eebc1d3f5858a", "score": "0.5671855", "text": "function OptionalDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "b92210eae35991fa9f00d42f56168130", "score": "0.55876297", "text": "function SelfDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "6485e9b5b33160ec01571cc01f955e3d", "score": "0.55722237", "text": "function HostDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "4d29ae708a6b956469859a64c6311de6", "score": "0.5518585", "text": "function OutputDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "8f4beb0fbb476ab9c1eb80285f0a605a", "score": "0.5505829", "text": "function Labelable() {}", "title": "" }, { "docid": "f2c4efc32cff6354af23af6158b59eb6", "score": "0.53999275", "text": "function SkipSelfDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "13df25260e4440a35d55566645faf853", "score": "0.5366802", "text": "function mifuncion(){}", "title": "" }, { "docid": "a3585382d7eae0ce449567e773a4950c", "score": "0.5335324", "text": "function IMPLEMENTS(_) {\r\n return function (t) { return t; };\r\n}", "title": "" }, { "docid": "d8241a45761c08f270210e967dcdd34f", "score": "0.532014", "text": "internals() {\n return {\n createHttp: (events, skipStart) => {\n return this.#createHttp(events, skipStart)\n },\n\n createLambda: (lambdas, skipStart) => {\n return this.#createLambda(lambdas, skipStart)\n },\n\n getApiGatewayServer: () => {\n return this.#http.getServer()\n },\n\n getEvents: () => {\n return this.#getEvents()\n },\n\n mergeOptions: () => {\n this.#mergeOptions()\n },\n }\n }", "title": "" }, { "docid": "e38edb5dd151abf14bec4bb78bd9efb2", "score": "0.52958286", "text": "function _fn(){ /*...*/ }\t//Funzioni private", "title": "" }, { "docid": "2cb6e09fdad4280ee05f4d3eee04c356", "score": "0.5293775", "text": "function Interface () {}", "title": "" }, { "docid": "b72cd654352e45bbfae1f79315811082", "score": "0.52936536", "text": "get Wrap() {}", "title": "" }, { "docid": "f43afc8f8c60f3b1b984951a8e1aff1a", "score": "0.52549785", "text": "function HostBindingDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "f76f0bdad039d128ac4672e55a5dd7bb", "score": "0.52307636", "text": "function thisisaFunc() {}", "title": "" }, { "docid": "f0408078d0a12f66b857c7a415862595", "score": "0.52194107", "text": "utility(state) {\n throw 'not implemented';\n }", "title": "" }, { "docid": "864df3088a481edf73f205add35931c5", "score": "0.5199138", "text": "_make () {}", "title": "" }, { "docid": "968df7bad421e9ca8c7ba820b520d25f", "score": "0.519113", "text": "function AttributeDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "0338c3939fe7691bcd0bd32d80f60fb2", "score": "0.51879674", "text": "function proceed() {\n var ifaceDesc;\n var iface;\n\n // First, we need to create our interface description (here we will only expose method calls)\n ifaceDesc = {\n name: interfaceName,\n methods: {\n // Simple types\n SayHello: ['', 's', [], ['hello_sentence']], // Takes no input and returns a single string\n GetInt16: ['', 'n', [], ['Int16_number']], // Takes no input and returns an int16 integers\n GetUInt16: ['', 'q', [], ['UInt16_number']], // Takes no input and returns an uint16 integers\n GetInt32: ['', 'i', [], ['Int32_number']], // Takes no input, returns an int32 integer\n GetUInt32: ['', 'u', [], ['UInt32_number']], // Takes no input, returns an uint32 integer\n // 64 numbers being not handled natively in Javascript, they are not yet handled by this library (WIP)\n //GetInt64: ['', 'x', [], ['Int32_number']], // Takes no input, returns an int64 integer\n //GetUInt64: ['', 't', [], ['UInt32_number']], // Takes no input, returns an uint64 integer\n GetBool: ['', 'b', [], ['Bool_value']], // Takes no input, returns a boolean\n GetDouble: ['', 'd', [], ['Double_value']], // Takes no input, returns a double\n GetByte: ['', 'y', [], ['Byte_value']], // Takes no input, returns a byte\n\n // Complex-types\n GetArrayOfStrings: ['y', 'as', ['nb_elems'], ['strings']], // Take a number and return an array of N strings\n // Takes no input, returns a structure with a string, an int32 and a bool\n GetCustomStruct: ['', '(sib)', [], ['struct']],\n // Takes no input, returns a dictionary (hash-table) whose keys are strings and values int32\n GetDictEntry: ['', 'a{si}', [], ['dict_entry']]\n },\n // No signals nor properties for this example\n signals: {},\n properties: {}\n };\n\n // Then we need to create the interface implementation (with actual functions)\n iface = {\n SayHello: function() {\n return 'Hello, world!'; // This is how to return a single string\n },\n GetInt16: function() {\n var min = -0x7fff - 1;\n var max = 0x7fff;\n return Math.round(Math.random() * (max - min) + min);\n },\n GetUInt16: function() {\n var min = 0;\n var max = 0xffff;\n return Math.round(Math.random() * (max - min) + min);\n },\n GetInt32: function() {\n var min = -0x7fffffff - 1;\n var max = 0x7fffffff;\n return Math.round(Math.random() * (max - min) + min);\n },\n GetUInt32: function() {\n var min = 0;\n var max = 0xffffffff;\n return Math.round(Math.random() * (max - min) + min);\n },\n GetBool: function() {\n return Math.random() >= 0.5 ? true : false;\n },\n GetDouble: function() {\n /*\n\t\t\t\tWe are only returning a number between 0 and 1 here, but this is just for the test.\n\t\t\t\tJavascript can handle number between Number.MIN_VALUE and Number.MAX_VALUE, which are 5e-234 and 1.7976931348623157e+308 respectively.\n\t\t\t\tThere would be no point in returing such big numbers for this demo, but this is perfectly okay with DBus.\n\t\t\t*/\n return Math.random();\n },\n GetByte: function() {\n var min = 0x00;\n var max = 0xff;\n return Math.round(Math.random() * (max - min) + min);\n },\n GetArrayOfStrings: function(n) {\n // Check that we requested a positive number of elements, and not a too big one\n if (n < 0 || n > 255) {\n // Return a DBus error to indicate a problem (shows how to send DBus errors)\n return new Error(\n 'Incorrect number of elements supplied (0 < n < 256)!'\n );\n }\n\n var ret = [];\n while (n--) {\n ret.unshift(`String #${n}`);\n }\n\n return ret; // 'ret' is an array, to return an array, we simply return it\n },\n GetCustomStruct: function() {\n var min = -0x7fffffff - 1;\n var max = 0x7fffffff;\n var string =\n 'Im sorry, my responses are limited, you must ask the right question.';\n var int32 = Math.round(Math.random() * (max - min) + min);\n var bool = Math.random() >= 0.5 ? true : false;\n\n /*\n\t\t\t\tImportant note here: for the DBus type STRUCT, you need to return a Javascript ARRAY, with the field in\n\t\t\t\tthe right order for the declared struct.\n\t\t\t*/\n return [string, int32, bool];\n },\n GetDictEntry: function() {\n var min = -0x7fffffff - 1;\n var max = 0x7fffffff;\n var key1 = 'str1';\n var key2 = 'str2';\n var key3 = 'str3';\n var i1 = Math.round(Math.random() * (max - min) + min);\n var i2 = Math.round(Math.random() * (max - min) + min);\n var i3 = Math.round(Math.random() * (max - min) + min);\n\n /*\n\t\t\t\tThis is how DICT_ENTRIES are returned: in JS side, it's an array of arrays.\n\t\t\t\tEach of the arrays must have TWO values, the first being the key (here a string ; keys\n\t\t\t\tMUST be single types, so string, integers, double, booleans, etc.) and the second being\n\t\t\t\tthe value (here, an int32 ; keys can be any type, including complex one: struct, etc.)\n\t\t\t*/\n return [[key1, i1], [key2, i2], [key3, i3]];\n }\n };\n\n // Now we need to actually export our interface on our object\n sessionBus.exportInterface(iface, objectPath, ifaceDesc);\n\n // Say our service is ready to receive function calls (you can use `gdbus call` to make function calls)\n console.log('Interface exposed to DBus, ready to receive function calls!');\n}", "title": "" }, { "docid": "c086531c61e8a5e7769d1df55b0e27fa", "score": "0.5184716", "text": "function IFace (){}", "title": "" }, { "docid": "9a80839656dcbc140dcd2d66517f6efb", "score": "0.5163492", "text": "get Generic() {}", "title": "" }, { "docid": "499386dd9179938c9642fab70ce150ac", "score": "0.51620823", "text": "transact(func) {\n throw new Error('Not implemented: transact');\n }", "title": "" }, { "docid": "fabba0332c75f75eee9af918c7f417c2", "score": "0.5159655", "text": "function h(a){[\"next\",\"throw\",\"return\"].forEach(function(b){a[b]=function(a){return this._invoke(b,a)}})}", "title": "" }, { "docid": "512ba6ee99f12199f0e7905f752d3260", "score": "0.5158543", "text": "get legacy() {}", "title": "" }, { "docid": "0c5332a6317fa954d10454b38ae3f292", "score": "0.51556903", "text": "function sdk_wrap(fn) {\n return wrap(fn)(); // tslint:disable-line:no-unsafe-any\n}", "title": "" }, { "docid": "53eb89ca67eeb868302ec681be3cdafe", "score": "0.51375437", "text": "function va(){}", "title": "" }, { "docid": "29eaf6574fb849ebbead47caaf55b8a5", "score": "0.5127983", "text": "function RequestBase(obj){if(obj)return mixin(obj)}", "title": "" }, { "docid": "699ab1d1462901558220dbe3590ab8e0", "score": "0.5124373", "text": "function ResponseBase(obj){if(obj)return mixin(obj)}", "title": "" }, { "docid": "bbdf983ed00cc7884a76355069c07d66", "score": "0.51241726", "text": "function dummy() {}", "title": "" }, { "docid": "bbdf983ed00cc7884a76355069c07d66", "score": "0.51241726", "text": "function dummy() {}", "title": "" }, { "docid": "bbdf983ed00cc7884a76355069c07d66", "score": "0.51241726", "text": "function dummy() {}", "title": "" }, { "docid": "24e51454ab8d6e7e1843c764261149c9", "score": "0.5102658", "text": "function OutputDecorator() {} // WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "24e51454ab8d6e7e1843c764261149c9", "score": "0.5102658", "text": "function OutputDecorator() {} // WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "6cd5f9bc208165283cd524dc010d8969", "score": "0.5061997", "text": "function struct(target) {}", "title": "" }, { "docid": "0907c8662bde216db808089ac1fdd923", "score": "0.50421923", "text": "function InterfaceWithGeneric() {}", "title": "" }, { "docid": "a1073e63ff7b0f18207238fb58ab4e3e", "score": "0.5036327", "text": "function Scrapper() {}", "title": "" }, { "docid": "ca43e630053167c1d7a30730df3f48a5", "score": "0.50339764", "text": "get Legacy() {}", "title": "" }, { "docid": "a780851fdc3acb093ec63d91cc0d9e90", "score": "0.5033929", "text": "function g(a){[\"next\",\"throw\",\"return\"].forEach(function(b){a[b]=function(a){return this._invoke(b,a)}})}", "title": "" }, { "docid": "d020628f5add6a9a4133bca880a33024", "score": "0.50087655", "text": "function ReceptionData(This) {\n // Nothing to do in this simplified version\n}", "title": "" }, { "docid": "66a466f2d9a17ad417a0091b5359fd08", "score": "0.50031984", "text": "function wl(){return wl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wl.apply(this,arguments)}", "title": "" }, { "docid": "b0f3ff834b5c133d9640319490cfbce2", "score": "0.50009274", "text": "function s(e){return new r.default((function(t){t(c(e))}))}", "title": "" }, { "docid": "d3c2ef4a95fdbb9129b93a2e3e1b6208", "score": "0.49927694", "text": "function InputWrapper() {\n}", "title": "" }, { "docid": "5dc73d0dc2d7180a27d5c0181e69191f", "score": "0.49764302", "text": "function o(e){return function(){return e}}", "title": "" }, { "docid": "0d3beb3f33cf9039274b014676dde66a", "score": "0.49744615", "text": "function GenericHandler() {}", "title": "" }, { "docid": "07baaa7b10a2faddf5ad2c1b651b13e9", "score": "0.4960761", "text": "function miFuncion(){}", "title": "" }, { "docid": "07baaa7b10a2faddf5ad2c1b651b13e9", "score": "0.4960761", "text": "function miFuncion(){}", "title": "" }, { "docid": "07baaa7b10a2faddf5ad2c1b651b13e9", "score": "0.4960761", "text": "function miFuncion(){}", "title": "" }, { "docid": "36c909a92bb9959d67d3d4ffc9cd78e9", "score": "0.49584344", "text": "function BuyOneLaptopForMe(){\n //the role of any function is to return something\n //This is an example of function return an object\n return {\n \"type\" : \"BUYLAPTOP\",\n \"info\" : {\n\n }\n }\n}", "title": "" }, { "docid": "935ea97ee614cb49b0a1dbbe0b0a50fb", "score": "0.4957064", "text": "function IO_bW2yv67jeVWcmCqoo9Yw(){}", "title": "" }, { "docid": "9002a2f6403201bbcbca72d9bd5530a8", "score": "0.49559134", "text": "function m(t, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ne) {\n return t;\n}", "title": "" }, { "docid": "9002a2f6403201bbcbca72d9bd5530a8", "score": "0.49559134", "text": "function m(t, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ne) {\n return t;\n}", "title": "" }, { "docid": "b13721fdc0df68a596240e7e3e92fa77", "score": "0.49553564", "text": "function HostListenerDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "6c9340397c1da3b797cd11718a2d29fb", "score": "0.49552017", "text": "function n(e,t,n){\"function\"==typeof e?e(t.getPublicInstance()):o.addComponentAsRefTo(t,e,n)}", "title": "" }, { "docid": "c06d59d4da3801f2114779b951741ab3", "score": "0.49525258", "text": "function I() {}", "title": "" }, { "docid": "6d3f96562b1db3a69195d96ada1f8bca", "score": "0.49507722", "text": "function e$h(e,t,a){let c,d;return void 0===t||Array.isArray(t)?(d=e,a=t,c=[void 0]):(d=t,c=Array.isArray(e)?e:[e]),(e,t)=>{const s=e.constructor.prototype;c.forEach((c=>{const p=h$3(e,c,d);p.read&&\"object\"!=typeof p.read&&(p.read={}),o$3(\"read.reader\",s[t],p),a&&(p.read.source=(p.read.source||[]).concat(a));}));}}", "title": "" }, { "docid": "6fe789508e91eae4c5b34e831508980e", "score": "0.49415532", "text": "function Interface(){}", "title": "" }, { "docid": "7c514dae7f59c9bc28d3ec05b1eca1d0", "score": "0.4937256", "text": "function ordinary() { }", "title": "" }, { "docid": "a1d9b7f16a66e406a36e3e0816899c1d", "score": "0.49293706", "text": "function xi(){return xi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xi.apply(this,arguments)}", "title": "" }, { "docid": "4551312b7c48edb3fa2093b01f7893e6", "score": "0.49224588", "text": "function wrapper() {\n\t\t return fn.apply( this, Array.prototype.slice.call( arguments, 1 ) );\n\t\t }", "title": "" }, { "docid": "68ccff687712efa198ba14f4ac3254c8", "score": "0.4915062", "text": "get Internal() {}", "title": "" }, { "docid": "847753d65f1376bb85ddd07103d833dc", "score": "0.49132505", "text": "function NgModuleDecorator(){}// WARNING: interface has both a type and a value, skipping emit", "title": "" }, { "docid": "168d4ef2837e9a7913e199e605ee632e", "score": "0.49073336", "text": "function internalApi(obj, ref, originalOptions) {\n //\n // Functions\n // =========\n function existy(something) {\n return something != null; // deliberate !=\n }\n\n function isObj(something) {\n return typeDetect(something) === \"Object\";\n }\n\n function pullAllWithGlob(originalInput, toBeRemoved) {\n if (typeof toBeRemoved === \"string\") {\n toBeRemoved = arrayiffy(toBeRemoved);\n }\n\n return Array.from(originalInput).filter(function (originalVal) {\n return !toBeRemoved.some(function (remVal) {\n return matcher.isMatch(originalVal, remVal, {\n caseSensitive: true\n });\n });\n });\n }\n\n var hasKey = Object.prototype.hasOwnProperty; // Variables\n // =========\n\n var NAMESFORANYTYPE = [\"any\", \"anything\", \"every\", \"everything\", \"all\", \"whatever\", \"whatevs\"];\n\n if (!existy(obj)) {\n throw new Error(\"check-types-mini: [THROW_ID_01] First argument is missing!\");\n } // Prep our own opts\n // =================\n\n\n var opts = _objectSpread2(_objectSpread2({}, defaults), originalOptions);\n\n if (typeof opts.ignoreKeys === \"string\") {\n opts.ignoreKeys = [opts.ignoreKeys];\n }\n\n if (typeof opts.ignorePaths === \"string\") {\n opts.ignorePaths = [opts.ignorePaths];\n }\n\n if (typeof opts.acceptArraysIgnore === \"string\") {\n opts.acceptArraysIgnore = [opts.acceptArraysIgnore];\n }\n\n opts.msg = (\"\" + opts.msg).trim();\n\n if (opts.msg[opts.msg.length - 1] === \":\") {\n opts.msg = opts.msg.slice(0, opts.msg.length - 1).trim();\n } // now, since we let users type the allowed types, we have to normalise the letter case:\n\n\n if (isObj(opts.schema)) {\n // 1. if schema is given as nested AST tree, for example:\n // {\n // schema: {\n // option1: { somekey: \"any\" }, // <------ !\n // option2: \"whatever\"\n // }\n // }\n //\n // (notice it's not flat, \"option1.somekey\": \"any\", but nested!)\n //\n // then, we flatten it first, so that each AST branch's path is key and the\n // value at that branch's tip is the key's value:\n // {\n // schema: {\n // \"option1.somekey\": \"any\", // <------ !\n // option2: \"whatever\"\n // }\n // }\n Object.keys(opts.schema).forEach(function (oneKey) {\n if (isObj(opts.schema[oneKey])) {\n // 1. extract all unique AST branches leading to their tips\n var tempObj = {};\n traverse(opts.schema[oneKey], function (key, val, innerObj) {\n var current = val !== undefined ? val : key;\n\n if (!Array.isArray(current) && !isObj(current)) {\n tempObj[oneKey + \".\" + innerObj.path] = current;\n }\n\n return current;\n }); // 2. delete that key which leads to object:\n\n delete opts.schema[oneKey]; // 3. merge in all paths-as-keys into schema opts object:\n\n opts.schema = _objectSpread2(_objectSpread2({}, opts.schema), tempObj);\n }\n }); //\n //\n //\n //\n //\n // 2. arrayiffy\n\n Object.keys(opts.schema).forEach(function (oneKey) {\n if (!Array.isArray(opts.schema[oneKey])) {\n opts.schema[oneKey] = [opts.schema[oneKey]];\n } // then turn all keys into strings and trim and lowercase them:\n\n\n opts.schema[oneKey] = opts.schema[oneKey].map(function (el) {\n return (\"\" + el).toLowerCase().trim();\n });\n });\n } else if (opts.schema != null) {\n throw new Error(\"check-types-mini: opts.schema was customised to \" + JSON.stringify(opts.schema, null, 0) + \" which is not object but \" + typeof opts.schema);\n }\n\n if (!existy(ref)) {\n // eslint-disable-next-line no-param-reassign\n ref = {};\n } // ---------------------------------------------------------------------------\n // ---------------------------------------------------------------------------\n // ---------------------------------------------------------------------------\n // THE BUSINESS\n // ============\n // Since v.4 we support nested opts. That's AST's. This means, we will have to\n // traverse them somehow up until the last tip of each branch. Luckily, we have\n // tools for traversal - ast-monkey-traverse.\n // 1. The \"obj\" and \"ref\" root level keys need separate attention.\n // If keys mismatch, we need to check them separately from traversal.\n // During traversal, we'll check if each value is a plain object/array and\n // match the keysets as well. However, traversal won't \"see\" root level keys.\n\n\n if (opts.enforceStrictKeyset) {\n if (existy(opts.schema) && Object.keys(opts.schema).length > 0) {\n if (ref && pullAllWithGlob(lodash_pullall(Object.keys(obj), Object.keys(ref).concat(Object.keys(opts.schema))), opts.ignoreKeys).length) {\n var keys = lodash_pullall(Object.keys(obj), Object.keys(ref).concat(Object.keys(opts.schema)));\n throw new TypeError(opts.msg + \": \" + opts.optsVarName + \".enforceStrictKeyset is on and the following key\" + (keys.length > 1 ? \"s\" : \"\") + \" \" + (keys.length > 1 ? \"are\" : \"is\") + \" not covered by schema and/or reference objects: \" + keys.join(\", \"));\n }\n } else if (isObj(ref) && Object.keys(ref).length > 0) {\n if (pullAllWithGlob(lodash_pullall(Object.keys(obj), Object.keys(ref)), opts.ignoreKeys).length !== 0) {\n var _keys = lodash_pullall(Object.keys(obj), Object.keys(ref));\n\n throw new TypeError(opts.msg + \": The input object has key\" + (_keys.length > 1 ? \"s\" : \"\") + \" which \" + (_keys.length > 1 ? \"are\" : \"is\") + \" not covered by the reference object: \" + _keys.join(\", \"));\n } else if (pullAllWithGlob(lodash_pullall(Object.keys(ref), Object.keys(obj)), opts.ignoreKeys).length !== 0) {\n var _keys2 = lodash_pullall(Object.keys(ref), Object.keys(obj));\n\n throw new TypeError(opts.msg + \": The reference object has key\" + (_keys2.length > 1 ? \"s\" : \"\") + \" which \" + (_keys2.length > 1 ? \"are\" : \"is\") + \" not present in the input object: \" + _keys2.join(\", \"));\n }\n } else {\n // it's an error because both schema and reference don't exist\n throw new TypeError(opts.msg + \": Both \" + opts.optsVarName + \".schema and reference objects are missing! We don't have anything to match the keys as you requested via opts.enforceStrictKeyset!\");\n }\n } // 2. Call the monkey and traverse the schema object, checking each value-as-object\n // or value-as-array separately, if opts.enforceStrictKeyset is on. Root level\n // was checked in step 1. above. What's left is deeper levels. // When users set schema to \"any\" for certain path, this applies to that path\n // and any (if exists) children objects/arrays/strings whatever on deeper children\n // paths. Now, the problem is, we check by traversing everything - this means,\n // for example, we have this to check:\n //\n // {\n // a: {\n // b: \"c\"\n // },\n // d: \"e\"\n // }\n // ast-monkey-traverse will check \"a\" and find it's schema is \"any\" - basically,\n // we don't care what it's type is and instruct \"check-types-mini\" to skip it.\n // This \"skip\" instruction applies to \"b\" too! However, our checking engine,\n // \"ast-monkey-traverse\" will still traverse \"b\". It can't stop there, because\n // there's still \"d\" key to check - we're traversing EVERYTHING.\n // Challenge: when \"ast-monkey\" will stumble upon \"b\" it might flag it up as\n // being of a wrong type, it does not have visibility of its parent's schemas.\n // What we'll do to fix this is we'll compile the list of any paths that have\n // \"any\"/\"whatever\" schemas in an array. Then, when deeper children nodes are\n // traversed, we'll check, are they children of any aforementioned paths (technically\n // speaking, do their path strings start with any of the strings in aforementioned\n // paths array strings).\n\n\n var ignoredPathsArr = [];\n traverse(obj, function (key, val, innerObj) {\n // innerObj.path // Here what we have been given:\n var current = val;\n var objKey = key;\n\n if (innerObj.parentType === \"array\") {\n objKey = undefined;\n current = key;\n } // Here's what we will compare against to.\n // If schema exists, types defined there will be used to compare against: // if current path is a children of any paths in \"ignoredPathsArr\", skip it:\n\n\n if (Array.isArray(ignoredPathsArr) && ignoredPathsArr.length && ignoredPathsArr.some(function (path) {\n return innerObj.path.startsWith(path);\n })) {\n return current;\n } // if this key is ignored, skip it:\n\n\n if (objKey && opts.ignoreKeys.some(function (oneOfKeysToIgnore) {\n return matcher.isMatch(objKey, oneOfKeysToIgnore);\n })) {\n return current;\n } // if this path is ignored, skip it:\n\n\n if (opts.ignorePaths.some(function (oneOfPathsToIgnore) {\n return matcher.isMatch(innerObj.path, oneOfPathsToIgnore);\n })) {\n return current;\n }\n\n var isNotAnArrayChild = !(!isObj(current) && !Array.isArray(current) && Array.isArray(innerObj.parent)); // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █\n\n var optsSchemaHasThisPathDefined = false;\n\n if (isObj(opts.schema) && hasKey.call(opts.schema, innerObj.path)) {\n optsSchemaHasThisPathDefined = true;\n }\n\n var refHasThisPathDefined = false;\n\n if (isObj(ref) && objectPath.has(ref, innerObj.path)) {\n refHasThisPathDefined = true;\n } // ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █\n // First, check if given path is not covered by neither ref object nor schema.\n // We also skip the non-container types (obj/arr) within arrays (test 02.11)\n // Otherwise, we would get false throws because arrays can mention list of\n // \"things\" (tag names, for example) and this application would enforce each\n // one of them, does it exist in schema/ref, but it won't exist!\n // Thus, strict existence checks apply only for object keys and arrays, not\n // array elements which are not objects/arrays.\n\n\n if (opts.enforceStrictKeyset && isNotAnArrayChild && !optsSchemaHasThisPathDefined && !refHasThisPathDefined) {\n throw new TypeError(opts.msg + \": \" + opts.optsVarName + \".\" + innerObj.path + \" is neither covered by reference object (second input argument), nor \" + opts.optsVarName + \".schema! To stop this error, turn off \" + opts.optsVarName + \".enforceStrictKeyset or provide some type reference (2nd argument or \" + opts.optsVarName + \".schema).\\n\\nDebug info:\\n\\nobj = \" + JSON.stringify(obj, null, 4) + \"\\n\\nref = \" + JSON.stringify(ref, null, 4) + \"\\n\\ninnerObj = \" + JSON.stringify(innerObj, null, 4) + \"\\n\\nopts = \" + JSON.stringify(opts, null, 4) + \"\\n\\ncurrent = \" + JSON.stringify(current, null, 4) + \"\\n\\n\");\n } else if (optsSchemaHasThisPathDefined) {\n // step 1. Fetch the current keys' schema and normalise it - it's an array\n // which holds strings. Those strings have to be lowercased. It also can\n // be raw null/undefined, which would be arrayified and turned into string.\n var currentKeysSchema = arrayiffy(opts.schema[innerObj.path]).map(function (el) {\n return (\"\" + el).toLowerCase();\n });\n objectPath.set(opts.schema, innerObj.path, currentKeysSchema); // step 2. First check does our schema contain any blanket names, \"any\", \"whatever\" etc.\n\n if (!lodash_intersection(currentKeysSchema, NAMESFORANYTYPE).length) {\n // Because, if not, it means we need to do some work, check types.\n // Beware, Booleans can be allowed blanket, as \"boolean\", but also,\n // in granular fashion: as just \"true\" or just \"false\".\n if (current !== true && current !== false && !currentKeysSchema.includes(typeDetect(current).toLowerCase()) || (current === true || current === false) && !currentKeysSchema.includes(String(current)) && !currentKeysSchema.includes(\"boolean\")) {\n // new in v.2.2\n // Check if key's value is array. Then, if it is, check if opts.acceptArrays is on.\n // If it is, then iterate through the array, checking does each value conform to the\n // types listed in that key's schema entry.\n if (Array.isArray(current) && opts.acceptArrays) {\n // check each key:\n for (var i = 0, len = current.length; i < len; i++) {\n if (!currentKeysSchema.includes(typeDetect(current[i]).toLowerCase())) {\n throw new TypeError(opts.msg + \": \" + opts.optsVarName + \".\" + innerObj.path + \".\" + i + \", the \" + i + \"th element (equal to \" + JSON.stringify(current[i], null, 0) + \") is of a type \" + typeDetect(current[i]).toLowerCase() + \", but only the following are allowed by the \" + opts.optsVarName + \".schema: \" + currentKeysSchema.join(\", \"));\n }\n }\n } else {\n // only then do throw...\n throw new TypeError(opts.msg + \": \" + opts.optsVarName + \".\" + innerObj.path + \" was customised to \" + (typeDetect(current) !== \"string\" ? '\"' : \"\") + JSON.stringify(current, null, 0) + (typeDetect(current) !== \"string\" ? '\"' : \"\") + \" (type: \" + typeDetect(current).toLowerCase() + \") which is not among the allowed types in schema (which is equal to \" + JSON.stringify(currentKeysSchema, null, 0) + \")\");\n }\n }\n } else {\n ignoredPathsArr.push(innerObj.path);\n }\n } else if (ref && isObj(ref) && refHasThisPathDefined) {\n var compareTo = objectPath.get(ref, innerObj.path);\n\n if (opts.acceptArrays && Array.isArray(current) && !opts.acceptArraysIgnore.includes(key)) {\n var allMatch = current.every(function (el) {\n return typeDetect(el).toLowerCase() === typeDetect(ref[key]).toLowerCase();\n });\n\n if (!allMatch) {\n throw new TypeError(opts.msg + \": \" + opts.optsVarName + \".\" + innerObj.path + \" was customised to be array, but not all of its elements are \" + typeDetect(ref[key]).toLowerCase() + \"-type\");\n }\n } else if (typeDetect(current) !== typeDetect(compareTo)) {\n throw new TypeError(opts.msg + \": \" + opts.optsVarName + \".\" + innerObj.path + \" was customised to \" + (typeDetect(current).toLowerCase() === \"string\" ? \"\" : '\"') + JSON.stringify(current, null, 0) + (typeDetect(current).toLowerCase() === \"string\" ? \"\" : '\"') + \" which is not \" + typeDetect(compareTo).toLowerCase() + \" but \" + typeDetect(current).toLowerCase());\n }\n } else ;\n\n return current;\n });\n}", "title": "" }, { "docid": "498fcbfde9cd2542fa579eafdf5174da", "score": "0.49068552", "text": "function dummy_func () {}", "title": "" }, { "docid": "48fcac54bfa377471ae4573d25c7e35f", "score": "0.49047905", "text": "expressive() {\n \n }", "title": "" }, { "docid": "56ed732e20fa59a6550e2a2358db579b", "score": "0.489624", "text": "get javaInterface() {}", "title": "" }, { "docid": "e3e2bb4d0241a12cbb016aa67b1e7dca", "score": "0.48883864", "text": "function Composition() {}", "title": "" }, { "docid": "e3e2bb4d0241a12cbb016aa67b1e7dca", "score": "0.48883864", "text": "function Composition() {}", "title": "" }, { "docid": "e3e2bb4d0241a12cbb016aa67b1e7dca", "score": "0.48883864", "text": "function Composition() {}", "title": "" }, { "docid": "e3e2bb4d0241a12cbb016aa67b1e7dca", "score": "0.48883864", "text": "function Composition() {}", "title": "" }, { "docid": "695660d1dfed69ccbc3616f4344f2d95", "score": "0.4887434", "text": "function o$41(o,e,t){let a,c;return void 0===e||Array.isArray(e)?(c=o,t=e,a=[void 0]):(c=e,a=Array.isArray(o)?o:[o]),(o,e)=>{const d=o.constructor.prototype;a.forEach((a=>{const s=d$3X(o,a,c);s.read&&\"object\"==typeof s.read||(s.read={}),s.read.reader=d[e],t&&(s.read.source=(s.read.source||[]).concat(t));}));}}", "title": "" }, { "docid": "7678ec89fde4ddd60213e98e92767551", "score": "0.4881828", "text": "run() {\n this.speak('hey, what up?'); \n this.restParameters('one', 'two', 'three');\n this.spread();\n this.forOf();\n this.destructuring();\n this.mapObj();\n this.shorthandMethods();\n }", "title": "" }, { "docid": "1ed34e37a75266ba52a0eac0fc54e58b", "score": "0.48743698", "text": "function o(){return function(){}}", "title": "" }, { "docid": "6bf9fce25d9f8a7b498ef6c3c7e92502", "score": "0.487293", "text": "function struct(target) {\n}", "title": "" }, { "docid": "5412cbec186d84761f7c0bb74ddbad34", "score": "0.48554233", "text": "function __func(){}", "title": "" }, { "docid": "4a41f32d2529b448554ba704a2e7c4f6", "score": "0.4849651", "text": "function d(t, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ne) {\n return t;\n}", "title": "" }, { "docid": "b505533f5b947b2f377f14431b8f9bfe", "score": "0.48456272", "text": "function r(t){var e=Object(i[\"a\"])(t);return null!==t&&(\"object\"===e||\"function\"===e)}", "title": "" }, { "docid": "aec282356988a9469803da0bd7f156d2", "score": "0.48304507", "text": "function UsesV2ReturnPass1(base, prop) {\n this.baseName = base;\n this.prop = prop;\n}", "title": "" }, { "docid": "0bd6db99821457331be88cd99280c1fb", "score": "0.48206472", "text": "function P(t, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ne) {\n return t;\n}", "title": "" }, { "docid": "f1f76ab67b287c356f600e863c6a0a27", "score": "0.4819996", "text": "function f(e){const t={inspect:function(){return e}};return u.inspect.custom&&(t[u.inspect.custom]=t.inspect),t}", "title": "" }, { "docid": "cad3642109f67b12c076a7327bd3926b", "score": "0.4817505", "text": "static defaultTransform(): Transform {\n /* eslint-disable no-unused-vars */\n return (\n jsonObj: any,\n query?: Query,\n requiredProps?: RequiredContractProps,\n ) => jsonObj;\n /* eslint-enable no-unused-vars */\n }", "title": "" }, { "docid": "c4ad70c14db161a8249749d3fe6828bc", "score": "0.48068723", "text": "next(){ /** todo */ }", "title": "" }, { "docid": "31ca3b893a7e6d0a12e6b7e3e7293b64", "score": "0.48043355", "text": "function BasicProxy() {}", "title": "" }, { "docid": "5628e8f8c3dd0f710eb9e7ccb6514e64", "score": "0.4801503", "text": "function r2(){return function(S){return S}}", "title": "" }, { "docid": "0256b754b371dbd60579a8fe63aaaa62", "score": "0.47916463", "text": "function ai(t){if(t instanceof $[\"a\"])return t.id;if(t instanceof oi[\"a\"])return t.get(\"id\");throw new Error(\"Illegal interaction argument\")}", "title": "" }, { "docid": "2d86ba4f147bb619fba685ef3fa27b96", "score": "0.47856438", "text": "function Interfaz(){}", "title": "" }, { "docid": "0707e2276203dfe049e92d77ca4d36f7", "score": "0.4783547", "text": "extend() {}", "title": "" }, { "docid": "6b2c3365475968136d6cb24401fef205", "score": "0.47801337", "text": "function ba(){}", "title": "" }, { "docid": "6b2c3365475968136d6cb24401fef205", "score": "0.47801337", "text": "function ba(){}", "title": "" }, { "docid": "6b2c3365475968136d6cb24401fef205", "score": "0.47801337", "text": "function ba(){}", "title": "" }, { "docid": "6b2c3365475968136d6cb24401fef205", "score": "0.47801337", "text": "function ba(){}", "title": "" }, { "docid": "6b2c3365475968136d6cb24401fef205", "score": "0.47801337", "text": "function ba(){}", "title": "" }, { "docid": "6b2c3365475968136d6cb24401fef205", "score": "0.47801337", "text": "function ba(){}", "title": "" }, { "docid": "5d24a569fe0c15f0f2df693334ba9069", "score": "0.47762424", "text": "static resolve(value){return Thenable.resolve(value);}", "title": "" }, { "docid": "9c89ea570e6d72ddc58e064cff3fb8fe", "score": "0.47692138", "text": "function So(){}", "title": "" }, { "docid": "f84fdf079860f235df33ba4a56c6018f", "score": "0.4767647", "text": "logic() {}", "title": "" }, { "docid": "43e2d6f32117f8c47b7054f9a04348b5", "score": "0.47665164", "text": "function wow(name,my){\n return my(name);\n}", "title": "" }, { "docid": "9390b49df53a56a431a00402aee26541", "score": "0.47644153", "text": "function Ex(){return Ex=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},Ex.apply(this,arguments)}", "title": "" }, { "docid": "cce5296e1a7d575ac7223be638765bf5", "score": "0.4763814", "text": "function r(e){return function(){return e}}", "title": "" } ]
f261d8dfe06119762be5f4e469fa470a
Handle end of animations, updating the state of the snackbar.
[ { "docid": "dccb1fcba261e4bd3416c7fd7ac98444", "score": "0.63487464", "text": "onAnimationEnd(event) {\n const { fromState, toState } = event;\n if ((toState === 'void' && fromState !== 'void') || toState === 'hidden') {\n this._completeExit();\n }\n if (toState === 'visible') {\n // Note: we shouldn't use `this` inside the zone callback,\n // because it can cause a memory leak.\n const onEnter = this._onEnter;\n this._ngZone.run(() => {\n onEnter.next();\n onEnter.complete();\n });\n }\n }", "title": "" } ]
[ { "docid": "127447d3c6145e76d7ca24932a624de0", "score": "0.68615526", "text": "notifyAnimationEnd() {}", "title": "" }, { "docid": "c417b06c2ffb3ff2c06148cbbe4cbd8e", "score": "0.67025536", "text": "function _onAnimationEnd () {\n clearTimeout(transitionEndTimeout);\n $target.off(events);\n animationEnded();\n deferred.resolve();\n }", "title": "" }, { "docid": "678890d692b25df29648e39de7c94501", "score": "0.66407645", "text": "onAnimationEnd() {\n\n }", "title": "" }, { "docid": "8330d848fe13f75325d248c2c4f250da", "score": "0.66247946", "text": "function handleAnimationEnd() {\n node.classList.remove(`${prefix}animated`, animationName);\n node.removeEventListener('animationend', handleAnimationEnd);\n\n resolve('Animation ended');\n }", "title": "" }, { "docid": "c2c010a50cbb6405bd181517ec0da1bf", "score": "0.6593626", "text": "function handleAnimationEnd() {\r\n node.classList.remove(`${prefix}animated`, animationName);\r\n node.removeEventListener('animationend', handleAnimationEnd);\r\n\r\n resolve('Animation ended');\r\n }", "title": "" }, { "docid": "59de4697e5b57e98ac9c44e7757f1269", "score": "0.6524334", "text": "handleAnimationEnd() {\n this.isAnimating = false;\n this.index = (this.index + 1) % this.greetings.length;\n\n setTimeout(() => this.updateGreeting(), 500);\n }", "title": "" }, { "docid": "f609b5e766dfa898264c88ed757e12e3", "score": "0.64487684", "text": "transitionCompleted() {\n // implement if needed\n }", "title": "" }, { "docid": "fca0eeab0c4fd887012ef5e26634b687", "score": "0.64301956", "text": "_onEnd() {\n this._duringDisplayAnim = false;\n // - need to re render at the end of the display animation\n this._setAnimParams();\n }", "title": "" }, { "docid": "666bcb4b3bd1785fbd0aa09db8ffe6cc", "score": "0.6428858", "text": "function handleAnimationEnd(event) {\n event.stopPropagation();\n node.classList.remove(`${prefix}animated`, animationName);\n resolve('Animation ended');\n }", "title": "" }, { "docid": "0d85747b3e791e70be5f19ef101e6373", "score": "0.6427843", "text": "_onAnimationEnd() {\n // Clean up the old container. This is done after the animation to avoid garbage\n // collection during the animation and because the black box updates need it.\n if (this._oldContainer) {\n this._oldContainer.removeFromParent();\n this._oldContainer.destroy();\n this._oldContainer = null;\n }\n\n if (this._delContainer) {\n this._delContainer.removeFromParent();\n this._delContainer.destroy();\n this._delContainer = null;\n }\n\n // Fire ready event saying animation is finished.\n if (!this.AnimationStopped) this.RenderComplete();\n\n // Restore event listeners\n this.EventManager.addListeners(this);\n\n // Reset animation flags\n this.Animation = null;\n this.AnimationStopped = false;\n }", "title": "" }, { "docid": "0c28f26339f8eb45b3d6752664c56c58", "score": "0.6404746", "text": "handleAnimationEnded ( result ) {\n \n if( result ) {\n this.props.handleOnChangeSurvey(this.state);\n }\n }", "title": "" }, { "docid": "abf218d8e7bd581435cb1cc10082a2dc", "score": "0.6383096", "text": "function handleAnimationEnd(event) {\n event.stopPropagation();\n node.classList.remove(`${prefix}animated`, animationName);\n resolve('Animation ended');\n }", "title": "" }, { "docid": "7ca0f697ce30e056a2374ba90996b33e", "score": "0.63817585", "text": "function handleAnimationEnd(event) {\n event.stopPropagation();\n node.classList.remove(`${prefix}animated`, animationName);\n resolve('Animation ended');\n }", "title": "" }, { "docid": "c7314619344d470046e156dad7ee5e22", "score": "0.63749784", "text": "function handleSnackbarClose() {\n setSnackbarState({\n ...snackbarState,\n open: false,\n });\n }", "title": "" }, { "docid": "114e9628c86e096bfe7dc6e9646fc367", "score": "0.63493025", "text": "function onAnimationEnd(e) {\n if ($element.hasClass('mos-hiding')) {\n // If it's a TransitionEvent and there is a timer, cancel it (otherwise the events will be fired twice)\n if (e && hideTimer) $timeout.cancel(hideTimer);\n\n $element.addClass('mos-hidden');\n $element.removeClass('mos-hiding');\n dispatch('onFinish');\n }\n }", "title": "" }, { "docid": "a9ac3eca56efb9795de016746bead58c", "score": "0.6339944", "text": "handleAnimationEnd(e) {\r\n\t\tthis.ended=true;\r\n\t\te.stopPropagation();\r\n\t\tif (this.props.onAnimateEnd) this.props.onAnimateEnd({\r\n\t\t\tcomponent:this,\r\n\t\t\tnativeEvent:e\r\n\t\t});\r\n\t}", "title": "" }, { "docid": "33ec7595f43b114d33ee5fc431e80e86", "score": "0.62996083", "text": "exit() {\n // Note: this one transitions to `hidden`, rather than `void`, in order to handle the case\n // where multiple snack bars are opened in quick succession (e.g. two consecutive calls to\n // `MatSnackBar.open`).\n this._animationState = 'hidden';\n // Mark this element with an 'exit' attribute to indicate that the snackbar has\n // been dismissed and will soon be removed from the DOM. This is used by the snackbar\n // test harness.\n this._elementRef.nativeElement.setAttribute('mat-exit', '');\n return this._onExit;\n }", "title": "" }, { "docid": "ef0fe601ea6b9ee5d2fe95a11e916fdf", "score": "0.6266093", "text": "handleSnackbarClose() {\n\t\tthis.setState({\n\t\t\tsnackbarOpen: false\n\t\t});\n\t}", "title": "" }, { "docid": "fa1489a55b839c39a8b2c355fe3c2f36", "score": "0.62592155", "text": "exit() {\n // It's common for snack bars to be opened by random outside calls like HTTP requests or\n // errors. Run inside the NgZone to ensure that it functions correctly.\n this._ngZone.run(() => {\n // Note: this one transitions to `hidden`, rather than `void`, in order to handle the case\n // where multiple snack bars are opened in quick succession (e.g. two consecutive calls to\n // `MatSnackBar.open`).\n this._animationState = 'hidden';\n // Mark this element with an 'exit' attribute to indicate that the snackbar has\n // been dismissed and will soon be removed from the DOM. This is used by the snackbar\n // test harness.\n this._elementRef.nativeElement.setAttribute('mat-exit', '');\n // If the snack bar hasn't been announced by the time it exits it wouldn't have been open\n // long enough to visually read it either, so clear the timeout for announcing.\n clearTimeout(this._announceTimeoutId);\n });\n return this._onExit;\n }", "title": "" }, { "docid": "1ff9d71f72c930957d69a1945a2ac9cb", "score": "0.62030786", "text": "function handleAnimationEnd(event) {\n\t\tevent.stopPropagation();\n\t\tnode.classList.remove(`${prefix}animated`, animationName);\n\t\tresolve('Animation ended');\n\t}", "title": "" }, { "docid": "b3869cbeb137576d9781c1b2f75e24a6", "score": "0.6185361", "text": "function handleAnimationEnd(event) {\n event.stopPropagation();\n if(animationName !== event.animationName)\n {\n //ended other animation => ignore it callback now\n //console.error(animationName);\n //console.error(event);\n\n log('Animation end '+event.animationName+'; Expected: '+animationName );\n return;\n }\n\n node.classList.remove(animationName);\n\n log('Animation ended '+animationName );\n resolve('Animation ended '+animation);\n }", "title": "" }, { "docid": "a6a41d5926a46cbb5cb9bbfb4baa18f8", "score": "0.61246324", "text": "OnAnimationEnd() {\n // Remove the container containing the delete animations\n if (this._deleteContainer) {\n this.removeChild(this._deleteContainer);\n this._deleteContainer = null;\n }\n\n // Clean up the old container used by black box updates\n if (this._oldContainer) {\n this.removeChild(this._oldContainer);\n this._oldContainer = null;\n }\n\n // Restore event listeners\n this.EventManager.addListeners(this);\n\n // Restore visual effects on node with keyboard focus\n this._processInitialFocus(true);\n\n // Process the highlightedCategories\n this._processInitialHighlighting();\n\n if (!this.AnimationStopped) this.RenderComplete();\n\n // Reset animation flags\n this.Animation = null;\n this.AnimationStopped = false;\n }", "title": "" }, { "docid": "4209ea3a93303b9b01db62ca16421ef3", "score": "0.6111533", "text": "onAnimationEnd(event) {\n if (event.animationName === 'b-ripple-expand') {\n this.hide();\n }\n }", "title": "" }, { "docid": "d863e5d68ab3aaae26849505d41c8d7c", "score": "0.61079", "text": "onAnimationEnd(event) {\n if (event.animationName === 'b-ripple-expand') {\n this.hide();\n }\n }", "title": "" }, { "docid": "35f3d17f137f8b0bd4c7e80e32f13bd9", "score": "0.6106655", "text": "exit() {\n if (!this._destroyed) {\n this._animationState = 'hidden';\n this._changeDetectorRef.markForCheck();\n }\n }", "title": "" }, { "docid": "c1fa95b2d4f022e4b38019074d6f11d8", "score": "0.60957694", "text": "function finished(ev) {\n if (ev && ev.target !== element[0]) return;\n\n if (ev) $timeout.cancel(timer);\n element.off($mdConstant.CSS.TRANSITIONEND, finished);\n\n // Never reject since ngAnimate may cause timeouts due missed transitionEnd events\n resolve();\n\n }", "title": "" }, { "docid": "160bc44525496fc16ba0deefe3d39bc9", "score": "0.6082147", "text": "function handleAnimationEnd(event) {\n event.stopPropagation();\n node.classList.remove(`${prefix}animated`, animationName);\n node.classList.remove(`animate__faster`);\n resolve('Animation ended');\n }", "title": "" }, { "docid": "992cb9ad910d8803f22d345b2fbb774e", "score": "0.6079769", "text": "handleAnimationEnd() {\n this.setState({ triggerEnabled: false });\n }", "title": "" }, { "docid": "6b6552680f9136666841410b0066cbe3", "score": "0.60779387", "text": "function finished(ev) {\n if ( ev && ev.target !== element[0]) return;\n\n if ( ev ) $timeout.cancel(timer);\n element.off($mdConstant.CSS.TRANSITIONEND, finished);\n\n // Never reject since ngAnimate may cause timeouts due missed transitionEnd events\n resolve();\n\n }", "title": "" }, { "docid": "b63c42ff3e7c23b7d01cedf13495260f", "score": "0.6071301", "text": "animationEnd() {\n if (this.movements.length !== 0) {\n this.nextMove()\n } else {\n this.orchestrator.camera.startAnimation(\"position\", 1.5, () => {\n this.orchestrator.changeState(new GameOverState(this.orchestrator))\n },\n [...this.orchestrator.camera.originalPosition],\n [\n this.orchestrator.gameboardProperties.x,\n this.orchestrator.gameboardProperties.y,\n this.orchestrator.gameboardProperties.z\n ])\n }\n\n }", "title": "" }, { "docid": "97e3bcebd5e6b2e2e9b89fc4edbbfb95", "score": "0.6041278", "text": "function finished(ev) {\n if ( ev && ev.target !== element[0]) return;\n\n if ( ev ) $timeout.cancel(timer);\n element.off($mdConstant.CSS.TRANSITIONEND, finished);\n\n // Never reject since ngAnimate may cause timeouts due missed transitionEnd events\n resolve();\n\n }", "title": "" }, { "docid": "5f2468deab938638e7b9a7e05a4ff10b", "score": "0.6040381", "text": "function handleAnimationEnd(event) {\n event.stopPropagation();\n removeClasses(el, animation);\n\n if(animation === 'rollIn'){\n el.classList.add('rolling')\n\n el.addEventListener('click', () => {\n el.classList.add(`animate__animated`, `animate__rollOut`);\n })\n }\n\n checkAnimateLate(el)\n \n resolve('Animation ended');\n }", "title": "" }, { "docid": "7be9be82cea2ae902106d0ce7239e11d", "score": "0.6038779", "text": "_onAnimationDone({ toState, totalTime }) {\n if (toState === 'enter') {\n this._openAnimationDone(totalTime);\n }\n else if (toState === 'exit') {\n this._animationStateChanged.next({ state: 'closed', totalTime });\n }\n }", "title": "" }, { "docid": "7be9be82cea2ae902106d0ce7239e11d", "score": "0.6038779", "text": "_onAnimationDone({ toState, totalTime }) {\n if (toState === 'enter') {\n this._openAnimationDone(totalTime);\n }\n else if (toState === 'exit') {\n this._animationStateChanged.next({ state: 'closed', totalTime });\n }\n }", "title": "" }, { "docid": "1fa0c83484285c1c7f61c33d6f4709e4", "score": "0.60353136", "text": "onAnimationEnd(event) {\n if (event.animationName === 'b-ripple-expand') {\n this.hide();\n }\n }", "title": "" }, { "docid": "26be66c7296529f387fa7000985c9fc4", "score": "0.60288256", "text": "function finished(ev) {\n if ( ev && ev.target !== element[0]) return;\n\n if ( ev ) $timeout.cancel(timer);\n element.off($mdConstant.CSS.TRANSITIONEND, finished);\n\n // Never reject since ngAnimate may cause timeouts due missed transitionEnd events\n resolve();\n\n }", "title": "" }, { "docid": "26be66c7296529f387fa7000985c9fc4", "score": "0.60288256", "text": "function finished(ev) {\n if ( ev && ev.target !== element[0]) return;\n\n if ( ev ) $timeout.cancel(timer);\n element.off($mdConstant.CSS.TRANSITIONEND, finished);\n\n // Never reject since ngAnimate may cause timeouts due missed transitionEnd events\n resolve();\n\n }", "title": "" }, { "docid": "44e030938152b3f18dd0d4c9e227f876", "score": "0.6014398", "text": "function onEnd() {\n element.off(css3AnimationEvents, onAnimationProgress);\n $$jqLite.removeClass(element, activeClassName);\n $$jqLite.removeClass(element, pendingClassName);\n if (staggerTimeout) {\n $timeout.cancel(staggerTimeout);\n }\n animateClose(element, className);\n var node = extractElementNode(element);\n for (var i in appliedStyles) {\n node.style.removeProperty(appliedStyles[i]);\n }\n }", "title": "" }, { "docid": "44e030938152b3f18dd0d4c9e227f876", "score": "0.6014398", "text": "function onEnd() {\n element.off(css3AnimationEvents, onAnimationProgress);\n $$jqLite.removeClass(element, activeClassName);\n $$jqLite.removeClass(element, pendingClassName);\n if (staggerTimeout) {\n $timeout.cancel(staggerTimeout);\n }\n animateClose(element, className);\n var node = extractElementNode(element);\n for (var i in appliedStyles) {\n node.style.removeProperty(appliedStyles[i]);\n }\n }", "title": "" }, { "docid": "44e030938152b3f18dd0d4c9e227f876", "score": "0.6014398", "text": "function onEnd() {\n element.off(css3AnimationEvents, onAnimationProgress);\n $$jqLite.removeClass(element, activeClassName);\n $$jqLite.removeClass(element, pendingClassName);\n if (staggerTimeout) {\n $timeout.cancel(staggerTimeout);\n }\n animateClose(element, className);\n var node = extractElementNode(element);\n for (var i in appliedStyles) {\n node.style.removeProperty(appliedStyles[i]);\n }\n }", "title": "" }, { "docid": "031ec28cb52d09b83b0b427a56a982d3", "score": "0.6003787", "text": "function onEnd() {\n element.off(css3AnimationEvents, onAnimationProgress);\n $$jqLite.removeClass(element, activeClassName);\n $$jqLite.removeClass(element, pendingClassName);\n if (staggerTimeout) {\n $timeout.cancel(staggerTimeout);\n }\n animateClose(element, className);\n var node = extractElementNode(element);\n for (var i in appliedStyles) {\n node.style.removeProperty(appliedStyles[i]);\n }\n }", "title": "" }, { "docid": "319c5cc4729d08ca801ca6a5e48ff3a1", "score": "0.6002056", "text": "_startExitAnimation() {\n this._state = 'exit';\n // Mark the container for check so it can react if the\n // view container is using OnPush change detection.\n this._changeDetectorRef.markForCheck();\n }", "title": "" }, { "docid": "319c5cc4729d08ca801ca6a5e48ff3a1", "score": "0.6002056", "text": "_startExitAnimation() {\n this._state = 'exit';\n // Mark the container for check so it can react if the\n // view container is using OnPush change detection.\n this._changeDetectorRef.markForCheck();\n }", "title": "" }, { "docid": "319c5cc4729d08ca801ca6a5e48ff3a1", "score": "0.6002056", "text": "_startExitAnimation() {\n this._state = 'exit';\n // Mark the container for check so it can react if the\n // view container is using OnPush change detection.\n this._changeDetectorRef.markForCheck();\n }", "title": "" }, { "docid": "dcc704f71fe8b2b78cbb4071d6e40791", "score": "0.5973608", "text": "handleAnimationEnd() {\n clearTimeout(this.animEndLatchTimer_);\n this.animEndLatchTimer_ = setTimeout(() => {\n this.adapter_.removeClass(this.currentAnimationClass_);\n this.adapter_.deregisterAnimationEndHandler(this.animEndHandler_);\n }, numbers$1.ANIM_END_LATCH_MS);\n }", "title": "" }, { "docid": "efeb29466a1db8c7145081195ccb5abc", "score": "0.5960803", "text": "#onAnimationFinish(state) {\n\t\t// Set the open attribute based on the parameter\n\t\tthis.state = state;\n\t\t// Clear the stored animation\n\t\tthis.animation = null;\n\t\t// Reset isClosing & isExpanding\n\t\tthis.isClosing = false;\n\t\tthis.isExpanding = false;\n\t\t// Remove the overflow hidden and the fixed height\n\t\tthis.element.style.height = this.element.style.overflow = '';\n\t}", "title": "" }, { "docid": "46d7797096a2174965c61354441213a1", "score": "0.59075814", "text": "_onAnimationDone(event) {\n this._animationDone.next(event);\n this._isAnimating = false;\n }", "title": "" }, { "docid": "dd938d4691c6a81874ce2fa1ee98a206", "score": "0.5905581", "text": "_onEndAnim() {\n if (this._indicator) {\n this._indicator.getParent().removeChild(this._indicator);\n this._indicator = null;\n }\n }", "title": "" }, { "docid": "56cd5bb2a56845366d009fc5b4d43307", "score": "0.5900388", "text": "handleShakeAnimationEnd_() {\n const {LABEL_SHAKE} = MDCFloatingLabelFoundation.cssClasses;\n this.adapter_.removeClass(LABEL_SHAKE);\n }", "title": "" }, { "docid": "56cd5bb2a56845366d009fc5b4d43307", "score": "0.5900388", "text": "handleShakeAnimationEnd_() {\n const {LABEL_SHAKE} = MDCFloatingLabelFoundation.cssClasses;\n this.adapter_.removeClass(LABEL_SHAKE);\n }", "title": "" }, { "docid": "3756f6fc843ebf316e098fc1bb178f89", "score": "0.588532", "text": "function _transitionComplete() {\n this.dispatchEvent( BaseTransition.END_EVENT, { target: this } );\n\n if ( element.scrollHeight > previousHeight ) {\n element.style.maxHeight = element.scrollHeight + 'px';\n }\n }", "title": "" }, { "docid": "f22d31f9a9b35b0e752b5cb8afdc84b4", "score": "0.5876196", "text": "function frameAnimationEnd() {\n f.animatedFrames = f.animatedFrames || 0;\n f.animatedFrames++;\n if(f.animatedFrames == f.frameItems.length){\n f.finished = true;\n f.o.cbFinished.call(f);\n }\n \n }", "title": "" }, { "docid": "cc43a2f58820df859e2532f0fb797058", "score": "0.58728176", "text": "function finish() {\n if (!isIn) element.hide();\n reset();\n if (cb) cb.apply(element);\n } // Resets transitions and removes motion-specific classes", "title": "" }, { "docid": "33b3f129f762dd87064d01a7dc148e39", "score": "0.5864146", "text": "function finished(ev){if(ev&&ev.target!==element[0])return;if(ev)$timeout.cancel(timer);element.off($mdConstant.CSS.TRANSITIONEND,finished);// Never reject since ngAnimate may cause timeouts due missed transitionEnd events\n\tresolve();}", "title": "" }, { "docid": "da63a8aa4dba361b8d67730d880be8d9", "score": "0.5859938", "text": "_animationDoneListener(event) {\n this._animationEnd.next(event);\n }", "title": "" }, { "docid": "79758ac8b92ef275d22ea5d6d8e0a438", "score": "0.58376336", "text": "function onEnd() {\n wrapper.classed( 'no-transition', true );\n wrapperNode.removeEventListener( 'transitionend', onEnd );\n }", "title": "" }, { "docid": "aef945e382b6f439479a0c6160ebf08b", "score": "0.5830965", "text": "function onEnd() {\n\t\t\t\t\t\t\telement.off(css3AnimationEvents, onAnimationProgress);\n\t\t\t\t\t\t\t$$jqLite.removeClass(element, activeClassName);\n\t\t\t\t\t\t\t$$jqLite.removeClass(element, pendingClassName);\n\t\t\t\t\t\t\tif (staggerTimeout) {\n\t\t\t\t\t\t\t\t$timeout.cancel(staggerTimeout);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tanimateClose(element, className);\n\t\t\t\t\t\t\tvar node = extractElementNode(element);\n\t\t\t\t\t\t\tfor (var i in appliedStyles) {\n\t\t\t\t\t\t\t\tnode.style.removeProperty(appliedStyles[i]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}", "title": "" }, { "docid": "98c51b1c7bdd1ebc3392ce494d90b0ed", "score": "0.5821771", "text": "function animationComplete() {\n\t\t\t\t\t\tself._setHashTag();\n\t\t\t\t\t\tself.active = false;\n\t\t\t\t\t\tself._resetAutoPlay(true, self.settings.autoPlayDelay);\n\t\t\t\t\t}", "title": "" }, { "docid": "9294baad4759bfa0e8280c009005d10c", "score": "0.58103836", "text": "function finish() {\n// if (--finished == 0) {\n if (!isFinished) {\n isFinished = true;\n Physics.there.style(self.from.getContainerBodyId(), {\n opacity: 0\n });\n\n self.dfd.resolve();\n }\n }", "title": "" }, { "docid": "7a1870dcef2448d451ede67d745c1a6c", "score": "0.5800777", "text": "_finishDismiss() {\n this._overlayRef.dispose();\n if (!this._onAction.closed) {\n this._onAction.complete();\n }\n this._afterDismissed.next({ dismissedByAction: this._dismissedByAction });\n this._afterDismissed.complete();\n this._dismissedByAction = false;\n }", "title": "" }, { "docid": "4f5f600aed73bf72be6a719d84a8b9ef", "score": "0.5798055", "text": "function snackbarClose() {\n\tsnackbar.classList.remove('snackbar__wrapper');\n\tsnackbar.classList.add('snackbar__wrapper--hidden');\n}", "title": "" }, { "docid": "230dc05a543ec4f400284c3eeb506365", "score": "0.57705826", "text": "function _finish(){\n logger.logEvent({'msg': 'animation finished'});\n if(logHeartbeat){\n clearInterval(logHeartbeat);\n }\n $('#finished-bg').fadeIn();\n if(currentMusicObj){\n __musicFade(currentMusicObj, false,1/(2000/MUSIC_ANIMATION_INTERVAL), false); //Fadeout animation for 2 seconds\n }\n for(var i=0; i<animationFinishObserver.length; i++){\n animationFinishObserver[i]();\n }\n _stopAllQueues();\n\n //Change pause button to replay\n var button = $('#play-toggle');\n button.removeClass('icon-pause');\n button.addClass('icon-repeat');\n button.unbind('click');\n button.bind('click', function(){location.reload();});\n\n for(var i = 0; i< currentAnimation.length; i++){ //Stop active animations (i.e. background)\n for(var j = 0; j<currentAnimation[i].length; j++){\n var node = currentAnimation[i][j];\n if('animation' in node){\n var _animation = node['animation'];\n if('object' in _animation){\n var _obj=_animation['object'];\n if(_obj){\n _obj.stop();\n }\n }\n }\n }\n }\n }", "title": "" }, { "docid": "2208902a82fb2a8226a58e2832315d89", "score": "0.57672745", "text": "function endAnimation() {\n let endAnimationText = getEndAnimation();\n endAnimationText.innerHTML = \"Finished!\";\n endAnimationText.style.fontSize = \"50px\";\n const finishedSound = audioFiles.finishedSound;\n if(audioOn && inhaleHold > 0) {\n finishedSound.load();\n finishedSound.play();\n }\n endEarlyDetails();\n}", "title": "" }, { "docid": "3f44d7dd52894b9ecb687e54ce7bcef2", "score": "0.57641524", "text": "_onAnimationDone({ toState, totalTime }) {\n if (toState === 'enter') {\n this._trapFocus();\n this._animationStateChanged.next({ state: 'opened', totalTime });\n }\n else if (toState === 'exit') {\n this._restoreFocus();\n this._animationStateChanged.next({ state: 'closed', totalTime });\n }\n }", "title": "" }, { "docid": "751c798da5eae3c08878f1be34635c31", "score": "0.5760589", "text": "function setEndAnimation() {\r\n\t\t\tinAnimation = false;\r\n\t\t}", "title": "" }, { "docid": "8991008cbf77be745571250aea2d5175", "score": "0.5754663", "text": "function handleToastAnimationEnd() {\n // remove any class on the toast variable \n toast.removeAttribute(\"class\");\n // if shouldNavigate is true , go back to home page\n if (shouldNavigateAway) {\n location.href = \"/\";\n }\n}", "title": "" }, { "docid": "deb3248b93aeeafb3ac1e657a60dd6c9", "score": "0.57307404", "text": "function transitionEnd() {\n\t\t\t\t\tif (bouncing) {\n\t\t\t\t\t\tbouncing = false;\n\t\t\t\t\t\treboundScroll();\n\t\t\t\t\t}\n\n\t\t\t\t\tclearTimeout(timeoutID);\n\t\t\t\t}", "title": "" }, { "docid": "e6db696cf287a48aac36b203d628707e", "score": "0.57230246", "text": "function handleToastAnimationEnd() {\n toast.removeAttribute(\"class\");\n if (shouldNavigateAway) {\n location.href = \"/\";\n }\n}", "title": "" }, { "docid": "08bb65ef5ac7b8fbb6df1286b2cfcfb0", "score": "0.57198274", "text": "finishTransition(transition) {\n // Unset the Semantic UI classes & styles for transitioning.\n transition.classes.forEach(c => this._renderer.removeClass(this._element, c));\n this._renderer.removeClass(this._element, `animating`);\n this._renderer.removeClass(this._element, transition.directionClass);\n this._renderer.removeStyle(this._element, `animationDuration`);\n this._renderer.removeStyle(this._element, `display`);\n if (transition.direction === TransitionDirection.In) {\n // If we have just animated in, we are now visible.\n this._isVisible = true;\n }\n else if (transition.direction === TransitionDirection.Out) {\n // If we have transitioned out, we should be invisible and hidden.\n this._isVisible = false;\n this._isHidden = true;\n }\n if (transition.onComplete) {\n // Call the user-defined transition callback.\n transition.onComplete();\n }\n // Delete the transition from the queue.\n this._queue.shift();\n this._isAnimating = false;\n this._changeDetector.markForCheck();\n // Immediately attempt to perform another transition.\n this.performTransition();\n }", "title": "" }, { "docid": "225e451b177de9e7020917fb40aecbf7", "score": "0.57038265", "text": "onDismissSnackBar() {\n this.props.dismissSnackbar();\n }", "title": "" }, { "docid": "765396ef45d47e78617057499a188ff1", "score": "0.569897", "text": "_animateSnackBar(snackBarRef, config) {\n // When the snackbar is dismissed, clear the reference to it.\n snackBarRef.afterDismissed().subscribe(() => {\n // Clear the snackbar ref if it hasn't already been replaced by a newer snackbar.\n if (this._openedSnackBarRef == snackBarRef) {\n this._openedSnackBarRef = null;\n }\n if (config.announcementMessage) {\n this._live.clear();\n }\n });\n if (this._openedSnackBarRef) {\n // If a snack bar is already in view, dismiss it and enter the\n // new snack bar after exit animation is complete.\n this._openedSnackBarRef.afterDismissed().subscribe(() => {\n snackBarRef.containerInstance.enter();\n });\n this._openedSnackBarRef.dismiss();\n }\n else {\n // If no snack bar is in view, enter the new snack bar.\n snackBarRef.containerInstance.enter();\n }\n // If a dismiss timeout is provided, set up dismiss based on after the snackbar is opened.\n if (config.duration && config.duration > 0) {\n snackBarRef.afterOpened().subscribe(() => snackBarRef._dismissAfter(config.duration));\n }\n if (config.announcementMessage) {\n this._live.announce(config.announcementMessage, config.politeness);\n }\n }", "title": "" }, { "docid": "3076fc681e99d2923de9e45634a17b28", "score": "0.5692396", "text": "onFinish() {\n\t\tif (this.props.onFinish) {\n\t\t\tthis.props.onFinish();\n\t\t}\n\t}", "title": "" }, { "docid": "e22a929f6a68567180a283e19eea502d", "score": "0.5671801", "text": "function onAnimationEnd() {\n // stop the last frame from being missed..\n rec.stop();\n }", "title": "" }, { "docid": "90a1fddeb3ac7660540718fb789f5149", "score": "0.56592333", "text": "onAnimationEnd_() {\n if (this.isOpen_()) {\n // On open sidebar\n const children = this.getRealChildren();\n this.scheduleLayout(children);\n this.scheduleResume(children);\n tryFocus(this.element);\n } else {\n // On close sidebar\n this.vsync_.mutate(() => {\n toggle(this.element, /* display */false);\n this.schedulePause(this.getRealChildren());\n });\n }\n }", "title": "" }, { "docid": "15e37a950a78c90ecfb07200b245b382", "score": "0.56553143", "text": "OnAnimationEnd() {\n // If the animation is complete (and not stopped), then rerender to restore any flourishes hidden during animation.\n if (!this.AnimationStopped) {\n this._container.removeChildren();\n\n // Finally, re-layout and render the component\n var availSpace = new Rectangle(0, 0, this.Width, this.Height);\n this.Layout(availSpace);\n this.Render(this._container, availSpace);\n\n // Reselect the nodes using the selection handler's state\n var selectedNodes = this._selectionHandler ? this._selectionHandler.getSelection() : [];\n for (var i = 0; i < selectedNodes.length; i++) selectedNodes[i].setSelected(true);\n }\n\n // : Force full angle extent in case the display animation didn't complete\n if (this._angleExtent < 2 * Math.PI) this._animateAngleExtent(2 * Math.PI);\n\n // Delegate to the superclass to clear common things\n super.OnAnimationEnd();\n }", "title": "" }, { "docid": "dfea3667c75d467824931e5ffdaeba73", "score": "0.5638411", "text": "function animcompleted() {\n\t\t\t\t\t\t}", "title": "" }, { "docid": "a64eff7c4bcfb5f31d88f7494d0fe30b", "score": "0.5636209", "text": "function onAnimationDone() {\n sourceFrameIndex = currentFrameIndex;\n if (playing) {\n waitTimeout();\n }\n }", "title": "" }, { "docid": "b549215015e869211dc94edee4fff1fa", "score": "0.5635376", "text": "function end_game_flow () {\n\t// console.log(\"end...\");\n\t// block all the event to gems\n\tthis.backgroundView.updateOpts({\n\t\tblockEvents: true\n\t});\n\t// disable scoreboard\n\tthis._scoreboard.updateOpts({\n\t\tvisible: false\n\t});\n\t// show end screen\n\tthis._endheader.updateOpts({\n\t\tvisible: true,\n\t\tcanHandleEvents: true\n\t});\n\tanimate(this._endheader).wait(800).then({y: 0}, 100, animate.easeIn).then({y: 35}, 1000, animate.easeIn);\n\n\t// show score\n\tvar scoreText = new TextView({\n\t\tsuperview: this._endheader,\n\t\tx: 0,\n\t\ty: 35, // endscreen animate end point\n\t\twidth: 350,\n\t\theight: 233,\n\t\tautoSize: true,\n\t\ttext: \"You achieved \" + score.toString(),\n\t\tsize: 38,\n\t\tverticalAlign: 'middle',\n\t\thorizontalAlign: 'center',\n\t\tcanHandleEvents: false\n\t});\n\t// //slight delay before allowing a tap reset\n\tsetTimeout(emit_endgame_event.bind(this), 2000);\n\tconsole.log('end game flow.. \\n');\n}", "title": "" }, { "docid": "8f5c3bb607cb2f928fd3df3d0e33af47", "score": "0.56248194", "text": "_onEndAnim() {\n if (this._overlay) {\n this._peer.getChart().getPlotArea().removeChild(this._overlay);\n this._overlay = null;\n }\n }", "title": "" }, { "docid": "33143e3439a1bdc2e8711aefca0c22cb", "score": "0.56158245", "text": "onFinish() {\n this.props.store.dispatch(ACTIONS.FINISH);\n }", "title": "" }, { "docid": "24078e1deecf5203b31f5310a8a09aa6", "score": "0.5565247", "text": "function end() {\n this.removeEventListener('transitionend', end, false);\n var replies = this.querySelectorAll('.reply');\n\n for (var i = 0; i < replies.length; i++) {\n replies[i].style.transform = 'rotateX(0)';\n replies[i].style.opacity = 1;\n }\n }", "title": "" }, { "docid": "40ce92bd6a32ed543740cc14165afd4d", "score": "0.5562378", "text": "function TweenComplete() {\n tweenSlide.eventComplete(function () {\n // Reset 'style' & 'transform' for slide\n that.ResetTFSlideCss();\n // Update the variable in toggle-end\n that.TOSLIDE.End();\n fxCSS.status = null;\n });\n }", "title": "" }, { "docid": "5bda63c45a882ddbd81053b7f90a5c43", "score": "0.55586326", "text": "function onSlideChangeEnd()\n\t{\n\t\tisAnimating = false;\n\t}", "title": "" }, { "docid": "8704a2e6392f39f19d9aad3916901a93", "score": "0.55524904", "text": "wait_GM_1st_AnimationEnd(){\n if(this.check_Reset())\n return;\n if (this.numberOfTries > this.maxNumberOfTries) {\n this.numberOfTries = -1;\n\n if (this.currentPlayer == 2)\n {\n this.scene.update_CameraRotation();\n this.state = 'WAIT_GM_CAMERA_ANIMATION_END';\n }\n else\n this.state = 'GAME_MOVIE';\n\n }\n this.numberOfTries++;\n }", "title": "" }, { "docid": "a3c8c25f5a2f6a1d83623990ed59c79f", "score": "0.55480707", "text": "function onSlideChangeEnd()\n {\n isAnimating = false;\n }", "title": "" }, { "docid": "b9e3d1eed99d72fc7ebc84f3bb6ba98e", "score": "0.55443877", "text": "function handleTransitonEnd(evt) {\n // to make sure the event comes from the Collapsible itself, not its children\n if (evt.target !== ownRef.current) {\n return;\n }\n\n if (expanded) {\n setCompletelyVisible(true);\n }\n }", "title": "" }, { "docid": "ee27ef013d1cf5fff575e46bf6800497", "score": "0.55315787", "text": "animateOut (callback) {\n // Declare that the notice is animating out.\n this.set({'_animating': 'out'});\n const finished = () => {\n this.refs.elem.removeEventListener('transitionend', finished);\n const {_animTimer, _animating, _moduleIsNoticeOpen} = this.get();\n if (_animTimer) {\n clearTimeout(_animTimer);\n }\n if (_animating !== 'out') {\n return;\n }\n let visible = _moduleIsNoticeOpen;\n if (!visible) {\n const domRect = this.refs.elem.getBoundingClientRect();\n for (let prop in domRect) {\n if (domRect[prop] > 0) {\n visible = true;\n break;\n }\n }\n }\n if (!this.refs.elem.style.opacity || this.refs.elem.style.opacity === '0' || !visible) {\n this.set({'_animatingClass': ''});\n const {stack} = this.get();\n if (stack && stack.overlay) {\n // Go through the modal stack to see if any are left open.\n // TODO: Rewrite this cause it sucks.\n let stillOpen = false;\n for (let i = 0; i < PNotify.notices.length; i++) {\n const notice = PNotify.notices[i];\n if (notice !== this && notice.get().stack === stack && notice.get()._state !== 'closed') {\n stillOpen = true;\n break;\n }\n }\n if (!stillOpen) {\n removeStackOverlay(stack);\n }\n }\n if (callback) {\n callback.call();\n }\n // Declare that the notice has completed animating.\n this.set({'_animating': false});\n } else {\n // In case this was called before the notice finished animating.\n this.set({'_animTimer': setTimeout(finished, 40)});\n }\n };\n\n if (this.get().animation === 'fade') {\n this.refs.elem.addEventListener('transitionend', finished);\n this.set({'_animatingClass': 'ui-pnotify-in'});\n // Just in case the event doesn't fire, call it after 650 ms.\n this.set({'_animTimer': setTimeout(finished, 650)});\n } else {\n this.set({'_animatingClass': ''});\n finished();\n }\n }", "title": "" }, { "docid": "7e2521739887244f63e4b1d70f80dac0", "score": "0.55251193", "text": "fadeOut() {\n const self = this;\n // \"Unload\" Animation - onComplete callback\n TweenMax.to($(this.oldContainer), 0.4, {\n opacity: 0,\n onComplete: () => {\n this.fadeIn();\n }\n });\n }", "title": "" }, { "docid": "64b94eaf82382d7a5eed1941527fe5f3", "score": "0.54938054", "text": "function endCardAnimation() {\n\t$(\".computer-card\").removeClass(\"animated-card\");\n\tanimating = false;\n\tif (!training && disabled) {\n\t\tenableButtons();\n\t}\n}", "title": "" }, { "docid": "96c247244f853f38cce1218483667bfe", "score": "0.5492564", "text": "function AnimComplete() {\n // Add timer to mark sure at end place\n setTimeout(function () {\n VariableModule(that);\n va.$capLast.css('visibility', '');\n va.$capInner.css('height', '');\n }, 10);\n }", "title": "" }, { "docid": "55210e885d48f2f3e5228ca5d040487f", "score": "0.5490753", "text": "function completeOnTransitionEnd(ev) {\n if (ev.target !== this) return;\n transitionComplete();\n }", "title": "" }, { "docid": "55210e885d48f2f3e5228ca5d040487f", "score": "0.5490753", "text": "function completeOnTransitionEnd(ev) {\n if (ev.target !== this) return;\n transitionComplete();\n }", "title": "" }, { "docid": "168626df577af1116f307cf3cc86dc07", "score": "0.5483912", "text": "function animateToEndState() {\n if (transition == null)\n throw new Error('Transition was already finished or never started.');\n\n for (const anim of document.getAnimations())\n anim.currentTime = anim.effect.getTiming().duration - 1;\n}", "title": "" }, { "docid": "648002e8710f1b707cd0ec8293a10a57", "score": "0.54643327", "text": "endAll() {\n this.animations.forEach((anim) => anim.onEnd());\n this.animations = [];\n }", "title": "" }, { "docid": "678b3e4e016a8df09fcf4f2d3748516e", "score": "0.545913", "text": "function clonedAnimationDone(){\n // scroll body\n anime({\n targets: \"html, body\",\n scrollTop: 0,\n easing: easingSwing, // swing\n duration: 150\n });\n\n // fadeOut oldContainer\n anime({\n targets: this.oldContainer,\n opacity : .5,\n easing: easingSwing, // swing\n duration: 300\n })\n\n // show new Container\n anime({\n targets: $newContainer.get(0),\n opacity: 1,\n easing: easingSwing, // swing\n duration: 300,\n complete: function(anim) {\n triggerBody()\n _this.done();\n }\n });\n\n $newContainer.addClass('one-team-anim')\n }", "title": "" }, { "docid": "82c9cf60da2f83553d7a84ac57495a42", "score": "0.5453286", "text": "animationEnded(e) {\n // wipe the slot of our drawer\n this.title = \"\";\n while (dom(this).firstChild !== null) {\n dom(this).removeChild(dom(this).firstChild);\n }\n if (this.invokedBy) {\n async.microTask.run(() => {\n setTimeout(() => {\n this.invokedBy.focus();\n }, 500);\n });\n }\n }", "title": "" }, { "docid": "08e240b686d37e505e8f564d90b849ca", "score": "0.5440296", "text": "function animationCompleted()\n{\n // Remove the tick event listener.\n TweenMax.ticker.removeEventListener(\"tick\");\n\n // Reenable the test button.\n animationTest.disabled = false;\n}", "title": "" }, { "docid": "b05884c2b3c87c41615962fce8cba3e2", "score": "0.54360175", "text": "wait_AnimationEnd() {\n if (this.tmpPiece.parabolic.end == true) {\n this.unvalidateCells();\n this.check_GameOver();\n this.check_Reset();\n this.checkSelected();\n this.locked = true;\n }\n }", "title": "" }, { "docid": "f6a2ed7ffdfb8c8c619b4ffd45338f62", "score": "0.54300654", "text": "endTransitionHandler(e) {\n if (this.active === true) {\n this.changeToDeactive();\n } else if (this.active === false) {\n this.transitionEndListenerOff();\n }\n }", "title": "" } ]
5b7fa09d9c12cbdb6f8d58866e692d83
don't remove the name
[ { "docid": "11e711df84f1d6dce0abc0d2a6acecb1", "score": "0.0", "text": "function init_ibox(linkFromTop,url) {\n\tvar elem_wrapper = \"ibox\";\n\t\n\t\n\tcreateIbox(document.getElementsByTagName(\"body\")[0]); //create our ibox\n\n\t//\telements here start the look up from the start non <a> tags\n\tvar docRoot = (document.all) ? document.all : document.getElementsByTagName(\"*\");\n\t\n\t// Or make sure we only check <a> tags\n\t//var docRoot = document.getElementsByTagName(\"a\");\n\tvar ibAttr = \"rel\"; \t// our attribute identifier for our iBox elements\n\n\tvar e;\n\t\n\tif(linkFromTop=='yes')\n\t{\n\t\t//Define the param values\n\t\t\n\t\tvar params = \"height=500&width=620\";\n\t\tvar params = parseQuery(params);\n\t\t//var url = this.href;\n\t\t//if(this.target != \"\") {url = this.target} \n\t\tvar title = \"\";\n\t\tif(url.match('/subscription/register/controlPanel.htm'))\n\t\t{\n\t\t\twindow.location.href=url;\t\n\t\t} else\n\t\t{\n\t\tshowBG();\n\t\t//URL which needs to be displayed\n\t\tshowIbox(url,title,params);\t// show ibox\n\t\twindow.onscroll = maintPos;\n\t\twindow.onresize = maintPos;\n\t\t}\n\t\t//URL which needs to be displayed\n\t\t\n\t\treturn false;\n\t} \n\telse if(linkFromTop =='fb_connect')\n\t{\n\t\t//Define the param values\n\t\t\n\t\tvar params = \"height=394&width=501\";\n\t\tvar params = parseQuery(params);\n\t\t//var url = this.href;\n\t\t//if(this.target != \"\") {url = this.target} \t\t\n\t\tshowBG();\n\t\t//URL which needs to be displayed\n\t\tshowIbox(url,title,params);\t// show ibox\n\t\t//window.onscroll = maintPos;\n\t\t//window.onresize = maintPos;\t\t \n\t\t//URL which needs to be displayedz\n\n\n\t\t \n\t\tvar box_w = getElem('ibox_w');\n\t\tvar pagesize = new getPgSize();\n\t\tvar ua = navigator.userAgent;\n\t\twindow.onscroll = maintPos;\n\t\twindow.onresize = maintPos;\n\n\t\tif(ua.indexOf(\"Opera/9\") != -1) {box_w.style.height = document.body.scrollHeight+'px';}\n\t\telse {box_w.style.height = document.body.scrollHeight+50+pagesize.height+'px';}\n\t\treturn false;\t\t\n\t}\n\telse if(linkFromTop=='cooper')\n\t{\n\t\tvar params = \"height=488&width=532\";\n\t\tshowBG();\n\t\tvar params = parseQuery(params);\n\t\tshowIbox(url,title,params);\t// show ibox\n\t\twindow.onscroll = maintPos;\n\t\twindow.onresize = maintPos;\n\t\treturn false;\n\t}\n\telse if(linkFromTop=='laveryinsight')\n\t{\n\t\tvar params = \"height=488&width=532\";\n\t\tshowBG();\n\t\tvar params = parseQuery(params);\n\t\tshowIbox(url,title,params);\t// show ibox\n\t\twindow.onscroll = maintPos;\n\t\twindow.onresize = maintPos;\n\t\treturn false;\n\t}\n\t\n\telse if(linkFromTop=='cartconfirm')\n\t{\n\t\tvar params = \"height=180&width=320\";\n\t\tshowBG();\n\t\tvar params = parseQuery(params);\n\t\tshowIbox(url,title,params);\t// show ibox\n\t\twindow.onscroll = maintPos;\n\t\twindow.onresize = maintPos;\n\t\treturn false;\n\t}\n\t\n\t\n\telse\n\t{\n\tfor (var i = 0; i < docRoot.length - 1; i++) {\n\t\t\te = docRoot[i];\n\t\t\tif(e.getAttribute(ibAttr)) {\n\t\t\t\tvar t = e.getAttribute(ibAttr);\n\t\t\t\tif ((t.indexOf(\"ibox\") != -1) || t.toLowerCase() == \"ibox\") { // check if this element is an iBox element\n\t\t\t\t\t\te.onclick = function() { // rather assign an onclick event\n\t\t\t\t\t\t\tvar t = this.getAttribute(ibAttr);\n\t\t\t\t\t\t\tvar params = parseQuery(t.substr(5,999));\n\t\t\t\t\t\t\tglobaparam = params ;\n\t\t\t\t\t\t\tvar url = this.href;\n\t\t\t\t\t\t\tif(this.target != \"\") {url = this.target} \n\t\t\t\t\t\t\tvar title = this.title;\n\t\t\t\t\t\t\tshowBG();\n\t\t\t\t\t\t\tshowIbox(url,title,params);\t// show ibox\n\t\t\t\t\t\t\twindow.onscroll = maintPos;\n\t\t\t\t\t\t\twindow.onresize = maintPos;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}; \n\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n }\n}\n}", "title": "" } ]
[ { "docid": "f9bb371c21d64e0437a7370bad2ad380", "score": "0.7433631", "text": "reset_name() {\n this.name = NO_NAME;\n }", "title": "" }, { "docid": "e7f18d42f0eb4875391739f76596de06", "score": "0.7418639", "text": "removeSomeone(name) {\n fncs.writeKeysObject(\n fncs.getKeys().filter(el => el.name !== name)\n )\n }", "title": "" }, { "docid": "822a7d4642f7e8b9101758953b628698", "score": "0.7061433", "text": "delete (name) {\n delete this[MAP][sanitizeName(name)]\n }", "title": "" }, { "docid": "b1b4cc2d330c50f365fd5331b46b97ba", "score": "0.6930765", "text": "function unfilterName(name) {\n GM_deleteValue(name);\n}", "title": "" }, { "docid": "adbe7de8609c0743e66fee9788d164e1", "score": "0.687775", "text": "function cleanNameTemplate() {\n name.textContent = \"\";\n}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "6bfc13d064a57bafee0f6758e22bae43", "score": "0.6848179", "text": "delete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}", "title": "" }, { "docid": "12608836b4a8f7ba827a326076e339dc", "score": "0.66308653", "text": "function removeTool(element, name) {\n var i, arr1, arr2;\n arr1 = element.className.split(\" \");\n arr2 = name.split(\" \");\n for (i = 0; i < arr2.length; i++) {\n while (arr1.indexOf(arr2[i]) > -1) {\n arr1.splice(arr1.indexOf(arr2[i]), 1);\n }\n }\n element.className = arr1.join(\" \");\n}", "title": "" }, { "docid": "b1111c67ce1d72e4c115b44dc3acaece", "score": "0.6630783", "text": "function clearDisplayName() {\n\t\tnavName.innerHTML = \"\";\n\t}", "title": "" }, { "docid": "843d4b32cd22e6e5c7ba36fc5f00d4a3", "score": "0.6543046", "text": "static removeNamedItem(name){if(NamedRouting.registry[name]){delete NamedRouting.registry[name]}}", "title": "" }, { "docid": "3fd23b1de7ce2c203b537e3daec88cec", "score": "0.6529262", "text": "delete ({internal_name}) {\n list.removeChild(list.querySelector(`#${ref(internal_name)}`));\n }", "title": "" }, { "docid": "11ac0a53062e791ec7aac26bcc2badcc", "score": "0.65092534", "text": "remove() {}", "title": "" }, { "docid": "36d5f9f8684b9dc99a16f15bad6d4e67", "score": "0.6454811", "text": "function myNameDelete(nameDelete){\nconsole.log (myName);\n}", "title": "" }, { "docid": "d814e44f6c8d58b849e67d017a103bfc", "score": "0.64105135", "text": "function removeElFromScene(name){\r\n\t\tvar toRemove = [];\r\n\t\tscene.traverse(child =>{\r\n\t\t\tif(child.name===name){\r\n\t\t\t\ttoRemove.push(child);\r\n\t\t\t}\r\n\t\t});\r\n\t\ttoRemove.forEach(el => {\r\n\t\t\tel.parent.remove(el);\r\n\t\t});\r\n\t\tall_campate = [];\r\n\t\tget_trains();\r\n\t}", "title": "" }, { "docid": "13fe87c93e65aa5819264f2a4d90c26e", "score": "0.64016676", "text": "remove() { }", "title": "" }, { "docid": "ba705f12d1967a26aea1abed38644c24", "score": "0.63745624", "text": "Remove() {}", "title": "" }, { "docid": "ba705f12d1967a26aea1abed38644c24", "score": "0.63745624", "text": "Remove() {}", "title": "" }, { "docid": "d10b142ca435cb6dfab35c4a9c327176", "score": "0.635938", "text": "get name() { return null; }", "title": "" }, { "docid": "be517479632c84ed3a346fd2f9d37e00", "score": "0.63417387", "text": "function nombrePropiedad(obj){\r\n\tvar propiedad = obj.name;\r\n\tdelete obj.name;\r\n\tobj.fullName = propiedad;\r\n}", "title": "" }, { "docid": "8ee927d2808a070b7d5da6b331c0b257", "score": "0.632893", "text": "removed() {}", "title": "" }, { "docid": "8ee927d2808a070b7d5da6b331c0b257", "score": "0.632893", "text": "removed() {}", "title": "" }, { "docid": "8729b07927dfbf359430af4c24484e36", "score": "0.6327698", "text": "static removeAssignment(name){if(NamedRouting.assignments[name]){delete NamedRouting.assignments[name];return!0}return!1}", "title": "" }, { "docid": "90bc633ce07502edfe750c72ce688fde", "score": "0.63134074", "text": "function changeFullname(){\n\tavenger.fullName = avenger.name;\n\tdelete avenger.name;\n}", "title": "" }, { "docid": "aba5445952099e1fd5a7c217d70ab9a1", "score": "0.6281107", "text": "removeDiv(name) {\n this.removeChild(name);\n }", "title": "" }, { "docid": "131d4a628a6ee910556aa6ded8c4981c", "score": "0.6263379", "text": "function removeEveFun(name){\n \tif(fun_list.length == 0 ) return ''\n for(var i =0 ;i<fun_list.length;i++ ){\n if(fun_list[i].name == name){\n var pre_list , last_list\n if(i == 0){\n \tpre_list = []\n }else{ \n \tpre_list = fun_list.slice(0,i)\n }\n if(i == fun_list.length-1){\n \tlast_list = []\n }else{ \n \tlast_list = fun_list.slice(i+1)\n }\n fun_list = pre_list.concat(last_list) \n break\n }\n }\n }", "title": "" }, { "docid": "b899f859b111bf81001d7614b7ca73b4", "score": "0.6262328", "text": "function _remove() {\n return;\n }", "title": "" }, { "docid": "f35d074891409299edecd5bec02794f6", "score": "0.62095815", "text": "remove(name) {\n let item = this.getItem(name);\n\n let itemIndex = this.items.indexOf(item);\n\n if (item) {\n this.items.splice(itemIndex, 1);\n this.update();\n }\n }", "title": "" }, { "docid": "b2a7678cf62efa9b55ddb9a4872c745d", "score": "0.6190764", "text": "function imprimir(nombre) {\n\n \n}", "title": "" }, { "docid": "df71e74ebb04c4514bd92899a6e06b95", "score": "0.6185691", "text": "get name () { return '' }", "title": "" }, { "docid": "4abd8665effb6e8b592522a7ebcd961b", "score": "0.6184196", "text": "function removeHighscore(_name){\n\t\tnamesList[_name] = 0; //set highscore to 0\n\t}", "title": "" }, { "docid": "3134836e6c862038c0757170b7703cc5", "score": "0.6178211", "text": "function trimName(arr, str){\n\tfor(let i=0; i<arr.length; i++){\n\t\tif(arr[i].hasOwnProperty(str)){\n\t\t\tif(!arr[i].hasOwnProperty(\"enabled\")){\n\t\t\t\tarr.splice(i, 1);\n\t\t\t\t//go back because fuck logic\n\t\t\t\t//no but seriously, splicing shifts everything ahead of it up one, so we want to go back one to really be where we were before\n\t\t\t\ti=-1;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tdelete arr[i][str];\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "25344b3538e7efdedc2c2b46543bd664", "score": "0.6176588", "text": "function remove(name){\n var index = roster.indexOf(name);\n if(index > -1){\n roster.splice(index, 1);\n }\n}", "title": "" }, { "docid": "990d4e14f6b837bf0ae48df8b28bc2fc", "score": "0.6143008", "text": "function clear_element(name) {\n var element = document.getElementsByName(name);\n for (index = element.length - 1; index >= 0; index--) {\n element[index].parentNode.removeChild(element[index]);\n }\n}", "title": "" }, { "docid": "2d5cc0a875c8e81a02101213bd593981", "score": "0.6140325", "text": "function hc_namednodemapremovenameditem() {\n var success;\n if(checkInitialization(builder, \"hc_namednodemapremovenameditem\") != null) return;\n var doc;\n var elementList;\n var newAttribute;\n var testAddress;\n var attributes;\n var streetAttr;\n var specified;\n var removedNode;\n \n var docRef = null;\n if (typeof(this.doc) != 'undefined') {\n docRef = this.doc;\n }\n doc = load(docRef, \"doc\", \"hc_staff\");\n elementList = doc.getElementsByTagName(\"acronym\");\n testAddress = elementList.item(2);\n attributes = testAddress.attributes;\n\n removedNode = attributes.removeNamedItem(\"class\");\n streetAttr = attributes.getNamedItem(\"class\");\n assertNull(\"isnull\",streetAttr);\n \n}", "title": "" }, { "docid": "5356c645235a022a7d6c787a3f803ba4", "score": "0.61279887", "text": "function removeClass(elem, name) {\n var cn = getClass(elem);\n var nameLen = name.length;\n var newcn = cn;\n if (cn == name) {\n newcn = \"\";\n }\n else {\n var index = (cn.indexOf(\" \" + name + \" \"));\n if (index > -1) {\n newcn = cn.substring(0, index) + cn.substring(index + nameLen + 1);\n }\n else {\n if (cn.endsWith(\" \" + name)) {\n var len = cn.length - (nameLen + 1);\n newcn = cn.substring(0, len);\n }\n else if (cn.startsWith(name + \"\")) {\n newcn = cn.substring(name.length + 1);\n }\n }\n }\n if (newcn != cn) {\n setClass(elem, newcn);\n }\n }", "title": "" }, { "docid": "f54e056d8c6ae3bef7f8100e0bd7f085", "score": "0.61237377", "text": "function Ur(t){delete Gr[t]}", "title": "" }, { "docid": "71ba3ef6510e9c961b54aeb5aed9465d", "score": "0.61205256", "text": "static removeSupervisor(name){\n supervisors.delete(name);\n }", "title": "" }, { "docid": "3cfca7f0f05b22d637f652cc8c76fe88", "score": "0.6113401", "text": "removeGreeting(removeName) {\n const filteredGreetings = this.state.greetings.filter(name => {\n return name !== removeName;\n });\n this.setState({ greetings: filteredGreetings });\n }", "title": "" }, { "docid": "73ea35da6e17201fadaf2cbd7a2412b8", "score": "0.61097795", "text": "removeName(index, fieldType) {\n fieldType.splice(index, 1);\n }", "title": "" }, { "docid": "9d32fb199900a039ac2ce50d18ad5197", "score": "0.61048806", "text": "removeDivider(name) {\n let _objToRemove = this.drawer.getObjectByName( name, true );\n\n if (_objToRemove) {\n this.drawer.remove( _objToRemove );\n }\n }", "title": "" }, { "docid": "802ae2caa4022dd6becb11d4c8aa3835", "score": "0.60959417", "text": "function Mr(t){delete Sr[t]}", "title": "" }, { "docid": "3e77249d06f0d08029230ffe425c34a8", "score": "0.608098", "text": "function deconflict(name) {\n\t\twhile (all_identifiers.has(name)) name += '_';\n\t\treturn name;\n\t}", "title": "" }, { "docid": "a8002f2d074dcbbfeede66d14856694b", "score": "0.60790926", "text": "function removeJuan() {\n var indexToRemove = names.findIndex(function (element) { return element.name === 'Juan'; });\n names.splice(indexToRemove, 1);\n console.log('The array with out the name Juan:', names);\n}", "title": "" }, { "docid": "7a15a7f802f0474c0ba419eb824ad9a9", "score": "0.6077874", "text": "remove(picName){\n ui.removePic(this.get(picName))\n delete this._pics[picName];\n delete this[picName];\n }", "title": "" }, { "docid": "0f018373dd8bb107e950b02ad8f1927e", "score": "0.6076697", "text": "function remove_sector(name){\n\n\t\tfor(var i = 0; i<sectors.length; i++){\n\t\t\tif(sectors[i].name == name){\n\t\t\t\tsectors[i].setMap(null);\n\t\t\t\tsectors.splice(i, 1);\n\t\t\t}\n\t\t}\t\n\t}", "title": "" }, { "docid": "f3cda497bed4ba373b303219dea49d1e", "score": "0.6071145", "text": "function removeClass(o,name) {\n\t\tvar c = o.className || \"\";\n\t\to.className = c.replace(new RegExp(\"(^|\\\\s)\"+name+\"(\\\\s|$)\"),\"$1\");\n\t}", "title": "" }, { "docid": "82258319ef5f1a2b1f7e1f870e713855", "score": "0.60704076", "text": "function remove_marker(name){\n\n\t\t// TODO - consider removing, don't really need this anymore\n\t\tcount = 0;\n\t\tfor(var i = 0; i < sectors.length; i++){\n\n\t\t\tif(sectors[i].site == name){\n\t\t\t\tsectors[i].setMap(null);\n\t\t\t\tsectors.splice(i,1);\n\t\t\t\ti--;\n\t\t\t}count++;\n\t\t}\n\t\ttowers[name].setMap(null);\n\t\tdelete towers[name];\n\t}", "title": "" }, { "docid": "4a326bd1b917ff0338d95f05c6500ff7", "score": "0.60602546", "text": "function remove(animals, name){\n for(var i = 0; i < animals.length ; i++){\n //name = name[0].toUpperCase() + name.slice(1).toLowerCase()\n if(animals[i].name === name){\n animals.splice(i,1);\n //return animals;\n }\n } return null;\n}", "title": "" }, { "docid": "07cbeb491420e746733784e81f975d05", "score": "0.6050974", "text": "function oneAddName() {\n let spanName = document.createElement(\"span\");\n nameDiv.appendChild(spanName);\n let myName = document.createTextNode(\"Cordell\");\n spanName.appendChild(myName);\n addNameButton.removeEventListener(\"click\", oneAddName);\n }", "title": "" }, { "docid": "dca3ac39e810000a09eddcdb38ab2cd5", "score": "0.6036762", "text": "function removeSearchTermByName(name) {\n\tvar labels = document.getElementsByClassName(\"search-term-label\");\n\tfor (var i = 0; i < labels.length; i++) {\n\t\tif (labels[i].childNodes[0].textContent == name) {\n\t\t\tlabels[i].parentElement.removeChild(labels[i]);\n\t\t}\n\t}\n\trefineResults(\"filter\");\n}", "title": "" }, { "docid": "476e2275669d9e2cc710b726b0a92340", "score": "0.6024838", "text": "remove(name) {\n this.customPropertyTarget ? this.customPropertyTarget.removeProperty(`--${name}`) : this.queue.add(this.remove.bind(this, name));\n }", "title": "" }, { "docid": "62953cc32061e7943241905f4fd446a2", "score": "0.6020356", "text": "delete(name) {\n this.inner.removeHeader(name);\n }", "title": "" }, { "docid": "5d172d712c221ac25d1551c6e0f3ed2f", "score": "0.6015191", "text": "function prv_unsubscribeName(name){\n\t\t\t\tif(IDs[name] > 0){\n\t\t\t\t\tfor(var m in topics){\n\t\t\t\t\t\tif(topics[m]){\n\t\t\t\t\t\t\tfor (var i = topics[m].length; i--;) {\n\t\t\t\t\t\t\t\tif((topics[m][i].token === IDs[name]) && !topics[m][i].persistent){\n\t\t\t\t\t\t\t\t\tdelete IDs[name];\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\ttopics[m].splice(i,1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}", "title": "" }, { "docid": "aad9029a410cbb0dae8ec9012f1ca04b", "score": "0.60087705", "text": "excute () {\n\t\tthis.object.name = this.newName;\n\t\tSubmitObjPropsApis.submitLocProps(this.object.id, 'name', this.newName);\n\t}", "title": "" }, { "docid": "7bdbc1fdf73dbf28bd9312180a5b703b", "score": "0.5995396", "text": "function removeUser(name) {\n var user = \"\";\n for(i = 0; i < conUsers.length; i++) {\n if(name==conUsers[i].name) {\n user = conUsers[i].name;\n break;\n }\n }\n if(user != \"\") {\n conUsers.splice(i,1);\n }\n return user;\n}", "title": "" }, { "docid": "f2061575323fa354815486c7ac5965b9", "score": "0.5990183", "text": "_onRemoveAttribute() {\n const container = this.markup.getContainer(this.selection.nodeFront);\n container.removeAttribute(this.nodeMenuTriggerInfo.name);\n }", "title": "" }, { "docid": "650b86b854d712288691fffc3c78360f", "score": "0.59850127", "text": "remove() {\n\n }", "title": "" }, { "docid": "650b86b854d712288691fffc3c78360f", "score": "0.59850127", "text": "remove() {\n\n }", "title": "" }, { "docid": "ef1a6e3c304c733756e8b92b3b6ed8dd", "score": "0.59762466", "text": "function destructivelyRemoveLastKitten(name){\n kittens.pop(name)\n return kittens\n}", "title": "" }, { "docid": "3091c54fa1e6c45748cd679ece8dbd5c", "score": "0.5976023", "text": "remove(name) {\n delete data[name];\n this.deleteCookie(name, this.path, this.domain);\n }", "title": "" }, { "docid": "ca8a30580b355f498da4094333669941", "score": "0.5970166", "text": "forgetSelf(name, $root) {\n this.forget(name, $root, true)\n }", "title": "" }, { "docid": "0dbb04b1facfc28518bd103c02a052c4", "score": "0.5957629", "text": "removeStudent(name) {\r\n const index = this.students.findIndex((student) => {\r\n return student.name === name;\r\n });\r\n if (index !== -1) {\r\n this.students.splice(index, 1);\r\n return this.students;\r\n };\r\n }", "title": "" }, { "docid": "601a05bbce65afb5237b32821a031bc7", "score": "0.5951206", "text": "function Uo(t){delete Yo[t]}", "title": "" }, { "docid": "7087c06589f2f1c35cc7fb24c2b4a5b1", "score": "0.59495384", "text": "undoTransaction() {\n this.list.name = this.oldName;\n }", "title": "" } ]
6be8405054dc41abfa9f45ae7c184206
extract button index and call a servlet to make move in the logic unit
[ { "docid": "4bd7efaa921b223e31ddf4bebce78aad", "score": "0.5608038", "text": "function AttackMove(clickedBtn){\r\n var col = $(clickedBtn).parent().index();\r\n var row = $(clickedBtn).closest('tr').index() - 1;\r\n $.ajax({\r\n data: {\"colIndex\":col, \"rowIndex\":row},\r\n url: MAKE_MOVE,\r\n error: function (errorMsg) {\r\n alert(errorMsg.responseText);\r\n },\r\n success: function () {\r\n\r\n }\r\n });\r\n}", "title": "" } ]
[ { "docid": "dd22fc4f83e1619832276e528b743088", "score": "0.6355344", "text": "function loadSendIndexButtonToModalVehiculo(){\n\t\t$.each($('.btn-open-modal-vehiculo'), function(index) {\n\t\t\tindex_current = index + 1;\n\t\t\tcadena_name_id = \"#btn-open-create-vehiculo\"+ index_current;\n\t\t\t \n\t\t\t $(cadena_name_id).click(function() {\n\t\t\t\t nombre_id_input_button = $(this).attr('id');\n\t\t\t\t longitud = nombre_id_input_button.length;\n\t\t\t\t if(longitud==25){\n\t\t\t\t\t index_current = nombre_id_input_button.substring(longitud-1);\n\t\t\t\t }else{\n\t\t\t\t\t index_current = nombre_id_input_button.substring(longitud-2);\n\t\t\t\t }\n\t\t\t\t $('#txt-nro-placa').val('');\n\t\t\t\t $('#txt-nro-placa').parent().removeClass('control-group has-error');\n\t\t\t\t $('#myModalAddVehiculo').attr('index-button',index_current);\n\t\t\t });\n\t\t});\n\t}", "title": "" }, { "docid": "34afebf5f138135b9ad74e57fede48cd", "score": "0.629399", "text": "function returnIndex(){\n\n document.getElementById('main').addEventListener('click', function(){\n if(event.target.classList.contains('return_employee_submit'))\n\n ApiAction.getRequest(\"https://localhost:44390/api/employee\", employeelist => {\n app.innerHTML = AdminEmployeeIndex(employeelist);\n })\n })\n}", "title": "" }, { "docid": "78913ca040488c1c939f42e1f7f9b15a", "score": "0.6282479", "text": "function loadSendIndexButtonToModalResponsable(){\n\t\t$.each($('.btn-open-modal-responsable'), function(index) {\n\t\t\tindex_current = index + 1;\n\t\t\tcadena_name_id = \"#btn-open-create-resp\"+ index_current;\n\t\t\t \n\t\t\t $(cadena_name_id).click(function() {\n\t\t\t\t nombre_id_input_button = $(this).attr('id');\n\t\t\t\t longitud = nombre_id_input_button.length;\n\t\t\t\t index_current = nombre_id_input_button.substring(longitud-1);\n\n\t\t\t\t $('#txt-apellido-nombre').val('');\n\t\t\t\t $('#txt-apellido-nombre').parent().removeClass('control-group has-error');\n\t\t\t\t $('#myModalAddTrabajador').attr('index-button',index_current);\n\t\t\t\t $('#myModalAddTrabajador').attr('data-type','r');\n\t\t\t });\n\t\t});\n\t}", "title": "" }, { "docid": "57eb9215dabc972cdf372ab3ffa24e8c", "score": "0.6275828", "text": "function doPageIndex(ind) {\n var frm = document.forms[0];\n addInputField(frm,'hidden','pg_ind','pg_ind',ind);\n for(var i = 0; i < frm.elements.length; i++) {\n if (frm.elements[i].type == 'submit') {\n frm.elements[i].click();\n return false;\n }\n }\n frm.submit();\n return false;\n}", "title": "" }, { "docid": "d50cb824cf35bc12fcc7e0dc9e3e5066", "score": "0.6166607", "text": "function loadSendIndexButtonToModalTrabajador(){\n\t\t$.each($('.btn-open-modal-trabajador'), function(index) {\n\t\t\tindex_current = index + 1;\n\t\t\tcadena_name_id = \"#btn-open-create-trabajador\"+ index_current;\n\t\t\t \n\t\t\t $(cadena_name_id).click(function() {\n\t\t\t\t nombre_id_input_button = $(this).attr('id');\n\t\t\t\t longitud = nombre_id_input_button.length;\n\t\t\t\t if(longitud==27){\n\t\t\t\t\t index_current = nombre_id_input_button.substring(longitud-1);\n\t\t\t\t }else{\n\t\t\t\t\t index_current = nombre_id_input_button.substring(longitud-2);\n\t\t\t\t }\n\t\t\t\t $('#txt-apellido-nombre').val('');\n\t\t\t\t $('#txt-nro-documento').val('');\n\t\t\t\t $('.cboTipoTrabajadores').val('');\n\t\t\t\t $('#txt-apellido-nombre').parent().removeClass('control-group has-error');\n\t\t\t\t $('#myModalAddTrabajador').attr('index-button',index_current);\n\t\t\t\t $('#myModalAddTrabajador').attr('data-type','t');\n\t\t\t });\n\t\t});\n\t}", "title": "" }, { "docid": "ec3b40d2ea4f2c35860aee698ae68ce0", "score": "0.60659784", "text": "function MEX_BtnPageClicked(btn, pge_index) {\n console.log( \"===== MEX_BtnPageClicked ========= \");\n\n console.log( \"btn\", btn, typeof btn);\n if (btn){\n const data_btn = get_attr_from_el(btn,\"data-btn\");\n mod_MEX_dict.pge_index = (data_btn) ? Number(data_btn.slice(4)) : 1;\n } else {\n mod_MEX_dict.pge_index = pge_index;\n }\n if (!mod_MEX_dict.pge_index) {mod_MEX_dict.pge_index = 1};\n console.log(\"mod_MEX_dict.pge_index\", mod_MEX_dict.pge_index)\n\n// --- highlight selected button\n b_highlight_BtnSelect(el_MEX_btn_pge_container, \"pge_\" + mod_MEX_dict.pge_index)\n\n //console.log( \"mod_MEX_dict.partex_dict\", mod_MEX_dict.partex_dict);\n MEXQ_FillPage()\n } // MEX_BtnPageClicked", "title": "" }, { "docid": "a7bb62e028f0dfffe83462d1ece1da94", "score": "0.5907884", "text": "function processButton(param) {\n switch (param.element) {\n case \"조회\":\n processRetrieve({});\n break;\n case \"닫기\":\n processClose({});\n break;\n case \"실행\":\n processRetrieve({});\n break;\n }\n }", "title": "" }, { "docid": "2af620f99e442cdbb76cd6cc9595c364", "score": "0.5899593", "text": "function buttonClickHandler(e) {\n\n\t\tvar html = e.target.innerHTML;\n\t\tvar isNext = html === 'Next';\n\n\t\tmoveForward(isNext);\n\t}", "title": "" }, { "docid": "6efaba6393ab84a35aed5934c46bcde9", "score": "0.5832103", "text": "function switchIndex(){\n\twindow.location.href=(\"./servletIndex.html\")\n}", "title": "" }, { "docid": "0572d621caa8baad30b7a63200be68fd", "score": "0.58149076", "text": "clickedButton(index) {\n // Value Was Given\n if (!isNaN(index)) {\n // Make sure Index is found in buttons array\n if (index < this.buttons.length && index >= 0) {\n this.buttons[index].fn();\n }\n // Invalid Index\n else {\n console.error(\"Invalid Index! Button Array Index Invalid!\");\n }\n // Done\n return;\n }\n // Position Object Given\n // Check for Mouse Position within any of the Buttons\n else {\n // Check Mouse vs Buttons\n for (const btn of this.buttons) {\n // Obtain Button's Location\n const obj = {\n x: btn.rectShape.x,\n y: btn.rectShape.y\n };\n // Obtain Button's Shape\n const shape = {\n w: btn.rectShape.w,\n h: btn.rectShape.h\n };\n // If mouse within\n if (Menu.within(obj, shape, index)) {\n // Prompt User for Arguments (for now it's 2)\n // Call Function with those Arugments\n if (btn.fnArgs == 2) {\n const a = parseInt(prompt(\"Enter Argument 1: \"));\n const b = parseInt(prompt(\"Enter Arguemnt 2: \"));\n btn.fn(a, b);\n }\n // Call Function without Arguments\n else {\n btn.fn();\n }\n return; // Stop Looking\n }\n }\n }\n }", "title": "" }, { "docid": "2312c5cfc9a186715fcb7ea5138fbda0", "score": "0.5790869", "text": "function processButton(param) {\n\n switch (param.element) {\n case \"조회\":\n {\n processRetrieve({});\n }\n break;\n case \"닫기\":\n {\n processClose({});\n processClear({});\n }\n break;\n }\n\n }", "title": "" }, { "docid": "5d330843050920ea6b2c3eb2cddb3bc3", "score": "0.57856685", "text": "get runners_index () { return $$('.RC-indexButtons__button') }", "title": "" }, { "docid": "ecf7a3f5e8b9503a601956ccc4e9f508", "score": "0.5760626", "text": "function processButton(param) {\n\n switch (param.element) {\n case \"조회\":\n {\n v_global.process.handler = processRetrieve;\n if (!checkUpdatable({})) return false;\n processRetrieve({});\n }\n break;\n case \"추가\":\n {\n if (param.object == \"lyrMenu\") {\n if (!checkUpdatable({ check: true })) return false;\n processInsert({});\n } else if (param.object == \"lyrMenu_SETUP_ISSUE\") {\n if (checkCRUD({}) == \"create\") {\n gw_com_api.messageBox([\n { text: \"데이터가 먼저 저장되어야 합니다.\" },\n { text: \"저장하신 후에 실행해 주세요.\" }\n ]);\n return false;\n }\n v_global.event.data = {\n setup_no: v_global.logic.setup_no,\n setup_seq: v_global.logic.setup_seq\n };\n var args = {\n type: \"PAGE\", page: \"EHM_3223\", title: \"SETUP 작업자 선택\",\n width: 500, height: 400, locate: [\"center\", \"center\"], open: true,\n };\n if (gw_com_module.dialoguePrepare(args) == false) {\n var args = {\n page: \"EHM_3223\",\n param: {\n ID: gw_com_api.v_Stream.msg_openedDialogue,\n data: v_global.event.data\n }\n };\n gw_com_module.dialogueOpen(args);\n }\n } else if (param.object == \"lyrMenu_FILE\") {\n //2021-05-18 by KYT\n //if (!checkManipulate({})) return;\n //if (!checkUpdatable({ check: true })) return false;\n\n //v_global.event.data = {\n // user: gw_com_module.v_Session.USR_ID,\n // key: gw_com_api.getValue(\"frmData_SETUP_D\", 1, \"setup_no\"),\n // seq: gw_com_api.getValue(\"frmData_SETUP_D\", 1, \"setup_seq\")\n //};\n //var args = {\n // type: \"PAGE\", page: \"w_upload_assetup\", title: \"파일 업로드\",\n // width: 650, height: 200, locate: [\"center\", \"bottom\"],\n // open: true\n //};\n //if (gw_com_module.dialoguePrepare(args) == false) {\n // var args = {\n // page: \"w_upload_assetup\",\n // param: {\n // ID: gw_com_api.v_Stream.msg_upload_ASSETUP,\n // data: v_global.event.data\n // }\n // };\n // gw_com_module.dialogueOpen(args);\n //}\n\n //-> dialogueOpen -> DLG.ready() -> this.msg_openedDialogue -> DLG.msg_openedDialogue\n //-> DLG.closed -> this.msg_closeDialogue -> this.processRetrieve\n\n processFileUpload({});\n\n\n }\n }\n break;\n case \"삭제\":\n {\n if (param.object == \"lyrMenu\") {\n var status = checkCRUD({});\n if (status == \"initialize\" || status == \"create\")\n processClear({});\n else\n gw_com_api.messageBox([\n { text: \"REMOVE\" }\n ], 420, gw_com_api.v_Message.msg_confirmRemove, \"YESNO\");\n } else if (param.object == \"lyrMenu_SETUP_ISSUE\") {\n var deletable = true;\n var crud = gw_com_api.getCRUD(\"grdData_SETUP_ISSUE\", \"selected\", true);\n if (crud == \"retrieve\" || crud == \"update\") {\n var args = {\n request: \"DATA\",\n name: \"EHM_3220_2_CHK_DEL\",\n url: \"../Service/svc_Data_Retrieve_JSON.aspx\" +\n \"?QRY_ID=EHM_3220_2_CHK_DEL\" +\n \"&QRY_COLS=deletable\" +\n \"&CRUD=R\" +\n \"&arg_setup_no=\" + gw_com_api.getValue(\"grdData_SETUP_ISSUE\", \"selected\", \"setup_no\", true) +\n \"&arg_setup_seq=\" + gw_com_api.getValue(\"grdData_SETUP_ISSUE\", \"selected\", \"setup_seq\", true) +\n \"&arg_issue_seq=\" + gw_com_api.getValue(\"grdData_SETUP_ISSUE\", \"selected\", \"issue_seq\", true) +\n \"&arg_user_id=\" + gw_com_module.v_Session.USR_ID,\n async: false,\n handler_success: successRequest\n };\n gw_com_module.callRequest(args);\n\n function successRequest(type, name, data) {\n\n if (data.DATA[0] == \"0\")\n deletable = false;\n\n }\n }\n if (deletable) {\n var args = { targetid: \"grdData_SETUP_ISSUE\", row: \"selected\", select: true }\n gw_com_module.gridDelete(args);\n } else {\n gw_com_api.messageBox([{ text: \"삭제 권한이 없습니다.\" }]);\n }\n } else if (param.object == \"lyrMenu_FILE\") {\n var args = { targetid: \"grdData_FileA\", row: \"selected\" }\n gw_com_module.gridDelete(args);\n }\n }\n break;\n case \"저장\":\n {\n processSave({});\n }\n break;\n case \"닫기\":\n {\n v_global.process.handler = processClose;\n if (!checkUpdatable({})) return;\n processClose({});\n }\n break;\n case \"공정\":\n {\n if (!checkManipulate({})) return;\n //if (checkCRUD({}) == \"create\") {\n // gw_com_api.messageBox([\n // { text: \"데이터가 먼저 저장되어야 합니다.\" },\n // { text: \"저장하신 후에 실행해 주세요.\" }\n // ]);\n // return false;\n //}\n v_global.event.data = {\n setup_no: v_global.logic.setup_no,\n setup_seq: v_global.logic.setup_seq,\n proc_seq: gw_com_api.getValue(\"frmData_SETUP_D\", 1, \"setup_procs\")\n };\n var args = {\n type: \"PAGE\", page: \"EHM_3221\", title: \"SETUP 공정 선택\",\n width: 600, height: 400, locate: [\"center\", 100], open: true,\n };\n if (gw_com_module.dialoguePrepare(args) == false) {\n var args = {\n page: \"EHM_3221\",\n param: {\n ID: gw_com_api.v_Stream.msg_openedDialogue,\n data: v_global.event.data\n }\n };\n gw_com_module.dialogueOpen(args);\n }\n }\n break;\n case \"작업자\":\n {\n if (!checkManipulate({})) return;\n //if (checkCRUD({}) == \"create\") {\n // gw_com_api.messageBox([\n // { text: \"데이터가 먼저 저장되어야 합니다.\" },\n // { text: \"저장하신 후에 실행해 주세요.\" }\n // ]);\n // return false;\n //}\n v_global.event.data = {\n setup_no: v_global.logic.setup_no,\n setup_seq: v_global.logic.setup_seq,\n user_seq: gw_com_api.getValue(\"frmData_SETUP_D\", 1, \"setup_users\")\n };\n var args = {\n type: \"PAGE\", page: \"EHM_3222\", title: \"SETUP 작업자 선택\",\n width: 500, height: 400, locate: [\"center\", 150], open: true,\n };\n if (gw_com_module.dialoguePrepare(args) == false) {\n var args = {\n page: \"EHM_3222\",\n param: {\n ID: gw_com_api.v_Stream.msg_openedDialogue,\n data: v_global.event.data\n }\n };\n gw_com_module.dialogueOpen(args);\n }\n }\n break;\n }\n\n}", "title": "" }, { "docid": "f727abcd2cff8ff5b67dacf93a36fd96", "score": "0.57419866", "text": "buttonClick(id){\n\n switch(id){\n case Buttons.Save:\n this.sendData();\n\n break;\n case Buttons.MainMenu:\n\n this.props.route.history.push('/');\n break;\n\n default:\n console.log(\"No such button\");\n }\n\n }", "title": "" }, { "docid": "b6165b55ad76b402d0c59a98ae37b569", "score": "0.57317936", "text": "buttonClick(id){\n\n switch(id){\n case Buttons.Delete:\n this.props.dispatch(sendCommand(\"Set\", \"CommandToRx\", {DeleteLog:1}));\n this.refreshList();\n break;\n case Buttons.Refresh:\n this.refreshList();\n break;\n\n case Buttons.Download:\n this.download(\"logfile\");\n break;\n\n case Buttons.MainMenu:\n this.props.route.history.push('/');\n break;\n\n default:\n console.log(\"No such button\");\n }\n\n }", "title": "" }, { "docid": "8cf87ad7028ab18c9b8a1f3bfe82fc0f", "score": "0.5728475", "text": "function onCadastrar(buttonIndex, codig){\n if(buttonIndex == 1){\n $(location).attr('href', 'cadastro.html');\n }else{\n $(location).attr('href', 'index.html');\n }\n}", "title": "" }, { "docid": "3cbe1b14e7bd41e1348218ba0cd08675", "score": "0.5697625", "text": "function ajaxGotoNext20Index(startIdx, path, divName) {\n\tif (startIdx.length < 1) {\n\t\tstartIdx = 0;\n\t}\n\t// next 20 page value as start index value\n\tparameter1 = startIdx;\n\t// set the start index value\n\tstartIndexValue = (startIdx - 1) * 10;\n\t// submit the ajax action\n\tajaxCommonActionSubmit(path, divName, DIV_DEFAULT_WIDTH, DIV_DEFAULT_HEIGHT);\n}", "title": "" }, { "docid": "04af904431639dd3ad571c59b47393f6", "score": "0.5663569", "text": "function actionBtnMethod() {\n currentPage++;\n onStateChange();\n}", "title": "" }, { "docid": "ccfcdd3c8ae2163998c98231022a5036", "score": "0.5657799", "text": "function processButton(param) {\n\n if (param.object == \"lyrMenu\") {\n switch (param.element) {\n case \"저장\":\n {\n processSave({});\n }\n break;\n case \"닫기\":\n processClose();\n break;\n }\n }\n\n}", "title": "" }, { "docid": "f021c64fa51ecfd609eb8ce1923e4af6", "score": "0.5621875", "text": "handleClick(i) {\n\t\t//TODO\n\t}", "title": "" }, { "docid": "301e712cec8feaf4452cc2ca21480c96", "score": "0.5618918", "text": "function handleBtnEatClicked() {\n console.log('handleBtnEatClicked');\n console.log(localSearchResultData[currentSearchResultIndex-1]);\n window.open(localSearchResultData[currentSearchResultIndex-1].url, '_blank');\n\n let data = {\n \"history\" : objForInsert\n };\n\n utilities.makeDbRequest('PUT', data).then(function(data) {\n console.log('added to db');\n }).catch(function(err) {\n console.log(err);\n });\n }", "title": "" }, { "docid": "f34739dc915227c42c5914683a2345d8", "score": "0.5598569", "text": "function handleOnButtonClick(btn) {\r\n switch (btn) {\r\n case 'SEARCH':\r\n document.forms[0].process.value = \"loadAllDividendRule\";\r\n submitFirstForm();\r\n break;\r\n default:break;\r\n }\r\n}", "title": "" }, { "docid": "b3bf9e8938bac321eb97b331b5fa4d81", "score": "0.55896145", "text": "function ajaxGotoIndex(path, indexVal, divName) {\n\t// get the start index value.\n\tstartIndexValue = indexVal;\n\n\t// submit the pagination action to get the next page.\n\tajaxCommonActionSubmit(path, divName, DIV_DEFAULT_WIDTH, DIV_DEFAULT_HEIGHT);\n\t\n}", "title": "" }, { "docid": "ca1c8a81a31c4aa0c64f1a10a96a894b", "score": "0.5581095", "text": "handleClick(index) {\n const {dispatch} = this.props;\n dispatch(requestCharas(index, 0));\n }", "title": "" }, { "docid": "8907fd91b3d77dbab4e5d92f2f47f39d", "score": "0.5572776", "text": "function handleNextBtn() {\n // Move the pointer back\n util.movePtr(\"next\");\n\n // Extract the index and url at ptr using object deconstruction\n const { idx, url } = ptr.value;\n\n // Update the index\n util.updateIdx(idx);\n\n // Update the carousel's image\n util.updateImage(url);\n }", "title": "" }, { "docid": "d1e0be4f58714511aed20f27c02117b4", "score": "0.5568411", "text": "handleNextButton() {\n console.log(\"clicked next button\");\n console.log(this.state.nextPaginationURL);\n\n this.grabItemsFromAPI();\n }", "title": "" }, { "docid": "af45596ead5fcfd80b66b52b1fffe6f4", "score": "0.5565015", "text": "hitButton(e) {\n c.history.push(e.target.textContent);\n c.controller(e.target.textContent);\n }", "title": "" }, { "docid": "c43f608a2384e95e8376e90adfc76fbf", "score": "0.55613697", "text": "function onVideoButtonClick(uniqueId, direction) {\n\n\t// get the request object\n\trequest = createRequest();\n\tif (request == null) {\n\t\talert(\"Could not make request -> Browser incompatible\");\n\t\treturn;\n\t}\n\n\t// Configure the request\n\tvar url = \"/HasMain/Has?control=\" + escape(uniqueId) + \"&data=\"\n\t\t\t+ escape(direction); // escape() comes in handy to kill any chars\n\t// that are problematic in a request URL\n\t// string.\n\t// this line tells the request object the URL to call.\n\t// we send the name of the item, so the server knows which details to send.\n\n\trequest.open(\"GET\", url, true); // this tells the request object how to\n\t// handle the connection to the server\n\n\t// Setup the callback function that the server will call when there's new\n\t// information available\n\trequest.onreadystatechange = emptyCallback();\n\n\t// Send the request\n\trequest.send(null); // null means no extra data is sent with the request\n\n}", "title": "" }, { "docid": "6d757aebd66b5018e5a5c47ffbaa1a28", "score": "0.5555015", "text": "function onVisualizar(buttonIndex){\n if(buttonIndex == 1){\n $(location).attr('href', 'produto.html');\n\n }else{\n $(location).attr('href', 'index.html');\n }\n}", "title": "" }, { "docid": "5a364a563743df9fa24479a132251cdf", "score": "0.5551841", "text": "function switchHandler() {\n\t// reset the placeholder of selector input\n\t$('.page-jump input').val(currentPage);\n\n\t// remove selector buttons\n\tvar btns = $('.button-groups').children();\n\tfor (var i = 0; i < btns.length; ++i)\n\t\t$(btns[i]).remove();\n\n\t// calculate start index and active index\n\tvar start = Math.floor((currentPage-1)/displPage)*displPage+1;\n\tvar index = currentPage%displPage;\n\tif (index == 0) index = displPage;\n\n\t// insert selector buttons\n\tif (displPage > totalPage - start + 1)\n\t\tsetPageSelector(totalPage - start + 1, start, index);\n\telse\n\t\tsetPageSelector(displPage, start, index);\n\n\t// ajax request\n\trequestData();\n}", "title": "" }, { "docid": "c3148c97741a6e766b35bf13b252b2db", "score": "0.5539795", "text": "function watchButtons(responseJson){\n $('button').click(function(){\n if(this.name === 'back'){\n clearPage();\n getPokemon();\n }\n else if(this.name === 'type'){\n let type = this.value;\n clearPage();\n getPokemonByType(type);\n }\n else if(this.name === 'poke-card'){\n let pokemon = $(this).attr('value');\n getSpecificPokemon(pokemon);\n }\n else if(this.name === 'next'){\n clearPage();\n getNextPage(responseJson.next);\n }\n else if(this.name === 'previous'){\n clearPage();\n getPreviousPage(responseJson.previous);\n }\n });\n}", "title": "" }, { "docid": "bbfadb1f0c1a356ecbd1cfea467eeb53", "score": "0.55301577", "text": "function to_home_from_download(){\n div_1.replaceChild(btn1, btn_get_from_ipfs);\n div_2.replaceChild(btn2, btn_h2);\n}", "title": "" }, { "docid": "ac5d8d028beffb6f574104c7adbb5955", "score": "0.5523368", "text": "function initIndex( ) {\n var a;\n\n a = new coc.ui.FastButton( document.getElementById( \"report-list-confirm\" ), prepareMap );\n\n document.getElementById( \"report-list\" ).onchange = function ( ) {\n setHelpBlurb( );\n };\n setHelpBlurb( );\n\n return false;\n }", "title": "" }, { "docid": "64509ad7389032d1906b1c064323bc32", "score": "0.5516577", "text": "function Button_6_onclick(e, obj, index) {\n\t$.davinci.changePage(\"pgMain\", {changeHash: false});\n}", "title": "" }, { "docid": "2393608ae72fe97ad45744e2458fc0de", "score": "0.5510972", "text": "function processButton(param) {\n\n if (param.object == undefined) return false;\n if (param.object == \"lyrMenu\") {\n if (param.element == \"저장\") {\n processInformResult({});\n } else if (param.element == \"닫기\") {\n processClose({});\n }\n }\n}", "title": "" }, { "docid": "8b9854d63523a6c74eb64744abe57a6f", "score": "0.5506777", "text": "async runIndex() {\n await ajax.post(this.urls.runIndex, { token: this.tokens.form })\n .then(() => {\n // Reset the page display\n $(this.searchId).val('');\n this.setHomeMode(true);\n\n // Close the filters\n $('#regions-box-content').collapse('hide');\n $('#departments-box-content').collapse('hide');\n });\n }", "title": "" }, { "docid": "438977891b9af7cbf9abe4919388df02", "score": "0.5505116", "text": "function handleNextBtn() {\n $('main').on('click', '#nextBtn', function(event) {\n store.questionNumber++;\n renderPage();\n })\n}", "title": "" }, { "docid": "7ffe1f5130d5fc692d81b40268da1922", "score": "0.55020636", "text": "function commandButtons() {\n\tbtnArray = new Array(\n\tdreamweaver.loadString(\"button/next\"),\t\"clickedNext()\", \n\tMM.BTN_Cancel,\t\"clickedCancel()\",\n\tMM.BTN_Help,\t\"clickedHelp()\");\n\treturn btnArray;\n}", "title": "" }, { "docid": "2958de47c5d4b9034087e57c9cc5b76f", "score": "0.5495012", "text": "function handleNextBtnClicked() {\n console.log('handleNextBtnClicked');\n console.log('btnNextResult', btnNextResult);\n populateSearchResult();\n\n pubSub.emit('destroyDetailsView');\n }", "title": "" }, { "docid": "669900c5b6c5345d9dd0efddd8c863b9", "score": "0.5494636", "text": "function sendOnClick(){\n\tvar method = 'POST'\n\tvar script = '../servidor/compruebaDisponibilidadXML.php'\n\tsendRequest(method, script, comprobarNick);\n}", "title": "" }, { "docid": "97e3fe32941e654bd53e0471815d6f7e", "score": "0.5490646", "text": "function handleClickStartButton() {\n $(\"main\").on(\"click\", \"#startButton\", event => {\n displayNextPage();\n })\n}", "title": "" }, { "docid": "da4c5ef9d377bb95df86227a8420e6ba", "score": "0.54904884", "text": "function hit_player_buttons(item, index) {\n if (canvasObjects.buttonHit(player_page_buttons[index])) {\n boards.switchTo(item);\n }\n }", "title": "" }, { "docid": "f5b6584f1f4624a757f15dafdb6ff921", "score": "0.54866004", "text": "function buttonClick() {\n\tvar id = event.target.id;\n\tswitch(id) {\n\tcase \"Load\":\n\t\tbtRead.disabled = false;\n\t\tloadParams();\n\tbreak;\n\tcase \"Read\":\n\t\tbtStart.disabled = false;\n\t\treadParams();\n\tbreak;\n\tcase \"Start\":\n\t\tif(btStart.innerHTML == \"Start\") {\n\t\t\tbtLoad.disabled = true;\n\t\t\tbtRead.disabled = true;\n\t\t\tbtInfo.disabled = true;\n\t\t\tbtStart.innerHTML = \"Stop\";\n\t\t\tproc = setInterval(simulate, Tproc);\n\t\t} else {\n\t\t\tbtLoad.disabled = false;\n\t\t\tbtRead.disabled = false;\n\t\t\tbtInfo.disabled = false;\n\t\t\tbtStart.innerHTML = \"Start\";\n\t\t\tclearInterval(proc);\n\t\t}\n\tbreak;\n\tcase \"Info\":\n\t\tvar info = \"\";\n\t\tinfo += \"scspg.js\\n\";\n\t\tinfo += \"Semi-circle segmented path generator\\n\";\n\t\tinfo += \"Sparisoma Viridi\\n\";\n\t\tinfo += \"https://github.com/dudung/butiran.js\\n\"\n\t\tinfo += \"Load load parameters\\n\";\n\t\tinfo += \"Read read parameters\\n\";\n\t\tinfo += \"Start start generation\\n\";\n\t\tinfo += \"Info show this messages\\n\";\n\t\tinfo += \"\\n\";\n\t\taddText(info).to(taOut);\n\tbreak;\n\tdefault:\n\t}\n}", "title": "" }, { "docid": "b15cf3881bbccd3608e6d42c310b286b", "score": "0.54778725", "text": "function onButtonGoToFirstPageClick(){\n\tgPageToDiplay = 1;\n\tperformAJAXRequest();\n}", "title": "" }, { "docid": "ffd6be3018a35aa5fde69fa212cad2bb", "score": "0.5471962", "text": "function handleOnButtonClick(asBtn) {\r\n switch (asBtn) {\r\n case 'SAVE':\r\n if (typeof erpListGrid1 == \"undefined\") {\r\n break;\r\n }\r\n document.forms[0].txtXML.value = getChangesOnly(erpListGrid1);\r\n var url = getAppPath() + \"/componentmgr/experiencemgr/processErp.do?\";\r\n postAjaxSubmit(url, \"saveAllErp\", false, false, handleOnSaveErpDone);\r\n break;\r\n case 'CLOSE':\r\n if (isOkToChangePage()) {\r\n closeThis();\r\n }\r\n break;\r\n case 'PROCESS_ERP':\r\n if (isOkToChangePage()) {\r\n var url = getAppPath() + \"/componentmgr/experiencemgr/processErp.do?\";\r\n postAjaxSubmit(url, \"processErp\", false, false, handleOnProcessErpDone);\r\n }\r\n break;\r\n case 'SHOW_ALL':\r\n getObject(\"showAll\").value = \"Y\";\r\n getObject(\"renewalYear\").value = \"\";\r\n showProcessingDivPopup();\r\n document.forms[0].action = getAppPath() + \"/componentmgr/experiencemgr/processErp.do?date=\" + new Date();\r\n document.forms[0].process.value = 'loadAllErp';\r\n submitFirstForm();\r\n break;\r\n case 'SEARCH':\r\n getObject(\"showAll\").value = \"N\";\r\n showProcessingDivPopup();\r\n enableDisableField(getObject(\"renewalDate\"), false);\r\n enableDisableField(getObject(\"processDate\"), false);\r\n enableDisableField(getObject(\"erpIssueStateCode\"), false);\r\n enableDisableField(getObject(\"batchNo\"), false);\r\n document.forms[0].action = getAppPath() + \"/componentmgr/experiencemgr/processErp.do?date=\" + new Date();\r\n document.forms[0].process.value = 'loadAllErp';\r\n submitFirstForm();\r\n break;\r\n case 'DELETE_BATCH':\r\n var batchNo = getObjectValue(\"batchNo\");\r\n if (isEmpty(batchNo)) {\r\n alert(getMessage(\"pm.processErp.deleteBatch.noBatchNo.error\"));\r\n return;\r\n }\r\n if (confirm(getMessage(\"pm.processErp.deleteBatch.confirmation\", new Array(batchNo)))) {\r\n var url = getAppPath() + \"/componentmgr/experiencemgr/processErp.do?process=deleteErpBatch&batchNo=\" + batchNo;\r\n new AJAXRequest(\"get\", url, '', handleOnDeleteErpBatchDone, false);\r\n }\r\n break;\r\n }\r\n}", "title": "" }, { "docid": "37c5d287488096a4c657c1d4fde9ef50", "score": "0.5470554", "text": "function ajaxGotoPrevious20Index(startIdx, path, divName) {\n\tif (startIdx.length < 1) {\n\t\tstartIdx = 0;\n\t}\n\t// set next 20 page value with new value\n\tparameter1 = startIdx - 19;\n\t// set the start index value\n\tstartIndexValue = (startIdx - 20) * 10;\n\t// submit the ajax action\n\tajaxCommonActionSubmit(path, divName, DIV_DEFAULT_WIDTH, DIV_DEFAULT_HEIGHT);\n\t\n}", "title": "" }, { "docid": "912527668134d2710179f536aca7cb09", "score": "0.5470553", "text": "function btnScrap_ClickCase15() {\n console.log(\"btnScrap_ClickCase15\");\n if ($scope.WOExecutionStatus == \"Completed\") {\n btnScrap_ClickCase20();\n } else {\n btnScrap_ClickCase100();\n }\n\n }", "title": "" }, { "docid": "f78a6d2600f8bffff0e37a0db1d3fc89", "score": "0.5438469", "text": "function wireButtons() {\n\n\t// Get buttons.\n\tvar buttons = document.querySelectorAll('.scene-maker.buttons button');\n\n\t// Create click handler function.\n\tfunction buttonClickHandler(e) {\n\n\t\tvar html = e.target.innerHTML;\n\t\tvar isNext = html === 'Next';\n\n\t\tmoveForward(isNext);\n\t}\n\n\t// Add event listeners to buttons.\n\tfor (let i = 0; i < buttons.length; i++) {\n\t\tbuttons[i].addEventListener('click', buttonClickHandler);\n\t}\n}", "title": "" }, { "docid": "ee51581adad8621e342ca4d6f92ab284", "score": "0.5436852", "text": "function buttonClick(widget) {\n\n // if button has db command, then use service to execute\n if(widget.button && widget.button.dbCommand) {\n console.log(vm.fields);\n DatabaseService\n .executeCommand(widget.button.dbCommand, vm.page, vm.fields)\n .then(\n function(response){\n // if button has navigate, then go there\n if(widget.button && widget.button.navigate) {\n $location.url(\"/developer/\"+vm.username+\"/website/\"+vm.websiteId+\"/page/\"+widget.button.navigate+\"/run\");\n }\n },\n function(err){\n vm.errors = err;\n }\n );\n } else {\n // if button has navigate, then go there\n if(widget.button && widget.button.navigate) {\n $location.url(\"/developer/\"+vm.username+\"/website/\"+vm.websiteId+\"/page/\"+widget.button.navigate+\"/run\");\n }\n }\n }", "title": "" }, { "docid": "f00a43a983e85e0a1ba3a5563fe34d29", "score": "0.5424339", "text": "function ajaxGotoNext20PageIndex(path, indexVal, next20page, divName) {\n\t// get the start index value.\n\tstartIndexValue = indexVal;\n\tparameter1 = next20page;\n\t\n\t// submit the pagination action to get the next page.\n\tajaxCommonActionSubmit(path, divName, DIV_DEFAULT_WIDTH, DIV_DEFAULT_HEIGHT);\n\t\n}", "title": "" }, { "docid": "b548b11dcf32668f697e4e86cd5a6cc4", "score": "0.5424114", "text": "function runPage(){\n\t$('#new-btn').click(getNewFood);\n\t$('#add-btn').click(addNewFood);\n\t$('.print').click(printReciept);\n\t$('#delete').click(deleteLast);\n\t$('#newCustomer').click(refresh);\n}", "title": "" }, { "docid": "e31032ec3bb366156fecb2a7669ccb98", "score": "0.54221463", "text": "function main() {\n renderPage(startPage);\n startBtnClick();\n}", "title": "" }, { "docid": "3f1cd950a5b1b00a4123f23ef29744b8", "score": "0.54047453", "text": "function pageRender(){\n $('#button1').on('click',function(){\n readJson(1);\n });\n $('#button2').on('click', function(){\n readJson(2);\n })\n}", "title": "" }, { "docid": "963a5537abd821582abae9007e7e6491", "score": "0.53952247", "text": "function commandButtons()\n{\n var btnArray = new Array(MM.BTN_OK, \"clickedOK()\", \n MM.BTN_Cancel, \"clickedCancel()\", \n MM.BTN_Test, \"clickedTest()\");\n\n\tvar dom = dreamweaver.getDocumentDOM();\n\tvar docName = dom.URL;\n\tvar docType = dom.documentType;\n\t\n\t// add a button for each different rs type\n\tfor (i = 0;i < MM.rsTypes.length;i++) \n\t{\n\t\tif(MM.rsTypes[i].single == \"true\") {\n\t\t\tcontinue;\n\t\t}\n\t\tif( (!MM.rsTypes[i].fileExt || docName.match(MM.rsTypes[i].fileExtRegExp)) ||\n\t\t (!MM.rsTypes[i].documentType || docType.match(MM.rsTypes[i].documentTypeRegExp)) )\n\t\t{\t \n \t\tif (dom.serverModel.getServerName() == MM.rsTypes[i].serverModel) {\n \t\t\tif (RECORDSET_TYPE.toLowerCase() != MM.rsTypes[i].type.toLowerCase()) {\n\t \t\t\t\tvar btnLabel = dw.loadString(\"recordsetType/\" + MM.rsTypes[i].type);\n\t\t\t\t\tif (!btnLabel)\n\t\t\t\t\t\tbtnLabel = MM.rsTypes[i].type;\n\t\t\t\t\tbtnArray.push(\" \" + btnLabel + \"... \");\n\t\t\t\t\tbtnArray.push(\"clickedChange(\" + i + \")\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tbtnArray.push(MM.BTN_Help);\n\tbtnArray.push(\"displayHelp()\"); \n\treturn btnArray;\n}", "title": "" }, { "docid": "f9bddf2a77e8f90b57afc4bd71c77546", "score": "0.53920096", "text": "function getPageCuti(page){ \r\n ajax.open(\"get\",page,true);\r\n ajax.onreadystatechange = function () {\r\n if (ajax.readyState == 4 && ajax.status == 200) {\r\n document.getElementById(\"switch\").innerHTML = ajax.responseText; \r\n showCuti(user_id);\r\n document.getElementById(\"formbutton\").innerHTML = \r\n `\r\n <button class=\"btn btn-primary col-12\" onclick=\"getPage('pengajuanCuti.html')\" style=\"margin-bottom:100px\">PENGAJUAN CUTI</button> \r\n `;\r\n } \r\n }\r\n ajax.send();\r\n}", "title": "" }, { "docid": "45ab87c722a9d6cc6fe4485acf8f2d17", "score": "0.5390551", "text": "handleOnPageBtnClick (pageIndex) {\n const currentUrl = this.state.currentUrl;\n const currentUrlPageParam = 'results_per_page='\n + this.state.resultPerPage\n + '&'\n + 'page=' + pageIndex;\n const currentUrlQueryParam = this.state.currentUrlQueryParam;\n\n const requestUrl = currentUrl\n + currentUrlPageParam\n + '&'\n + currentUrlQueryParam;\n\n this.setState({page: pageIndex, data: [], isNoResult: true, isLoading: true});\n this.fetchData(requestUrl);\n }", "title": "" }, { "docid": "df7c893498cce4b1db059a80fb58609f", "score": "0.53736454", "text": "function setNextBackButtonsLogic(){\n\n\t\t$(document).on(\"click\", \".button.next\", function(){\n\n\t\t\tswitch(mode){\n\t\t\t\t\n\t\t\t\tcase BabyTrackMode.CREATE_NEW_PERSON:\n\t\t\t\t\topenChoosePersonWindow();\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase BabyTrackMode.CHOOSE_EXISTED_PERSON:\n\t\t\t\t\topenAddEventWizardNewActivityWindow();\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase BabyTrackMode.ADD_EVENT_WIZARD_NEW_ACTIVITY:\n\t\t\t\t\topenSelectedActivity();\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase BabyTrackMode.ADD_FOOD_EVENT:\n\n\t\t\t\t\ttry{\n\t\t\t\t\t\tcheckCorrectInputAndSubmit({window: \"ADD_FOOD_EVENT\"});\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\talert(e.toString());\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent_baby.activityImg = 'images/old/bottle.png';\n\t\t\t\t\tcurrent_baby.activity = \"FOOD\";\n\t\t\t\t\tcurrent_baby.setNotes( getDefaultNotes(\"FOOD\") );\n\t\t\t\t\tcurrent_baby.setSubmitDate( glSubmitDate );\n\t\t\t\t\tcurrent_baby.setSubmitTime( glSubmitTime );\n\n\t\t\t\t\t//current_baby.addToTable( $(\"#posted_results_table\").find(\"table\").html() );\n\t\t\t\t\tcurrent_baby.submit();\n\t\t\t\t\tnormalize({window: BabyTrackWindows.POSTED_RESULTS_TABLE});\n\t\t\t\t\t\n\t\t\t\t\topenPostedResultsWindowLogic();\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase BabyTrackMode.ADD_DIAPER_EVENT:\n\n\t\t\t\t\ttry{\n\t\t\t\t\t\tcheckCorrectInputAndSubmit({window: \"ADD_DIAPER_EVENT\"});\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\talert(e.toString());\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent_baby.activityImg = $(\"#diaper_content\").find(\".subactivity_diaper.selected[data-diaper-type]\").find(\"img\").attr(\"src\");\n\t\t\t\t\tcurrent_baby.activity = \"DIAPER\";\n\t\t\t\t\tcurrent_baby.setNotes( getDefaultNotes(\"DIAPER\") );\n\t\t\t\t\tcurrent_baby.setSubmitDate( glSubmitDate );\n\t\t\t\t\tcurrent_baby.setSubmitTime( glSubmitTime );\n\n\t\t\t\t\t//current_baby.addToTable( $(\"#posted_results_table\").find(\"table\").html() );\n\t\t\t\t\tcurrent_baby.submit();\n\t\t\t\t\tnormalize({window: BabyTrackWindows.POSTED_RESULTS_TABLE});\n\t\t\t\t\t\n\t\t\t\t\topenPostedResultsWindowLogic();\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\t\t});\n\n\n\t\t$(document).on(\"click\", \".button.back\", function(){\n\t\t\tswitch(previousWindow){\n\n\t\t\t\tcase BabyTrackWindows.NONE:\n\t\t\t\tbreak;\n\n\t\t\t\tcase BabyTrackWindows.WELCOME_POST:\n\t\t\t\t\t$(\"#add_event_button\").show(1000);\n\n\t\t\t\t\tdropNextBackBtns();\n\n\t\t\t\t\tinitialPage = BabyTrackInitialPage.WELCOME_POST;\n\t\t\t\t\tpreviousWindow = BabyTrackWindows.NONE;\n\t\t\t\t\tmode = BabyTrackMode.NONE;\n\n\t\t\t\t\tclearWindows({effect: \"fadeOut\", speed: 800});\t//asynchronous function\n\n\t\t\t\t\t//awaiting until other animation processes stop\n\t\t\t\t\t//as clearWindows function is asynchronous\n\n\t\t\t\t\tvar timer = setInterval(function(){\n\t\t\t\t\t\tif(windowsAnimationOver){\n\t\t\t\t\t\t\tsetInitialPage(initialPage, {effect: \"drop\", speed: 500});\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//clear all the fields in Create New Person Window\n\t\t\t\t\t\t\tclearResults({window: \"CREATE_NEW_PERSON\"});\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 10);\n\n\t\t\t\tbreak;\n\n\t\t\t\tcase BabyTrackWindows.POSTED_RESULTS_TABLE:\n\t\t\t\t\t$(\"#add_event_button\").show(1000);\n\n\t\t\t\t\tdropNextBackBtns();\n\n\t\t\t\t\tinitialPage = BabyTrackInitialPage.POSTED_RESULTS_TABLE;\n\t\t\t\t\tpreviousWindow = BabyTrackWindows.NONE;\n\t\t\t\t\tmode = BabyTrackMode.NONE;\n\n\t\t\t\t\tclearWindows({effect: \"fadeOut\", speed: 800});\t//asynchronous function\n\n\t\t\t\t\t//awaiting until other animation processes stop\n\t\t\t\t\t//as clearWindows function is asynchronous\n\n\t\t\t\t\tvar timer = setInterval(function(){\n\t\t\t\t\t\tif(windowsAnimationOver){\n\t\t\t\t\t\t\tsetInitialPage(initialPage, {effect: \"drop\", speed: 500}, true);\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//clear all the fields in Create New Person Window\n\t\t\t\t\t\t\tclearResults({window: \"CREATE_NEW_PERSON\"});\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 10);\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase BabyTrackWindows.CREATE_NEW_PERSON:\n\t\t\t\t\tneedToCorrectInputs = true;\n\t\t\t\t\tpreviousWindow = BabyTrackWindows.WELCOME_POST;\n\t\t\t\t\tmode = BabyTrackMode.CREATE_NEW_PERSON;\n\n\t\t\t\t\tclearWindows({effect: \"drop\", speed: 500, direction: \"right\"});\n\t\t\t\t\tvar timer = setInterval(function(){\n\t\t\t\t\t\tif(windowsAnimationOver){\n\t\t\t\t\t\t\t$(\"#create_person_block\").show(\"drop\", {direction: \"left\"}, 400);\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 10);\n\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase BabyTrackWindows.CHOOSE_EXISTED_PERSON:\n\t\t\t\t\t\n\t\t\t\t\tmode = BabyTrackMode.CHOOSE_EXISTED_PERSON;\n\t\t\t\t\tpreviousWindow = BabyTrackWindows.CREATE_NEW_PERSON;\n\n\t\t\t\t\tclearWindows({effect: \"drop\", speed: 500, direction: \"right\"});\n\t\t\t\t\tvar timer = setInterval(function(){\n\t\t\t\t\t\tif(windowsAnimationOver){\n\t\t\t\t\t\t\t$(\"#choose_person\").show(\"drop\", {direction: \"left\"}, 400);\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 10);\n\n\t\t\t\tbreak;\n\n\t\t\t\tcase BabyTrackWindows.ADD_EVENT_WIZARD_NEW_PERSON:\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t\t\tcase BabyTrackWindows.ADD_EVENT_WIZARD_NEW_ACTIVITY:\n\n\t\t\t\t\tmode = BabyTrackMode.ADD_EVENT_WIZARD_NEW_ACTIVITY;\n\t\t\t\t\tpreviousWindow = BabyTrackWindows.CHOOSE_EXISTED_PERSON;\n\n\t\t\t\t\tclearWindows({effect: \"drop\", speed: 500, direction: \"right\"});\n\t\t\t\t\tvar timer = setInterval(function(){\n\t\t\t\t\t\tif(windowsAnimationOver){\n\t\t\t\t\t\t\t$(\"#wizard_new_activity\").show(\"drop\", {direction: \"left\"}, 400);\n\t\t\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 10);\n\t\t\t\tbreak;\n\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "ccac834d696fdd2346800308bff20b87", "score": "0.5366466", "text": "function buttonClicked(i, j) { //this is where you should start\n setStatusText(\"Button [\" + i + \", \" + j + \"] pressed\");\n clickHistory.push(i*8 + j);\n //set this button to a random color\n setButtonColor(i, j, getRandomColor());\n var currentText = getButtonText(i, j);\n var textValue = 0;\n if (currentText != \"\") {\n textValue = parseInt(currentText, 10); //convert the text to base10 (decimal) number\n }\n setButtonText(i, j, textValue+1);\n //increase the progress bar a bit\n progress += textValue;\n setProgressBar(\"bar\", \"bg-success\", progress);\n}", "title": "" }, { "docid": "4c34085b30b1f2bcee3a9a4d2b967eac", "score": "0.5357205", "text": "function setBtnto(action){\n\tvar obj= {\n\t\t'start_button' : action\n\t};\n\tsetObjectdata(obj);\n\tdocument.getElementById('start_button').text = action;\n}", "title": "" }, { "docid": "ecf59268a332bc4b3bb62c8eb778434a", "score": "0.534292", "text": "function buttonClick() {\r\n\t// Get target and verbose to taOut1\r\n\tvar target = event.target;\r\n\tvar cap = target.innerHTML;\r\n\ttout(taOut1, cap + \"\\n\");\r\n\t\r\n\t// Perform according to the clicked button\r\n\tif(cap == \"Load\") {\r\n\t\tloadParameters(taIn);\r\n\t\tbtRead.disabled = false;\r\n\t\ttout(taOut1, \"Parameters are loaded\\n\\n\");\r\n\t} else if(cap == \"Clear\") {\r\n\t\tclearAll();\r\n\t\tbtRead.disabled = true;\r\n\t\tbtStart.disabled = true;\r\n\t\ttout(taOut1, \"All are cleared except this element\\n\\n\");\r\n\t} else if(cap == \"Read\") {\r\n\t\treadParameters(taIn);\r\n\t\tinitParams();\r\n\t\tclearCanvas();\r\n\t\tdrawSystem();\r\n\t\tbtStart.disabled = false;\r\n\t\ttout(taOut1, \"Parameters are read\\n\\n\");\r\n\t} else if(cap == \"Start\") {\r\n\t\ttarget.innerHTML = \"Stop\";\r\n\t\tbtRead.disabled = true;\r\n\t\ttaIn.disabled = true;\r\n\t\ttout(taOut1, \"Simulation starts\\n\\n\");\r\n\t\tproc = setInterval(simulate, tproc);\r\n\t} else if(cap == \"Stop\") {\r\n\t\ttarget.innerHTML = \"Start\";\r\n\t\tbtRead.disabled = false;\r\n\t\ttaIn.disabled = false;\r\n\t\ttout(taOut1, \"Simulation stops\\n\\n\");\r\n\t\tclearInterval(proc);\r\n\t} else if(cap == \"Info\") {\r\n\t\ttout(taOut1, \"yukawa.js -- 20190323\\n\"\r\n\t\t\t+ \"Simulation of Yukawa Potential\\n\"\r\n\t\t\t+ \"on 2 Spherical Masses\\n\"\r\n\t\t\t+ \"Harianto Wibowo| \"\r\n\t\t\t+ \"hariantowb@gmail\"\r\n\t\t\t+ \"\\n\\n\"\r\n\t\t);\r\n\t}\r\n}", "title": "" }, { "docid": "da0644f590afeba70af50490bf92d1ce", "score": "0.5339281", "text": "function forwardButton() {\n\t// Send a message to the server indicating that the button has been\n\t// clicked. The text of the message is simply the word \"forward\".\n\tsocket.send('forward');\n\t\n}", "title": "" }, { "docid": "a334efe266813b7a350ce8ee9ded51fd", "score": "0.5336444", "text": "function main() {\n render();\n quizStartPageStartButton();\n questionSubmitButton();\n resultsResetButton();\n nextQuestionButton();\n}", "title": "" }, { "docid": "172dd13b1807864e1fe3334a8112a0b3", "score": "0.532941", "text": "function main() {\n $registerBtn = $('#registerBtn')\n $loginBtn = $('#loginBtn')\n $profileBtn = $('#profileBtn')\n $adminBtn = $('#adminBtn')\n $courseBtn = $('#courseBtn')\n\n $registerBtn.click(function () { window.location.href = './jquery/components/register/register.template.client.html' })\n $loginBtn.click(function () { window.location.href = './jquery/components/login/login.template.client.html' })\n $profileBtn.click(function () { window.location.href = './jquery/components/profile/profile.template.client.html' })\n $adminBtn.click(function () { window.location.href = './jquery/components/admin/user-admin.template.client.html' })\n $courseBtn.click(function () { window.location.href = 'https://whiteboard-react-chasebish.herokuapp.com/' })\n }", "title": "" }, { "docid": "8320c7d37be699beae71ee089c6c4f7f", "score": "0.5324232", "text": "static onNextClicked() {\n var $next = $('button#btn_next');\n // No need to verify data since there will always be default data\n // Confirm functionality\n if (StepHandler.readyForNext) {\n $next.text('Next >');\n StepHandler.readyForNext = false;\n StepHandler.onStepComplete();\n }\n else {\n $next.text('Confirm ?');\n StepHandler.readyForNext = true;\n }\n }", "title": "" }, { "docid": "36cd596a09a2d2a047a0875bf6c0fca4", "score": "0.5322642", "text": "function ds_nganh_nghe_trang_chu_ntv_theo_nganh_hot() {\n\tv_url = '/ajax/ntv_danh_sach_nganh_nghe_trang_chu/index/';\n\tAjaxAction('div_ds_nganh_nghe_trang_chu_ntv', v_url);\n}", "title": "" }, { "docid": "00a7851308a678381b88f9163d8ce684", "score": "0.53215754", "text": "function bindButtons() {\n\t document.getElementById(\"newWork\").addEventListener('click', function(event) {\n\t\tvar req = new XMLHttpRequest();\n\t\tvar workName = document.getElementById(\"workName\").value;\n\t\tvar repsCurrent = document.getElementById(\"reps\").value;\n\t\tvar weightCurrent = document.getElementById(\"weight\").value;\n\t\tvar dateCurrent = document.getElementById(\"date\").value;\n\t\tvar unitsCurrent = document.getElementById(\"lbsbutton\").value;\n\t\tvar units2Current = document.getElementById(\"kgsbutton\").value;\n\t\tconsole.log(unitsCurrent);\n\t\tconsole.log(units2Current);\n\t\tif(document.getElementById(\"lbsbutton\").checked) {\n\t\t\tvar units = 1;\n\t\t}\n\t\telse {\n\t\t\tvar units = 0;\n\t\t}\n\t\t\n\t\tvar payload = {};\n\t\tpayload.name=workName;\n\t\tpayload.reps=repsCurrent;\n\t\tpayload.weight=weightCurrent;\n\t\tpayload.date=dateCurrent;\n\t\tpayload.units=units;\n\t\t\n\t\treq.open(\"POST\", \"http://52.26.106.49:3000/insert\", true);\n\t\treq.setRequestHeader(\"Content-Type\", \"application/json\");\n\t\treq.addEventListener(\"load\", function() {\n\t\t if (req.status >= 200 && req.status < 400) {\n\t\t\tvar response = JSON.parse(req.responseText);\n\t\t\tvar data = JSON.parse(response.results);\n\t\t buildTable(data);\n\t\t\t}\n\t\t else {\n\t\t console.log(\"Error in network request: \" );\n\t\t}});\n\t\t\n req.send(JSON.stringify(payload));\n\t\tevent.preventDefault();\n\t\t\n\t });\n\t }", "title": "" }, { "docid": "48ae7f1bad89c3fa77fa0ad304755b66", "score": "0.53213453", "text": "function uvIndex(lon, lat) {\n\tvar indexURL = `https://api.openweathermap.org/data/2.5/uvi?appid=${apiKey}&lat=${lat}&lon=${lon}`;\n \n $.ajax({\n\t\turl: indexURL,\n\t\tmethod: \"GET\"\n\t}).done(function(uvInfo) {\n \n var uvValue = uvInfo.value;\n $(\".weather-info\").append(\"<p id='uv'>\" + \"UV Index: \" + \"</p>\");\n\t\tvar uvBtn = $(\"<button>\").text(uvValue);\n\t\t$(\"#uv\").append(uvBtn);\n\t\t//button styles\n\t\tif (uvValue < 3) {\n\t\t\tuvBtn.css(\"background-color\", \"Green\");\n\t\t} else if (uvValue < 6) {\n\t\t\tuvBtn.css(\"background-color\", \"Yellow\");\n\t\t} else if (uvValue < 8) {\n\t\t\tuvBtn.css(\"background-color\", \"Orange\");\n\t\t} else if (uvValue < 11) {\n\t\t\tuvBtn.css(\"background-color\", \"Red\");\n\t\t} else {\n\t\t\tuvBtn.css(\"background-color\", \"Purple\");\n\t\t}\n })\n}", "title": "" }, { "docid": "81edd3f85c86c627d4ec7032b33db96a", "score": "0.53207296", "text": "function startPage (){\n myButtons();\n}", "title": "" }, { "docid": "10e53d70943db245f8c98e01a2f77c78", "score": "0.5320422", "text": "function _commandButtonClick($btn) {\n exec($btn);\n }", "title": "" }, { "docid": "8435f3c400351ae2f43a2298d3fba843", "score": "0.5320032", "text": "function handleNextBtnClicked() {\n console.log('handleNextBtnClicked');\n toggleLoader();\n getDataFromApi(pagination.next, processData);\n scrollToTop();\n}", "title": "" }, { "docid": "aa7dbe46c8137de36e6f6247fc69159c", "score": "0.5316818", "text": "pressStnd(){\n\n\tthis.components.btnStandard.setClassName(\"knopje-actief\");\n\tthis.components.btnAdvanced.setClassName(\"knopje-nonactief\");\n\tthis.components.standardPage.setVisible(true);\n\tthis.components.advancedPage.setVisible(false);\n\n\tthis.uiHandler.render()\n }", "title": "" }, { "docid": "36118d046456871c654fdd8a6123f68c", "score": "0.5315723", "text": "function set_UI_button() {\n $(\"#scr_download_lua\").click(download_TTS_Lua_code);\n $(\"#scr_download_as_image\").click(download_Image);\n}", "title": "" }, { "docid": "14021c9ac27cab40a1a6cdd359f55978", "score": "0.5307201", "text": "function register_event_handlers()\n {\n \n \n /* button Acasa */\n \n \n /* button Acasa */\n \n \n /* button Acasa */\n \n \n /* button Acasa */\n \n \n /* button Acasa */\n \n \n /* button Orar */\n $(document).on(\"click\", \".uib_w_13\", function(evt)\n {\n /*global activate_page */\n activate_page(\"#Orar\"); \n return false;\n });\n \n /* button Acasa */\n $(document).on(\"click\", \".uib_w_11\", function(evt)\n {\n /*global activate_page */\n activate_page(\"#mainpage\"); \n return false;\n });\n \n /* button Button */\n $(document).on(\"click\", \".uib_w_9\", function(evt)\n {\n /* your code goes here */ \n return false;\n });\n \n /* button Button */\n $(document).on(\"click\", \".uib_w_9\", function(evt)\n {\n /*global activate_page */\n activate_page(\"#mainpage\"); \n return false;\n });\n \n /* button Catalog */\n $(document).on(\"click\", \".uib_w_7\", function(evt)\n {\n /*global activate_page */\n activate_page(\"#Catalog\"); \n return false;\n });\n \n /* button Button */\n $(document).on(\"click\", \".uib_w_15\", function(evt)\n {\n /*global activate_page */\n activate_page(\"#mainpage\"); \n return false;\n });\n \n /* button Despre Noi */\n $(document).on(\"click\", \".uib_w_12\", function(evt)\n {\n /*global activate_page */\n activate_page(\"#despre_noi\"); \n return false;\n });\n \n }", "title": "" }, { "docid": "9644c7786402a885fc9bee37d5878112", "score": "0.5298011", "text": "function index_changePageAction(event, ui)\n{\n var fromPage = 'none';\n var toPage = 'none';\n //\n // gibt es vorher und oder nachher\n //\n if (ui.toPage != undefined)\n {\n if (ui.toPage[0] != undefined)\n {\n toPage = ui.toPage[0].id;\n } \n } \n if (ui.fromPage != undefined)\n {\n if (ui.fromPage[0] != undefined)\n {\n fromPage = ui.fromPage[0].id;\n } \n } \n console.log(\"Changed from Page: \" + fromPage + \" to Page: \" + toPage);\n //\n // zuerst Sachen erledigen, wenn eich eine Seite verlassen habe\n //\n if( fromPage == 'index-page')\n {\n // Auf der Index-Page ein paar Sachen deaktivieren\n //\n }\n else if(fromPage == 'edit-page')\n {\n // auf der EDIT Seite (Dialog) ein paar Sachen aufräumen\n console.debug(\"deactivate any things on the edit page...\");\n }\n //\n // Jetzt die Sachen erledigen, wenn ich die Seite betreten habe\n //\n if(toPage == 'index-page')\n {\n // Auf der Index-Page ein paar Sachen aktivieren\n //\n console.debug(\"deactivate any things on the index page...\");\n index_initIndexPage();\n index_startRefreshTimer();\n }\n else if(toPage == 'edit-page')\n {\n console.debug(\"deactivate any things on the index page...\");\n if (timerId != null)\n {\n index_stopRefreshTimer();\n } \n // auf der EDIT Seite (Dialog) ein paar Sachen aktivieren\n console.debug(\"deactivate any things on the edit page...\");\n edit_initEditPage();\n } \n else if(toPage == 'delete-page')\n {\n console.debug(\"deactivate any things on the index page...\");\n if (timerId != null)\n {\n index_stopRefreshTimer();\n } \n // auf der EDIT Seite (Dialog) ein paar Sachen aktivieren\n console.debug(\"deactivate any things on the edit page...\");\n delete_initDeletePage();\n }\n}", "title": "" }, { "docid": "532ff646fc683aa257e992d56e56443e", "score": "0.5294673", "text": "function goIndex() {\n goTo(\"index\");\n}", "title": "" }, { "docid": "58a11592ed1ff6ac5101dac0c9d41e70", "score": "0.52923393", "text": "function goLite(FRM,BTN)\r\n{\r\n\t \r\n}", "title": "" }, { "docid": "afe8478b40b5e8534afde0772e0098a8", "score": "0.5291406", "text": "function navigate(objButton){\n\n\tpage = objButton.value;\n\n\turl = 'http://' + window.location.host + '/' + page;\n document.location.href = url;\n\n}", "title": "" }, { "docid": "0193cb79ecb0882f7cb1d542b235d2ef", "score": "0.52859217", "text": "function BtnClicked(btn)\n{\n CloseAllDropDowns();\n //AddStatus(btn.name+\" clicked\");\n btn.parentElement.style.display=\"\";\n switch (btn.name)\n {\n case \"airspace\":\n if (btn.innerHTML.includes(\"on\"))\n {\n btn.innerHTML=\"Airspace off\";\n let x = runway1.x;\n let y = (runway1.y+runway2.y)/2;\n DrawCircle(x,y,500,\"airspace\");\n }\n else\n {\n btn.innerHTML=\"Airspace on\";\n ClearSketch(\"airspace\");\n }\n break;\n\n case \"startsim\":\n if (btn.innerHTML==\"Start\")\n {\n btn.innerHTML=\"Stop\";\n StartAnimation(true);\n }\n else\n {\n btn.innerHTML=\"Start\";\n StartAnimation(false);\n // stop addplanes if its running\n get(\"addplanes\").innerHTML=\"Start\";\n }\n break;\n\n case \"addplanes\":\n AddPlanes();\n break;\n\n case \"addplane\":\n AddPlane();\n break;\n\n case \"alt\":\n //AddStatus(btn.innerHTML);\n SetAltitude(btn);\n break;\n\n case \"speed\":\n //AddStatus(btn.innerHTML);\n SetSpeed(Number(btn.innerHTML));\n break;\n\n case \"clearsketch\":\n let radial = drawings.filter(x=>x.lbl==\"radial\");\n let fix = drawings.filter(x=>x.lbl==\"hold\");\n if (radial.length>0)\n ClearSketch(\"line,radial,hold\");\n else\n ClearSketch(\"line,fix\");\n break;\n\n case \"clearstatus\":\n ClearStatus();\n break;\n\n case \"debug\":\n Debug(btn);\n break;\n\n case \"Help\":\n AddStatus(\"in Help\");\n window.location.href=\"../RadarSimHelp/index.html\";\n break;\n\n case \"grid\":\n if (btn.innerHTML.includes(\"Clear\"))\n {\n btn.innerHTML=\"Draw Grid\";\n ClearSketch(\"grid\");\n }\n else\n {\n btn.innerHTML=\"Clear Grid\";\n DrawGrid();\n }\n break;\n }\n}", "title": "" }, { "docid": "79cb8b3edbf292fc9ead947e47c97a58", "score": "0.5283512", "text": "function checkButtonSelection(param){\n if(param == 2)\n {\n //console.log(\"Le dio comprar\");\n //page = 6;\n //$.mobile.changePage( \"browser.html\", { transition: \"slideup\", reloadPage: true });\n cargarURl();\n } \n }", "title": "" }, { "docid": "92cfe1857ea01c83724aa47f842a2338", "score": "0.5280424", "text": "function clickButton() {\n\n const consulta = {\n nombre,\n apellido,\n numDoc,\n edad,\n telefono,\n email,\n fechaConsulta,\n horaConsulta,\n motivo,\n }\n enviarAlServidor(consulta)\n}", "title": "" }, { "docid": "94e9665aa5b6c6dcd834f0545ce92716", "score": "0.5277869", "text": "function ds_nganh_nghe_trang_chu_ntd_theo_nganh_hot() {\n\tv_url = '/ajax/ntd_danh_sach_nganh_nghe_trang_chu/index/';\n\tAjaxAction('div_ds_nganh_nghe_trang_chu_ntd', v_url);\n}", "title": "" }, { "docid": "33478b11e68b866d54c198698699848a", "score": "0.5277728", "text": "success() {\n // no need for response data\n // redirect to index page when done\n wx.switchTab({\n url: '/pages/stories/stories'\n });\n }", "title": "" }, { "docid": "5a622730272b801378be9b0448458fed", "score": "0.52745175", "text": "function btn_go() {\r\n btn_command(txtCommand.value);\r\n}", "title": "" }, { "docid": "aa4d1a400dee676475da6e0e2347a8c1", "score": "0.52742153", "text": "function gotoIndex() {\n\twindow.location = \"/hiwi/public/index.jsp\";\n}", "title": "" }, { "docid": "7c92b886e9cb8174895452a4107b905b", "score": "0.5272284", "text": "function initiateGoingButtons() {\n var buttons = document.getElementsByClassName(\"btn-going\");\n\n // cannot call forEach directly on buttons {HTMLCollection}\n Array.prototype.forEach.call(buttons, function(button) {\n updateButtonLabel(button);\n\n // now that we're done with the look, lets add the logic\n button.addEventListener(\"click\", function(event) {\n event.preventDefault();\n\n // #user rendered if user is logged in and contain user ID\n // this means we mark a business as \"going\" fot the user\n try {\n var userID = document.querySelector(\"#user\").innerHTML;\n var yelpID = button.getAttribute(\"yelpid\");\n var url = window.location.origin + \"/api/metoo\";\n var payload = {\"yelpID\": yelpID, \"userID\": userID};\n // eslint-disable-next-line no-undef\n ajaxRequest(\"POST\", url, payload, function(response){\n // this route give a \"soft\" error (meaning with http code 200) when:\n // user already marked a business als \"going\" before\n try {\n response = JSON.parse(response);\n if (response.error) {\n alert(response.error);\n } else {\n updateButtonLabel(button);\n }\n } catch (e) {\n console.log(e);\n updateButtonLabel(button); // update the button anyway just to be sure \n }\n });\n } catch (e) {\n // redirect to login otherwise\n var loginURL = window.location.origin + \"/auth/twitter\";\n window.location.assign(loginURL);\n }\n });\n });\n}", "title": "" }, { "docid": "7ad9954915dc16b8eecf4e723f57f418", "score": "0.52654326", "text": "function setButtons(){\n // Set button function\n $(\"#continue\").click(function() {\n // data saving\n var trial_data = {\n 'alphaNews': alphaNewsClicks,\n 'premierNews': premierNewsClicks,\n 'firstNews': firstNewsClicks,\n 'firstForAgainst': firstForAgainst\n }\n // goto next trial in block\n display_element.html('');\n jsPsych.finishTrial(trial_data);\n });\n\n // Set 1st button functionality\n // ALPHA NEWS\n // This news generator will always agree with the user\n $('#alpha_news').click(function() {\n var position = 'for';\n if (!trial.responseFavour){\n position = 'against';\n }\n\n $('#alpha_disp').text(getHeadline(position));\n\n updateProgress();\n\n alphaNewsClicks.push((new Date()).getTime());\n });\n\n // Set 2nd button functionality\n // PREMIER NEWS\n // This news generator will always disagree with the user\n $('#premier_news').click(function() {\n var position = 'for'\n if (trial.responseFavour){\n position = 'against'\n }\n $('#premi_disp').text(getHeadline(position));\n\n updateProgress();\n\n premierNewsClicks.push((new Date()).getTime());\n })\n\n // Set 3rd button functionality\n // FIRST NEWS\n $('#first_news').click(function() {\n var position = 'for';\n if (Math.random() > 0.5){\n position = 'against';\n }\n $('#first_disp').text(getHeadline(position));\n\n updateProgress();\n\n firstNewsClicks.push((new Date()).getTime());\n firstForAgainst.push(position);\n })\n }", "title": "" }, { "docid": "db454f85a68f364444871c0d5e72baad", "score": "0.52577764", "text": "function handleNextButton() {\n \n $('#next-hidden').on('click', function () {\n fetch(nextJson)\n .then(nextPage => {\n if (nextPage.ok) {\n return nextPage.json();\n }\n throw new Error(nextPage.statusText);\n })\n .then(nextPageJson => radioResults(nextPageJson))\n .catch(err => {\n $('#js-error-message').text(`Sorry, something went wrong, check your internet connection or Try Again Later!: ${err.message}`);\n });\n });\n}", "title": "" }, { "docid": "35bba4feb6e57748867b1b128c43b0a0", "score": "0.5256568", "text": "function showButtons(index){\r\n\t\t\t\t\t\tif(options.buttonNavigation === true){\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t/**\r\n\t\t\t\t\t\t\t* Hide/show prev button.\r\n\t\t\t\t\t\t\t**/\r\n\t\t\t\t\t\t\tif(index == 0){\r\n\t\t\t\t\t\t\t\twizard.find('.e-wizard-prev').addClass('e-wizard-disabled');\t\t\r\n\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\twizard.find('.e-wizard-prev').removeClass('e-wizard-disabled');\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t/**\r\n\t\t\t\t\t\t\t* Hide/show next button.\r\n\t\t\t\t\t\t\t**/\r\n\t\t\t\t\t\t\tif((index + 1)== totalSteps){\r\n\t\t\t\t\t\t\t\twizard.find('.e-wizard-next').addClass('e-wizard-disabled');\t\r\n\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\twizard.find('.e-wizard-next').removeClass('e-wizard-disabled');\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}", "title": "" }, { "docid": "b55f79d32f7a75770592db2e5f1eb34b", "score": "0.52543896", "text": "function uvIndex(lon, lat) {\n\t// SEARCHES\n\tvar indexURL =\n\t\t\"https://api.openweathermap.org/data/2.5/uvi?appid=8c9bb7e0eeb10862d148cd62de471c05&lat=\";\n\tvar middle = \"&lon=\";\n\tvar indexSearch = indexURL + lat + middle + lon;\n\tconsole.log(indexSearch);\n\n\t$.ajax({\n\t\turl: indexSearch,\n\t\tmethod: \"GET\"\n\t}).then(function(response) {\n\t\tvar uvFinal = response.value;\n\n\t\t// should be able to compare float to the numbers, try it out\n\t\t// then append button with uvFinal printed to it\n\t\t$(\".uvIndex\").append(\"UV Index: \");\n\t\tvar uvBtn = $(\"<button>\").text(uvFinal);\n\t\t$(\".uvIndex\").append(uvBtn);\n\t\t// then style uvFinal button with below\n\t\tif (uvFinal < 3) {\n\t\t\t// IF RETURN IS 0-2 SYLE GREEN\n\t\t\tuvBtn.attr(\"class\", \"uvGreen\");\n\t\t} else if (uvFinal < 6) {\n\t\t\t// IF 3-5 STYLE YELLOW\n\t\t\tuvBtn.attr(\"class\", \"uvYellow\");\n\t\t} else if (uvFinal < 8) {\n\t\t\t// IF 6-7 STYLE ORANGE\n\t\t\tuvBtn.attr(\"class\", \"uvOrange\");\n\t\t} else if (uvFinal < 11) {\n\t\t\t// IF 8-10 STYLE RED\n\t\t\tuvBtn.attr(\"class\", \"uvRed\");\n\t\t} else {\n\t\t\t// IF 11+ STYLE VIOLET\n\t\t\tuvBtn.attr(\"class\", \"uvPurple\");\n\t\t}\n\t});\n}", "title": "" }, { "docid": "6cc4a81f45762809255b9c1caf318c56", "score": "0.5251718", "text": "function init_buttons() {\r\n var btnPro = document.getElementById(\"btn_pro\");\r\n var btnNone = document.getElementById(\"btn_none\");\r\n var btnContra = document.getElementById(\"btn_contra\");\r\n var btnSkip = document.getElementById(\"btn_skip\");\r\n\r\n /** Creating an onclick to send a request te re render the page with a new count */\r\n btnPro.onclick = function () {\r\n answerArray.splice(count, 1, { \"answer\": \"pro\" });\r\n prepareRender();\r\n }\r\n btnNone.onclick = function () {\r\n answerArray.splice(count, 1, { \"answer\": \"none\" });\r\n prepareRender();\r\n }\r\n btnContra.onclick = function () {\r\n answerArray.splice(count, 1, { \"answer\": \"contra\" });\r\n prepareRender();\r\n }\r\n btnSkip.onclick = function () {\r\n answerArray.splice(count, 1, { \"answer\": \"\"});\r\n prepareRender();\r\n }\r\n}", "title": "" }, { "docid": "4fa35299a4da9967abadb0d783b5275e", "score": "0.5247688", "text": "function handleNextClicked() {\n $('main').on('click', '#js-next', e => {\n render();\n })\n console.log('handleNextClicked ran')\n}", "title": "" }, { "docid": "7462d7589ba0c9f18947cfdd4dc5bb89", "score": "0.5237827", "text": "function actionOnNxtClick() {\r\n if (newCount < 0) {\r\n newCount = 0;\r\n }\r\n nextBtnCount();\r\n if (newCount < pageId.length) {\r\n document.getElementById(pageId[newCount]).style.top = 0 + '%';\r\n }\r\n crntIndexNum = newCount;\r\n }", "title": "" }, { "docid": "15982711643221d67cc4b238c6978b26", "score": "0.5236758", "text": "function file_upload_btn(index){\n file_upload_input[index].click();\n}", "title": "" }, { "docid": "e96b086c657d8c091509c80ae407fdc1", "score": "0.52365553", "text": "function vm_submitButton(pressbutton, frmName, pageName) {\n\tvm_submitForm(pressbutton, frmName, pageName);\n}", "title": "" }, { "docid": "a87c67c0808fb08bf89296678c8d6354", "score": "0.5236138", "text": "function processClick(param) {\n\n switch (param.element) {\n case \"조회\":\n {\n gw_com_api.hide(\"frmRoleID\");\n var args = { target: [{ id: \"frmOption\", focus: true }] };\n gw_com_module.objToggle(args);\n }\n break;\n case \"복사\":\n {\n closeOption({});\n if (!checkUpdatable({ check: true })) return;\n if (gw_com_api.getSelectedRow(\"grdData_권한\") == null) {\n gw_com_api.messageBox([{ text: \"NODATA\" }]);\n return;\n }\n gw_com_api.show(\"frmRoleID\");\n }\n break;\n case \"추가\":\n {\n v_global.process.handler = processInsert;\n if (!checkUpdatable({})) return;\n processInsert({});\n }\n break;\n case \"삭제\":\n {\n v_global.process.handler = processRemove;\n if (!checkManipulate({})) return;\n checkRemovable({});\n }\n break;\n case \"저장\":\n {\n closeOption({});\n processSave({});\n }\n break;\n case \"닫기\":\n {\n checkClosable({});\n }\n break;\n case \"실행\":\n {\n if (param.object == \"frmOption\") {\n v_global.process.handler = processRetrieve;\n if (!checkUpdatable({})) return;\n processRetrieve({});\n } else {\n var args = {\n target: [\n { type: \"FORM\", id: \"frmRoleID\" }\n ]\n };\n if (gw_com_module.objValidate(args) == false) return false;\n if (gw_com_api.getSelectedRow(\"grdData_권한\") == null) {\n gw_com_api.messageBox([{ text: \"NODATA\" }]);\n return;\n }\n processBatch({});\n }\n }\n break;\n default:\n {\n closeOption({});\n }\n break;\n }\n\n }", "title": "" }, { "docid": "5cef4c33fc6308e4c4bc31e86d6e0f1a", "score": "0.52337205", "text": "onClick(name, index) {\n if (this.linkFunction === undefined) return;\n // check if link function is defined\n var link = this.linkFunction(index);\n if (!(link === undefined)) {\n // go there\n window.location.href = $SCRIPT_ROOT + \"/\" + link;\n }\n }", "title": "" }, { "docid": "22b2b35a925fde39f90a63c3a8c5b57f", "score": "0.52302235", "text": "static _handlePageClick(elem) {\n elem.closest(\".rs-pager\").find(\"input:hidden:first\").val(elem.data(\"page\"));\n elem.closest(\"form\").submit();\n }", "title": "" }, { "docid": "195734d9fe4aeb552d3ee710d42a47b0", "score": "0.5227349", "text": "function initButtons() {\n\t\t\t\t\t$(\".show-first-resources\").click(function(event) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tinstance.manager.changeStart(0);\n\t\t\t\t\t});\n\t\t\t\t\t$(\".show-last-resources\").click(function(event) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tinstance.manager.showLastPage();\n\t\t\t\t\t});\n\t\t\t\t}", "title": "" }, { "docid": "36ae3e046a968ac1135cbf2f6085ba10", "score": "0.5223701", "text": "function createButtons() {\n\n autoClick('#addClassA', '아리아');\n\n autoClick('#addClassD', '동작없음');\n\n for(var i = 1; i <= no;i++){\n autoClick('#'+btnName+''+i, tag[i]);\n }\n\n\n\n // Predict button\n buttonPredict = select('#buttonPredict');\n buttonPredict.mousePressed(classify);\n\n // Clear all classes button\n buttonClearAll = select('#clearAll');\n buttonClearAll.mousePressed(clearAllLabels);\n\n buttonGetData = select('#save');\n buttonGetData.mousePressed(saveMyKNN);\n}", "title": "" }, { "docid": "bb9b01b77da2100e42a8bc4e06cca578", "score": "0.5222514", "text": "function handleOnButtonClick(asBtn) {\r\n switch (asBtn) {\r\n case 'SAVE':\r\n submitSave(\"saveAllTailQuote\");\r\n break;\r\n }\r\n}", "title": "" } ]
68c7bd30feb59c43a5fa7905caf7717e
Create a valid object from passed info for TryUploadSubtitles
[ { "docid": "8a1873147e96b7afd947cc346ff36920", "score": "0.49506572", "text": "createTryData(input) {\r\n\r\n const checkMovie = (obj = Object()) => {\r\n if (!input.path) return Promise.resolve(obj)\r\n\r\n return libhash.computeHash(input.path).then(response => {\r\n obj = response // moviebytesize + moviehash\r\n obj.moviefilename = path.basename(input.path)\r\n return obj\r\n })\r\n }\r\n\r\n const checkSub = (obj = Object()) => {\r\n if (!input.subpath) return Promise.reject('Missing subpath parameter (path to subtitle file)')\r\n\r\n return libhash.computeMD5(input.subpath).then(md5 => {\r\n obj.subhash = md5\r\n obj.subfilename = path.basename(input.subpath)\r\n return obj\r\n })\r\n }\r\n\r\n const injectInput = (obj = Object()) => {\r\n if (input.imdbid) obj.idmovieimdb = input.imdbid.toString().replace('tt', '')\r\n if (input.sublanguageid) obj.sublanguageid = input.sublanguageid\r\n if (input.moviefps) obj.moviefps = input.moviefps.toString()\r\n if (input.movieframes) obj.movieframes = input.movieframes.toString()\r\n if (input.movietimems) obj.movietimems = input.movietimems.toString()\r\n if (input.subauthorcomment) obj.subauthorcomment = input.subauthorcomment\r\n if (input.subtranslator) obj.subtranslator = input.subtranslator\r\n if (input.moviereleasename) obj.moviereleasename = input.moviereleasename\r\n if (input.movieaka) obj.movieaka = input.movieaka\r\n if (input.hearingimpaired) obj.hearingimpaired = isNaN(parseInt(input.hearingimpaired)) ? input.hearingimpaired ? '1' : '0' : input.hearingimpaired.toString()\r\n if (input.highdefinition) obj.highdefinition = isNaN(parseInt(input.highdefinition)) ? input.highdefinition ? '1' : '0' : input.highdefinition.toString()\r\n if (input.automatictranslation) obj.automatictranslation = isNaN(parseInt(input.automatictranslation)) ? input.automatictranslation ? '1' : '0' : input.automatictranslation.toString()\r\n if (input.foreignpartsonly) obj.foreignpartsonly = isNaN(parseInt(input.foreignpartsonly)) ? input.foreignpartsonly ? '1' : '0' : input.foreignpartsonly.toString()\r\n\r\n return obj\r\n }\r\n\r\n // mandatory: subhash (md5 of subtitles), subfilename, moviehash, moviebytesize, moviefilename\r\n return checkMovie()\r\n .then(checkSub)\r\n .then(injectInput)\r\n .then(data => ({cd1: data}))\r\n }", "title": "" } ]
[ { "docid": "9af25412eb76d85b76c5d71a655720a7", "score": "0.56467813", "text": "static initialize(obj, file, thumbnail, title, description, subjectId) { \n obj['file'] = file;\n obj['thumbnail'] = thumbnail;\n obj['title'] = title;\n obj['description'] = description;\n obj['subject_id'] = subjectId;\n }", "title": "" }, { "docid": "d0ba5c5d15bde94f3667c89dc6e483a8", "score": "0.5589064", "text": "arrangeUploadData(input) {\r\n let baseinfo = Object()\r\n\r\n if (input.idmovieimdb) baseinfo.idmovieimdb = input.idmovieimdb.toString()\r\n if (input.moviereleasename) baseinfo.moviereleasename = input.moviereleasename.toString()\r\n if (input.movieaka) baseinfo.movieaka = input.movieaka.toString()\r\n if (input.sublanguageid) baseinfo.sublanguageid = input.sublanguageid.toString()\r\n if (input.subauthorcomment) baseinfo.subauthorcomment = input.subauthorcomment.toString()\r\n if (input.hearingimpaired) baseinfo.hearingimpaired = input.hearingimpaired.toString()\r\n if (input.highdefinition) baseinfo.highdefinition = input.highdefinition.toString()\r\n if (input.automatictranslation) baseinfo.automatictranslation = input.automatictranslation.toString()\r\n if (input.subtranslator) baseinfo.subtranslator = input.subtranslator.toString()\r\n if (input.foreignpartsonly) baseinfo.foreignpartsonly = input.foreignpartsonly.toString()\r\n\r\n let cd1 = {\r\n subhash: input.subhash,\r\n subfilename: input.subfilename,\r\n subcontent: input.subcontent\r\n }\r\n\r\n if (input.moviebytesize) cd1.moviebytesize = input.moviebytesize.toString()\r\n if (input.moviehash) cd1.moviehash = input.moviehash\r\n if (input.moviefilename) cd1.moviefilename = input.moviefilename\r\n if (input.moviefps) cd1.moviefps = input.moviefps\r\n if (input.movieframes) cd1.movieframes = input.movieframes.toString()\r\n if (input.movietimems) cd1.movietimems = input.movietimems.toString()\r\n\r\n return {\r\n baseinfo: baseinfo,\r\n cd1: cd1\r\n }\r\n }", "title": "" }, { "docid": "8d0299c03db7c25c766362ace97fb1c0", "score": "0.5212622", "text": "function buildSongObj() {\n let songObj = {\n title: $(\"#form--title\").val(),\n artist: $(\"#form--artist\").val(),\n album: $(\"#form--album\").val(),\n year: $(\"#form--year\").val()\n };\n return songObj;\n}", "title": "" }, { "docid": "d9abc8a509dc6101b5f6bfdc59788183", "score": "0.52012354", "text": "function uploadSubs (subsArray, callback) {\n // Collect data to upload\n var data = new window.FormData();\n for (var i = 0; i < subsArray.length; i++) {\n var subs = subsArray[i];\n\n // Only upload subs if it needs it\n if(subs.asBlob){\n data.append(subs.subtitleId.toString(), subs.asBlob, subs.subFileName);\n }\n }\n\n var url = Settings.fleexApiEndpoint + 'Subtitles/UploadSubtitles';\n $.ajax({\n type : 'POST',\n url : url,\n data : data,\n //Options to tell JQuery not to process data or worry about content-type\n cache: false,\n contentType: false,\n processData: false\n }).complete(function(){\n if(typeof callback === 'function'){ return callback(); }\n });\n }", "title": "" }, { "docid": "77f5d17a1928cfec7a8f8d8f4d423fca", "score": "0.51801664", "text": "constructor(image_url, title, sub_title, url) {\n this.image_url = image_url\n this.title = title\n this.sub_title = sub_title\n this.url = url\n }", "title": "" }, { "docid": "3e29d0c04e4cdc04c146fdead7cd4bbf", "score": "0.51192147", "text": "function Subtitle(srt, Player, target) {\n\t var _this = this;\n\t\n\t _classCallCheck(this, Subtitle);\n\t\n\t this.Player = Player;\n\t this.srt = srt;\n\t this.target = document.querySelector(target);\n\t _logger2.default.addLog('Player - Subtitle', 'create', 'Subtitle initialization started', this);\n\t this.setSRT(srt);\n\t this.Player.Events.addListener('player_onTimeUpdate', function () {\n\t return _this.tick();\n\t });\n\t this.Player.Events.addListener('player_onEnded', function () {\n\t return _this.target.innerText = '';\n\t });\n\t }", "title": "" }, { "docid": "4db0c114538027194ee09a33ce5e95ee", "score": "0.5100618", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x88bf9319;\n this.SUBCLASS_OF_ID = 0x80a4a3de;\n\n this.id = args.id;\n this.type = args.type;\n this.title = args.title || null;\n this.description = args.description || null;\n this.url = args.url || null;\n this.thumb = args.thumb || null;\n this.content = args.content || null;\n this.sendMessage = args.sendMessage;\n }", "title": "" }, { "docid": "580664493b122c9ff0871ed90e4fb361", "score": "0.5100461", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x11965f3a;\n this.SUBCLASS_OF_ID = 0x3832b3d5;\n\n this.id = args.id;\n this.type = args.type;\n this.title = args.title || null;\n this.description = args.description || null;\n this.url = args.url || null;\n this.thumb = args.thumb || null;\n this.content = args.content || null;\n this.sendMessage = args.sendMessage;\n }", "title": "" }, { "docid": "85b822b774f8f8740e90486d07b902d9", "score": "0.50731677", "text": "constructor(songTitle, artistName, year) {\n console.log(\"Creating a new Song...\", songTitle);\n // \"this\" is the generic name you use to REFER TO THE OBJECT\n this.title = songTitle;\n this.artist = artistName;\n this.releaseYear = year;\n }", "title": "" }, { "docid": "b19ae72fa95601ccbd9c940b02017607", "score": "0.5069812", "text": "static initialize(obj, body, id, title) { \n obj['body'] = body;\n obj['id'] = id;\n obj['title'] = title;\n }", "title": "" }, { "docid": "73eb7c0f23a18d4e101c5713f215f953", "score": "0.5040923", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xfa64e172;\n this.SUBCLASS_OF_ID = 0x55a97481;\n\n this.id = args.id;\n this.url = args.url;\n this.displayUrl = args.displayUrl;\n this.hash = args.hash;\n this.type = args.type || null;\n this.siteName = args.siteName || null;\n this.title = args.title || null;\n this.description = args.description || null;\n this.photo = args.photo || null;\n this.embedUrl = args.embedUrl || null;\n this.embedType = args.embedType || null;\n this.embedWidth = args.embedWidth || null;\n this.embedHeight = args.embedHeight || null;\n this.duration = args.duration || null;\n this.author = args.author || null;\n this.document = args.document || null;\n this.documents = args.documents || null;\n this.cachedPage = args.cachedPage || null;\n }", "title": "" }, { "docid": "ccf140c584e16eb87d94ea956c7dfa5b", "score": "0.50287", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x5b38c6c1;\n this.SUBCLASS_OF_ID = 0xfaf846f4;\n\n this.nosoundVideo = args.nosoundVideo || null;\n this.file = args.file;\n this.thumb = args.thumb || null;\n this.mimeType = args.mimeType;\n this.attributes = args.attributes;\n this.stickers = args.stickers || null;\n this.ttlSeconds = args.ttlSeconds || null;\n }", "title": "" }, { "docid": "659307406123220f00d82a6b2e2e9f59", "score": "0.5025252", "text": "constructor(obj) {\r\n this.id = obj.id;\r\n this.lastModified = obj.lastModified;\r\n this.created = obj.created;\r\n this.favourite = obj.favourite;\r\n this.deleted = obj.deleted;\r\n this.title = obj.title;\r\n this.tags = obj.tags;\r\n this.template = obj.template;\r\n this.content = obj.content;\r\n }", "title": "" }, { "docid": "5c000d5df1970f27caef60776f55d676", "score": "0.5005686", "text": "function createStreamerObject(streamInfo) {\n \n let streamerObject = {\n name: streamInfo.channel.display_name,\n title: streamInfo.channel.status,\n game: streamInfo.channel.game,\n avatar: streamInfo.channel.logo,\n url: streamInfo.channel.url,\n isLive: true,\n startTime: new Date()\n };\n\n return streamerObject;\n}", "title": "" }, { "docid": "d0f2b4e7a862ab755f3c50f0fb6facd4", "score": "0.49985412", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x17db940b;\n this.SUBCLASS_OF_ID = 0x3832b3d5;\n\n this.id = args.id;\n this.type = args.type;\n this.photo = args.photo || null;\n this.document = args.document || null;\n this.title = args.title || null;\n this.description = args.description || null;\n this.sendMessage = args.sendMessage;\n }", "title": "" }, { "docid": "582889f1dcb64c876422dcd35662fad4", "score": "0.49955267", "text": "static initialize(obj, id, videoId, score, name, duration, language, publicationDate, views, uploader, scorePreferencesTerm, scoreSearchTerm, ratingNExperts, ratingNRatings, nReports, publicExperts, nPublicExperts, nPrivateExperts, paretoOptimal, reliability, importance, engaging, pedagogy, laymanFriendly, diversityInclusion, backfireRisk, betterHabits, entertainingRelaxing) { \n obj['id'] = id;\n obj['video_id'] = videoId;\n obj['score'] = score;\n obj['name'] = name;\n obj['duration'] = duration;\n obj['language'] = language;\n obj['publication_date'] = publicationDate;\n obj['views'] = views;\n obj['uploader'] = uploader;\n obj['score_preferences_term'] = scorePreferencesTerm;\n obj['score_search_term'] = scoreSearchTerm;\n obj['rating_n_experts'] = ratingNExperts;\n obj['rating_n_ratings'] = ratingNRatings;\n obj['n_reports'] = nReports;\n obj['public_experts'] = publicExperts;\n obj['n_public_experts'] = nPublicExperts;\n obj['n_private_experts'] = nPrivateExperts;\n obj['pareto_optimal'] = paretoOptimal;\n obj['reliability'] = reliability;\n obj['importance'] = importance;\n obj['engaging'] = engaging;\n obj['pedagogy'] = pedagogy;\n obj['layman_friendly'] = laymanFriendly;\n obj['diversity_inclusion'] = diversityInclusion;\n obj['backfire_risk'] = backfireRisk;\n obj['better_habits'] = betterHabits;\n obj['entertaining_relaxing'] = entertainingRelaxing;\n }", "title": "" }, { "docid": "407347425488edcda506d2d8f140069c", "score": "0.49563125", "text": "function createMediaObject(streamData) {\r\n\t\t\tvar newStream = {};\r\n\t\t\tvar num = streamData.formats.length;\r\n\t\t\tnewStream.title = streamData.title;\r\n\t\t\tfor (var i=0; i<num; i++) {\r\n\t\t\t\tnewStream[streamData.formats[i].format] = streamData.formats[i].url;\r\n\t\t\t}\r\n\t\t\tif (streamData.description) {\r\n\t\t\t\tnewStream.description = streamData.description;\r\n\t\t\t}\r\n\t\t\tif (self.options.showPosters && streamData.poster) {\r\n\t\t\t\tnewStream.poster = streamData.poster;\r\n\t\t\t}\r\n\t\t\tnewStream.siteurl = streamData.siteurl;\r\n\t\t\treturn newStream;\r\n\t\t}", "title": "" }, { "docid": "97f92c6a7ab2d4bb89786a528c4e6baf", "score": "0.49541506", "text": "async create (req, res) {\n try {\n if (typeof req.user === 'undefined' || req.user === null) {\n throw new Error('You are not connected')\n }\n await Playlist.belongToUser(req.body.playlistId, req.user.userId)\n const getYoutubeMetadata = require('youtube-metadata-cli')\n await getYoutubeMetadata(req.body.videoUrl)\n .on('error', function (err) {\n return res.status(400).send({\n error: err.message\n })\n })\n .on('data', (meta) => {\n console.log('\\n FORMAT : \\n', meta.requested_formats[1].url)\n const createStruct = {\n videoYoutubeId: meta.id,\n videoName: meta.title,\n videoThumbnail: meta.thumbnail,\n videoUploaderUrl: meta.uploader_url,\n // videoAudioLink: meta.requested_formats[1].url,\n PlaylistPlaylistId: req.body.playlistId\n }\n CRUDController.create(req, res, Video, createStruct)\n })\n } catch (err) {\n // 401 Unauthorized\n return res.status(401).send({\n error: err.message\n })\n }\n }", "title": "" }, { "docid": "327898a6be279a27d0142f58a23a5a55", "score": "0.49322623", "text": "static initialize(obj, title, createdBy, isLocked, tagsAsCsv) { \n obj['title'] = title;\n obj['createdBy'] = createdBy;\n obj['isLocked'] = isLocked;\n obj['tagsAsCsv'] = tagsAsCsv;\n }", "title": "" }, { "docid": "2fee7b8e9d079f5aab0610f6c077f854", "score": "0.492357", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xbdf9653b;\n this.SUBCLASS_OF_ID = 0x83199eb2;\n\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.shortName = args.shortName;\n this.title = args.title;\n this.description = args.description;\n this.photo = args.photo;\n this.document = args.document || null;\n }", "title": "" }, { "docid": "0acb01a434562d6d7af88cfcd8f8314b", "score": "0.49198934", "text": "function getSubtitlesFromWeb(urlSubtitles, lang) {\r\n var axios = require('axios');\r\n var config = {\r\n method: 'get',\r\n url: urlSubtitles,\r\n headers: {}\r\n };\r\n return axios(config)\r\n .then(function (response) {\r\n // convert subtitles name into hash\r\n let hashUrl = hashFunction(urlSubtitles);\r\n console.log(hashUrl);\r\n const info = new Info({\r\n hashUrl: hashUrl,\r\n subtitles: response.data,\r\n urlPose: urlSubtitles,\r\n sentences: helper.createSentenses(response.data)\r\n });\r\n // save to db\r\n info.save()\r\n .then((result) => {\r\n getPoseFromPythonServer(urlSubtitles, lang, hashUrl);\r\n\r\n console.log('saved!');\r\n\r\n return result;\r\n });\r\n // get from server the pose and save it to file system in university\r\n })\r\n}", "title": "" }, { "docid": "ef3d4b28ce5763576895e775ee0a3e13", "score": "0.4907631", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x87eabb53;\n this.SUBCLASS_OF_ID = 0xc47f1bd1;\n\n this.video = args.video || null;\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.date = args.date;\n this.adminId = args.adminId;\n this.participantId = args.participantId;\n this.gAHash = args.gAHash;\n this.protocol = args.protocol;\n }", "title": "" }, { "docid": "c3761b972c35d09610e985756cfae6a3", "score": "0.49025822", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x16115a96;\n this.SUBCLASS_OF_ID = 0x1aca5644;\n\n this.title = args.title;\n this.articles = args.articles;\n }", "title": "" }, { "docid": "a15e5133aadcad9fedd0cf45dc0cc48f", "score": "0.48936382", "text": "constructor(data) {\n this.title = data.title\n this.chore = data.chore || []\n }", "title": "" }, { "docid": "724e46bea06ce12a87e0d44fd018d6f5", "score": "0.48901713", "text": "static initialize(obj, type, mediaUrl) { \n obj['type'] = type;\n obj['mediaUrl'] = mediaUrl;\n }", "title": "" }, { "docid": "69b668e98d1f6557f4fa45bf855b933f", "score": "0.4886864", "text": "static initialize(obj, applicationIds, title, name, description, mimeType, handler, version) { \n obj['applicationIds'] = applicationIds;\n obj['title'] = title;\n obj['name'] = name;\n obj['description'] = description;\n obj['mimeType'] = mimeType;\n obj['handler'] = handler;\n obj['version'] = version;\n }", "title": "" }, { "docid": "a81396bb90664c5fe9c603c7a8d2f8bc", "score": "0.48867857", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x1b8f4ad1;\n this.SUBCLASS_OF_ID = 0xc47f1bd1;\n\n this.video = args.video || null;\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.date = args.date;\n this.adminId = args.adminId;\n this.participantId = args.participantId;\n this.protocol = args.protocol;\n this.receiveDate = args.receiveDate || null;\n }", "title": "" }, { "docid": "6f7b2e4a83559ac6a021866c58c200f6", "score": "0.48859492", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x997c454a;\n this.SUBCLASS_OF_ID = 0xc47f1bd1;\n\n this.video = args.video || null;\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.date = args.date;\n this.adminId = args.adminId;\n this.participantId = args.participantId;\n this.gB = args.gB;\n this.protocol = args.protocol;\n }", "title": "" }, { "docid": "b9273ef58d8c38c13f399060eaf9734b", "score": "0.48827845", "text": "handleAdd(image,name,title,link){\n this.props.addTrackToPlaylist(spotifyApi,[link],this.props.playlist.id);\n // Assigning the track to a variable so it can be shown\n let newObj = {};\n let songObj = {};\n newObj = Object.assign({},newObj,{\n image:image,\n name:name,\n title:title,\n uri:link,\n })\n newItems.push(newObj);\n songs = newItems;\n songObj = Object.assign({},songObj,{\n items:newItems\n })\n songs = songObj\n }", "title": "" }, { "docid": "1c23d8e9d1dae4b35449de6817f28bf4", "score": "0.487347", "text": "function updatePlaylist(obj , artistName , songTitle)\n{\n obj[artistName] = songTitle;\n return obj;\n}", "title": "" }, { "docid": "a165e74131f337953856d9ecd2450c6d", "score": "0.4866952", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x9852f9c6;\n this.SUBCLASS_OF_ID = 0xf729eb9b;\n\n this.voice = args.voice || null;\n this.duration = args.duration;\n this.title = args.title || null;\n this.performer = args.performer || null;\n this.waveform = args.waveform || null;\n }", "title": "" }, { "docid": "0085259c408a4252b450f6d703cb6a01", "score": "0.48665598", "text": "function preProcessServerCreateObject(obj) {\n\tdebugObject(\"preProcessServerCreateObject() obj=\", obj);\n\t\n\tswitch (obj.objType) {\n\tcase QUESTIONNAIRE_OBJECT:\n\t\tpersistentState.questionnaire = obj;\n\t\t// Questionnaire is always at the top of the hierarchy.\n\t\tpersistentState.hierarchy[obj.id] = new HierarchyObject(null, 0, 0, false);\n\t\ttemporaryState.newQuestionnaire = true;\n\t\ttemporaryState.questionnaireChanged = true;\n\t\ttemporaryState.items[obj.id] = obj;\n\t\tbreak;\n\tcase GROUP_OBJECT:\n\t\ttemporaryState.groups.push(obj);\n\t\ttemporaryState.items[obj.id] = obj;\n\t\tbreak;\n\tcase QUESTION_OBJECT:\n\t\ttemporaryState.items[obj.id] = obj;\n\t\tbreak;\n\tcase NOTE_OBJECT:\n\t\ttemporaryState.items[obj.id] = obj;\n\t\tbreak;\n\tcase ERROR_OBJECT:\n\t\tbreak;\n\tdefault:\n\t\thandleError(ERROR_TYPES.INTERNAL, [ \"invalid object type: \" + obj.objType ],\n\t\t\t\t\"dynamicUI_interface.preProcessServerCreateObject\", objectToString(obj));\n\t}\n}", "title": "" }, { "docid": "9fca23d03bf490fdd7c776571ed56281", "score": "0.48498848", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xfff8fdc4;\n this.SUBCLASS_OF_ID = 0x80a4a3de;\n\n this.id = args.id;\n this.type = args.type;\n this.title = args.title || null;\n this.description = args.description || null;\n this.document = args.document;\n this.sendMessage = args.sendMessage;\n }", "title": "" }, { "docid": "ecd4d5d097fe75e957a22fc08d44069d", "score": "0.4842435", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xae891bec;\n this.SUBCLASS_OF_ID = 0xb438191e;\n\n this.part = args.part || null;\n this.rtl = args.rtl || null;\n this.v2 = args.v2 || null;\n this.url = args.url;\n this.blocks = args.blocks;\n this.photos = args.photos;\n this.documents = args.documents;\n }", "title": "" }, { "docid": "7bc8bbf2333015cfeefc10d1984b659b", "score": "0.48132455", "text": "static initialize(obj, title, source) { \n obj['title'] = title;\n obj['source'] = source;\n }", "title": "" }, { "docid": "0ef531e2d5e8dd28fc2207d30b1646b9", "score": "0.47944745", "text": "function Song(song){\n this.title = song.title;\n this.tags = song.tags.split(',').map(function(tag){return tag.trim();});\n this.tags = _.compact(this.tags);\n this.albumId = song.albumId || '';\n}", "title": "" }, { "docid": "fb3bd94f536d05a2c442a161fb8222e4", "score": "0.4775111", "text": "static initialize(obj, user, video, comment, username, anonymizedUsernameId, datetimeLastedit, datetimeAdd, votesPlus, votesMinus, redFlags, id, children, datetimeAddAgo, editedMAddedS) { \n obj['user'] = user;\n obj['video'] = video;\n obj['comment'] = comment;\n obj['username'] = username;\n obj['anonymized_username_id'] = anonymizedUsernameId;\n obj['datetime_lastedit'] = datetimeLastedit;\n obj['datetime_add'] = datetimeAdd;\n obj['votes_plus'] = votesPlus;\n obj['votes_minus'] = votesMinus;\n obj['red_flags'] = redFlags;\n obj['id'] = id;\n obj['children'] = children;\n obj['datetime_add_ago'] = datetimeAddAgo;\n obj['edited_m_added_s'] = editedMAddedS;\n }", "title": "" }, { "docid": "cf27c28e2bbfa1fe4336a6cf65be7b35", "score": "0.47725296", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xdfc2f58e;\n this.SUBCLASS_OF_ID = 0x4561736;\n\n this.channel = args.channel || null;\n this.broadcast = args.broadcast || null;\n this.public = args.public || null;\n this.megagroup = args.megagroup || null;\n this.title = args.title;\n this.photo = args.photo;\n this.participantsCount = args.participantsCount;\n this.participants = args.participants || null;\n }", "title": "" }, { "docid": "8979ad22dafb2fdaa82bcbf32e2c5487", "score": "0.47578222", "text": "gatherInfo(info, content) {\n info.spotify_artist_id = content.artists ? content.artists[0].id : content.id;\n info.spotify_album_id = content.album ? content.album.id : content.id;\n info.spotify_song_id = content.id;\n info.spotify_artist_url = content.artists ? content.artists[0].external_urls.spotify : content.external_urls.spotify;\n info.spotify_album_url = content.album ? content.album.external_urls.spotify : content.external_urls.spotify;\n info.spotify_song_url = content.external_urls.spotify;\n info.artist_image = content.artists ? null : module.exports.selectImage(content.images); // we'll need to ge the image some other way.\n info.album_image = module.exports.selectImage(content.album ? content.album.images : content.images);\n info.song_image = info.album_image;\n return info;\n }", "title": "" }, { "docid": "7bbaaf2d60ff0677ad592c2e258e755d", "score": "0.4748311", "text": "formatSCData(track, data, featured, genre) {\n track.artist = data.user.username\n track.artwork_url = data.artwork_url\n track.artwork_url_midres = data.artwork_url ? data.artwork_url.replace('large','t200x200') : ''\n track.artwork_url_hires = data.artwork_url ? data.artwork_url.replace('large','t500x500') : ''\n track.duration = data.duration\n track.featured = featured\n track.genre = genre\n track.kind = 'sc'\n track.likes = 0\n track.permalink = data.permalink_url\n track.tag_list = data.tag_list\n track.timestamp = 0 - Date.now()\n track.title = data.title\n return track\n }", "title": "" }, { "docid": "94b834b604494fc2d09f86a24e720dbb", "score": "0.47400564", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xa6638b9a;\n this.SUBCLASS_OF_ID = 0x8680d126;\n\n this.title = args.title;\n this.users = args.users;\n }", "title": "" }, { "docid": "922e70c23ec74a43dd12c36738157d59", "score": "0.47269577", "text": "function subtitle(titleinfo) /* (titleinfo : titleinfo) -> string */ {\n return titleinfo.subtitle;\n}", "title": "" }, { "docid": "284fe4546706772561f6a764a1fce6b6", "score": "0.47215724", "text": "static parse(body) {\n var post = new Object();\n post.postId = body.postId;\n post.title = body.title;\n post.author = body.author;\n post.published_on = body.published_on;\n post.issue = Number(body.issue);\n post.content = body.content;\n post.category = body.category;\n post.staging = (body.staging) ? true : false;\n post.thumbnail_credit = body.thumbnail_credit;\n post.postStyle = body.postStyle;\n var error = '';\n error += Posts.validate(post.postId, 'string');\n error += Posts.validate(post.title, 'string');\n error += Posts.validate(post.author, 'string');\n error += Posts.validate(post.published_on, 'string');\n error += Posts.validate(post.content, 'string');\n error += Posts.validate(post.category, 'string');\n error += Posts.validate(post.thumbnail_credit, 'string');\n if (error) {\n console.error(error);\n return null;\n }\n return post;\n }", "title": "" }, { "docid": "b66aa14dbb7a6b84771679489dfd8361", "score": "0.47181615", "text": "constructor(data){\n\n if(data == null){\n return;\n }\n\n this._albumId = data.albumId;\n this._id = data.id;\n this.caption = data.title;\n this.photo = data.url;\n this.thumb = data.url;\n this.selected = false;\n }", "title": "" }, { "docid": "29f86a57aeb1b3a175e8bcb22cacba61", "score": "0.4712729", "text": "function loadSubtitles(subtitlesURL, isLocalFile, encoding) {\n /* Hide any previously uploaded subtitles */\n $('.subtitles').css(\"display\", \"block\");\n\n /* Initialize new bubbles instance */\n if (!subBubblesVideo) {\n subBubblesVideo = new Bubbles.video('sub-video');\n registerKeyboardListeners();\n }\n var data = {\n \"English\": {\n language: \"English\",\n file: subtitlesURL,\n encoding: encoding,\n isLocalFile: isLocalFile\n }\n };\n\n subBubblesVideo.subtitles(false, data);\n\n $('#sub-info').css(\"opacity\", 1);\n console.log(srt_text)\n if (cond.length<50)\n {\n$(\"#sub-message\").html(\"Oops, We were unable to find the subtitle file. r However , yo can refresh the page to try again.\");\n }\n else{\n $(\"#sub-message\").html(\"Subtitle added. Enjoy!!! <br> Hit space bar or click on subtitle to pause/resume the video.\"+ shortcutsMessage);\n}\n // $(\"#sub-message\").fadeOut(3000);\n\n getFontSizeFromLocalStorage();\n}", "title": "" }, { "docid": "675fe47ee4dd01721d32a465f3ca71a7", "score": "0.4707976", "text": "constructor(title, type) {\n this.title = title;\n this.type = type;\n }", "title": "" }, { "docid": "77b8d720d886567042d7433795f56709", "score": "0.47050604", "text": "static initialize(obj, name, photoUrls) { \n obj['name'] = name;\n obj['photoUrls'] = photoUrls;\n }", "title": "" }, { "docid": "77b8d720d886567042d7433795f56709", "score": "0.47050604", "text": "static initialize(obj, name, photoUrls) { \n obj['name'] = name;\n obj['photoUrls'] = photoUrls;\n }", "title": "" }, { "docid": "1a2911a27c5617c3b01aa43e852ad50d", "score": "0.4696257", "text": "function objFromSaveFormat(objectInArray) {\n var objectInTree = {id: objectInArray.id, name: objectInArray.name};\n if (objectInArray.type == \"folder\") {\n objectInTree.children = [];\n } else if (objectInArray.content != undefined) {\n objectInTree.content = objectInArray.content;\n }\n return objectInTree;\n }", "title": "" }, { "docid": "7b7d7265a977a679443c2e74eabc8645", "score": "0.4689884", "text": "async function uploadUnique(nam, o) {\n var o = o||{};\n if(o.log) console.log('-uploadUnique:', nam);\n var qry = OPTIONS.youtube.title.replace(/\\$\\{title\\}/g, nam);\n var ids = await youtubeuploader.lines({title: qry});\n if(ids.length) {\n if(o.log) console.log(' .already exists:', ids);\n return 2;\n }\n try { await wikipediaTts(null, nam, o); }\n catch(e) {\n console.error(e);\n return e.message==='No article found'? -2:-4;\n }\n return 4;\n}", "title": "" }, { "docid": "d57ab1e5499777fb62096eeec60f07cd", "score": "0.46894252", "text": "static initialize(obj, id, modelTypeId, title) { \n obj['id'] = id;\n obj['model_type_id'] = modelTypeId;\n obj['title'] = title;\n }", "title": "" }, { "docid": "d4aa10354f263385cd922729809a3087", "score": "0.46880478", "text": "constructor(data) {\n this.title = data.title\n this.todo = data.todo || []\n\n }", "title": "" }, { "docid": "b39fe0842d18863749066b03b7fb6493", "score": "0.4679996", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xb390dc08;\n this.SUBCLASS_OF_ID = 0x36d05822;\n\n this.url = args.url;\n this.webpageId = args.webpageId;\n this.title = args.title || null;\n this.description = args.description || null;\n this.photoId = args.photoId || null;\n this.author = args.author || null;\n this.publishedDate = args.publishedDate || null;\n }", "title": "" }, { "docid": "68c891905077dc7b2c73713ad84eaf82", "score": "0.46756685", "text": "create({ title, description }) {\n const id = uuidv4();\n\n const object = {\n id,\n title,\n description\n };\n\n this.data[id] = (object);\n return Promise.resolve(object);\n }", "title": "" }, { "docid": "4b390bddfc8d160b79e725624b28be76", "score": "0.46752703", "text": "function createSensorSubscriptionObject(topicname, messagetype, subtopicnames)\n{\n return {\n TopicName: topicname,\n MessageType: messagetype,\n SubTopicNames: subtopicnames\n };\n}", "title": "" }, { "docid": "80137d281142f068d07003640158c5a9", "score": "0.46707538", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x1759c560;\n this.SUBCLASS_OF_ID = 0x1aca5644;\n\n this.photoId = args.photoId;\n this.caption = args.caption;\n this.url = args.url || null;\n this.webpageId = args.webpageId || null;\n }", "title": "" }, { "docid": "00c3f11f081e786bb47cbcac22db01c7", "score": "0.4667962", "text": "function Song(id, cover, title, username, userAvatar, streamLink)\n\t{\n\t\tthis.id \t\t= id;\n\t\tthis.cover \t\t= cover;\n\t\tthis.title \t\t= title;\n\t\tthis.username \t= username;\n\t\tthis.userAvatar = userAvatar;\n\t\tthis.streamLink = streamLink;\n\t}", "title": "" }, { "docid": "d75583d7d030cdf3630d2472e4bebaf4", "score": "0.4654167", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xf4e096c3;\n this.SUBCLASS_OF_ID = 0xfaf846f4;\n\n this.title = args.title;\n this.description = args.description;\n this.photo = args.photo || null;\n this.invoice = args.invoice;\n this.payload = args.payload;\n this.provider = args.provider;\n this.providerData = args.providerData;\n this.startParam = args.startParam;\n }", "title": "" }, { "docid": "f005adf372f4971a9c45e6241358a240", "score": "0.46541023", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xf7d90ce0;\n this.SUBCLASS_OF_ID = 0x56b4c80c;\n\n this.creator = args.creator || null;\n this.default = args.default || null;\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.slug = args.slug;\n this.title = args.title;\n this.document = args.document || null;\n this.installsCount = args.installsCount;\n }", "title": "" }, { "docid": "c412fa7e69f570d49b585b92bb6cf6d3", "score": "0.46455878", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x9bed434d;\n this.SUBCLASS_OF_ID = 0x8ae8b146;\n\n this.url = args.url;\n this.size = args.size;\n this.mimeType = args.mimeType;\n this.attributes = args.attributes;\n }", "title": "" }, { "docid": "16d78135f493504f71e83abdae8ea5be", "score": "0.46386296", "text": "function createSpeechObject(optionsParam) {\n if (optionsParam && optionsParam.type === 'SSML') {\n return {\n type: optionsParam.type,\n ssml: optionsParam['speech']\n };\n } else {\n return {\n type: optionsParam.type || 'PlainText',\n text: optionsParam['speech'] || optionsParam\n };\n }\n}", "title": "" }, { "docid": "16d78135f493504f71e83abdae8ea5be", "score": "0.46386296", "text": "function createSpeechObject(optionsParam) {\n if (optionsParam && optionsParam.type === 'SSML') {\n return {\n type: optionsParam.type,\n ssml: optionsParam['speech']\n };\n } else {\n return {\n type: optionsParam.type || 'PlainText',\n text: optionsParam['speech'] || optionsParam\n };\n }\n}", "title": "" }, { "docid": "16d78135f493504f71e83abdae8ea5be", "score": "0.46386296", "text": "function createSpeechObject(optionsParam) {\n if (optionsParam && optionsParam.type === 'SSML') {\n return {\n type: optionsParam.type,\n ssml: optionsParam['speech']\n };\n } else {\n return {\n type: optionsParam.type || 'PlainText',\n text: optionsParam['speech'] || optionsParam\n };\n }\n}", "title": "" }, { "docid": "b1c4874249c259a42ef66165fafbb777", "score": "0.46287316", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x9ba29cc1;\n this.SUBCLASS_OF_ID = 0x211fe820;\n\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.fileReference = args.fileReference;\n this.date = args.date;\n this.mimeType = args.mimeType;\n this.size = args.size;\n this.thumbs = args.thumbs || null;\n this.dcId = args.dcId;\n this.attributes = args.attributes;\n }", "title": "" }, { "docid": "1d613d251fa427ba83a7a15e22daa32d", "score": "0.4621932", "text": "function getTextFormData(obj){\n var formData = {};\n var genre = {};\n\t\t\t var uploaded_thumb = {};\n formData.fileName = obj.find('.favo-icon span.file-name').text();\n formData.favourite = (obj.find('.favo-icon #favo').is(\":checked\")) ? 1 : 0;\n formData.title = obj.find('.title-field #title').val();\n formData.archived = (obj.find('.archieve-field .box-check').is(\":checked\")) ? 1 : 0;\n genre.value = obj.find('select#genre-field').val();\n formData.genre = genre;\n formData.tags = obj.find('#tags_tagsinput .tag .tag-text').map(function() {\n return jQuery(this).text()\n }).get();\n formData.description = obj.find('.description-field .form-control.description').val();\n formData.copyRights = obj.find('.copyright-field .copyright').val();\n formData.mkits = obj.find('.wrapped-all-checkboxes input[type=checkbox]:checked').map(function() {\n return jQuery(this).val()\n }).get();\n formData.remove_mkits = obj.find('.wrapped-all-checkboxes input[type=checkbox]:not(:checked)').map(function() {\n return jQuery(this).val()\n }).get(); \n formData.availTumbsList = obj.find('.wrapped-all-checkboxes-thumbs input[type=checkbox]').map(function() {\n return jQuery(this).val()\n }).get();\n formData.availTumbsListSelected = obj.find('.wrapped-all-checkboxes-thumbs input[type=checkbox]:checked').map(function() {\n return jQuery(this).val()\n }).get();\n if(obj.find('.video-thumbnail-field').hasClass('new-thumb-uploaded')){\n uploaded_thumb.src = obj.find('.video-thumbnail-field .preview-thumbnails img').attr('src');\n\t\t\t uploaded_thumb.name = obj.find('.video-thumbnail-field .preview-file-name .file-name').text();\n }\n else if(obj.find('.video-thumbnail-field').hasClass('new-thumb-removed')){\n uploaded_thumb.src = '';\n\t\t\t uploaded_thumb.name = '';\n }\n else{\n\t\t\t\tif(obj.find('.video-thumbnail-field .preview-thumbnails').hasClass('no-default')){\n\t\t\t\t// uploaded_thumb.src = obj.find('.video-thumbnail-field .preview-thumbnails img').attr('src');\n\t\t\t // uploaded_thumb.name = obj.find('.video-thumbnail-field .preview-file-name .file-name').text();\n formData.thumbalready = obj.find('.video-thumbnail-field .preview-thumbnails img').attr('data-fid');\t\t\t\t \n\t\t\t\t}\n\t\t\t\telse{\n uploaded_thumb.src = '';\n\t\t\t uploaded_thumb.name = '';\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\t\t\t\n formData.uploaded_thumb\t= uploaded_thumb;\t\t\t\n return formData ; \n }", "title": "" }, { "docid": "a1bca8be116a9101903e7f1f11410ab3", "score": "0.4615385", "text": "function VideoObj(url) {\n // If url is null or empty\n if (url == undefined || url == \"\") { return null; }\n \n var obj = {}; // Init OBJ\n \n // try for youtube\n var youtubeRegex = /(\\?v=|\\/\\d\\/|\\/embed\\/|\\/v\\/|\\.be\\/)([a-zA-Z0-9\\-\\_]+)/;\n var result = url.match(youtubeRegex);\n if (result) { \n obj.type = \"youtube\";\n obj.url = url;\n obj.url_id = result[2]; \n obj.element = getYtPlayer(result[2]);\n return obj; \n }\n\n // validate ted urls\n var ted_rex = /ted\\.com\\/talks\\/(.+)/;\n var validate_ted_url = url.match(ted_rex);\n if (!validate_ted_url) {\n return null;\n }\n\n // try for ted\n var ted_re = /(?:http:\\/\\/)?(?:www\\.)?ted.com\\/([a-zA-Z0-9\\-\\_]+)\\/([a-zA-Z0-9\\-\\_]+)/;\n result = url.match(ted_re);\n if (result) { \n obj.type = \"ted\";\n obj.url = url;\n obj.url_id = result[2]; \n obj.element = getTdPlayer(result[2]);\n return obj; \n }\n return null;\n }", "title": "" }, { "docid": "e1f44a210c2eca64d71ef6a2eea32b45", "score": "0.4607848", "text": "function parseValues({ title, text = null, url = null, files, params = {} } = {}) {\n\t\tif (('text' in params) && typeof text === 'string' && text.length !== 0 && (typeof url !== 'string' || url.length === 0)) {\n\t\t\tconst words = text.trim().split(' ');\n\t\t\tconst end = words.splice(-1)[0];\n\n\t\t\t/**\n\t\t\t * Check if `text` ends with a URL\n\t\t\t */\n\t\t\tif (end.startsWith('https://') || end.startsWith('http://')) {\n\t\t\t\turl = end;\n\t\t\t\ttext = words.join(' ');\n\t\t\t}\n\t\t} else if (('text' in params) && typeof text === 'string' && typeof url == 'string' && url.length === 0 && text.endsWith(url)) {\n\t\t\t/**\n\t\t\t * URL given alone and in text\n\t\t\t */\n\t\t\ttext = text.replace(url, '').trim();\n\t\t} else if (typeof text === 'string' && typeof url === 'string' && text.endsWith(url)) {\n\t\t\ttext = text.replace(url, '').trim();\n\t\t}\n\n\t\treturn { title, text, url, files, params };\n\t}", "title": "" }, { "docid": "9dae090e5bb452a48a2c1645e2e4f6eb", "score": "0.4602397", "text": "static async createTaskFromSub({ user, sub_id, task }) {\n\n const requiredFields = [\"details\"];\n requiredFields.forEach((field) => {\n if (!task.hasOwnProperty(field) || !task[field]) {\n throw new BadRequestError(\n `Required field - ${field} - missing from request body.`\n );\n }\n });\n\n const query = `\n INSERT INTO tasks (user_id, sub_id, details, priority, date)\n VALUES ((SELECT id FROM users WHERE email=$1), $2, $3, $4, $5)\n RETURNING *;\n `;\n\n const result = await db.query(query, [user.email, sub_id, task.details, task.priority, task.date]);\n\n // return new task\n return result.rows[0];\n }", "title": "" }, { "docid": "f9774c39d8e45b876de64ef9c40eb6ea", "score": "0.45969304", "text": "function makeArticle(obj){\n this.title = obj.title;\n this.category = obj.category;\n this.author = obj.author;\n this.authorUrl = obj.authorUrl;\n this.publishedOn = obj.publishedOn;\n this.body = obj.body;\n }", "title": "" }, { "docid": "48eac98fad00a566a2a0b17f97885c70", "score": "0.4594123", "text": "static initialize(obj, description, documentation, files, healthPercentage, updatedAt) { \n obj['description'] = description;\n obj['documentation'] = documentation;\n obj['files'] = files;\n obj['health_percentage'] = healthPercentage;\n obj['updated_at'] = updatedAt;\n }", "title": "" }, { "docid": "ad2e5eabc90f1c3ab39bcd1de17ffbe1", "score": "0.45926306", "text": "function Controller() {\n\n /**\n * Main information about subtitles\n * @protected\n * @type {array}\n */\n this._data = [];\n\n /**\n * Subtitle start time in seconds\n * @protected\n * @type {number}\n */\n this._time = 0;\n\n /**\n * Subtitle end time in seconds\n * @protected\n * @type {string}\n */\n this._emotion = '';\n\n /**\n * Last inserted id of form\n * @protected\n * @type {number}\n */\n this._lastInsertedId = 0;\n\n /**\n * Video duration in seconds\n * @protected\n * @type {number}\n */\n this._duration = 0;\n\n /**\n * Time interval for getCurrentTime() function\n * @type {number}\n */\n this._timeInterval = 1000;\n\n /**\n * Id of setInterval function\n * @type {number}\n */\n this._intervalId = 0;\n\n /**\n * Fadeout time of submit images\n * @type {number}\n */\n this._fadeSubmitTime = 2000;\n\n /**\n * Fadeout time of emotions images\n * @type {number}\n */\n this._fadeEmotionTime = 10000;\n}", "title": "" }, { "docid": "62715571f337b9b728e08145ec395fce", "score": "0.4586226", "text": "SetSubs(val){\n console.log(\"subs set to PhraseManager.js\");\n this.subs = JSON.parse(val);\n console.log(this.subs);\n\n }", "title": "" }, { "docid": "71eb88c4219982cddec4857069a37ad4", "score": "0.4584068", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xd31a961e;\n this.SUBCLASS_OF_ID = 0xc5af5d94;\n\n this.creator = args.creator || null;\n this.left = args.left || null;\n this.broadcast = args.broadcast || null;\n this.verified = args.verified || null;\n this.megagroup = args.megagroup || null;\n this.restricted = args.restricted || null;\n this.signatures = args.signatures || null;\n this.min = args.min || null;\n this.scam = args.scam || null;\n this.hasLink = args.hasLink || null;\n this.hasGeo = args.hasGeo || null;\n this.slowmodeEnabled = args.slowmodeEnabled || null;\n this.id = args.id;\n this.accessHash = args.accessHash || null;\n this.title = args.title;\n this.username = args.username || null;\n this.photo = args.photo;\n this.date = args.date;\n this.version = args.version;\n this.restrictionReason = args.restrictionReason || null;\n this.adminRights = args.adminRights || null;\n this.bannedRights = args.bannedRights || null;\n this.defaultBannedRights = args.defaultBannedRights || null;\n this.participantsCount = args.participantsCount || null;\n }", "title": "" }, { "docid": "cfbd47a91e592fa230a05ef9abd1e7c7", "score": "0.457536", "text": "static convertToPreboardExamItem(info = TestInformation.structure){\n const extraData = (info.extraData || {});\n return PreboardExamItem.wrap({\n examname : info.title ,\n description: info.description ,\n //reassign preboard specific data\n timelimit: info.preboardTimeLimit,\n startdate: info.preboardStartdate,\n enddate : info.preboardEnddate ,\n //reassign extraData\n indexid : extraData.indexid ,\n exammodules: extraData.exammodules,\n dateposted : extraData.dateposted ,\n });\n }", "title": "" }, { "docid": "57dfad3092cc9b68aa3f1c043aed5280", "score": "0.45732993", "text": "static initialize(obj, id, integrationType, title, description, payload, method, relativeUrl, headers) { \n obj['id'] = id;\n obj['integrationType'] = integrationType;\n obj['title'] = title;\n obj['description'] = description;\n obj['payload'] = payload;\n obj['method'] = method;\n obj['relativeUrl'] = relativeUrl;\n obj['headers'] = headers;\n }", "title": "" }, { "docid": "ed94be7dbe3b42869ea8c7412c014ebe", "score": "0.4569256", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0xeeb46f27;\n this.SUBCLASS_OF_ID = 0xbad3ff91;\n\n this.archived = args.archived || null;\n this.official = args.official || null;\n this.masks = args.masks || null;\n this.animated = args.animated || null;\n this.installedDate = args.installedDate || null;\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.title = args.title;\n this.shortName = args.shortName;\n this.thumb = args.thumb || null;\n this.thumbDcId = args.thumbDcId || null;\n this.count = args.count;\n this.hash = args.hash;\n }", "title": "" }, { "docid": "d39744799791597d4302d8baaee97ef1", "score": "0.45692182", "text": "function addBookToLibrary() {\n if (titleInput.value === \"\" || authorInput.value === \"\") { //making sure we have these required inputs filled out\n alert(\"Please fill out all required inputs to submit your book\");\n } else {\n let formData = new FormData(form); /* learned this from this thread https://stackoverflow.com/questions/41431322/how-to-convert-formdatahtml5-object-to-json*/\n let obj = Object.fromEntries(formData);\n let book = new Book(obj.title, obj.author, obj.readstatus, obj.rating); //using object destructuring to pull our form data object property values to pass as arguments to our constructor function\n myLibrary.push(book); //pushing our newly created book object into the myLibrary array\n }\n setStorage(myLibrary);\n getScore(myLibrary);\n}", "title": "" }, { "docid": "0a96e775c51f1e8d8cc829d0c28b2e93", "score": "0.4567449", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x162ecc1f;\n this.SUBCLASS_OF_ID = 0x5bbc92c3;\n\n this.url = args.url;\n this.thumbUrl = args.thumbUrl;\n this.contentUrl = args.contentUrl;\n this.contentType = args.contentType;\n this.w = args.w;\n this.h = args.h;\n }", "title": "" }, { "docid": "aa5ae7f7402d7773962bc830b8c52437", "score": "0.45669934", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x804361ea;\n this.SUBCLASS_OF_ID = 0x1aca5644;\n\n this.audioId = args.audioId;\n this.caption = args.caption;\n }", "title": "" }, { "docid": "156ff51a01a47286e795bf4cb1548c49", "score": "0.4566763", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x9c750409;\n this.SUBCLASS_OF_ID = 0x5bbc92c3;\n\n this.url = args.url;\n this.photo = args.photo;\n this.document = args.document;\n }", "title": "" }, { "docid": "309a1cc88e2f59779b9796a443f67656", "score": "0.4563708", "text": "function Song(songTitle, animeTitle, artist, type) {\n this.songTitle = songTitle;\n this.animeTitle = animeTitle;\n this.artist = artist;\n this.type = type;\n}", "title": "" }, { "docid": "3daf1759a17e4edaa76cb8d7323dfd70", "score": "0.45599085", "text": "createObj(uri, obj) {\n // Post options\n const httpOptions = {\n headers: new HttpHeaders({\n Authorization: 'Bearer ' + this.accessToken\n })\n };\n // Url\n const url = this.apiURL + uri;\n // Check form data\n if (FormUtility.needFormData(obj)) {\n obj = FormUtility.jsonToFormData(obj);\n }\n // Do request\n return this.httpClient\n .post(url, obj, httpOptions)\n .pipe(\n // Map response\n map((response) => this.parseResponse(response)));\n }", "title": "" }, { "docid": "543a15c806cce585b6a404b1225eeaac", "score": "0.45514467", "text": "function buildItem(videoId)\n{ \n let videoItem = {\n video_id: parseInt(videoId).toString(16), // <-- Set a hexadecimal ID for entry.\n timeinserted: new Date().getTime(), // <-- Set a UNIX timestamp for entry.\n video_hd: `output/adb_cb17-${videoId}-video_HD.mp4`, // <-- Directory to look for in S3.\n thumbnail: `output/adb_cb17-${videoId}-video_still_thumbnail-00001.jpg`, \n still_1: `output/adb_cb17-${videoId}-video_still-00001.jpg`,\n still_2: `output/adb_cb17-${videoId}-video_still-00002.jpg`,\n still_3: `output/adb_cb17-${videoId}-video_still-00003.jpg`,\n item_type: 'submission'\n };\n\n return videoItem;\n}", "title": "" }, { "docid": "3a1f8d58770116f9e2897ffe6ce35f9a", "score": "0.455128", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x3bda1bde;\n this.SUBCLASS_OF_ID = 0xc5af5d94;\n\n this.creator = args.creator || null;\n this.kicked = args.kicked || null;\n this.left = args.left || null;\n this.deactivated = args.deactivated || null;\n this.id = args.id;\n this.title = args.title;\n this.photo = args.photo;\n this.participantsCount = args.participantsCount;\n this.date = args.date;\n this.version = args.version;\n this.migratedTo = args.migratedTo || null;\n this.adminRights = args.adminRights || null;\n this.defaultBannedRights = args.defaultBannedRights || null;\n }", "title": "" }, { "docid": "44f3da7c1e6e754725e30fc96f64beec", "score": "0.45500508", "text": "static getInstanceFromDoc(doc) {\n return {\n id: doc.id,\n name: doc.data().name,\n description: doc.data().description,\n channels: doc.data().channels,\n categories: doc.data().categories,\n logo: doc.data().logo,\n rank: doc.data().rank,\n schedules: doc.data().schedules,\n year: doc.data().year\n }\n }", "title": "" }, { "docid": "1cc3c10862f81d9fbd47e234e269064f", "score": "0.45444325", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x1c570ed1;\n this.SUBCLASS_OF_ID = 0x3b642814;\n\n this.url = args.url;\n this.accessHash = args.accessHash;\n this.size = args.size;\n this.mimeType = args.mimeType;\n this.attributes = args.attributes;\n }", "title": "" }, { "docid": "e784efbdd380c3c659075cbedd752187", "score": "0.45429152", "text": "static initialize(obj, name, type, visible, kind, campaignsCount) { \n obj['name'] = name;\n obj['type'] = type;\n obj['visible'] = visible;\n obj['kind'] = kind;\n obj['campaignsCount'] = campaignsCount;\n }", "title": "" }, { "docid": "66a03ed4f576246a06dc5813e844bad6", "score": "0.45426172", "text": "constructor({\n chunks, _id, title, author, favicon,\n speaker = 'male', auth_token = '',\n id, image, url, domain, pinned, progress = 0\n }) {\n this.title = title;\n this.author = author;\n this.favicon = favicon || image;\n this._speaker = speaker;\n this.id = id || _id.$oid;\n\n this.chunks = chunks.map(i => ({text: i, audio: new Audio()}));\n this.length = this.chunks.length;\n this.index = 0;\n this._playingState = 'idle';\n\n this._audio = new Audio();\n this._volume = 0.8;\n\n this._word_count = getWordsCount(this.chunks.map(i => i.text).join(' '));\n this.url = url;\n this.domain = domain;\n this.auth_token = auth_token;\n this.pinned = pinned;\n\n this.progress = progress;\n }", "title": "" }, { "docid": "2f35cc04e9595bd16870dfaca38452ee", "score": "0.45423388", "text": "function makeObject(obj){\n\t// console.log(\"ovj=\",obj);\n\t// console.log();\n\ttry{\n\t\tif(obj!=undefined && obj[10]!=undefined && obj[0]!=\"Delete\"){\n\t\t\tvar newObj={};\n\t\t\tnewObj._key=calculate_key(obj);\n\t\t\tnewObj.name=obj[1];\n\t\t\tnewObj.priority=obj[2];\n\t\t\tnewObj.owner_name=obj[3];\n\t\t\tnewObj.owner_number=obj[4];\n\t\t\tnewObj.contact_person=obj[5];\n\t\t\tnewObj.contact_phone=obj[6];\n\t\t\tnewObj.address=obj[7];\n\t\t\tnewObj.location=obj[8];\n\t\t\tnewObj.description=obj[9];\n\t\t\tnewObj.facebookurl=obj[10];\n\t\t\tnewObj.fbid=calculate_key(obj);\n\t\t\tnewObj.genre=obj[11];\n\t\t\tnewObj.profile_type=\"Party Spot\";\n\t\t\tnewObj.time=obj[13];\n\t\t\tnewObj.price=obj[14];\n\t\t\tnewObj.min=obj[14];\n\t\t\tnewObj.max=obj[14];\n\t\t\tnewObj.more=obj[15];\n\t\t\tnewObj.createdat=new Date().getTime();\n\t\t\tnewObj.rsm= {\n\t\t\t\t\"email\": \"[email protected]\",\n\t\t\t\t\"name\": \"Tarun\",\n\t\t\t\t\"phone\": \"+91 97 1197 1244\"\n\t\t\t};\n\n\n\t\t\treturn newObj;\n\t\t}\n\t\treturn undefined;\n\t}\n\tcatch(err){\n\t\tconsole.log(\"eror=\",err);\n\t\treturn undefined;\n\t}\n\treturn undefined;\n}", "title": "" }, { "docid": "06ff9084eb5fcd644786eb01ece6f856", "score": "0.4537436", "text": "constructor(storyObj) {\n this.author = storyObj.author;\n this.title = storyObj.title;\n this.url = storyObj.url;\n this.username = storyObj.username;\n this.storyId = storyObj.storyId;\n this.createdAt = storyObj.createdAt;\n this.updatedAt = storyObj.updatedAt;\n\n\n }", "title": "" }, { "docid": "c9da4c4a22460342bbc63f1886f7ffc9", "score": "0.45229188", "text": "function create(req, res) {\n db.Album.findById(req.params.albumId, function(err, foundAlbum) {\n console.log(req.body);\n var newSong = new db.Song(req.body); //dangerous, in real app we'd validate incoming data. this bypasses that.\n foundAlbum.songs.push(newSong);\n foundAlbum.save(function(err, savedAlbum) {\n console.log('newSong created: ', newSong);\n res.json(newSong); // responding with just the song, some APIs may respond with parent objects\n });\n });\n }", "title": "" }, { "docid": "2c8b2e7e5070eb14f46ace3272d6bec3", "score": "0.4513066", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x40181ffe;\n this.SUBCLASS_OF_ID = 0x1523d462;\n\n this.id = args.id;\n this.accessHash = args.accessHash;\n this.fileReference = args.fileReference;\n this.thumbSize = args.thumbSize;\n }", "title": "" }, { "docid": "feeb3e58c2d9946370a26f52b11c6da1", "score": "0.45129752", "text": "createNewsObject(body, format) {\n format = this.news.getNewsObject(body, format);\n return format;\n }", "title": "" }, { "docid": "5f68100a2a193671c14c32e536743cb2", "score": "0.45115465", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x3c2884c1;\n this.SUBCLASS_OF_ID = 0xf1d0b479;\n\n this.text = args.text;\n this.url = args.url;\n this.webpageId = args.webpageId;\n }", "title": "" }, { "docid": "7b83d30fc22cf5a2eb2d3575e95bc84a", "score": "0.45106006", "text": "function loadDataToObject(tracks)\n\t{\n\t\t// Empty search results array\n\t\tsearchResults = [];\n\n\t\t// Loop through each search result\n\t\ttracks.forEach(function(track)\n\t\t{\n\t\t\t// Create new object to store data into\n\t\t\tvar song = new Song();\t\t\t\n\n\t\t\t// Strip the fat off the API results\n\t\t\tsong.id \t\t= track.id;\n\t\t\tsong.cover \t\t= track.artwork_url;\n\t\t\tsong.title \t\t= track.title;\n\t\t\tsong.username \t= track.user.username;\n\t\t\tsong.userAvatar = track.user.avatar_url;\n\t\t\tsong.streamLink = track.stream_url;\n\n\t\t\t// Load object into array\n\t\t\tsearchResults.push(song);\n\t\t});\n\n\t\t// sort data... hopefully\n\t\tsearchResults.sort(function(a, b)\n\t\t{\n\t\t\tif(a.title < b.title)\n\t\t\t{\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif(a.title > b.title)\n\t\t\t{\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t});\n\t}", "title": "" }, { "docid": "9116e256ae60675053db23de3dbe9851", "score": "0.45079726", "text": "function addSong(){\r\n var song = {};\r\n \r\n // prompt user for data\r\n song.title = prompt(\"please enter the title of the song\");\r\n song.artist = prompt(\"please enter the name of the artist of the song\");\r\n song.videoId = prompt(\"please enter the video id\");\r\n data.songs.push(song);\r\n\r\n // if the current playist isnt also the all songs playlist\r\n if(current_playlist.songs != data.songs){\r\n // add song to data\r\n var songCopy = {};\r\n songCopy.title = song.title;\r\n songCopy.artist = song.artist;\r\n songCopy.videoId = song.videoId;\r\n current_playlist.songs.push(songCopy);\r\n }\r\n updateSongPane();\r\n}", "title": "" }, { "docid": "0dff8f18bde8beb6131355dba004324d", "score": "0.45071223", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x21e753bc;\n this.SUBCLASS_OF_ID = 0x68f17f51;\n\n this.size = args.size;\n this.mimeType = args.mimeType;\n this.fileType = args.fileType;\n this.mtime = args.mtime;\n this._bytes = args.bytes;\n }", "title": "" }, { "docid": "84dbfeb9e0bcd3910de7febd0370897b", "score": "0.4506336", "text": "function Book(info) {\n this.image_url= info.imageLinks?info.imageLinks.thumbnail:'https://i.imgur.com/J5LVHEL.jpg';\n this.title = info.title || 'No title available';\n this.author=info.authors;\n this.description=info.description;\n this.isbn=info.industryIdentifiers ? info.industryIdentifiers[0].identifier: 'No isbn';\n}", "title": "" }, { "docid": "9a24fe9f3812a8cfb0c4c8cf6e09e6e2", "score": "0.4505008", "text": "constructor(args) {\n super();\n args = args || {}\n this.CONSTRUCTOR_ID = 0x4f4456d3;\n this.SUBCLASS_OF_ID = 0x1aca5644;\n\n this.text = args.text;\n this.caption = args.caption;\n }", "title": "" }, { "docid": "a3a02d72b69d1ba62cce681102fb12b0", "score": "0.45045996", "text": "constructor(storyObj) {\n this.author = storyObj.author;\n this.title = storyObj.title;\n this.url = storyObj.url;\n this.username = storyObj.username;\n this.storyId = storyObj.storyId;\n this.createdAt = storyObj.createdAt;\n this.updatedAt = storyObj.updatedAt;\n }", "title": "" } ]
78107219c6d08e880049520a0f40eab2
this method will return the union of two sets
[ { "docid": "e260cf8c4891b78a221b5934600d8362", "score": "0.8349016", "text": "union(otherSet) {\n const unionSet = new mySet();\n const firstSet = this.values;\n const secondSet = otherSet.values;\n \n firstSet.forEach((e) => unionSet.add(e));\n secondSet.forEach((e) => unionSet.add(e));\n return unionSet;\n }", "title": "" } ]
[ { "docid": "01a13b3b4e39757c77e1fc4d799bd3fd", "score": "0.84530383", "text": "union(setA, setB) {\n const unionArray = [...Array.from(setA), ...Array.from(setB)];\n let unionSet = new Set(unionArray);\n return unionSet;\n }", "title": "" }, { "docid": "2c3cb916842e092de5785ebc45268a2b", "score": "0.8407423", "text": "union(otherSet) {\n var set = new Set();\n\n this.collection.forEach(element => {\n set.add(element);\n });\n\n otherSet.values().forEach(element => {\n set.add(element);\n });\n\n return set;\n }", "title": "" }, { "docid": "b0804eb0961663ce1fede8b0e8d7b29e", "score": "0.8191742", "text": "function union(setA, setB) {\n var newSet = new Set(setA);\n setB.forEach(newSet.add, newSet);\n return newSet;\n}", "title": "" }, { "docid": "b19c97bdc51509df419699c9fa3492ea", "score": "0.81715703", "text": "union (otherSet) {\n const unionSet = new MySet()\n const firstSet = this.values()\n const secondSet = otherSet.values()\n\n firstSet.map(e => unionSet.add(e))\n secondSet.map(e => unionSet.add(e))\n\n return unionSet\n }", "title": "" }, { "docid": "604af4d317bca86d3c07abc39511353b", "score": "0.8078832", "text": "function union(setA, setB) {\n let _union = new Set(setA)\n for (let elem of setB) {\n _union.add(elem)\n }\n return _union\n}", "title": "" }, { "docid": "fa813bd1730b41cc199c8fd6e6a88690", "score": "0.8069964", "text": "union(set) {\n const newSet = new Set();\n this.values().forEach(value => {\n newSet.add(value);\n })\n set.values().forEach(value => {\n newSet.add(value);\n })\n\n return newSet;\n }", "title": "" }, { "docid": "8187074718e5e474751dc500e490cb61", "score": "0.8066208", "text": "function getUnion(list1, list2) {\n let unionSet = new Set([...list1, ...list2]);\n return [...unionSet];\n}", "title": "" }, { "docid": "991bcaa4da8b20f8afdddb9287e52838", "score": "0.8041886", "text": "function setUnion(set1, set2) {\n var newSet = new Set();\n set1.forEach(function (val) {\n newSet.add(val);\n });\n set2.forEach(function (val) {\n newSet.add(val);\n });\n var asArray = [];\n newSet.forEach(function (val) {\n asArray.push(val);\n });\n return asArray;\n}", "title": "" }, { "docid": "3f5c682b86981a4306d30f36fcc31837", "score": "0.8041729", "text": "function union(setA, setB) {\n var _union = new Set(setA);\n for (var elem of setB) {\n _union.add(elem);\n }\n return _union;\n}", "title": "" }, { "docid": "e4eb1c22d3e23d283fb72767fcba3c18", "score": "0.803479", "text": "function union(setA, setB) {\n let _union = new Set(setA);\n for (let elem of setB) {\n _union.add(elem);\n }\n return _union;\n}", "title": "" }, { "docid": "c2535960f6b9196930eadd6862643578", "score": "0.80280614", "text": "function union(setA, setB) {\n let _union = new Set(setA);\n for (let elem of setB) {\n _union.add(elem);\n }\n return _union;\n}", "title": "" }, { "docid": "773c2acc804f5bf35ee94c67667ed4f8", "score": "0.8012211", "text": "function union(sourceSet,targetValues){const unionSet=new Set(sourceSet);targetValues.forEach(value=>{unionSet.add(value);});return unionSet;}", "title": "" }, { "docid": "f7ea6c4f51cf46c6186ef6b9a40b8a82", "score": "0.7877189", "text": "function orderedMultiSetUnion(sortedA, sortedB){\n \n}", "title": "" }, { "docid": "d2622ff584b4ed72752c6463a5b2641c", "score": "0.77999145", "text": "function union(arr1, arr2) {\n return [...new Set([...arr1, ...arr2])];\n}", "title": "" }, { "docid": "99fa7d0bf19be5c764d327c4c56a5951", "score": "0.768432", "text": "union(set) {\n let unionArray = this.toArray().concat(set.toArray());\n return new AbstractSet(...unionArray);\n }", "title": "" }, { "docid": "cb8774d9bdab0368c631bd43891b4ea8", "score": "0.76219714", "text": "function union(a, b) {\n var a2 = a.filter(function() { return true; });\n b.forEach(function(e) {\n if(a.indexOf(e) == -1)\n a2.push(e);\n });\n\n return a2;\n}", "title": "" }, { "docid": "09e7423a047a3e6c320e578b05fcc491", "score": "0.7384832", "text": "union(otherPowerSet) {\n const newPowerSet = new PowerSet(this.pSet);\n const addToThis = function(element) {\n this.add(element);\n };\n otherPowerSet.pSet.forEach(addToThis, newPowerSet.pSet);\n return newPowerSet;\n }", "title": "" }, { "docid": "c9af40aee0a00162eecd4b67a0f998e7", "score": "0.73620933", "text": "function union() {\n var temp = [];\n for (var i = 0; i < arguments.length; i++) {\n temp = temp.concat(arguments[i]);\n }\n return temp.filter(function(el, index, arr) {\n return arr.indexOf(el) === index;\n });\n}", "title": "" }, { "docid": "25e8c4f99d72d2ed5edab70a8e9f195a", "score": "0.7331022", "text": "function union(a, b) {\n var set = {};\n var maxLength = Math.max(a.length, b.length);\n var result = [];\n var i, key;\n\n for (i = 0; i < maxLength; i++) {\n if (i < a.length) set[a[i]] = true;\n if (i < b.length) set[b[i]] = true;\n }\n\n for (key in set) {\n result.push(key);\n }\n return result;\n}", "title": "" }, { "docid": "ecdb010d4798d644f9ee17b1a71b2826", "score": "0.72695416", "text": "static merge(setA, setB) {\n const res = new LWWElementSet()\n\n // put setA in result set\n for (let key in setA.addSet) {\n res.insert(key, setA.addSet[key])\n }\n for (let key in setA.removeSet) {\n res.remove(key, setA.removeSet[key])\n }\n // put setB in result set\n for (let key in setB.addSet) {\n if (res.has(key)) {\n if (res.addSet[key] < setB.addSet[key]) {\n res.insert(key, setB.addSet[key])\n }\n } else {\n res.insert(key, setB.addSet[key])\n }\n }\n for (let key in setB.removeSet) {\n if (res.has(key)) {\n if (res.removeSet[key] < setB.removeSet[key]) {\n res.remove(key, setB.removeSet[key])\n }\n } else {\n res.remove(key, setB.removeSet[key])\n }\n }\n // P.S. i prefer more lines for conditions instead of longer lines, so the code will be more readable\n return res\n }", "title": "" }, { "docid": "76e5b7dad572c88aea99378df53f502f", "score": "0.7141591", "text": "function union(x, y) {\n var obj = {};\n for (var i = 0; i < x.length; i++)\n obj[x[i]] = x[i];\n for (i = 0; i < y.length; i++)\n obj[y[i]] = y[i];\n var res = [];\n for (var k in obj) {\n if (obj.hasOwnProperty(k))\n res.push(obj[k]);\n }\n return res;\n }", "title": "" }, { "docid": "b743f46e3ca294cb7be621190d6bea8b", "score": "0.69414264", "text": "function union(arrays){\n function biUnion(a1, a2){\n result = a2;\n for (i in a1){\n if (result.includes(a1[i])){ continue;}\n result.push(a1[i])\n }\n console.log(result)\n return result;\n }\n\n result = [];\n result = reduce(arguments, biUnion, result);\n return result;\n}", "title": "" }, { "docid": "499da0c47ec95793ff9137aee375e269", "score": "0.6928999", "text": "function union(arr1, arr2) {\n let union = [];\n\n arr1.forEach((element) => {\n if (!union.includes(element)) {\n union.push(element);\n }\n });\n\n arr2.forEach((element) => {\n if (!union.includes(element)) {\n union.push(element);\n }\n });\n\n console.log(union);\n}", "title": "" }, { "docid": "57d27a88a368bee26302eae9a64d6be6", "score": "0.6908053", "text": "function setUnion(first, second, compare) {\n var i = 0, j = 0;\n var len1 = first.length;\n var len2 = second.length;\n var merged = [];\n while (i < len1 && j < len2) {\n var a = first[i];\n var b = second[j];\n var v = compare(a, b);\n if (v < 0) {\n merged.push(a);\n ++i;\n } else if (v > 0) {\n merged.push(b);\n ++j;\n } else {\n merged.push(a);\n ++i;\n ++j;\n }\n }\n while (i < len1) {\n merged.push(first[i]);\n ++i;\n }\n while (j < len2) {\n merged.push(second[j]);\n ++j;\n }\n return merged;\n }", "title": "" }, { "docid": "7427054ef51218ab84ffb1f6a43fbe75", "score": "0.6878948", "text": "function Union(ar1,ar2){\n\tfor(var i=0;i<ar2.length;i++){\n\t\tif(!ar1.includes(ar2[i])){\n\t\t\tar1.push(ar2[i]);\n\t\t}\n\t}\n\treturn ar1;\n}", "title": "" }, { "docid": "2f244810517e40f6d733e2629c3555b4", "score": "0.6865811", "text": "function union(arr1, arr2) {\n let unitedArr = [];\n\n addArr(arr1, unitedArr);\n addArr(arr2, unitedArr);\n\n return unitedArr;\n}", "title": "" }, { "docid": "70b997bc63fe4bea833ec70777da3210", "score": "0.6860537", "text": "function union(arrays) {\n\n}", "title": "" }, { "docid": "70b997bc63fe4bea833ec70777da3210", "score": "0.6860537", "text": "function union(arrays) {\n\n}", "title": "" }, { "docid": "0b3660c455b9f4faa33dc3a31b25ffa1", "score": "0.68116844", "text": "function union(a, b) {\n return a.union(b).length;\n}", "title": "" }, { "docid": "9fcec9f5ae89a28f99cb7015d3d864c4", "score": "0.6792791", "text": "union(other){\n var syms = this.enum_type.members.filter((sym) =>\n this.symbols.includes(sym) || other.symbols.includes(sym)\n );\n return new Enumeration.EnumSet(this.enum_type, syms);\n }", "title": "" }, { "docid": "ffc5860d10b4c04dce9ddd2e8b7825e5", "score": "0.6755582", "text": "function union(arr1, arr2){\n let arr3 = [...arr1, ...arr2];\n let arr4 = [];\n\n for (let i = 0; i < arr3.length; i++) {\n if(arr4.indexOf(arr3[i]) === -1) {\n arr4.push(arr3[i])\n }\n }\n\n return arr4;\n}", "title": "" }, { "docid": "a571b4216e1d49b69bfc44264cf0a968", "score": "0.6752362", "text": "static or(sets) {\n let r = new IntervalSet();\n for (let s of sets) {\n r.addAll(s);\n }\n return r;\n }", "title": "" }, { "docid": "42aff23bd6535e9a713e396fc3e3317a", "score": "0.67448276", "text": "static or(sets) {\r\n let r = new IntervalSet();\r\n for (let s of sets) {\r\n r.addAll(s);\r\n }\r\n return r;\r\n }", "title": "" }, { "docid": "2ea038dc1cf38dde40b069fb477169be", "score": "0.67319316", "text": "or(set) {\n const data = this.data;\n const other = set.data;\n const minWords = Math.min(data.length, other.length);\n const words = Math.max(data.length, other.length);\n const dest = data.length === words ? data : new Uint16Array(words);\n let lastWord = -1;\n // Or those words both sets have in common\n for (let i = 0; i < minWords; i++) {\n let value = dest[i] = data[i] | other[i];\n if (value !== 0) {\n lastWord = i;\n }\n }\n // Copy words from larger set (if there is one)\n const longer = data.length > other.length ? data : other;\n for (let i = minWords; i < words; i++) {\n let value = dest[i] = longer[i];\n if (value !== 0) {\n lastWord = i;\n }\n }\n if (lastWord === -1) {\n this.data = EMPTY_DATA;\n }\n else if (dest.length === lastWord + 1) {\n this.data = dest;\n }\n else {\n this.data = dest.slice(0, lastWord);\n }\n }", "title": "" }, { "docid": "6e75cfb229e6fce587da395588bc5681", "score": "0.67174435", "text": "function union(xs, ys) {\n // for newer browsers/node we can improve performance by using\n // modern JS\n if (setExists() && Array.from) {\n // eslint-disable-next-line no-undef\n var set = new Set(xs);\n for (var y = 0; y < ys.length; y++) {\n set.add(ys[y]);\n }\n var arr = Array.from(set);\n arr.sort();\n return arr;\n }\n var obj = {};\n for (var i = 0; i < xs.length; i++) {\n obj[xs[i]] = true;\n }\n for (var j = 0; j < ys.length; j++) {\n obj[ys[j]] = true;\n }\n var keys = [];\n for (var k in obj) {\n if ({}.hasOwnProperty.call(obj, k)) {\n keys.push(k);\n }\n }\n keys.sort();\n return keys;\n}", "title": "" }, { "docid": "7a155bea52afb0b7408d7e755148feca", "score": "0.6707544", "text": "function union(arrays) {\n return reduce(arrays, function unionTwo(arrayA, arrayB) {\n const result = [];\n const arrA = [...arrayA]; // assume remove duplicates also\n const arrB = [...arrayB];\n for (let i = 0; i < arrA.length; i++) {\n result.push(arrA[i]);\n for (let j = 0; j < arrB.length; j++) {\n if (arrA[i] == arrB[j]) {\n arrB[j] = undefined;\n }\n }\n }\n for (let i = 0; i < arrB.length; i++) {\n if (arrB[i] != undefined) {\n result.push(arrB[i]);\n }\n }\n return result;\n }, arrays[0])\n}", "title": "" }, { "docid": "2fa992ccb0ec14d785bde31532d3c50a", "score": "0.66916674", "text": "function unionAll() {\n var union = [];\n for (var i = 0, l = arguments.length; i < l; i++)\n union = union.concat.apply(union, arguments[i]);\n return union;\n }", "title": "" }, { "docid": "2fa992ccb0ec14d785bde31532d3c50a", "score": "0.66916674", "text": "function unionAll() {\n var union = [];\n for (var i = 0, l = arguments.length; i < l; i++)\n union = union.concat.apply(union, arguments[i]);\n return union;\n }", "title": "" }, { "docid": "f2e8bb63f06efc3bc53ad3e3ac404de9", "score": "0.6639246", "text": "difference(otherSet) {\n var set = new Set();\n\n this.collection.forEach(element => {\n if (!otherSet.has(element)) {\n set.add(element);\n }\n });\n\n return set;\n }", "title": "" }, { "docid": "9ade0d1464fd318565d691baffc90212", "score": "0.6634713", "text": "function union(arrs) {\n var results = [];\n var i = -1, len = arguments.length;\n while (++i < len) {\n append(results, arguments[i]);\n }\n\n return unique(results);\n }", "title": "" }, { "docid": "08c744056a24c1c347e5a22db59de25c", "score": "0.6595672", "text": "function computeUnion(array1, array2) {\n\n}", "title": "" }, { "docid": "2ff1d3205b1b715424c0c3652e46a445", "score": "0.65759873", "text": "function union(arrayOne, arrayTwo) {\n return arrayOne.concat(arrayTwo)\n .sort()\n .filter((val, idx, arr) => val !== arr[idx + 1]);\n}", "title": "" }, { "docid": "4059029ac454d45b589fa7b4cb0d5ad8", "score": "0.6544296", "text": "static union(arr1, arr2) {\n // arr2 not empty\n if (arr2.length > 0) {\n arr2.forEach(element => {\n arr1.push(element)\n })\n }\n arr2 = []\n return [arr1, arr2]\n }", "title": "" }, { "docid": "b4990acd6842f7a1b39456bc6b012c81", "score": "0.65119326", "text": "function intersect(set1, set2) {\n\tif(!set1.length) { return []; }\n\tif(memberQ(car(set1), set2)) {\n\t\treturn cons(car(set1), intersect(cdr(set1), set2));\n\t} else {\n\t\treturn intersect(cdr(set1), set2);\n\t}\n}", "title": "" }, { "docid": "74553e592477cc1facea50e5f04984a5", "score": "0.6431238", "text": "function union(target, source) {\n for (var i = 0, len = source.length; i < len; ++i) {\n unionSingle(target, source[i]);\n }\n }", "title": "" }, { "docid": "74553e592477cc1facea50e5f04984a5", "score": "0.6431238", "text": "function union(target, source) {\n for (var i = 0, len = source.length; i < len; ++i) {\n unionSingle(target, source[i]);\n }\n }", "title": "" }, { "docid": "f0372686c8dc90a8bd9641400458ae59", "score": "0.64303505", "text": "intersection(otherSet) {\n const intersectionSet = new mySet();\n const firstSet = this.values;\n firstSet.forEach((e) => {\n if (otherSet.has(e)) {\n intersectionSet.add(e);\n }\n });\n return intersectionSet;\n }", "title": "" }, { "docid": "c8a5b17940655f617f4ad7b3f8f5cb03", "score": "0.6416424", "text": "function myFunction(set1, set2) {\n const group = [...set1,...set2];\n return newSet = new Set(group);\n}", "title": "" }, { "docid": "d6ed6225b19c1a0f0ae1650eb98459b0", "score": "0.641271", "text": "function Set() {\n\n //we could use array too, but with an object in JS we cannot set two different properties, so this resolves the duplicate problem.\n let items = {};\n\n this.has = function (value) {\n // hasOwnProperty method returns true if has value we passed through the param.\n return items.hasOwnProperty(value);\n };\n\n this.add = function (value) {\n //if the value is not in items so we add to it.\n if (!this.has(value)) {\n //we are adding value like the key and value, because adding it like key can help us to find it (hasOwnProperty).\n items[value] = value;\n return true;\n }\n return false;\n };\n\n this.delete = function (value) {\n if (this.has(value)) {\n delete items[value];\n return true;\n }\n return false;\n };\n\n this.size = function () {\n //keys () method brings to us all the properties of the specified array, and then we can use the property length to see the size of this item.\n return Object.keys(items).length;\n };\n\n //method for extracting all the item values in array form\n this.values = function () {\n let values = [];\n for (let i = 0, keys = Object.keys(items); i < keys.length; i++) {\n values.push(items[keys[i]]);\n }\n return values;\n };\n\n //union - two set data, return a new set with all the all set's elements.\n this.union = function (otherSet) {\n let unionSet = new Set();\n\n let values = this.values();\n for (let i = 0; i < values.length; i++) {\n unionSet.add(values[i]);\n }\n\n values = otherSet.values();\n for (let i = 0; i < values.length; i++) {\n unionSet.add(values[i]);\n }\n\n return unionSet;\n\n };\n\n //two sets data, return a new set with just elements presents in all sets.\n this.intersection = function (otherSet) {\n let intersectionSet = new Set();\n\n let values = this.values();\n for (let i = 0; i < values.length; i++) {\n if (otherSet.has(values[i])) {\n intersectionSet.add(values[i]);\n }\n }\n return intersectionSet;\n };\n\n //two set data, return a new set with all different element between then.\n this.difference = function (otherSet) {\n let differenceSet = new Set();\n\n let values = this.values();\n for (let i = 0; i < values.length; i++) {\n if (!otherSet.has(values[i])) {\n differenceSet.add(values[i]);\n }\n }\n\n return differenceSet;\n };\n\n // subset - current set has all your values in the other set who you will compare too.\n this.subset = function (otherSet) {\n if (this.size() > otherSet.size()) {\n return false;\n } else {\n\n let values = this.values();\n //compare the current values with the values the other set,\n // if not there any value in another set, so in this way, \n //it means the current set is not a subset of the other set.\n for (let i = 0; i < values.length; i++) {\n if (!otherSet.has(values[i])) {\n return false;\n }\n }\n return true;\n }\n };\n\n}", "title": "" }, { "docid": "b14af496e3605ec0af7be4ecfe9d8cdb", "score": "0.63971466", "text": "intersection(otherSet) {\n var set = new Set();\n\n this.collection.forEach(element => {\n if (otherSet.has(element)) {\n set.add(element);\n }\n });\n\n return set;\n }", "title": "" }, { "docid": "8348cf776097750957236b840a75a054", "score": "0.6383724", "text": "difference(otherSet) {\n const differenceSet = new mySet();\n const firstSet = this.values;\n firstSet.forEach((e) => {\n if (!otherSet.has(e)) {\n differenceSet.add(e);\n }\n });\n return differenceSet;\n }", "title": "" }, { "docid": "488ce8b92740bf3d3e6f792f29fbb7ed", "score": "0.638333", "text": "function unionArray(array1, array2) {\n union = [];\n for (i = 0; i < array1.length; i++) {\n for (j = 0; j < array2.length; j++) {\n if (array1[i] == array2[j]) {\n array1[i] = \"duplicate\"; //common element will become duplicate. it will be easier to remove further.\n }\n }\n }\n //\n combineArray = joinArray(array1, array2);\n for (k = 0; k < combineArray.length; k++) {\n if (combineArray[k] != \"duplicate\") {\n union.push(combineArray[k]);\n }\n }\n console.log(union);\n}", "title": "" }, { "docid": "cd52108e1c83e5f7d44b9e6630bbe61f", "score": "0.63669014", "text": "function Union (arr1,arr2) {\n let arr3 = [...arr1]\n arr2.map(item => {\n if ( !arr3.includes(item) ) arr3 = arr3.concat(item)\n })\n console.log(arr3)\n}", "title": "" }, { "docid": "5a952739d1dc8c1559d89d67e9775ed2", "score": "0.6335879", "text": "function interSets(setA, setB) {\n\n let intersection = new Set();\n\n for(let elem of setB) {\n\n if(setA.has(elem)) {\n intersection.add(elem);\n }\n\n }\n return [...intersection];\n}", "title": "" }, { "docid": "43c566c467716d8909c900fd2ca2774b", "score": "0.630612", "text": "function unionofArray(arr1, arr2) {\n var outputArr = arr1.slice();\n for (var i = 0; i < arr2.length; i++) {\n if (!outputArr.includes(arr2[i])) {\n outputArr.push(arr2[i]);\n }\n }\n console.log(outputArr);\n}", "title": "" }, { "docid": "091113b1d900bdb8d3caf77154c2e567", "score": "0.6300904", "text": "function setDifference(set1, set2) {\n var newSet = [];\n set1.forEach(function (val) {\n if(!set2.has(val)){\n newSet.push(val);\n }\n });\n return newSet;\n}", "title": "" }, { "docid": "5b3267aef8183d3ec3b9265e5a90ff9f", "score": "0.62848645", "text": "function union(xs){\n\t\t// Convert xs to a list if it isn't one already\n\t\tif (xs.constructor != Array){\n\t\t\txs = [xs];\n\t\t}\n\n\t\t// Merge all sets containing any x in xs\n\t\tvar roots = xs.map(get),\n\t\t\theaviest = d3.max(roots.map(function(r){ return [weights[r], r]; }))[1];\n\n\t\troots.forEach(function(r){\n\t\t\tif (r != heaviest){\n\t\t\t\tweights[heaviest] += weights[r];\n\t\t\t\tparents[r] = heaviest;\n\t\t\t}\n\t\t});\n\t}", "title": "" }, { "docid": "f584c013cdcf0a4e3673b3abe5c38dee", "score": "0.62798166", "text": "function findUnion(array1, array2) {\nvar unionArray = [];\n\n for (i=0; i<array1.length; i++) { //if an element in array1 is in array2, push it to the unionArray\n if (array2.includes(array1[i])) {\n unionArray.push(array1[i])\n }\n }\n console.log(unionArray)\n}", "title": "" }, { "docid": "eafc80da41ad6875c05b12460e802add", "score": "0.62644815", "text": "union(...args) {\n return this._union('union', args);\n }", "title": "" }, { "docid": "2dee24036dfa9c0bd8ed4dc464a262e5", "score": "0.6263516", "text": "complement(set) {\n let complementSet = new Set(Array.from(this.getUniversalSet()));\n set.forEach(setNumber => {\n complementSet.delete(setNumber);\n });\n return complementSet;\n }", "title": "" }, { "docid": "7be2c27169c8d683a733e02688a58723", "score": "0.6260329", "text": "unionAll(...args) {\n return this._union('union all', args);\n }", "title": "" }, { "docid": "818798906b8e3008cb4896080a9a3d9b", "score": "0.6242377", "text": "function unionof2Array(arr1, arr2) {\n var cnctArr = arr1.concat(arr2);\n console.log(cnctArr);\n var unionArr = [];\n var newObj = {};\n cnctArr.forEach(function (val, index) {\n if (!(val in newObj))//checking weather val is already present in the object,go inside add only if not present in it\n {\n unionArr.push(val);\n newObj[val] = true;\n }\n });\n console.log(unionArr);\n}", "title": "" }, { "docid": "aa4ce0563f726c19e43df245e2719217", "score": "0.62422675", "text": "function difference (set1, set2) {\r\n\t\treturn new Set([...set1].filter(x => !set2.has(x)));\r\n\t}", "title": "" }, { "docid": "385d1ceee818113b94c92c61b954cce6", "score": "0.62187845", "text": "function intersection (set1, set2) {\r\n\t\treturn new Set([...set1].filter(x => set2.has(x)));\r\n\t}", "title": "" }, { "docid": "4b0460e95c9c5cf899f0e95448e2ef47", "score": "0.6215474", "text": "function union(key1, key2) {\n var p1 = find(key1),\n p2 = find(key2);\n if (p1 == p2) return p1;\n // Do not bother implementing union by rank. This is pretty fast too.\n // n.b., http://stackoverflow.com/a/2326676/265298\n unioned[p2] = p1;\n sizes[p1] = size(p1) + size(p2);\n delete sizes[p2];\n }", "title": "" }, { "docid": "2739a1c3e47e94c43162389f8d2ec891", "score": "0.62032366", "text": "function Union(arr1, arr2) {\n let arr3 = [...arr1];\n\n for (let j = 0; j < arr2.length; j++) {\n for (let i = 0; i < arr1.length; i++) {\n if (arr2[j] === arr1[i])\n break\n if (i === arr1.length-1 ){\n arr3 = arr3.concat(arr2[j])\n }\n }\n }\n console.log(arr3)\n}", "title": "" }, { "docid": "5af5abbc920f4a1da28ababc2a4c1a00", "score": "0.61939186", "text": "union(n1, n2) { // O(logN) => merge \n const root1 = this.root(n1);\n const weight1 = this.weight[root1];\n\n const root2 = this.root(n2);\n const weight2 = this.weight[root2];\n\n if (root1 === root2) {\n return;\n }\n\n if (weight1 < weight2) {\n this.list[root1] = root2;\n this.weight[weight2] = weight2 + weight1;\n } else {\n this.list[root2] = root1;\n this.weight[weight1] = weight2 + weight1;\n }\n }", "title": "" }, { "docid": "6afdf5e4991897913abc1811921115f5", "score": "0.6180994", "text": "function MySet() {\n this.storage = []; //we'll use array without duplicate values for storage\n\n this.has = function (value) {\n if (this.storage.indexOf(value) !== -1) {\n return true;\n }\n return false;\n };\n\n this.add = function (value) {\n if (!this.has(value)) {\n this.storage.push(value);\n }\n return this.storage;\n };\n\n this.clear = function () {\n this.storage = [];\n };\n\n this.delete = function (value) {\n if (this.has(value)) {\n this.storage.splice(this.storage.indexOf(value), 1);\n return true;\n }\n return false;\n };\n\n //combines the values of both the array and removes the duplicates\n this.union = function (secondArray) {\n let union = new MySet();\n this.storage.forEach((element) => {\n union.add(element);\n });\n secondArray.forEach((element) => {\n if (!union.has(element)) {\n union.add(element);\n }\n });\n return union;\n };\n\n //returns common values from both arrays\n this.intersection = function (secondArray) {\n let intersection = new MySet();\n this.storage.forEach((element) => {\n if (secondArray.indexOf(element) !== -1) {\n intersection.add(element);\n }\n });\n secondArray.forEach((element) => {\n if (this.has(element)) {\n intersection.add(element);\n }\n });\n return intersection;\n };\n\n // Union minus intersection\n this.difference = function (secondArray) {\n let firstSet = new MySet();\n this.storage.forEach((element) => {\n firstSet.add(element);\n });\n let union = firstSet.union(secondArray);\n let intersection = firstSet.intersection(secondArray);\n\n intersection.storage.forEach((element) => {\n union.delete(element);\n });\n\n return union;\n };\n\n //if first subset is contained in second subset\n this.subset = function (secondArray) {\n return this.storage.every((element) => {\n return secondArray.indexOf(element) !== -1;\n });\n };\n}", "title": "" }, { "docid": "d04cae65614069ab137a1dfede6df585", "score": "0.6160197", "text": "function _union2(sortedA, sortedB) {\n\tlet lenA = sortedA.length;\n\tlet lenB = sortedB.length;\n\tif( lenA === 0 ) return sortedB;\n\tif( lenB === 0 ) return sortedA;\n\t\t\n\tif( lenA === 1 && lenB === 1) {\n\t\tif(sortedA[0] === sortedB[0]) return sortedA;\n\t}\n\telse if( lenA === 1 ) return _union2(sortedB, sortedA);\n\telse if( lenB === 1 ) {\n\t\tlet b0 = sortedB[0];\n\t\tlet a0 = sortedA[0];\n\t\tif(lenA === 1 ) {\n\t\t\tif(a0 === b0) return sortedA;\n\t\t} else {\n\t\t\tif( b0 === a0 ) return sortedA;\n\t\t\tif( b0 === sortedA[lenA-1]) return sortedA;\n\t\t}\n\t}\n\tlet res = [];\n\tlet j=0, i=0;\n\t//let iA = sortedA[0];\n\tfor(; i< lenA && j< lenB; i++) {\n\t\tlet iA = sortedA[i] | 0;\n\t\tdo {\n\t\t\tlet jB = sortedB[j] | 0; \n\t\t\t//console.log(iA,jB);\n\t\t\tif(iA > jB) {\n\t\t\t\tres.push(jB);\n\t\t\t\tj++;\n\t\t\t\tif( j >= lenB) {\n\t\t\t\t\tres.push(iA);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if( iA === jB ){\n\t\t\t\tres.push(iA); \n\t\t\t\tj++;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tres.push(iA);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while( j < lenB );\n\t}\n\twhile(j<lenB) res.push(sortedB[j++]);\n\twhile(i<lenA) res.push(sortedA[i++]);\n\treturn res; \n}", "title": "" }, { "docid": "d91cb410386ef147ff5b52b8f0e62a03", "score": "0.61577916", "text": "function union(a, b) {\n if (!a || !b)\n return [];\n\n if (typeof a === 'string')\n a = a.split(',');\n if (typeof b === 'string')\n b = b.split(',');\n\n if (!Array.isArray(a))\n a = [a];\n if (!Array.isArray(b))\n b = [b];\n\n var c = [];\n for (var i = 0; i < a.length; ++i) {\n var value = a[i];\n if (b.indexOf(value) !== -1)\n c.push(value);\n }\n return c;\n }", "title": "" }, { "docid": "72f9096f61b4508193be5489d84d01e6", "score": "0.61404794", "text": "function union(arra1) {\n var newArr = []\n for (var i = 0; i < arguments.length; i++) {\n newArr = newArr.concat(arguments[i]);\n }\n var obj = {};\n\n for (var i = arra1.length - 1; i >= 0; --i)\n obj[arra1[i]] = arra1[i];\n\n for (var i = newArr.length - 1; i >= 0; --i)\n obj[newArr[i]] = newArr[i];\n\n var res = [];\n\n for (var n in obj) {\n\n if (obj.hasOwnProperty(n))\n res.push(obj[n]);\n }\n\n return res;\n\n}", "title": "" }, { "docid": "55414358a69039c6b8335c1fa6255aaf", "score": "0.61040837", "text": "function union(arr1, arr2) {\n const result = [];\n // your code here\n if (arr1.length == 0 && arr2.length == 0) {\n return \"arrays are empty\"\n } else if (arr1.length == 0 && arr2.length > 0) {\n return arr2\n } else if (arr1.length > 0 && arr2.length == 0) {\n return arr1\n } else {\n while (arr1.length > 0 && arr2.length > 0) {\n if (arr1[0] < arr2[0]) {\n result.push(arr1.shift())\n } else if (arr1[0] > arr2[0]) {\n result.push(arr2.shift())\n } else {\n result.push(arr1.shift())\n arr2.shift()\n }\n }\n }\n\n\n return result;\n}", "title": "" }, { "docid": "d145378c8c124939d5d735bc080a94cb", "score": "0.60958195", "text": "function union(arg) {\n newArr = [];\n for (let i = 0; i < arg.length; i++) {\n var arr = arg[i]\n //console.log(arr)\n for (var j = 0; j < arr.length; j++) {\n var item = arr[j]\n if (newArr.indexOf(item) == -1) {\n newArr.push(item)\n }\n }\n }\n return newArr;\n}", "title": "" }, { "docid": "427e73549e4d7fe53058a17493f3e55c", "score": "0.60883987", "text": "function arrmerge(arr1, arr2){\n\treturn arraytoset(arr1.concat(arr2));\n}", "title": "" }, { "docid": "5204f7e478556b4644e1e5d7e0857f84", "score": "0.60577786", "text": "intersect(otherPowerSet) {\n const newPowerSet = new PowerSet();\n const addToThis = function(element) {\n if (otherPowerSet.contains(element)) {\n this.add(element);\n }\n };\n this.pSet.forEach(addToThis, newPowerSet.pSet);\n return newPowerSet;\n }", "title": "" }, { "docid": "1a8576b0f627158ba456320b196c18fe", "score": "0.60428405", "text": "function mergeSets(current, additional, defaultFilter) {\n if (additional.length > 0) {\n return new Set([...current, ...additional])\n } else {\n return defaultFilter ? new Set([...current, defaultFilter]) : current;\n }\n}", "title": "" }, { "docid": "6446c4ee0f02e8022babb4dd4fd15929", "score": "0.60210323", "text": "function mergeById (setA, setB) {\n let output = Array.from(setA)\n setB.forEach(value => {\n let index = output.findIndex(existing => existing.id === value.id)\n if (index === -1) {\n output.push(value)\n } else {\n output[index] = value\n }\n })\n return output\n}", "title": "" }, { "docid": "ee8d12b3e96fbc8783e7f3d4205d2424", "score": "0.59750366", "text": "function sortedUnion(arr1, arr2) {\nconst newArray = arr1.concat(arr2);\nreturn newArray.sort((a, b) => a - b);\n}", "title": "" }, { "docid": "195aa63d63e054f9f8af35483787ee50", "score": "0.59724003", "text": "function difference(sourceSet,targetValues){const differenceSet=new Set(sourceSet);targetValues.forEach(value=>{differenceSet.delete(value);});return differenceSet;}", "title": "" }, { "docid": "40376b55b7639e54e422d6def9228053", "score": "0.59719", "text": "function mergeSets(outputSet, ...inputSets) {\n return inputSets.reduce((acc, inputSet) => {\n inputSet.forEach(el => acc.add(el));\n return acc;\n }, outputSet);\n}", "title": "" }, { "docid": "5b30ba9adeb31c83ae196eb5aacfb60f", "score": "0.5969415", "text": "function myFunction(setA, setB) {\n const intersection = new Set();\n for (const elem of setA) {\n if (setB.has(elem) === true) {\n intersection.add(elem);\n }\n }\n return intersection\n}", "title": "" }, { "docid": "ea81d86b83c34233ddbcf6b337dac41d", "score": "0.59569496", "text": "function addAll(sourceSet,targetValues){targetValues.forEach(value=>{sourceSet.add(value);});return sourceSet;}", "title": "" }, { "docid": "8b2267c70af29a1241df379ce6cc06d5", "score": "0.59558", "text": "difference(otherPowerSet) {\n const newPowerSet = new PowerSet();\n const addToThis = function(element) {\n if (! otherPowerSet.contains(element)) {\n this.add(element);\n }\n };\n this.pSet.forEach(addToThis, newPowerSet.pSet);\n return newPowerSet;\n }", "title": "" }, { "docid": "aab1a17550d8968e241c17983368bd87", "score": "0.59178334", "text": "function symmetricDifferences(setA, setB) {}", "title": "" }, { "docid": "34df522a87c90ad779eba02bdc775d45", "score": "0.59157085", "text": "function union(dest, added) {\n var destLength = dest.length;\n var addedLength = added.length;\n var returned = [];\n\n if (destLength === 0 && addedLength === 0) return returned;\n\n for (var j = 0; j < destLength; j++) returned[j] = dest[j];\n\n if (addedLength === 0) return returned;\n\n for (var i = 0; i < addedLength; i++) {\n var missing = true;\n for (j = 0; j < destLength; j++) {\n if (dest[j].uid === added[i].uid) {\n missing = false;\n break;\n }\n }\n if (missing) returned.push(added[i]);\n }\n\n return returned;\n}", "title": "" }, { "docid": "a9e8b53f4e9e8363f7e14221158de578", "score": "0.59090316", "text": "function setDiff(setA, setB){\n //removes from A all items in setA ∩ setB\n return setA.filter(function (item, pos, self){\n return !inSet(item,intersect(setA,setB));\n });\n}", "title": "" }, { "docid": "96307748e646a0504ad32e2d009ad078", "score": "0.5875583", "text": "difference(baseSet, exludeSet) {\n let differenceSet = new Set(Array.from(baseSet));\n exludeSet.forEach(setNumber => {\n differenceSet.delete(setNumber);\n });\n return differenceSet;\n }", "title": "" }, { "docid": "8dd176dfb23836a471b2c78edc4c0a52", "score": "0.5873936", "text": "function union(...args) {\n return args.flat().filter((ele, index, array) => index === array.indexOf(ele));\n}", "title": "" }, { "docid": "e46f3598ed32b350bb97ea4228f59e91", "score": "0.5867696", "text": "union(other) {\n return Interval.of(Math.min(this.a, other.a), Math.max(this.b, other.b));\n }", "title": "" }, { "docid": "1fe06e7edca93c7dc3e6fcc152330ddd", "score": "0.5857464", "text": "function mergeQueryListAndSet(queryList, set) {\n return queryList.toArray().concat(Array.from(set));\n}", "title": "" }, { "docid": "6876e6f591005065ee5ce56be8ac3b4a", "score": "0.5855205", "text": "function uniteUnique() {\n var val = [];\n for (let i = 0; i < arguments.length; i++) {\n val = val.concat(arguments[i]);\n }\n var uniq = [...new Set(val)];\n return uniq;\n}", "title": "" }, { "docid": "0984fc453f6df77bd9dadf5fe7448ebd", "score": "0.5848396", "text": "function solve(a,b) {\n let setA = new Set(a), setB = new Set(b);\n return [...(a+b)].filter(c => setA.has(c) ^ setB.has(c)).join(\"\");\n}", "title": "" }, { "docid": "8605db0d6e5de3ca1b6d1e658cc32a37", "score": "0.5844505", "text": "function MySet() {\n \n // The let collection will hold the set\n let collection;\n \n // 'has' will check for the presence of an element and return true or false\n this.has = element => (collection.indexOf(element) !== -1);\n \n // 'values' will return all the elements of the set\n this.values = () => collection;\n \n // 'add' will add an element to the set\n this.add = (element) => {\n if (!this.has(element)) {\n collection.push(element);\n return true;\n }\n return false;\n };\n \n // 'remove' will remove an element from the set\n this.remove = (element) => {\n if (this.has(element)) {\n const index = collection.indexOf(element);\n collection.splice(index, 1);\n return true;\n }\n return false;\n };\n \n // 'size' will return the size of the set\n this.size = () => collection.length;\n \n // 'union' will return the union of two sets\n this.union = (otherSet) => {\n let unionSet = new MySet();\n const firstSet = this.values();\n const secondSet = otherSet.values();\n firstSet.forEach(e => unionSet.add(e));\n secondSet.forEach(e => unionSet.add(e));\n return unionSet;\n };\n \n // 'intersection' will return the intersection of two sets as a new set\n this.intersection = (otherSet) => {\n let intersectionSet = new MySet();\n const firstSet = this.values();\n firstSet.forEach((e) => {\n if (otherSet.has(e)) intersectionSet.add(e);\n });\n return intersectionSet;\n };\n \n // 'difference' will return the differences of two sets as a new sets\n this.difference = (otherSet) => {\n let differenceSet = new MySet();\n const firstSet = this.values();\n firstSet.forEach((e) => {\n if (!otherSet.has(e)) differenceSet.add(e)\n });\n return differenceSet;\n };\n \n // 'subset' will test if the set is a subset of a different set\n this.subset = (otehrSet) => {\n const firstSet = this.values();\n return firstSet.every(value => otherSet.has(value));\n };\n}", "title": "" }, { "docid": "c4db4e9ae838dbae5623be9077a1d4e2", "score": "0.5824678", "text": "function uniteUniqueConcat(...arrays) {\n //make an array out of the given arrays and flatten it (using the spread operator)\n const flatArray = [].concat(...arrays);\n // create a Set which clears any duplicates since it's a regulat set and not a multiset\n return [...new Set(flatArray)];\n}", "title": "" }, { "docid": "3a9107f5d50f8bdc2e141a532b37e834", "score": "0.58185416", "text": "function intersectQ(set1, set2) {\n\tif(!set1.length) { return false; }\n\treturn ((memberQ(car(set1), set2)) || intersectQ(cdr(set1), set2));\n}", "title": "" }, { "docid": "495010e28cda3fc93ad5d9ef27b55d0d", "score": "0.58047247", "text": "union(pos1, pos2) {\n let numAtPos1 = this._root(pos1);\n let numAtPos2 = this._root(pos2);\n this.idArray[numAtPos1] = numAtPos2;\n }", "title": "" }, { "docid": "415f19838a88d9555a5bfa4672c3d71d", "score": "0.58028895", "text": "function UnionFind(){\n\t// Instance variables\n\tvar weights = {},\n\t\tparents = {};\n\n\t// Find and return the name of the set containing the object\n\tfunction get(x){\n\t\t// check for previously unknown object\n\t\tif (!(x in parents)){\n\t\t\tparents[x] = x;\n\t\t\tweights[x] = 1;\n\t\t\treturn x;\n\t\t} else {\n\t\t\t// find path of objects leading to the root\n\t\t\tvar path = [x],\n\t\t\t\troot = parents[x],\n\t\t\t\tcount = 0;\n\n\t\t\twhile (root != path[path.length - 1] && count <= 15){\n\t\t\t\tpath.push( root );\n\t\t\t\troot = parents[root];\n\t\t\t\tcount++;\n\t\t\t}\n\n\t\t\t// compress the path and return\n\t\t\tpath.forEach(function(ancestor){\n\t\t\t\tparents[ancestor] = root;\n\t\t\t});\n\n\t\t\treturn root;\n\t\t}\n\t}\n\n\t// Find the sets containing the objects and merge them all\n\tfunction union(xs){\n\t\t// Convert xs to a list if it isn't one already\n\t\tif (xs.constructor != Array){\n\t\t\txs = [xs];\n\t\t}\n\n\t\t// Merge all sets containing any x in xs\n\t\tvar roots = xs.map(get),\n\t\t\theaviest = d3.max(roots.map(function(r){ return [weights[r], r]; }))[1];\n\n\t\troots.forEach(function(r){\n\t\t\tif (r != heaviest){\n\t\t\t\tweights[heaviest] += weights[r];\n\t\t\t\tparents[r] = heaviest;\n\t\t\t}\n\t\t});\n\t}\n\n\t// Return a list of lists containing each group\n\tfunction groups(){\n\t\tvar groupIndex = 0,\n\t\t\tgroupToIndex = {},\n\t\t\tcurrentGroups = [[]];\n\n\t\tObject.keys(parents).forEach(function(n){\n\t\t\tvar group = get(n);\n\t\t\tif (!(group in groupToIndex)) groupToIndex[group] = groupIndex++;\n\t\t\tif (currentGroups.length <= groupToIndex[group]) currentGroups.push([]);\n\t\t\tcurrentGroups[groupToIndex[group]].push( +n );\n\t\t});\n\n\t\treturn currentGroups;\n\t}\n\n\treturn { get: get, union: union, groups: groups };\n}", "title": "" }, { "docid": "14f2e6f1264ed06fa964236301b21eb9", "score": "0.5801823", "text": "intersect(callbacks, wrap) {\n if (arguments.length === 1 || (arguments.length === 2 && isBoolean(wrap))) {\n if (!Array.isArray(callbacks)) {\n callbacks = [callbacks];\n }\n for (let i = 0, l = callbacks.length; i < l; i++) {\n this._statements.push({\n grouping: 'union',\n clause: 'intersect',\n value: callbacks[i],\n wrap: wrap || false,\n });\n }\n } else {\n callbacks = toArray(arguments).slice(0, arguments.length - 1);\n wrap = arguments[arguments.length - 1];\n if (!isBoolean(wrap)) {\n callbacks.push(wrap);\n wrap = false;\n }\n this.intersect(callbacks, wrap);\n }\n return this;\n }", "title": "" }, { "docid": "78c5d193a3900b68840b7ec301f04c7b", "score": "0.5793969", "text": "function findIntersection(set1, set2) {\n //see which set is shorter\n var temp;\n if (set2.length > set1.length) {\n temp = set2; set2 = set1; set1 = temp;\n }\n\n return set1\n .filter(function(e) { //puts in the intersecting names\n return set2.indexOf(e) > -1;\n })\n .filter(function(e,i,c) { // gets rid of duplicates\n return c.indexOf(e) === i;\n })\n}", "title": "" }, { "docid": "1c5fbb89513227a45ef93ac791261a8e", "score": "0.5791554", "text": "function getIntersect(...sets) {\n return sets.reduce((res, set) => {\n return new Set([...res].filter(item => set.has(item)));\n });\n}", "title": "" } ]
7267fc2fddb860a211088f4d0a895bf8
wait for some time before checking of watches worked
[ { "docid": "718a4248091a6fdbb3ec44378bf878f6", "score": "0.0", "text": "function pTimer_ (id, ms) {\n return new Promise(function (resolve, reject) {\n setTimeout(function(){\n resolve (id);\n } , ms);\n });\n}", "title": "" } ]
[ { "docid": "5ce20467667c973bf155d6bda72ec5f8", "score": "0.6550072", "text": "waitUntilStop() {\n // Could happen that shouldWait doesn't change if program is at rest\n // so numberChecked is used to ensure modifications are done.\n let numberChecked = 0;\n this.shouldWait = true;\n\n return new Promise((resolve) => {\n const checkIfReady = () => {\n if (!this.shouldWait) {\n resolve();\n } else if (numberChecked === 10) {\n this.shouldWait = false;\n checkIfReady();\n // resolve();\n } else {\n numberChecked++;\n setTimeout(checkIfReady, 100);\n }\n };\n checkIfReady();\n });\n }", "title": "" }, { "docid": "ab9f433c353a7d6be7d104f32ed9646e", "score": "0.6547816", "text": "static startWatching() {\n // Start the interval\n setInterval(() => {\n this.checkTasks()\n .catch(debug.error);\n }, WATCH_INTERVAL);\n\n // Do an initial check\n this.checkTasks();\n }", "title": "" }, { "docid": "1c6cde2e5ee168dbd62821c93068631d", "score": "0.63873965", "text": "function wait() {\n //do not log.debug >> called every 100ms\n var i,\n val;\n\n for (i = 0; i < sensors.brushSwitch.length; i = i + 1) {\n val = sensors.brushSwitch[i].read();\n if (val === 0) { //0 for NO (normally open switch), 1 for NC (normally closed)\n log.info('Trigger for toothbrush ' + i + ': Start Timer');\n prepCountdown(i);\n timers.lightsOut = setInterval(watchForLightsOut, 50);\n break;\n }\n }\n\n if (i >= sensors.brushSwitch.length) {\n setTimeout(wait, 100);\n }\n }", "title": "" }, { "docid": "a1b71c9c66f4c04def80774c09cb9e7f", "score": "0.61586374", "text": "function waitingForDebounce(){\n browser.sleep(1500);\n }", "title": "" }, { "docid": "5f4c79486b126134be011e4ff9838dcd", "score": "0.61048496", "text": "function waitFor(check, cb, params) {\n params = params || {};\n if (typeof cb === 'object') {\n params = cb;\n cb = params.done;\n }\n\n var milliseconds = params.interval || 30,\n j = 0;\n\n var i = setInterval(function() {\n if (check()) {\n clearInterval(i);\n cb(null);\n }\n\n if (params.timeout && params.timeout - (j * milliseconds) <= 0) {\n clearInterval(i);\n cb(new Error('timeout'));\n }\n\n j++;\n }, milliseconds);\n }", "title": "" }, { "docid": "f4280b7cce05502856d89c9f79879c7e", "score": "0.6093536", "text": "function waitForStatus()\n{\n window.setInterval(getStatus, 1000);\n}", "title": "" }, { "docid": "36546b981f0aaf153ee30f18d9998272", "score": "0.6060997", "text": "waitUntilReady () {\n const launcher = this\n\n return new Promise((resolve, reject) => {\n let retries = 0;\n (function poll () {\n debug('Waiting for Chrome', retries)\n\n launcher\n .isReady()\n .then(() => {\n debug('Started Chrome')\n resolve()\n })\n .catch((error) => {\n retries += 1\n\n if (retries > 10) {\n return reject(error)\n }\n\n return delay(launcher.pollInterval).then(poll)\n })\n }())\n })\n }", "title": "" }, { "docid": "a26d4aa1dca5c82c0380e852b91d0c48", "score": "0.6049271", "text": "function start_checkupdates(){\n console.log(\"MAIN: Checking for updates\");\n updater.updater_check_updates(version_core,global.storage_settings[\"version\"],global.storage_settings[\"version_branch\"]);\n setTimeout(function(){ start_checkupdates_refresh(); }, 30);\n}", "title": "" }, { "docid": "c6812d5ad516ed60aef41670db90b6d4", "score": "0.6046533", "text": "function start_checkupdates_refresh(){\n var update_avalable=updater.updater_get_avalable(version_core,global.storage_settings[\"version\"],global.storage_settings[\"version_branch\"]);\n\n if (update_avalable==true){\n start_updates();\n win.close();\n }else{\n if (update_avalable==null){\n setTimeout(function(){ start_checkupdates_refresh(); }, 30);\n }\n }\n}", "title": "" }, { "docid": "e440fed27cca0c5b2cc57f7c96b191d1", "score": "0.599589", "text": "function wait() {\n Utilities.sleep(500);\n}", "title": "" }, { "docid": "c823283028026b17f21b07dea6ac0380", "score": "0.5948309", "text": "function wait(ms) {\n const start = new Date().getTime();\n for (let i = 0; i < 1e7; i++) {\n if (new Date().getTime() - start > ms) {\n break;\n }\n }\n}", "title": "" }, { "docid": "70f65f84a804af45040d71799eeaa5a8", "score": "0.5914698", "text": "async waitTillCopyComplete () {\n\t\tlet lastModTime = 0;\n\t\tlet i;\n\t\tfor (i = 0; i < 60; i++) {\n\t\t\tlet fileStat;\n\t\t\tawait new Promise((resolve, reject) => {\n\t\t\t\tthis.log('Statting ' + this.filePath);\n\t\t\t\tFS.stat(this.filePath, (error, stat) => {\n\t\t\t\t\tif (error) { return reject(error); }\n\t\t\t\t\tthis.log(`Stat for ${this.filePath}: ${JSON.stringify(stat)}`);\n\t\t\t\t\tfileStat = stat;\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tconst modTime = fileStat.mtime.getTime();\n\t\t\tif (lastModTime && modTime === lastModTime) {\n\t\t\t\tthis.log('File has not changed for 1 second: ' + this.filePath);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlastModTime = modTime;\n\t\t\t}\n\n\t\t\tawait new Promise(resolve => {\n\t\t\t\tsetTimeout(resolve, 1000);\n\t\t\t});\n\t\t}\n\t\tif (i === 60) {\n\t\t\tthrow 'file too big';\n\t\t}\n\t\tthis.log('Will now process ' + this.filePath);\n\t}", "title": "" }, { "docid": "3bb819a3759227b626ecb937f210e21c", "score": "0.5880785", "text": "async function checkMsdComplete (successCallback) {\n\n const msdPath = await getMsdPath();\n\n electronLog.log('Checking drives');\n\n /* If the final timeout hasn't been cleared yet */\n if (!msdFinalTimedOut) {\n\n if (msdPath !== null) {\n\n msdCheckTimeout = setTimeout(function () {\n\n /* Send amount of time app has been waiting to main process to calculate progress */\n resetTime += MSD_RESET_CHECK_TIMEOUT_LENGTH;\n electron.ipcRenderer.send('set-bar-restart-progress', resetTime);\n\n checkMsdComplete(successCallback);\n\n }, MSD_RESET_CHECK_TIMEOUT_LENGTH);\n\n } else {\n\n clearTimeout(msdFinalTimeout);\n electron.ipcRenderer.send('set-bar-restarted');\n successCallback();\n\n }\n\n }\n\n}", "title": "" }, { "docid": "d769a170c5cf00e35007ed01d9b13356", "score": "0.58549523", "text": "enterNotificationsWatching() {\n this.watchingTimeout_ = setTimeout(() => {\n this.onSecondTick_();\n }, rflect.cal.NotificationManager.SECOND_TIMEOUT);\n if (!this.askedSystemNotificationsPermissionInTimeout_) {\n setTimeout(() => {\n this.requestSystemNotification();\n }, rflect.cal.NotificationManager.ASK_FOR_NOTIFICATIONS_TIMEOUT);\n this.askedSystemNotificationsPermissionInTimeout_ = true;\n }\n }", "title": "" }, { "docid": "2c2a1908d6cd56d4d1477be9e9da4314", "score": "0.5853696", "text": "function watchSyncing(){\n if(web3 != null && web3.isConnected()) {\n\t web3.eth.isSyncing(function(err, sync){\n\t if(!err) {\n\t // stop all app activity\n\t if(sync === true) {\n\t // we use `true`, so it stops all filters, but not the web3.eth.syncing polling\n\t web3.reset(true);\n\t } else if(sync) {\n\t // Show sync info. When your Ethereum node is not runnning for a day, your node need to be synchronized.\n\t // A message will be displayed on top of screen.\n\t //\n\t let message = \"Syncing from \"+sync.currentBlock+\" to \"+sync.highestBlock;\n\t showIntervalMessage(message);\n\t // if(debug) console.log(\"The block number where the sync started = \"+sync.startingBlock);\n\t // if(debug) console.log(\"The block number where at which block the node currently synced to already = \"+sync.currentBlock);\n\t // if(debug) console.log(\"The estimated block number to sync to = \"+sync.highestBlock);\n\t } else {\n\t // re-gain app operation\n\t // if(debug) console.log(\"startApp\");\n\t startApp();\n\t }\n\t }\n\t });\n }\n}", "title": "" }, { "docid": "e419220a82dece7dd936c3d166503e97", "score": "0.5844119", "text": "wait (callback) {\n\t\t// there can be some delay between when access is revoked and when the channel can become unsubscribed;\n\t\t// we want to test that the channel becomes unsubscribable without explicit unsubscribing and resubscibing,\n\t\t// so we inroduce an artificial delay\n\t\tsetTimeout(callback, 10000);\n\t}", "title": "" }, { "docid": "c690a1590a0666ad7bdae629e5356cc5", "score": "0.58280784", "text": "checkLaterIfStillPresent() {\n\t\tclearTimeout(this.timeout);\n\t\t/**\n\t\t * Timeout for rechecking if the presence is remaining\n\t\t * after a certain amount of time\n\t\t */\n\t\tthis.timeout = setTimeout(() => {\n\t\t\tif (this.presenceDetected) {\n\t\t\t\tlogUtil.log({\n\t\t\t\t\ttype: 'hardware',\n\t\t\t\t\ttitle: 'Long presence detected'\n\t\t\t\t});\n\t\t\t\tthis.resolve();\n\t\t\t\tthis.proximity.removeAllListeners('data');\n\t\t\t}\n\t\t}, MIN_PRESENCE_DURATION);\n\t}", "title": "" }, { "docid": "1e85e30698676ebbe477d1ca64b987d2", "score": "0.57874876", "text": "function watch() {\n\n\trequirePortalParam();\n\n\tgulp.watch( getConfig().watch.sprites, gulp.parallel( 'svgSprite' ) );\n\tgulp.watch( getConfig().watch.hb, gulp.parallel( 'compile-handlebars' ) );\n\tgulp.watch( getConfig().watch.postcss, gulp.parallel( 'postcss' ) );\n\n}", "title": "" }, { "docid": "88b63d3877767c4958f0cc65991e4bcb", "score": "0.57831603", "text": "function waitFor(cond) {return new Promise((ok,ko)=>{var tEnd=Date.now()+waitFor.timeout,ret,w4=function(){try{ret=cond();}catch(e){ret=false;}if(ret){return ok(ret);}else{if(tEnd<Date.now()){return ko();}}setTimeout(w4,waitFor.sleep);};w4();});}", "title": "" }, { "docid": "dbcd0964ceee1332cfc56e635c542fcd", "score": "0.5743785", "text": "function browserSyncWatchTask(cb) {\n $.utils.runSubtasks($.utils.getHooks('watch', $.recipes), cb);\n }", "title": "" }, { "docid": "0b09293d97da7cd1e1311b4fbf06c3e1", "score": "0.57301825", "text": "async checkConditions() {\n let currentPlayer = this.controller.currentPlayer;\n this.controller.waiting = true;\n await this.checkSwamp(currentPlayer);\n await this.checkEnd(currentPlayer);\n this.controller.waiting = false;\n }", "title": "" }, { "docid": "7a3738442bc8b020048b9af3674f75d3", "score": "0.5717732", "text": "function checkOnWait(task, item) {\n}", "title": "" }, { "docid": "8aaef1e17a30993b1447727393dac48f", "score": "0.5688631", "text": "static waitFor (cond, fn, err = 'waiting_timed_out', interval = 1000, count = 60) {\n if (count < 0) fn(new Error(err))\n else if (cond()) fn()\n else setTimeout(MongoStore.waitFor.bind(undefined, cond, fn, err, interval, --count), interval)\n }", "title": "" }, { "docid": "f5f687c140493a1dab20c368d2ab57b2", "score": "0.5675963", "text": "function startWartching(to_be_watched) {\n for( let i=0; i<to_be_watched.files.length; i++ ){\n let watcher_path = path.join(project.root_path, to_be_watched.files[i]);\n let watcher = watch(watcher_path, { recursive: false });\n active_watchers.push(watcher);\n\n watcher.on('change', function(evt, name) {\n if (evt == 'update' || evt == 'remove') {\n console.log('auto deploying', to_be_watched.files[i]);\n mainWindow.webContents.send('auto_deploy_start', project._id);\n }\n });\n\n watcher.on('error', function(err) {\n console.log('error occured on watcher for', to_be_watched.files[i]);\n watcher.close();\n console.log(`watcher for ${to_be_watched.files[i]} killed`);\n });\n }\n\n for( let i=0; i<to_be_watched.dirs.length; i++ ){\n let watcher_path = path.join(project.root_path, to_be_watched.dirs[i]);\n let watcher = watch(watcher_path, { recursive: true });\n active_watchers.push(watcher);\n\n watcher.on('change', function(evt, name) {\n if (evt == 'update' || evt == 'remove') {\n console.log('auto deploying', to_be_watched.dirs[i]);\n mainWindow.webContents.send('auto_deploy_start', project._id);\n }\n });\n\n watcher.on('error', function(err) {\n console.log('error occured on watcher for', to_be_watched.dirs[i]);\n watcher.close();\n console.log(`watcher for ${to_be_watched.dirs[i]} killed`);\n });\n }\n }", "title": "" }, { "docid": "133f068a742dff160ac1ce7b50ca26ed", "score": "0.56684184", "text": "function watchBSTask(){\r\n watch([paths.styles.src], scssTask); \r\n watch([paths.html], browserSyncReload); \r\n}", "title": "" }, { "docid": "cfc46e65d632ba7eca80ba79d1ce5f60", "score": "0.566728", "text": "function spawn_watch() {\n\tvar i = parseInt(Math.random() * 100);\n\tvar commitindex = 0;\n\tetcd.get(\"cnt/\"+i, function(err,e) {\n\t commitindex = e.node?parseInt(e.node.modifiedIndex):0;\n\t iter_swatch();\n\t});\n\tfunction iter_swatch(){\t\n\t //console.log(\"Wathing\", commitindex+1);\n\t etcd.watchIndex(\"cnt/\"+i, commitindex+1, function(err,e) {\n\t\tif (err && err.errorCode == 401) {\n\t\t return etcd.get(\"cnt/\"+i, function(err,e) {\n\t\t\tcommitindex = e.node?parseInt(e.node.modifiedIndex):0;\n\t\t\titer_swatch();\n\t\t });\n\t\t}\n\t\t// Simulate a `slow` watcher, to see that we get updates\n\t\t// even if the wather is not ready yet\n\t\tsetTimeout(iter_swatch, Math.random()* 100);\n\t\t//setImmediate(iter_watch);\n\t\t\n\t\tif (err) console.log(\"watcher\",err, e);\n\t\tif (err) return reconnect(); \n\t\ttry {\n\t\t var now = new Date(), age = new Date(e.node.value);\n\t\t if ( (output++%1000)==5)\n\t\t\tconsole.log(i, now, now - age);\n\t\t // Max time to cycle through for the setter\n\t\t // should be 100 sec, lets make some noise if the data looks stale\n\t\t // i.e older than 100 sec.\n\t\t if ( (now-age) > 110000) \n\t\t\tconsole.log(i, now, now - age, e);\n\t\t \n\t\t commitindex = e.node?parseInt(e.node.modifiedIndex):0;\n\t\t} catch(e) {}\n\t });\n\t}\n }", "title": "" }, { "docid": "d64559b8cede9e2a4ff392168150b872", "score": "0.5658559", "text": "function waiter() {\n locker = 0;\n var remaining = minInterval - (win.Date.now() - timestamp);\n\n if (remaining > 0) {\n locker = win.setTimeout(waiter, remaining);\n } else {\n fire(nextCallArgs);\n }\n }", "title": "" }, { "docid": "0bff158c4181edde17198c2dee28a1a3", "score": "0.5657253", "text": "watch(){\n\tconsole.log(\"You watched all 60 seconds of Otters Holding Hands!\");\n}", "title": "" }, { "docid": "fb1412fa02be1d444687d39c2c516061", "score": "0.5644966", "text": "function waitFor(testFx, onReady, onTimeout, start, timeout, checkInterval) {\n var condition = false,\n interval = setInterval(function() {\n if ( (new Date().getTime() - start < timeout) && !condition ) {\n // If not timeout yet and condition not yet fulfilled\n condition = testFx();\n } else {\n clearInterval(interval); // Stop this interval\n if ( !condition ) {\n // If condition still not fulfilled (timeout but condition is 'false')\n onTimeout();\n } else {\n // Condition fulfilled (timeout and/or condition is 'true')\n onReady((new Date().getTime() - start));\n }\n }\n }, checkInterval);\n}", "title": "" }, { "docid": "d572320af26e39a3378162e941ce85d6", "score": "0.5640572", "text": "waitFor_raceMeetingOverview_GearChanges() {\n if(!this.raceMeetingOverview_GearChanges.isVisible()){\n this.raceMeetingOverview_GearChanges.waitForVisible(5000);\n }\n }", "title": "" }, { "docid": "ce42f047b0f871fcb8d315c6e0b9c830", "score": "0.56404763", "text": "function check_if_monitoring_disabled()\n{\n if( !g_disable_preference_viewing )\n {\n return false;\n }\n\n var d = new Date();\n var current = d.getTime();\n\n var remaining = g_time_to_wait_for - current;\n\n if( remaining < 0 )\n {\n dump('\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n');\n dump(' *** wait for load action ::\\n' );\n dump(' *** enough time has passed, enable config monitoring again\\n' );\n dump('\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n');\n\n g_disable_preference_viewing = false;\n return false;\n }\n\n// dump('waiting, time remaining: ' + remaining );\n return true;\n}", "title": "" }, { "docid": "8759bd70cfea974f2a651248c9f8814c", "score": "0.56298935", "text": "function checkChangesCycle() {\n setInterval(checkFriendsStatus, getTimeout());\n}", "title": "" }, { "docid": "f96f5cd72905512119b332f934c7445c", "score": "0.5624776", "text": "function wait(ms){\n let then = Date.now() + ms;\n let now = Date.now();\n do{\n now = Date.now()\n } while(now < then);\n}", "title": "" }, { "docid": "c0e0acb72872d5d3010aa8706c4ce50e", "score": "0.5610059", "text": "async function pollStatusUtilSynced() {\n logger.info({\n message: 'Waiting for Tendermint to finish syncing blockchain',\n });\n if (syncing == null || syncing === true) {\n for (;;) {\n const status = await tendermintWsClient.getStatus();\n syncing = status.sync_info.syncing;\n if (syncing === false) {\n logger.info({\n message: 'Tendermint blockchain synced',\n });\n readyPromise.resolve();\n readyPromise = null;\n break;\n }\n await utils.wait(1000);\n }\n }\n}", "title": "" }, { "docid": "302c36244ed7ff5500b4eff728389a6f", "score": "0.5601893", "text": "function wait(ms){\n var start = new Date().getTime();\n var end = start;\n while(end < start + ms) {\n end = new Date().getTime();\n }\n }", "title": "" }, { "docid": "6ccd4b89bdd00213e0a5e453162440ab", "score": "0.5600913", "text": "function wait(ms){\n var d = new Date();\n var d2 = null;\n do { d2 = new Date(); }\n while(d2-d < ms);\n}", "title": "" }, { "docid": "4ae6a461d8cbb8e3106a1a45f8a172d5", "score": "0.5571036", "text": "function poll () {\n timer = win.setInterval(notify, 1000);\n }", "title": "" }, { "docid": "5980a7e3e832116999b90a6c3a486b27", "score": "0.55693173", "text": "function waitFor(milliseconds, callback) {\n setTimeout(callback, milliseconds)\n}", "title": "" }, { "docid": "6167eb6f129e79fcbbe323a12e345882", "score": "0.5556194", "text": "function timeoutCheck() {\n timeout = setTimeout(function() {\n var error = {\n name: 'Timeout',\n message: 'The action was unable to execute within the allotted time and has been stopped'\n };\n reportError(error, true);\n }, (options && options.runTimeout ? options.runTimeout * 1000 : 0));\n}", "title": "" }, { "docid": "19886cda3dd2a76421f1ca976bbea8af", "score": "0.55544376", "text": "function checkWatchedDirs() {\n var neededDirs = {};\n for (var client in clients) {\n neededDirs[clients[client].directory] = true;\n }\n\n for (var directory in watchedDirs) {\n if (!neededDirs[directory]) {\n watchedDirs[directory].close();\n delete watchedDirs[directory];\n }\n }\n}", "title": "" }, { "docid": "5a82994aeba5872b7679f9a2ebdf50c4", "score": "0.5551376", "text": "function Wait() {\r\n firstHit = true;\r\n }", "title": "" }, { "docid": "4cc2672538469ab7d012e9a87f0ef43e", "score": "0.5541935", "text": "function checkWorkers() {\n let toStop = [];\n let maxTime = GetTime() - 15000;\n for (let gameHash in heartbeat) {\n if (heartbeat[gameHash] < maxTime) toStop.push(gameHash);\n }\n\n for (let gameHash of toStop) {\n console.log(\"No heartbeat from worker \", gameHash);\n stopGame(gameHash);\n }\n // Check every 7 seconds.\n setTimeout(() => checkWorkers(), 7000);\n}", "title": "" }, { "docid": "10278782b07a58f524324b1462de0448", "score": "0.55311894", "text": "function isStalled() {\n var stallTime = player.getCurrentTime();\n\n setTimeout(function(){\n var currentTime = player.getCurrentTime();\n\n if (stallTime == currentTime) {\n beachIDRetreival();\n }\n }, 2000);\n }", "title": "" }, { "docid": "ae7a68fc1bf86455f64889b15252f8a8", "score": "0.5526713", "text": "function watchBuild() {\n request('GET', '/build/status?start=' + lines.length, function(err, result) {\n if (err) {\n exitCode = -1;\n addOutput(['Failed to watch build: ' + err.toString()]);\n return endBuild();\n }\n\n exitCode = result.exitCode;\n addOutput(result.lines);\n\n if (result.running) {\n watchBuild();\n } else {\n endBuild();\n }\n });\n}", "title": "" }, { "docid": "f12984b5e0101656742eefa590f258ac", "score": "0.5525087", "text": "async function watchBuild() {\n await observeSass();\n await observeHtml();\n await observeAssets();\n}", "title": "" }, { "docid": "24ea9297e0bc925363438ebba48b3d5c", "score": "0.5521809", "text": "function wait(ms){\n var start = new Date().getTime();\n var end = start;\n while(end < start + ms) {\n end = new Date().getTime();\n }\n}", "title": "" }, { "docid": "fe1208ca4a95bd9587411f4f9af8d217", "score": "0.55173", "text": "setToWatching() {\n\t\t__.watching = true;\n\t}", "title": "" }, { "docid": "b64367965620f8aee2b0fc2803c0ee1c", "score": "0.5511419", "text": "function wait(ms){\r\n var start = new Date().getTime();\r\n var end = start;\r\n while(end < start + ms) {\r\n end = new Date().getTime();\r\n }\r\n }", "title": "" }, { "docid": "2ae875f7eb34526ca9ae3adfe854d243", "score": "0.55039006", "text": "waitEnabled(timeout) {\n return this.then(() => {\n return this.poll(() => {\n return this._assertEnabled(true);\n }, value(timeout));\n });\n }", "title": "" }, { "docid": "25afd4028a7ca1d5e977976be8b103e8", "score": "0.5499673", "text": "function wait( callback ) {\n\t\t\tsetTimeout( callback, 0 );\n\t\t}", "title": "" }, { "docid": "25afd4028a7ca1d5e977976be8b103e8", "score": "0.5499673", "text": "function wait( callback ) {\n\t\t\tsetTimeout( callback, 0 );\n\t\t}", "title": "" }, { "docid": "25afd4028a7ca1d5e977976be8b103e8", "score": "0.5499673", "text": "function wait( callback ) {\n\t\t\tsetTimeout( callback, 0 );\n\t\t}", "title": "" }, { "docid": "d00014df0ace873843ce0264d885b55f", "score": "0.5495731", "text": "function waitForTimeBuffered(media, time, callback)\n{\n waitForTimeBuffered_media = media;\n waitForTimeBuffered_time = time;\n waitForTimeBuffered_callback = callback;\n\n if (waitForTimeBuffered_interval != 0)\n {\n window.clearInterval(waitForTimeBuffered_interval);\n waitForTimeBuffered_interval = 0;\n }\n\n waitForTimeBuffered_interval = setInterval(\"waitForTimeBuffered_check();\", 250);\n}", "title": "" }, { "docid": "d0e726f09e40b258efc32401582db59e", "score": "0.54945993", "text": "function sheduleReloadCheck(tmReloadWait)\r\n {\r\n window.setTimeout(function(){ refreshSwitchVillage(); },tmReloadWait);\r\n }", "title": "" }, { "docid": "c5b1a4afd39e907950a14a1613f203e8", "score": "0.548051", "text": "function startWatch() {\n if (watcher) return\n\n watcher = setInterval(function() {\n if (self.root[self.origin.offset]) {\n stopWatch()\n self.update()\n }\n }, 300) // is it good enought for you?)\n }", "title": "" }, { "docid": "46ad53f74990ec1e4d6fb097f15b0db7", "score": "0.5465413", "text": "function waitForChanges() {\n requests\n .changes({\n filter: \"requests/iscompleted\",\n live: true,\n })\n .on(\"change\", (change) => {\n evt.emit(change.id);\n })\n .on(\"error\", () => {\n if (process.env.NODE_ENV !== \"test\") {\n console.log(\n \"lost connection to database at\",\n DbUrl,\n \"trying to reconnect in\",\n retryMs,\n \"ms\"\n );\n }\n setTimeout(() => {\n waitForChanges();\n }, retryMs);\n });\n}", "title": "" }, { "docid": "578e884f486a720ed95bc006844c1e63", "score": "0.5464942", "text": "function sleep(clock) { //in milliseconds\n // var start = Date.now();\n for (var i = 0; i < 1e7; i++) {\n if ((Date.now()) >= clock){\n break;\n }\n }\n}", "title": "" }, { "docid": "f94b0e869e52c0b07c257832cbae92ad", "score": "0.54600674", "text": "function startCheckingUrl() {\r\n\t\ttimeout = setTimeout(timeoutHandler, timeoutLength);\r\n\t}", "title": "" }, { "docid": "fa264a11ba1756b052d0e5721f997262", "score": "0.5457915", "text": "function pollJob(){\n console.log('Bad practise: Poll Job Ping Pong at: ' + (new Date()));\n $timeout(pollJob, 5000);\n }", "title": "" }, { "docid": "384051c0a5875ac8b0f5a3af5582fd00", "score": "0.54569596", "text": "function watchingfile() {\n\tfilesystem.watchFile('test/'+file_name, function (curr, prev) {\n\t\tnew_write();\n\t\tfilesystem.unwatchFile('test/'+file_name);\n\t});\n}", "title": "" }, { "docid": "9a560d4c1921c91c955d678d75814698", "score": "0.5452576", "text": "requestCheck() {\n this[kMonitor].requestCheck();\n }", "title": "" }, { "docid": "b91c8fa179f719845f87744cbe2d0260", "score": "0.54502946", "text": "startWatch() {\n\t\tthis.watch.toggle(true);\n\t}", "title": "" }, { "docid": "fe5d69ac7c9dba763ffc83c64e1915a9", "score": "0.54493344", "text": "startChecking() {\n if (this.pollingInterval) clearInterval(this.pollingInterval)\n this.pollingInterval = setInterval(this.check.bind(this), 1000)\n }", "title": "" }, { "docid": "fefe75fdc941b5a253e90ed06576df83", "score": "0.5449254", "text": "function wait(ms) {\n\tvar start = Date.now(), now = start;\n\twhile (now - start < ms) {\n\t\tnow = Date.now();\n\t}\n}", "title": "" }, { "docid": "956649914935daf9ffd0d17961c1f006", "score": "0.5427075", "text": "function wait(ms){\r\n var start = new Date().getTime();\r\n var end = start;\r\n while(end < start + ms) {\r\n end = new Date().getTime();\r\n }\r\n}", "title": "" }, { "docid": "956649914935daf9ffd0d17961c1f006", "score": "0.5427075", "text": "function wait(ms){\r\n var start = new Date().getTime();\r\n var end = start;\r\n while(end < start + ms) {\r\n end = new Date().getTime();\r\n }\r\n}", "title": "" }, { "docid": "66b17f2d5286d72d5bcc64eb45ebf2a4", "score": "0.5423762", "text": "skipWaiting() {}", "title": "" }, { "docid": "9946e2bcd1f8ceb56d7f676ed6260fd5", "score": "0.5418706", "text": "function wait(ms){\n var start = new Date().getTime();\n var end = start;\n while(end < start + ms) {\n end = new Date().getTime();\n }\n}", "title": "" }, { "docid": "9946e2bcd1f8ceb56d7f676ed6260fd5", "score": "0.5418706", "text": "function wait(ms){\n var start = new Date().getTime();\n var end = start;\n while(end < start + ms) {\n end = new Date().getTime();\n }\n}", "title": "" }, { "docid": "d13919e4776a44f3ef66882f2da9d0a5", "score": "0.5416571", "text": "function checkChromeAndNotify() {\n if ( !getChromeVersion(false) ) {\n chrome.runtime.sendMessage({chromeNeedsUpdate: true});\n}\n\n}", "title": "" }, { "docid": "bc99d5756cc9b7b714344c39f71792de", "score": "0.5415272", "text": "initWatch() {\n if(this.watchFlag) this.watch();\n }", "title": "" }, { "docid": "0649be905ffbbb5fce8a6527f34068d9", "score": "0.5414887", "text": "function watchWorker(rpcWorkerHandle, pingTime) {\n return new Promise((resolve, reject) => {\n let pingIsOK = true\n const watcherInterval = setInterval(() => {\n if (!pingIsOK) {\n clearInterval(watcherInterval)\n reject(\n new Error(\n `worker look longer than ${pingTime} ms to respond. terminated.`,\n ),\n )\n } else {\n pingIsOK = false\n rpcWorkerHandle.call('ping').then(() => {\n pingIsOK = true\n })\n }\n }, pingTime)\n })\n}", "title": "" }, { "docid": "406c1da9ce1a9707ec36f9699caec6fe", "score": "0.54113656", "text": "function delay2(){\n\n browser.elementByCss('#global-logo > div > a').displayed().should.eventually.equal(true)\n .notify(done); \n }", "title": "" }, { "docid": "33491c9f2648221a19d86a5bfe6da372", "score": "0.5404775", "text": "function wsleep( ms ) { return new Promise( resolve => setTimeout( resolve , ms ) ); }", "title": "" }, { "docid": "a8b3a61d1a9f7fc68ec5b618b2ad0c1a", "score": "0.5404773", "text": "sleep(milliseconds) {\n var start = new Date().getTime();\n for (var i = 0; i < 1e7; i++) {\n if ((new Date().getTime() - start) > milliseconds){\n break;\n }\n }\n }", "title": "" }, { "docid": "71893276c258eb833e993657f391fcbb", "score": "0.5402581", "text": "function waitForSlotChange() {\n return new Promise(setTimeout);\n}", "title": "" }, { "docid": "8d4dbe715d0c3abb064e6dfe5de24237", "score": "0.54005414", "text": "function watch() {\n scrollNs.isBusy = true;\n $timeout(function() {\n listElms = getListElms();\n ngCheckAnim().then(function() {\n //handle images\n handleImage();\n $timeout(function() {\n //to handle scroll appearance\n reflowGrids();\n });\n });\n });\n }", "title": "" }, { "docid": "ed52dd12c12ba057e235fed8a8117583", "score": "0.5396817", "text": "checkWatch() {\n if (this._watched && this._observers.real_size === 0 && this._children.real_size === 0) {\n this._watched = false;\n if (this.idx != null)\n queue.delete(this);\n this.unwatched();\n }\n else if (!this._watched && this._observers.real_size + this._children.real_size > 0) {\n this._watched = true;\n this.watched();\n }\n }", "title": "" }, { "docid": "f7734f2d5f7b9302d4f77e4024441eff", "score": "0.5395484", "text": "function wait(callback) {\n \tsetTimeout(callback, 0);\n }", "title": "" }, { "docid": "f7734f2d5f7b9302d4f77e4024441eff", "score": "0.5395484", "text": "function wait(callback) {\n \tsetTimeout(callback, 0);\n }", "title": "" }, { "docid": "f7734f2d5f7b9302d4f77e4024441eff", "score": "0.5395484", "text": "function wait(callback) {\n \tsetTimeout(callback, 0);\n }", "title": "" }, { "docid": "d47549f2829a923c8e6739dbc957de3f", "score": "0.53906214", "text": "function waitFor(start, ival, done) {\n setTimeout(function () {\n if (done()) return\n var clear = setInterval(function () {\n if (done()) {\n clearInterval(clear)\n }\n }, ival)\n }, start)\n}", "title": "" }, { "docid": "5bd20e7377793e20746325c38b1ef054", "score": "0.53860307", "text": "function wait(times, interval, callback) {\n Delay.setEditorTimeout(editor, function () {\n resize({});\n\n if (times--) {\n wait(times, interval, callback);\n } else if (callback) {\n callback();\n }\n }, interval);\n }", "title": "" }, { "docid": "c2f7cf66d704728f7d7e3989927a8cbe", "score": "0.5384747", "text": "function waitForScript() {\n Utilities.sleep(60000);\n}", "title": "" }, { "docid": "b51ddd692e6b039cd37ca98cb8dd3cf1", "score": "0.53801894", "text": "function onDeviceReady() {\n startWatch();\n}", "title": "" }, { "docid": "5489865f67699cfb3679f4f8d0eae198", "score": "0.53745896", "text": "async function waitForTime (page) {\n let pageText = await page.$$eval('.a-alert-heading', alerts => alerts.map(alert => alert.innerText));\n console.log(pageText[0]);\n let count = 0;\n while (pageText[0] == 'Due to increased demand, available windows are limited. Please check back later or shop a Whole Foods Market near you.') {\n count = count + 1;\n console.log(`refresh #${count}`);\n if (count % 30 === 0) {\n await page.screenshot({path: `time-slot-example-${count/30}.png`})\n }\n await page.waitFor(5000)\n await page.reload({ waitUntil: ['networkidle0', 'domcontentloaded'] });\n pageText = await page.$$eval('.a-alert-heading', alerts => alerts.map(alert => alert.innerText));\n }\n return true;\n}", "title": "" }, { "docid": "9c378fcee5c4094ffab0a811b6c6120c", "score": "0.5374142", "text": "function waitForDone() {\n var req_count = req_counter\n setTimeout(function() {\n if (req_count == req_counter) {\n console.log(getTimeString()+' DONE')\n process.exit(0)\n } else {\n waitForDone()\n }\n }, 5000)\n }", "title": "" }, { "docid": "bc0b76a2e81c14af4fba55fdff05e353", "score": "0.5370943", "text": "function countWatch() {\n watchCount++;\n var curDigest = { start: Date.now() };\n recentDigests.push(curDigest);\n setTimeout(function(){\n curDigest.end = Date.now();\n curDigest.duration = curDigest.end - curDigest.start;\n },0); // measure the compute time of the digest loop by assuming it's blocking\n }", "title": "" }, { "docid": "6437d8ab0b40a2f67fce0ed8a771041a", "score": "0.53704983", "text": "function waitThreeSecounds() {\n var ms = 3000 + new Date().getTime();\n while (new Date() < ms) {}\n console.log('finished function');\n}", "title": "" }, { "docid": "d8efaec1173d86e00657d05ba49c50e9", "score": "0.53667533", "text": "function sch_next_check() {\n\t\tclearTimeout(checkPeriodically);\n\t\tcheckPeriodically = setTimeout(function () {\n\t\t\ttry {\n\t\t\t\tws_server.check_for_updates(null);\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\tconsole.log('');\n\t\t\t\tlogger.error('Error in sch next check\\n\\n', e);\n\t\t\t\tsch_next_check();\n\t\t\t\tws_server.check_for_updates(null);\n\t\t\t}\n\t\t}, cp.getBlockDelay() + 2000);\n\t}", "title": "" }, { "docid": "878875e46c112eaf65a1ff927e92b260", "score": "0.5364865", "text": "async syncCheck () {\n await this.__chooseHost()\n\n logger.debug(`Sending wake-up check to relay node ${this.host}`)\n\n try {\n await this.__get(`${this.host}/internal/syncCheck`)\n } catch (error) {\n logger.error(`Could not sync check: ${error.message}`)\n }\n }", "title": "" }, { "docid": "a9ad5b448a1d00f67325908a9bb054cf", "score": "0.53566", "text": "function check() {\n if(!jpnode) {\n return;\n }\n for (var i = 0; i < soundObjects.length; i++) {\n if(soundObjects[i].isInAnyRegion() ||\n (soundObjects[i].stacked && soundObjects[i].stack.sos[0].isInAnyRegion())) {\n soundObjects[i].gain.gain.value = 1;\n } else {\n soundObjects[i].gain.gain.value = 0;\n }\n }\n if((new Date().getTime() - timer) >= (60000 / tempo)*4) {\n //one bar has passed\n MetronomeSoundObject.play();\n timer = new Date().getTime();\n for (var i = 0; i < soundObjects.length; i++) {\n window.setTimeout(playDelayedSoundClosure, soundObjects[i].delay, i);\n }\n }\n}", "title": "" }, { "docid": "466c4a0658d63feed33b9c60fc088477", "score": "0.5350302", "text": "function sleep(msec){\n\tvar start = new Date().getTime();\n\tfor (var i = 0; i < 1e7; i++){\n\t\tif (new Date().getTime() - start > msec){\n\t\t\tbreak;\n\t\t}\n\t}\n}", "title": "" }, { "docid": "1e2a8c75bd119522abd970bbacd7bae1", "score": "0.53472203", "text": "function waitForPause(){\n\tconsole.log(\"Waiting...\");\n\tloopBreak+=1;\n\tsetTimeout(function(){\n\t\tif(!pauseEvents || loopBreak>=5){decideNextMove();}\n\t\telse{waitForPause();}\n\t}, 10000);\n}", "title": "" }, { "docid": "774781a6a7ee79effb9b8ca6e2aed79a", "score": "0.5336607", "text": "function autoMine() {\n console.log('automine check');\n mine((block) => {\n var waitTime = Math.floor(Math.random() * 20000) + 5000; // TODO: make config vars\n setTimeout(autoMine,waitTime);\n });\n}", "title": "" }, { "docid": "01bfd04d25d1702c272094e52dd2bb4d", "score": "0.533608", "text": "async function scanning(){\n while(shouldScan){\n console.log('scanning')\n if(store.get('default_path') != null){\n files = fs.readdirSync(store.get('default_path'));\n if(files.length > 0){\n fs.rename(store.get('default_path') + \"/\" + files[0], store.get('default_path') + \"/encounter\", err => {\n if (err) {\n console.error(err)\n return\n }\n })\n console.log('should have shown')\n win.show()\n shouldScan = false\n }\n }\n await sleep(1000)\n }\n}", "title": "" }, { "docid": "192ca6ff0261a9b0bd4730857a889856", "score": "0.53320086", "text": "function runner(){\n ping()\n setTimeout( () => {\n if (current_progress_status !== \"Done\" && current_progress_status !== \"Out of Space\") {\n runner();\n }\n }, 1000)\n}", "title": "" }, { "docid": "eb5a3f25e0e1934184d2c7d1700a8a40", "score": "0.5329159", "text": "function checkBusy() {\n var now = performance.now();\n var delta = now - last;\n last = now;\n\n // if we're more than 2x the polling interval + deviation, we missed one period\n // completely\n while (delta > ((BUSY_POLLING_INTERVAL * 2) + BUSY_ALLOWED_DEVIATION_MS)) {\n total++;\n late++;\n\n // adjust by the interval, and check again\n delta -= BUSY_POLLING_INTERVAL;\n }\n\n // total intervals increased by one\n total++;\n\n // late intervals increased by one if we're more than the interval + deviation\n if (delta > (BUSY_POLLING_INTERVAL + BUSY_ALLOWED_DEVIATION_MS)) {\n late++;\n }\n }", "title": "" }, { "docid": "aef95d4384608c5e44ee1b9618c3f25a", "score": "0.532823", "text": "function watch() {\n gulp.watch(watchFiles, ['test']);\n}", "title": "" }, { "docid": "f5f3ee961686a2c6047dce580fedb096", "score": "0.5325128", "text": "function waitForFile(file, ms)\n{\n var thread = Components.classes[\"@mozilla.org/thread-manager;1\"].getService(Components.interfaces.nsIThreadManager).currentThread;\n var start = new Date().getTime();\n while (!FileIO.exists(file) && new Date().getTime() - start < ms) {\n thread.processNextEvent(true);\n }\n return FileIO.exists(file);\n}", "title": "" }, { "docid": "67dee7286c4f6bd548b58f3d5eaf8cb2", "score": "0.5323519", "text": "function checkForUpdate () {\n store.setState('checking')\n ipcRenderer.send('auto-updater-channel', 'check-for-update')\n}", "title": "" } ]